@aignostics/sdk 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,41 @@
1
- import { A as ApplicationReadShortResponse, a as ApplicationReadResponse, R as RunReadResponse, b as RunCreationRequest, c as RunCreationResponse, I as ItemState, d as ItemTerminationReason, e as ItemResultReadResponse, V as VersionReadResponse } from './api-Ce-0fPc3.cjs';
2
- export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, Z as Configuration, Y as ConfigurationParameters, C as CustomMetadataUpdateRequest, j as CustomMetadataUpdateResponse, H as HTTPValidationError, k as InputArtifact, l as InputArtifactCreationRequest, m as ItemCreationRequest, n as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, o as OutputArtifact, p as OutputArtifactResultReadResponse, q as OutputArtifactScope, r as OutputArtifactVisibility, X as PublicApi, D as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, P as PublicApiAxiosParamCreator, E as PublicApiCancelRunV1RunsRunIdCancelPostRequest, F as PublicApiCreateRunV1RunsPostRequest, G as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, z as PublicApiFactory, y as PublicApiFp, J as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, K as PublicApiGetRunV1RunsRunIdGetRequest, B as PublicApiInterface, L as PublicApiListApplicationsV1ApplicationsGetRequest, N as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, Q as PublicApiListRunsV1RunsGetRequest, S as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, T as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, W as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, s as RunItemStatistics, t as RunOutput, u as RunState, v as RunTerminationReason, U as UserReadResponse, w as ValidationError, x as ValidationErrorLocInner } from './api-Ce-0fPc3.cjs';
1
+ import { R as RunReadResponse, I as ItemResultReadResponse, A as ApplicationReadShortResponse, a as ApplicationReadResponse, b as RunCreationRequest, c as RunCreationResponse, d as ItemState, e as ItemTerminationReason, V as VersionReadResponse } from './api-CWohsFN3.cjs';
2
+ export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, a0 as Configuration, $ as ConfigurationParameters, C as CustomMetadataUpdateRequest, j as CustomMetadataUpdateResponse, H as HTTPValidationError, k as InputArtifact, l as InputArtifactCreationRequest, m as ItemCreationRequest, n as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, o as OutputArtifact, p as OutputArtifactResultReadResponse, q as OutputArtifactScope, r as OutputArtifactVisibility, _ as PublicApi, E as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, P as PublicApiAxiosParamCreator, F as PublicApiCancelRunV1RunsRunIdCancelPostRequest, G as PublicApiCreateRunV1RunsPostRequest, J as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, B as PublicApiFactory, z as PublicApiFp, K as PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, L as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, N as PublicApiGetRunV1RunsRunIdGetRequest, D as PublicApiInterface, Q as PublicApiListApplicationsV1ApplicationsGetRequest, T as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, W as PublicApiListRunsV1RunsGetRequest, X as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, Y as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, Z as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, s as RunItemStatistics, t as RunOutput, u as RunState, v as RunTerminationReason, S as SchedulingRequest, w as SchedulingResponse, U as UserReadResponse, x as ValidationError, y as ValidationErrorLocInner } from './api-CWohsFN3.cjs';
3
3
  import 'axios';
4
4
 
5
+ /**
6
+ * Enriched application run entity that extends the raw API response
7
+ * with computed properties derived from run state and statistics.
8
+ *
9
+ * Returned by `PlatformSDKHttp.listApplicationRuns()` and `PlatformSDKHttp.getRun()`
10
+ * instead of the raw `RunReadResponse`.
11
+ */
12
+ interface ApplicationRun extends RunReadResponse {
13
+ /** Percentage of items processed (0–100), computed from run statistics. */
14
+ progress: number;
15
+ /** Human-readable status derived from `state` and `termination_reason`. */
16
+ status: RunStatus;
17
+ /** Whether the run's result items are available for download. */
18
+ can_download: boolean;
19
+ }
20
+ /** Derived run status that simplifies the raw `state` + `termination_reason` combination. */
21
+ type RunStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'COMPLETED_WITH_ERRORS' | 'CANCELED' | 'FAILED';
22
+
23
+ /**
24
+ * Enriched run-item entity that extends the raw API response
25
+ * with computed properties derived from item state and termination reason.
26
+ *
27
+ * Returned by `PlatformSDKHttp.listRunResults()` instead of the raw
28
+ * `ItemResultReadResponse`.
29
+ */
30
+ interface ApplicationRunItem extends ItemResultReadResponse {
31
+ /** Whether the item's output artifact is available for download. */
32
+ can_download: boolean;
33
+ /** Human-readable status derived from `state` and `termination_reason`. */
34
+ status: string;
35
+ }
36
+ /** Derived item status that simplifies the raw `state` + `termination_reason` combination. */
37
+ type ItemStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'SKIPPED';
38
+
5
39
  /**
6
40
  * Token provider function that returns a valid access token
7
41
  */
@@ -37,9 +71,9 @@ interface PlatformSDK {
37
71
  pageSize?: number;
38
72
  customMetadata?: string;
39
73
  sort?: string[];
40
- }): Promise<RunReadResponse[]>;
74
+ }): Promise<ApplicationRun[]>;
41
75
  createApplicationRun(request: RunCreationRequest): Promise<RunCreationResponse>;
42
- getRun(applicationRunId: string): Promise<RunReadResponse>;
76
+ getRun(applicationRunId: string): Promise<ApplicationRun>;
43
77
  cancelApplicationRun(applicationRunId: string): Promise<void>;
44
78
  listRunResults(applicationRunId: string, options?: {
45
79
  page?: number;
@@ -48,7 +82,7 @@ interface PlatformSDK {
48
82
  externalIdIn?: string[];
49
83
  state?: ItemState;
50
84
  terminationReason?: ItemTerminationReason;
51
- }): Promise<ItemResultReadResponse[]>;
85
+ }): Promise<ApplicationRunItem[]>;
52
86
  getApplicationVersionDetails(applicationId: string, version: string): Promise<VersionReadResponse>;
53
87
  }
54
88
  /**
@@ -215,7 +249,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
215
249
  sort?: string[];
216
250
  page?: number;
217
251
  pageSize?: number;
218
- }): Promise<RunReadResponse[]>;
252
+ }): Promise<ApplicationRun[]>;
219
253
  /**
220
254
  * Create and submit a new application run for processing
221
255
  *
@@ -280,7 +314,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
280
314
  * }
281
315
  * ```
282
316
  */
283
- getRun(applicationRunId: string): Promise<RunReadResponse>;
317
+ getRun(applicationRunId: string): Promise<ApplicationRun>;
284
318
  /**
285
319
  * Cancel a running or queued application run
286
320
  *
@@ -346,7 +380,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
346
380
  externalIdIn?: string[];
347
381
  state?: ItemState;
348
382
  terminationReason?: ItemTerminationReason;
349
- }): Promise<ItemResultReadResponse[]>;
383
+ }): Promise<ApplicationRunItem[]>;
350
384
  /**
351
385
  * Get the current version of the SDK
352
386
  *
@@ -474,4 +508,80 @@ declare class ConfigurationError extends BaseError {
474
508
  constructor(message: string, options?: BaseErrorOptions);
475
509
  }
476
510
 
477
- export { APIError, ApplicationReadResponse, ApplicationReadShortResponse, AuthenticationError, BaseError, ConfigurationError, ItemResultReadResponse, ItemState, ItemTerminationReason, type PlatformSDK, type PlatformSDKConfig, PlatformSDKHttp, RunCreationRequest, RunCreationResponse, RunReadResponse, type TokenProvider, VersionReadResponse, PlatformSDKHttp as default };
511
+ /**
512
+ * Transform a raw {@link RunReadResponse} from the API into an enriched
513
+ * {@link ApplicationRun} by computing derived properties (progress, status, can_download).
514
+ *
515
+ * This is the single entry-point used by `PlatformSDKHttp` methods to map API
516
+ * responses before returning them to consumers.
517
+ *
518
+ * @param run - Raw run response from the API
519
+ * @returns Enriched run entity with computed properties spread onto the original response
520
+ */
521
+ declare const processApplicationRun: (run: RunReadResponse) => ApplicationRun;
522
+
523
+ /**
524
+ * Compute the overall progress of a run as a percentage (0–100).
525
+ * Progress is based on the ratio of terminal items (succeeded + errored + skipped)
526
+ * to the total item count.
527
+ *
528
+ * @param run - Raw run response from the API
529
+ * @returns Integer percentage rounded to the nearest whole number
530
+ */
531
+ declare function getRunProgress(run: RunReadResponse): number;
532
+ /**
533
+ * Derive a human-readable {@link RunStatus} from the raw API `state` and `termination_reason`.
534
+ *
535
+ * Mapping rules:
536
+ * - PENDING / PROCESSING → passed through as-is
537
+ * - TERMINATED + CANCELED_BY_USER → CANCELED
538
+ * - TERMINATED + CANCELED_BY_SYSTEM → FAILED
539
+ * - TERMINATED + not all items succeeded → COMPLETED_WITH_ERRORS
540
+ * - TERMINATED + all items succeeded → COMPLETED
541
+ *
542
+ * @param run - Raw run response from the API
543
+ */
544
+ declare function getRunStatus(run: RunReadResponse): RunStatus;
545
+ /**
546
+ * Determine whether a run's result items are available for download.
547
+ * Items can only be downloaded once the run has reached a completed state.
548
+ *
549
+ * @param run - Raw run response from the API
550
+ * @returns `true` if items are available for download (run is COMPLETED or COMPLETED_WITH_ERRORS)
551
+ */
552
+ declare const canDownloadRunItems: (run: RunReadResponse) => boolean;
553
+
554
+ /**
555
+ * Transform a raw {@link ItemResultReadResponse} from the API into an enriched
556
+ * {@link ApplicationRunItem} by computing derived properties (status, can_download).
557
+ *
558
+ * This is the single entry-point used by `PlatformSDKHttp.listRunResults()` to
559
+ * map API responses before returning them to consumers.
560
+ *
561
+ * @param item - Raw item response from the API
562
+ * @returns Enriched item entity with computed properties spread onto the original response
563
+ */
564
+ declare const processRunItem: (item: ItemResultReadResponse) => ApplicationRunItem;
565
+
566
+ /**
567
+ * Determine whether a single run item's output artifact is available for download.
568
+ * Only items in the COMPLETED state have downloadable artifacts.
569
+ *
570
+ * @param item - Raw item response from the API
571
+ * @returns `true` if the item is in a COMPLETED state
572
+ */
573
+ declare const canDownloadItem: (item: ItemResultReadResponse) => boolean;
574
+ /**
575
+ * Derive a human-readable {@link ItemStatus} from the raw API `state` and `termination_reason`.
576
+ *
577
+ * Mapping rules:
578
+ * - PENDING / PROCESSING → passed through as-is
579
+ * - TERMINATED + SYSTEM_ERROR or USER_ERROR → FAILED
580
+ * - TERMINATED + SKIPPED → SKIPPED
581
+ * - TERMINATED (otherwise) → COMPLETED
582
+ *
583
+ * @param item - Raw item response from the API
584
+ */
585
+ declare function getItemStatus(item: ItemResultReadResponse): ItemStatus;
586
+
587
+ export { APIError, ApplicationReadResponse, ApplicationReadShortResponse, type ApplicationRun, type ApplicationRunItem, AuthenticationError, BaseError, ConfigurationError, ItemResultReadResponse, ItemState, type ItemStatus, ItemTerminationReason, type PlatformSDK, type PlatformSDKConfig, PlatformSDKHttp, RunCreationRequest, RunCreationResponse, RunReadResponse, type TokenProvider, VersionReadResponse, canDownloadItem, canDownloadRunItems, PlatformSDKHttp as default, getItemStatus, getRunProgress, getRunStatus, processApplicationRun, processRunItem };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,41 @@
1
- import { A as ApplicationReadShortResponse, a as ApplicationReadResponse, R as RunReadResponse, b as RunCreationRequest, c as RunCreationResponse, I as ItemState, d as ItemTerminationReason, e as ItemResultReadResponse, V as VersionReadResponse } from './api-Ce-0fPc3.js';
2
- export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, Z as Configuration, Y as ConfigurationParameters, C as CustomMetadataUpdateRequest, j as CustomMetadataUpdateResponse, H as HTTPValidationError, k as InputArtifact, l as InputArtifactCreationRequest, m as ItemCreationRequest, n as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, o as OutputArtifact, p as OutputArtifactResultReadResponse, q as OutputArtifactScope, r as OutputArtifactVisibility, X as PublicApi, D as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, P as PublicApiAxiosParamCreator, E as PublicApiCancelRunV1RunsRunIdCancelPostRequest, F as PublicApiCreateRunV1RunsPostRequest, G as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, z as PublicApiFactory, y as PublicApiFp, J as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, K as PublicApiGetRunV1RunsRunIdGetRequest, B as PublicApiInterface, L as PublicApiListApplicationsV1ApplicationsGetRequest, N as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, Q as PublicApiListRunsV1RunsGetRequest, S as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, T as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, W as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, s as RunItemStatistics, t as RunOutput, u as RunState, v as RunTerminationReason, U as UserReadResponse, w as ValidationError, x as ValidationErrorLocInner } from './api-Ce-0fPc3.js';
1
+ import { R as RunReadResponse, I as ItemResultReadResponse, A as ApplicationReadShortResponse, a as ApplicationReadResponse, b as RunCreationRequest, c as RunCreationResponse, d as ItemState, e as ItemTerminationReason, V as VersionReadResponse } from './api-CWohsFN3.js';
2
+ export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, a0 as Configuration, $ as ConfigurationParameters, C as CustomMetadataUpdateRequest, j as CustomMetadataUpdateResponse, H as HTTPValidationError, k as InputArtifact, l as InputArtifactCreationRequest, m as ItemCreationRequest, n as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, o as OutputArtifact, p as OutputArtifactResultReadResponse, q as OutputArtifactScope, r as OutputArtifactVisibility, _ as PublicApi, E as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, P as PublicApiAxiosParamCreator, F as PublicApiCancelRunV1RunsRunIdCancelPostRequest, G as PublicApiCreateRunV1RunsPostRequest, J as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, B as PublicApiFactory, z as PublicApiFp, K as PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, L as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, N as PublicApiGetRunV1RunsRunIdGetRequest, D as PublicApiInterface, Q as PublicApiListApplicationsV1ApplicationsGetRequest, T as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, W as PublicApiListRunsV1RunsGetRequest, X as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, Y as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, Z as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, s as RunItemStatistics, t as RunOutput, u as RunState, v as RunTerminationReason, S as SchedulingRequest, w as SchedulingResponse, U as UserReadResponse, x as ValidationError, y as ValidationErrorLocInner } from './api-CWohsFN3.js';
3
3
  import 'axios';
4
4
 
5
+ /**
6
+ * Enriched application run entity that extends the raw API response
7
+ * with computed properties derived from run state and statistics.
8
+ *
9
+ * Returned by `PlatformSDKHttp.listApplicationRuns()` and `PlatformSDKHttp.getRun()`
10
+ * instead of the raw `RunReadResponse`.
11
+ */
12
+ interface ApplicationRun extends RunReadResponse {
13
+ /** Percentage of items processed (0–100), computed from run statistics. */
14
+ progress: number;
15
+ /** Human-readable status derived from `state` and `termination_reason`. */
16
+ status: RunStatus;
17
+ /** Whether the run's result items are available for download. */
18
+ can_download: boolean;
19
+ }
20
+ /** Derived run status that simplifies the raw `state` + `termination_reason` combination. */
21
+ type RunStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'COMPLETED_WITH_ERRORS' | 'CANCELED' | 'FAILED';
22
+
23
+ /**
24
+ * Enriched run-item entity that extends the raw API response
25
+ * with computed properties derived from item state and termination reason.
26
+ *
27
+ * Returned by `PlatformSDKHttp.listRunResults()` instead of the raw
28
+ * `ItemResultReadResponse`.
29
+ */
30
+ interface ApplicationRunItem extends ItemResultReadResponse {
31
+ /** Whether the item's output artifact is available for download. */
32
+ can_download: boolean;
33
+ /** Human-readable status derived from `state` and `termination_reason`. */
34
+ status: string;
35
+ }
36
+ /** Derived item status that simplifies the raw `state` + `termination_reason` combination. */
37
+ type ItemStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'SKIPPED';
38
+
5
39
  /**
6
40
  * Token provider function that returns a valid access token
7
41
  */
@@ -37,9 +71,9 @@ interface PlatformSDK {
37
71
  pageSize?: number;
38
72
  customMetadata?: string;
39
73
  sort?: string[];
40
- }): Promise<RunReadResponse[]>;
74
+ }): Promise<ApplicationRun[]>;
41
75
  createApplicationRun(request: RunCreationRequest): Promise<RunCreationResponse>;
42
- getRun(applicationRunId: string): Promise<RunReadResponse>;
76
+ getRun(applicationRunId: string): Promise<ApplicationRun>;
43
77
  cancelApplicationRun(applicationRunId: string): Promise<void>;
44
78
  listRunResults(applicationRunId: string, options?: {
45
79
  page?: number;
@@ -48,7 +82,7 @@ interface PlatformSDK {
48
82
  externalIdIn?: string[];
49
83
  state?: ItemState;
50
84
  terminationReason?: ItemTerminationReason;
51
- }): Promise<ItemResultReadResponse[]>;
85
+ }): Promise<ApplicationRunItem[]>;
52
86
  getApplicationVersionDetails(applicationId: string, version: string): Promise<VersionReadResponse>;
53
87
  }
54
88
  /**
@@ -215,7 +249,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
215
249
  sort?: string[];
216
250
  page?: number;
217
251
  pageSize?: number;
218
- }): Promise<RunReadResponse[]>;
252
+ }): Promise<ApplicationRun[]>;
219
253
  /**
220
254
  * Create and submit a new application run for processing
221
255
  *
@@ -280,7 +314,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
280
314
  * }
281
315
  * ```
282
316
  */
283
- getRun(applicationRunId: string): Promise<RunReadResponse>;
317
+ getRun(applicationRunId: string): Promise<ApplicationRun>;
284
318
  /**
285
319
  * Cancel a running or queued application run
286
320
  *
@@ -346,7 +380,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
346
380
  externalIdIn?: string[];
347
381
  state?: ItemState;
348
382
  terminationReason?: ItemTerminationReason;
349
- }): Promise<ItemResultReadResponse[]>;
383
+ }): Promise<ApplicationRunItem[]>;
350
384
  /**
351
385
  * Get the current version of the SDK
352
386
  *
@@ -474,4 +508,80 @@ declare class ConfigurationError extends BaseError {
474
508
  constructor(message: string, options?: BaseErrorOptions);
475
509
  }
476
510
 
477
- export { APIError, ApplicationReadResponse, ApplicationReadShortResponse, AuthenticationError, BaseError, ConfigurationError, ItemResultReadResponse, ItemState, ItemTerminationReason, type PlatformSDK, type PlatformSDKConfig, PlatformSDKHttp, RunCreationRequest, RunCreationResponse, RunReadResponse, type TokenProvider, VersionReadResponse, PlatformSDKHttp as default };
511
+ /**
512
+ * Transform a raw {@link RunReadResponse} from the API into an enriched
513
+ * {@link ApplicationRun} by computing derived properties (progress, status, can_download).
514
+ *
515
+ * This is the single entry-point used by `PlatformSDKHttp` methods to map API
516
+ * responses before returning them to consumers.
517
+ *
518
+ * @param run - Raw run response from the API
519
+ * @returns Enriched run entity with computed properties spread onto the original response
520
+ */
521
+ declare const processApplicationRun: (run: RunReadResponse) => ApplicationRun;
522
+
523
+ /**
524
+ * Compute the overall progress of a run as a percentage (0–100).
525
+ * Progress is based on the ratio of terminal items (succeeded + errored + skipped)
526
+ * to the total item count.
527
+ *
528
+ * @param run - Raw run response from the API
529
+ * @returns Integer percentage rounded to the nearest whole number
530
+ */
531
+ declare function getRunProgress(run: RunReadResponse): number;
532
+ /**
533
+ * Derive a human-readable {@link RunStatus} from the raw API `state` and `termination_reason`.
534
+ *
535
+ * Mapping rules:
536
+ * - PENDING / PROCESSING → passed through as-is
537
+ * - TERMINATED + CANCELED_BY_USER → CANCELED
538
+ * - TERMINATED + CANCELED_BY_SYSTEM → FAILED
539
+ * - TERMINATED + not all items succeeded → COMPLETED_WITH_ERRORS
540
+ * - TERMINATED + all items succeeded → COMPLETED
541
+ *
542
+ * @param run - Raw run response from the API
543
+ */
544
+ declare function getRunStatus(run: RunReadResponse): RunStatus;
545
+ /**
546
+ * Determine whether a run's result items are available for download.
547
+ * Items can only be downloaded once the run has reached a completed state.
548
+ *
549
+ * @param run - Raw run response from the API
550
+ * @returns `true` if items are available for download (run is COMPLETED or COMPLETED_WITH_ERRORS)
551
+ */
552
+ declare const canDownloadRunItems: (run: RunReadResponse) => boolean;
553
+
554
+ /**
555
+ * Transform a raw {@link ItemResultReadResponse} from the API into an enriched
556
+ * {@link ApplicationRunItem} by computing derived properties (status, can_download).
557
+ *
558
+ * This is the single entry-point used by `PlatformSDKHttp.listRunResults()` to
559
+ * map API responses before returning them to consumers.
560
+ *
561
+ * @param item - Raw item response from the API
562
+ * @returns Enriched item entity with computed properties spread onto the original response
563
+ */
564
+ declare const processRunItem: (item: ItemResultReadResponse) => ApplicationRunItem;
565
+
566
+ /**
567
+ * Determine whether a single run item's output artifact is available for download.
568
+ * Only items in the COMPLETED state have downloadable artifacts.
569
+ *
570
+ * @param item - Raw item response from the API
571
+ * @returns `true` if the item is in a COMPLETED state
572
+ */
573
+ declare const canDownloadItem: (item: ItemResultReadResponse) => boolean;
574
+ /**
575
+ * Derive a human-readable {@link ItemStatus} from the raw API `state` and `termination_reason`.
576
+ *
577
+ * Mapping rules:
578
+ * - PENDING / PROCESSING → passed through as-is
579
+ * - TERMINATED + SYSTEM_ERROR or USER_ERROR → FAILED
580
+ * - TERMINATED + SKIPPED → SKIPPED
581
+ * - TERMINATED (otherwise) → COMPLETED
582
+ *
583
+ * @param item - Raw item response from the API
584
+ */
585
+ declare function getItemStatus(item: ItemResultReadResponse): ItemStatus;
586
+
587
+ export { APIError, ApplicationReadResponse, ApplicationReadShortResponse, type ApplicationRun, type ApplicationRunItem, AuthenticationError, BaseError, ConfigurationError, ItemResultReadResponse, ItemState, type ItemStatus, ItemTerminationReason, type PlatformSDK, type PlatformSDKConfig, PlatformSDKHttp, RunCreationRequest, RunCreationResponse, RunReadResponse, type TokenProvider, VersionReadResponse, canDownloadItem, canDownloadRunItems, PlatformSDKHttp as default, getItemStatus, getRunProgress, getRunStatus, processApplicationRun, processRunItem };
package/dist/index.js CHANGED
@@ -246,6 +246,35 @@ var PublicApiAxiosParamCreator = function(configuration) {
246
246
  options: localVarRequestOptions
247
247
  };
248
248
  },
249
+ /**
250
+ * Download the artifact file with the specified artifact_id, belonging to the specified run. The artifact_is is returned by the `GET /v1/runs/{run_id}/items` endpoint as part of the item results, and can also be retrieved via `GET /v1/runs/{run_id}/items/{external_id}`. The endpoint may return a redirect response with a presigned URL to download the artifact file from the storage bucket. The presigned URL is valid for a limited time, so it should be used immediately after receiving the response.
251
+ * @summary Get Artifact Url
252
+ * @param {string} runId Run id, returned by &#x60;POST /runs/&#x60; endpoint
253
+ * @param {string} artifactId The artifact id to download
254
+ * @param {*} [options] Override http request option.
255
+ * @throws {RequiredError}
256
+ */
257
+ getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet: async (runId, artifactId, options = {}) => {
258
+ assertParamExists("getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet", "runId", runId);
259
+ assertParamExists("getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet", "artifactId", artifactId);
260
+ const localVarPath = `/v1/runs/{run_id}/artifacts/{artifact_id}/file`.replace(`{${"run_id"}}`, encodeURIComponent(String(runId))).replace(`{${"artifact_id"}}`, encodeURIComponent(String(artifactId)));
261
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
262
+ let baseOptions;
263
+ if (configuration) {
264
+ baseOptions = configuration.baseOptions;
265
+ }
266
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
267
+ const localVarHeaderParameter = {};
268
+ const localVarQueryParameter = {};
269
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
270
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
271
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
272
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
273
+ return {
274
+ url: toPathString(localVarUrlObj),
275
+ options: localVarRequestOptions
276
+ };
277
+ },
249
278
  /**
250
279
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
251
280
  * @summary Get Item By Run
@@ -432,11 +461,12 @@ var PublicApiAxiosParamCreator = function(configuration) {
432
461
  * @param {string | null} [customMetadata] Use PostgreSQL JSONPath expressions to filter runs by their custom_metadata. #### URL Encoding Required **Important**: JSONPath expressions contain special characters that must be URL-encoded when used in query parameters. Most HTTP clients handle this automatically, but when constructing URLs manually, please ensure proper encoding. #### Examples (Clear Format): - **Field existence**: &#x60;$.study&#x60; - Runs that have a study field defined - **Exact value match**: &#x60;$.study ? (@ &#x3D;&#x3D; \&quot;high\&quot;)&#x60; - Runs with specific study value - **Numeric comparison**: &#x60;$.confidence_score ? (@ &gt; 0.75)&#x60; - Runs with confidence score greater than 0.75 - **Array operations**: &#x60;$.tags[*] ? (@ &#x3D;&#x3D; \&quot;draft\&quot;)&#x60; - Runs with tags array containing \&quot;draft\&quot; - **Complex conditions**: &#x60;$.resources ? (@.gpu_count &gt; 2 &amp;&amp; @.memory_gb &gt;&#x3D; 16)&#x60; - Runs with high resource requirements #### Examples (URL-Encoded Format): - **Field existence**: &#x60;%24.study&#x60; - **Exact value match**: &#x60;%24.study%20%3F%20(%40%20%3D%3D%20%22high%22)&#x60; - **Numeric comparison**: &#x60;%24.confidence_score%20%3F%20(%40%20%3E%200.75)&#x60; - **Array operations**: &#x60;%24.tags%5B*%5D%20%3F%20(%40%20%3D%3D%20%22draft%22)&#x60; - **Complex conditions**: &#x60;%24.resources%20%3F%20(%40.gpu_count%20%3E%202%20%26%26%20%40.memory_gb%20%3E%3D%2016)&#x60; #### Notes - JSONPath expressions are evaluated using PostgreSQL\&#39;s &#x60;@?&#x60; operator - The &#x60;$.&#x60; prefix is automatically added to root-level field references if missing - String values in conditions must be enclosed in double quotes - Use &#x60;&amp;&amp;&#x60; for AND operations and &#x60;||&#x60; for OR operations - Regular expressions use &#x60;like_regex&#x60; with standard regex syntax - **Please remember to URL-encode the entire JSONPath expression when making HTTP requests**
433
462
  * @param {number} [page]
434
463
  * @param {number} [pageSize]
464
+ * @param {string | null} [forOrganization] Filter runs by organization ID. Available for superadmins (any org) and admins (own org only). When provided, returns all runs for the specified organization instead of only the caller\&#39;s own runs.
435
465
  * @param {Array<string> | null} [sort] Sort the results by one or more fields. Use &#x60;+&#x60; for ascending and &#x60;-&#x60; for descending order. **Available fields:** - &#x60;run_id&#x60; - &#x60;application_id&#x60; - &#x60;version_number&#x60; - &#x60;custom_metadata&#x60; - &#x60;submitted_at&#x60; - &#x60;submitted_by&#x60; - &#x60;terminated_at&#x60; - &#x60;termination_reason&#x60; **Examples:** - &#x60;?sort&#x3D;submitted_at&#x60; - Sort by creation time (ascending) - &#x60;?sort&#x3D;-submitted_at&#x60; - Sort by creation time (descending) - &#x60;?sort&#x3D;state&amp;sort&#x3D;-submitted_at&#x60; - Sort by state, then by time (descending)
436
466
  * @param {*} [options] Override http request option.
437
467
  * @throws {RequiredError}
438
468
  */
439
- listRunsV1RunsGet: async (applicationId, applicationVersion, externalId, customMetadata, page, pageSize, sort, options = {}) => {
469
+ listRunsV1RunsGet: async (applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options = {}) => {
440
470
  const localVarPath = `/v1/runs`;
441
471
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
442
472
  let baseOptions;
@@ -465,6 +495,9 @@ var PublicApiAxiosParamCreator = function(configuration) {
465
495
  if (pageSize !== void 0) {
466
496
  localVarQueryParameter["page_size"] = pageSize;
467
497
  }
498
+ if (forOrganization !== void 0) {
499
+ localVarQueryParameter["for_organization"] = forOrganization;
500
+ }
468
501
  if (sort) {
469
502
  localVarQueryParameter["sort"] = sort;
470
503
  }
@@ -625,6 +658,20 @@ var PublicApiFp = function(configuration) {
625
658
  const localVarOperationServerBasePath = operationServerMap["PublicApi.deleteRunItemsV1RunsRunIdArtifactsDelete"]?.[localVarOperationServerIndex]?.url;
626
659
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
627
660
  },
661
+ /**
662
+ * Download the artifact file with the specified artifact_id, belonging to the specified run. The artifact_is is returned by the `GET /v1/runs/{run_id}/items` endpoint as part of the item results, and can also be retrieved via `GET /v1/runs/{run_id}/items/{external_id}`. The endpoint may return a redirect response with a presigned URL to download the artifact file from the storage bucket. The presigned URL is valid for a limited time, so it should be used immediately after receiving the response.
663
+ * @summary Get Artifact Url
664
+ * @param {string} runId Run id, returned by &#x60;POST /runs/&#x60; endpoint
665
+ * @param {string} artifactId The artifact id to download
666
+ * @param {*} [options] Override http request option.
667
+ * @throws {RequiredError}
668
+ */
669
+ async getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(runId, artifactId, options) {
670
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(runId, artifactId, options);
671
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
672
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet"]?.[localVarOperationServerIndex]?.url;
673
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
674
+ },
628
675
  /**
629
676
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
630
677
  * @summary Get Item By Run
@@ -709,12 +756,13 @@ var PublicApiFp = function(configuration) {
709
756
  * @param {string | null} [customMetadata] Use PostgreSQL JSONPath expressions to filter runs by their custom_metadata. #### URL Encoding Required **Important**: JSONPath expressions contain special characters that must be URL-encoded when used in query parameters. Most HTTP clients handle this automatically, but when constructing URLs manually, please ensure proper encoding. #### Examples (Clear Format): - **Field existence**: &#x60;$.study&#x60; - Runs that have a study field defined - **Exact value match**: &#x60;$.study ? (@ &#x3D;&#x3D; \&quot;high\&quot;)&#x60; - Runs with specific study value - **Numeric comparison**: &#x60;$.confidence_score ? (@ &gt; 0.75)&#x60; - Runs with confidence score greater than 0.75 - **Array operations**: &#x60;$.tags[*] ? (@ &#x3D;&#x3D; \&quot;draft\&quot;)&#x60; - Runs with tags array containing \&quot;draft\&quot; - **Complex conditions**: &#x60;$.resources ? (@.gpu_count &gt; 2 &amp;&amp; @.memory_gb &gt;&#x3D; 16)&#x60; - Runs with high resource requirements #### Examples (URL-Encoded Format): - **Field existence**: &#x60;%24.study&#x60; - **Exact value match**: &#x60;%24.study%20%3F%20(%40%20%3D%3D%20%22high%22)&#x60; - **Numeric comparison**: &#x60;%24.confidence_score%20%3F%20(%40%20%3E%200.75)&#x60; - **Array operations**: &#x60;%24.tags%5B*%5D%20%3F%20(%40%20%3D%3D%20%22draft%22)&#x60; - **Complex conditions**: &#x60;%24.resources%20%3F%20(%40.gpu_count%20%3E%202%20%26%26%20%40.memory_gb%20%3E%3D%2016)&#x60; #### Notes - JSONPath expressions are evaluated using PostgreSQL\&#39;s &#x60;@?&#x60; operator - The &#x60;$.&#x60; prefix is automatically added to root-level field references if missing - String values in conditions must be enclosed in double quotes - Use &#x60;&amp;&amp;&#x60; for AND operations and &#x60;||&#x60; for OR operations - Regular expressions use &#x60;like_regex&#x60; with standard regex syntax - **Please remember to URL-encode the entire JSONPath expression when making HTTP requests**
710
757
  * @param {number} [page]
711
758
  * @param {number} [pageSize]
759
+ * @param {string | null} [forOrganization] Filter runs by organization ID. Available for superadmins (any org) and admins (own org only). When provided, returns all runs for the specified organization instead of only the caller\&#39;s own runs.
712
760
  * @param {Array<string> | null} [sort] Sort the results by one or more fields. Use &#x60;+&#x60; for ascending and &#x60;-&#x60; for descending order. **Available fields:** - &#x60;run_id&#x60; - &#x60;application_id&#x60; - &#x60;version_number&#x60; - &#x60;custom_metadata&#x60; - &#x60;submitted_at&#x60; - &#x60;submitted_by&#x60; - &#x60;terminated_at&#x60; - &#x60;termination_reason&#x60; **Examples:** - &#x60;?sort&#x3D;submitted_at&#x60; - Sort by creation time (ascending) - &#x60;?sort&#x3D;-submitted_at&#x60; - Sort by creation time (descending) - &#x60;?sort&#x3D;state&amp;sort&#x3D;-submitted_at&#x60; - Sort by state, then by time (descending)
713
761
  * @param {*} [options] Override http request option.
714
762
  * @throws {RequiredError}
715
763
  */
716
- async listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, sort, options) {
717
- const localVarAxiosArgs = await localVarAxiosParamCreator.listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, sort, options);
764
+ async listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options) {
765
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options);
718
766
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
719
767
  const localVarOperationServerBasePath = operationServerMap["PublicApi.listRunsV1RunsGet"]?.[localVarOperationServerIndex]?.url;
720
768
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
@@ -806,6 +854,16 @@ var PublicApiFactory = function(configuration, basePath, axios) {
806
854
  deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters, options) {
807
855
  return localVarFp.deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters.runId, options).then((request) => request(axios, basePath));
808
856
  },
857
+ /**
858
+ * Download the artifact file with the specified artifact_id, belonging to the specified run. The artifact_is is returned by the `GET /v1/runs/{run_id}/items` endpoint as part of the item results, and can also be retrieved via `GET /v1/runs/{run_id}/items/{external_id}`. The endpoint may return a redirect response with a presigned URL to download the artifact file from the storage bucket. The presigned URL is valid for a limited time, so it should be used immediately after receiving the response.
859
+ * @summary Get Artifact Url
860
+ * @param {PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest} requestParameters Request parameters.
861
+ * @param {*} [options] Override http request option.
862
+ * @throws {RequiredError}
863
+ */
864
+ getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters, options) {
865
+ return localVarFp.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters.runId, requestParameters.artifactId, options).then((request) => request(axios, basePath));
866
+ },
809
867
  /**
810
868
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
811
869
  * @summary Get Item By Run
@@ -863,7 +921,7 @@ var PublicApiFactory = function(configuration, basePath, axios) {
863
921
  * @throws {RequiredError}
864
922
  */
865
923
  listRunsV1RunsGet(requestParameters = {}, options) {
866
- return localVarFp.listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.sort, options).then((request) => request(axios, basePath));
924
+ return localVarFp.listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.forOrganization, requestParameters.sort, options).then((request) => request(axios, basePath));
867
925
  },
868
926
  /**
869
927
  * Update the custom metadata of the item with the specified `external_id`, belonging to the specified run. Optionally, a checksum may be provided along the custom metadata JSON. It can be used to verify if the custom metadata was updated since the last time it was accessed. If the checksum is provided, it must match the existing custom metadata in the system, ensuring that the current custom metadata value to be overwritten is acknowledged by the user. If no checksum is provided, submitted metadata directly overwrites the existing metadata, without any checks. The latest custom metadata and checksum can be retrieved for individual items via `GET /v1/runs/{run_id}/items/{external_id}`, and for all items of a run via `GET /v1/runs/{run_id}/items`.
@@ -942,6 +1000,17 @@ var PublicApi = class extends BaseAPI {
942
1000
  deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters, options) {
943
1001
  return PublicApiFp(this.configuration).deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters.runId, options).then((request) => request(this.axios, this.basePath));
944
1002
  }
1003
+ /**
1004
+ * Download the artifact file with the specified artifact_id, belonging to the specified run. The artifact_is is returned by the `GET /v1/runs/{run_id}/items` endpoint as part of the item results, and can also be retrieved via `GET /v1/runs/{run_id}/items/{external_id}`. The endpoint may return a redirect response with a presigned URL to download the artifact file from the storage bucket. The presigned URL is valid for a limited time, so it should be used immediately after receiving the response.
1005
+ * @summary Get Artifact Url
1006
+ * @param {PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest} requestParameters Request parameters.
1007
+ * @param {*} [options] Override http request option.
1008
+ * @throws {RequiredError}
1009
+ * @memberof PublicApi
1010
+ */
1011
+ getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters, options) {
1012
+ return PublicApiFp(this.configuration).getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters.runId, requestParameters.artifactId, options).then((request) => request(this.axios, this.basePath));
1013
+ }
945
1014
  /**
946
1015
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
947
1016
  * @summary Get Item By Run
@@ -1005,7 +1074,7 @@ var PublicApi = class extends BaseAPI {
1005
1074
  * @memberof PublicApi
1006
1075
  */
1007
1076
  listRunsV1RunsGet(requestParameters = {}, options) {
1008
- return PublicApiFp(this.configuration).listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
1077
+ return PublicApiFp(this.configuration).listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.forOrganization, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
1009
1078
  }
1010
1079
  /**
1011
1080
  * Update the custom metadata of the item with the specified `external_id`, belonging to the specified run. Optionally, a checksum may be provided along the custom metadata JSON. It can be used to verify if the custom metadata was updated since the last time it was accessed. If the checksum is provided, it must match the existing custom metadata in the system, ensuring that the current custom metadata value to be overwritten is acknowledged by the user. If no checksum is provided, submitted metadata directly overwrites the existing metadata, without any checks. The latest custom metadata and checksum can be retrieved for individual items via `GET /v1/runs/{run_id}/items/{external_id}`, and for all items of a run via `GET /v1/runs/{run_id}/items`.
@@ -1215,6 +1284,87 @@ var UnexpectedError = class extends BaseError {
1215
1284
  super(message, "UNEXPECTED_ERROR", options);
1216
1285
  }
1217
1286
  };
1287
+
1288
+ // src/entities/application-run/utils.ts
1289
+ function getRunProgress(run) {
1290
+ const {
1291
+ item_count,
1292
+ item_succeeded_count,
1293
+ item_user_error_count,
1294
+ item_system_error_count,
1295
+ item_skipped_count
1296
+ } = run.statistics;
1297
+ if (item_count === 0) return 0;
1298
+ const processed = item_succeeded_count + item_user_error_count + item_system_error_count + item_skipped_count;
1299
+ return Math.round(processed / item_count * 100);
1300
+ }
1301
+ function getRunStatus(run) {
1302
+ const { state, statistics, termination_reason } = run;
1303
+ switch (state) {
1304
+ case "PENDING":
1305
+ return "PENDING";
1306
+ case "PROCESSING":
1307
+ return "PROCESSING";
1308
+ case "TERMINATED":
1309
+ if (termination_reason === "CANCELED_BY_USER") {
1310
+ return "CANCELED";
1311
+ }
1312
+ if (termination_reason === "CANCELED_BY_SYSTEM") {
1313
+ return "FAILED";
1314
+ }
1315
+ if (statistics.item_count !== statistics.item_succeeded_count) {
1316
+ return "COMPLETED_WITH_ERRORS";
1317
+ }
1318
+ return "COMPLETED";
1319
+ }
1320
+ }
1321
+ var canDownloadRunItems = (run) => {
1322
+ const status = getRunStatus(run);
1323
+ return !["FAILED", "CANCELED", "PENDING", "PROCESSING"].includes(status);
1324
+ };
1325
+
1326
+ // src/entities/application-run/process-application-run.ts
1327
+ var processApplicationRun = (run) => {
1328
+ return {
1329
+ ...run,
1330
+ progress: getRunProgress(run),
1331
+ status: getRunStatus(run),
1332
+ can_download: canDownloadRunItems(run)
1333
+ };
1334
+ };
1335
+
1336
+ // src/entities/run-item/utils.ts
1337
+ var canDownloadItem = (item) => {
1338
+ return getItemStatus(item) === "COMPLETED";
1339
+ };
1340
+ function getItemStatus(item) {
1341
+ const { state, termination_reason } = item;
1342
+ switch (state) {
1343
+ case "PENDING":
1344
+ return "PENDING";
1345
+ case "PROCESSING":
1346
+ return "PROCESSING";
1347
+ case "TERMINATED":
1348
+ if (termination_reason === "SYSTEM_ERROR" || termination_reason === "USER_ERROR") {
1349
+ return "FAILED";
1350
+ }
1351
+ if (termination_reason === "SKIPPED") {
1352
+ return "SKIPPED";
1353
+ }
1354
+ return "COMPLETED";
1355
+ }
1356
+ }
1357
+
1358
+ // src/entities/run-item/process-run-item.ts
1359
+ var processRunItem = (item) => {
1360
+ return {
1361
+ ...item,
1362
+ status: getItemStatus(item),
1363
+ can_download: canDownloadItem(item)
1364
+ };
1365
+ };
1366
+
1367
+ // src/platform-sdk.ts
1218
1368
  var validationErrorSchema = z.object({
1219
1369
  detail: z.array(
1220
1370
  z.object({
@@ -1481,7 +1631,7 @@ var PlatformSDKHttp = class {
1481
1631
  page: options?.page,
1482
1632
  pageSize: options?.pageSize
1483
1633
  });
1484
- return response.data;
1634
+ return response.data.map(processApplicationRun);
1485
1635
  } catch (error) {
1486
1636
  handleRequestError(error);
1487
1637
  }
@@ -1566,7 +1716,7 @@ var PlatformSDKHttp = class {
1566
1716
  const response = await client.getRunV1RunsRunIdGet({
1567
1717
  runId: applicationRunId
1568
1718
  });
1569
- return response.data;
1719
+ return processApplicationRun(response.data);
1570
1720
  } catch (error) {
1571
1721
  handleRequestError(error);
1572
1722
  }
@@ -1657,7 +1807,7 @@ var PlatformSDKHttp = class {
1657
1807
  state,
1658
1808
  terminationReason
1659
1809
  });
1660
- return response.data;
1810
+ return response.data.map(processRunItem);
1661
1811
  } catch (error) {
1662
1812
  handleRequestError(error);
1663
1813
  }
@@ -1709,6 +1859,6 @@ var PlatformSDKHttp = class {
1709
1859
  // src/index.ts
1710
1860
  var index_default = PlatformSDKHttp;
1711
1861
 
1712
- export { APIError, ArtifactOutput, ArtifactState, ArtifactTerminationReason, AuthenticationError, BaseError, Configuration, ConfigurationError, ItemOutput, ItemState, ItemTerminationReason, OutputArtifactScope, OutputArtifactVisibility, PlatformSDKHttp, PublicApi, PublicApiAxiosParamCreator, PublicApiFactory, PublicApiFp, RunOutput, RunState, RunTerminationReason, index_default as default };
1862
+ export { APIError, ArtifactOutput, ArtifactState, ArtifactTerminationReason, AuthenticationError, BaseError, Configuration, ConfigurationError, ItemOutput, ItemState, ItemTerminationReason, OutputArtifactScope, OutputArtifactVisibility, PlatformSDKHttp, PublicApi, PublicApiAxiosParamCreator, PublicApiFactory, PublicApiFp, RunOutput, RunState, RunTerminationReason, canDownloadItem, canDownloadRunItems, index_default as default, getItemStatus, getRunProgress, getRunStatus, processApplicationRun, processRunItem };
1713
1863
  //# sourceMappingURL=index.js.map
1714
1864
  //# sourceMappingURL=index.js.map