@aignostics/sdk 3.7.0 → 3.8.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.ts CHANGED
@@ -1,42 +1,7 @@
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-CGkiPRMR.js';
2
- export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, C as Configuration, j as ConfigurationParameters, k as CustomMetadataUpdateRequest, l as CustomMetadataUpdateResponse, G as GrantCreateRequest, m as GrantReadResponse, n as GrantRelation, H as HTTPValidationError, o as InputArtifact, p as InputArtifactCreationRequest, q as InputArtifactResultReadResponse, r as ItemCreationRequest, s as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, t as OutputArtifact, u as OutputArtifactResultReadResponse, v as OutputArtifactScope, w as OutputArtifactVisibility, P as PublicApi, x as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, y as PublicApiAxiosParamCreator, z as PublicApiCancelRunV1RunsRunIdCancelPostRequest, B as PublicApiCreateGrantV1AccessGrantsPostRequest, D as PublicApiCreateRunV1RunsPostRequest, E as PublicApiCreateShareTokenV1AccessShareTokensPostRequest, F as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, J as PublicApiFactory, K as PublicApiFp, L as PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, N as PublicApiGetGrantV1AccessGrantsGrantIdGetRequest, Q as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, S as PublicApiGetRunV1RunsRunIdGetRequest, T as PublicApiGetShareTokenV1AccessShareTokensShareTokenIdGetRequest, U as PublicApiGetVersionDocumentContentRequest, W as PublicApiGetVersionDocumentFileRequest, X as PublicApiGetVersionDocumentRequest, Y as PublicApiInterface, Z as PublicApiListApplicationsV1ApplicationsGetRequest, _ as PublicApiListGrantsV1AccessGrantsGetRequest, $ as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, a0 as PublicApiListRunsV1RunsGetRequest, a1 as PublicApiListShareTokensV1AccessShareTokensGetRequest, a2 as PublicApiListVersionDocumentsRequest, a3 as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, a4 as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, a5 as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, a6 as PublicApiRevokeGrantV1AccessGrantsGrantIdDeleteRequest, a7 as PublicApiRevokeShareTokenV1AccessShareTokensShareTokenIdDeleteRequest, a8 as ResourceType, a9 as RunItemStatistics, aa as RunOutput, ab as RunState, ac as RunTerminationReason, ad as SchedulingRequest, ae as SchedulingResponse, af as ShareTokenCreateRequest, ag as ShareTokenCreateResponse, ah as ShareTokenReadResponse, ai as SubjectType, aj as UserReadResponse, ak as ValidationError, al as ValidationErrorLocInner, am as VersionDocumentResponse, an as VersionDocumentVisibility } from './api-CGkiPRMR.js';
3
- import { Readable } from 'node:stream';
4
- import 'axios';
5
-
6
- /**
7
- * Enriched application run entity that extends the raw API response
8
- * with computed properties derived from run state and statistics.
9
- *
10
- * Returned by `PlatformSDKHttp.listApplicationRuns()` and `PlatformSDKHttp.getRun()`
11
- * instead of the raw `RunReadResponse`.
12
- */
13
- interface ApplicationRun extends RunReadResponse {
14
- /** Percentage of items processed (0–100), computed from run statistics. */
15
- progress: number;
16
- /** Human-readable status derived from `state` and `termination_reason`. */
17
- status: RunStatus;
18
- /** Whether the run's result items are available for download. */
19
- can_download: boolean;
20
- }
21
- /** Derived run status that simplifies the raw `state` + `termination_reason` combination. */
22
- type RunStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'COMPLETED_WITH_ERRORS' | 'CANCELED' | 'FAILED' | 'UNKNOWN';
23
-
24
- /**
25
- * Enriched run-item entity that extends the raw API response
26
- * with computed properties derived from item state and termination reason.
27
- *
28
- * Returned by `PlatformSDKHttp.listRunResults()` instead of the raw
29
- * `ItemResultReadResponse`.
30
- */
31
- interface ApplicationRunItem extends ItemResultReadResponse {
32
- /** Whether the item's output artifact is available for download. */
33
- can_download: boolean;
34
- /** Human-readable status derived from `state` and `termination_reason`. */
35
- status: string;
36
- }
37
- /** Derived item status that simplifies the raw `state` + `termination_reason` combination. */
38
- type ItemStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'SKIPPED' | 'UNKNOWN';
39
-
1
+ import { $ as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, A as PublicApiCancelRunV1RunsRunIdCancelPostRequest, B as PublicApiGetRunV1RunsRunIdGetRequest, C as OutputArtifact, Ct as Configuration, D as PublicApi, E as OutputArtifactVisibility, F as PublicApiFactory, G as PublicApiInterface, H as PublicApiGetVersionDocumentContentRequest, I as PublicApiFp, J as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, K as PublicApiListApplicationsV1ApplicationsGetRequest, L as PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, M as PublicApiCreateRunV1RunsPostRequest, N as PublicApiCreateShareTokenV1AccessShareTokensPostRequest, O as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, P as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, Q as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, R as PublicApiGetGrantV1AccessGrantsGrantIdGetRequest, S as OrganizationReadResponse, St as VersionReadResponse, T as OutputArtifactScope, U as PublicApiGetVersionDocumentFileRequest, V as PublicApiGetShareTokenV1AccessShareTokensShareTokenIdGetRequest, W as PublicApiGetVersionDocumentRequest, X as PublicApiListShareTokensV1AccessShareTokensGetRequest, Y as PublicApiListRunsV1RunsGetRequest, Z as PublicApiListVersionDocumentsRequest, _ as ItemOutput, _t as UserReadResponse, a as ArtifactState, at as RunCreationResponse, b as ItemTerminationReason, bt as VersionDocumentResponse, c as CustomMetadataUpdateResponse, ct as RunReadResponse, d as GrantRelation, dt as SchedulingRequest, et as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, f as HTTPValidationError, ft as SchedulingResponse, g as ItemCreationRequest, gt as SubjectType, h as InputArtifactResultReadResponse, ht as ShareTokenReadResponse, i as ArtifactOutput, it as RunCreationRequest, j as PublicApiCreateGrantV1AccessGrantsPostRequest, k as PublicApiAxiosParamCreator, l as GrantCreateRequest, lt as RunState, m as InputArtifactCreationRequest, mt as ShareTokenCreateResponse, n as ApplicationReadShortResponse, nt as PublicApiRevokeShareTokenV1AccessShareTokensShareTokenIdDeleteRequest, o as ArtifactTerminationReason, ot as RunItemStatistics, p as InputArtifact, pt as ShareTokenCreateRequest, q as PublicApiListGrantsV1AccessGrantsGetRequest, r as ApplicationVersion, rt as ResourceType, s as CustomMetadataUpdateRequest, st as RunOutput, t as ApplicationReadResponse, tt as PublicApiRevokeGrantV1AccessGrantsGrantIdDeleteRequest, u as GrantReadResponse, ut as RunTerminationReason, v as ItemResultReadResponse, vt as ValidationError, w as OutputArtifactResultReadResponse, wt as ConfigurationParameters, x as MeReadResponse, xt as VersionDocumentVisibility, y as ItemState, yt as ValidationErrorLocInner, z as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest } from "./index-B3pQQ0Yu.js";
2
+ import "axios";
3
+ import { Readable } from "node:stream";
4
+ //#region src/platform-sdk.d.ts
40
5
  /**
41
6
  * Token provider function that returns a valid access token
42
7
  */
@@ -45,456 +10,733 @@ type TokenProvider = () => Promise<string | null> | string | null;
45
10
  * Configuration options for the Platform SDK
46
11
  */
47
12
  interface PlatformSDKConfig {
48
- /**
49
- * Base URL for the API
50
- */
51
- baseURL?: string;
52
- /**
53
- * Token provider function for dynamic token retrieval
54
- * This function will be called when a token is needed
55
- */
56
- tokenProvider: TokenProvider;
57
- /**
58
- * Request timeout in milliseconds
59
- */
60
- timeout?: number;
13
+ /**
14
+ * Base URL for the API
15
+ */
16
+ baseURL?: string;
17
+ /**
18
+ * Token provider function for dynamic token retrieval
19
+ * This function will be called when a token is needed
20
+ */
21
+ tokenProvider: TokenProvider;
22
+ /**
23
+ * Request timeout in milliseconds
24
+ */
25
+ timeout?: number;
61
26
  }
62
27
  interface PlatformSDK {
63
- getVersion(): string;
64
- getConfig(): PlatformSDKConfig;
65
- testConnection(): Promise<boolean>;
66
- listApplications(): Promise<ApplicationReadShortResponse[]>;
67
- getApplication(applicationId: string): Promise<ApplicationReadResponse>;
68
- listApplicationRuns(options?: {
69
- applicationId?: string;
70
- applicationVersion?: string;
71
- page?: number;
72
- pageSize?: number;
73
- customMetadata?: string;
74
- sort?: string[];
75
- }): Promise<ApplicationRun[]>;
76
- createApplicationRun(request: RunCreationRequest): Promise<RunCreationResponse>;
77
- getRun(applicationRunId: string): Promise<ApplicationRun>;
78
- cancelApplicationRun(applicationRunId: string): Promise<void>;
79
- listRunResults(applicationRunId: string, options?: {
80
- page?: number;
81
- pageSize?: number;
82
- sort?: string[];
83
- externalIdIn?: string[];
84
- state?: ItemState;
85
- terminationReason?: ItemTerminationReason;
86
- }): Promise<ApplicationRunItem[]>;
87
- getApplicationVersionDetails(applicationId: string, version: string): Promise<VersionReadResponse>;
88
- downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
89
- downloadArtifactStream(runId: string, artifactId: string): Promise<Readable>;
28
+ getVersion(): string;
29
+ getConfig(): PlatformSDKConfig;
30
+ testConnection(): Promise<boolean>;
31
+ listApplications(): Promise<ApplicationReadShortResponse[]>;
32
+ getApplication(applicationId: string): Promise<ApplicationReadResponse>;
33
+ listApplicationRuns(options?: {
34
+ applicationId?: string;
35
+ applicationVersion?: string;
36
+ page?: number;
37
+ pageSize?: number;
38
+ customMetadata?: string;
39
+ sort?: string[];
40
+ }): Promise<RunReadResponse[]>;
41
+ createApplicationRun(request: RunCreationRequest): Promise<RunCreationResponse>;
42
+ getRun(applicationRunId: string): Promise<RunReadResponse>;
43
+ cancelApplicationRun(applicationRunId: string): Promise<void>;
44
+ listRunResults(applicationRunId: string, options?: {
45
+ page?: number;
46
+ pageSize?: number;
47
+ sort?: string[];
48
+ externalIdIn?: string[];
49
+ state?: ItemState;
50
+ terminationReason?: ItemTerminationReason;
51
+ }): Promise<ItemResultReadResponse[]>;
52
+ getRunItem(applicationRunId: string, externalId: string): Promise<ItemResultReadResponse>;
53
+ updateRunMetadata(applicationRunId: string, customMetadata: Record<string, unknown> | null, customMetadataChecksum?: string | null): Promise<CustomMetadataUpdateResponse>;
54
+ updateRunItemMetadata(applicationRunId: string, externalId: string, customMetadata: Record<string, unknown> | null, customMetadataChecksum?: string | null): Promise<CustomMetadataUpdateResponse>;
55
+ deleteRunResults(applicationRunId: string): Promise<void>;
56
+ getApplicationVersionDetails(applicationId: string, version: string): Promise<VersionReadResponse>;
57
+ downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
58
+ downloadArtifactStream(runId: string, artifactId: string): Promise<Readable>;
59
+ createGrant(request: GrantCreateRequest): Promise<GrantReadResponse>;
60
+ listGrants(options?: {
61
+ resourceType?: ResourceType;
62
+ resourceId?: string;
63
+ subjectType?: SubjectType;
64
+ subjectId?: string;
65
+ relation?: GrantRelation[];
66
+ revoked?: boolean;
67
+ page?: number;
68
+ pageSize?: number;
69
+ sort?: string[];
70
+ }): Promise<GrantReadResponse[]>;
71
+ getGrant(grantId: string): Promise<GrantReadResponse>;
72
+ revokeGrant(grantId: string): Promise<GrantReadResponse>;
73
+ createShareToken(request: ShareTokenCreateRequest): Promise<ShareTokenCreateResponse>;
74
+ listShareTokens(options?: {
75
+ runId?: string;
76
+ createdBy?: string;
77
+ revoked?: boolean;
78
+ page?: number;
79
+ pageSize?: number;
80
+ sort?: string[];
81
+ }): Promise<ShareTokenReadResponse[]>;
82
+ getShareToken(shareTokenId: string): Promise<ShareTokenReadResponse>;
83
+ revokeShareToken(shareTokenId: string): Promise<ShareTokenReadResponse>;
90
84
  }
91
85
  /**
92
86
  * Main SDK class for interacting with the Aignostics Platform
93
87
  */
94
88
  declare class PlatformSDKHttp implements PlatformSDK {
95
- #private;
96
- /**
97
- * Creates a new instance of the Platform SDK
98
- * @param config Configuration options
99
- */
100
- constructor(config: PlatformSDKConfig);
101
- /**
102
- * Test the connection to the Aignostics Platform API
103
- *
104
- * This method performs a simple API call to verify that the SDK can successfully
105
- * connect to the platform using the provided configuration and authentication.
106
- * It's useful for validating setup and troubleshooting connectivity issues.
107
- *
108
- * @returns A promise that resolves to `true` if the connection is successful
109
- * @throws {AuthenticationError} If no valid authentication token is available
110
- * @throws {Error} If the connection test fails due to network issues or API errors
111
- *
112
- * @example
113
- * ```typescript
114
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
115
- *
116
- * try {
117
- * const isConnected = await sdk.testConnection();
118
- * console.log('Connection successful:', isConnected);
119
- * } catch (error) {
120
- * console.error('Connection failed:', error.message);
121
- * }
122
- * ```
123
- */
124
- testConnection(): Promise<boolean>;
125
- /**
126
- * Retrieve a list of all available applications on the platform
127
- *
128
- * This method fetches all applications that are accessible with the current
129
- * authentication credentials. Applications represent different AI models or
130
- * processing pipelines available on the Aignostics Platform.
131
- *
132
- * @returns A promise that resolves to an array of application objects
133
- * @throws {AuthenticationError} If no valid authentication token is available
134
- * @throws {Error} If the request fails due to network issues or API errors
135
- *
136
- * @example
137
- * ```typescript
138
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
139
- *
140
- * try {
141
- * const applications = await sdk.listApplications();
142
- * console.log(`Found ${applications.length} applications`);
143
- * applications.forEach(app => {
144
- * console.log(`- ${app.name} (ID: ${app.id})`);
145
- * });
146
- * } catch (error) {
147
- * console.error('Failed to list applications:', error.message);
148
- * }
149
- * ```
150
- */
151
- listApplications(): Promise<ApplicationReadShortResponse[]>;
152
- /**
153
- * Retrieve detailed information about a specific application version
154
- *
155
- * This method fetches comprehensive details about a specific version of an
156
- * application, including its changelog, release date, and any version-specific
157
- * configurations or features.
158
- *
159
- * @param applicationId - The unique identifier of the application
160
- * @param version - The version string of the application to retrieve
161
- * @returns A promise that resolves to the application version details
162
- * @throws {Error} If the request fails due to network issues, authentication problems, invalid application ID or version, or API errors
163
- *
164
- * @example
165
- * ```typescript
166
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
167
- *
168
- * try {
169
- * const appVersion = await sdk.getApplicationVersionDetails('app-123', 'v1.2.0');
170
- * console.log(`Application Version: ${appVersion.version}`);
171
- * console.log(`Release Date: ${appVersion.release_date}`);
172
- * console.log(`Changelog: ${appVersion.changelog}`);
173
- * } catch (error) {
174
- * console.error('Failed to get application version details:', error.message);
175
- * }
176
- * ```
177
- */
178
- getApplicationVersionDetails(applicationId: string, version: string): Promise<VersionReadResponse>;
179
- /**
180
- * Retrieve detailed information about a specific application
181
- *
182
- * This method fetches comprehensive details about an application, including
183
- * its name, description, regulatory classes, and all available versions.
184
- * This provides more detailed information compared to the summary returned
185
- * by `listApplications()`.
186
- *
187
- * @param applicationId - The unique identifier of the application to retrieve
188
- * @returns A promise that resolves to the complete application details
189
- * @throws {Error} If the request fails due to network issues, authentication problems, invalid application ID, or API errors
190
- *
191
- * @example
192
- * ```typescript
193
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
194
- *
195
- * try {
196
- * const application = await sdk.getApplication('app-123');
197
- * console.log(`Application: ${application.name}`);
198
- * console.log(`Description: ${application.description}`);
199
- * console.log(`Available versions: ${application.versions.length}`);
200
- *
201
- * application.versions.forEach(version => {
202
- * console.log(`- ${version.version} (ID: ${version.application_version_id})`);
203
- * });
204
- * } catch (error) {
205
- * console.error('Failed to get application details:', error.message);
206
- * }
207
- * ```
208
- */
209
- getApplication(applicationId: string): Promise<ApplicationReadResponse>;
210
- /**
211
- * Retrieve a list of application runs with optional filtering
212
- *
213
- * This method fetches application runs (processing jobs) that have been
214
- * submitted to the platform. You can optionally filter by application ID
215
- * and/or application version to narrow down the results.
216
- *
217
- * @param options - Optional filtering parameters
218
- * @param options.applicationId - Filter runs by specific application ID
219
- * @param options.applicationVersion - Filter runs by specific application version
220
- * @returns A promise that resolves to an array of application run objects
221
- * @throws {Error} If the request fails due to network issues, authentication problems, or API errors
222
- *
223
- * @example
224
- * ```typescript
225
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
226
- *
227
- * try {
228
- * // Get all runs
229
- * const allRuns = await sdk.listApplicationRuns();
230
- *
231
- * // Get runs for a specific application
232
- * const appRuns = await sdk.listApplicationRuns({
233
- * applicationId: 'app-123'
234
- * });
235
- *
236
- * // Get runs for a specific application version
237
- * const versionRuns = await sdk.listApplicationRuns({
238
- * applicationId: 'app-123',
239
- * applicationVersion: 'v1.2.0'
240
- * });
241
- *
242
- * console.log(`Found ${allRuns.length} total runs`);
243
- * } catch (error) {
244
- * console.error('Failed to list application runs:', error.message);
245
- * }
246
- * ```
247
- */
248
- listApplicationRuns(options?: {
249
- applicationId?: string;
250
- applicationVersion?: string;
251
- customMetadata?: string;
252
- sort?: string[];
253
- page?: number;
254
- pageSize?: number;
255
- }): Promise<ApplicationRun[]>;
256
- /**
257
- * Create and submit a new application run for processing
258
- *
259
- * This method creates a new processing job by submitting data items to a
260
- * specific application version. The run will be queued and processed
261
- * asynchronously on the Aignostics Platform.
262
- *
263
- * @param request - The run creation request containing application version ID and items to process
264
- * @returns A promise that resolves to the created run response with run ID and status
265
- * @throws {Error} If the request fails due to network issues, authentication problems, invalid request data, or API errors
266
- *
267
- * @example
268
- * ```typescript
269
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
270
- *
271
- * try {
272
- * const runRequest = {
273
- * application_version_id: 'app-version-123',
274
- * items: [
275
- * {
276
- * id: 'item-1',
277
- * data: { }
278
- * },
279
- * {
280
- * id: 'item-2',
281
- * data: { }
282
- * }
283
- * ]
284
- * };
285
- *
286
- * const run = await sdk.createApplicationRun(runRequest);
287
- * console.log(`Created run with ID: ${run.id}`);
288
- * console.log(`Status: ${run.status}`);
289
- * } catch (error) {
290
- * console.error('Failed to create application run:', error.message);
291
- * }
292
- * ```
293
- */
294
- createApplicationRun(request: RunCreationRequest): Promise<RunCreationResponse>;
295
- /**
296
- * Retrieve detailed information about a specific application run
297
- *
298
- * This method fetches complete details about a processing job, including
299
- * its current status, progress, metadata, and execution information.
300
- *
301
- * @param applicationRunId - The unique identifier of the application run
302
- * @returns A promise that resolves to the run details object
303
- * @throws {Error} If the request fails due to network issues, authentication problems, invalid run ID, or API errors
304
- *
305
- * @example
306
- * ```typescript
307
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
308
- *
309
- * try {
310
- * const run = await sdk.getRun('run-123');
311
- * console.log(`Run ID: ${run.id}`);
312
- * console.log(`Status: ${run.status}`);
313
- * console.log(`Progress: ${run.progress}%`);
314
- * console.log(`Created: ${run.created_at}`);
315
- * } catch (error) {
316
- * console.error('Failed to get run details:', error.message);
317
- * }
318
- * ```
319
- */
320
- getRun(applicationRunId: string): Promise<ApplicationRun>;
321
- /**
322
- * Cancel a running or queued application run
323
- *
324
- * This method attempts to cancel an application run that is currently
325
- * in progress or waiting in the queue. Once cancelled, the run cannot
326
- * be resumed and will transition to a cancelled state.
327
- *
328
- * @param applicationRunId - The unique identifier of the application run to cancel
329
- * @returns A promise that resolves when the cancellation request is successful
330
- * @throws {Error} If the request fails due to network issues, authentication problems, invalid run ID, or if the run cannot be cancelled
331
- *
332
- * @example
333
- * ```typescript
334
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
335
- *
336
- * try {
337
- * await sdk.cancelApplicationRun('run-123');
338
- * console.log('Run cancellation requested successfully');
339
- *
340
- * // Check the status to confirm cancellation
341
- * const run = await sdk.getRun('run-123');
342
- * console.log(`Updated status: ${run.status}`);
343
- * } catch (error) {
344
- * console.error('Failed to cancel run:', error.message);
345
- * }
346
- * ```
347
- */
348
- cancelApplicationRun(applicationRunId: string): Promise<void>;
349
- /**
350
- * Retrieve the processing results for a completed application run
351
- *
352
- * This method fetches all result items produced by a completed application run.
353
- * Results include the processed data, analysis outcomes, and any generated
354
- * artifacts from the AI model execution.
355
- *
356
- * @param applicationRunId - The unique identifier of the application run
357
- * @returns A promise that resolves to an array of result items
358
- * @throws {Error} If the request fails due to network issues, authentication problems, invalid run ID, or API errors
359
- *
360
- * @example
361
- * ```typescript
362
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
363
- *
364
- * try {
365
- * const results = await sdk.listRunResults('run-123');
366
- * console.log(`Found ${results.length} result items`);
367
- *
368
- * results.forEach((result, index) => {
369
- * console.log(`Result ${index + 1}:`);
370
- * console.log(`- Item ID: ${result.item_id}`);
371
- * console.log(`- Status: ${result.status}`);
372
- * console.log(`- Data: ${JSON.stringify(result.data)}`);
373
- * });
374
- * } catch (error) {
375
- * console.error('Failed to list run results:', error.message);
376
- * }
377
- * ```
378
- */
379
- listRunResults(applicationRunId: string, { page, pageSize, sort, externalIdIn, state, terminationReason, }?: {
380
- page?: number;
381
- pageSize?: number;
382
- sort?: string[];
383
- externalIdIn?: string[];
384
- state?: ItemState;
385
- terminationReason?: ItemTerminationReason;
386
- }): Promise<ApplicationRunItem[]>;
387
- /**
388
- * Get the current version of the SDK
389
- *
390
- * This method returns the version string of the Platform SDK, which can be
391
- * useful for debugging, logging, or ensuring compatibility with API versions.
392
- *
393
- * @returns The SDK version string (e.g., "1.2.3")
394
- *
395
- * @example
396
- * ```typescript
397
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
398
- * console.log(`Using SDK version: ${sdk.getVersion()}`);
399
- * ```
400
- */
401
- getVersion(): string;
402
- /**
403
- * Get the current SDK configuration
404
- *
405
- * This method returns a copy of the current configuration used by the SDK,
406
- * including the base URL, timeout settings, and other options. The returned
407
- * object is a copy to prevent accidental modification of the internal config.
408
- *
409
- * @returns A copy of the current SDK configuration object
410
- *
411
- * @example
412
- * ```typescript
413
- * const sdk = new PlatformSDKHttp({
414
- * baseURL: 'https://api.aignostics.com',
415
- * tokenProvider: () => 'your-token',
416
- * timeout: 30000
417
- * });
418
- *
419
- * const config = sdk.getConfig();
420
- * console.log(`Base URL: ${config.baseURL}`);
421
- * console.log(`Timeout: ${config.timeout}ms`);
422
- * ```
423
- */
424
- getConfig(): PlatformSDKConfig;
425
- /**
426
- * Download an artifact file from a completed application run
427
- *
428
- * This method retrieves the binary content of a specific artifact produced
429
- * during an application run. Artifacts can include generated reports, processed
430
- * images, or other output files from the AI model execution.
431
- *
432
- * The download is performed with automatic retries for transient failures.
433
- * Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
434
- *
435
- * @param runId - The unique identifier of the application run
436
- * @param artifactId - The unique identifier of the artifact to download
437
- * @returns A promise that resolves to an ArrayBuffer containing the artifact's binary content
438
- * @throws {AuthenticationError} If no valid authentication token is available
439
- * @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
440
- * @throws {UnexpectedError} If a non-HTTP error occurs
441
- *
442
- * @example
443
- * ```typescript
444
- * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
445
- *
446
- * try {
447
- * const buffer = await sdk.downloadArtifact('run-123', 'artifact-456');
448
- * console.log(`Downloaded ${buffer.byteLength} bytes`);
449
- *
450
- * // Write to file (Node.js)
451
- * fs.writeFileSync('output.bin', Buffer.from(buffer));
452
- * } catch (error) {
453
- * console.error('Failed to download artifact:', error.message);
454
- * }
455
- * ```
456
- */
457
- downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
458
- /**
459
- * Download an artifact file from a completed application run as a stream
460
- *
461
- * Prefer this method over `downloadArtifact` when downloading large (e.g. multi-gigabyte)
462
- * artifacts: instead of buffering the entire file into memory before returning it, this
463
- * method streams the artifact's bytes as they arrive, keeping memory usage low regardless
464
- * of the artifact's size.
465
- *
466
- * The download is performed with automatic retries for transient failures.
467
- * Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
468
- *
469
- * @param runId - The unique identifier of the application run
470
- * @param artifactId - The unique identifier of the artifact to download
471
- * @returns A promise that resolves to a Node.js `Readable` stream yielding the artifact's binary content
472
- * @throws {AuthenticationError} If no valid authentication token is available
473
- * @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
474
- * @throws {UnexpectedError} If a non-HTTP error occurs
475
- *
476
- * @example
477
- * ```typescript
478
- * import { pipeline } from 'node:stream/promises';
479
- * import { createWriteStream } from 'node:fs';
480
- *
481
- * const stream = await sdk.downloadArtifactStream('run-123', 'artifact-456');
482
- * await pipeline(stream, createWriteStream('output.bin'));
483
- * ```
484
- *
485
- * @remarks
486
- * Retries only cover failures at the initial-request stage (a non-2xx status surfaced from
487
- * the response headers before the body begins streaming). Once the response body has started
488
- * streaming, a mid-stream connection drop CANNOT be retried by this method — the consumer must
489
- * listen for the stream's `error` event and re-download if needed.
490
- */
491
- downloadArtifactStream(runId: string, artifactId: string): Promise<Readable>;
89
+ #private;
90
+ /**
91
+ * Creates a new instance of the Platform SDK
92
+ * @param config Configuration options
93
+ */
94
+ constructor(config: PlatformSDKConfig);
95
+ /**
96
+ * Test the connection to the Aignostics Platform API
97
+ *
98
+ * This method performs a simple API call to verify that the SDK can successfully
99
+ * connect to the platform using the provided configuration and authentication.
100
+ * It's useful for validating setup and troubleshooting connectivity issues.
101
+ *
102
+ * @returns A promise that resolves to `true` if the connection is successful
103
+ * @throws {AuthenticationError} If no valid authentication token is available
104
+ * @throws {Error} If the connection test fails due to network issues or API errors
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
109
+ *
110
+ * try {
111
+ * const isConnected = await sdk.testConnection();
112
+ * console.log('Connection successful:', isConnected);
113
+ * } catch (error) {
114
+ * console.error('Connection failed:', error.message);
115
+ * }
116
+ * ```
117
+ */
118
+ testConnection(): Promise<boolean>;
119
+ /**
120
+ * Retrieve a list of all available applications on the platform
121
+ *
122
+ * This method fetches all applications that are accessible with the current
123
+ * authentication credentials. Applications represent different AI models or
124
+ * processing pipelines available on the Aignostics Platform.
125
+ *
126
+ * @returns A promise that resolves to an array of application objects
127
+ * @throws {AuthenticationError} If no valid authentication token is available
128
+ * @throws {Error} If the request fails due to network issues or API errors
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
133
+ *
134
+ * try {
135
+ * const applications = await sdk.listApplications();
136
+ * console.log(`Found ${applications.length} applications`);
137
+ * applications.forEach(app => {
138
+ * console.log(`- ${app.name} (ID: ${app.id})`);
139
+ * });
140
+ * } catch (error) {
141
+ * console.error('Failed to list applications:', error.message);
142
+ * }
143
+ * ```
144
+ */
145
+ listApplications(): Promise<ApplicationReadShortResponse[]>;
146
+ /**
147
+ * Retrieve detailed information about a specific application version
148
+ *
149
+ * This method fetches comprehensive details about a specific version of an
150
+ * application, including its changelog, release date, and any version-specific
151
+ * configurations or features.
152
+ *
153
+ * @param applicationId - The unique identifier of the application
154
+ * @param version - The version string of the application to retrieve
155
+ * @returns A promise that resolves to the application version details
156
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid application ID or version, or API errors
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
161
+ *
162
+ * try {
163
+ * const appVersion = await sdk.getApplicationVersionDetails('app-123', 'v1.2.0');
164
+ * console.log(`Application Version: ${appVersion.version}`);
165
+ * console.log(`Release Date: ${appVersion.release_date}`);
166
+ * console.log(`Changelog: ${appVersion.changelog}`);
167
+ * } catch (error) {
168
+ * console.error('Failed to get application version details:', error.message);
169
+ * }
170
+ * ```
171
+ */
172
+ getApplicationVersionDetails(applicationId: string, version: string): Promise<VersionReadResponse>;
173
+ /**
174
+ * Retrieve detailed information about a specific application
175
+ *
176
+ * This method fetches comprehensive details about an application, including
177
+ * its name, description, regulatory classes, and all available versions.
178
+ * This provides more detailed information compared to the summary returned
179
+ * by `listApplications()`.
180
+ *
181
+ * @param applicationId - The unique identifier of the application to retrieve
182
+ * @returns A promise that resolves to the complete application details
183
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid application ID, or API errors
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
188
+ *
189
+ * try {
190
+ * const application = await sdk.getApplication('app-123');
191
+ * console.log(`Application: ${application.name}`);
192
+ * console.log(`Description: ${application.description}`);
193
+ * console.log(`Available versions: ${application.versions.length}`);
194
+ *
195
+ * application.versions.forEach(version => {
196
+ * console.log(`- ${version.version} (ID: ${version.application_version_id})`);
197
+ * });
198
+ * } catch (error) {
199
+ * console.error('Failed to get application details:', error.message);
200
+ * }
201
+ * ```
202
+ */
203
+ getApplication(applicationId: string): Promise<ApplicationReadResponse>;
204
+ /**
205
+ * Retrieve a list of application runs with optional filtering
206
+ *
207
+ * This method fetches application runs (processing jobs) that have been
208
+ * submitted to the platform. You can optionally filter by application ID
209
+ * and/or application version to narrow down the results.
210
+ *
211
+ * @param options - Optional filtering parameters
212
+ * @param options.applicationId - Filter runs by specific application ID
213
+ * @param options.applicationVersion - Filter runs by specific application version
214
+ * @returns A promise that resolves to an array of application run objects
215
+ * @throws {Error} If the request fails due to network issues, authentication problems, or API errors
216
+ *
217
+ * @example
218
+ * ```typescript
219
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
220
+ *
221
+ * try {
222
+ * // Get all runs
223
+ * const allRuns = await sdk.listApplicationRuns();
224
+ *
225
+ * // Get runs for a specific application
226
+ * const appRuns = await sdk.listApplicationRuns({
227
+ * applicationId: 'app-123'
228
+ * });
229
+ *
230
+ * // Get runs for a specific application version
231
+ * const versionRuns = await sdk.listApplicationRuns({
232
+ * applicationId: 'app-123',
233
+ * applicationVersion: 'v1.2.0'
234
+ * });
235
+ *
236
+ * console.log(`Found ${allRuns.length} total runs`);
237
+ * } catch (error) {
238
+ * console.error('Failed to list application runs:', error.message);
239
+ * }
240
+ * ```
241
+ */
242
+ listApplicationRuns(options?: {
243
+ applicationId?: string;
244
+ applicationVersion?: string;
245
+ customMetadata?: string;
246
+ sort?: string[];
247
+ page?: number;
248
+ pageSize?: number;
249
+ }): Promise<RunReadResponse[]>;
250
+ /**
251
+ * Create and submit a new application run for processing
252
+ *
253
+ * This method creates a new processing job by submitting data items to a
254
+ * specific application version. The run will be queued and processed
255
+ * asynchronously on the Aignostics Platform.
256
+ *
257
+ * @param request - The run creation request containing application version ID and items to process
258
+ * @returns A promise that resolves to the created run response with run ID and status
259
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid request data, or API errors
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
264
+ *
265
+ * try {
266
+ * const runRequest = {
267
+ * application_version_id: 'app-version-123',
268
+ * items: [
269
+ * {
270
+ * id: 'item-1',
271
+ * data: { }
272
+ * },
273
+ * {
274
+ * id: 'item-2',
275
+ * data: { }
276
+ * }
277
+ * ]
278
+ * };
279
+ *
280
+ * const run = await sdk.createApplicationRun(runRequest);
281
+ * console.log(`Created run with ID: ${run.id}`);
282
+ * console.log(`Status: ${run.status}`);
283
+ * } catch (error) {
284
+ * console.error('Failed to create application run:', error.message);
285
+ * }
286
+ * ```
287
+ */
288
+ createApplicationRun(request: RunCreationRequest): Promise<RunCreationResponse>;
289
+ /**
290
+ * Retrieve detailed information about a specific application run
291
+ *
292
+ * This method fetches complete details about a processing job, including
293
+ * its current status, progress, metadata, and execution information.
294
+ *
295
+ * @param applicationRunId - The unique identifier of the application run
296
+ * @returns A promise that resolves to the run details object
297
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid run ID, or API errors
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
302
+ *
303
+ * try {
304
+ * const run = await sdk.getRun('run-123');
305
+ * console.log(`Run ID: ${run.id}`);
306
+ * console.log(`Status: ${run.status}`);
307
+ * console.log(`Progress: ${run.progress}%`);
308
+ * console.log(`Created: ${run.created_at}`);
309
+ * } catch (error) {
310
+ * console.error('Failed to get run details:', error.message);
311
+ * }
312
+ * ```
313
+ */
314
+ getRun(applicationRunId: string): Promise<RunReadResponse>;
315
+ /**
316
+ * Cancel a running or queued application run
317
+ *
318
+ * This method attempts to cancel an application run that is currently
319
+ * in progress or waiting in the queue. Once cancelled, the run cannot
320
+ * be resumed and will transition to a cancelled state.
321
+ *
322
+ * @param applicationRunId - The unique identifier of the application run to cancel
323
+ * @returns A promise that resolves when the cancellation request is successful
324
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid run ID, or if the run cannot be cancelled
325
+ *
326
+ * @example
327
+ * ```typescript
328
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
329
+ *
330
+ * try {
331
+ * await sdk.cancelApplicationRun('run-123');
332
+ * console.log('Run cancellation requested successfully');
333
+ *
334
+ * // Check the status to confirm cancellation
335
+ * const run = await sdk.getRun('run-123');
336
+ * console.log(`Updated status: ${run.status}`);
337
+ * } catch (error) {
338
+ * console.error('Failed to cancel run:', error.message);
339
+ * }
340
+ * ```
341
+ */
342
+ cancelApplicationRun(applicationRunId: string): Promise<void>;
343
+ /**
344
+ * Retrieve the processing results for a completed application run
345
+ *
346
+ * This method fetches all result items produced by a completed application run.
347
+ * Results include the processed data, analysis outcomes, and any generated
348
+ * artifacts from the AI model execution.
349
+ *
350
+ * @param applicationRunId - The unique identifier of the application run
351
+ * @returns A promise that resolves to an array of result items
352
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid run ID, or API errors
353
+ *
354
+ * @example
355
+ * ```typescript
356
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
357
+ *
358
+ * try {
359
+ * const results = await sdk.listRunResults('run-123');
360
+ * console.log(`Found ${results.length} result items`);
361
+ *
362
+ * results.forEach((result, index) => {
363
+ * console.log(`Result ${index + 1}:`);
364
+ * console.log(`- Item ID: ${result.item_id}`);
365
+ * console.log(`- Status: ${result.status}`);
366
+ * console.log(`- Data: ${JSON.stringify(result.data)}`);
367
+ * });
368
+ * } catch (error) {
369
+ * console.error('Failed to list run results:', error.message);
370
+ * }
371
+ * ```
372
+ */
373
+ listRunResults(applicationRunId: string, { page, pageSize, sort, externalIdIn, state, terminationReason }?: {
374
+ page?: number;
375
+ pageSize?: number;
376
+ sort?: string[];
377
+ externalIdIn?: string[];
378
+ state?: ItemState;
379
+ terminationReason?: ItemTerminationReason;
380
+ }): Promise<ItemResultReadResponse[]>;
381
+ /**
382
+ * Retrieve a single item from an application run by its external ID
383
+ *
384
+ * This method fetches details for one specific result item within a run,
385
+ * identified by the `external_id` supplied when the run was created.
386
+ *
387
+ * @param applicationRunId - The unique identifier of the application run
388
+ * @param externalId - The external ID of the item, as supplied when creating the run
389
+ * @returns A promise that resolves to the enriched run item
390
+ * @throws {AuthenticationError} If no valid authentication token is available
391
+ * @throws {APIError} If the request fails (e.g., 404 if the item doesn't exist)
392
+ *
393
+ * @example
394
+ * ```typescript
395
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
396
+ *
397
+ * try {
398
+ * const item = await sdk.getRunItem('run-123', 'slide-001');
399
+ * console.log(`Item status: ${item.status}`);
400
+ * } catch (error) {
401
+ * console.error('Failed to get run item:', error.message);
402
+ * }
403
+ * ```
404
+ */
405
+ getRunItem(applicationRunId: string, externalId: string): Promise<ItemResultReadResponse>;
406
+ /**
407
+ * Set (replace) the custom metadata attached to an application run
408
+ *
409
+ * This method overwrites the run's custom metadata, an arbitrary JSON object
410
+ * that consumers can use to store their own attributes (e.g. tags, notes,
411
+ * external references) alongside a run. Pass `null` to clear existing metadata.
412
+ *
413
+ * @param applicationRunId - The unique identifier of the application run
414
+ * @param customMetadata - The new custom metadata object, or `null` to clear it
415
+ * @param customMetadataChecksum - Optional checksum for optimistic concurrency control
416
+ * @returns A promise that resolves to the updated metadata checksum
417
+ * @throws {AuthenticationError} If no valid authentication token is available
418
+ * @throws {APIError} If the request fails (e.g., 404 if the run doesn't exist, 422 on checksum mismatch)
419
+ *
420
+ * @example
421
+ * ```typescript
422
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
423
+ *
424
+ * try {
425
+ * await sdk.updateRunMetadata('run-123', { note: 'Reviewed by QA' });
426
+ * } catch (error) {
427
+ * console.error('Failed to update run metadata:', error.message);
428
+ * }
429
+ * ```
430
+ */
431
+ updateRunMetadata(applicationRunId: string, customMetadata: Record<string, unknown> | null, customMetadataChecksum?: string | null): Promise<CustomMetadataUpdateResponse>;
432
+ /**
433
+ * Set (replace) the custom metadata attached to a single run item
434
+ *
435
+ * This method overwrites the custom metadata of one item within a run,
436
+ * identified by its `external_id`. Pass `null` to clear existing metadata.
437
+ *
438
+ * @param applicationRunId - The unique identifier of the application run
439
+ * @param externalId - The external ID of the item, as supplied when creating the run
440
+ * @param customMetadata - The new custom metadata object, or `null` to clear it
441
+ * @param customMetadataChecksum - Optional checksum for optimistic concurrency control
442
+ * @returns A promise that resolves to the updated metadata checksum
443
+ * @throws {AuthenticationError} If no valid authentication token is available
444
+ * @throws {APIError} If the request fails (e.g., 404 if the item doesn't exist, 422 on checksum mismatch)
445
+ *
446
+ * @example
447
+ * ```typescript
448
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
449
+ *
450
+ * try {
451
+ * await sdk.updateRunItemMetadata('run-123', 'slide-001', { reviewed: true });
452
+ * } catch (error) {
453
+ * console.error('Failed to update run item metadata:', error.message);
454
+ * }
455
+ * ```
456
+ */
457
+ updateRunItemMetadata(applicationRunId: string, externalId: string, customMetadata: Record<string, unknown> | null, customMetadataChecksum?: string | null): Promise<CustomMetadataUpdateResponse>;
458
+ /**
459
+ * Delete the results (output artifacts) of an application run
460
+ *
461
+ * This method permanently deletes the output artifacts produced by a
462
+ * terminated run. The run and its items remain queryable, but their
463
+ * output artifacts are no longer available for download.
464
+ *
465
+ * @param applicationRunId - The unique identifier of the application run
466
+ * @returns A promise that resolves when the deletion request succeeds
467
+ * @throws {AuthenticationError} If no valid authentication token is available
468
+ * @throws {APIError} If the request fails (e.g., 404 if the run doesn't exist)
469
+ *
470
+ * @example
471
+ * ```typescript
472
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
473
+ *
474
+ * try {
475
+ * await sdk.deleteRunResults('run-123');
476
+ * console.log('Run results deleted');
477
+ * } catch (error) {
478
+ * console.error('Failed to delete run results:', error.message);
479
+ * }
480
+ * ```
481
+ */
482
+ deleteRunResults(applicationRunId: string): Promise<void>;
483
+ /**
484
+ * Get the current version of the SDK
485
+ *
486
+ * This method returns the version string of the Platform SDK, which can be
487
+ * useful for debugging, logging, or ensuring compatibility with API versions.
488
+ *
489
+ * @returns The SDK version string (e.g., "1.2.3")
490
+ *
491
+ * @example
492
+ * ```typescript
493
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
494
+ * console.log(`Using SDK version: ${sdk.getVersion()}`);
495
+ * ```
496
+ */
497
+ getVersion(): string;
498
+ /**
499
+ * Get the current SDK configuration
500
+ *
501
+ * This method returns a copy of the current configuration used by the SDK,
502
+ * including the base URL, timeout settings, and other options. The returned
503
+ * object is a copy to prevent accidental modification of the internal config.
504
+ *
505
+ * @returns A copy of the current SDK configuration object
506
+ *
507
+ * @example
508
+ * ```typescript
509
+ * const sdk = new PlatformSDKHttp({
510
+ * baseURL: 'https://api.aignostics.com',
511
+ * tokenProvider: () => 'your-token',
512
+ * timeout: 30000
513
+ * });
514
+ *
515
+ * const config = sdk.getConfig();
516
+ * console.log(`Base URL: ${config.baseURL}`);
517
+ * console.log(`Timeout: ${config.timeout}ms`);
518
+ * ```
519
+ */
520
+ getConfig(): PlatformSDKConfig;
521
+ /**
522
+ * Download an artifact file from a completed application run
523
+ *
524
+ * This method retrieves the binary content of a specific artifact produced
525
+ * during an application run. Artifacts can include generated reports, processed
526
+ * images, or other output files from the AI model execution.
527
+ *
528
+ * The download is performed with automatic retries for transient failures.
529
+ * Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
530
+ *
531
+ * @param runId - The unique identifier of the application run
532
+ * @param artifactId - The unique identifier of the artifact to download
533
+ * @returns A promise that resolves to an ArrayBuffer containing the artifact's binary content
534
+ * @throws {AuthenticationError} If no valid authentication token is available
535
+ * @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
536
+ * @throws {UnexpectedError} If a non-HTTP error occurs
537
+ *
538
+ * @example
539
+ * ```typescript
540
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
541
+ *
542
+ * try {
543
+ * const buffer = await sdk.downloadArtifact('run-123', 'artifact-456');
544
+ * console.log(`Downloaded ${buffer.byteLength} bytes`);
545
+ *
546
+ * // Write to file (Node.js)
547
+ * fs.writeFileSync('output.bin', Buffer.from(buffer));
548
+ * } catch (error) {
549
+ * console.error('Failed to download artifact:', error.message);
550
+ * }
551
+ * ```
552
+ */
553
+ downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
554
+ /**
555
+ * Download an artifact file from a completed application run as a stream
556
+ *
557
+ * Prefer this method over `downloadArtifact` when downloading large (e.g. multi-gigabyte)
558
+ * artifacts: instead of buffering the entire file into memory before returning it, this
559
+ * method streams the artifact's bytes as they arrive, keeping memory usage low regardless
560
+ * of the artifact's size.
561
+ *
562
+ * The download is performed with automatic retries for transient failures.
563
+ * Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
564
+ *
565
+ * @param runId - The unique identifier of the application run
566
+ * @param artifactId - The unique identifier of the artifact to download
567
+ * @returns A promise that resolves to a Node.js `Readable` stream yielding the artifact's binary content
568
+ * @throws {AuthenticationError} If no valid authentication token is available
569
+ * @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
570
+ * @throws {UnexpectedError} If a non-HTTP error occurs
571
+ *
572
+ * @example
573
+ * ```typescript
574
+ * import { pipeline } from 'node:stream/promises';
575
+ * import { createWriteStream } from 'node:fs';
576
+ *
577
+ * const stream = await sdk.downloadArtifactStream('run-123', 'artifact-456');
578
+ * await pipeline(stream, createWriteStream('output.bin'));
579
+ * ```
580
+ *
581
+ * @remarks
582
+ * Retries only cover failures at the initial-request stage (a non-2xx status surfaced from
583
+ * the response headers before the body begins streaming). Once the response body has started
584
+ * streaming, a mid-stream connection drop CANNOT be retried by this method — the consumer must
585
+ * listen for the stream's `error` event and re-download if needed.
586
+ */
587
+ downloadArtifactStream(runId: string, artifactId: string): Promise<Readable>;
588
+ /**
589
+ * Create a grant to share access to a resource with a subject (user or organization)
590
+ *
591
+ * @param request - The grant creation request
592
+ * @returns A promise that resolves to the created grant
593
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid request data, or API errors
594
+ *
595
+ * @example
596
+ * ```typescript
597
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
598
+ *
599
+ * const grant = await sdk.createGrant({
600
+ * resource_type: 'run',
601
+ * resource_id: 'run-123',
602
+ * subject_type: 'user',
603
+ * subject_email: 'colleague@example.com',
604
+ * relation: 'viewer',
605
+ * });
606
+ * ```
607
+ */
608
+ createGrant(request: GrantCreateRequest): Promise<GrantReadResponse>;
609
+ /**
610
+ * List grants, optionally filtered by resource, subject, relation, or revocation status
611
+ *
612
+ * @param options - Optional filters and pagination/sort options
613
+ * @returns A promise that resolves to an array of grants
614
+ * @throws {Error} If the request fails due to network issues, authentication problems, or API errors
615
+ *
616
+ * @example
617
+ * ```typescript
618
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
619
+ *
620
+ * const grants = await sdk.listGrants({ resourceType: 'run', resourceId: 'run-123' });
621
+ * ```
622
+ */
623
+ listGrants({ resourceType, resourceId, subjectType, subjectId, relation, revoked, page, pageSize, sort }?: {
624
+ resourceType?: ResourceType;
625
+ resourceId?: string;
626
+ subjectType?: SubjectType;
627
+ subjectId?: string;
628
+ relation?: GrantRelation[];
629
+ revoked?: boolean;
630
+ page?: number;
631
+ pageSize?: number;
632
+ sort?: string[];
633
+ }): Promise<GrantReadResponse[]>;
634
+ /**
635
+ * Get a grant by its ID
636
+ *
637
+ * @param grantId - The unique identifier of the grant
638
+ * @returns A promise that resolves to the grant details
639
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid grant ID, or API errors
640
+ *
641
+ * @example
642
+ * ```typescript
643
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
644
+ *
645
+ * const grant = await sdk.getGrant('grant-123');
646
+ * ```
647
+ */
648
+ getGrant(grantId: string): Promise<GrantReadResponse>;
649
+ /**
650
+ * Revoke a grant by its ID
651
+ *
652
+ * @param grantId - The unique identifier of the grant to revoke
653
+ * @returns A promise that resolves to the revoked grant details
654
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid grant ID, or API errors
655
+ *
656
+ * @example
657
+ * ```typescript
658
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
659
+ *
660
+ * await sdk.revokeGrant('grant-123');
661
+ * ```
662
+ */
663
+ revokeGrant(grantId: string): Promise<GrantReadResponse>;
664
+ /**
665
+ * Create a share token. The returned share_token value is shown only once and is never stored.
666
+ * Use `createGrant` with `subject_type: 'share_token'` to grant access to a resource.
667
+ *
668
+ * @param request - The share token creation request
669
+ * @returns A promise that resolves to the created share token, including the one-time token value
670
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid request data, or API errors
671
+ *
672
+ * @example
673
+ * ```typescript
674
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
675
+ *
676
+ * const shareToken = await sdk.createShareToken({ expires_at: '2026-01-01T00:00:00Z' });
677
+ * console.log(shareToken.share_token); // Only shown once
678
+ * ```
679
+ */
680
+ createShareToken(request: ShareTokenCreateRequest): Promise<ShareTokenCreateResponse>;
681
+ /**
682
+ * List share tokens, optionally filtered by run, creator, or revocation status
683
+ *
684
+ * @param options - Optional filters and pagination/sort options
685
+ * @returns A promise that resolves to an array of share tokens
686
+ * @throws {Error} If the request fails due to network issues, authentication problems, or API errors
687
+ *
688
+ * @example
689
+ * ```typescript
690
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
691
+ *
692
+ * const shareTokens = await sdk.listShareTokens({ runId: 'run-123' });
693
+ * ```
694
+ */
695
+ listShareTokens({ runId, createdBy, revoked, page, pageSize, sort }?: {
696
+ runId?: string;
697
+ createdBy?: string;
698
+ revoked?: boolean;
699
+ page?: number;
700
+ pageSize?: number;
701
+ sort?: string[];
702
+ }): Promise<ShareTokenReadResponse[]>;
703
+ /**
704
+ * Get a share token by its ID
705
+ *
706
+ * @param shareTokenId - The unique identifier of the share token
707
+ * @returns A promise that resolves to the share token details (excludes the token value)
708
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid share token ID, or API errors
709
+ *
710
+ * @example
711
+ * ```typescript
712
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
713
+ *
714
+ * const shareToken = await sdk.getShareToken('share-token-123');
715
+ * ```
716
+ */
717
+ getShareToken(shareTokenId: string): Promise<ShareTokenReadResponse>;
718
+ /**
719
+ * Revoke a share token by its ID. Invalidates the credential regardless of any active grants.
720
+ *
721
+ * @param shareTokenId - The unique identifier of the share token to revoke
722
+ * @returns A promise that resolves to the revoked share token details
723
+ * @throws {Error} If the request fails due to network issues, authentication problems, invalid share token ID, or API errors
724
+ *
725
+ * @example
726
+ * ```typescript
727
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
728
+ *
729
+ * await sdk.revokeShareToken('share-token-123');
730
+ * ```
731
+ */
732
+ revokeShareToken(shareTokenId: string): Promise<ShareTokenReadResponse>;
492
733
  }
493
-
734
+ //#endregion
735
+ //#region src/errors.d.ts
494
736
  type ErrorCode = 'AUTHENTICATION_ERROR' | 'API_ERROR' | 'CONFIGURATION_ERROR' | 'UNEXPECTED_ERROR';
495
737
  interface BaseErrorOptions {
496
- context?: Record<string, unknown>;
497
- originalError?: unknown;
738
+ context?: Record<string, unknown>;
739
+ originalError?: unknown;
498
740
  }
499
741
  /**
500
742
  * Base error class for all SDK-related errors
@@ -503,26 +745,26 @@ interface BaseErrorOptions {
503
745
  * providing consistent error handling and additional context information.
504
746
  */
505
747
  declare class BaseError extends Error {
506
- /**
507
- * Error code for programmatic error handling
508
- */
509
- readonly code: ErrorCode;
510
- /**
511
- * Additional context or metadata related to the error
512
- */
513
- readonly context?: Record<string, unknown>;
514
- /**
515
- * Original error that caused this error, if applicable
516
- */
517
- readonly originalError?: unknown;
518
- /**
519
- * Creates a new BaseError instance
520
- *
521
- * @param message - Human-readable error message
522
- * @param code - Error code for programmatic handling
523
- * @param context - Additional error context or metadata
524
- */
525
- constructor(message: string, code: ErrorCode, { context, originalError }?: BaseErrorOptions);
748
+ /**
749
+ * Error code for programmatic error handling
750
+ */
751
+ readonly code: ErrorCode;
752
+ /**
753
+ * Additional context or metadata related to the error
754
+ */
755
+ readonly context?: Record<string, unknown>;
756
+ /**
757
+ * Original error that caused this error, if applicable
758
+ */
759
+ readonly originalError?: unknown;
760
+ /**
761
+ * Creates a new BaseError instance
762
+ *
763
+ * @param message - Human-readable error message
764
+ * @param code - Error code for programmatic handling
765
+ * @param context - Additional error context or metadata
766
+ */
767
+ constructor(message: string, code: ErrorCode, { context, originalError }?: BaseErrorOptions);
526
768
  }
527
769
  /**
528
770
  * Authentication-related error
@@ -531,15 +773,15 @@ declare class BaseError extends Error {
531
773
  * credentials are available for API requests.
532
774
  */
533
775
  declare class AuthenticationError extends BaseError {
534
- /**
535
- * Creates a new AuthenticationError instance
536
- *
537
- * @param message - Human-readable error message describing the authentication issue
538
- * @param options - Additional options about the authentication failure
539
- * @param options.context - Additional context about the authentication failure
540
- * @param options.originalError - Original error that caused this authentication error
541
- */
542
- constructor(message: string, options?: BaseErrorOptions);
776
+ /**
777
+ * Creates a new AuthenticationError instance
778
+ *
779
+ * @param message - Human-readable error message describing the authentication issue
780
+ * @param options - Additional options about the authentication failure
781
+ * @param options.context - Additional context about the authentication failure
782
+ * @param options.originalError - Original error that caused this authentication error
783
+ */
784
+ constructor(message: string, options?: BaseErrorOptions);
543
785
  }
544
786
  /**
545
787
  * API-related error
@@ -548,20 +790,20 @@ declare class AuthenticationError extends BaseError {
548
790
  * or invalid responses from the Aignostics Platform API.
549
791
  */
550
792
  declare class APIError extends BaseError {
551
- /**
552
- * HTTP status code from the failed API request
553
- */
554
- readonly statusCode?: number;
555
- /**
556
- * Creates a new APIError instance
557
- *
558
- * @param message - Human-readable error message describing the API issue
559
- * @param statusCode - HTTP status code from the failed request
560
- * @param context - Additional context about the API failure
561
- */
562
- constructor(message: string, options?: BaseErrorOptions & {
563
- statusCode?: number;
564
- });
793
+ /**
794
+ * HTTP status code from the failed API request
795
+ */
796
+ readonly statusCode?: number;
797
+ /**
798
+ * Creates a new APIError instance
799
+ *
800
+ * @param message - Human-readable error message describing the API issue
801
+ * @param statusCode - HTTP status code from the failed request
802
+ * @param context - Additional context about the API failure
803
+ */
804
+ constructor(message: string, options?: BaseErrorOptions & {
805
+ statusCode?: number;
806
+ });
565
807
  }
566
808
  /**
567
809
  * Configuration-related error
@@ -569,27 +811,20 @@ declare class APIError extends BaseError {
569
811
  * Thrown when SDK configuration is invalid or missing required parameters.
570
812
  */
571
813
  declare class ConfigurationError extends BaseError {
572
- /**
573
- * Creates a new ConfigurationError instance
574
- *
575
- * @param message - Human-readable error message describing the configuration issue
576
- * @param context - Additional context about the configuration problem
577
- */
578
- constructor(message: string, options?: BaseErrorOptions);
814
+ /**
815
+ * Creates a new ConfigurationError instance
816
+ *
817
+ * @param message - Human-readable error message describing the configuration issue
818
+ * @param context - Additional context about the configuration problem
819
+ */
820
+ constructor(message: string, options?: BaseErrorOptions);
579
821
  }
580
-
581
- /**
582
- * Transform a raw {@link RunReadResponse} from the API into an enriched
583
- * {@link ApplicationRun} by computing derived properties (progress, status, can_download).
584
- *
585
- * This is the single entry-point used by `PlatformSDKHttp` methods to map API
586
- * responses before returning them to consumers.
587
- *
588
- * @param run - Raw run response from the API
589
- * @returns Enriched run entity with computed properties spread onto the original response
590
- */
591
- declare const processApplicationRun: (run: RunReadResponse) => ApplicationRun;
592
-
822
+ //#endregion
823
+ //#region src/entities/application-run/types.d.ts
824
+ /** Derived run status that simplifies the raw `state` + `termination_reason` combination. */
825
+ type RunStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'COMPLETED_WITH_ERRORS' | 'CANCELED' | 'FAILED' | 'UNKNOWN';
826
+ //#endregion
827
+ //#region src/entities/application-run/utils.d.ts
593
828
  /**
594
829
  * Compute the overall progress of a run as a percentage (0–100).
595
830
  * Progress is based on the ratio of terminal items (succeeded + errored + skipped)
@@ -624,19 +859,12 @@ declare function getRunStatus(run: RunReadResponse): RunStatus;
624
859
  * @returns `true` if items are available for download (run is COMPLETED or COMPLETED_WITH_ERRORS)
625
860
  */
626
861
  declare const canDownloadRunItems: (run: RunReadResponse) => boolean;
627
-
628
- /**
629
- * Transform a raw {@link ItemResultReadResponse} from the API into an enriched
630
- * {@link ApplicationRunItem} by computing derived properties (status, can_download).
631
- *
632
- * This is the single entry-point used by `PlatformSDKHttp.listRunResults()` to
633
- * map API responses before returning them to consumers.
634
- *
635
- * @param item - Raw item response from the API
636
- * @returns Enriched item entity with computed properties spread onto the original response
637
- */
638
- declare const processRunItem: (item: ItemResultReadResponse) => ApplicationRunItem;
639
-
862
+ //#endregion
863
+ //#region src/entities/run-item/types.d.ts
864
+ /** Derived item status that simplifies the raw `state` + `termination_reason` combination. */
865
+ type ItemStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'SKIPPED' | 'UNKNOWN';
866
+ //#endregion
867
+ //#region src/entities/run-item/utils.d.ts
640
868
  /**
641
869
  * Determine whether a single run item's output artifact is available for download.
642
870
  * Disabled for PENDING, PROCESSING, FAILED, and SKIPPED items; available otherwise
@@ -662,5 +890,6 @@ declare const ERROR_TERMINATION_REASONS: Set<string>;
662
890
  * @param item - Raw item response from the API
663
891
  */
664
892
  declare function getItemStatus(item: ItemResultReadResponse): ItemStatus;
665
-
666
- export { APIError, ApplicationReadResponse, ApplicationReadShortResponse, type ApplicationRun, type ApplicationRunItem, AuthenticationError, BaseError, ConfigurationError, ERROR_TERMINATION_REASONS, ItemResultReadResponse, ItemState, type ItemStatus, ItemTerminationReason, type PlatformSDK, type PlatformSDKConfig, PlatformSDKHttp, RunCreationRequest, RunCreationResponse, RunReadResponse, type RunStatus, type TokenProvider, VersionReadResponse, canDownloadItem, canDownloadRunItems, PlatformSDKHttp as default, getItemStatus, getRunProgress, getRunStatus, processApplicationRun, processRunItem };
893
+ //#endregion
894
+ export { APIError, ApplicationReadResponse, ApplicationReadShortResponse, ApplicationVersion, ArtifactOutput, ArtifactState, ArtifactTerminationReason, AuthenticationError, BaseError, Configuration, ConfigurationError, ConfigurationParameters, CustomMetadataUpdateRequest, CustomMetadataUpdateResponse, ERROR_TERMINATION_REASONS, GrantCreateRequest, GrantReadResponse, GrantRelation, HTTPValidationError, InputArtifact, InputArtifactCreationRequest, InputArtifactResultReadResponse, ItemCreationRequest, ItemOutput, ItemResultReadResponse, ItemState, type ItemStatus, ItemTerminationReason, MeReadResponse, OrganizationReadResponse, OutputArtifact, OutputArtifactResultReadResponse, OutputArtifactScope, OutputArtifactVisibility, type PlatformSDK, type PlatformSDKConfig, PlatformSDKHttp, PlatformSDKHttp as default, PublicApi, PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, PublicApiAxiosParamCreator, PublicApiCancelRunV1RunsRunIdCancelPostRequest, PublicApiCreateGrantV1AccessGrantsPostRequest, PublicApiCreateRunV1RunsPostRequest, PublicApiCreateShareTokenV1AccessShareTokensPostRequest, PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, PublicApiFactory, PublicApiFp, PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, PublicApiGetGrantV1AccessGrantsGrantIdGetRequest, PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, PublicApiGetRunV1RunsRunIdGetRequest, PublicApiGetShareTokenV1AccessShareTokensShareTokenIdGetRequest, PublicApiGetVersionDocumentContentRequest, PublicApiGetVersionDocumentFileRequest, PublicApiGetVersionDocumentRequest, PublicApiInterface, PublicApiListApplicationsV1ApplicationsGetRequest, PublicApiListGrantsV1AccessGrantsGetRequest, PublicApiListRunItemsV1RunsRunIdItemsGetRequest, PublicApiListRunsV1RunsGetRequest, PublicApiListShareTokensV1AccessShareTokensGetRequest, PublicApiListVersionDocumentsRequest, PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, PublicApiRevokeGrantV1AccessGrantsGrantIdDeleteRequest, PublicApiRevokeShareTokenV1AccessShareTokensShareTokenIdDeleteRequest, ResourceType, RunCreationRequest, RunCreationResponse, RunItemStatistics, RunOutput, RunReadResponse, RunState, type RunStatus, RunTerminationReason, SchedulingRequest, SchedulingResponse, ShareTokenCreateRequest, ShareTokenCreateResponse, ShareTokenReadResponse, SubjectType, type TokenProvider, UserReadResponse, ValidationError, ValidationErrorLocInner, VersionDocumentResponse, VersionDocumentVisibility, VersionReadResponse, canDownloadItem, canDownloadRunItems, getItemStatus, getRunProgress, getRunStatus };
895
+ //# sourceMappingURL=index.d.ts.map