fix: rewrite SDK field names in OData options for remaining services [PLT-106297]#548
fix: rewrite SDK field names in OData options for remaining services [PLT-106297]#548ninja-shreyash wants to merge 2 commits into
Conversation
…[PLT-106297] Extends PLT-102084 — applied to Jobs in #536 — to the remaining services whose field maps are used to rename API fields on responses: Queues, Assets, Buckets, Processes, Attachments, and Tasks. Without this, a consumer who reads a renamed field on a response (e.g. `processName`, `createdTime`, `folderId`) and turns around to filter / orderby / select / expand by that same name is silently rejected by the API, which only knows the original field names (`releaseName`, `creationTime`, `organizationUnitId`, …). Wire `transformOptions(options, EntityMap)` at every OData input edge that pairs with a response-side `transformData(…, EntityMap)`: - Queues: getAll, getById - Assets: getAll, getById, getByName (via shared helper) - Buckets: getFileMetaData, getFiles, getReadUri, _getWriteUri - Processes: getAll, getById, getByName, start (query options) - Attachments: getById - Tasks (action-center): getAll, getById `FolderScopedService.getByNameLookup` gains an optional `requestFieldMap` parameter so Assets/Processes can apply their respective maps inside the shared `getByName` flow before the OData `$filter=Name eq '…'` is built. Unit tests added per service mirror the Jobs pattern: assert the post-transformation shape on the call to `PaginationHelpers.getAll` / `addPrefixToKeys`. Tasks' suite identity-mocks the transform module, so its two new tests assert the wiring (that `transformOptions` is invoked with the right map) rather than the rewritten string. Refs: PLT-106297, PLT-102084 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Review summaryThree test-coverage gaps found. All three are actionable — the implementation itself looks correct. New findings
|
…st pass Address PR #548 review feedback: - buckets.test.ts: add transform-wiring assertions for getFileMetaData (filter rewrite) and getReadUri (select rewrite). The first pass only covered getFiles, leaving the two sibling methods that share the same transformOptions(restOptions, BucketMap) wiring untested. - assets.test.ts: add a getByName test that asserts an SDK-named select is rewritten to API names before the OData call. Exercises the new requestFieldMap branch in FolderScopedService.getByNameLookup. - processes.test.ts: same coverage for processes.getByName, hitting the ProcessMap-reversed rewrite (processName → releaseName, createdTime → creationTime) inside getByNameLookup. Per convention: "when sibling methods share a configuration pattern, each method needs its own test for that pattern." Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| const apiOptions = addPrefixToKeys(queryOptions, ODATA_PREFIX, keysToPrefix); | ||
| // Rewrite renamed SDK field names → API names inside OData strings, | ||
| // then prefix all query parameter keys with '$' for OData. | ||
| const apiFieldOptions = transformOptions(queryOptions, ProcessMap); |
There was a problem hiding this comment.
Per the project convention: "when sibling methods share a configuration pattern, each method needs its own test for that pattern — verifying it on one method does not cover a sibling."
getAll, getById, and getByName all received tests that verify the transformOptions + addPrefixToKeys wiring. start uses the exact same pattern here for queryOptions, but no test exercises it. If this call were accidentally dropped, no unit test would catch it.
Add a test inside the start describe block:
it('should rewrite renamed SDK field names in query options before calling the API', async () => {
const mockResponse = createMockProcessStartApiResponse([createMockProcessStartResponse()]);
mockApiClient.post.mockResolvedValue(mockResponse);
const request = PROCESS_TEST_CONSTANTS.PROCESS_START_REQUEST as ProcessStartRequest;
await service.start(request, {
folderId: TEST_CONSTANTS.FOLDER_ID,
filter: "processName eq 'InvoiceBot'",
});
// processName → releaseName (ProcessMap reversed).
expect(mockApiClient.post).toHaveBeenCalledWith(
PROCESS_ENDPOINTS.START_PROCESS,
expect.any(Object),
expect.objectContaining({
params: expect.objectContaining({
'$filter': "releaseName eq 'InvoiceBot'",
}),
}),
);
});
Review summaryOne new finding this run. New finding
|



Summary
Extends PLT-102084 — applied to Jobs in #536 — to the remaining services whose field maps rename API fields on responses: Queues, Assets, Buckets, Processes, Attachments, Tasks.
Without this, a consumer who reads a renamed field on a response (e.g.
processName,createdTime,folderId) and turns around to filter / orderby / select / expand by that same name is silently rejected by the API, which only knows the original field names (releaseName,creationTime,organizationUnitId, …).Changes
Wire
transformOptions(options, EntityMap)at every OData input edge that pairs with a response-sidetransformData(…, EntityMap):getAll,getByIdgetAll,getById,getByName(via shared helper)getFileMetaData,getFiles,getReadUri,_getWriteUrigetAll,getById,getByName,start(query options)getByIdgetAll,getByIdFolderScopedService.getByNameLookupgains an optionalrequestFieldMapparameter so Assets/Processes can apply their respective maps inside the sharedgetByNameflow before the OData$filter=Name eq '…'is built.Test plan
npm run typecheck— cleannpm run lint— 0 warnings, 0 errorsnpm run test:unit— 1948 / 1948 passing (10 new tests)npm run build— producesdist/outputPaginationHelpers.getAll/addPrefixToKeys. Tasks' suite identity-mocks the transform module, so its two new tests assert the wiring (thattransformOptionsis invoked with the right map) rather than the rewritten string.Refs: PLT-106297, PLT-102084