@usestatemachines/sdk 0.1.1 → 0.3.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/README.md +265 -75
- package/agents/SKILL.md +33 -46
- package/agents/index.js +7 -7
- package/agents/llms.txt +25 -40
- package/agents/prompt.md +11 -34
- package/esm/extensions/apps.d.ts +18 -0
- package/esm/extensions/apps.js +39 -0
- package/esm/extensions/client.d.ts +66 -3
- package/esm/extensions/client.js +236 -35
- package/esm/extensions/errors.d.ts +50 -6
- package/esm/extensions/errors.js +37 -3
- package/esm/extensions/index.d.ts +5 -3
- package/esm/extensions/index.js +2 -1
- package/esm/extensions/running-environment.d.ts +32 -0
- package/esm/extensions/running-environment.js +44 -0
- package/esm/extensions/signal.d.ts +1 -2
- package/esm/extensions/signal.js +9 -4
- package/esm/extensions/wait.d.ts +11 -3
- package/esm/extensions/wait.js +23 -13
- package/esm/funcs/create-environment-definition.d.ts +11 -0
- package/esm/funcs/create-environment-definition.js +94 -0
- package/esm/funcs/environments-list.js +1 -0
- package/esm/funcs/snapshots-capture.d.ts +11 -0
- package/esm/funcs/snapshots-capture.js +94 -0
- package/esm/funcs/snapshots-delete.d.ts +11 -0
- package/esm/funcs/snapshots-delete.js +92 -0
- package/esm/funcs/snapshots-get.d.ts +11 -0
- package/esm/funcs/snapshots-get.js +92 -0
- package/esm/funcs/snapshots-list.d.ts +11 -0
- package/esm/funcs/snapshots-list.js +98 -0
- package/esm/funcs/snapshots-update.d.ts +11 -0
- package/esm/funcs/snapshots-update.js +93 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/app-instance-snapshot.d.ts +15 -0
- package/esm/models/app-instance-snapshot.js +19 -0
- package/esm/models/connection-secret.d.ts +16 -0
- package/esm/models/connection-secret.js +13 -0
- package/esm/models/connection.d.ts +14 -0
- package/esm/models/connection.js +14 -0
- package/esm/models/create-environment-input.d.ts +6 -2
- package/esm/models/create-environment-input.js +3 -1
- package/esm/models/environment-app.d.ts +1 -0
- package/esm/models/environment-app.js +1 -0
- package/esm/models/environment-snapshot.d.ts +39 -0
- package/esm/models/environment-snapshot.js +41 -0
- package/esm/models/environment.d.ts +1 -0
- package/esm/models/environment.js +1 -0
- package/esm/models/error-response.d.ts +5 -0
- package/esm/models/error-response.js +5 -0
- package/esm/models/index.d.ts +2 -0
- package/esm/models/index.js +2 -0
- package/esm/models/operations/capture-snapshot.d.ts +41 -0
- package/esm/models/operations/capture-snapshot.js +36 -0
- package/esm/models/operations/create-environment-definition.d.ts +143 -0
- package/esm/models/operations/create-environment-definition.js +90 -0
- package/esm/models/operations/delete-snapshot.d.ts +23 -0
- package/esm/models/operations/delete-snapshot.js +20 -0
- package/esm/models/operations/get-snapshot.d.ts +23 -0
- package/esm/models/operations/get-snapshot.js +20 -0
- package/esm/models/operations/index.d.ts +6 -0
- package/esm/models/operations/index.js +6 -0
- package/esm/models/operations/list-environments.d.ts +2 -0
- package/esm/models/operations/list-environments.js +1 -0
- package/esm/models/operations/list-snapshots.d.ts +30 -0
- package/esm/models/operations/list-snapshots.js +25 -0
- package/esm/models/operations/reveal-connection.d.ts +26 -4
- package/esm/models/operations/reveal-connection.js +28 -2
- package/esm/models/operations/update-snapshot.d.ts +37 -0
- package/esm/models/operations/update-snapshot.js +29 -0
- package/esm/sdk/sdk.d.ts +6 -1
- package/esm/sdk/sdk.js +10 -0
- package/esm/sdk/snapshots.d.ts +9 -0
- package/esm/sdk/snapshots.js +27 -0
- package/openapi.json +1471 -144
- package/package.json +10 -11
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Environment } from '../models/environment.js';
|
|
2
|
+
import type { EnvironmentSnapshot } from '../models/environment-snapshot.js';
|
|
3
|
+
import type { ReleaseActor } from '../models/release-actor.js';
|
|
4
|
+
import type { CallOptions, CaptureInput, CaptureOptions, ConnectOptions, StateMachines } from './client.js';
|
|
5
|
+
import type { Connection } from './connection.js';
|
|
6
|
+
import type { WaitOptions } from './wait.js';
|
|
7
|
+
/** A started environment. It remains the handle after `stop()`. */
|
|
8
|
+
export declare class RunningEnvironment {
|
|
9
|
+
#private;
|
|
10
|
+
readonly id: string;
|
|
11
|
+
/** The record when `start()` resolved. Use `sm.environments.get(id)` for fresh state. */
|
|
12
|
+
readonly environment: Environment;
|
|
13
|
+
constructor(sm: StateMachines, environment: Environment);
|
|
14
|
+
/**
|
|
15
|
+
* actorId defaults to the actor of the environment's declared default connection, or
|
|
16
|
+
* else the app's first actor (for Salesforce, the administrator). Pick another from
|
|
17
|
+
* actors() to act with that user's permissions.
|
|
18
|
+
*/
|
|
19
|
+
connect(appKey: string, options?: ConnectOptions): Promise<Connection>;
|
|
20
|
+
/** The app's users, in the release's order. */
|
|
21
|
+
actors(appKey: string, options?: CallOptions): Promise<ReleaseActor[]>;
|
|
22
|
+
/** Captures a snapshot in the environment's own workspace and waits until it's `ready`. */
|
|
23
|
+
snapshot(input?: CaptureInput, options?: CaptureOptions): Promise<EnvironmentSnapshot>;
|
|
24
|
+
/** Safe to call twice. Doesn't wait for disposal: use `waitUntilStopped()`. */
|
|
25
|
+
stop(options?: CallOptions): Promise<Environment>;
|
|
26
|
+
/** Resolves when the environment ended and every sandbox is confirmed disposed. */
|
|
27
|
+
waitUntilStopped(options?: WaitOptions): Promise<Environment>;
|
|
28
|
+
toJSON(): {
|
|
29
|
+
id: string;
|
|
30
|
+
environment: Environment;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** A started environment. It remains the handle after `stop()`. */
|
|
2
|
+
export class RunningEnvironment {
|
|
3
|
+
id;
|
|
4
|
+
/** The record when `start()` resolved. Use `sm.environments.get(id)` for fresh state. */
|
|
5
|
+
environment;
|
|
6
|
+
#environments;
|
|
7
|
+
#snapshots;
|
|
8
|
+
constructor(sm, environment) {
|
|
9
|
+
this.id = environment.id;
|
|
10
|
+
this.environment = environment;
|
|
11
|
+
this.#environments = sm.environments;
|
|
12
|
+
this.#snapshots = sm.snapshots;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* actorId defaults to the actor of the environment's declared default connection, or
|
|
16
|
+
* else the app's first actor (for Salesforce, the administrator). Pick another from
|
|
17
|
+
* actors() to act with that user's permissions.
|
|
18
|
+
*/
|
|
19
|
+
connect(appKey, options) {
|
|
20
|
+
return this.#environments.connect(this.id, appKey, options);
|
|
21
|
+
}
|
|
22
|
+
/** The app's users, in the release's order. */
|
|
23
|
+
actors(appKey, options) {
|
|
24
|
+
return this.#environments.actors(this.id, appKey, options);
|
|
25
|
+
}
|
|
26
|
+
/** Captures a snapshot in the environment's own workspace and waits until it's `ready`. */
|
|
27
|
+
snapshot(input, options = {}) {
|
|
28
|
+
return this.#snapshots.capture(this.id, input, {
|
|
29
|
+
...options,
|
|
30
|
+
workspaceId: options.workspaceId ?? this.environment.workspaceId,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Safe to call twice. Doesn't wait for disposal: use `waitUntilStopped()`. */
|
|
34
|
+
stop(options) {
|
|
35
|
+
return this.#environments.stop(this.id, options);
|
|
36
|
+
}
|
|
37
|
+
/** Resolves when the environment ended and every sandbox is confirmed disposed. */
|
|
38
|
+
waitUntilStopped(options) {
|
|
39
|
+
return this.#environments.waitUntilStopped(this.id, options);
|
|
40
|
+
}
|
|
41
|
+
toJSON() {
|
|
42
|
+
return { id: this.id, environment: this.environment };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** A signal that aborts on the parent's abort, after `timeoutMs`, or on `close()`. */
|
|
2
1
|
export interface LinkedSignal {
|
|
3
2
|
readonly signal: AbortSignal;
|
|
4
3
|
/** Releases the timer and the parent listener without aborting. */
|
|
@@ -11,4 +10,4 @@ export interface LinkedSignal {
|
|
|
11
10
|
* on Node 20.20 in our probes. The timer and the listener hold the controller, so
|
|
12
11
|
* the abort reaches in-flight requests.
|
|
13
12
|
*/
|
|
14
|
-
export declare function linkSignal(parent: AbortSignal | undefined, timeoutMs?: number): LinkedSignal;
|
|
13
|
+
export declare function linkSignal(parent: AbortSignal | undefined | readonly AbortSignal[], timeoutMs?: number): LinkedSignal;
|
package/esm/extensions/signal.js
CHANGED
|
@@ -4,22 +4,27 @@
|
|
|
4
4
|
* the abort reaches in-flight requests.
|
|
5
5
|
*/
|
|
6
6
|
export function linkSignal(parent, timeoutMs) {
|
|
7
|
+
const parents = parent === undefined ? [] : [parent].flat();
|
|
7
8
|
const controller = new AbortController();
|
|
8
9
|
const timer = timeoutMs === undefined
|
|
9
10
|
? undefined
|
|
10
11
|
: setTimeout(() => controller.abort(new DOMException(`Timed out after ${timeoutMs} ms.`, 'TimeoutError')), timeoutMs);
|
|
11
|
-
const onAbort = () => controller.abort(
|
|
12
|
+
const onAbort = () => controller.abort(parents.find(({ aborted }) => aborted)?.reason);
|
|
12
13
|
const dispose = () => {
|
|
13
14
|
clearTimeout(timer);
|
|
14
|
-
|
|
15
|
+
for (const each of parents) {
|
|
16
|
+
each.removeEventListener('abort', onAbort);
|
|
17
|
+
}
|
|
15
18
|
};
|
|
16
19
|
timer?.unref?.();
|
|
17
20
|
controller.signal.addEventListener('abort', dispose, { once: true });
|
|
18
|
-
if (
|
|
21
|
+
if (parents.some(({ aborted }) => aborted)) {
|
|
19
22
|
onAbort();
|
|
20
23
|
}
|
|
21
24
|
else {
|
|
22
|
-
|
|
25
|
+
for (const each of parents) {
|
|
26
|
+
each.addEventListener('abort', onAbort, { once: true });
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
return {
|
|
25
30
|
signal: controller.signal,
|
package/esm/extensions/wait.d.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import type { Environment } from '../models/environment.js';
|
|
2
|
+
import type { EnvironmentSnapshot } from '../models/environment-snapshot.js';
|
|
2
3
|
export interface WaitOptions {
|
|
3
4
|
/** Overall deadline for the wait. Defaults to 10 minutes. */
|
|
4
5
|
timeoutMs?: number;
|
|
5
6
|
/** Aborting rejects the wait with `signal.reason`. */
|
|
6
7
|
signal?: AbortSignal;
|
|
7
8
|
}
|
|
8
|
-
type Read = (signal: AbortSignal) => Promise<
|
|
9
|
-
type Decide = (
|
|
9
|
+
type Read<T> = (signal: AbortSignal) => Promise<T>;
|
|
10
|
+
type Decide<T> = (value: T) => boolean;
|
|
11
|
+
export declare const defaultTimeoutMs = 600000;
|
|
12
|
+
export declare function poll(read: Read<Environment>, done: Decide<Environment>, options?: WaitOptions): Promise<Environment>;
|
|
10
13
|
/**
|
|
11
14
|
* Reads until `done` returns true. `done` throws to end the wait with a failure.
|
|
12
15
|
* Transient read failures are retried with backoff until the deadline.
|
|
13
16
|
*/
|
|
14
|
-
export declare function
|
|
17
|
+
export declare function pollUntil<T>(read: Read<T>, done: Decide<T>, options: WaitOptions | undefined, timeout: (timeoutMs: number, last: T | null) => Error): Promise<T>;
|
|
15
18
|
/** Resolves on `running`. Never stops the environment. */
|
|
16
19
|
export declare function ready(environment: Environment): boolean;
|
|
17
20
|
/** Resolves once the environment ended and every app's sandbox is confirmed disposed. */
|
|
18
21
|
export declare function disposed(environment: Environment): boolean;
|
|
22
|
+
/** Resolves on `ready`. A failed or deleted snapshot ends the wait. */
|
|
23
|
+
export declare function snapshotReady(snapshot: EnvironmentSnapshot): boolean;
|
|
24
|
+
/** 1 s × 1.5ⁿ, capped at 5 s, with ±20% jitter. */
|
|
25
|
+
export declare function backoff(attempt: number): number;
|
|
26
|
+
export declare function sleep(ms: number, signal: AbortSignal | null | undefined): Promise<void>;
|
|
19
27
|
export {};
|
package/esm/extensions/wait.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { DisposalIncompleteError, EnvironmentFailedError, TimeoutError, toStateMachinesError, } from './errors.js';
|
|
1
|
+
import { DisposalIncompleteError, EnvironmentFailedError, SnapshotFailedError, TimeoutError, toStateMachinesError, } from './errors.js';
|
|
2
2
|
import { linkSignal } from './signal.js';
|
|
3
|
-
const defaultTimeoutMs = 600000;
|
|
3
|
+
export const defaultTimeoutMs = 600000;
|
|
4
4
|
const readTimeoutMs = 30000;
|
|
5
|
+
export function poll(read, done, options) {
|
|
6
|
+
return pollUntil(read, done, options, (timeoutMs, last) => new TimeoutError(timeoutMs, last));
|
|
7
|
+
}
|
|
5
8
|
/**
|
|
6
9
|
* Reads until `done` returns true. `done` throws to end the wait with a failure.
|
|
7
10
|
* Transient read failures are retried with backoff until the deadline.
|
|
8
11
|
*/
|
|
9
|
-
export async function
|
|
12
|
+
export async function pollUntil(read, done, options = {}, timeout) {
|
|
10
13
|
const { signal } = options;
|
|
11
14
|
const timeoutMs = options.timeoutMs ?? defaultTimeoutMs;
|
|
12
15
|
if (!(timeoutMs >= 0)) {
|
|
@@ -18,20 +21,20 @@ export async function poll(read, done, options = {}) {
|
|
|
18
21
|
signal?.throwIfAborted();
|
|
19
22
|
const remaining = deadline - Date.now();
|
|
20
23
|
if (remaining <= 0) {
|
|
21
|
-
throw
|
|
24
|
+
throw timeout(timeoutMs, last);
|
|
22
25
|
}
|
|
23
26
|
let waitMs = backoff(attempt);
|
|
24
|
-
let
|
|
27
|
+
let value = null;
|
|
25
28
|
const link = linkSignal(signal, Math.min(readTimeoutMs, remaining));
|
|
26
29
|
try {
|
|
27
|
-
|
|
28
|
-
last =
|
|
30
|
+
value = await read(link.signal);
|
|
31
|
+
last = value;
|
|
29
32
|
}
|
|
30
33
|
catch (error) {
|
|
31
34
|
// Classify by signal state: a stalled body read surfaces as an arbitrary error.
|
|
32
35
|
signal?.throwIfAborted();
|
|
33
36
|
if (Date.now() >= deadline) {
|
|
34
|
-
throw
|
|
37
|
+
throw timeout(timeoutMs, last);
|
|
35
38
|
}
|
|
36
39
|
if (!link.signal.aborted) {
|
|
37
40
|
const failure = toStateMachinesError(error);
|
|
@@ -47,10 +50,10 @@ export async function poll(read, done, options = {}) {
|
|
|
47
50
|
// A read can settle after an abort or past the deadline; neither may resolve the wait.
|
|
48
51
|
signal?.throwIfAborted();
|
|
49
52
|
if (Date.now() >= deadline) {
|
|
50
|
-
throw
|
|
53
|
+
throw timeout(timeoutMs, last);
|
|
51
54
|
}
|
|
52
|
-
if (
|
|
53
|
-
return
|
|
55
|
+
if (value !== null && done(value)) {
|
|
56
|
+
return value;
|
|
54
57
|
}
|
|
55
58
|
await sleep(Math.min(waitMs, deadline - Date.now()), signal);
|
|
56
59
|
}
|
|
@@ -79,11 +82,18 @@ export function disposed(environment) {
|
|
|
79
82
|
}
|
|
80
83
|
return environment.apps.every((app) => app.disposal === 'complete');
|
|
81
84
|
}
|
|
85
|
+
/** Resolves on `ready`. A failed or deleted snapshot ends the wait. */
|
|
86
|
+
export function snapshotReady(snapshot) {
|
|
87
|
+
if (snapshot.status === 'failed' || snapshot.deletedAt) {
|
|
88
|
+
throw new SnapshotFailedError(snapshot);
|
|
89
|
+
}
|
|
90
|
+
return snapshot.status === 'ready';
|
|
91
|
+
}
|
|
82
92
|
/** 1 s × 1.5ⁿ, capped at 5 s, with ±20% jitter. */
|
|
83
|
-
function backoff(attempt) {
|
|
93
|
+
export function backoff(attempt) {
|
|
84
94
|
return Math.min(5000, 1000 * 1.5 ** attempt) * (0.8 + Math.random() * 0.4);
|
|
85
95
|
}
|
|
86
|
-
function sleep(ms, signal) {
|
|
96
|
+
export function sleep(ms, signal) {
|
|
87
97
|
return new Promise((resolve, reject) => {
|
|
88
98
|
if (signal?.aborted) {
|
|
89
99
|
reject(signal.reason);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StateMachinesCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/http-client-errors.js";
|
|
4
|
+
import * as errors from "../models/errors/index.js";
|
|
5
|
+
import { ResponseValidationError } from "../models/errors/response-validation-error.js";
|
|
6
|
+
import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
|
|
7
|
+
import { StateMachinesHTTPError } from "../models/errors/state-machines-http-error.js";
|
|
8
|
+
import * as operations from "../models/operations/index.js";
|
|
9
|
+
import { APIPromise } from "../types/async.js";
|
|
10
|
+
import { Result } from "../types/fp.js";
|
|
11
|
+
export declare function createEnvironmentDefinition(client: StateMachinesCore, request: operations.CreateEnvironmentDefinitionRequest, options?: RequestOptions): APIPromise<Result<operations.CreateEnvironmentDefinitionResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
6
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as operations from "../models/operations/index.js";
|
|
14
|
+
import { APIPromise } from "../types/async.js";
|
|
15
|
+
export function createEnvironmentDefinition(client, request, options) {
|
|
16
|
+
return new APIPromise($do(client, request, options));
|
|
17
|
+
}
|
|
18
|
+
async function $do(client, request, options) {
|
|
19
|
+
const parsed = safeParse(request, (value) => z.parse(operations.CreateEnvironmentDefinitionRequest$outboundSchema, value), "Input validation failed");
|
|
20
|
+
if (!parsed.ok) {
|
|
21
|
+
return [parsed, { status: "invalid" }];
|
|
22
|
+
}
|
|
23
|
+
const payload = parsed.value;
|
|
24
|
+
const body = encodeJSON("body", payload.body, { explode: true });
|
|
25
|
+
const pathParams = {
|
|
26
|
+
workspaceId: encodeSimple("workspaceId", payload.workspaceId, {
|
|
27
|
+
explode: false,
|
|
28
|
+
charEncoding: "percent",
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
const path = pathToFunc("/v1/workspaces/{workspaceId}/environment-definitions")(pathParams);
|
|
32
|
+
const headers = new Headers(compactMap({
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
Accept: "application/json",
|
|
35
|
+
"idempotency-key": encodeSimple("idempotency-key", payload["idempotency-key"], { explode: false, charEncoding: "none" }),
|
|
36
|
+
}));
|
|
37
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
38
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
39
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
40
|
+
const context = {
|
|
41
|
+
options: client._options,
|
|
42
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
43
|
+
operationID: "createEnvironmentDefinition",
|
|
44
|
+
oAuth2Scopes: null,
|
|
45
|
+
resolvedSecurity: requestSecurity,
|
|
46
|
+
securitySource: client._options.apiKey,
|
|
47
|
+
retryConfig: options?.retries
|
|
48
|
+
|| client._options.retryConfig
|
|
49
|
+
|| {
|
|
50
|
+
strategy: "backoff",
|
|
51
|
+
backoff: {
|
|
52
|
+
initialInterval: 1000,
|
|
53
|
+
maxInterval: 5000,
|
|
54
|
+
exponent: 1.5,
|
|
55
|
+
maxElapsedTime: 600000,
|
|
56
|
+
},
|
|
57
|
+
retryConnectionErrors: true,
|
|
58
|
+
}
|
|
59
|
+
|| { strategy: "none" },
|
|
60
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
61
|
+
};
|
|
62
|
+
const requestRes = client._createRequest(context, {
|
|
63
|
+
security: requestSecurity,
|
|
64
|
+
method: "POST",
|
|
65
|
+
baseURL: options?.serverURL,
|
|
66
|
+
path: path,
|
|
67
|
+
headers: headers,
|
|
68
|
+
body: body,
|
|
69
|
+
userAgent: client._options.userAgent,
|
|
70
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
71
|
+
}, options);
|
|
72
|
+
if (!requestRes.ok) {
|
|
73
|
+
return [requestRes, { status: "invalid" }];
|
|
74
|
+
}
|
|
75
|
+
const req = requestRes.value;
|
|
76
|
+
const doResult = await client._do(req, {
|
|
77
|
+
context,
|
|
78
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
79
|
+
retryConfig: context.retryConfig,
|
|
80
|
+
retryCodes: context.retryCodes,
|
|
81
|
+
});
|
|
82
|
+
if (!doResult.ok) {
|
|
83
|
+
return [doResult, { status: "request-error", request: req }];
|
|
84
|
+
}
|
|
85
|
+
const response = doResult.value;
|
|
86
|
+
const responseFields = {
|
|
87
|
+
HttpMeta: { Response: response, Request: req },
|
|
88
|
+
};
|
|
89
|
+
const [result] = await M.match(M.json(202, operations.CreateEnvironmentDefinitionResponse$inboundSchema), M.jsonErr([400, 401, 403, 404, 409, 413, 422, 429], errors.ErrorResponse$inboundSchema), M.jsonErr([500, 503], errors.ErrorResponse$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
90
|
+
if (!result.ok) {
|
|
91
|
+
return [result, { status: "complete", request: req, response }];
|
|
92
|
+
}
|
|
93
|
+
return [result, { status: "complete", request: req, response }];
|
|
94
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StateMachinesCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/http-client-errors.js";
|
|
4
|
+
import * as errors from "../models/errors/index.js";
|
|
5
|
+
import { ResponseValidationError } from "../models/errors/response-validation-error.js";
|
|
6
|
+
import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
|
|
7
|
+
import { StateMachinesHTTPError } from "../models/errors/state-machines-http-error.js";
|
|
8
|
+
import * as operations from "../models/operations/index.js";
|
|
9
|
+
import { APIPromise } from "../types/async.js";
|
|
10
|
+
import { Result } from "../types/fp.js";
|
|
11
|
+
export declare function snapshotsCapture(client: StateMachinesCore, request: operations.CaptureSnapshotRequest, options?: RequestOptions): APIPromise<Result<operations.CaptureSnapshotResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
6
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as operations from "../models/operations/index.js";
|
|
14
|
+
import { APIPromise } from "../types/async.js";
|
|
15
|
+
export function snapshotsCapture(client, request, options) {
|
|
16
|
+
return new APIPromise($do(client, request, options));
|
|
17
|
+
}
|
|
18
|
+
async function $do(client, request, options) {
|
|
19
|
+
const parsed = safeParse(request, (value) => z.parse(operations.CaptureSnapshotRequest$outboundSchema, value), "Input validation failed");
|
|
20
|
+
if (!parsed.ok) {
|
|
21
|
+
return [parsed, { status: "invalid" }];
|
|
22
|
+
}
|
|
23
|
+
const payload = parsed.value;
|
|
24
|
+
const body = encodeJSON("body", payload.body, { explode: true });
|
|
25
|
+
const pathParams = {
|
|
26
|
+
workspaceId: encodeSimple("workspaceId", payload.workspaceId, {
|
|
27
|
+
explode: false,
|
|
28
|
+
charEncoding: "percent",
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
const path = pathToFunc("/v1/workspaces/{workspaceId}/snapshots")(pathParams);
|
|
32
|
+
const headers = new Headers(compactMap({
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
Accept: "application/json",
|
|
35
|
+
"idempotency-key": encodeSimple("idempotency-key", payload["idempotency-key"], { explode: false, charEncoding: "none" }),
|
|
36
|
+
}));
|
|
37
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
38
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
39
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
40
|
+
const context = {
|
|
41
|
+
options: client._options,
|
|
42
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
43
|
+
operationID: "captureSnapshot",
|
|
44
|
+
oAuth2Scopes: null,
|
|
45
|
+
resolvedSecurity: requestSecurity,
|
|
46
|
+
securitySource: client._options.apiKey,
|
|
47
|
+
retryConfig: options?.retries
|
|
48
|
+
|| client._options.retryConfig
|
|
49
|
+
|| {
|
|
50
|
+
strategy: "backoff",
|
|
51
|
+
backoff: {
|
|
52
|
+
initialInterval: 1000,
|
|
53
|
+
maxInterval: 5000,
|
|
54
|
+
exponent: 1.5,
|
|
55
|
+
maxElapsedTime: 600000,
|
|
56
|
+
},
|
|
57
|
+
retryConnectionErrors: true,
|
|
58
|
+
}
|
|
59
|
+
|| { strategy: "none" },
|
|
60
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
61
|
+
};
|
|
62
|
+
const requestRes = client._createRequest(context, {
|
|
63
|
+
security: requestSecurity,
|
|
64
|
+
method: "POST",
|
|
65
|
+
baseURL: options?.serverURL,
|
|
66
|
+
path: path,
|
|
67
|
+
headers: headers,
|
|
68
|
+
body: body,
|
|
69
|
+
userAgent: client._options.userAgent,
|
|
70
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
71
|
+
}, options);
|
|
72
|
+
if (!requestRes.ok) {
|
|
73
|
+
return [requestRes, { status: "invalid" }];
|
|
74
|
+
}
|
|
75
|
+
const req = requestRes.value;
|
|
76
|
+
const doResult = await client._do(req, {
|
|
77
|
+
context,
|
|
78
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
79
|
+
retryConfig: context.retryConfig,
|
|
80
|
+
retryCodes: context.retryCodes,
|
|
81
|
+
});
|
|
82
|
+
if (!doResult.ok) {
|
|
83
|
+
return [doResult, { status: "request-error", request: req }];
|
|
84
|
+
}
|
|
85
|
+
const response = doResult.value;
|
|
86
|
+
const responseFields = {
|
|
87
|
+
HttpMeta: { Response: response, Request: req },
|
|
88
|
+
};
|
|
89
|
+
const [result] = await M.match(M.json(202, operations.CaptureSnapshotResponse$inboundSchema), M.jsonErr([400, 401, 403, 404, 409, 413, 422, 429], errors.ErrorResponse$inboundSchema), M.jsonErr([500, 503], errors.ErrorResponse$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
90
|
+
if (!result.ok) {
|
|
91
|
+
return [result, { status: "complete", request: req, response }];
|
|
92
|
+
}
|
|
93
|
+
return [result, { status: "complete", request: req, response }];
|
|
94
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StateMachinesCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/http-client-errors.js";
|
|
4
|
+
import * as errors from "../models/errors/index.js";
|
|
5
|
+
import { ResponseValidationError } from "../models/errors/response-validation-error.js";
|
|
6
|
+
import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
|
|
7
|
+
import { StateMachinesHTTPError } from "../models/errors/state-machines-http-error.js";
|
|
8
|
+
import * as operations from "../models/operations/index.js";
|
|
9
|
+
import { APIPromise } from "../types/async.js";
|
|
10
|
+
import { Result } from "../types/fp.js";
|
|
11
|
+
export declare function snapshotsDelete(client: StateMachinesCore, request: operations.DeleteSnapshotRequest, options?: RequestOptions): APIPromise<Result<operations.DeleteSnapshotResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
6
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as operations from "../models/operations/index.js";
|
|
14
|
+
import { APIPromise } from "../types/async.js";
|
|
15
|
+
export function snapshotsDelete(client, request, options) {
|
|
16
|
+
return new APIPromise($do(client, request, options));
|
|
17
|
+
}
|
|
18
|
+
async function $do(client, request, options) {
|
|
19
|
+
const parsed = safeParse(request, (value) => z.parse(operations.DeleteSnapshotRequest$outboundSchema, value), "Input validation failed");
|
|
20
|
+
if (!parsed.ok) {
|
|
21
|
+
return [parsed, { status: "invalid" }];
|
|
22
|
+
}
|
|
23
|
+
const payload = parsed.value;
|
|
24
|
+
const body = null;
|
|
25
|
+
const pathParams = {
|
|
26
|
+
snapshotId: encodeSimple("snapshotId", payload.snapshotId, {
|
|
27
|
+
explode: false,
|
|
28
|
+
charEncoding: "percent",
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
const path = pathToFunc("/v1/snapshots/{snapshotId}")(pathParams);
|
|
32
|
+
const headers = new Headers(compactMap({
|
|
33
|
+
Accept: "application/json",
|
|
34
|
+
}));
|
|
35
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
36
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
37
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
38
|
+
const context = {
|
|
39
|
+
options: client._options,
|
|
40
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
41
|
+
operationID: "deleteSnapshot",
|
|
42
|
+
oAuth2Scopes: null,
|
|
43
|
+
resolvedSecurity: requestSecurity,
|
|
44
|
+
securitySource: client._options.apiKey,
|
|
45
|
+
retryConfig: options?.retries
|
|
46
|
+
|| client._options.retryConfig
|
|
47
|
+
|| {
|
|
48
|
+
strategy: "backoff",
|
|
49
|
+
backoff: {
|
|
50
|
+
initialInterval: 1000,
|
|
51
|
+
maxInterval: 5000,
|
|
52
|
+
exponent: 1.5,
|
|
53
|
+
maxElapsedTime: 600000,
|
|
54
|
+
},
|
|
55
|
+
retryConnectionErrors: true,
|
|
56
|
+
}
|
|
57
|
+
|| { strategy: "none" },
|
|
58
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
59
|
+
};
|
|
60
|
+
const requestRes = client._createRequest(context, {
|
|
61
|
+
security: requestSecurity,
|
|
62
|
+
method: "DELETE",
|
|
63
|
+
baseURL: options?.serverURL,
|
|
64
|
+
path: path,
|
|
65
|
+
headers: headers,
|
|
66
|
+
body: body,
|
|
67
|
+
userAgent: client._options.userAgent,
|
|
68
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
69
|
+
}, options);
|
|
70
|
+
if (!requestRes.ok) {
|
|
71
|
+
return [requestRes, { status: "invalid" }];
|
|
72
|
+
}
|
|
73
|
+
const req = requestRes.value;
|
|
74
|
+
const doResult = await client._do(req, {
|
|
75
|
+
context,
|
|
76
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
77
|
+
retryConfig: context.retryConfig,
|
|
78
|
+
retryCodes: context.retryCodes,
|
|
79
|
+
});
|
|
80
|
+
if (!doResult.ok) {
|
|
81
|
+
return [doResult, { status: "request-error", request: req }];
|
|
82
|
+
}
|
|
83
|
+
const response = doResult.value;
|
|
84
|
+
const responseFields = {
|
|
85
|
+
HttpMeta: { Response: response, Request: req },
|
|
86
|
+
};
|
|
87
|
+
const [result] = await M.match(M.json(200, operations.DeleteSnapshotResponse$inboundSchema), M.jsonErr([400, 401, 403, 404, 409, 413, 422, 429], errors.ErrorResponse$inboundSchema), M.jsonErr([500, 503], errors.ErrorResponse$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
|
|
88
|
+
if (!result.ok) {
|
|
89
|
+
return [result, { status: "complete", request: req, response }];
|
|
90
|
+
}
|
|
91
|
+
return [result, { status: "complete", request: req, response }];
|
|
92
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StateMachinesCore } from "../core.js";
|
|
2
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
3
|
+
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/http-client-errors.js";
|
|
4
|
+
import * as errors from "../models/errors/index.js";
|
|
5
|
+
import { ResponseValidationError } from "../models/errors/response-validation-error.js";
|
|
6
|
+
import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
|
|
7
|
+
import { StateMachinesHTTPError } from "../models/errors/state-machines-http-error.js";
|
|
8
|
+
import * as operations from "../models/operations/index.js";
|
|
9
|
+
import { APIPromise } from "../types/async.js";
|
|
10
|
+
import { Result } from "../types/fp.js";
|
|
11
|
+
export declare function snapshotsGet(client: StateMachinesCore, request: operations.GetSnapshotRequest, options?: RequestOptions): APIPromise<Result<operations.GetSnapshotResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|