@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/index.js CHANGED
@@ -132,6 +132,10 @@ var RunTerminationReason = {
132
132
  CanceledBySystem: "CANCELED_BY_SYSTEM",
133
133
  CanceledByUser: "CANCELED_BY_USER"
134
134
  };
135
+ var VersionDocumentVisibility = {
136
+ Public: "public",
137
+ Internal: "internal"
138
+ };
135
139
  var PublicApiAxiosParamCreator = function(configuration) {
136
140
  return {
137
141
  /**
@@ -246,6 +250,35 @@ var PublicApiAxiosParamCreator = function(configuration) {
246
250
  options: localVarRequestOptions
247
251
  };
248
252
  },
253
+ /**
254
+ * Download the artifact file with the specified artifact_id, belonging to the specified run. The artifact_is is returned by the `GET /v1/runs/{run_id}/items` endpoint as part of the item results, and can also be retrieved via `GET /v1/runs/{run_id}/items/{external_id}`. The endpoint may return a redirect response with a presigned URL to download the artifact file from the storage bucket. The presigned URL is valid for a limited time, so it should be used immediately after receiving the response.
255
+ * @summary Get Artifact Url
256
+ * @param {string} runId Run id, returned by `POST /runs/` endpoint
257
+ * @param {string} artifactId The artifact id to download
258
+ * @param {*} [options] Override http request option.
259
+ * @throws {RequiredError}
260
+ */
261
+ getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet: async (runId, artifactId, options = {}) => {
262
+ assertParamExists("getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet", "runId", runId);
263
+ assertParamExists("getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet", "artifactId", artifactId);
264
+ const localVarPath = `/v1/runs/{run_id}/artifacts/{artifact_id}/file`.replace(`{${"run_id"}}`, encodeURIComponent(String(runId))).replace(`{${"artifact_id"}}`, encodeURIComponent(String(artifactId)));
265
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
266
+ let baseOptions;
267
+ if (configuration) {
268
+ baseOptions = configuration.baseOptions;
269
+ }
270
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
271
+ const localVarHeaderParameter = {};
272
+ const localVarQueryParameter = {};
273
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
274
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
275
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
276
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
277
+ return {
278
+ url: toPathString(localVarUrlObj),
279
+ options: localVarRequestOptions
280
+ };
281
+ },
249
282
  /**
250
283
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
251
284
  * @summary Get Item By Run
@@ -327,6 +360,99 @@ var PublicApiAxiosParamCreator = function(configuration) {
327
360
  options: localVarRequestOptions
328
361
  };
329
362
  },
363
+ /**
364
+ * Return metadata for a single public document attached to an application version.
365
+ * @summary Get version document metadata
366
+ * @param {string} applicationId
367
+ * @param {string} version
368
+ * @param {string} name
369
+ * @param {*} [options] Override http request option.
370
+ * @throws {RequiredError}
371
+ */
372
+ getVersionDocument: async (applicationId, version, name, options = {}) => {
373
+ assertParamExists("getVersionDocument", "applicationId", applicationId);
374
+ assertParamExists("getVersionDocument", "version", version);
375
+ assertParamExists("getVersionDocument", "name", name);
376
+ const localVarPath = `/v1/applications/{application_id}/versions/{version}/documents/{name}`.replace(`{${"application_id"}}`, encodeURIComponent(String(applicationId))).replace(`{${"version"}}`, encodeURIComponent(String(version))).replace(`{${"name"}}`, encodeURIComponent(String(name)));
377
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
378
+ let baseOptions;
379
+ if (configuration) {
380
+ baseOptions = configuration.baseOptions;
381
+ }
382
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
383
+ const localVarHeaderParameter = {};
384
+ const localVarQueryParameter = {};
385
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
386
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
387
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
388
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
389
+ return {
390
+ url: toPathString(localVarUrlObj),
391
+ options: localVarRequestOptions
392
+ };
393
+ },
394
+ /**
395
+ * 307 redirect to a short-lived GCS signed URL for streaming document content. Unlike ``/file``, no ``Content-Disposition`` override is set — GCS serves the object body with its stored ``Content-Type``. Intended for programmatic clients that follow redirects and consume the content directly. Response carries ``Cache-Control: no-store``.
396
+ * @summary Stream version document content (programmatic)
397
+ * @param {string} applicationId
398
+ * @param {string} version
399
+ * @param {string} name
400
+ * @param {*} [options] Override http request option.
401
+ * @throws {RequiredError}
402
+ */
403
+ getVersionDocumentContent: async (applicationId, version, name, options = {}) => {
404
+ assertParamExists("getVersionDocumentContent", "applicationId", applicationId);
405
+ assertParamExists("getVersionDocumentContent", "version", version);
406
+ assertParamExists("getVersionDocumentContent", "name", name);
407
+ const localVarPath = `/v1/applications/{application_id}/versions/{version}/documents/{name}/content`.replace(`{${"application_id"}}`, encodeURIComponent(String(applicationId))).replace(`{${"version"}}`, encodeURIComponent(String(version))).replace(`{${"name"}}`, encodeURIComponent(String(name)));
408
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
409
+ let baseOptions;
410
+ if (configuration) {
411
+ baseOptions = configuration.baseOptions;
412
+ }
413
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
414
+ const localVarHeaderParameter = {};
415
+ const localVarQueryParameter = {};
416
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
417
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
418
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
419
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
420
+ return {
421
+ url: toPathString(localVarUrlObj),
422
+ options: localVarRequestOptions
423
+ };
424
+ },
425
+ /**
426
+ * 307 redirect to a short-lived GCS signed URL for downloading a document. The signed URL includes ``response-content-disposition=attachment; filename=\"<name>\"`` so browsers prompt a save-as dialog rather than rendering inline. Response carries ``Cache-Control: no-store``.
427
+ * @summary Download version document (browser)
428
+ * @param {string} applicationId
429
+ * @param {string} version
430
+ * @param {string} name
431
+ * @param {*} [options] Override http request option.
432
+ * @throws {RequiredError}
433
+ */
434
+ getVersionDocumentFile: async (applicationId, version, name, options = {}) => {
435
+ assertParamExists("getVersionDocumentFile", "applicationId", applicationId);
436
+ assertParamExists("getVersionDocumentFile", "version", version);
437
+ assertParamExists("getVersionDocumentFile", "name", name);
438
+ const localVarPath = `/v1/applications/{application_id}/versions/{version}/documents/{name}/file`.replace(`{${"application_id"}}`, encodeURIComponent(String(applicationId))).replace(`{${"version"}}`, encodeURIComponent(String(version))).replace(`{${"name"}}`, encodeURIComponent(String(name)));
439
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
440
+ let baseOptions;
441
+ if (configuration) {
442
+ baseOptions = configuration.baseOptions;
443
+ }
444
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
445
+ const localVarHeaderParameter = {};
446
+ const localVarQueryParameter = {};
447
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
448
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
449
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
450
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
451
+ return {
452
+ url: toPathString(localVarUrlObj),
453
+ options: localVarRequestOptions
454
+ };
455
+ },
330
456
  /**
331
457
  * Returns the list of the applications, available to the caller. The application is available if any of the versions of the application is assigned to the caller\'s organization. The response is paginated and sorted according to the provided parameters.
332
458
  * @summary List available applications
@@ -432,11 +558,12 @@ var PublicApiAxiosParamCreator = function(configuration) {
432
558
  * @param {string | null} [customMetadata] Use PostgreSQL JSONPath expressions to filter runs by their custom_metadata. #### URL Encoding Required **Important**: JSONPath expressions contain special characters that must be URL-encoded when used in query parameters. Most HTTP clients handle this automatically, but when constructing URLs manually, please ensure proper encoding. #### Examples (Clear Format): - **Field existence**: &#x60;$.study&#x60; - Runs that have a study field defined - **Exact value match**: &#x60;$.study ? (@ &#x3D;&#x3D; \&quot;high\&quot;)&#x60; - Runs with specific study value - **Numeric comparison**: &#x60;$.confidence_score ? (@ &gt; 0.75)&#x60; - Runs with confidence score greater than 0.75 - **Array operations**: &#x60;$.tags[*] ? (@ &#x3D;&#x3D; \&quot;draft\&quot;)&#x60; - Runs with tags array containing \&quot;draft\&quot; - **Complex conditions**: &#x60;$.resources ? (@.gpu_count &gt; 2 &amp;&amp; @.memory_gb &gt;&#x3D; 16)&#x60; - Runs with high resource requirements #### Examples (URL-Encoded Format): - **Field existence**: &#x60;%24.study&#x60; - **Exact value match**: &#x60;%24.study%20%3F%20(%40%20%3D%3D%20%22high%22)&#x60; - **Numeric comparison**: &#x60;%24.confidence_score%20%3F%20(%40%20%3E%200.75)&#x60; - **Array operations**: &#x60;%24.tags%5B*%5D%20%3F%20(%40%20%3D%3D%20%22draft%22)&#x60; - **Complex conditions**: &#x60;%24.resources%20%3F%20(%40.gpu_count%20%3E%202%20%26%26%20%40.memory_gb%20%3E%3D%2016)&#x60; #### Notes - JSONPath expressions are evaluated using PostgreSQL\&#39;s &#x60;@?&#x60; operator - The &#x60;$.&#x60; prefix is automatically added to root-level field references if missing - String values in conditions must be enclosed in double quotes - Use &#x60;&amp;&amp;&#x60; for AND operations and &#x60;||&#x60; for OR operations - Regular expressions use &#x60;like_regex&#x60; with standard regex syntax - **Please remember to URL-encode the entire JSONPath expression when making HTTP requests**
433
559
  * @param {number} [page]
434
560
  * @param {number} [pageSize]
561
+ * @param {string | null} [forOrganization] Filter runs by organization ID. Available for superadmins (any org) and admins (own org only). When provided, returns all runs for the specified organization instead of only the caller\&#39;s own runs.
435
562
  * @param {Array<string> | null} [sort] Sort the results by one or more fields. Use &#x60;+&#x60; for ascending and &#x60;-&#x60; for descending order. **Available fields:** - &#x60;run_id&#x60; - &#x60;application_id&#x60; - &#x60;version_number&#x60; - &#x60;custom_metadata&#x60; - &#x60;submitted_at&#x60; - &#x60;submitted_by&#x60; - &#x60;terminated_at&#x60; - &#x60;termination_reason&#x60; **Examples:** - &#x60;?sort&#x3D;submitted_at&#x60; - Sort by creation time (ascending) - &#x60;?sort&#x3D;-submitted_at&#x60; - Sort by creation time (descending) - &#x60;?sort&#x3D;state&amp;sort&#x3D;-submitted_at&#x60; - Sort by state, then by time (descending)
436
563
  * @param {*} [options] Override http request option.
437
564
  * @throws {RequiredError}
438
565
  */
439
- listRunsV1RunsGet: async (applicationId, applicationVersion, externalId, customMetadata, page, pageSize, sort, options = {}) => {
566
+ listRunsV1RunsGet: async (applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options = {}) => {
440
567
  const localVarPath = `/v1/runs`;
441
568
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
442
569
  let baseOptions;
@@ -465,6 +592,9 @@ var PublicApiAxiosParamCreator = function(configuration) {
465
592
  if (pageSize !== void 0) {
466
593
  localVarQueryParameter["page_size"] = pageSize;
467
594
  }
595
+ if (forOrganization !== void 0) {
596
+ localVarQueryParameter["for_organization"] = forOrganization;
597
+ }
468
598
  if (sort) {
469
599
  localVarQueryParameter["sort"] = sort;
470
600
  }
@@ -476,6 +606,35 @@ var PublicApiAxiosParamCreator = function(configuration) {
476
606
  options: localVarRequestOptions
477
607
  };
478
608
  },
609
+ /**
610
+ * List public documents attached to an application version. Returns only documents with ``visibility=public`` and ``status=uploaded``.
611
+ * @summary List version documents
612
+ * @param {string} applicationId
613
+ * @param {string} version
614
+ * @param {*} [options] Override http request option.
615
+ * @throws {RequiredError}
616
+ */
617
+ listVersionDocuments: async (applicationId, version, options = {}) => {
618
+ assertParamExists("listVersionDocuments", "applicationId", applicationId);
619
+ assertParamExists("listVersionDocuments", "version", version);
620
+ const localVarPath = `/v1/applications/{application_id}/versions/{version}/documents`.replace(`{${"application_id"}}`, encodeURIComponent(String(applicationId))).replace(`{${"version"}}`, encodeURIComponent(String(version)));
621
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
622
+ let baseOptions;
623
+ if (configuration) {
624
+ baseOptions = configuration.baseOptions;
625
+ }
626
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
627
+ const localVarHeaderParameter = {};
628
+ const localVarQueryParameter = {};
629
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
630
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
631
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
632
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
633
+ return {
634
+ url: toPathString(localVarUrlObj),
635
+ options: localVarRequestOptions
636
+ };
637
+ },
479
638
  /**
480
639
  * Update the custom metadata of the item with the specified `external_id`, belonging to the specified run. Optionally, a checksum may be provided along the custom metadata JSON. It can be used to verify if the custom metadata was updated since the last time it was accessed. If the checksum is provided, it must match the existing custom metadata in the system, ensuring that the current custom metadata value to be overwritten is acknowledged by the user. If no checksum is provided, submitted metadata directly overwrites the existing metadata, without any checks. The latest custom metadata and checksum can be retrieved for individual items via `GET /v1/runs/{run_id}/items/{external_id}`, and for all items of a run via `GET /v1/runs/{run_id}/items`.
481
640
  * @summary Put Item Custom Metadata By Run
@@ -625,6 +784,20 @@ var PublicApiFp = function(configuration) {
625
784
  const localVarOperationServerBasePath = operationServerMap["PublicApi.deleteRunItemsV1RunsRunIdArtifactsDelete"]?.[localVarOperationServerIndex]?.url;
626
785
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
627
786
  },
787
+ /**
788
+ * Download the artifact file with the specified artifact_id, belonging to the specified run. The artifact_is is returned by the `GET /v1/runs/{run_id}/items` endpoint as part of the item results, and can also be retrieved via `GET /v1/runs/{run_id}/items/{external_id}`. The endpoint may return a redirect response with a presigned URL to download the artifact file from the storage bucket. The presigned URL is valid for a limited time, so it should be used immediately after receiving the response.
789
+ * @summary Get Artifact Url
790
+ * @param {string} runId Run id, returned by &#x60;POST /runs/&#x60; endpoint
791
+ * @param {string} artifactId The artifact id to download
792
+ * @param {*} [options] Override http request option.
793
+ * @throws {RequiredError}
794
+ */
795
+ async getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(runId, artifactId, options) {
796
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(runId, artifactId, options);
797
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
798
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet"]?.[localVarOperationServerIndex]?.url;
799
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
800
+ },
628
801
  /**
629
802
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
630
803
  * @summary Get Item By Run
@@ -664,6 +837,51 @@ var PublicApiFp = function(configuration) {
664
837
  const localVarOperationServerBasePath = operationServerMap["PublicApi.getRunV1RunsRunIdGet"]?.[localVarOperationServerIndex]?.url;
665
838
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
666
839
  },
840
+ /**
841
+ * Return metadata for a single public document attached to an application version.
842
+ * @summary Get version document metadata
843
+ * @param {string} applicationId
844
+ * @param {string} version
845
+ * @param {string} name
846
+ * @param {*} [options] Override http request option.
847
+ * @throws {RequiredError}
848
+ */
849
+ async getVersionDocument(applicationId, version, name, options) {
850
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getVersionDocument(applicationId, version, name, options);
851
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
852
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.getVersionDocument"]?.[localVarOperationServerIndex]?.url;
853
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
854
+ },
855
+ /**
856
+ * 307 redirect to a short-lived GCS signed URL for streaming document content. Unlike ``/file``, no ``Content-Disposition`` override is set — GCS serves the object body with its stored ``Content-Type``. Intended for programmatic clients that follow redirects and consume the content directly. Response carries ``Cache-Control: no-store``.
857
+ * @summary Stream version document content (programmatic)
858
+ * @param {string} applicationId
859
+ * @param {string} version
860
+ * @param {string} name
861
+ * @param {*} [options] Override http request option.
862
+ * @throws {RequiredError}
863
+ */
864
+ async getVersionDocumentContent(applicationId, version, name, options) {
865
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getVersionDocumentContent(applicationId, version, name, options);
866
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
867
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.getVersionDocumentContent"]?.[localVarOperationServerIndex]?.url;
868
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
869
+ },
870
+ /**
871
+ * 307 redirect to a short-lived GCS signed URL for downloading a document. The signed URL includes ``response-content-disposition=attachment; filename=\"<name>\"`` so browsers prompt a save-as dialog rather than rendering inline. Response carries ``Cache-Control: no-store``.
872
+ * @summary Download version document (browser)
873
+ * @param {string} applicationId
874
+ * @param {string} version
875
+ * @param {string} name
876
+ * @param {*} [options] Override http request option.
877
+ * @throws {RequiredError}
878
+ */
879
+ async getVersionDocumentFile(applicationId, version, name, options) {
880
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getVersionDocumentFile(applicationId, version, name, options);
881
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
882
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.getVersionDocumentFile"]?.[localVarOperationServerIndex]?.url;
883
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
884
+ },
667
885
  /**
668
886
  * Returns the list of the applications, available to the caller. The application is available if any of the versions of the application is assigned to the caller\'s organization. The response is paginated and sorted according to the provided parameters.
669
887
  * @summary List available applications
@@ -709,16 +927,31 @@ var PublicApiFp = function(configuration) {
709
927
  * @param {string | null} [customMetadata] Use PostgreSQL JSONPath expressions to filter runs by their custom_metadata. #### URL Encoding Required **Important**: JSONPath expressions contain special characters that must be URL-encoded when used in query parameters. Most HTTP clients handle this automatically, but when constructing URLs manually, please ensure proper encoding. #### Examples (Clear Format): - **Field existence**: &#x60;$.study&#x60; - Runs that have a study field defined - **Exact value match**: &#x60;$.study ? (@ &#x3D;&#x3D; \&quot;high\&quot;)&#x60; - Runs with specific study value - **Numeric comparison**: &#x60;$.confidence_score ? (@ &gt; 0.75)&#x60; - Runs with confidence score greater than 0.75 - **Array operations**: &#x60;$.tags[*] ? (@ &#x3D;&#x3D; \&quot;draft\&quot;)&#x60; - Runs with tags array containing \&quot;draft\&quot; - **Complex conditions**: &#x60;$.resources ? (@.gpu_count &gt; 2 &amp;&amp; @.memory_gb &gt;&#x3D; 16)&#x60; - Runs with high resource requirements #### Examples (URL-Encoded Format): - **Field existence**: &#x60;%24.study&#x60; - **Exact value match**: &#x60;%24.study%20%3F%20(%40%20%3D%3D%20%22high%22)&#x60; - **Numeric comparison**: &#x60;%24.confidence_score%20%3F%20(%40%20%3E%200.75)&#x60; - **Array operations**: &#x60;%24.tags%5B*%5D%20%3F%20(%40%20%3D%3D%20%22draft%22)&#x60; - **Complex conditions**: &#x60;%24.resources%20%3F%20(%40.gpu_count%20%3E%202%20%26%26%20%40.memory_gb%20%3E%3D%2016)&#x60; #### Notes - JSONPath expressions are evaluated using PostgreSQL\&#39;s &#x60;@?&#x60; operator - The &#x60;$.&#x60; prefix is automatically added to root-level field references if missing - String values in conditions must be enclosed in double quotes - Use &#x60;&amp;&amp;&#x60; for AND operations and &#x60;||&#x60; for OR operations - Regular expressions use &#x60;like_regex&#x60; with standard regex syntax - **Please remember to URL-encode the entire JSONPath expression when making HTTP requests**
710
928
  * @param {number} [page]
711
929
  * @param {number} [pageSize]
930
+ * @param {string | null} [forOrganization] Filter runs by organization ID. Available for superadmins (any org) and admins (own org only). When provided, returns all runs for the specified organization instead of only the caller\&#39;s own runs.
712
931
  * @param {Array<string> | null} [sort] Sort the results by one or more fields. Use &#x60;+&#x60; for ascending and &#x60;-&#x60; for descending order. **Available fields:** - &#x60;run_id&#x60; - &#x60;application_id&#x60; - &#x60;version_number&#x60; - &#x60;custom_metadata&#x60; - &#x60;submitted_at&#x60; - &#x60;submitted_by&#x60; - &#x60;terminated_at&#x60; - &#x60;termination_reason&#x60; **Examples:** - &#x60;?sort&#x3D;submitted_at&#x60; - Sort by creation time (ascending) - &#x60;?sort&#x3D;-submitted_at&#x60; - Sort by creation time (descending) - &#x60;?sort&#x3D;state&amp;sort&#x3D;-submitted_at&#x60; - Sort by state, then by time (descending)
713
932
  * @param {*} [options] Override http request option.
714
933
  * @throws {RequiredError}
715
934
  */
716
- async listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, sort, options) {
717
- const localVarAxiosArgs = await localVarAxiosParamCreator.listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, sort, options);
935
+ async listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options) {
936
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options);
718
937
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
719
938
  const localVarOperationServerBasePath = operationServerMap["PublicApi.listRunsV1RunsGet"]?.[localVarOperationServerIndex]?.url;
720
939
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
721
940
  },
941
+ /**
942
+ * List public documents attached to an application version. Returns only documents with ``visibility=public`` and ``status=uploaded``.
943
+ * @summary List version documents
944
+ * @param {string} applicationId
945
+ * @param {string} version
946
+ * @param {*} [options] Override http request option.
947
+ * @throws {RequiredError}
948
+ */
949
+ async listVersionDocuments(applicationId, version, options) {
950
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listVersionDocuments(applicationId, version, options);
951
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
952
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.listVersionDocuments"]?.[localVarOperationServerIndex]?.url;
953
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
954
+ },
722
955
  /**
723
956
  * Update the custom metadata of the item with the specified `external_id`, belonging to the specified run. Optionally, a checksum may be provided along the custom metadata JSON. It can be used to verify if the custom metadata was updated since the last time it was accessed. If the checksum is provided, it must match the existing custom metadata in the system, ensuring that the current custom metadata value to be overwritten is acknowledged by the user. If no checksum is provided, submitted metadata directly overwrites the existing metadata, without any checks. The latest custom metadata and checksum can be retrieved for individual items via `GET /v1/runs/{run_id}/items/{external_id}`, and for all items of a run via `GET /v1/runs/{run_id}/items`.
724
957
  * @summary Put Item Custom Metadata By Run
@@ -806,6 +1039,16 @@ var PublicApiFactory = function(configuration, basePath, axios) {
806
1039
  deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters, options) {
807
1040
  return localVarFp.deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters.runId, options).then((request) => request(axios, basePath));
808
1041
  },
1042
+ /**
1043
+ * Download the artifact file with the specified artifact_id, belonging to the specified run. The artifact_is is returned by the `GET /v1/runs/{run_id}/items` endpoint as part of the item results, and can also be retrieved via `GET /v1/runs/{run_id}/items/{external_id}`. The endpoint may return a redirect response with a presigned URL to download the artifact file from the storage bucket. The presigned URL is valid for a limited time, so it should be used immediately after receiving the response.
1044
+ * @summary Get Artifact Url
1045
+ * @param {PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest} requestParameters Request parameters.
1046
+ * @param {*} [options] Override http request option.
1047
+ * @throws {RequiredError}
1048
+ */
1049
+ getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters, options) {
1050
+ return localVarFp.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters.runId, requestParameters.artifactId, options).then((request) => request(axios, basePath));
1051
+ },
809
1052
  /**
810
1053
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
811
1054
  * @summary Get Item By Run
@@ -835,6 +1078,36 @@ var PublicApiFactory = function(configuration, basePath, axios) {
835
1078
  getRunV1RunsRunIdGet(requestParameters, options) {
836
1079
  return localVarFp.getRunV1RunsRunIdGet(requestParameters.runId, options).then((request) => request(axios, basePath));
837
1080
  },
1081
+ /**
1082
+ * Return metadata for a single public document attached to an application version.
1083
+ * @summary Get version document metadata
1084
+ * @param {PublicApiGetVersionDocumentRequest} requestParameters Request parameters.
1085
+ * @param {*} [options] Override http request option.
1086
+ * @throws {RequiredError}
1087
+ */
1088
+ getVersionDocument(requestParameters, options) {
1089
+ return localVarFp.getVersionDocument(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(axios, basePath));
1090
+ },
1091
+ /**
1092
+ * 307 redirect to a short-lived GCS signed URL for streaming document content. Unlike ``/file``, no ``Content-Disposition`` override is set — GCS serves the object body with its stored ``Content-Type``. Intended for programmatic clients that follow redirects and consume the content directly. Response carries ``Cache-Control: no-store``.
1093
+ * @summary Stream version document content (programmatic)
1094
+ * @param {PublicApiGetVersionDocumentContentRequest} requestParameters Request parameters.
1095
+ * @param {*} [options] Override http request option.
1096
+ * @throws {RequiredError}
1097
+ */
1098
+ getVersionDocumentContent(requestParameters, options) {
1099
+ return localVarFp.getVersionDocumentContent(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(axios, basePath));
1100
+ },
1101
+ /**
1102
+ * 307 redirect to a short-lived GCS signed URL for downloading a document. The signed URL includes ``response-content-disposition=attachment; filename=\"<name>\"`` so browsers prompt a save-as dialog rather than rendering inline. Response carries ``Cache-Control: no-store``.
1103
+ * @summary Download version document (browser)
1104
+ * @param {PublicApiGetVersionDocumentFileRequest} requestParameters Request parameters.
1105
+ * @param {*} [options] Override http request option.
1106
+ * @throws {RequiredError}
1107
+ */
1108
+ getVersionDocumentFile(requestParameters, options) {
1109
+ return localVarFp.getVersionDocumentFile(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(axios, basePath));
1110
+ },
838
1111
  /**
839
1112
  * Returns the list of the applications, available to the caller. The application is available if any of the versions of the application is assigned to the caller\'s organization. The response is paginated and sorted according to the provided parameters.
840
1113
  * @summary List available applications
@@ -863,7 +1136,17 @@ var PublicApiFactory = function(configuration, basePath, axios) {
863
1136
  * @throws {RequiredError}
864
1137
  */
865
1138
  listRunsV1RunsGet(requestParameters = {}, options) {
866
- return localVarFp.listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.sort, options).then((request) => request(axios, basePath));
1139
+ return localVarFp.listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.forOrganization, requestParameters.sort, options).then((request) => request(axios, basePath));
1140
+ },
1141
+ /**
1142
+ * List public documents attached to an application version. Returns only documents with ``visibility=public`` and ``status=uploaded``.
1143
+ * @summary List version documents
1144
+ * @param {PublicApiListVersionDocumentsRequest} requestParameters Request parameters.
1145
+ * @param {*} [options] Override http request option.
1146
+ * @throws {RequiredError}
1147
+ */
1148
+ listVersionDocuments(requestParameters, options) {
1149
+ return localVarFp.listVersionDocuments(requestParameters.applicationId, requestParameters.version, options).then((request) => request(axios, basePath));
867
1150
  },
868
1151
  /**
869
1152
  * Update the custom metadata of the item with the specified `external_id`, belonging to the specified run. Optionally, a checksum may be provided along the custom metadata JSON. It can be used to verify if the custom metadata was updated since the last time it was accessed. If the checksum is provided, it must match the existing custom metadata in the system, ensuring that the current custom metadata value to be overwritten is acknowledged by the user. If no checksum is provided, submitted metadata directly overwrites the existing metadata, without any checks. The latest custom metadata and checksum can be retrieved for individual items via `GET /v1/runs/{run_id}/items/{external_id}`, and for all items of a run via `GET /v1/runs/{run_id}/items`.
@@ -942,6 +1225,17 @@ var PublicApi = class extends BaseAPI {
942
1225
  deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters, options) {
943
1226
  return PublicApiFp(this.configuration).deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters.runId, options).then((request) => request(this.axios, this.basePath));
944
1227
  }
1228
+ /**
1229
+ * Download the artifact file with the specified artifact_id, belonging to the specified run. The artifact_is is returned by the `GET /v1/runs/{run_id}/items` endpoint as part of the item results, and can also be retrieved via `GET /v1/runs/{run_id}/items/{external_id}`. The endpoint may return a redirect response with a presigned URL to download the artifact file from the storage bucket. The presigned URL is valid for a limited time, so it should be used immediately after receiving the response.
1230
+ * @summary Get Artifact Url
1231
+ * @param {PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest} requestParameters Request parameters.
1232
+ * @param {*} [options] Override http request option.
1233
+ * @throws {RequiredError}
1234
+ * @memberof PublicApi
1235
+ */
1236
+ getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters, options) {
1237
+ return PublicApiFp(this.configuration).getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters.runId, requestParameters.artifactId, options).then((request) => request(this.axios, this.basePath));
1238
+ }
945
1239
  /**
946
1240
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
947
1241
  * @summary Get Item By Run
@@ -974,6 +1268,39 @@ var PublicApi = class extends BaseAPI {
974
1268
  getRunV1RunsRunIdGet(requestParameters, options) {
975
1269
  return PublicApiFp(this.configuration).getRunV1RunsRunIdGet(requestParameters.runId, options).then((request) => request(this.axios, this.basePath));
976
1270
  }
1271
+ /**
1272
+ * Return metadata for a single public document attached to an application version.
1273
+ * @summary Get version document metadata
1274
+ * @param {PublicApiGetVersionDocumentRequest} requestParameters Request parameters.
1275
+ * @param {*} [options] Override http request option.
1276
+ * @throws {RequiredError}
1277
+ * @memberof PublicApi
1278
+ */
1279
+ getVersionDocument(requestParameters, options) {
1280
+ return PublicApiFp(this.configuration).getVersionDocument(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(this.axios, this.basePath));
1281
+ }
1282
+ /**
1283
+ * 307 redirect to a short-lived GCS signed URL for streaming document content. Unlike ``/file``, no ``Content-Disposition`` override is set — GCS serves the object body with its stored ``Content-Type``. Intended for programmatic clients that follow redirects and consume the content directly. Response carries ``Cache-Control: no-store``.
1284
+ * @summary Stream version document content (programmatic)
1285
+ * @param {PublicApiGetVersionDocumentContentRequest} requestParameters Request parameters.
1286
+ * @param {*} [options] Override http request option.
1287
+ * @throws {RequiredError}
1288
+ * @memberof PublicApi
1289
+ */
1290
+ getVersionDocumentContent(requestParameters, options) {
1291
+ return PublicApiFp(this.configuration).getVersionDocumentContent(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(this.axios, this.basePath));
1292
+ }
1293
+ /**
1294
+ * 307 redirect to a short-lived GCS signed URL for downloading a document. The signed URL includes ``response-content-disposition=attachment; filename=\"<name>\"`` so browsers prompt a save-as dialog rather than rendering inline. Response carries ``Cache-Control: no-store``.
1295
+ * @summary Download version document (browser)
1296
+ * @param {PublicApiGetVersionDocumentFileRequest} requestParameters Request parameters.
1297
+ * @param {*} [options] Override http request option.
1298
+ * @throws {RequiredError}
1299
+ * @memberof PublicApi
1300
+ */
1301
+ getVersionDocumentFile(requestParameters, options) {
1302
+ return PublicApiFp(this.configuration).getVersionDocumentFile(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(this.axios, this.basePath));
1303
+ }
977
1304
  /**
978
1305
  * Returns the list of the applications, available to the caller. The application is available if any of the versions of the application is assigned to the caller\'s organization. The response is paginated and sorted according to the provided parameters.
979
1306
  * @summary List available applications
@@ -1005,7 +1332,18 @@ var PublicApi = class extends BaseAPI {
1005
1332
  * @memberof PublicApi
1006
1333
  */
1007
1334
  listRunsV1RunsGet(requestParameters = {}, options) {
1008
- return PublicApiFp(this.configuration).listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
1335
+ return PublicApiFp(this.configuration).listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.forOrganization, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
1336
+ }
1337
+ /**
1338
+ * List public documents attached to an application version. Returns only documents with ``visibility=public`` and ``status=uploaded``.
1339
+ * @summary List version documents
1340
+ * @param {PublicApiListVersionDocumentsRequest} requestParameters Request parameters.
1341
+ * @param {*} [options] Override http request option.
1342
+ * @throws {RequiredError}
1343
+ * @memberof PublicApi
1344
+ */
1345
+ listVersionDocuments(requestParameters, options) {
1346
+ return PublicApiFp(this.configuration).listVersionDocuments(requestParameters.applicationId, requestParameters.version, options).then((request) => request(this.axios, this.basePath));
1009
1347
  }
1010
1348
  /**
1011
1349
  * Update the custom metadata of the item with the specified `external_id`, belonging to the specified run. Optionally, a checksum may be provided along the custom metadata JSON. It can be used to verify if the custom metadata was updated since the last time it was accessed. If the checksum is provided, it must match the existing custom metadata in the system, ensuring that the current custom metadata value to be overwritten is acknowledged by the user. If no checksum is provided, submitted metadata directly overwrites the existing metadata, without any checks. The latest custom metadata and checksum can be retrieved for individual items via `GET /v1/runs/{run_id}/items/{external_id}`, and for all items of a run via `GET /v1/runs/{run_id}/items`.
@@ -1215,6 +1553,337 @@ var UnexpectedError = class extends BaseError {
1215
1553
  super(message, "UNEXPECTED_ERROR", options);
1216
1554
  }
1217
1555
  };
1556
+
1557
+ // src/entities/application-run/utils.ts
1558
+ function getRunProgress(run) {
1559
+ const {
1560
+ item_count,
1561
+ item_succeeded_count,
1562
+ item_user_error_count,
1563
+ item_system_error_count,
1564
+ item_skipped_count
1565
+ } = run.statistics;
1566
+ if (item_count === 0) return 0;
1567
+ const processed = item_succeeded_count + item_user_error_count + item_system_error_count + item_skipped_count;
1568
+ return Math.round(processed / item_count * 100);
1569
+ }
1570
+ function getRunStatus(run) {
1571
+ const { state, statistics, termination_reason } = run;
1572
+ switch (state) {
1573
+ case "PENDING":
1574
+ return "PENDING";
1575
+ case "PROCESSING":
1576
+ return "PROCESSING";
1577
+ case "TERMINATED":
1578
+ if (termination_reason === "CANCELED_BY_USER") {
1579
+ return "CANCELED";
1580
+ }
1581
+ if (termination_reason === "CANCELED_BY_SYSTEM") {
1582
+ return "FAILED";
1583
+ }
1584
+ if (statistics.item_count !== statistics.item_succeeded_count) {
1585
+ return "COMPLETED_WITH_ERRORS";
1586
+ }
1587
+ return "COMPLETED";
1588
+ }
1589
+ }
1590
+ var canDownloadRunItems = (run) => {
1591
+ const status = getRunStatus(run);
1592
+ return !["FAILED", "CANCELED", "PENDING", "PROCESSING"].includes(status);
1593
+ };
1594
+
1595
+ // src/entities/application-run/process-application-run.ts
1596
+ var processApplicationRun = (run) => {
1597
+ return {
1598
+ ...run,
1599
+ progress: getRunProgress(run),
1600
+ status: getRunStatus(run),
1601
+ can_download: canDownloadRunItems(run)
1602
+ };
1603
+ };
1604
+
1605
+ // src/entities/run-item/utils.ts
1606
+ var canDownloadItem = (item) => {
1607
+ return getItemStatus(item) === "COMPLETED";
1608
+ };
1609
+ function getItemStatus(item) {
1610
+ const { state, termination_reason } = item;
1611
+ switch (state) {
1612
+ case "PENDING":
1613
+ return "PENDING";
1614
+ case "PROCESSING":
1615
+ return "PROCESSING";
1616
+ case "TERMINATED":
1617
+ if (termination_reason === "SYSTEM_ERROR" || termination_reason === "USER_ERROR") {
1618
+ return "FAILED";
1619
+ }
1620
+ if (termination_reason === "SKIPPED") {
1621
+ return "SKIPPED";
1622
+ }
1623
+ return "COMPLETED";
1624
+ }
1625
+ }
1626
+
1627
+ // src/entities/run-item/process-run-item.ts
1628
+ var processRunItem = (item) => {
1629
+ return {
1630
+ ...item,
1631
+ status: getItemStatus(item),
1632
+ can_download: canDownloadItem(item)
1633
+ };
1634
+ };
1635
+
1636
+ // ../../node_modules/is-network-error/index.js
1637
+ var objectToString = Object.prototype.toString;
1638
+ var isError = (value) => objectToString.call(value) === "[object Error]";
1639
+ var errorMessages = /* @__PURE__ */ new Set([
1640
+ "network error",
1641
+ // Chrome
1642
+ "NetworkError when attempting to fetch resource.",
1643
+ // Firefox
1644
+ "The Internet connection appears to be offline.",
1645
+ // Safari 16
1646
+ "Network request failed",
1647
+ // `cross-fetch`
1648
+ "fetch failed",
1649
+ // Undici (Node.js)
1650
+ "terminated",
1651
+ // Undici (Node.js)
1652
+ " A network error occurred.",
1653
+ // Bun (WebKit)
1654
+ "Network connection lost"
1655
+ // Cloudflare Workers (fetch)
1656
+ ]);
1657
+ function isNetworkError(error) {
1658
+ const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
1659
+ if (!isValid) {
1660
+ return false;
1661
+ }
1662
+ const { message, stack } = error;
1663
+ if (message === "Load failed") {
1664
+ return stack === void 0 || "__sentry_captured__" in error;
1665
+ }
1666
+ if (message.startsWith("error sending request for url")) {
1667
+ return true;
1668
+ }
1669
+ if (message === "Failed to fetch" || message.startsWith("Failed to fetch (") && message.endsWith(")")) {
1670
+ return true;
1671
+ }
1672
+ return errorMessages.has(message);
1673
+ }
1674
+
1675
+ // ../../node_modules/p-retry/index.js
1676
+ function validateRetries(retries) {
1677
+ if (typeof retries === "number") {
1678
+ if (retries < 0) {
1679
+ throw new TypeError("Expected `retries` to be a non-negative number.");
1680
+ }
1681
+ if (Number.isNaN(retries)) {
1682
+ throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.");
1683
+ }
1684
+ } else if (retries !== void 0) {
1685
+ throw new TypeError("Expected `retries` to be a number or Infinity.");
1686
+ }
1687
+ }
1688
+ function validateNumberOption(name, value, { min = 0, allowInfinity = false } = {}) {
1689
+ if (value === void 0) {
1690
+ return;
1691
+ }
1692
+ if (typeof value !== "number" || Number.isNaN(value)) {
1693
+ throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
1694
+ }
1695
+ if (!allowInfinity && !Number.isFinite(value)) {
1696
+ throw new TypeError(`Expected \`${name}\` to be a finite number.`);
1697
+ }
1698
+ if (value < min) {
1699
+ throw new TypeError(`Expected \`${name}\` to be \u2265 ${min}.`);
1700
+ }
1701
+ }
1702
+ function validateFunctionOption(name, value) {
1703
+ if (value === void 0) {
1704
+ return;
1705
+ }
1706
+ if (typeof value !== "function") {
1707
+ throw new TypeError(`Expected \`${name}\` to be a function.`);
1708
+ }
1709
+ }
1710
+ var AbortError = class extends Error {
1711
+ constructor(message) {
1712
+ super();
1713
+ if (message instanceof Error) {
1714
+ this.originalError = message;
1715
+ ({ message } = message);
1716
+ } else {
1717
+ this.originalError = new Error(message);
1718
+ this.originalError.stack = this.stack;
1719
+ }
1720
+ this.name = "AbortError";
1721
+ this.message = message;
1722
+ }
1723
+ };
1724
+ function calculateDelay(retriesConsumed, options) {
1725
+ const attempt = Math.max(1, retriesConsumed + 1);
1726
+ const random = options.randomize ? Math.random() + 1 : 1;
1727
+ let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));
1728
+ timeout = Math.min(timeout, options.maxTimeout);
1729
+ return timeout;
1730
+ }
1731
+ function calculateRemainingTime(start, max) {
1732
+ if (!Number.isFinite(max)) {
1733
+ return max;
1734
+ }
1735
+ return max - (performance.now() - start);
1736
+ }
1737
+ async function delayForRetry(delay, options) {
1738
+ if (delay <= 0) {
1739
+ return;
1740
+ }
1741
+ await new Promise((resolve, reject) => {
1742
+ const onAbort = () => {
1743
+ clearTimeout(timeoutToken);
1744
+ options.signal?.removeEventListener("abort", onAbort);
1745
+ reject(options.signal.reason);
1746
+ };
1747
+ const timeoutToken = setTimeout(() => {
1748
+ options.signal?.removeEventListener("abort", onAbort);
1749
+ resolve();
1750
+ }, delay);
1751
+ if (options.unref) {
1752
+ timeoutToken.unref?.();
1753
+ }
1754
+ options.signal?.addEventListener("abort", onAbort, { once: true });
1755
+ });
1756
+ }
1757
+ async function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options }) {
1758
+ const normalizedError = error instanceof Error ? error : new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
1759
+ if (normalizedError instanceof AbortError) {
1760
+ throw normalizedError.originalError;
1761
+ }
1762
+ const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
1763
+ const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
1764
+ const delayTime = calculateDelay(retriesConsumed, options);
1765
+ const remainingTimeBeforeCallbacks = calculateRemainingTime(startTime, maxRetryTime);
1766
+ if (remainingTimeBeforeCallbacks <= 0) {
1767
+ const context2 = Object.freeze({
1768
+ error: normalizedError,
1769
+ attemptNumber,
1770
+ retriesLeft,
1771
+ retriesConsumed,
1772
+ retryDelay: 0
1773
+ });
1774
+ await options.onFailedAttempt(context2);
1775
+ throw normalizedError;
1776
+ }
1777
+ const consumeRetryContext = Object.freeze({
1778
+ error: normalizedError,
1779
+ attemptNumber,
1780
+ retriesLeft,
1781
+ retriesConsumed,
1782
+ retryDelay: retriesLeft > 0 ? delayTime : 0
1783
+ });
1784
+ const consumeRetry = await options.shouldConsumeRetry(consumeRetryContext);
1785
+ const effectiveDelay = consumeRetry && retriesLeft > 0 ? delayTime : 0;
1786
+ const context = Object.freeze({
1787
+ error: normalizedError,
1788
+ attemptNumber,
1789
+ retriesLeft,
1790
+ retriesConsumed,
1791
+ retryDelay: effectiveDelay
1792
+ });
1793
+ await options.onFailedAttempt(context);
1794
+ if (calculateRemainingTime(startTime, maxRetryTime) <= 0) {
1795
+ throw normalizedError;
1796
+ }
1797
+ const remainingTime = calculateRemainingTime(startTime, maxRetryTime);
1798
+ if (remainingTime <= 0 || retriesLeft <= 0) {
1799
+ throw normalizedError;
1800
+ }
1801
+ if (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {
1802
+ throw normalizedError;
1803
+ }
1804
+ if (!await options.shouldRetry(context)) {
1805
+ throw normalizedError;
1806
+ }
1807
+ const remainingTimeAfterShouldRetry = calculateRemainingTime(startTime, maxRetryTime);
1808
+ if (remainingTimeAfterShouldRetry <= 0) {
1809
+ throw normalizedError;
1810
+ }
1811
+ if (!consumeRetry) {
1812
+ options.signal?.throwIfAborted();
1813
+ return false;
1814
+ }
1815
+ const finalDelay = Math.min(effectiveDelay, remainingTimeAfterShouldRetry);
1816
+ options.signal?.throwIfAborted();
1817
+ await delayForRetry(finalDelay, options);
1818
+ options.signal?.throwIfAborted();
1819
+ return true;
1820
+ }
1821
+ async function pRetry(input, options = {}) {
1822
+ options = { ...options };
1823
+ validateRetries(options.retries);
1824
+ if (Object.hasOwn(options, "forever")) {
1825
+ throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
1826
+ }
1827
+ options.retries ??= 10;
1828
+ options.factor ??= 2;
1829
+ options.minTimeout ??= 1e3;
1830
+ options.maxTimeout ??= Number.POSITIVE_INFINITY;
1831
+ options.maxRetryTime ??= Number.POSITIVE_INFINITY;
1832
+ options.randomize ??= false;
1833
+ options.onFailedAttempt ??= () => {
1834
+ };
1835
+ options.shouldRetry ??= () => true;
1836
+ options.shouldConsumeRetry ??= () => true;
1837
+ validateFunctionOption("onFailedAttempt", options.onFailedAttempt);
1838
+ validateFunctionOption("shouldRetry", options.shouldRetry);
1839
+ validateFunctionOption("shouldConsumeRetry", options.shouldConsumeRetry);
1840
+ validateNumberOption("factor", options.factor, { min: 0, allowInfinity: false });
1841
+ validateNumberOption("minTimeout", options.minTimeout, { min: 0, allowInfinity: false });
1842
+ validateNumberOption("maxTimeout", options.maxTimeout, { min: 0, allowInfinity: true });
1843
+ validateNumberOption("maxRetryTime", options.maxRetryTime, { min: 0, allowInfinity: true });
1844
+ if (!(options.factor > 0)) {
1845
+ options.factor = 1;
1846
+ }
1847
+ options.signal?.throwIfAborted();
1848
+ let attemptNumber = 0;
1849
+ let retriesConsumed = 0;
1850
+ const startTime = performance.now();
1851
+ while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {
1852
+ attemptNumber++;
1853
+ try {
1854
+ options.signal?.throwIfAborted();
1855
+ const result = await input(attemptNumber);
1856
+ options.signal?.throwIfAborted();
1857
+ return result;
1858
+ } catch (error) {
1859
+ if (await onAttemptFailure({
1860
+ error,
1861
+ attemptNumber,
1862
+ retriesConsumed,
1863
+ startTime,
1864
+ options
1865
+ })) {
1866
+ retriesConsumed++;
1867
+ }
1868
+ }
1869
+ }
1870
+ throw new Error("Retry attempts exhausted without throwing an error.");
1871
+ }
1872
+
1873
+ // src/utils/downloadWithRetry.ts
1874
+ var downloadWithRetry = async (callbackFn, abortStatuses = [404]) => {
1875
+ return await pRetry(callbackFn, {
1876
+ retries: 3,
1877
+ shouldRetry: ({ error }) => {
1878
+ if (isAxiosError(error) && abortStatuses.includes(error.response?.status ?? 0)) {
1879
+ return false;
1880
+ }
1881
+ return true;
1882
+ }
1883
+ });
1884
+ };
1885
+
1886
+ // src/platform-sdk.ts
1218
1887
  var validationErrorSchema = z.object({
1219
1888
  detail: z.array(
1220
1889
  z.object({
@@ -1246,6 +1915,24 @@ function handleRequestError(error) {
1246
1915
  statusCode: 404
1247
1916
  });
1248
1917
  }
1918
+ case 403: {
1919
+ throw new APIError(`Access forbidden: ${error.message}`, {
1920
+ context: {
1921
+ responseBody: errorResponseSchema.parse(error.response?.data)
1922
+ },
1923
+ originalError: error,
1924
+ statusCode: 403
1925
+ });
1926
+ }
1927
+ case 410: {
1928
+ throw new APIError(`Resource gone: ${error.message}`, {
1929
+ context: {
1930
+ responseBody: errorResponseSchema.parse(error.response?.data)
1931
+ },
1932
+ originalError: error,
1933
+ statusCode: 410
1934
+ });
1935
+ }
1249
1936
  default: {
1250
1937
  throw new APIError(`API request failed: ${error.message}`, {
1251
1938
  context: {
@@ -1481,7 +2168,7 @@ var PlatformSDKHttp = class {
1481
2168
  page: options?.page,
1482
2169
  pageSize: options?.pageSize
1483
2170
  });
1484
- return response.data;
2171
+ return response.data.map(processApplicationRun);
1485
2172
  } catch (error) {
1486
2173
  handleRequestError(error);
1487
2174
  }
@@ -1566,7 +2253,7 @@ var PlatformSDKHttp = class {
1566
2253
  const response = await client.getRunV1RunsRunIdGet({
1567
2254
  runId: applicationRunId
1568
2255
  });
1569
- return response.data;
2256
+ return processApplicationRun(response.data);
1570
2257
  } catch (error) {
1571
2258
  handleRequestError(error);
1572
2259
  }
@@ -1657,7 +2344,7 @@ var PlatformSDKHttp = class {
1657
2344
  state,
1658
2345
  terminationReason
1659
2346
  });
1660
- return response.data;
2347
+ return response.data.map(processRunItem);
1661
2348
  } catch (error) {
1662
2349
  handleRequestError(error);
1663
2350
  }
@@ -1704,11 +2391,63 @@ var PlatformSDKHttp = class {
1704
2391
  getConfig() {
1705
2392
  return { ...this.#config };
1706
2393
  }
2394
+ /**
2395
+ * Download an artifact file from a completed application run
2396
+ *
2397
+ * This method retrieves the binary content of a specific artifact produced
2398
+ * during an application run. Artifacts can include generated reports, processed
2399
+ * images, or other output files from the AI model execution.
2400
+ *
2401
+ * The download is performed with automatic retries for transient failures.
2402
+ * Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
2403
+ *
2404
+ * @param runId - The unique identifier of the application run
2405
+ * @param artifactId - The unique identifier of the artifact to download
2406
+ * @returns A promise that resolves to an ArrayBuffer containing the artifact's binary content
2407
+ * @throws {AuthenticationError} If no valid authentication token is available
2408
+ * @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
2409
+ * @throws {UnexpectedError} If a non-HTTP error occurs
2410
+ *
2411
+ * @example
2412
+ * ```typescript
2413
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
2414
+ *
2415
+ * try {
2416
+ * const buffer = await sdk.downloadArtifact('run-123', 'artifact-456');
2417
+ * console.log(`Downloaded ${buffer.byteLength} bytes`);
2418
+ *
2419
+ * // Write to file (Node.js)
2420
+ * fs.writeFileSync('output.bin', Buffer.from(buffer));
2421
+ * } catch (error) {
2422
+ * console.error('Failed to download artifact:', error.message);
2423
+ * }
2424
+ * ```
2425
+ */
2426
+ async downloadArtifact(runId, artifactId) {
2427
+ const client = await this.#getClient();
2428
+ try {
2429
+ const response = await downloadWithRetry(
2430
+ () => client.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(
2431
+ {
2432
+ runId,
2433
+ artifactId
2434
+ },
2435
+ {
2436
+ responseType: "arraybuffer"
2437
+ }
2438
+ ),
2439
+ [403, 404, 410, 422]
2440
+ );
2441
+ return response.data;
2442
+ } catch (error) {
2443
+ handleRequestError(error);
2444
+ }
2445
+ }
1707
2446
  };
1708
2447
 
1709
2448
  // src/index.ts
1710
2449
  var index_default = PlatformSDKHttp;
1711
2450
 
1712
- export { APIError, ArtifactOutput, ArtifactState, ArtifactTerminationReason, AuthenticationError, BaseError, Configuration, ConfigurationError, ItemOutput, ItemState, ItemTerminationReason, OutputArtifactScope, OutputArtifactVisibility, PlatformSDKHttp, PublicApi, PublicApiAxiosParamCreator, PublicApiFactory, PublicApiFp, RunOutput, RunState, RunTerminationReason, index_default as default };
2451
+ export { APIError, ArtifactOutput, ArtifactState, ArtifactTerminationReason, AuthenticationError, BaseError, Configuration, ConfigurationError, ItemOutput, ItemState, ItemTerminationReason, OutputArtifactScope, OutputArtifactVisibility, PlatformSDKHttp, PublicApi, PublicApiAxiosParamCreator, PublicApiFactory, PublicApiFp, RunOutput, RunState, RunTerminationReason, VersionDocumentVisibility, canDownloadItem, canDownloadRunItems, index_default as default, getItemStatus, getRunProgress, getRunStatus, processApplicationRun, processRunItem };
1713
2452
  //# sourceMappingURL=index.js.map
1714
2453
  //# sourceMappingURL=index.js.map