Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/models/data-fabric/entities.models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export interface EntityServiceModel {
* // First, get records to obtain the record ID
* const records = await entities.getAllRecords(<entityId>);
* // Get the recordId for the record
* const recordId = records.items[0].id;
* const recordId = records.items[0].Id;
* // Get the record
* const record = await entities.getRecordById(<entityId>, recordId);
*
Expand Down Expand Up @@ -293,14 +293,14 @@ export interface EntityServiceModel {
* ```typescript
* // Basic usage
* const result = await entities.updateRecordsById(<entityId>, [
* { id: "123", name: "John Updated", age: 31 },
* { id: "456", name: "Jane Updated", age: 26 }
* { Id: "123", name: "John Updated", age: 31 },
* { Id: "456", name: "Jane Updated", age: 26 }
* ]);
*
* // With options
* const result = await entities.updateRecordsById(<entityId>, [
* { id: "123", name: "John Updated", age: 31 },
* { id: "456", name: "Jane Updated", age: 26 }
* { Id: "123", name: "John Updated", age: 31 },
* { Id: "456", name: "Jane Updated", age: 26 }
* ], {
* expansionLevel: 1,
* failOnFirst: true
Expand Down Expand Up @@ -355,15 +355,15 @@ export interface EntityServiceModel {
* // First, get records to obtain the record ID
* const records = await entities.getAllRecords("<entityId>");
* // Get the recordId for the record that contains the attachment
* const recordId = records.items[0].id;
* const recordId = records.items[0].Id;
*
* // Get the entityId from getAll()
* const allEntities = await entities.getAll();
* const entityId = allEntities[0].id;
*
* // Get the recordId from getAllRecords()
* const records = await entities.getAllRecords(entityId);
* const recordId = records[0].id;
* const recordId = records[0].Id;
*
* // Download attachment using service method
* const response = await entities.downloadAttachment(entityId, recordId, 'Documents');
Expand Down Expand Up @@ -416,7 +416,7 @@ export interface EntityServiceModel {
*
* // Get the recordId from getAllRecords()
* const records = await entities.getAllRecords(entityId);
* const recordId = records[0].id;
* const recordId = records[0].Id;
*
* // Browser: Upload a file from an input element
* const fileInput = document.getElementById('file-input') as HTMLInputElement;
Expand Down Expand Up @@ -450,7 +450,7 @@ export interface EntityServiceModel {
*
* // Get the recordId from getAllRecords()
* const records = await entities.getAllRecords(entityId);
* const recordId = records[0].id;
* const recordId = records[0].Id;
*
* // Delete attachment for a specific record and field
* await entities.deleteAttachment(entityId, recordId, 'Documents');
Expand Down
2 changes: 1 addition & 1 deletion src/models/data-fabric/entities.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface EntityRecord {
/**
* Unique identifier for the record
*/
id: string;
Id: string;

/**
* Additional dynamic fields for the entity
Expand Down
40 changes: 12 additions & 28 deletions src/services/data-fabric/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { ENTITY_PAGINATION, ENTITY_OFFSET_PARAMS } from '../../utils/constants/c
import { DATA_FABRIC_ENDPOINTS } from '../../utils/constants/endpoints';
import { RESPONSE_TYPES } from '../../utils/constants/headers';
import { createParams } from '../../utils/http/params';
import { pascalToCamelCaseKeys, transformData } from '../../utils/transform';
import { transformData } from '../../utils/transform';
import { EntityFieldTypeMap, SqlFieldType, EntityMap } from '../../models/data-fabric/entities.constants';
import { track } from '../../core/telemetry';

Expand Down Expand Up @@ -178,13 +178,9 @@ export class EntityService extends BaseService implements EntityServiceModel {
{ params }
);

// Convert PascalCase response to camelCase
const camelResponse = pascalToCamelCaseKeys(response.data);
// Apply EntityMap transformations
const transformedResponse = transformData(camelResponse, EntityMap);
return transformedResponse;
return response.data;
}

/**
* Inserts a single record into an entity by entity ID
*
Expand Down Expand Up @@ -223,9 +219,7 @@ export class EntityService extends BaseService implements EntityServiceModel {
}
);

// Convert PascalCase response to camelCase
const camelResponse = pascalToCamelCaseKeys(response.data);
return camelResponse;
return response.data;
}

/**
Expand Down Expand Up @@ -274,9 +268,7 @@ export class EntityService extends BaseService implements EntityServiceModel {
}
);

// Convert PascalCase response to camelCase
const camelResponse = pascalToCamelCaseKeys(response.data);
return camelResponse;
return response.data;
}

/**
Expand Down Expand Up @@ -318,9 +310,7 @@ export class EntityService extends BaseService implements EntityServiceModel {
}
);

// Convert PascalCase response to camelCase
const camelResponse = pascalToCamelCaseKeys(response.data);
return camelResponse;
return response.data;
}

/**
Expand Down Expand Up @@ -370,9 +360,7 @@ export class EntityService extends BaseService implements EntityServiceModel {
}
);

// Convert PascalCase response to camelCase
const camelResponse = pascalToCamelCaseKeys(response.data);
return camelResponse;
return response.data;
}

/**
Expand Down Expand Up @@ -410,9 +398,7 @@ export class EntityService extends BaseService implements EntityServiceModel {
}
);

// Convert PascalCase response to camelCase
const camelResponse = pascalToCamelCaseKeys(response.data);
return camelResponse;
return response.data;
}

/**
Expand Down Expand Up @@ -471,7 +457,7 @@ export class EntityService extends BaseService implements EntityServiceModel {
*
* // Get the recordId from getAllRecords()
* const records = await entities.getAllRecords(entityId);
* const recordId = records[0].id;
* const recordId = records[0].Id;
*
* // Download attachment for a specific record and field
* const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
Expand Down Expand Up @@ -511,7 +497,7 @@ export class EntityService extends BaseService implements EntityServiceModel {
*
* // Get the recordId from getAllRecords()
* const records = await entities.getAllRecords(entityId);
* const recordId = records[0].id;
* const recordId = records[0].Id;
*
* // Upload a file attachment
* const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
Expand All @@ -534,9 +520,7 @@ export class EntityService extends BaseService implements EntityServiceModel {
{ params }
);

// Convert PascalCase response to camelCase
const camelResponse = pascalToCamelCaseKeys(response.data);
return camelResponse;
return response.data;
}

/**
Expand All @@ -559,7 +543,7 @@ export class EntityService extends BaseService implements EntityServiceModel {
*
* // Get the recordId from getAllRecords()
* const records = await entities.getAllRecords(entityId);
* const recordId = records[0].id;
* const recordId = records[0].Id;
*
* // Delete attachment for a specific record and field
* await entities.deleteAttachment(entityId, recordId, 'Documents');
Expand Down
38 changes: 19 additions & 19 deletions tests/integration/shared/data-fabric/entities.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>
const record = await entities.getRecordById(entityId, recordId);

expect(record).toBeDefined();
expect(record.id).toBe(recordId);
expect(record.Id).toBe(recordId);
});
});

Expand All @@ -379,13 +379,13 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>
const result = await entities.insertRecordById(entityId, testData);

expect(result).toBeDefined();
expect(result.id).toBeDefined();
expect(result.Id).toBeDefined();

serviceLevelRecordIds.push(result.id);
createdRecordIds.push(result.id);
serviceLevelRecordIds.push(result.Id);
createdRecordIds.push(result.Id);
registerResource('entityRecords', {
entityId,
recordIds: [result.id],
recordIds: [result.Id],
});
});

Expand All @@ -403,7 +403,7 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>
const record = await entities.getRecordById(entityId, recordId);

expect(record).toBeDefined();
expect(record.id).toBe(recordId);
expect(record.Id).toBe(recordId);
});

it('should batch insert multiple records using insertRecordsById', async () => {
Expand All @@ -429,8 +429,8 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>
expect(Array.isArray(result.successRecords)).toBe(true);

const insertedIds = result.successRecords
.filter((r: any) => r.Id || r.id)
.map((r: any) => r.Id || r.id);
.filter((r) => r.Id)
.map((r) => r.Id);
serviceLevelRecordIds.push(...insertedIds);
createdRecordIds.push(...insertedIds);
registerResource('entityRecords', {
Expand All @@ -456,7 +456,7 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>
// Build update payloads: each must include `Id` plus at least one updated field
const writableFields = getWritableFields(entityMetadata.fields);
const updateData: EntityRecord[] = serviceLevelRecordIds.map((id) => {
const updates = { id: id } as EntityRecord;
const updates = { Id: id } as EntityRecord;
// Update the first writable field with a new value
if (writableFields.length > 0) {
const field = writableFields[0];
Expand Down Expand Up @@ -518,13 +518,13 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>
const result = await entity.insertRecord(testData);

expect(result).toBeDefined();
expect(result.id).toBeDefined();
expect(result.Id).toBeDefined();

entityMethodRecordIds.push(result.id);
createdRecordIds.push(result.id);
entityMethodRecordIds.push(result.Id);
createdRecordIds.push(result.Id);
registerResource('entityRecords', {
entityId,
recordIds: [result.id],
recordIds: [result.Id],
});
});

Expand All @@ -549,8 +549,8 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>
expect(Array.isArray(result.successRecords)).toBe(true);

const insertedIds = result.successRecords
.filter((r: any) => r.Id || r.id)
.map((r: any) => r.Id || r.id);
.filter((r) => r.Id)
.map((r) => r.Id);
entityMethodRecordIds.push(...insertedIds);
createdRecordIds.push(...insertedIds);
registerResource('entityRecords', {
Expand Down Expand Up @@ -593,7 +593,7 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>
const record = await entity.getRecord(recordId);

expect(record).toBeDefined();
expect(record.id).toBe(recordId);
expect(record.Id).toBe(recordId);
});

it('should update records via entity.updateRecords', async () => {
Expand All @@ -611,7 +611,7 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>

const writableFields = getWritableFields(entity.fields);
const updateData: EntityRecord[] = entityMethodRecordIds.map((id) => {
const updates = { id: id } as EntityRecord;
const updates = { Id: id } as EntityRecord;
if (writableFields.length > 0) {
const field = writableFields[0];
updates[field.name] = generateFieldValue(field);
Expand Down Expand Up @@ -670,7 +670,7 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>
};

const inserted = await entities.insertRecordById(entityId, insertData);
const updateTestRecordId = inserted.id;
const updateTestRecordId = inserted.Id;

if (!updateTestRecordId) {
throw new Error('Could not get inserted record ID');
Expand All @@ -688,7 +688,7 @@ describe.each(modes)('Data Fabric Entities - Integration Tests [%s]', (mode) =>
});

expect(result).toBeDefined();
expect(result.id).toBe(updateTestRecordId);
expect(result.Id).toBe(updateTestRecordId);
});

it('should handle API errors for non-existent record', async () => {
Expand Down
Loading
Loading