Skip to content

fix: rewrite SDK field names in OData options for remaining services [PLT-106297]#548

Open
ninja-shreyash wants to merge 2 commits into
mainfrom
fix/odata-transform-options-remaining-services-plt-106297
Open

fix: rewrite SDK field names in OData options for remaining services [PLT-106297]#548
ninja-shreyash wants to merge 2 commits into
mainfrom
fix/odata-transform-options-remaining-services-plt-106297

Conversation

@ninja-shreyash

@ninja-shreyash ninja-shreyash commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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-side transformData(…, EntityMap):

Service OData input edges wired
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.

Test plan

  • npm run typecheck — clean
  • npm run lint — 0 warnings, 0 errors
  • npm run test:unit — 1948 / 1948 passing (10 new tests)
  • npm run build — produces dist/ output
  • Per-service unit tests mirror the Jobs pattern from fix: rewrite SDK field names in OData filter/orderby/select/expand [PLT-102084] #536: 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

…[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>
@ninja-shreyash ninja-shreyash requested a review from a team June 23, 2026 11:04
@sonarqubecloud

Copy link
Copy Markdown

Comment thread tests/unit/services/orchestrator/buckets.test.ts
Comment thread tests/unit/services/orchestrator/assets.test.ts
Comment thread tests/unit/services/orchestrator/processes.test.ts
@claude

claude Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review summary

Three test-coverage gaps found. All three are actionable — the implementation itself looks correct.

New findings

  1. tests/unit/services/orchestrator/buckets.test.ts line 1557 — PR wires transformOptions to four Bucket methods (getFileMetaData, getFiles, getReadUri, _getWriteUri) but only adds a transform-wiring test for getFiles. Per conventions, each sibling method needs its own test.

  2. tests/unit/services/orchestrator/assets.test.ts line 275AssetService.getByName now passes AssetMap to getByNameLookup (new requestFieldMap path), but no test verifies that OData options like select are field-rewritten through that path.

  3. tests/unit/services/orchestrator/processes.test.ts line 266 — same gap for ProcessService.getByName with ProcessMap (which has the most renames of any service here).

…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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'",
      }),
    }),
  );
});

@claude

claude Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review summary

One new finding this run.

New finding

src/services/orchestrator/processes/processes.ts line 197start wires transformOptions(queryOptions, ProcessMap) for OData query options, the same pattern added to getAll, getById, and getByName. All three of those methods received a field-rewrite test in this PR, but start has none. Per conventions, each sibling method needs its own test for the shared pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant