Skip to content

task: add domain entities for application runs and items#60

Open
na66im wants to merge 1 commit intomainfrom
task/TSSDK-51-introduce-domain-entities-in-tssdk
Open

task: add domain entities for application runs and items#60
na66im wants to merge 1 commit intomainfrom
task/TSSDK-51-introduce-domain-entities-in-tssdk

Conversation

@na66im
Copy link
Contributor

@na66im na66im commented Mar 9, 2026

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(), and listRunResults() now return ApplicationRun / ApplicationRunItem entities with:

  • progress (runs only) — percentage (0–100) of items in a terminal state
  • status — simplified human-readable status (PENDING, PROCESSING, COMPLETED, COMPLETED_WITH_ERRORS, CANCELED, FAILED / SKIPPED)
  • can_download — whether results are available for download

Changes

  • New packages/sdk/src/entities/application-run/ — types, utility functions, processor, and tests
  • New packages/sdk/src/entities/run-item/ — types, utility functions, processor, and tests
  • Updated PlatformSDKHttp methods to return enriched entities
  • Updated existing SDK tests to assert enriched properties
  • Exported all new types and utilities from packages/sdk/src/index.ts

@na66im na66im self-assigned this Mar 9, 2026
Copilot AI review requested due to automatic review settings March 9, 2026 12:54
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            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              
Flag Coverage Δ
unittests 96.38% <100.00%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ntities/application-run/process-application-run.ts 100.00% <100.00%> (ø)
packages/sdk/src/entities/application-run/utils.ts 100.00% <100.00%> (ø)
...ages/sdk/src/entities/run-item/process-run-item.ts 100.00% <100.00%> (ø)
packages/sdk/src/entities/run-item/utils.ts 100.00% <100.00%> (ø)
packages/sdk/src/platform-sdk.ts 94.08% <100.00%> (+0.05%) ⬆️

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 + ApplicationRunItem entity types, processors, and utility functions (with unit tests).
  • Updated PlatformSDKHttp.listApplicationRuns(), getRun(), and listRunResults() 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.

page?: number;
pageSize?: number;
}): Promise<RunReadResponse[]> {
}): Promise<ApplicationRun[]> {
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +53
);

expect(result.status).toBe('COMPLETED');
expect(result.can_download).toBe(false);
});
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@na66im na66im force-pushed the task/TSSDK-51-introduce-domain-entities-in-tssdk branch from 1e3ad5b to 6de0a22 Compare March 9, 2026 13:36
@na66im na66im force-pushed the task/TSSDK-51-introduce-domain-entities-in-tssdk branch from 6de0a22 to bf346d6 Compare March 10, 2026 08:51
Copilot AI review requested due to automatic review settings March 10, 2026 08:51
@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comment on lines +9 to +18
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';
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,21 @@
import { ItemResultReadResponse } from '../../generated/api.js';
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +15
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;
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
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.

2 participants