v1.0.14 (#4770)
This commit is contained in:
@@ -26,8 +26,8 @@ export class SkyvernClient {
|
||||
"x-api-key": _options?.apiKey,
|
||||
"X-Fern-Language": "JavaScript",
|
||||
"X-Fern-SDK-Name": "@skyvern/client",
|
||||
"X-Fern-SDK-Version": "1.0.13",
|
||||
"User-Agent": "@skyvern/client/1.0.13",
|
||||
"X-Fern-SDK-Version": "1.0.14",
|
||||
"User-Agent": "@skyvern/client/1.0.14",
|
||||
"X-Fern-Runtime": core.RUNTIME.type,
|
||||
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
||||
},
|
||||
@@ -1102,6 +1102,139 @@ export class SkyvernClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List workflow runs across all workflows for the current organization.
|
||||
*
|
||||
* Results are paginated and can be filtered by **status**, **search_key**, and **error_code**. All filters are combined with **AND** logic — a run must match every supplied filter to be returned.
|
||||
*
|
||||
* ### search_key
|
||||
*
|
||||
* A case-insensitive substring search that matches against **any** of the following fields:
|
||||
*
|
||||
* | Searched field | Description |
|
||||
* |---|---|
|
||||
* | `workflow_run_id` | The unique run identifier (e.g. `wr_123…`) |
|
||||
* | Parameter **key** | The `key` of any workflow parameter definition associated with the run |
|
||||
* | Parameter **description** | The `description` of any workflow parameter definition |
|
||||
* | Run parameter **value** | The actual value supplied for any parameter when the run was created |
|
||||
* | `extra_http_headers` | Extra HTTP headers attached to the run (searched as raw JSON text) |
|
||||
*
|
||||
* Soft-deleted parameter definitions are excluded from key/description matching. A run is returned if **any** of the fields above contain the search term.
|
||||
*
|
||||
* ### error_code
|
||||
*
|
||||
* An **exact-match** filter against the `error_code` field inside each task's `errors` JSON array. A run matches if **any** of its tasks contains an error object with a matching `error_code` value. Error codes are user-defined strings set during workflow execution (e.g. `INVALID_CREDENTIALS`, `LOGIN_FAILED`, `CAPTCHA_DETECTED`).
|
||||
*
|
||||
* ### Combining filters
|
||||
*
|
||||
* All query parameters use AND logic:
|
||||
* - `?status=failed` — only failed runs
|
||||
* - `?status=failed&error_code=LOGIN_FAILED` — failed runs **and** have a LOGIN_FAILED error
|
||||
* - `?status=failed&error_code=LOGIN_FAILED&search_key=prod_credential` — all three conditions must match
|
||||
*
|
||||
* @param {Skyvern.GetWorkflowRunsRequest} request
|
||||
* @param {SkyvernClient.RequestOptions} requestOptions - Request-specific configuration.
|
||||
*
|
||||
* @throws {@link Skyvern.UnprocessableEntityError}
|
||||
*
|
||||
* @example
|
||||
* await client.getWorkflowRuns({
|
||||
* page: 1,
|
||||
* page_size: 1,
|
||||
* search_key: "search_key",
|
||||
* error_code: "error_code"
|
||||
* })
|
||||
*/
|
||||
public getWorkflowRuns(
|
||||
request: Skyvern.GetWorkflowRunsRequest = {},
|
||||
requestOptions?: SkyvernClient.RequestOptions,
|
||||
): core.HttpResponsePromise<Skyvern.WorkflowRun[]> {
|
||||
return core.HttpResponsePromise.fromPromise(this.__getWorkflowRuns(request, requestOptions));
|
||||
}
|
||||
|
||||
private async __getWorkflowRuns(
|
||||
request: Skyvern.GetWorkflowRunsRequest = {},
|
||||
requestOptions?: SkyvernClient.RequestOptions,
|
||||
): Promise<core.WithRawResponse<Skyvern.WorkflowRun[]>> {
|
||||
const { page, page_size: pageSize, status, search_key: searchKey, error_code: errorCode } = request;
|
||||
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
|
||||
if (page != null) {
|
||||
_queryParams.page = page.toString();
|
||||
}
|
||||
|
||||
if (pageSize != null) {
|
||||
_queryParams.page_size = pageSize.toString();
|
||||
}
|
||||
|
||||
if (status != null) {
|
||||
if (Array.isArray(status)) {
|
||||
_queryParams.status = status.map((item) => item);
|
||||
} else {
|
||||
_queryParams.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
if (searchKey != null) {
|
||||
_queryParams.search_key = searchKey;
|
||||
}
|
||||
|
||||
if (errorCode != null) {
|
||||
_queryParams.error_code = errorCode;
|
||||
}
|
||||
|
||||
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/workflows/runs",
|
||||
),
|
||||
method: "GET",
|
||||
headers: _headers,
|
||||
queryParameters: { ..._queryParams, ...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 as Skyvern.WorkflowRun[], 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 GET /v1/workflows/runs.");
|
||||
case "unknown":
|
||||
throw new errors.SkyvernError({
|
||||
message: _response.error.errorMessage,
|
||||
rawResponse: _response.rawResponse,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} workflowPermanentId
|
||||
* @param {Skyvern.GetWorkflowRequest} request
|
||||
@@ -2271,6 +2404,96 @@ export class SkyvernClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the stored credential data (e.g. username/password) while keeping the same credential_id.
|
||||
*
|
||||
* @param {string} credentialId - The unique identifier of the credential to update
|
||||
* @param {Skyvern.CreateCredentialRequest} request
|
||||
* @param {SkyvernClient.RequestOptions} requestOptions - Request-specific configuration.
|
||||
*
|
||||
* @throws {@link Skyvern.UnprocessableEntityError}
|
||||
*
|
||||
* @example
|
||||
* await client.updateCredential("cred_1234567890", {
|
||||
* name: "My Credential",
|
||||
* credential_type: "password",
|
||||
* credential: {
|
||||
* password: "newpassword123",
|
||||
* username: "user@example.com"
|
||||
* }
|
||||
* })
|
||||
*/
|
||||
public updateCredential(
|
||||
credentialId: string,
|
||||
request: Skyvern.CreateCredentialRequest,
|
||||
requestOptions?: SkyvernClient.RequestOptions,
|
||||
): core.HttpResponsePromise<Skyvern.CredentialResponse> {
|
||||
return core.HttpResponsePromise.fromPromise(this.__updateCredential(credentialId, request, requestOptions));
|
||||
}
|
||||
|
||||
private async __updateCredential(
|
||||
credentialId: string,
|
||||
request: Skyvern.CreateCredentialRequest,
|
||||
requestOptions?: SkyvernClient.RequestOptions,
|
||||
): Promise<core.WithRawResponse<Skyvern.CredentialResponse>> {
|
||||
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/credentials/${core.url.encodePathParam(credentialId)}/update`,
|
||||
),
|
||||
method: "POST",
|
||||
headers: _headers,
|
||||
contentType: "application/json",
|
||||
queryParameters: requestOptions?.queryParams,
|
||||
requestType: "json",
|
||||
body: request,
|
||||
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
||||
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
||||
abortSignal: requestOptions?.abortSignal,
|
||||
});
|
||||
if (_response.ok) {
|
||||
return { data: _response.body as Skyvern.CredentialResponse, 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/credentials/{credential_id}/update.",
|
||||
);
|
||||
case "unknown":
|
||||
throw new errors.SkyvernError({
|
||||
message: _response.error.errorMessage,
|
||||
rawResponse: _response.rawResponse,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a specific credential by its ID
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user