task: add domain entities for application runs and items#60
task: add domain entities for application runs and items#60
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #60 +/- ##
==========================================
+ Coverage 96.16% 96.38% +0.22%
==========================================
Files 9 13 +4
Lines 1225 1301 +76
Branches 174 189 +15
==========================================
+ Hits 1178 1254 +76
Misses 47 47
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces domain “entity” wrappers in the SDK that enrich raw OpenAPI responses for application runs and run items with computed fields (progress, simplified status, and download eligibility), and updates PlatformSDKHttp to return these enriched entities.
Changes:
- Added
ApplicationRun+ApplicationRunItementity types, processors, and utility functions (with unit tests). - Updated
PlatformSDKHttp.listApplicationRuns(),getRun(), andlistRunResults()to return enriched entities. - Re-exported new entity APIs from the SDK entrypoint.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/sdk/src/platform-sdk.ts | Maps API responses through new processors and updates method return types. |
| packages/sdk/src/platform-sdk.test.ts | Adds assertions that enriched fields exist on SDK responses. |
| packages/sdk/src/index.ts | Exports new entity types/utilities/processors. |
| packages/sdk/src/entities/run-item/utils.ts | Adds derived item status + download eligibility helpers. |
| packages/sdk/src/entities/run-item/utils.spec.ts | Unit tests for run-item utility functions. |
| packages/sdk/src/entities/run-item/types.ts | Defines ApplicationRunItem and ItemStatus. |
| packages/sdk/src/entities/run-item/process-run-item.ts | Processor to enrich a raw run-item response. |
| packages/sdk/src/entities/run-item/process-run-item.spec.ts | Unit tests for run-item processor. |
| packages/sdk/src/entities/application-run/utils.ts | Adds derived run status/progress + download eligibility helpers. |
| packages/sdk/src/entities/application-run/utils.spec.ts | Unit tests for application-run utility functions. |
| packages/sdk/src/entities/application-run/types.ts | Defines ApplicationRun and RunStatus. |
| packages/sdk/src/entities/application-run/process-application-run.ts | Processor to enrich a raw run response. |
| packages/sdk/src/entities/application-run/process-application-run.spec.ts | Unit tests for application-run processor. |
| ATTRIBUTIONS.md | Updates recorded lodash-es version. |
packages/sdk/src/entities/application-run/process-application-run.spec.ts
Show resolved
Hide resolved
| page?: number; | ||
| pageSize?: number; | ||
| }): Promise<RunReadResponse[]> { | ||
| }): Promise<ApplicationRun[]> { |
There was a problem hiding this comment.
PlatformSDKHttp.listApplicationRuns() now returns Promise<ApplicationRun[]>, but the PlatformSDK interface still declares Promise<RunReadResponse[]>. Consumers typing against PlatformSDK won’t see the enriched fields (progress, derived status, can_download). Update the PlatformSDK interface signatures to match the enriched entity return types (or add separate methods if you need backward compatibility).
| ); | ||
|
|
||
| expect(result.status).toBe('COMPLETED'); | ||
| expect(result.can_download).toBe(false); | ||
| }); |
There was a problem hiding this comment.
This test expects a successfully completed item (TERMINATED + SUCCEEDED) to have can_download === false. If can_download is meant to represent download availability, this should be true for completed items. Update this assertion after correcting canDownloadItem.
1e3ad5b to
6de0a22
Compare
6de0a22 to
bf346d6
Compare
|
| export { ApplicationRun } from './entities/application-run/types.js'; | ||
| export { processApplicationRun } from './entities/application-run/process-application-run.js'; | ||
| export { | ||
| getRunProgress, | ||
| getRunStatus, | ||
| canDownloadRunItems, | ||
| } from './entities/application-run/utils.js'; | ||
| export { ApplicationRunItem, ItemStatus } from './entities/run-item/types.js'; | ||
| export { processRunItem } from './entities/run-item/process-run-item.js'; | ||
| export { canDownloadItem, getItemStatus } from './entities/run-item/utils.js'; |
There was a problem hiding this comment.
ApplicationRun, ApplicationRunItem, and ItemStatus are type-only exports (interface/type). Re-exporting them with export { ... } will produce runtime ESM re-exports that fail because there is no corresponding JS value export. Use export type { ... } for these type-only exports to avoid runtime/bundling errors (similar to how PlatformSDKConfig/PlatformSDK are exported below).
| @@ -0,0 +1,21 @@ | |||
| import { ItemResultReadResponse } from '../../generated/api.js'; | |||
There was a problem hiding this comment.
This import path (../../generated/api.js) is inconsistent with the rest of the SDK (which imports generated types from ../../generated/index.js). If api.js isn’t generated/exported, this will break builds/tests at runtime. Align this import with the generated entrypoint used elsewhere.
| export interface ApplicationRunItem extends ItemResultReadResponse { | ||
| /** Whether the item's output artifact is available for download. */ | ||
| can_download: boolean; | ||
| /** Human-readable status derived from `state` and `termination_reason`. */ | ||
| status: string; | ||
| } |
There was a problem hiding this comment.
ApplicationRunItem extends ItemResultReadResponse, which already defines a status property in the generated API types. Redeclaring status here both collides with that existing field and (together with processRunItem) effectively repurposes it to mean the derived status. If the goal is to add computed information, use a distinct property name for the derived status (and type it as ItemStatus if you keep it).



Introduce domain entities for Application Runs and Run Items
Summary
Enrich raw API responses (
RunReadResponse,ItemResultReadResponse) with computed properties so SDK consumers no longer need to derive progress, status, or download eligibility themselves.listApplicationRuns(),getRun(), andlistRunResults()now returnApplicationRun/ApplicationRunItementities with:progress(runs only) — percentage (0–100) of items in a terminal statestatus— simplified human-readable status (PENDING,PROCESSING,COMPLETED,COMPLETED_WITH_ERRORS,CANCELED,FAILED/SKIPPED)can_download— whether results are available for downloadChanges
packages/sdk/src/entities/application-run/— types, utility functions, processor, and testspackages/sdk/src/entities/run-item/— types, utility functions, processor, and testsPlatformSDKHttpmethods to return enriched entitiespackages/sdk/src/index.ts