Skip to content

Automate browser based workflows with AI

Fix the TS SDK npm release: stop .gitignore from swallowing the artifacts resource (#8476)

Shuchang Zhengf42220c891a3
diff --git a/.gitignore b/.gitignore
index 86172c6f3..1df97b9de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -166,6 +166,9 @@ credential_vault/
videos/
skyvern/artifacts/
artifacts/
+# The bare artifacts/ rule above is unanchored and would otherwise swallow the
+# Fern-generated TS SDK resource of the same name, breaking the npm release build.
+!skyvern-ts/client/src/api/resources/artifacts/
traces/
*.pkl
har/
diff --git a/skyvern-ts/client/src/api/resources/artifacts/client/Client.ts b/skyvern-ts/client/src/api/resources/artifacts/client/Client.ts
new file mode 100644
index 000000000..dd574a472
--- /dev/null
+++ b/skyvern-ts/client/src/api/resources/artifacts/client/Client.ts
@@ -0,0 +1,108 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import * as errors from "../../../../errors/index.js";
+import * as Skyvern from "../../../index.js";
+
+export declare namespace Artifacts {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+export class Artifacts {
+ protected readonly _options: Artifacts.Options;
+
+ constructor(_options: Artifacts.Options = {}) {
+ this._options = _options;
+ }
+
+ /**
+ * Download the raw content of an artifact (supports bundled artifacts).
+ *
+ * @param {string} artifactId
+ * @param {Artifacts.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Skyvern.ForbiddenError}
+ * @throws {@link Skyvern.NotFoundError}
+ * @throws {@link Skyvern.RangeNotSatisfiableError}
+ * @throws {@link Skyvern.UnprocessableEntityError}
+ *
+ * @example
+ * await client.artifacts.getArtifactContent("artifact_id")
+ */
+ public getArtifactContent(
+ artifactId: string,
+ requestOptions?: Artifacts.RequestOptions,
+ ): core.HttpResponsePromise<unknown> {
+ return core.HttpResponsePromise.fromPromise(this.__getArtifactContent(artifactId, requestOptions));
+ }
+
+ private async __getArtifactContent(
+ artifactId: string,
+ requestOptions?: Artifacts.RequestOptions,
+ ): Promise<core.WithRawResponse<unknown>> {
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "x-api-key": requestOptions?.apiKey ?? this._options?.apiKey }),
+ requestOptions?.headers,
+ );
+ const _response = await core.fetcher({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SkyvernEnvironment.Cloud,
+ `v1/artifacts/${core.url.encodePathParam(artifactId)}/content`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ });
+ if (_response.ok) {
+ return { data: _response.body, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 403:
+ throw new Skyvern.ForbiddenError(_response.error.body as unknown, _response.rawResponse);
+ case 404:
+ throw new Skyvern.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ case 416:
+ throw new Skyvern.RangeNotSatisfiableError(_response.error.body as unknown, _response.rawResponse);
+ case 422:
+ throw new Skyvern.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.SkyvernError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SkyvernError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SkyvernTimeoutError(
+ "Timeout exceeded when calling GET /v1/artifacts/{artifact_id}/content.",
+ );
+ case "unknown":
+ throw new errors.SkyvernError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+}
diff --git a/skyvern-ts/client/src/api/resources/artifacts/client/index.ts b/skyvern-ts/client/src/api/resources/artifacts/client/index.ts
new file mode 100644
index 000000000..cb0ff5c3b
--- /dev/null
+++ b/skyvern-ts/client/src/api/resources/artifacts/client/index.ts
@@ -0,0 +1 @@
+export {};
diff --git a/skyvern-ts/client/src/api/resources/artifacts/index.ts b/skyvern-ts/client/src/api/resources/artifacts/index.ts
new file mode 100644
index 000000000..914b8c3c7
--- /dev/null
+++ b/skyvern-ts/client/src/api/resources/artifacts/index.ts
@@ -0,0 +1 @@
+export * from "./client/index.js";