@usestatemachines/sdk 0.2.0 → 0.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/README.md +158 -18
- package/agents/SKILL.md +18 -8
- package/agents/index.js +6 -6
- package/agents/llms.txt +22 -9
- package/agents/prompt.md +2 -2
- package/esm/extensions/apps.d.ts +11 -1
- package/esm/extensions/apps.js +16 -0
- package/esm/extensions/client.d.ts +47 -4
- package/esm/extensions/client.js +107 -12
- package/esm/extensions/errors.d.ts +26 -1
- package/esm/extensions/errors.js +34 -1
- package/esm/extensions/index.d.ts +4 -4
- package/esm/extensions/index.js +1 -1
- package/esm/extensions/running-environment.d.ts +20 -3
- package/esm/extensions/running-environment.js +33 -2
- package/esm/extensions/wait.d.ts +13 -4
- package/esm/extensions/wait.js +38 -13
- package/esm/funcs/environments-list.js +1 -0
- package/esm/funcs/environments-resume.d.ts +11 -0
- package/esm/funcs/environments-resume.js +92 -0
- package/esm/funcs/environments-suspend.d.ts +11 -0
- package/esm/funcs/environments-suspend.js +92 -0
- package/esm/funcs/get-environment-exchange.d.ts +11 -0
- package/esm/funcs/get-environment-exchange.js +96 -0
- package/esm/funcs/get-environment-position.d.ts +11 -0
- package/esm/funcs/get-environment-position.js +92 -0
- package/esm/funcs/list-environment-history.d.ts +11 -0
- package/esm/funcs/list-environment-history.js +97 -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/create-environment-input.d.ts +6 -2
- package/esm/models/create-environment-input.js +3 -1
- package/esm/models/environment-app.d.ts +11 -0
- package/esm/models/environment-app.js +13 -0
- package/esm/models/environment-exchange.d.ts +116 -0
- package/esm/models/environment-exchange.js +126 -0
- package/esm/models/environment-position.d.ts +25 -0
- package/esm/models/environment-position.js +32 -0
- package/esm/models/environment-snapshot.d.ts +40 -0
- package/esm/models/environment-snapshot.js +42 -0
- package/esm/models/environment.d.ts +5 -0
- package/esm/models/environment.js +5 -0
- package/esm/models/error-response.d.ts +9 -0
- package/esm/models/error-response.js +9 -0
- package/esm/models/history-body.d.ts +28 -0
- package/esm/models/history-body.js +33 -0
- package/esm/models/history-cause.d.ts +48 -0
- package/esm/models/history-cause.js +63 -0
- package/esm/models/history-position.d.ts +11 -0
- package/esm/models/history-position.js +15 -0
- package/esm/models/history-transaction.d.ts +16 -0
- package/esm/models/history-transaction.js +20 -0
- package/esm/models/index.d.ts +8 -0
- package/esm/models/index.js +8 -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 +92 -10
- package/esm/models/operations/create-environment-definition.js +63 -4
- package/esm/models/operations/delete-snapshot.d.ts +23 -0
- package/esm/models/operations/delete-snapshot.js +20 -0
- package/esm/models/operations/get-environment-exchange.d.ts +25 -0
- package/esm/models/operations/get-environment-exchange.js +21 -0
- package/esm/models/operations/get-environment-position.d.ts +23 -0
- package/esm/models/operations/get-environment-position.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 +10 -0
- package/esm/models/operations/index.js +10 -0
- package/esm/models/operations/list-environment-history.d.ts +28 -0
- package/esm/models/operations/list-environment-history.js +24 -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/resume-environment.d.ts +23 -0
- package/esm/models/operations/resume-environment.js +20 -0
- package/esm/models/operations/stop-environment.d.ts +1 -1
- package/esm/models/operations/suspend-environment.d.ts +23 -0
- package/esm/models/operations/suspend-environment.js +20 -0
- package/esm/models/operations/update-snapshot.d.ts +37 -0
- package/esm/models/operations/update-snapshot.js +29 -0
- package/esm/models/release.d.ts +11 -0
- package/esm/models/release.js +10 -0
- package/esm/sdk/environments.d.ts +2 -0
- package/esm/sdk/environments.js +8 -0
- package/esm/sdk/sdk.d.ts +6 -0
- package/esm/sdk/sdk.js +17 -0
- package/esm/sdk/snapshots.d.ts +9 -0
- package/esm/sdk/snapshots.js +27 -0
- package/esm/types/discriminated-union.d.ts +24 -0
- package/esm/types/discriminated-union.js +60 -0
- package/esm/types/smart-union.js +2 -1
- package/openapi.json +2473 -242
- package/package.json +11 -11
package/esm/extensions/wait.d.ts
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
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;
|
|
10
11
|
export declare const defaultTimeoutMs = 600000;
|
|
12
|
+
export declare function poll(read: Read<Environment>, done: Decide<Environment>, options?: WaitOptions): Promise<Environment>;
|
|
11
13
|
/**
|
|
12
14
|
* Reads until `done` returns true. `done` throws to end the wait with a failure.
|
|
13
15
|
* Transient read failures are retried with backoff until the deadline.
|
|
14
16
|
*/
|
|
15
|
-
export declare function
|
|
16
|
-
/** Resolves on `running`. Never stops the environment. */
|
|
17
|
+
export declare function pollUntil<T>(read: Read<T>, done: Decide<T>, options: WaitOptions | undefined, timeout: (timeoutMs: number, last: T | null) => Error): Promise<T>;
|
|
18
|
+
/** Resolves on `running`. Never suspends or stops the environment. */
|
|
17
19
|
export declare function ready(environment: Environment): boolean;
|
|
20
|
+
/** Resolves on `suspended`, when the environment can resume. */
|
|
21
|
+
export declare function suspended(environment: Environment): boolean;
|
|
18
22
|
/** Resolves once the environment ended and every app's sandbox is confirmed disposed. */
|
|
19
23
|
export declare function disposed(environment: Environment): boolean;
|
|
24
|
+
/** Resolves on `ready`. A failed or deleted snapshot ends the wait. */
|
|
25
|
+
export declare function snapshotReady(snapshot: EnvironmentSnapshot): boolean;
|
|
26
|
+
/** 1 s × 1.5ⁿ, capped at 5 s, with ±20% jitter. */
|
|
27
|
+
export declare function backoff(attempt: number): number;
|
|
28
|
+
export declare function sleep(ms: number, signal: AbortSignal | null | undefined): Promise<void>;
|
|
20
29
|
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
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,20 +50,35 @@ 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
|
}
|
|
57
60
|
}
|
|
58
|
-
/** Resolves on `running`. Never stops the environment. */
|
|
61
|
+
/** Resolves on `running`. Never suspends or stops the environment. */
|
|
59
62
|
export function ready(environment) {
|
|
60
63
|
switch (environment.status) {
|
|
61
64
|
case 'running':
|
|
62
65
|
return true;
|
|
63
66
|
case 'failed':
|
|
67
|
+
case 'suspending':
|
|
68
|
+
case 'suspended':
|
|
69
|
+
case 'stopping':
|
|
70
|
+
case 'stopped':
|
|
71
|
+
throw new EnvironmentFailedError(environment);
|
|
72
|
+
default:
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Resolves on `suspended`, when the environment can resume. */
|
|
77
|
+
export function suspended(environment) {
|
|
78
|
+
switch (environment.status) {
|
|
79
|
+
case 'suspended':
|
|
80
|
+
return true;
|
|
81
|
+
case 'failed':
|
|
64
82
|
case 'stopping':
|
|
65
83
|
case 'stopped':
|
|
66
84
|
throw new EnvironmentFailedError(environment);
|
|
@@ -79,11 +97,18 @@ export function disposed(environment) {
|
|
|
79
97
|
}
|
|
80
98
|
return environment.apps.every((app) => app.disposal === 'complete');
|
|
81
99
|
}
|
|
100
|
+
/** Resolves on `ready`. A failed or deleted snapshot ends the wait. */
|
|
101
|
+
export function snapshotReady(snapshot) {
|
|
102
|
+
if (snapshot.status === 'failed' || snapshot.deletedAt) {
|
|
103
|
+
throw new SnapshotFailedError(snapshot);
|
|
104
|
+
}
|
|
105
|
+
return snapshot.status === 'ready';
|
|
106
|
+
}
|
|
82
107
|
/** 1 s × 1.5ⁿ, capped at 5 s, with ±20% jitter. */
|
|
83
|
-
function backoff(attempt) {
|
|
108
|
+
export function backoff(attempt) {
|
|
84
109
|
return Math.min(5000, 1000 * 1.5 ** attempt) * (0.8 + Math.random() * 0.4);
|
|
85
110
|
}
|
|
86
|
-
function sleep(ms, signal) {
|
|
111
|
+
export function sleep(ms, signal) {
|
|
87
112
|
return new Promise((resolve, reject) => {
|
|
88
113
|
if (signal?.aborted) {
|
|
89
114
|
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 environmentsResume(client: StateMachinesCore, request: operations.ResumeEnvironmentRequest, options?: RequestOptions): APIPromise<Result<operations.ResumeEnvironmentResponse, 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 environmentsResume(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.ResumeEnvironmentRequest$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
|
+
environmentId: encodeSimple("environmentId", payload.environmentId, {
|
|
27
|
+
explode: false,
|
|
28
|
+
charEncoding: "percent",
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
const path = pathToFunc("/v1/environments/{environmentId}/resume")(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: "resumeEnvironment",
|
|
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: "POST",
|
|
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.ResumeEnvironmentResponse$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 environmentsSuspend(client: StateMachinesCore, request: operations.SuspendEnvironmentRequest, options?: RequestOptions): APIPromise<Result<operations.SuspendEnvironmentResponse, 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 environmentsSuspend(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.SuspendEnvironmentRequest$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
|
+
environmentId: encodeSimple("environmentId", payload.environmentId, {
|
|
27
|
+
explode: false,
|
|
28
|
+
charEncoding: "percent",
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
const path = pathToFunc("/v1/environments/{environmentId}/suspend")(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: "suspendEnvironment",
|
|
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: "POST",
|
|
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.SuspendEnvironmentResponse$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 getEnvironmentExchange(client: StateMachinesCore, request: operations.GetEnvironmentExchangeRequest, options?: RequestOptions): APIPromise<Result<operations.GetEnvironmentExchangeResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,96 @@
|
|
|
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 getEnvironmentExchange(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.GetEnvironmentExchangeRequest$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
|
+
environmentId: encodeSimple("environmentId", payload.environmentId, {
|
|
27
|
+
explode: false,
|
|
28
|
+
charEncoding: "percent",
|
|
29
|
+
}),
|
|
30
|
+
exchangeId: encodeSimple("exchangeId", payload.exchangeId, {
|
|
31
|
+
explode: false,
|
|
32
|
+
charEncoding: "percent",
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
const path = pathToFunc("/v1/environments/{environmentId}/history/{exchangeId}")(pathParams);
|
|
36
|
+
const headers = new Headers(compactMap({
|
|
37
|
+
Accept: "application/json",
|
|
38
|
+
}));
|
|
39
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
40
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
41
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
42
|
+
const context = {
|
|
43
|
+
options: client._options,
|
|
44
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
45
|
+
operationID: "getEnvironmentExchange",
|
|
46
|
+
oAuth2Scopes: null,
|
|
47
|
+
resolvedSecurity: requestSecurity,
|
|
48
|
+
securitySource: client._options.apiKey,
|
|
49
|
+
retryConfig: options?.retries
|
|
50
|
+
|| client._options.retryConfig
|
|
51
|
+
|| {
|
|
52
|
+
strategy: "backoff",
|
|
53
|
+
backoff: {
|
|
54
|
+
initialInterval: 1000,
|
|
55
|
+
maxInterval: 5000,
|
|
56
|
+
exponent: 1.5,
|
|
57
|
+
maxElapsedTime: 600000,
|
|
58
|
+
},
|
|
59
|
+
retryConnectionErrors: true,
|
|
60
|
+
}
|
|
61
|
+
|| { strategy: "none" },
|
|
62
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
63
|
+
};
|
|
64
|
+
const requestRes = client._createRequest(context, {
|
|
65
|
+
security: requestSecurity,
|
|
66
|
+
method: "GET",
|
|
67
|
+
baseURL: options?.serverURL,
|
|
68
|
+
path: path,
|
|
69
|
+
headers: headers,
|
|
70
|
+
body: body,
|
|
71
|
+
userAgent: client._options.userAgent,
|
|
72
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
73
|
+
}, options);
|
|
74
|
+
if (!requestRes.ok) {
|
|
75
|
+
return [requestRes, { status: "invalid" }];
|
|
76
|
+
}
|
|
77
|
+
const req = requestRes.value;
|
|
78
|
+
const doResult = await client._do(req, {
|
|
79
|
+
context,
|
|
80
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
81
|
+
retryConfig: context.retryConfig,
|
|
82
|
+
retryCodes: context.retryCodes,
|
|
83
|
+
});
|
|
84
|
+
if (!doResult.ok) {
|
|
85
|
+
return [doResult, { status: "request-error", request: req }];
|
|
86
|
+
}
|
|
87
|
+
const response = doResult.value;
|
|
88
|
+
const responseFields = {
|
|
89
|
+
HttpMeta: { Response: response, Request: req },
|
|
90
|
+
};
|
|
91
|
+
const [result] = await M.match(M.json(200, operations.GetEnvironmentExchangeResponse$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 });
|
|
92
|
+
if (!result.ok) {
|
|
93
|
+
return [result, { status: "complete", request: req, response }];
|
|
94
|
+
}
|
|
95
|
+
return [result, { status: "complete", request: req, response }];
|
|
96
|
+
}
|
|
@@ -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 getEnvironmentPosition(client: StateMachinesCore, request: operations.GetEnvironmentPositionRequest, options?: RequestOptions): APIPromise<Result<operations.GetEnvironmentPositionResponse, 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 getEnvironmentPosition(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.GetEnvironmentPositionRequest$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
|
+
environmentId: encodeSimple("environmentId", payload.environmentId, {
|
|
27
|
+
explode: false,
|
|
28
|
+
charEncoding: "percent",
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
const path = pathToFunc("/v1/environments/{environmentId}/history/position")(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: "getEnvironmentPosition",
|
|
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: "GET",
|
|
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.GetEnvironmentPositionResponse$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 listEnvironmentHistory(client: StateMachinesCore, request: operations.ListEnvironmentHistoryRequest, options?: RequestOptions): APIPromise<Result<operations.ListEnvironmentHistoryResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|