@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.cjs CHANGED
@@ -141,6 +141,10 @@ var RunTerminationReason = {
141
141
  CanceledBySystem: "CANCELED_BY_SYSTEM",
142
142
  CanceledByUser: "CANCELED_BY_USER"
143
143
  };
144
+ var VersionDocumentVisibility = {
145
+ Public: "public",
146
+ Internal: "internal"
147
+ };
144
148
  var PublicApiAxiosParamCreator = function(configuration) {
145
149
  return {
146
150
  /**
@@ -255,6 +259,35 @@ var PublicApiAxiosParamCreator = function(configuration) {
255
259
  options: localVarRequestOptions
256
260
  };
257
261
  },
262
+ /**
263
+ * 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.
264
+ * @summary Get Artifact Url
265
+ * @param {string} runId Run id, returned by `POST /runs/` endpoint
266
+ * @param {string} artifactId The artifact id to download
267
+ * @param {*} [options] Override http request option.
268
+ * @throws {RequiredError}
269
+ */
270
+ getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet: async (runId, artifactId, options = {}) => {
271
+ assertParamExists("getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet", "runId", runId);
272
+ assertParamExists("getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet", "artifactId", artifactId);
273
+ const localVarPath = `/v1/runs/{run_id}/artifacts/{artifact_id}/file`.replace(`{${"run_id"}}`, encodeURIComponent(String(runId))).replace(`{${"artifact_id"}}`, encodeURIComponent(String(artifactId)));
274
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
275
+ let baseOptions;
276
+ if (configuration) {
277
+ baseOptions = configuration.baseOptions;
278
+ }
279
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
280
+ const localVarHeaderParameter = {};
281
+ const localVarQueryParameter = {};
282
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
283
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
284
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
285
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
286
+ return {
287
+ url: toPathString(localVarUrlObj),
288
+ options: localVarRequestOptions
289
+ };
290
+ },
258
291
  /**
259
292
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
260
293
  * @summary Get Item By Run
@@ -336,6 +369,99 @@ var PublicApiAxiosParamCreator = function(configuration) {
336
369
  options: localVarRequestOptions
337
370
  };
338
371
  },
372
+ /**
373
+ * Return metadata for a single public document attached to an application version.
374
+ * @summary Get version document metadata
375
+ * @param {string} applicationId
376
+ * @param {string} version
377
+ * @param {string} name
378
+ * @param {*} [options] Override http request option.
379
+ * @throws {RequiredError}
380
+ */
381
+ getVersionDocument: async (applicationId, version, name, options = {}) => {
382
+ assertParamExists("getVersionDocument", "applicationId", applicationId);
383
+ assertParamExists("getVersionDocument", "version", version);
384
+ assertParamExists("getVersionDocument", "name", name);
385
+ 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)));
386
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
387
+ let baseOptions;
388
+ if (configuration) {
389
+ baseOptions = configuration.baseOptions;
390
+ }
391
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
392
+ const localVarHeaderParameter = {};
393
+ const localVarQueryParameter = {};
394
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
395
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
396
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
397
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
398
+ return {
399
+ url: toPathString(localVarUrlObj),
400
+ options: localVarRequestOptions
401
+ };
402
+ },
403
+ /**
404
+ * 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``.
405
+ * @summary Stream version document content (programmatic)
406
+ * @param {string} applicationId
407
+ * @param {string} version
408
+ * @param {string} name
409
+ * @param {*} [options] Override http request option.
410
+ * @throws {RequiredError}
411
+ */
412
+ getVersionDocumentContent: async (applicationId, version, name, options = {}) => {
413
+ assertParamExists("getVersionDocumentContent", "applicationId", applicationId);
414
+ assertParamExists("getVersionDocumentContent", "version", version);
415
+ assertParamExists("getVersionDocumentContent", "name", name);
416
+ 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)));
417
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
418
+ let baseOptions;
419
+ if (configuration) {
420
+ baseOptions = configuration.baseOptions;
421
+ }
422
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
423
+ const localVarHeaderParameter = {};
424
+ const localVarQueryParameter = {};
425
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
426
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
427
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
428
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
429
+ return {
430
+ url: toPathString(localVarUrlObj),
431
+ options: localVarRequestOptions
432
+ };
433
+ },
434
+ /**
435
+ * 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``.
436
+ * @summary Download version document (browser)
437
+ * @param {string} applicationId
438
+ * @param {string} version
439
+ * @param {string} name
440
+ * @param {*} [options] Override http request option.
441
+ * @throws {RequiredError}
442
+ */
443
+ getVersionDocumentFile: async (applicationId, version, name, options = {}) => {
444
+ assertParamExists("getVersionDocumentFile", "applicationId", applicationId);
445
+ assertParamExists("getVersionDocumentFile", "version", version);
446
+ assertParamExists("getVersionDocumentFile", "name", name);
447
+ 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)));
448
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
449
+ let baseOptions;
450
+ if (configuration) {
451
+ baseOptions = configuration.baseOptions;
452
+ }
453
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
454
+ const localVarHeaderParameter = {};
455
+ const localVarQueryParameter = {};
456
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
457
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
458
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
459
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
460
+ return {
461
+ url: toPathString(localVarUrlObj),
462
+ options: localVarRequestOptions
463
+ };
464
+ },
339
465
  /**
340
466
  * 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.
341
467
  * @summary List available applications
@@ -441,11 +567,12 @@ var PublicApiAxiosParamCreator = function(configuration) {
441
567
  * @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**
442
568
  * @param {number} [page]
443
569
  * @param {number} [pageSize]
570
+ * @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.
444
571
  * @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)
445
572
  * @param {*} [options] Override http request option.
446
573
  * @throws {RequiredError}
447
574
  */
448
- listRunsV1RunsGet: async (applicationId, applicationVersion, externalId, customMetadata, page, pageSize, sort, options = {}) => {
575
+ listRunsV1RunsGet: async (applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options = {}) => {
449
576
  const localVarPath = `/v1/runs`;
450
577
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
451
578
  let baseOptions;
@@ -474,6 +601,9 @@ var PublicApiAxiosParamCreator = function(configuration) {
474
601
  if (pageSize !== void 0) {
475
602
  localVarQueryParameter["page_size"] = pageSize;
476
603
  }
604
+ if (forOrganization !== void 0) {
605
+ localVarQueryParameter["for_organization"] = forOrganization;
606
+ }
477
607
  if (sort) {
478
608
  localVarQueryParameter["sort"] = sort;
479
609
  }
@@ -485,6 +615,35 @@ var PublicApiAxiosParamCreator = function(configuration) {
485
615
  options: localVarRequestOptions
486
616
  };
487
617
  },
618
+ /**
619
+ * List public documents attached to an application version. Returns only documents with ``visibility=public`` and ``status=uploaded``.
620
+ * @summary List version documents
621
+ * @param {string} applicationId
622
+ * @param {string} version
623
+ * @param {*} [options] Override http request option.
624
+ * @throws {RequiredError}
625
+ */
626
+ listVersionDocuments: async (applicationId, version, options = {}) => {
627
+ assertParamExists("listVersionDocuments", "applicationId", applicationId);
628
+ assertParamExists("listVersionDocuments", "version", version);
629
+ const localVarPath = `/v1/applications/{application_id}/versions/{version}/documents`.replace(`{${"application_id"}}`, encodeURIComponent(String(applicationId))).replace(`{${"version"}}`, encodeURIComponent(String(version)));
630
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
631
+ let baseOptions;
632
+ if (configuration) {
633
+ baseOptions = configuration.baseOptions;
634
+ }
635
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
636
+ const localVarHeaderParameter = {};
637
+ const localVarQueryParameter = {};
638
+ await setOAuthToObject(localVarHeaderParameter, "OAuth2AuthorizationCodeBearer", [], configuration);
639
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
640
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
641
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
642
+ return {
643
+ url: toPathString(localVarUrlObj),
644
+ options: localVarRequestOptions
645
+ };
646
+ },
488
647
  /**
489
648
  * 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`.
490
649
  * @summary Put Item Custom Metadata By Run
@@ -634,6 +793,20 @@ var PublicApiFp = function(configuration) {
634
793
  const localVarOperationServerBasePath = operationServerMap["PublicApi.deleteRunItemsV1RunsRunIdArtifactsDelete"]?.[localVarOperationServerIndex]?.url;
635
794
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
636
795
  },
796
+ /**
797
+ * 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.
798
+ * @summary Get Artifact Url
799
+ * @param {string} runId Run id, returned by &#x60;POST /runs/&#x60; endpoint
800
+ * @param {string} artifactId The artifact id to download
801
+ * @param {*} [options] Override http request option.
802
+ * @throws {RequiredError}
803
+ */
804
+ async getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(runId, artifactId, options) {
805
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(runId, artifactId, options);
806
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
807
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet"]?.[localVarOperationServerIndex]?.url;
808
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
809
+ },
637
810
  /**
638
811
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
639
812
  * @summary Get Item By Run
@@ -673,6 +846,51 @@ var PublicApiFp = function(configuration) {
673
846
  const localVarOperationServerBasePath = operationServerMap["PublicApi.getRunV1RunsRunIdGet"]?.[localVarOperationServerIndex]?.url;
674
847
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
675
848
  },
849
+ /**
850
+ * Return metadata for a single public document attached to an application version.
851
+ * @summary Get version document metadata
852
+ * @param {string} applicationId
853
+ * @param {string} version
854
+ * @param {string} name
855
+ * @param {*} [options] Override http request option.
856
+ * @throws {RequiredError}
857
+ */
858
+ async getVersionDocument(applicationId, version, name, options) {
859
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getVersionDocument(applicationId, version, name, options);
860
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
861
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.getVersionDocument"]?.[localVarOperationServerIndex]?.url;
862
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
863
+ },
864
+ /**
865
+ * 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``.
866
+ * @summary Stream version document content (programmatic)
867
+ * @param {string} applicationId
868
+ * @param {string} version
869
+ * @param {string} name
870
+ * @param {*} [options] Override http request option.
871
+ * @throws {RequiredError}
872
+ */
873
+ async getVersionDocumentContent(applicationId, version, name, options) {
874
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getVersionDocumentContent(applicationId, version, name, options);
875
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
876
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.getVersionDocumentContent"]?.[localVarOperationServerIndex]?.url;
877
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
878
+ },
879
+ /**
880
+ * 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``.
881
+ * @summary Download version document (browser)
882
+ * @param {string} applicationId
883
+ * @param {string} version
884
+ * @param {string} name
885
+ * @param {*} [options] Override http request option.
886
+ * @throws {RequiredError}
887
+ */
888
+ async getVersionDocumentFile(applicationId, version, name, options) {
889
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getVersionDocumentFile(applicationId, version, name, options);
890
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
891
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.getVersionDocumentFile"]?.[localVarOperationServerIndex]?.url;
892
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
893
+ },
676
894
  /**
677
895
  * 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.
678
896
  * @summary List available applications
@@ -718,16 +936,31 @@ var PublicApiFp = function(configuration) {
718
936
  * @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**
719
937
  * @param {number} [page]
720
938
  * @param {number} [pageSize]
939
+ * @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.
721
940
  * @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)
722
941
  * @param {*} [options] Override http request option.
723
942
  * @throws {RequiredError}
724
943
  */
725
- async listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, sort, options) {
726
- const localVarAxiosArgs = await localVarAxiosParamCreator.listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, sort, options);
944
+ async listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options) {
945
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options);
727
946
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
728
947
  const localVarOperationServerBasePath = operationServerMap["PublicApi.listRunsV1RunsGet"]?.[localVarOperationServerIndex]?.url;
729
948
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
730
949
  },
950
+ /**
951
+ * List public documents attached to an application version. Returns only documents with ``visibility=public`` and ``status=uploaded``.
952
+ * @summary List version documents
953
+ * @param {string} applicationId
954
+ * @param {string} version
955
+ * @param {*} [options] Override http request option.
956
+ * @throws {RequiredError}
957
+ */
958
+ async listVersionDocuments(applicationId, version, options) {
959
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listVersionDocuments(applicationId, version, options);
960
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
961
+ const localVarOperationServerBasePath = operationServerMap["PublicApi.listVersionDocuments"]?.[localVarOperationServerIndex]?.url;
962
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
963
+ },
731
964
  /**
732
965
  * 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`.
733
966
  * @summary Put Item Custom Metadata By Run
@@ -815,6 +1048,16 @@ var PublicApiFactory = function(configuration, basePath, axios) {
815
1048
  deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters, options) {
816
1049
  return localVarFp.deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters.runId, options).then((request) => request(axios, basePath));
817
1050
  },
1051
+ /**
1052
+ * 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.
1053
+ * @summary Get Artifact Url
1054
+ * @param {PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest} requestParameters Request parameters.
1055
+ * @param {*} [options] Override http request option.
1056
+ * @throws {RequiredError}
1057
+ */
1058
+ getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters, options) {
1059
+ return localVarFp.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters.runId, requestParameters.artifactId, options).then((request) => request(axios, basePath));
1060
+ },
818
1061
  /**
819
1062
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
820
1063
  * @summary Get Item By Run
@@ -844,6 +1087,36 @@ var PublicApiFactory = function(configuration, basePath, axios) {
844
1087
  getRunV1RunsRunIdGet(requestParameters, options) {
845
1088
  return localVarFp.getRunV1RunsRunIdGet(requestParameters.runId, options).then((request) => request(axios, basePath));
846
1089
  },
1090
+ /**
1091
+ * Return metadata for a single public document attached to an application version.
1092
+ * @summary Get version document metadata
1093
+ * @param {PublicApiGetVersionDocumentRequest} requestParameters Request parameters.
1094
+ * @param {*} [options] Override http request option.
1095
+ * @throws {RequiredError}
1096
+ */
1097
+ getVersionDocument(requestParameters, options) {
1098
+ return localVarFp.getVersionDocument(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(axios, basePath));
1099
+ },
1100
+ /**
1101
+ * 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``.
1102
+ * @summary Stream version document content (programmatic)
1103
+ * @param {PublicApiGetVersionDocumentContentRequest} requestParameters Request parameters.
1104
+ * @param {*} [options] Override http request option.
1105
+ * @throws {RequiredError}
1106
+ */
1107
+ getVersionDocumentContent(requestParameters, options) {
1108
+ return localVarFp.getVersionDocumentContent(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(axios, basePath));
1109
+ },
1110
+ /**
1111
+ * 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``.
1112
+ * @summary Download version document (browser)
1113
+ * @param {PublicApiGetVersionDocumentFileRequest} requestParameters Request parameters.
1114
+ * @param {*} [options] Override http request option.
1115
+ * @throws {RequiredError}
1116
+ */
1117
+ getVersionDocumentFile(requestParameters, options) {
1118
+ return localVarFp.getVersionDocumentFile(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(axios, basePath));
1119
+ },
847
1120
  /**
848
1121
  * 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.
849
1122
  * @summary List available applications
@@ -872,7 +1145,17 @@ var PublicApiFactory = function(configuration, basePath, axios) {
872
1145
  * @throws {RequiredError}
873
1146
  */
874
1147
  listRunsV1RunsGet(requestParameters = {}, options) {
875
- return localVarFp.listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.sort, options).then((request) => request(axios, basePath));
1148
+ 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));
1149
+ },
1150
+ /**
1151
+ * List public documents attached to an application version. Returns only documents with ``visibility=public`` and ``status=uploaded``.
1152
+ * @summary List version documents
1153
+ * @param {PublicApiListVersionDocumentsRequest} requestParameters Request parameters.
1154
+ * @param {*} [options] Override http request option.
1155
+ * @throws {RequiredError}
1156
+ */
1157
+ listVersionDocuments(requestParameters, options) {
1158
+ return localVarFp.listVersionDocuments(requestParameters.applicationId, requestParameters.version, options).then((request) => request(axios, basePath));
876
1159
  },
877
1160
  /**
878
1161
  * 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`.
@@ -951,6 +1234,17 @@ var PublicApi = class extends BaseAPI {
951
1234
  deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters, options) {
952
1235
  return PublicApiFp(this.configuration).deleteRunItemsV1RunsRunIdArtifactsDelete(requestParameters.runId, options).then((request) => request(this.axios, this.basePath));
953
1236
  }
1237
+ /**
1238
+ * 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.
1239
+ * @summary Get Artifact Url
1240
+ * @param {PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest} requestParameters Request parameters.
1241
+ * @param {*} [options] Override http request option.
1242
+ * @throws {RequiredError}
1243
+ * @memberof PublicApi
1244
+ */
1245
+ getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters, options) {
1246
+ return PublicApiFp(this.configuration).getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(requestParameters.runId, requestParameters.artifactId, options).then((request) => request(this.axios, this.basePath));
1247
+ }
954
1248
  /**
955
1249
  * Retrieve details of a specific item (slide) by its external ID and the run ID.
956
1250
  * @summary Get Item By Run
@@ -983,6 +1277,39 @@ var PublicApi = class extends BaseAPI {
983
1277
  getRunV1RunsRunIdGet(requestParameters, options) {
984
1278
  return PublicApiFp(this.configuration).getRunV1RunsRunIdGet(requestParameters.runId, options).then((request) => request(this.axios, this.basePath));
985
1279
  }
1280
+ /**
1281
+ * Return metadata for a single public document attached to an application version.
1282
+ * @summary Get version document metadata
1283
+ * @param {PublicApiGetVersionDocumentRequest} requestParameters Request parameters.
1284
+ * @param {*} [options] Override http request option.
1285
+ * @throws {RequiredError}
1286
+ * @memberof PublicApi
1287
+ */
1288
+ getVersionDocument(requestParameters, options) {
1289
+ return PublicApiFp(this.configuration).getVersionDocument(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(this.axios, this.basePath));
1290
+ }
1291
+ /**
1292
+ * 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``.
1293
+ * @summary Stream version document content (programmatic)
1294
+ * @param {PublicApiGetVersionDocumentContentRequest} requestParameters Request parameters.
1295
+ * @param {*} [options] Override http request option.
1296
+ * @throws {RequiredError}
1297
+ * @memberof PublicApi
1298
+ */
1299
+ getVersionDocumentContent(requestParameters, options) {
1300
+ return PublicApiFp(this.configuration).getVersionDocumentContent(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(this.axios, this.basePath));
1301
+ }
1302
+ /**
1303
+ * 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``.
1304
+ * @summary Download version document (browser)
1305
+ * @param {PublicApiGetVersionDocumentFileRequest} requestParameters Request parameters.
1306
+ * @param {*} [options] Override http request option.
1307
+ * @throws {RequiredError}
1308
+ * @memberof PublicApi
1309
+ */
1310
+ getVersionDocumentFile(requestParameters, options) {
1311
+ return PublicApiFp(this.configuration).getVersionDocumentFile(requestParameters.applicationId, requestParameters.version, requestParameters.name, options).then((request) => request(this.axios, this.basePath));
1312
+ }
986
1313
  /**
987
1314
  * 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.
988
1315
  * @summary List available applications
@@ -1014,7 +1341,18 @@ var PublicApi = class extends BaseAPI {
1014
1341
  * @memberof PublicApi
1015
1342
  */
1016
1343
  listRunsV1RunsGet(requestParameters = {}, options) {
1017
- 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));
1344
+ 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));
1345
+ }
1346
+ /**
1347
+ * List public documents attached to an application version. Returns only documents with ``visibility=public`` and ``status=uploaded``.
1348
+ * @summary List version documents
1349
+ * @param {PublicApiListVersionDocumentsRequest} requestParameters Request parameters.
1350
+ * @param {*} [options] Override http request option.
1351
+ * @throws {RequiredError}
1352
+ * @memberof PublicApi
1353
+ */
1354
+ listVersionDocuments(requestParameters, options) {
1355
+ return PublicApiFp(this.configuration).listVersionDocuments(requestParameters.applicationId, requestParameters.version, options).then((request) => request(this.axios, this.basePath));
1018
1356
  }
1019
1357
  /**
1020
1358
  * 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`.
@@ -1224,6 +1562,337 @@ var UnexpectedError = class extends BaseError {
1224
1562
  super(message, "UNEXPECTED_ERROR", options);
1225
1563
  }
1226
1564
  };
1565
+
1566
+ // src/entities/application-run/utils.ts
1567
+ function getRunProgress(run) {
1568
+ const {
1569
+ item_count,
1570
+ item_succeeded_count,
1571
+ item_user_error_count,
1572
+ item_system_error_count,
1573
+ item_skipped_count
1574
+ } = run.statistics;
1575
+ if (item_count === 0) return 0;
1576
+ const processed = item_succeeded_count + item_user_error_count + item_system_error_count + item_skipped_count;
1577
+ return Math.round(processed / item_count * 100);
1578
+ }
1579
+ function getRunStatus(run) {
1580
+ const { state, statistics, termination_reason } = run;
1581
+ switch (state) {
1582
+ case "PENDING":
1583
+ return "PENDING";
1584
+ case "PROCESSING":
1585
+ return "PROCESSING";
1586
+ case "TERMINATED":
1587
+ if (termination_reason === "CANCELED_BY_USER") {
1588
+ return "CANCELED";
1589
+ }
1590
+ if (termination_reason === "CANCELED_BY_SYSTEM") {
1591
+ return "FAILED";
1592
+ }
1593
+ if (statistics.item_count !== statistics.item_succeeded_count) {
1594
+ return "COMPLETED_WITH_ERRORS";
1595
+ }
1596
+ return "COMPLETED";
1597
+ }
1598
+ }
1599
+ var canDownloadRunItems = (run) => {
1600
+ const status = getRunStatus(run);
1601
+ return !["FAILED", "CANCELED", "PENDING", "PROCESSING"].includes(status);
1602
+ };
1603
+
1604
+ // src/entities/application-run/process-application-run.ts
1605
+ var processApplicationRun = (run) => {
1606
+ return {
1607
+ ...run,
1608
+ progress: getRunProgress(run),
1609
+ status: getRunStatus(run),
1610
+ can_download: canDownloadRunItems(run)
1611
+ };
1612
+ };
1613
+
1614
+ // src/entities/run-item/utils.ts
1615
+ var canDownloadItem = (item) => {
1616
+ return getItemStatus(item) === "COMPLETED";
1617
+ };
1618
+ function getItemStatus(item) {
1619
+ const { state, termination_reason } = item;
1620
+ switch (state) {
1621
+ case "PENDING":
1622
+ return "PENDING";
1623
+ case "PROCESSING":
1624
+ return "PROCESSING";
1625
+ case "TERMINATED":
1626
+ if (termination_reason === "SYSTEM_ERROR" || termination_reason === "USER_ERROR") {
1627
+ return "FAILED";
1628
+ }
1629
+ if (termination_reason === "SKIPPED") {
1630
+ return "SKIPPED";
1631
+ }
1632
+ return "COMPLETED";
1633
+ }
1634
+ }
1635
+
1636
+ // src/entities/run-item/process-run-item.ts
1637
+ var processRunItem = (item) => {
1638
+ return {
1639
+ ...item,
1640
+ status: getItemStatus(item),
1641
+ can_download: canDownloadItem(item)
1642
+ };
1643
+ };
1644
+
1645
+ // ../../node_modules/is-network-error/index.js
1646
+ var objectToString = Object.prototype.toString;
1647
+ var isError = (value) => objectToString.call(value) === "[object Error]";
1648
+ var errorMessages = /* @__PURE__ */ new Set([
1649
+ "network error",
1650
+ // Chrome
1651
+ "NetworkError when attempting to fetch resource.",
1652
+ // Firefox
1653
+ "The Internet connection appears to be offline.",
1654
+ // Safari 16
1655
+ "Network request failed",
1656
+ // `cross-fetch`
1657
+ "fetch failed",
1658
+ // Undici (Node.js)
1659
+ "terminated",
1660
+ // Undici (Node.js)
1661
+ " A network error occurred.",
1662
+ // Bun (WebKit)
1663
+ "Network connection lost"
1664
+ // Cloudflare Workers (fetch)
1665
+ ]);
1666
+ function isNetworkError(error) {
1667
+ const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
1668
+ if (!isValid) {
1669
+ return false;
1670
+ }
1671
+ const { message, stack } = error;
1672
+ if (message === "Load failed") {
1673
+ return stack === void 0 || "__sentry_captured__" in error;
1674
+ }
1675
+ if (message.startsWith("error sending request for url")) {
1676
+ return true;
1677
+ }
1678
+ if (message === "Failed to fetch" || message.startsWith("Failed to fetch (") && message.endsWith(")")) {
1679
+ return true;
1680
+ }
1681
+ return errorMessages.has(message);
1682
+ }
1683
+
1684
+ // ../../node_modules/p-retry/index.js
1685
+ function validateRetries(retries) {
1686
+ if (typeof retries === "number") {
1687
+ if (retries < 0) {
1688
+ throw new TypeError("Expected `retries` to be a non-negative number.");
1689
+ }
1690
+ if (Number.isNaN(retries)) {
1691
+ throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.");
1692
+ }
1693
+ } else if (retries !== void 0) {
1694
+ throw new TypeError("Expected `retries` to be a number or Infinity.");
1695
+ }
1696
+ }
1697
+ function validateNumberOption(name, value, { min = 0, allowInfinity = false } = {}) {
1698
+ if (value === void 0) {
1699
+ return;
1700
+ }
1701
+ if (typeof value !== "number" || Number.isNaN(value)) {
1702
+ throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
1703
+ }
1704
+ if (!allowInfinity && !Number.isFinite(value)) {
1705
+ throw new TypeError(`Expected \`${name}\` to be a finite number.`);
1706
+ }
1707
+ if (value < min) {
1708
+ throw new TypeError(`Expected \`${name}\` to be \u2265 ${min}.`);
1709
+ }
1710
+ }
1711
+ function validateFunctionOption(name, value) {
1712
+ if (value === void 0) {
1713
+ return;
1714
+ }
1715
+ if (typeof value !== "function") {
1716
+ throw new TypeError(`Expected \`${name}\` to be a function.`);
1717
+ }
1718
+ }
1719
+ var AbortError = class extends Error {
1720
+ constructor(message) {
1721
+ super();
1722
+ if (message instanceof Error) {
1723
+ this.originalError = message;
1724
+ ({ message } = message);
1725
+ } else {
1726
+ this.originalError = new Error(message);
1727
+ this.originalError.stack = this.stack;
1728
+ }
1729
+ this.name = "AbortError";
1730
+ this.message = message;
1731
+ }
1732
+ };
1733
+ function calculateDelay(retriesConsumed, options) {
1734
+ const attempt = Math.max(1, retriesConsumed + 1);
1735
+ const random = options.randomize ? Math.random() + 1 : 1;
1736
+ let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));
1737
+ timeout = Math.min(timeout, options.maxTimeout);
1738
+ return timeout;
1739
+ }
1740
+ function calculateRemainingTime(start, max) {
1741
+ if (!Number.isFinite(max)) {
1742
+ return max;
1743
+ }
1744
+ return max - (performance.now() - start);
1745
+ }
1746
+ async function delayForRetry(delay, options) {
1747
+ if (delay <= 0) {
1748
+ return;
1749
+ }
1750
+ await new Promise((resolve, reject) => {
1751
+ const onAbort = () => {
1752
+ clearTimeout(timeoutToken);
1753
+ options.signal?.removeEventListener("abort", onAbort);
1754
+ reject(options.signal.reason);
1755
+ };
1756
+ const timeoutToken = setTimeout(() => {
1757
+ options.signal?.removeEventListener("abort", onAbort);
1758
+ resolve();
1759
+ }, delay);
1760
+ if (options.unref) {
1761
+ timeoutToken.unref?.();
1762
+ }
1763
+ options.signal?.addEventListener("abort", onAbort, { once: true });
1764
+ });
1765
+ }
1766
+ async function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options }) {
1767
+ const normalizedError = error instanceof Error ? error : new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
1768
+ if (normalizedError instanceof AbortError) {
1769
+ throw normalizedError.originalError;
1770
+ }
1771
+ const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
1772
+ const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
1773
+ const delayTime = calculateDelay(retriesConsumed, options);
1774
+ const remainingTimeBeforeCallbacks = calculateRemainingTime(startTime, maxRetryTime);
1775
+ if (remainingTimeBeforeCallbacks <= 0) {
1776
+ const context2 = Object.freeze({
1777
+ error: normalizedError,
1778
+ attemptNumber,
1779
+ retriesLeft,
1780
+ retriesConsumed,
1781
+ retryDelay: 0
1782
+ });
1783
+ await options.onFailedAttempt(context2);
1784
+ throw normalizedError;
1785
+ }
1786
+ const consumeRetryContext = Object.freeze({
1787
+ error: normalizedError,
1788
+ attemptNumber,
1789
+ retriesLeft,
1790
+ retriesConsumed,
1791
+ retryDelay: retriesLeft > 0 ? delayTime : 0
1792
+ });
1793
+ const consumeRetry = await options.shouldConsumeRetry(consumeRetryContext);
1794
+ const effectiveDelay = consumeRetry && retriesLeft > 0 ? delayTime : 0;
1795
+ const context = Object.freeze({
1796
+ error: normalizedError,
1797
+ attemptNumber,
1798
+ retriesLeft,
1799
+ retriesConsumed,
1800
+ retryDelay: effectiveDelay
1801
+ });
1802
+ await options.onFailedAttempt(context);
1803
+ if (calculateRemainingTime(startTime, maxRetryTime) <= 0) {
1804
+ throw normalizedError;
1805
+ }
1806
+ const remainingTime = calculateRemainingTime(startTime, maxRetryTime);
1807
+ if (remainingTime <= 0 || retriesLeft <= 0) {
1808
+ throw normalizedError;
1809
+ }
1810
+ if (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {
1811
+ throw normalizedError;
1812
+ }
1813
+ if (!await options.shouldRetry(context)) {
1814
+ throw normalizedError;
1815
+ }
1816
+ const remainingTimeAfterShouldRetry = calculateRemainingTime(startTime, maxRetryTime);
1817
+ if (remainingTimeAfterShouldRetry <= 0) {
1818
+ throw normalizedError;
1819
+ }
1820
+ if (!consumeRetry) {
1821
+ options.signal?.throwIfAborted();
1822
+ return false;
1823
+ }
1824
+ const finalDelay = Math.min(effectiveDelay, remainingTimeAfterShouldRetry);
1825
+ options.signal?.throwIfAborted();
1826
+ await delayForRetry(finalDelay, options);
1827
+ options.signal?.throwIfAborted();
1828
+ return true;
1829
+ }
1830
+ async function pRetry(input, options = {}) {
1831
+ options = { ...options };
1832
+ validateRetries(options.retries);
1833
+ if (Object.hasOwn(options, "forever")) {
1834
+ throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
1835
+ }
1836
+ options.retries ??= 10;
1837
+ options.factor ??= 2;
1838
+ options.minTimeout ??= 1e3;
1839
+ options.maxTimeout ??= Number.POSITIVE_INFINITY;
1840
+ options.maxRetryTime ??= Number.POSITIVE_INFINITY;
1841
+ options.randomize ??= false;
1842
+ options.onFailedAttempt ??= () => {
1843
+ };
1844
+ options.shouldRetry ??= () => true;
1845
+ options.shouldConsumeRetry ??= () => true;
1846
+ validateFunctionOption("onFailedAttempt", options.onFailedAttempt);
1847
+ validateFunctionOption("shouldRetry", options.shouldRetry);
1848
+ validateFunctionOption("shouldConsumeRetry", options.shouldConsumeRetry);
1849
+ validateNumberOption("factor", options.factor, { min: 0, allowInfinity: false });
1850
+ validateNumberOption("minTimeout", options.minTimeout, { min: 0, allowInfinity: false });
1851
+ validateNumberOption("maxTimeout", options.maxTimeout, { min: 0, allowInfinity: true });
1852
+ validateNumberOption("maxRetryTime", options.maxRetryTime, { min: 0, allowInfinity: true });
1853
+ if (!(options.factor > 0)) {
1854
+ options.factor = 1;
1855
+ }
1856
+ options.signal?.throwIfAborted();
1857
+ let attemptNumber = 0;
1858
+ let retriesConsumed = 0;
1859
+ const startTime = performance.now();
1860
+ while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {
1861
+ attemptNumber++;
1862
+ try {
1863
+ options.signal?.throwIfAborted();
1864
+ const result = await input(attemptNumber);
1865
+ options.signal?.throwIfAborted();
1866
+ return result;
1867
+ } catch (error) {
1868
+ if (await onAttemptFailure({
1869
+ error,
1870
+ attemptNumber,
1871
+ retriesConsumed,
1872
+ startTime,
1873
+ options
1874
+ })) {
1875
+ retriesConsumed++;
1876
+ }
1877
+ }
1878
+ }
1879
+ throw new Error("Retry attempts exhausted without throwing an error.");
1880
+ }
1881
+
1882
+ // src/utils/downloadWithRetry.ts
1883
+ var downloadWithRetry = async (callbackFn, abortStatuses = [404]) => {
1884
+ return await pRetry(callbackFn, {
1885
+ retries: 3,
1886
+ shouldRetry: ({ error }) => {
1887
+ if (globalAxios2.isAxiosError(error) && abortStatuses.includes(error.response?.status ?? 0)) {
1888
+ return false;
1889
+ }
1890
+ return true;
1891
+ }
1892
+ });
1893
+ };
1894
+
1895
+ // src/platform-sdk.ts
1227
1896
  var validationErrorSchema = z__default.default.object({
1228
1897
  detail: z__default.default.array(
1229
1898
  z__default.default.object({
@@ -1255,6 +1924,24 @@ function handleRequestError(error) {
1255
1924
  statusCode: 404
1256
1925
  });
1257
1926
  }
1927
+ case 403: {
1928
+ throw new APIError(`Access forbidden: ${error.message}`, {
1929
+ context: {
1930
+ responseBody: errorResponseSchema.parse(error.response?.data)
1931
+ },
1932
+ originalError: error,
1933
+ statusCode: 403
1934
+ });
1935
+ }
1936
+ case 410: {
1937
+ throw new APIError(`Resource gone: ${error.message}`, {
1938
+ context: {
1939
+ responseBody: errorResponseSchema.parse(error.response?.data)
1940
+ },
1941
+ originalError: error,
1942
+ statusCode: 410
1943
+ });
1944
+ }
1258
1945
  default: {
1259
1946
  throw new APIError(`API request failed: ${error.message}`, {
1260
1947
  context: {
@@ -1490,7 +2177,7 @@ var PlatformSDKHttp = class {
1490
2177
  page: options?.page,
1491
2178
  pageSize: options?.pageSize
1492
2179
  });
1493
- return response.data;
2180
+ return response.data.map(processApplicationRun);
1494
2181
  } catch (error) {
1495
2182
  handleRequestError(error);
1496
2183
  }
@@ -1575,7 +2262,7 @@ var PlatformSDKHttp = class {
1575
2262
  const response = await client.getRunV1RunsRunIdGet({
1576
2263
  runId: applicationRunId
1577
2264
  });
1578
- return response.data;
2265
+ return processApplicationRun(response.data);
1579
2266
  } catch (error) {
1580
2267
  handleRequestError(error);
1581
2268
  }
@@ -1666,7 +2353,7 @@ var PlatformSDKHttp = class {
1666
2353
  state,
1667
2354
  terminationReason
1668
2355
  });
1669
- return response.data;
2356
+ return response.data.map(processRunItem);
1670
2357
  } catch (error) {
1671
2358
  handleRequestError(error);
1672
2359
  }
@@ -1713,6 +2400,58 @@ var PlatformSDKHttp = class {
1713
2400
  getConfig() {
1714
2401
  return { ...this.#config };
1715
2402
  }
2403
+ /**
2404
+ * Download an artifact file from a completed application run
2405
+ *
2406
+ * This method retrieves the binary content of a specific artifact produced
2407
+ * during an application run. Artifacts can include generated reports, processed
2408
+ * images, or other output files from the AI model execution.
2409
+ *
2410
+ * The download is performed with automatic retries for transient failures.
2411
+ * Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
2412
+ *
2413
+ * @param runId - The unique identifier of the application run
2414
+ * @param artifactId - The unique identifier of the artifact to download
2415
+ * @returns A promise that resolves to an ArrayBuffer containing the artifact's binary content
2416
+ * @throws {AuthenticationError} If no valid authentication token is available
2417
+ * @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
2418
+ * @throws {UnexpectedError} If a non-HTTP error occurs
2419
+ *
2420
+ * @example
2421
+ * ```typescript
2422
+ * const sdk = new PlatformSDKHttp({ tokenProvider: () => 'your-token' });
2423
+ *
2424
+ * try {
2425
+ * const buffer = await sdk.downloadArtifact('run-123', 'artifact-456');
2426
+ * console.log(`Downloaded ${buffer.byteLength} bytes`);
2427
+ *
2428
+ * // Write to file (Node.js)
2429
+ * fs.writeFileSync('output.bin', Buffer.from(buffer));
2430
+ * } catch (error) {
2431
+ * console.error('Failed to download artifact:', error.message);
2432
+ * }
2433
+ * ```
2434
+ */
2435
+ async downloadArtifact(runId, artifactId) {
2436
+ const client = await this.#getClient();
2437
+ try {
2438
+ const response = await downloadWithRetry(
2439
+ () => client.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(
2440
+ {
2441
+ runId,
2442
+ artifactId
2443
+ },
2444
+ {
2445
+ responseType: "arraybuffer"
2446
+ }
2447
+ ),
2448
+ [403, 404, 410, 422]
2449
+ );
2450
+ return response.data;
2451
+ } catch (error) {
2452
+ handleRequestError(error);
2453
+ }
2454
+ }
1716
2455
  };
1717
2456
 
1718
2457
  // src/index.ts
@@ -1739,6 +2478,14 @@ exports.PublicApiFp = PublicApiFp;
1739
2478
  exports.RunOutput = RunOutput;
1740
2479
  exports.RunState = RunState;
1741
2480
  exports.RunTerminationReason = RunTerminationReason;
2481
+ exports.VersionDocumentVisibility = VersionDocumentVisibility;
2482
+ exports.canDownloadItem = canDownloadItem;
2483
+ exports.canDownloadRunItems = canDownloadRunItems;
1742
2484
  exports.default = index_default;
2485
+ exports.getItemStatus = getItemStatus;
2486
+ exports.getRunProgress = getRunProgress;
2487
+ exports.getRunStatus = getRunStatus;
2488
+ exports.processApplicationRun = processApplicationRun;
2489
+ exports.processRunItem = processRunItem;
1743
2490
  //# sourceMappingURL=index.cjs.map
1744
2491
  //# sourceMappingURL=index.cjs.map