@usestatemachines/sdk 0.1.1

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 (203) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +311 -0
  3. package/agents/SKILL.md +90 -0
  4. package/agents/index.d.ts +13 -0
  5. package/agents/index.js +22 -0
  6. package/agents/llms.txt +93 -0
  7. package/agents/prompt.md +49 -0
  8. package/esm/core.d.ts +9 -0
  9. package/esm/core.js +12 -0
  10. package/esm/extensions/client.d.ts +81 -0
  11. package/esm/extensions/client.js +213 -0
  12. package/esm/extensions/connection.d.ts +42 -0
  13. package/esm/extensions/connection.js +133 -0
  14. package/esm/extensions/errors.d.ts +52 -0
  15. package/esm/extensions/errors.js +129 -0
  16. package/esm/extensions/index.d.ts +11 -0
  17. package/esm/extensions/index.js +7 -0
  18. package/esm/extensions/signal.d.ts +14 -0
  19. package/esm/extensions/signal.js +29 -0
  20. package/esm/extensions/wait.d.ts +19 -0
  21. package/esm/extensions/wait.js +102 -0
  22. package/esm/funcs/catalog-get.d.ts +11 -0
  23. package/esm/funcs/catalog-get.js +76 -0
  24. package/esm/funcs/catalog-release.d.ts +11 -0
  25. package/esm/funcs/catalog-release.js +92 -0
  26. package/esm/funcs/credential-get.d.ts +11 -0
  27. package/esm/funcs/credential-get.js +76 -0
  28. package/esm/funcs/environments-create.d.ts +11 -0
  29. package/esm/funcs/environments-create.js +94 -0
  30. package/esm/funcs/environments-events.d.ts +12 -0
  31. package/esm/funcs/environments-events.js +98 -0
  32. package/esm/funcs/environments-get-connection.d.ts +11 -0
  33. package/esm/funcs/environments-get-connection.js +96 -0
  34. package/esm/funcs/environments-get.d.ts +11 -0
  35. package/esm/funcs/environments-get.js +92 -0
  36. package/esm/funcs/environments-list.d.ts +11 -0
  37. package/esm/funcs/environments-list.js +100 -0
  38. package/esm/funcs/environments-reveal.d.ts +11 -0
  39. package/esm/funcs/environments-reveal.js +97 -0
  40. package/esm/funcs/environments-stop.d.ts +11 -0
  41. package/esm/funcs/environments-stop.js +92 -0
  42. package/esm/funcs/workspaces-events.d.ts +12 -0
  43. package/esm/funcs/workspaces-events.js +98 -0
  44. package/esm/funcs/workspaces-get.d.ts +11 -0
  45. package/esm/funcs/workspaces-get.js +92 -0
  46. package/esm/funcs/workspaces-list.d.ts +11 -0
  47. package/esm/funcs/workspaces-list.js +90 -0
  48. package/esm/hooks/hooks.d.ts +24 -0
  49. package/esm/hooks/hooks.js +79 -0
  50. package/esm/hooks/index.d.ts +2 -0
  51. package/esm/hooks/index.js +5 -0
  52. package/esm/hooks/types.d.ts +76 -0
  53. package/esm/hooks/types.js +4 -0
  54. package/esm/index.d.ts +5 -0
  55. package/esm/index.js +7 -0
  56. package/esm/lib/base64.d.ts +9 -0
  57. package/esm/lib/base64.js +30 -0
  58. package/esm/lib/config.d.ts +37 -0
  59. package/esm/lib/config.js +30 -0
  60. package/esm/lib/encodings.d.ts +54 -0
  61. package/esm/lib/encodings.js +406 -0
  62. package/esm/lib/files.d.ts +25 -0
  63. package/esm/lib/files.js +90 -0
  64. package/esm/lib/http.d.ts +66 -0
  65. package/esm/lib/http.js +208 -0
  66. package/esm/lib/logger.d.ts +5 -0
  67. package/esm/lib/logger.js +4 -0
  68. package/esm/lib/matchers.d.ts +58 -0
  69. package/esm/lib/matchers.js +201 -0
  70. package/esm/lib/primitives.d.ts +26 -0
  71. package/esm/lib/primitives.js +119 -0
  72. package/esm/lib/retries.d.ts +37 -0
  73. package/esm/lib/retries.js +156 -0
  74. package/esm/lib/schemas.d.ts +20 -0
  75. package/esm/lib/schemas.js +56 -0
  76. package/esm/lib/sdks.d.ts +62 -0
  77. package/esm/lib/sdks.js +289 -0
  78. package/esm/lib/security.d.ts +83 -0
  79. package/esm/lib/security.js +145 -0
  80. package/esm/lib/url.d.ts +4 -0
  81. package/esm/lib/url.js +23 -0
  82. package/esm/models/actor.d.ts +12 -0
  83. package/esm/models/actor.js +16 -0
  84. package/esm/models/api-profile.d.ts +17 -0
  85. package/esm/models/api-profile.js +22 -0
  86. package/esm/models/app.d.ts +14 -0
  87. package/esm/models/app.js +18 -0
  88. package/esm/models/catalog.d.ts +12 -0
  89. package/esm/models/catalog.js +15 -0
  90. package/esm/models/connection-secret.d.ts +14 -0
  91. package/esm/models/connection-secret.js +18 -0
  92. package/esm/models/connection.d.ts +26 -0
  93. package/esm/models/connection.js +30 -0
  94. package/esm/models/create-environment-input.d.ts +35 -0
  95. package/esm/models/create-environment-input.js +23 -0
  96. package/esm/models/credential-kind.d.ts +9 -0
  97. package/esm/models/credential-kind.js +10 -0
  98. package/esm/models/credential.d.ts +48 -0
  99. package/esm/models/credential.js +44 -0
  100. package/esm/models/environment-app.d.ts +42 -0
  101. package/esm/models/environment-app.js +44 -0
  102. package/esm/models/environment-lifetime.d.ts +10 -0
  103. package/esm/models/environment-lifetime.js +14 -0
  104. package/esm/models/environment.d.ts +47 -0
  105. package/esm/models/environment.js +48 -0
  106. package/esm/models/error-response.d.ts +45 -0
  107. package/esm/models/error-response.js +47 -0
  108. package/esm/models/errors/error-response.d.ts +18 -0
  109. package/esm/models/errors/error-response.js +32 -0
  110. package/esm/models/errors/http-client-errors.d.ts +43 -0
  111. package/esm/models/errors/http-client-errors.js +55 -0
  112. package/esm/models/errors/index.d.ts +6 -0
  113. package/esm/models/errors/index.js +9 -0
  114. package/esm/models/errors/response-validation-error.d.ts +25 -0
  115. package/esm/models/errors/response-validation-error.js +36 -0
  116. package/esm/models/errors/sdk-validation-error.d.ts +20 -0
  117. package/esm/models/errors/sdk-validation-error.js +51 -0
  118. package/esm/models/errors/state-machines-http-error.d.ts +18 -0
  119. package/esm/models/errors/state-machines-http-error.js +25 -0
  120. package/esm/models/errors/unexpected-response-error.d.ts +9 -0
  121. package/esm/models/errors/unexpected-response-error.js +29 -0
  122. package/esm/models/event-page.d.ts +11 -0
  123. package/esm/models/event-page.js +16 -0
  124. package/esm/models/event.d.ts +20 -0
  125. package/esm/models/event.js +22 -0
  126. package/esm/models/index.d.ts +19 -0
  127. package/esm/models/index.js +22 -0
  128. package/esm/models/operations/create-environments.d.ts +27 -0
  129. package/esm/models/operations/create-environments.js +27 -0
  130. package/esm/models/operations/get-catalog.d.ts +13 -0
  131. package/esm/models/operations/get-catalog.js +13 -0
  132. package/esm/models/operations/get-connection.d.ts +25 -0
  133. package/esm/models/operations/get-connection.js +21 -0
  134. package/esm/models/operations/get-credential.d.ts +13 -0
  135. package/esm/models/operations/get-credential.js +13 -0
  136. package/esm/models/operations/get-environment.d.ts +23 -0
  137. package/esm/models/operations/get-environment.js +20 -0
  138. package/esm/models/operations/get-release.d.ts +23 -0
  139. package/esm/models/operations/get-release.js +20 -0
  140. package/esm/models/operations/get-workspace.d.ts +23 -0
  141. package/esm/models/operations/get-workspace.js +20 -0
  142. package/esm/models/operations/index.d.ts +13 -0
  143. package/esm/models/operations/index.js +16 -0
  144. package/esm/models/operations/list-environment-events.d.ts +15 -0
  145. package/esm/models/operations/list-environment-events.js +13 -0
  146. package/esm/models/operations/list-environments.d.ts +49 -0
  147. package/esm/models/operations/list-environments.js +40 -0
  148. package/esm/models/operations/list-workspace-events.d.ts +15 -0
  149. package/esm/models/operations/list-workspace-events.js +13 -0
  150. package/esm/models/operations/list-workspaces.d.ts +32 -0
  151. package/esm/models/operations/list-workspaces.js +27 -0
  152. package/esm/models/operations/reveal-connection.d.ts +37 -0
  153. package/esm/models/operations/reveal-connection.js +29 -0
  154. package/esm/models/operations/stop-environment.d.ts +23 -0
  155. package/esm/models/operations/stop-environment.js +20 -0
  156. package/esm/models/release-actor.d.ts +11 -0
  157. package/esm/models/release-actor.js +15 -0
  158. package/esm/models/release.d.ts +26 -0
  159. package/esm/models/release.js +29 -0
  160. package/esm/models/security.d.ts +11 -0
  161. package/esm/models/security.js +11 -0
  162. package/esm/models/workspace.d.ts +16 -0
  163. package/esm/models/workspace.js +21 -0
  164. package/esm/sdk/catalog.d.ts +6 -0
  165. package/esm/sdk/catalog.js +15 -0
  166. package/esm/sdk/credential.d.ts +5 -0
  167. package/esm/sdk/credential.js +11 -0
  168. package/esm/sdk/environments.d.ts +12 -0
  169. package/esm/sdk/environments.js +35 -0
  170. package/esm/sdk/index.d.ts +1 -0
  171. package/esm/sdk/index.js +4 -0
  172. package/esm/sdk/sdk.d.ts +15 -0
  173. package/esm/sdk/sdk.js +26 -0
  174. package/esm/sdk/workspaces.d.ts +8 -0
  175. package/esm/sdk/workspaces.js +19 -0
  176. package/esm/types/async.d.ts +22 -0
  177. package/esm/types/async.js +27 -0
  178. package/esm/types/blobs.d.ts +3 -0
  179. package/esm/types/blobs.js +24 -0
  180. package/esm/types/const-date-time.d.ts +2 -0
  181. package/esm/types/const-date-time.js +9 -0
  182. package/esm/types/default-to-zero-value.d.ts +11 -0
  183. package/esm/types/default-to-zero-value.js +30 -0
  184. package/esm/types/enums.d.ts +8 -0
  185. package/esm/types/enums.js +26 -0
  186. package/esm/types/fp.d.ts +30 -0
  187. package/esm/types/fp.js +30 -0
  188. package/esm/types/index.d.ts +9 -0
  189. package/esm/types/index.js +9 -0
  190. package/esm/types/operations.d.ts +26 -0
  191. package/esm/types/operations.js +76 -0
  192. package/esm/types/primitives.d.ts +8 -0
  193. package/esm/types/primitives.js +108 -0
  194. package/esm/types/rfcdate.d.ts +20 -0
  195. package/esm/types/rfcdate.js +42 -0
  196. package/esm/types/smart-union.d.ts +6 -0
  197. package/esm/types/smart-union.js +116 -0
  198. package/esm/types/streams.d.ts +1 -0
  199. package/esm/types/streams.js +14 -0
  200. package/esm/types/unrecognized.d.ts +15 -0
  201. package/esm/types/unrecognized.js +30 -0
  202. package/openapi.json +2853 -0
  203. package/package.json +50 -0
@@ -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 environmentsStop(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.StopEnvironmentRequest$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}/stop")(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: "stopEnvironment",
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.StopEnvironmentResponse$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,12 @@
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 models from "../models/index.js";
9
+ import * as operations from "../models/operations/index.js";
10
+ import { APIPromise } from "../types/async.js";
11
+ import { Result } from "../types/fp.js";
12
+ export declare function workspacesEvents(client: StateMachinesCore, request: operations.ListWorkspaceEventsRequest, options?: RequestOptions): APIPromise<Result<models.EventPage, 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 models from "../models/index.js";
14
+ import * as operations from "../models/operations/index.js";
15
+ import { APIPromise } from "../types/async.js";
16
+ export function workspacesEvents(client, request, options) {
17
+ return new APIPromise($do(client, request, options));
18
+ }
19
+ async function $do(client, request, options) {
20
+ const parsed = safeParse(request, (value) => z.parse(operations.ListWorkspaceEventsRequest$outboundSchema, value), "Input validation failed");
21
+ if (!parsed.ok) {
22
+ return [parsed, { status: "invalid" }];
23
+ }
24
+ const payload = parsed.value;
25
+ const body = null;
26
+ const pathParams = {
27
+ workspaceId: encodeSimple("workspaceId", payload.workspaceId, {
28
+ explode: false,
29
+ charEncoding: "percent",
30
+ }),
31
+ };
32
+ const path = pathToFunc("/v1/workspaces/{workspaceId}/events")(pathParams);
33
+ const query = encodeFormQuery({
34
+ "cursor": payload.cursor,
35
+ "limit": payload.limit,
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: "listWorkspaceEvents",
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, models.EventPage$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 workspacesGet(client: StateMachinesCore, request: operations.GetWorkspaceRequest, options?: RequestOptions): APIPromise<Result<operations.GetWorkspaceResponse, 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 workspacesGet(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.GetWorkspaceRequest$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}")(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: "getWorkspace",
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.GetWorkspaceResponse$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 workspacesList(client: StateMachinesCore, request?: operations.ListWorkspacesRequest | undefined, options?: RequestOptions): APIPromise<Result<operations.ListWorkspacesResponse, errors.ErrorResponse | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
@@ -0,0 +1,90 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ import * as z from "zod/v4-mini";
5
+ import { encodeFormQuery } 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 workspacesList(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(z.optional(operations.ListWorkspacesRequest$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 path = pathToFunc("/v1/workspaces")();
26
+ const query = encodeFormQuery({
27
+ "archived": payload?.archived,
28
+ });
29
+ const headers = new Headers(compactMap({
30
+ Accept: "application/json",
31
+ }));
32
+ const secConfig = await extractSecurity(client._options.apiKey);
33
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
34
+ const requestSecurity = resolveGlobalSecurity(securityInput);
35
+ const context = {
36
+ options: client._options,
37
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
38
+ operationID: "listWorkspaces",
39
+ oAuth2Scopes: null,
40
+ resolvedSecurity: requestSecurity,
41
+ securitySource: client._options.apiKey,
42
+ retryConfig: options?.retries
43
+ || client._options.retryConfig
44
+ || {
45
+ strategy: "backoff",
46
+ backoff: {
47
+ initialInterval: 1000,
48
+ maxInterval: 5000,
49
+ exponent: 1.5,
50
+ maxElapsedTime: 600000,
51
+ },
52
+ retryConnectionErrors: true,
53
+ }
54
+ || { strategy: "none" },
55
+ retryCodes: options?.retryCodes || ["502", "503", "504"],
56
+ };
57
+ const requestRes = client._createRequest(context, {
58
+ security: requestSecurity,
59
+ method: "GET",
60
+ baseURL: options?.serverURL,
61
+ path: path,
62
+ headers: headers,
63
+ query: query,
64
+ body: body,
65
+ userAgent: client._options.userAgent,
66
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
67
+ }, options);
68
+ if (!requestRes.ok) {
69
+ return [requestRes, { status: "invalid" }];
70
+ }
71
+ const req = requestRes.value;
72
+ const doResult = await client._do(req, {
73
+ context,
74
+ isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
75
+ retryConfig: context.retryConfig,
76
+ retryCodes: context.retryCodes,
77
+ });
78
+ if (!doResult.ok) {
79
+ return [doResult, { status: "request-error", request: req }];
80
+ }
81
+ const response = doResult.value;
82
+ const responseFields = {
83
+ HttpMeta: { Response: response, Request: req },
84
+ };
85
+ const [result] = await M.match(M.json(200, operations.ListWorkspacesResponse$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 });
86
+ if (!result.ok) {
87
+ return [result, { status: "complete", request: req, response }];
88
+ }
89
+ return [result, { status: "complete", request: req, response }];
90
+ }
@@ -0,0 +1,24 @@
1
+ import { SDKOptions } from "../lib/config.js";
2
+ import { RequestInput } from "../lib/http.js";
3
+ import { AfterErrorContext, AfterErrorHook, AfterSuccessContext, AfterSuccessHook, BeforeCreateRequestContext, BeforeCreateRequestHook, BeforeRequestContext, BeforeRequestHook, Hooks, SDKInitHook } from "./types.js";
4
+ export declare class SDKHooks implements Hooks {
5
+ sdkInitHooks: SDKInitHook[];
6
+ beforeCreateRequestHooks: BeforeCreateRequestHook[];
7
+ beforeRequestHooks: BeforeRequestHook[];
8
+ afterSuccessHooks: AfterSuccessHook[];
9
+ afterErrorHooks: AfterErrorHook[];
10
+ constructor();
11
+ registerSDKInitHook(hook: SDKInitHook): void;
12
+ registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void;
13
+ registerBeforeRequestHook(hook: BeforeRequestHook): void;
14
+ registerAfterSuccessHook(hook: AfterSuccessHook): void;
15
+ registerAfterErrorHook(hook: AfterErrorHook): void;
16
+ sdkInit(opts: SDKOptions): SDKOptions;
17
+ beforeCreateRequest(hookCtx: BeforeCreateRequestContext, input: RequestInput): RequestInput;
18
+ beforeRequest(hookCtx: BeforeRequestContext, request: Request): Promise<Request>;
19
+ afterSuccess(hookCtx: AfterSuccessContext, response: Response): Promise<Response>;
20
+ afterError(hookCtx: AfterErrorContext, response: Response | null, error: unknown): Promise<{
21
+ response: Response | null;
22
+ error: unknown;
23
+ }>;
24
+ }
@@ -0,0 +1,79 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ export class SDKHooks {
5
+ sdkInitHooks = [];
6
+ beforeCreateRequestHooks = [];
7
+ beforeRequestHooks = [];
8
+ afterSuccessHooks = [];
9
+ afterErrorHooks = [];
10
+ constructor() {
11
+ const presetHooks = [];
12
+ for (const hook of presetHooks) {
13
+ if ("sdkInit" in hook) {
14
+ this.registerSDKInitHook(hook);
15
+ }
16
+ if ("beforeCreateRequest" in hook) {
17
+ this.registerBeforeCreateRequestHook(hook);
18
+ }
19
+ if ("beforeRequest" in hook) {
20
+ this.registerBeforeRequestHook(hook);
21
+ }
22
+ if ("afterSuccess" in hook) {
23
+ this.registerAfterSuccessHook(hook);
24
+ }
25
+ if ("afterError" in hook) {
26
+ this.registerAfterErrorHook(hook);
27
+ }
28
+ }
29
+ }
30
+ registerSDKInitHook(hook) {
31
+ this.sdkInitHooks.push(hook);
32
+ }
33
+ registerBeforeCreateRequestHook(hook) {
34
+ this.beforeCreateRequestHooks.push(hook);
35
+ }
36
+ registerBeforeRequestHook(hook) {
37
+ this.beforeRequestHooks.push(hook);
38
+ }
39
+ registerAfterSuccessHook(hook) {
40
+ this.afterSuccessHooks.push(hook);
41
+ }
42
+ registerAfterErrorHook(hook) {
43
+ this.afterErrorHooks.push(hook);
44
+ }
45
+ sdkInit(opts) {
46
+ return this.sdkInitHooks.reduce((opts, hook) => hook.sdkInit(opts), opts);
47
+ }
48
+ beforeCreateRequest(hookCtx, input) {
49
+ let inp = input;
50
+ for (const hook of this.beforeCreateRequestHooks) {
51
+ inp = hook.beforeCreateRequest(hookCtx, inp);
52
+ }
53
+ return inp;
54
+ }
55
+ async beforeRequest(hookCtx, request) {
56
+ let req = request;
57
+ for (const hook of this.beforeRequestHooks) {
58
+ req = await hook.beforeRequest(hookCtx, req);
59
+ }
60
+ return req;
61
+ }
62
+ async afterSuccess(hookCtx, response) {
63
+ let res = response;
64
+ for (const hook of this.afterSuccessHooks) {
65
+ res = await hook.afterSuccess(hookCtx, res);
66
+ }
67
+ return res;
68
+ }
69
+ async afterError(hookCtx, response, error) {
70
+ let res = response;
71
+ let err = error;
72
+ for (const hook of this.afterErrorHooks) {
73
+ const result = await hook.afterError(hookCtx, res, err);
74
+ res = result.response;
75
+ err = result.error;
76
+ }
77
+ return { response: res, error: err };
78
+ }
79
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./hooks.js";
2
+ export * from "./types.js";
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ export * from "./hooks.js";
5
+ export * from "./types.js";
@@ -0,0 +1,76 @@
1
+ import { SDKOptions } from "../lib/config.js";
2
+ import { RequestInput } from "../lib/http.js";
3
+ import { RetryConfig } from "../lib/retries.js";
4
+ import { SecurityState } from "../lib/security.js";
5
+ export type HookContext = {
6
+ baseURL: string | URL;
7
+ operationID: string;
8
+ oAuth2Scopes: string[] | null;
9
+ securitySource?: any | (() => Promise<any>);
10
+ retryConfig: RetryConfig;
11
+ resolvedSecurity: SecurityState | null;
12
+ options: SDKOptions;
13
+ timeoutMs?: number;
14
+ };
15
+ export type Awaitable<T> = T | Promise<T>;
16
+ export type BeforeCreateRequestContext = HookContext & {};
17
+ export type BeforeRequestContext = HookContext & {};
18
+ export type AfterSuccessContext = HookContext & {};
19
+ export type AfterErrorContext = HookContext & {};
20
+ /**
21
+ * SDKInitHook is called when the SDK is initializing. The
22
+ * hook can return a new baseURL and HTTP client to be used by the SDK.
23
+ */
24
+ export interface SDKInitHook {
25
+ sdkInit: (opts: SDKOptions) => SDKOptions;
26
+ }
27
+ export interface BeforeCreateRequestHook {
28
+ /**
29
+ * A hook that is called before the SDK creates a `Request` object. The hook
30
+ * can modify how a request is constructed since certain modifications, like
31
+ * changing the request URL, cannot be done on a request object directly.
32
+ */
33
+ beforeCreateRequest: (hookCtx: BeforeCreateRequestContext, input: RequestInput) => RequestInput;
34
+ }
35
+ export interface BeforeRequestHook {
36
+ /**
37
+ * A hook that is called before the SDK sends a request. The hook can
38
+ * introduce instrumentation code such as logging, tracing and metrics or
39
+ * replace the request before it is sent or throw an error to stop the
40
+ * request from being sent.
41
+ */
42
+ beforeRequest: (hookCtx: BeforeRequestContext, request: Request) => Awaitable<Request>;
43
+ }
44
+ export interface AfterSuccessHook {
45
+ /**
46
+ * A hook that is called after the SDK receives a response. The hook can
47
+ * introduce instrumentation code such as logging, tracing and metrics or
48
+ * modify the response before it is handled or throw an error to stop the
49
+ * response from being handled.
50
+ */
51
+ afterSuccess: (hookCtx: AfterSuccessContext, response: Response) => Awaitable<Response>;
52
+ }
53
+ export interface AfterErrorHook {
54
+ /**
55
+ * A hook that is called after the SDK encounters an error, or a
56
+ * non-successful response. The hook can introduce instrumentation code such
57
+ * as logging, tracing and metrics or modify the response or error values.
58
+ */
59
+ afterError: (hookCtx: AfterErrorContext, response: Response | null, error: unknown) => Awaitable<{
60
+ response: Response | null;
61
+ error: unknown;
62
+ }>;
63
+ }
64
+ export interface Hooks {
65
+ /** Registers a hook to be used by the SDK for initialization event. */
66
+ registerSDKInitHook(hook: SDKInitHook): void;
67
+ /** Registers a hook to be used by the SDK for to modify `Request` construction. */
68
+ registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void;
69
+ /** Registers a hook to be used by the SDK for the before request event. */
70
+ registerBeforeRequestHook(hook: BeforeRequestHook): void;
71
+ /** Registers a hook to be used by the SDK for the after success event. */
72
+ registerAfterSuccessHook(hook: AfterSuccessHook): void;
73
+ /** Registers a hook to be used by the SDK for the after error event. */
74
+ registerAfterErrorHook(hook: AfterErrorHook): void;
75
+ }
76
+ export type Hook = SDKInitHook | BeforeCreateRequestHook | BeforeRequestHook | AfterSuccessHook | AfterErrorHook;
@@ -0,0 +1,4 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ export {};
package/esm/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./lib/config.js";
2
+ export * as files from "./lib/files.js";
3
+ export { HTTPClient } from "./lib/http.js";
4
+ export type { Fetcher, HTTPClientOptions } from "./lib/http.js";
5
+ export * from "./sdk/sdk.js";
package/esm/index.js ADDED
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ export * from "./lib/config.js";
5
+ export * as files from "./lib/files.js";
6
+ export { HTTPClient } from "./lib/http.js";
7
+ export * from "./sdk/sdk.js";
@@ -0,0 +1,9 @@
1
+ import * as z from "zod/v4-mini";
2
+ export declare function bytesToBase64(u8arr: Uint8Array): string;
3
+ export declare function bytesFromBase64(encoded: string): Uint8Array;
4
+ export declare function stringToBytes(str: string): Uint8Array;
5
+ export declare function stringFromBytes(u8arr: Uint8Array): string;
6
+ export declare function stringToBase64(str: string): string;
7
+ export declare function stringFromBase64(b64str: string): string;
8
+ export declare const zodOutbound: z.ZodMiniUnion<readonly [z.ZodMiniCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, string>>]>;
9
+ export declare const zodInbound: z.ZodMiniUnion<readonly [z.ZodMiniCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, string>>]>;