@aignostics/sdk 3.2.0 → 3.4.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/aignostics-sdk-3.4.0.tgz +0 -0
- package/dist/{api-Ce-0fPc3.d.cts → api-DXw7V8bK.d.cts} +552 -33
- package/dist/{api-Ce-0fPc3.d.ts → api-DXw7V8bK.d.ts} +552 -33
- package/dist/index.cjs +755 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +153 -9
- package/dist/index.d.ts +153 -9
- package/dist/index.js +748 -9
- package/dist/index.js.map +1 -1
- package/dist/test-utils/http-mocks.cjs +26 -1
- package/dist/test-utils/http-mocks.cjs.map +1 -1
- package/dist/test-utils/http-mocks.d.cts +1 -1
- package/dist/test-utils/http-mocks.d.ts +1 -1
- package/dist/test-utils/http-mocks.js +26 -1
- package/dist/test-utils/http-mocks.js.map +1 -1
- package/package.json +2 -1
- package/dist/aignostics-sdk-3.2.0.tgz +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason,
|
|
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-DXw7V8bK.cjs';
|
|
2
|
+
export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, a7 as Configuration, a6 as ConfigurationParameters, C as CustomMetadataUpdateRequest, j as CustomMetadataUpdateResponse, H as HTTPValidationError, k as InputArtifact, l as InputArtifactCreationRequest, m as InputArtifactResultReadResponse, n as ItemCreationRequest, o as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, p as OutputArtifact, q as OutputArtifactResultReadResponse, r as OutputArtifactScope, s as OutputArtifactVisibility, a5 as PublicApi, J as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, P as PublicApiAxiosParamCreator, K as PublicApiCancelRunV1RunsRunIdCancelPostRequest, L as PublicApiCreateRunV1RunsPostRequest, N as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, F as PublicApiFactory, E as PublicApiFp, Q as PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, T as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, W as PublicApiGetRunV1RunsRunIdGetRequest, Y as PublicApiGetVersionDocumentContentRequest, Z as PublicApiGetVersionDocumentFileRequest, X as PublicApiGetVersionDocumentRequest, G as PublicApiInterface, _ as PublicApiListApplicationsV1ApplicationsGetRequest, $ as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, a0 as PublicApiListRunsV1RunsGetRequest, a1 as PublicApiListVersionDocumentsRequest, a2 as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, a3 as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, a4 as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, t as RunItemStatistics, u as RunOutput, v as RunState, w as RunTerminationReason, S as SchedulingRequest, x as SchedulingResponse, U as UserReadResponse, y as ValidationError, z as ValidationErrorLocInner, B as VersionDocumentResponse, D as VersionDocumentVisibility } from './api-DXw7V8bK.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<
|
|
74
|
+
}): Promise<ApplicationRun[]>;
|
|
41
75
|
createApplicationRun(request: RunCreationRequest): Promise<RunCreationResponse>;
|
|
42
|
-
getRun(applicationRunId: string): Promise<
|
|
76
|
+
getRun(applicationRunId: string): Promise<ApplicationRun>;
|
|
43
77
|
cancelApplicationRun(applicationRunId: string): Promise<void>;
|
|
44
78
|
listRunResults(applicationRunId: string, options?: {
|
|
45
79
|
page?: number;
|
|
@@ -48,8 +82,9 @@ interface PlatformSDK {
|
|
|
48
82
|
externalIdIn?: string[];
|
|
49
83
|
state?: ItemState;
|
|
50
84
|
terminationReason?: ItemTerminationReason;
|
|
51
|
-
}): Promise<
|
|
85
|
+
}): Promise<ApplicationRunItem[]>;
|
|
52
86
|
getApplicationVersionDetails(applicationId: string, version: string): Promise<VersionReadResponse>;
|
|
87
|
+
downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
|
|
53
88
|
}
|
|
54
89
|
/**
|
|
55
90
|
* Main SDK class for interacting with the Aignostics Platform
|
|
@@ -215,7 +250,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
|
|
|
215
250
|
sort?: string[];
|
|
216
251
|
page?: number;
|
|
217
252
|
pageSize?: number;
|
|
218
|
-
}): Promise<
|
|
253
|
+
}): Promise<ApplicationRun[]>;
|
|
219
254
|
/**
|
|
220
255
|
* Create and submit a new application run for processing
|
|
221
256
|
*
|
|
@@ -280,7 +315,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
|
|
|
280
315
|
* }
|
|
281
316
|
* ```
|
|
282
317
|
*/
|
|
283
|
-
getRun(applicationRunId: string): Promise<
|
|
318
|
+
getRun(applicationRunId: string): Promise<ApplicationRun>;
|
|
284
319
|
/**
|
|
285
320
|
* Cancel a running or queued application run
|
|
286
321
|
*
|
|
@@ -346,7 +381,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
|
|
|
346
381
|
externalIdIn?: string[];
|
|
347
382
|
state?: ItemState;
|
|
348
383
|
terminationReason?: ItemTerminationReason;
|
|
349
|
-
}): Promise<
|
|
384
|
+
}): Promise<ApplicationRunItem[]>;
|
|
350
385
|
/**
|
|
351
386
|
* Get the current version of the SDK
|
|
352
387
|
*
|
|
@@ -385,6 +420,39 @@ declare class PlatformSDKHttp implements PlatformSDK {
|
|
|
385
420
|
* ```
|
|
386
421
|
*/
|
|
387
422
|
getConfig(): PlatformSDKConfig;
|
|
423
|
+
/**
|
|
424
|
+
* Download an artifact file from a completed application run
|
|
425
|
+
*
|
|
426
|
+
* This method retrieves the binary content of a specific artifact produced
|
|
427
|
+
* during an application run. Artifacts can include generated reports, processed
|
|
428
|
+
* images, or other output files from the AI model execution.
|
|
429
|
+
*
|
|
430
|
+
* The download is performed with automatic retries for transient failures.
|
|
431
|
+
* Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
|
|
432
|
+
*
|
|
433
|
+
* @param runId - The unique identifier of the application run
|
|
434
|
+
* @param artifactId - The unique identifier of the artifact to download
|
|
435
|
+
* @returns A promise that resolves to an ArrayBuffer containing the artifact's binary content
|
|
436
|
+
* @throws {AuthenticationError} If no valid authentication token is available
|
|
437
|
+
* @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
|
|
438
|
+
* @throws {UnexpectedError} If a non-HTTP error occurs
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```typescript
|
|
442
|
+
* const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
|
|
443
|
+
*
|
|
444
|
+
* try {
|
|
445
|
+
* const buffer = await sdk.downloadArtifact('run-123', 'artifact-456');
|
|
446
|
+
* console.log(`Downloaded ${buffer.byteLength} bytes`);
|
|
447
|
+
*
|
|
448
|
+
* // Write to file (Node.js)
|
|
449
|
+
* fs.writeFileSync('output.bin', Buffer.from(buffer));
|
|
450
|
+
* } catch (error) {
|
|
451
|
+
* console.error('Failed to download artifact:', error.message);
|
|
452
|
+
* }
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
|
|
388
456
|
}
|
|
389
457
|
|
|
390
458
|
type ErrorCode = 'AUTHENTICATION_ERROR' | 'API_ERROR' | 'CONFIGURATION_ERROR' | 'UNEXPECTED_ERROR';
|
|
@@ -474,4 +542,80 @@ declare class ConfigurationError extends BaseError {
|
|
|
474
542
|
constructor(message: string, options?: BaseErrorOptions);
|
|
475
543
|
}
|
|
476
544
|
|
|
477
|
-
|
|
545
|
+
/**
|
|
546
|
+
* Transform a raw {@link RunReadResponse} from the API into an enriched
|
|
547
|
+
* {@link ApplicationRun} by computing derived properties (progress, status, can_download).
|
|
548
|
+
*
|
|
549
|
+
* This is the single entry-point used by `PlatformSDKHttp` methods to map API
|
|
550
|
+
* responses before returning them to consumers.
|
|
551
|
+
*
|
|
552
|
+
* @param run - Raw run response from the API
|
|
553
|
+
* @returns Enriched run entity with computed properties spread onto the original response
|
|
554
|
+
*/
|
|
555
|
+
declare const processApplicationRun: (run: RunReadResponse) => ApplicationRun;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Compute the overall progress of a run as a percentage (0–100).
|
|
559
|
+
* Progress is based on the ratio of terminal items (succeeded + errored + skipped)
|
|
560
|
+
* to the total item count.
|
|
561
|
+
*
|
|
562
|
+
* @param run - Raw run response from the API
|
|
563
|
+
* @returns Integer percentage rounded to the nearest whole number
|
|
564
|
+
*/
|
|
565
|
+
declare function getRunProgress(run: RunReadResponse): number;
|
|
566
|
+
/**
|
|
567
|
+
* Derive a human-readable {@link RunStatus} from the raw API `state` and `termination_reason`.
|
|
568
|
+
*
|
|
569
|
+
* Mapping rules:
|
|
570
|
+
* - PENDING / PROCESSING → passed through as-is
|
|
571
|
+
* - TERMINATED + CANCELED_BY_USER → CANCELED
|
|
572
|
+
* - TERMINATED + CANCELED_BY_SYSTEM → FAILED
|
|
573
|
+
* - TERMINATED + not all items succeeded → COMPLETED_WITH_ERRORS
|
|
574
|
+
* - TERMINATED + all items succeeded → COMPLETED
|
|
575
|
+
*
|
|
576
|
+
* @param run - Raw run response from the API
|
|
577
|
+
*/
|
|
578
|
+
declare function getRunStatus(run: RunReadResponse): RunStatus;
|
|
579
|
+
/**
|
|
580
|
+
* Determine whether a run's result items are available for download.
|
|
581
|
+
* Items can only be downloaded once the run has reached a completed state.
|
|
582
|
+
*
|
|
583
|
+
* @param run - Raw run response from the API
|
|
584
|
+
* @returns `true` if items are available for download (run is COMPLETED or COMPLETED_WITH_ERRORS)
|
|
585
|
+
*/
|
|
586
|
+
declare const canDownloadRunItems: (run: RunReadResponse) => boolean;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Transform a raw {@link ItemResultReadResponse} from the API into an enriched
|
|
590
|
+
* {@link ApplicationRunItem} by computing derived properties (status, can_download).
|
|
591
|
+
*
|
|
592
|
+
* This is the single entry-point used by `PlatformSDKHttp.listRunResults()` to
|
|
593
|
+
* map API responses before returning them to consumers.
|
|
594
|
+
*
|
|
595
|
+
* @param item - Raw item response from the API
|
|
596
|
+
* @returns Enriched item entity with computed properties spread onto the original response
|
|
597
|
+
*/
|
|
598
|
+
declare const processRunItem: (item: ItemResultReadResponse) => ApplicationRunItem;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Determine whether a single run item's output artifact is available for download.
|
|
602
|
+
* Only items in the COMPLETED state have downloadable artifacts.
|
|
603
|
+
*
|
|
604
|
+
* @param item - Raw item response from the API
|
|
605
|
+
* @returns `true` if the item is in a COMPLETED state
|
|
606
|
+
*/
|
|
607
|
+
declare const canDownloadItem: (item: ItemResultReadResponse) => boolean;
|
|
608
|
+
/**
|
|
609
|
+
* Derive a human-readable {@link ItemStatus} from the raw API `state` and `termination_reason`.
|
|
610
|
+
*
|
|
611
|
+
* Mapping rules:
|
|
612
|
+
* - PENDING / PROCESSING → passed through as-is
|
|
613
|
+
* - TERMINATED + SYSTEM_ERROR or USER_ERROR → FAILED
|
|
614
|
+
* - TERMINATED + SKIPPED → SKIPPED
|
|
615
|
+
* - TERMINATED (otherwise) → COMPLETED
|
|
616
|
+
*
|
|
617
|
+
* @param item - Raw item response from the API
|
|
618
|
+
*/
|
|
619
|
+
declare function getItemStatus(item: ItemResultReadResponse): ItemStatus;
|
|
620
|
+
|
|
621
|
+
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 {
|
|
2
|
-
export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason,
|
|
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-DXw7V8bK.js';
|
|
2
|
+
export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, a7 as Configuration, a6 as ConfigurationParameters, C as CustomMetadataUpdateRequest, j as CustomMetadataUpdateResponse, H as HTTPValidationError, k as InputArtifact, l as InputArtifactCreationRequest, m as InputArtifactResultReadResponse, n as ItemCreationRequest, o as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, p as OutputArtifact, q as OutputArtifactResultReadResponse, r as OutputArtifactScope, s as OutputArtifactVisibility, a5 as PublicApi, J as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, P as PublicApiAxiosParamCreator, K as PublicApiCancelRunV1RunsRunIdCancelPostRequest, L as PublicApiCreateRunV1RunsPostRequest, N as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, F as PublicApiFactory, E as PublicApiFp, Q as PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, T as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, W as PublicApiGetRunV1RunsRunIdGetRequest, Y as PublicApiGetVersionDocumentContentRequest, Z as PublicApiGetVersionDocumentFileRequest, X as PublicApiGetVersionDocumentRequest, G as PublicApiInterface, _ as PublicApiListApplicationsV1ApplicationsGetRequest, $ as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, a0 as PublicApiListRunsV1RunsGetRequest, a1 as PublicApiListVersionDocumentsRequest, a2 as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, a3 as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, a4 as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, t as RunItemStatistics, u as RunOutput, v as RunState, w as RunTerminationReason, S as SchedulingRequest, x as SchedulingResponse, U as UserReadResponse, y as ValidationError, z as ValidationErrorLocInner, B as VersionDocumentResponse, D as VersionDocumentVisibility } from './api-DXw7V8bK.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<
|
|
74
|
+
}): Promise<ApplicationRun[]>;
|
|
41
75
|
createApplicationRun(request: RunCreationRequest): Promise<RunCreationResponse>;
|
|
42
|
-
getRun(applicationRunId: string): Promise<
|
|
76
|
+
getRun(applicationRunId: string): Promise<ApplicationRun>;
|
|
43
77
|
cancelApplicationRun(applicationRunId: string): Promise<void>;
|
|
44
78
|
listRunResults(applicationRunId: string, options?: {
|
|
45
79
|
page?: number;
|
|
@@ -48,8 +82,9 @@ interface PlatformSDK {
|
|
|
48
82
|
externalIdIn?: string[];
|
|
49
83
|
state?: ItemState;
|
|
50
84
|
terminationReason?: ItemTerminationReason;
|
|
51
|
-
}): Promise<
|
|
85
|
+
}): Promise<ApplicationRunItem[]>;
|
|
52
86
|
getApplicationVersionDetails(applicationId: string, version: string): Promise<VersionReadResponse>;
|
|
87
|
+
downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
|
|
53
88
|
}
|
|
54
89
|
/**
|
|
55
90
|
* Main SDK class for interacting with the Aignostics Platform
|
|
@@ -215,7 +250,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
|
|
|
215
250
|
sort?: string[];
|
|
216
251
|
page?: number;
|
|
217
252
|
pageSize?: number;
|
|
218
|
-
}): Promise<
|
|
253
|
+
}): Promise<ApplicationRun[]>;
|
|
219
254
|
/**
|
|
220
255
|
* Create and submit a new application run for processing
|
|
221
256
|
*
|
|
@@ -280,7 +315,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
|
|
|
280
315
|
* }
|
|
281
316
|
* ```
|
|
282
317
|
*/
|
|
283
|
-
getRun(applicationRunId: string): Promise<
|
|
318
|
+
getRun(applicationRunId: string): Promise<ApplicationRun>;
|
|
284
319
|
/**
|
|
285
320
|
* Cancel a running or queued application run
|
|
286
321
|
*
|
|
@@ -346,7 +381,7 @@ declare class PlatformSDKHttp implements PlatformSDK {
|
|
|
346
381
|
externalIdIn?: string[];
|
|
347
382
|
state?: ItemState;
|
|
348
383
|
terminationReason?: ItemTerminationReason;
|
|
349
|
-
}): Promise<
|
|
384
|
+
}): Promise<ApplicationRunItem[]>;
|
|
350
385
|
/**
|
|
351
386
|
* Get the current version of the SDK
|
|
352
387
|
*
|
|
@@ -385,6 +420,39 @@ declare class PlatformSDKHttp implements PlatformSDK {
|
|
|
385
420
|
* ```
|
|
386
421
|
*/
|
|
387
422
|
getConfig(): PlatformSDKConfig;
|
|
423
|
+
/**
|
|
424
|
+
* Download an artifact file from a completed application run
|
|
425
|
+
*
|
|
426
|
+
* This method retrieves the binary content of a specific artifact produced
|
|
427
|
+
* during an application run. Artifacts can include generated reports, processed
|
|
428
|
+
* images, or other output files from the AI model execution.
|
|
429
|
+
*
|
|
430
|
+
* The download is performed with automatic retries for transient failures.
|
|
431
|
+
* Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
|
|
432
|
+
*
|
|
433
|
+
* @param runId - The unique identifier of the application run
|
|
434
|
+
* @param artifactId - The unique identifier of the artifact to download
|
|
435
|
+
* @returns A promise that resolves to an ArrayBuffer containing the artifact's binary content
|
|
436
|
+
* @throws {AuthenticationError} If no valid authentication token is available
|
|
437
|
+
* @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
|
|
438
|
+
* @throws {UnexpectedError} If a non-HTTP error occurs
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```typescript
|
|
442
|
+
* const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
|
|
443
|
+
*
|
|
444
|
+
* try {
|
|
445
|
+
* const buffer = await sdk.downloadArtifact('run-123', 'artifact-456');
|
|
446
|
+
* console.log(`Downloaded ${buffer.byteLength} bytes`);
|
|
447
|
+
*
|
|
448
|
+
* // Write to file (Node.js)
|
|
449
|
+
* fs.writeFileSync('output.bin', Buffer.from(buffer));
|
|
450
|
+
* } catch (error) {
|
|
451
|
+
* console.error('Failed to download artifact:', error.message);
|
|
452
|
+
* }
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
|
|
388
456
|
}
|
|
389
457
|
|
|
390
458
|
type ErrorCode = 'AUTHENTICATION_ERROR' | 'API_ERROR' | 'CONFIGURATION_ERROR' | 'UNEXPECTED_ERROR';
|
|
@@ -474,4 +542,80 @@ declare class ConfigurationError extends BaseError {
|
|
|
474
542
|
constructor(message: string, options?: BaseErrorOptions);
|
|
475
543
|
}
|
|
476
544
|
|
|
477
|
-
|
|
545
|
+
/**
|
|
546
|
+
* Transform a raw {@link RunReadResponse} from the API into an enriched
|
|
547
|
+
* {@link ApplicationRun} by computing derived properties (progress, status, can_download).
|
|
548
|
+
*
|
|
549
|
+
* This is the single entry-point used by `PlatformSDKHttp` methods to map API
|
|
550
|
+
* responses before returning them to consumers.
|
|
551
|
+
*
|
|
552
|
+
* @param run - Raw run response from the API
|
|
553
|
+
* @returns Enriched run entity with computed properties spread onto the original response
|
|
554
|
+
*/
|
|
555
|
+
declare const processApplicationRun: (run: RunReadResponse) => ApplicationRun;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Compute the overall progress of a run as a percentage (0–100).
|
|
559
|
+
* Progress is based on the ratio of terminal items (succeeded + errored + skipped)
|
|
560
|
+
* to the total item count.
|
|
561
|
+
*
|
|
562
|
+
* @param run - Raw run response from the API
|
|
563
|
+
* @returns Integer percentage rounded to the nearest whole number
|
|
564
|
+
*/
|
|
565
|
+
declare function getRunProgress(run: RunReadResponse): number;
|
|
566
|
+
/**
|
|
567
|
+
* Derive a human-readable {@link RunStatus} from the raw API `state` and `termination_reason`.
|
|
568
|
+
*
|
|
569
|
+
* Mapping rules:
|
|
570
|
+
* - PENDING / PROCESSING → passed through as-is
|
|
571
|
+
* - TERMINATED + CANCELED_BY_USER → CANCELED
|
|
572
|
+
* - TERMINATED + CANCELED_BY_SYSTEM → FAILED
|
|
573
|
+
* - TERMINATED + not all items succeeded → COMPLETED_WITH_ERRORS
|
|
574
|
+
* - TERMINATED + all items succeeded → COMPLETED
|
|
575
|
+
*
|
|
576
|
+
* @param run - Raw run response from the API
|
|
577
|
+
*/
|
|
578
|
+
declare function getRunStatus(run: RunReadResponse): RunStatus;
|
|
579
|
+
/**
|
|
580
|
+
* Determine whether a run's result items are available for download.
|
|
581
|
+
* Items can only be downloaded once the run has reached a completed state.
|
|
582
|
+
*
|
|
583
|
+
* @param run - Raw run response from the API
|
|
584
|
+
* @returns `true` if items are available for download (run is COMPLETED or COMPLETED_WITH_ERRORS)
|
|
585
|
+
*/
|
|
586
|
+
declare const canDownloadRunItems: (run: RunReadResponse) => boolean;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Transform a raw {@link ItemResultReadResponse} from the API into an enriched
|
|
590
|
+
* {@link ApplicationRunItem} by computing derived properties (status, can_download).
|
|
591
|
+
*
|
|
592
|
+
* This is the single entry-point used by `PlatformSDKHttp.listRunResults()` to
|
|
593
|
+
* map API responses before returning them to consumers.
|
|
594
|
+
*
|
|
595
|
+
* @param item - Raw item response from the API
|
|
596
|
+
* @returns Enriched item entity with computed properties spread onto the original response
|
|
597
|
+
*/
|
|
598
|
+
declare const processRunItem: (item: ItemResultReadResponse) => ApplicationRunItem;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Determine whether a single run item's output artifact is available for download.
|
|
602
|
+
* Only items in the COMPLETED state have downloadable artifacts.
|
|
603
|
+
*
|
|
604
|
+
* @param item - Raw item response from the API
|
|
605
|
+
* @returns `true` if the item is in a COMPLETED state
|
|
606
|
+
*/
|
|
607
|
+
declare const canDownloadItem: (item: ItemResultReadResponse) => boolean;
|
|
608
|
+
/**
|
|
609
|
+
* Derive a human-readable {@link ItemStatus} from the raw API `state` and `termination_reason`.
|
|
610
|
+
*
|
|
611
|
+
* Mapping rules:
|
|
612
|
+
* - PENDING / PROCESSING → passed through as-is
|
|
613
|
+
* - TERMINATED + SYSTEM_ERROR or USER_ERROR → FAILED
|
|
614
|
+
* - TERMINATED + SKIPPED → SKIPPED
|
|
615
|
+
* - TERMINATED (otherwise) → COMPLETED
|
|
616
|
+
*
|
|
617
|
+
* @param item - Raw item response from the API
|
|
618
|
+
*/
|
|
619
|
+
declare function getItemStatus(item: ItemResultReadResponse): ItemStatus;
|
|
620
|
+
|
|
621
|
+
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 };
|