@usestatemachines/sdk 0.3.0 → 0.5.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 +122 -19
- package/agents/SKILL.md +10 -7
- package/agents/index.js +6 -6
- package/agents/llms.txt +19 -11
- package/agents/prompt.md +1 -1
- package/esm/extensions/client.d.ts +24 -2
- package/esm/extensions/client.js +26 -3
- package/esm/extensions/index.d.ts +2 -2
- package/esm/extensions/running-environment.d.ts +18 -4
- package/esm/extensions/running-environment.js +24 -2
- package/esm/extensions/wait.d.ts +3 -1
- package/esm/extensions/wait.js +17 -2
- package/esm/funcs/environments-get-request-payload.d.ts +11 -0
- package/esm/funcs/environments-get-request-payload.js +100 -0
- package/esm/funcs/environments-get-request-stats.d.ts +11 -0
- package/esm/funcs/environments-get-request-stats.js +103 -0
- package/esm/funcs/environments-get-request.d.ts +11 -0
- package/esm/funcs/environments-get-request.js +96 -0
- package/esm/funcs/environments-list-requests.d.ts +11 -0
- package/esm/funcs/environments-list-requests.js +105 -0
- package/esm/funcs/environments-resume.d.ts +11 -0
- package/esm/funcs/environments-resume.js +93 -0
- package/esm/funcs/environments-stop.js +1 -0
- package/esm/funcs/environments-suspend.d.ts +11 -0
- package/esm/funcs/environments-suspend.js +93 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/environment-app.d.ts +2 -0
- package/esm/models/environment-app.js +2 -0
- package/esm/models/environment-request-detail.d.ts +40 -0
- package/esm/models/environment-request-detail.js +39 -0
- package/esm/models/environment-request-stats.d.ts +26 -0
- package/esm/models/environment-request-stats.js +31 -0
- package/esm/models/environment-request.d.ts +31 -0
- package/esm/models/environment-request.js +34 -0
- package/esm/models/environment-snapshot.d.ts +3 -2
- package/esm/models/environment-snapshot.js +3 -2
- package/esm/models/environment.d.ts +4 -0
- package/esm/models/environment.js +4 -0
- package/esm/models/error-response.d.ts +7 -0
- package/esm/models/error-response.js +7 -0
- package/esm/models/index.d.ts +4 -0
- package/esm/models/index.js +4 -0
- package/esm/models/operations/create-environment-definition.d.ts +10 -0
- package/esm/models/operations/create-environment-definition.js +3 -0
- package/esm/models/operations/get-environment-request-payload.d.ts +23 -0
- package/esm/models/operations/get-environment-request-payload.js +19 -0
- package/esm/models/operations/get-environment-request-stats.d.ts +70 -0
- package/esm/models/operations/get-environment-request-stats.js +55 -0
- package/esm/models/operations/get-environment-request.d.ts +25 -0
- package/esm/models/operations/get-environment-request.js +21 -0
- package/esm/models/operations/index.d.ts +6 -0
- package/esm/models/operations/index.js +6 -0
- package/esm/models/operations/list-environment-requests.d.ts +75 -0
- package/esm/models/operations/list-environment-requests.js +59 -0
- package/esm/models/operations/resume-environment.d.ts +25 -0
- package/esm/models/operations/resume-environment.js +26 -0
- package/esm/models/operations/stop-environment.d.ts +3 -1
- package/esm/models/operations/stop-environment.js +8 -2
- package/esm/models/operations/suspend-environment.d.ts +25 -0
- package/esm/models/operations/suspend-environment.js +26 -0
- package/esm/models/release.d.ts +11 -0
- package/esm/models/release.js +10 -0
- package/esm/models/request-payload-preview.d.ts +31 -0
- package/esm/models/request-payload-preview.js +33 -0
- package/esm/sdk/environments.d.ts +6 -0
- package/esm/sdk/environments.js +24 -0
- package/openapi.json +1380 -29
- package/package.json +4 -3
|
@@ -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 environmentsGetRequest(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.GetEnvironmentRequestRequest$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
|
+
requestId: encodeSimple("requestId", payload.requestId, {
|
|
31
|
+
explode: false,
|
|
32
|
+
charEncoding: "percent",
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
const path = pathToFunc("/v1/environments/{environmentId}/requests/{requestId}")(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: "getEnvironmentRequest",
|
|
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.GetEnvironmentRequestResponse$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 environmentsListRequests(client: StateMachinesCore, request: operations.ListEnvironmentRequestsRequest, options?: RequestOptions): APIPromise<Result<operations.ListEnvironmentRequestsResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { encodeFormQuery, 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 environmentsListRequests(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.ListEnvironmentRequestsRequest$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}/requests")(pathParams);
|
|
32
|
+
const query = encodeFormQuery({
|
|
33
|
+
"appKey": payload.appKey,
|
|
34
|
+
"cursor": payload.cursor,
|
|
35
|
+
"from": payload.from,
|
|
36
|
+
"limit": payload.limit,
|
|
37
|
+
"method": payload.method,
|
|
38
|
+
"search": payload.search,
|
|
39
|
+
"status": payload.status,
|
|
40
|
+
"statusClass": payload.statusClass,
|
|
41
|
+
"to": payload.to,
|
|
42
|
+
"writesOnly": payload.writesOnly,
|
|
43
|
+
});
|
|
44
|
+
const headers = new Headers(compactMap({
|
|
45
|
+
Accept: "application/json",
|
|
46
|
+
}));
|
|
47
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
48
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
49
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
50
|
+
const context = {
|
|
51
|
+
options: client._options,
|
|
52
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
53
|
+
operationID: "listEnvironmentRequests",
|
|
54
|
+
oAuth2Scopes: null,
|
|
55
|
+
resolvedSecurity: requestSecurity,
|
|
56
|
+
securitySource: client._options.apiKey,
|
|
57
|
+
retryConfig: options?.retries
|
|
58
|
+
|| client._options.retryConfig
|
|
59
|
+
|| {
|
|
60
|
+
strategy: "backoff",
|
|
61
|
+
backoff: {
|
|
62
|
+
initialInterval: 1000,
|
|
63
|
+
maxInterval: 5000,
|
|
64
|
+
exponent: 1.5,
|
|
65
|
+
maxElapsedTime: 600000,
|
|
66
|
+
},
|
|
67
|
+
retryConnectionErrors: true,
|
|
68
|
+
}
|
|
69
|
+
|| { strategy: "none" },
|
|
70
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
71
|
+
};
|
|
72
|
+
const requestRes = client._createRequest(context, {
|
|
73
|
+
security: requestSecurity,
|
|
74
|
+
method: "GET",
|
|
75
|
+
baseURL: options?.serverURL,
|
|
76
|
+
path: path,
|
|
77
|
+
headers: headers,
|
|
78
|
+
query: query,
|
|
79
|
+
body: body,
|
|
80
|
+
userAgent: client._options.userAgent,
|
|
81
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
82
|
+
}, options);
|
|
83
|
+
if (!requestRes.ok) {
|
|
84
|
+
return [requestRes, { status: "invalid" }];
|
|
85
|
+
}
|
|
86
|
+
const req = requestRes.value;
|
|
87
|
+
const doResult = await client._do(req, {
|
|
88
|
+
context,
|
|
89
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
90
|
+
retryConfig: context.retryConfig,
|
|
91
|
+
retryCodes: context.retryCodes,
|
|
92
|
+
});
|
|
93
|
+
if (!doResult.ok) {
|
|
94
|
+
return [doResult, { status: "request-error", request: req }];
|
|
95
|
+
}
|
|
96
|
+
const response = doResult.value;
|
|
97
|
+
const responseFields = {
|
|
98
|
+
HttpMeta: { Response: response, Request: req },
|
|
99
|
+
};
|
|
100
|
+
const [result] = await M.match(M.json(200, operations.ListEnvironmentRequestsResponse$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 });
|
|
101
|
+
if (!result.ok) {
|
|
102
|
+
return [result, { status: "complete", request: req, response }];
|
|
103
|
+
}
|
|
104
|
+
return [result, { status: "complete", request: req, response }];
|
|
105
|
+
}
|
|
@@ -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,93 @@
|
|
|
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
|
+
"idempotency-key": encodeSimple("idempotency-key", payload["idempotency-key"], { explode: false, charEncoding: "none" }),
|
|
35
|
+
}));
|
|
36
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
37
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
38
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
39
|
+
const context = {
|
|
40
|
+
options: client._options,
|
|
41
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
42
|
+
operationID: "resumeEnvironment",
|
|
43
|
+
oAuth2Scopes: null,
|
|
44
|
+
resolvedSecurity: requestSecurity,
|
|
45
|
+
securitySource: client._options.apiKey,
|
|
46
|
+
retryConfig: options?.retries
|
|
47
|
+
|| client._options.retryConfig
|
|
48
|
+
|| {
|
|
49
|
+
strategy: "backoff",
|
|
50
|
+
backoff: {
|
|
51
|
+
initialInterval: 1000,
|
|
52
|
+
maxInterval: 5000,
|
|
53
|
+
exponent: 1.5,
|
|
54
|
+
maxElapsedTime: 600000,
|
|
55
|
+
},
|
|
56
|
+
retryConnectionErrors: true,
|
|
57
|
+
}
|
|
58
|
+
|| { strategy: "none" },
|
|
59
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
60
|
+
};
|
|
61
|
+
const requestRes = client._createRequest(context, {
|
|
62
|
+
security: requestSecurity,
|
|
63
|
+
method: "POST",
|
|
64
|
+
baseURL: options?.serverURL,
|
|
65
|
+
path: path,
|
|
66
|
+
headers: headers,
|
|
67
|
+
body: body,
|
|
68
|
+
userAgent: client._options.userAgent,
|
|
69
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
70
|
+
}, options);
|
|
71
|
+
if (!requestRes.ok) {
|
|
72
|
+
return [requestRes, { status: "invalid" }];
|
|
73
|
+
}
|
|
74
|
+
const req = requestRes.value;
|
|
75
|
+
const doResult = await client._do(req, {
|
|
76
|
+
context,
|
|
77
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
78
|
+
retryConfig: context.retryConfig,
|
|
79
|
+
retryCodes: context.retryCodes,
|
|
80
|
+
});
|
|
81
|
+
if (!doResult.ok) {
|
|
82
|
+
return [doResult, { status: "request-error", request: req }];
|
|
83
|
+
}
|
|
84
|
+
const response = doResult.value;
|
|
85
|
+
const responseFields = {
|
|
86
|
+
HttpMeta: { Response: response, Request: req },
|
|
87
|
+
};
|
|
88
|
+
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 });
|
|
89
|
+
if (!result.ok) {
|
|
90
|
+
return [result, { status: "complete", request: req, response }];
|
|
91
|
+
}
|
|
92
|
+
return [result, { status: "complete", request: req, response }];
|
|
93
|
+
}
|
|
@@ -31,6 +31,7 @@ async function $do(client, request, options) {
|
|
|
31
31
|
const path = pathToFunc("/v1/environments/{environmentId}/stop")(pathParams);
|
|
32
32
|
const headers = new Headers(compactMap({
|
|
33
33
|
Accept: "application/json",
|
|
34
|
+
"idempotency-key": encodeSimple("idempotency-key", payload["idempotency-key"], { explode: false, charEncoding: "none" }),
|
|
34
35
|
}));
|
|
35
36
|
const secConfig = await extractSecurity(client._options.apiKey);
|
|
36
37
|
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
@@ -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,93 @@
|
|
|
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
|
+
"idempotency-key": encodeSimple("idempotency-key", payload["idempotency-key"], { explode: false, charEncoding: "none" }),
|
|
35
|
+
}));
|
|
36
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
37
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
38
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
39
|
+
const context = {
|
|
40
|
+
options: client._options,
|
|
41
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
42
|
+
operationID: "suspendEnvironment",
|
|
43
|
+
oAuth2Scopes: null,
|
|
44
|
+
resolvedSecurity: requestSecurity,
|
|
45
|
+
securitySource: client._options.apiKey,
|
|
46
|
+
retryConfig: options?.retries
|
|
47
|
+
|| client._options.retryConfig
|
|
48
|
+
|| {
|
|
49
|
+
strategy: "backoff",
|
|
50
|
+
backoff: {
|
|
51
|
+
initialInterval: 1000,
|
|
52
|
+
maxInterval: 5000,
|
|
53
|
+
exponent: 1.5,
|
|
54
|
+
maxElapsedTime: 600000,
|
|
55
|
+
},
|
|
56
|
+
retryConnectionErrors: true,
|
|
57
|
+
}
|
|
58
|
+
|| { strategy: "none" },
|
|
59
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
60
|
+
};
|
|
61
|
+
const requestRes = client._createRequest(context, {
|
|
62
|
+
security: requestSecurity,
|
|
63
|
+
method: "POST",
|
|
64
|
+
baseURL: options?.serverURL,
|
|
65
|
+
path: path,
|
|
66
|
+
headers: headers,
|
|
67
|
+
body: body,
|
|
68
|
+
userAgent: client._options.userAgent,
|
|
69
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
70
|
+
}, options);
|
|
71
|
+
if (!requestRes.ok) {
|
|
72
|
+
return [requestRes, { status: "invalid" }];
|
|
73
|
+
}
|
|
74
|
+
const req = requestRes.value;
|
|
75
|
+
const doResult = await client._do(req, {
|
|
76
|
+
context,
|
|
77
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
78
|
+
retryConfig: context.retryConfig,
|
|
79
|
+
retryCodes: context.retryCodes,
|
|
80
|
+
});
|
|
81
|
+
if (!doResult.ok) {
|
|
82
|
+
return [doResult, { status: "request-error", request: req }];
|
|
83
|
+
}
|
|
84
|
+
const response = doResult.value;
|
|
85
|
+
const responseFields = {
|
|
86
|
+
HttpMeta: { Response: response, Request: req },
|
|
87
|
+
};
|
|
88
|
+
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 });
|
|
89
|
+
if (!result.ok) {
|
|
90
|
+
return [result, { status: "complete", request: req, response }];
|
|
91
|
+
}
|
|
92
|
+
return [result, { status: "complete", request: req, response }];
|
|
93
|
+
}
|
package/esm/lib/config.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
31
31
|
export declare const SDK_METADATA: {
|
|
32
32
|
readonly language: "typescript";
|
|
33
33
|
readonly openapiDocVersion: "1.0.0";
|
|
34
|
-
readonly sdkVersion: "0.
|
|
34
|
+
readonly sdkVersion: "0.5.0";
|
|
35
35
|
readonly genVersion: "2.941.0";
|
|
36
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.
|
|
36
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.5.0 2.941.0 1.0.0 @usestatemachines/sdk";
|
|
37
37
|
};
|
package/esm/lib/config.js
CHANGED
|
@@ -24,7 +24,7 @@ export function serverURLFromOptions(options) {
|
|
|
24
24
|
export const SDK_METADATA = {
|
|
25
25
|
language: "typescript",
|
|
26
26
|
openapiDocVersion: "1.0.0",
|
|
27
|
-
sdkVersion: "0.
|
|
27
|
+
sdkVersion: "0.5.0",
|
|
28
28
|
genVersion: "2.941.0",
|
|
29
|
-
userAgent: "speakeasy-sdk/typescript 0.
|
|
29
|
+
userAgent: "speakeasy-sdk/typescript 0.5.0 2.941.0 1.0.0 @usestatemachines/sdk",
|
|
30
30
|
};
|
|
@@ -13,6 +13,8 @@ export declare const EnvironmentAppStatus: {
|
|
|
13
13
|
readonly Pending: "pending";
|
|
14
14
|
readonly Starting: "starting";
|
|
15
15
|
readonly Ready: "ready";
|
|
16
|
+
readonly Recovering: "recovering";
|
|
17
|
+
readonly Suspended: "suspended";
|
|
16
18
|
readonly Stopping: "stopping";
|
|
17
19
|
readonly Stopped: "stopped";
|
|
18
20
|
readonly Failed: "failed";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as z from "zod/v4-mini";
|
|
2
|
+
import { OpenEnum } from "../types/enums.js";
|
|
3
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
|
+
import { SDKValidationError } from "./errors/sdk-validation-error.js";
|
|
5
|
+
import { RequestPayloadPreview } from "./request-payload-preview.js";
|
|
6
|
+
export declare const EnvironmentRequestDetailOutcome: {
|
|
7
|
+
readonly ReplicaResponse: "replica_response";
|
|
8
|
+
readonly GatewayError: "gateway_error";
|
|
9
|
+
};
|
|
10
|
+
export type EnvironmentRequestDetailOutcome = OpenEnum<typeof EnvironmentRequestDetailOutcome>;
|
|
11
|
+
export type EnvironmentRequestDetail = {
|
|
12
|
+
appInstanceId: string | null;
|
|
13
|
+
appKey: string;
|
|
14
|
+
completedAt: Date;
|
|
15
|
+
durationMs: number;
|
|
16
|
+
environmentId: string;
|
|
17
|
+
errorCode: string | null;
|
|
18
|
+
id: string;
|
|
19
|
+
method: string;
|
|
20
|
+
outcome: EnvironmentRequestDetailOutcome;
|
|
21
|
+
path: string;
|
|
22
|
+
query: string;
|
|
23
|
+
receivedAt: Date;
|
|
24
|
+
requestBytes: number | null;
|
|
25
|
+
responseBytes: number | null;
|
|
26
|
+
status: number;
|
|
27
|
+
requestBody: RequestPayloadPreview;
|
|
28
|
+
requestHeaders: {
|
|
29
|
+
[k: string]: string;
|
|
30
|
+
};
|
|
31
|
+
responseBody: RequestPayloadPreview;
|
|
32
|
+
responseHeaders: {
|
|
33
|
+
[k: string]: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/** @internal */
|
|
37
|
+
export declare const EnvironmentRequestDetailOutcome$inboundSchema: z.ZodMiniType<EnvironmentRequestDetailOutcome, unknown>;
|
|
38
|
+
/** @internal */
|
|
39
|
+
export declare const EnvironmentRequestDetail$inboundSchema: z.ZodMiniType<EnvironmentRequestDetail, unknown>;
|
|
40
|
+
export declare function environmentRequestDetailFromJSON(jsonString: string): SafeParseResult<EnvironmentRequestDetail, SDKValidationError>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { safeParse } from "../lib/schemas.js";
|
|
6
|
+
import * as openEnums from "../types/enums.js";
|
|
7
|
+
import * as types from "../types/primitives.js";
|
|
8
|
+
import { RequestPayloadPreview$inboundSchema, } from "./request-payload-preview.js";
|
|
9
|
+
export const EnvironmentRequestDetailOutcome = {
|
|
10
|
+
ReplicaResponse: "replica_response",
|
|
11
|
+
GatewayError: "gateway_error",
|
|
12
|
+
};
|
|
13
|
+
/** @internal */
|
|
14
|
+
export const EnvironmentRequestDetailOutcome$inboundSchema = openEnums.inboundSchema(EnvironmentRequestDetailOutcome);
|
|
15
|
+
/** @internal */
|
|
16
|
+
export const EnvironmentRequestDetail$inboundSchema = z.object({
|
|
17
|
+
appInstanceId: types.nullable(types.string()),
|
|
18
|
+
appKey: types.string(),
|
|
19
|
+
completedAt: types.date(),
|
|
20
|
+
durationMs: types.number(),
|
|
21
|
+
environmentId: types.string(),
|
|
22
|
+
errorCode: types.nullable(types.string()),
|
|
23
|
+
id: types.string(),
|
|
24
|
+
method: types.string(),
|
|
25
|
+
outcome: EnvironmentRequestDetailOutcome$inboundSchema,
|
|
26
|
+
path: types.string(),
|
|
27
|
+
query: types.string(),
|
|
28
|
+
receivedAt: types.date(),
|
|
29
|
+
requestBytes: types.nullable(types.number()),
|
|
30
|
+
responseBytes: types.nullable(types.number()),
|
|
31
|
+
status: types.number(),
|
|
32
|
+
requestBody: RequestPayloadPreview$inboundSchema,
|
|
33
|
+
requestHeaders: z.record(z.string(), types.string()),
|
|
34
|
+
responseBody: RequestPayloadPreview$inboundSchema,
|
|
35
|
+
responseHeaders: z.record(z.string(), types.string()),
|
|
36
|
+
});
|
|
37
|
+
export function environmentRequestDetailFromJSON(jsonString) {
|
|
38
|
+
return safeParse(jsonString, (x) => EnvironmentRequestDetail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EnvironmentRequestDetail' from JSON`);
|
|
39
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as z from "zod/v4-mini";
|
|
2
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
3
|
+
import { SDKValidationError } from "./errors/sdk-validation-error.js";
|
|
4
|
+
export type Bucket = {
|
|
5
|
+
clientError: number;
|
|
6
|
+
from: Date;
|
|
7
|
+
serverError: number;
|
|
8
|
+
success: number;
|
|
9
|
+
};
|
|
10
|
+
export type EnvironmentRequestStats = {
|
|
11
|
+
buckets: Array<Bucket>;
|
|
12
|
+
clientErrorCount: number;
|
|
13
|
+
count: number;
|
|
14
|
+
from: Date;
|
|
15
|
+
p50Ms: number | null;
|
|
16
|
+
p95Ms: number | null;
|
|
17
|
+
serverErrorCount: number;
|
|
18
|
+
successCount: number;
|
|
19
|
+
to: Date;
|
|
20
|
+
};
|
|
21
|
+
/** @internal */
|
|
22
|
+
export declare const Bucket$inboundSchema: z.ZodMiniType<Bucket, unknown>;
|
|
23
|
+
export declare function bucketFromJSON(jsonString: string): SafeParseResult<Bucket, SDKValidationError>;
|
|
24
|
+
/** @internal */
|
|
25
|
+
export declare const EnvironmentRequestStats$inboundSchema: z.ZodMiniType<EnvironmentRequestStats, unknown>;
|
|
26
|
+
export declare function environmentRequestStatsFromJSON(jsonString: string): SafeParseResult<EnvironmentRequestStats, SDKValidationError>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { safeParse } from "../lib/schemas.js";
|
|
6
|
+
import * as types from "../types/primitives.js";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export const Bucket$inboundSchema = z.object({
|
|
9
|
+
clientError: types.number(),
|
|
10
|
+
from: types.date(),
|
|
11
|
+
serverError: types.number(),
|
|
12
|
+
success: types.number(),
|
|
13
|
+
});
|
|
14
|
+
export function bucketFromJSON(jsonString) {
|
|
15
|
+
return safeParse(jsonString, (x) => Bucket$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Bucket' from JSON`);
|
|
16
|
+
}
|
|
17
|
+
/** @internal */
|
|
18
|
+
export const EnvironmentRequestStats$inboundSchema = z.object({
|
|
19
|
+
buckets: z.array(z.lazy(() => Bucket$inboundSchema)),
|
|
20
|
+
clientErrorCount: types.number(),
|
|
21
|
+
count: types.number(),
|
|
22
|
+
from: types.date(),
|
|
23
|
+
p50Ms: types.nullable(types.number()),
|
|
24
|
+
p95Ms: types.nullable(types.number()),
|
|
25
|
+
serverErrorCount: types.number(),
|
|
26
|
+
successCount: types.number(),
|
|
27
|
+
to: types.date(),
|
|
28
|
+
});
|
|
29
|
+
export function environmentRequestStatsFromJSON(jsonString) {
|
|
30
|
+
return safeParse(jsonString, (x) => EnvironmentRequestStats$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EnvironmentRequestStats' from JSON`);
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as z from "zod/v4-mini";
|
|
2
|
+
import { OpenEnum } from "../types/enums.js";
|
|
3
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
|
+
import { SDKValidationError } from "./errors/sdk-validation-error.js";
|
|
5
|
+
export declare const EnvironmentRequestOutcome: {
|
|
6
|
+
readonly ReplicaResponse: "replica_response";
|
|
7
|
+
readonly GatewayError: "gateway_error";
|
|
8
|
+
};
|
|
9
|
+
export type EnvironmentRequestOutcome = OpenEnum<typeof EnvironmentRequestOutcome>;
|
|
10
|
+
export type EnvironmentRequest = {
|
|
11
|
+
appInstanceId: string | null;
|
|
12
|
+
appKey: string;
|
|
13
|
+
completedAt: Date;
|
|
14
|
+
durationMs: number;
|
|
15
|
+
environmentId: string;
|
|
16
|
+
errorCode: string | null;
|
|
17
|
+
id: string;
|
|
18
|
+
method: string;
|
|
19
|
+
outcome: EnvironmentRequestOutcome;
|
|
20
|
+
path: string;
|
|
21
|
+
query: string;
|
|
22
|
+
receivedAt: Date;
|
|
23
|
+
requestBytes: number | null;
|
|
24
|
+
responseBytes: number | null;
|
|
25
|
+
status: number;
|
|
26
|
+
};
|
|
27
|
+
/** @internal */
|
|
28
|
+
export declare const EnvironmentRequestOutcome$inboundSchema: z.ZodMiniType<EnvironmentRequestOutcome, unknown>;
|
|
29
|
+
/** @internal */
|
|
30
|
+
export declare const EnvironmentRequest$inboundSchema: z.ZodMiniType<EnvironmentRequest, unknown>;
|
|
31
|
+
export declare function environmentRequestFromJSON(jsonString: string): SafeParseResult<EnvironmentRequest, SDKValidationError>;
|