Generate Fern TypeSscript SDK (#3785)

This commit is contained in:
Stanislav Novosad
2025-10-23 20:14:59 -06:00
committed by GitHub
parent d55b9637c4
commit 2062adac66
239 changed files with 14550 additions and 3 deletions

View File

@@ -0,0 +1 @@
export * as scripts from "./scripts/index.js";

View File

@@ -0,0 +1,102 @@
// 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 Scripts {
export interface Options extends BaseClientOptions {}
export interface RequestOptions extends BaseRequestOptions {}
}
export class Scripts {
protected readonly _options: Scripts.Options;
constructor(_options: Scripts.Options = {}) {
this._options = _options;
}
/**
* Run a script
*
* @param {string} scriptId - The unique identifier of the script
* @param {Scripts.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Skyvern.UnprocessableEntityError}
*
* @example
* await client.scripts.runScript("s_abc123")
*/
public runScript(scriptId: string, requestOptions?: Scripts.RequestOptions): core.HttpResponsePromise<unknown> {
return core.HttpResponsePromise.fromPromise(this.__runScript(scriptId, requestOptions));
}
private async __runScript(
scriptId: string,
requestOptions?: Scripts.RequestOptions,
): Promise<core.WithRawResponse<unknown>> {
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({
"x-api-key": requestOptions?.apiKey ?? this._options?.apiKey,
...(await this._getCustomAuthorizationHeaders()),
}),
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.Production,
`v1/scripts/${core.url.encodePathParam(scriptId)}/run`,
),
method: "POST",
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 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 POST /v1/scripts/{script_id}/run.");
case "unknown":
throw new errors.SkyvernError({
message: _response.error.errorMessage,
rawResponse: _response.rawResponse,
});
}
}
protected async _getCustomAuthorizationHeaders(): Promise<Record<string, string | undefined>> {
const xApiKeyValue = await core.Supplier.get(this._options.xApiKey);
return { "x-api-key": xApiKeyValue };
}
}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export * from "./client/index.js";