@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.
Files changed (106) hide show
  1. package/README.md +158 -18
  2. package/agents/SKILL.md +18 -8
  3. package/agents/index.js +6 -6
  4. package/agents/llms.txt +22 -9
  5. package/agents/prompt.md +2 -2
  6. package/esm/extensions/apps.d.ts +11 -1
  7. package/esm/extensions/apps.js +16 -0
  8. package/esm/extensions/client.d.ts +47 -4
  9. package/esm/extensions/client.js +107 -12
  10. package/esm/extensions/errors.d.ts +26 -1
  11. package/esm/extensions/errors.js +34 -1
  12. package/esm/extensions/index.d.ts +4 -4
  13. package/esm/extensions/index.js +1 -1
  14. package/esm/extensions/running-environment.d.ts +20 -3
  15. package/esm/extensions/running-environment.js +33 -2
  16. package/esm/extensions/wait.d.ts +13 -4
  17. package/esm/extensions/wait.js +38 -13
  18. package/esm/funcs/environments-list.js +1 -0
  19. package/esm/funcs/environments-resume.d.ts +11 -0
  20. package/esm/funcs/environments-resume.js +92 -0
  21. package/esm/funcs/environments-suspend.d.ts +11 -0
  22. package/esm/funcs/environments-suspend.js +92 -0
  23. package/esm/funcs/get-environment-exchange.d.ts +11 -0
  24. package/esm/funcs/get-environment-exchange.js +96 -0
  25. package/esm/funcs/get-environment-position.d.ts +11 -0
  26. package/esm/funcs/get-environment-position.js +92 -0
  27. package/esm/funcs/list-environment-history.d.ts +11 -0
  28. package/esm/funcs/list-environment-history.js +97 -0
  29. package/esm/funcs/snapshots-capture.d.ts +11 -0
  30. package/esm/funcs/snapshots-capture.js +94 -0
  31. package/esm/funcs/snapshots-delete.d.ts +11 -0
  32. package/esm/funcs/snapshots-delete.js +92 -0
  33. package/esm/funcs/snapshots-get.d.ts +11 -0
  34. package/esm/funcs/snapshots-get.js +92 -0
  35. package/esm/funcs/snapshots-list.d.ts +11 -0
  36. package/esm/funcs/snapshots-list.js +98 -0
  37. package/esm/funcs/snapshots-update.d.ts +11 -0
  38. package/esm/funcs/snapshots-update.js +93 -0
  39. package/esm/lib/config.d.ts +2 -2
  40. package/esm/lib/config.js +2 -2
  41. package/esm/models/app-instance-snapshot.d.ts +15 -0
  42. package/esm/models/app-instance-snapshot.js +19 -0
  43. package/esm/models/create-environment-input.d.ts +6 -2
  44. package/esm/models/create-environment-input.js +3 -1
  45. package/esm/models/environment-app.d.ts +11 -0
  46. package/esm/models/environment-app.js +13 -0
  47. package/esm/models/environment-exchange.d.ts +116 -0
  48. package/esm/models/environment-exchange.js +126 -0
  49. package/esm/models/environment-position.d.ts +25 -0
  50. package/esm/models/environment-position.js +32 -0
  51. package/esm/models/environment-snapshot.d.ts +40 -0
  52. package/esm/models/environment-snapshot.js +42 -0
  53. package/esm/models/environment.d.ts +5 -0
  54. package/esm/models/environment.js +5 -0
  55. package/esm/models/error-response.d.ts +9 -0
  56. package/esm/models/error-response.js +9 -0
  57. package/esm/models/history-body.d.ts +28 -0
  58. package/esm/models/history-body.js +33 -0
  59. package/esm/models/history-cause.d.ts +48 -0
  60. package/esm/models/history-cause.js +63 -0
  61. package/esm/models/history-position.d.ts +11 -0
  62. package/esm/models/history-position.js +15 -0
  63. package/esm/models/history-transaction.d.ts +16 -0
  64. package/esm/models/history-transaction.js +20 -0
  65. package/esm/models/index.d.ts +8 -0
  66. package/esm/models/index.js +8 -0
  67. package/esm/models/operations/capture-snapshot.d.ts +41 -0
  68. package/esm/models/operations/capture-snapshot.js +36 -0
  69. package/esm/models/operations/create-environment-definition.d.ts +92 -10
  70. package/esm/models/operations/create-environment-definition.js +63 -4
  71. package/esm/models/operations/delete-snapshot.d.ts +23 -0
  72. package/esm/models/operations/delete-snapshot.js +20 -0
  73. package/esm/models/operations/get-environment-exchange.d.ts +25 -0
  74. package/esm/models/operations/get-environment-exchange.js +21 -0
  75. package/esm/models/operations/get-environment-position.d.ts +23 -0
  76. package/esm/models/operations/get-environment-position.js +20 -0
  77. package/esm/models/operations/get-snapshot.d.ts +23 -0
  78. package/esm/models/operations/get-snapshot.js +20 -0
  79. package/esm/models/operations/index.d.ts +10 -0
  80. package/esm/models/operations/index.js +10 -0
  81. package/esm/models/operations/list-environment-history.d.ts +28 -0
  82. package/esm/models/operations/list-environment-history.js +24 -0
  83. package/esm/models/operations/list-environments.d.ts +2 -0
  84. package/esm/models/operations/list-environments.js +1 -0
  85. package/esm/models/operations/list-snapshots.d.ts +30 -0
  86. package/esm/models/operations/list-snapshots.js +25 -0
  87. package/esm/models/operations/resume-environment.d.ts +23 -0
  88. package/esm/models/operations/resume-environment.js +20 -0
  89. package/esm/models/operations/stop-environment.d.ts +1 -1
  90. package/esm/models/operations/suspend-environment.d.ts +23 -0
  91. package/esm/models/operations/suspend-environment.js +20 -0
  92. package/esm/models/operations/update-snapshot.d.ts +37 -0
  93. package/esm/models/operations/update-snapshot.js +29 -0
  94. package/esm/models/release.d.ts +11 -0
  95. package/esm/models/release.js +10 -0
  96. package/esm/sdk/environments.d.ts +2 -0
  97. package/esm/sdk/environments.js +8 -0
  98. package/esm/sdk/sdk.d.ts +6 -0
  99. package/esm/sdk/sdk.js +17 -0
  100. package/esm/sdk/snapshots.d.ts +9 -0
  101. package/esm/sdk/snapshots.js +27 -0
  102. package/esm/types/discriminated-union.d.ts +24 -0
  103. package/esm/types/discriminated-union.js +60 -0
  104. package/esm/types/smart-union.js +2 -1
  105. package/openapi.json +2473 -242
  106. package/package.json +11 -11
@@ -0,0 +1,97 @@
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 listEnvironmentHistory(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.ListEnvironmentHistoryRequest$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")(pathParams);
32
+ const query = encodeFormQuery({
33
+ "cursor": payload.cursor,
34
+ "limit": payload.limit,
35
+ });
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: "listEnvironmentHistory",
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
+ query: query,
71
+ body: body,
72
+ userAgent: client._options.userAgent,
73
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
74
+ }, options);
75
+ if (!requestRes.ok) {
76
+ return [requestRes, { status: "invalid" }];
77
+ }
78
+ const req = requestRes.value;
79
+ const doResult = await client._do(req, {
80
+ context,
81
+ isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
82
+ retryConfig: context.retryConfig,
83
+ retryCodes: context.retryCodes,
84
+ });
85
+ if (!doResult.ok) {
86
+ return [doResult, { status: "request-error", request: req }];
87
+ }
88
+ const response = doResult.value;
89
+ const responseFields = {
90
+ HttpMeta: { Response: response, Request: req },
91
+ };
92
+ const [result] = await M.match(M.json(200, operations.ListEnvironmentHistoryResponse$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 });
93
+ if (!result.ok) {
94
+ return [result, { status: "complete", request: req, response }];
95
+ }
96
+ return [result, { status: "complete", request: req, response }];
97
+ }
@@ -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>>;
@@ -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 snapshotsGet(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.GetSnapshotRequest$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: "getSnapshot",
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.GetSnapshotResponse$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 snapshotsList(client: StateMachinesCore, request: operations.ListSnapshotsRequest, options?: RequestOptions): APIPromise<Result<operations.ListSnapshotsResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
@@ -0,0 +1,98 @@
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 snapshotsList(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.ListSnapshotsRequest$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
+ workspaceId: encodeSimple("workspaceId", payload.workspaceId, {
27
+ explode: false,
28
+ charEncoding: "percent",
29
+ }),
30
+ };
31
+ const path = pathToFunc("/v1/workspaces/{workspaceId}/snapshots")(pathParams);
32
+ const query = encodeFormQuery({
33
+ "cursor": payload.cursor,
34
+ "limit": payload.limit,
35
+ "sourceEnvironmentId": payload.sourceEnvironmentId,
36
+ });
37
+ const headers = new Headers(compactMap({
38
+ Accept: "application/json",
39
+ }));
40
+ const secConfig = await extractSecurity(client._options.apiKey);
41
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
42
+ const requestSecurity = resolveGlobalSecurity(securityInput);
43
+ const context = {
44
+ options: client._options,
45
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
46
+ operationID: "listSnapshots",
47
+ oAuth2Scopes: null,
48
+ resolvedSecurity: requestSecurity,
49
+ securitySource: client._options.apiKey,
50
+ retryConfig: options?.retries
51
+ || client._options.retryConfig
52
+ || {
53
+ strategy: "backoff",
54
+ backoff: {
55
+ initialInterval: 1000,
56
+ maxInterval: 5000,
57
+ exponent: 1.5,
58
+ maxElapsedTime: 600000,
59
+ },
60
+ retryConnectionErrors: true,
61
+ }
62
+ || { strategy: "none" },
63
+ retryCodes: options?.retryCodes || ["502", "503", "504"],
64
+ };
65
+ const requestRes = client._createRequest(context, {
66
+ security: requestSecurity,
67
+ method: "GET",
68
+ baseURL: options?.serverURL,
69
+ path: path,
70
+ headers: headers,
71
+ query: query,
72
+ body: body,
73
+ userAgent: client._options.userAgent,
74
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
75
+ }, options);
76
+ if (!requestRes.ok) {
77
+ return [requestRes, { status: "invalid" }];
78
+ }
79
+ const req = requestRes.value;
80
+ const doResult = await client._do(req, {
81
+ context,
82
+ isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
83
+ retryConfig: context.retryConfig,
84
+ retryCodes: context.retryCodes,
85
+ });
86
+ if (!doResult.ok) {
87
+ return [doResult, { status: "request-error", request: req }];
88
+ }
89
+ const response = doResult.value;
90
+ const responseFields = {
91
+ HttpMeta: { Response: response, Request: req },
92
+ };
93
+ const [result] = await M.match(M.json(200, operations.ListSnapshotsResponse$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 });
94
+ if (!result.ok) {
95
+ return [result, { status: "complete", request: req, response }];
96
+ }
97
+ return [result, { status: "complete", request: req, response }];
98
+ }
@@ -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 snapshotsUpdate(client: StateMachinesCore, request: operations.UpdateSnapshotRequest, options?: RequestOptions): APIPromise<Result<operations.UpdateSnapshotResponse, 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 { 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 snapshotsUpdate(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.UpdateSnapshotRequest$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
+ 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
+ "Content-Type": "application/json",
34
+ Accept: "application/json",
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: "updateSnapshot",
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: "PATCH",
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.UpdateSnapshotResponse$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,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.2.0";
34
+ readonly sdkVersion: "0.4.0";
35
35
  readonly genVersion: "2.941.0";
36
- readonly userAgent: "speakeasy-sdk/typescript 0.2.0 2.941.0 1.0.0 @usestatemachines/sdk";
36
+ readonly userAgent: "speakeasy-sdk/typescript 0.4.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.2.0",
27
+ sdkVersion: "0.4.0",
28
28
  genVersion: "2.941.0",
29
- userAgent: "speakeasy-sdk/typescript 0.2.0 2.941.0 1.0.0 @usestatemachines/sdk",
29
+ userAgent: "speakeasy-sdk/typescript 0.4.0 2.941.0 1.0.0 @usestatemachines/sdk",
30
30
  };