@usestatemachines/sdk 0.8.1 → 0.9.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 (48) hide show
  1. package/README.md +19 -2
  2. package/agents/SKILL.md +46 -30
  3. package/agents/index.js +6 -6
  4. package/agents/llms.txt +11 -4
  5. package/agents/prompt.md +1 -1
  6. package/esm/extensions/ui.d.ts +59 -0
  7. package/esm/extensions/ui.js +153 -0
  8. package/esm/funcs/launch-ui-session.d.ts +15 -0
  9. package/esm/funcs/launch-ui-session.js +101 -0
  10. package/esm/funcs/list-snapshot-creators.d.ts +11 -0
  11. package/esm/funcs/list-snapshot-creators.js +90 -0
  12. package/esm/funcs/revoke-ui-session.d.ts +15 -0
  13. package/esm/funcs/revoke-ui-session.js +104 -0
  14. package/esm/funcs/snapshots-list.js +3 -0
  15. package/esm/lib/config.d.ts +2 -2
  16. package/esm/lib/config.js +2 -2
  17. package/esm/models/browser-capability.d.ts +12 -0
  18. package/esm/models/browser-capability.js +16 -0
  19. package/esm/models/environment.d.ts +8 -0
  20. package/esm/models/environment.js +9 -0
  21. package/esm/models/error.d.ts +1 -0
  22. package/esm/models/error.js +1 -0
  23. package/esm/models/index.d.ts +5 -0
  24. package/esm/models/index.js +5 -0
  25. package/esm/models/launch-ui-session.d.ts +26 -0
  26. package/esm/models/launch-ui-session.js +16 -0
  27. package/esm/models/operations/index.d.ts +3 -0
  28. package/esm/models/operations/index.js +3 -0
  29. package/esm/models/operations/launch-ui-session.d.ts +16 -0
  30. package/esm/models/operations/launch-ui-session.js +14 -0
  31. package/esm/models/operations/list-snapshot-creators.d.ts +23 -0
  32. package/esm/models/operations/list-snapshot-creators.js +20 -0
  33. package/esm/models/operations/list-snapshots.d.ts +6 -0
  34. package/esm/models/operations/list-snapshots.js +3 -0
  35. package/esm/models/operations/revoke-ui-session.d.ts +15 -0
  36. package/esm/models/operations/revoke-ui-session.js +13 -0
  37. package/esm/models/service.d.ts +2 -0
  38. package/esm/models/service.js +2 -0
  39. package/esm/models/ui-session-launch.d.ts +21 -0
  40. package/esm/models/ui-session-launch.js +25 -0
  41. package/esm/models/ui-session-mode.d.ts +11 -0
  42. package/esm/models/ui-session-mode.js +12 -0
  43. package/esm/models/ui-session-revocation.d.ts +12 -0
  44. package/esm/models/ui-session-revocation.js +16 -0
  45. package/esm/sdk/sdk.d.ts +10 -0
  46. package/esm/sdk/sdk.js +18 -0
  47. package/openapi.json +738 -78
  48. package/package.json +6 -2
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Browser helpers for a UI session that a trusted server launched. This
3
+ * module imports nothing: it holds no management client, API key or token,
4
+ * so a browser bundle that imports it holds none either.
5
+ */
6
+ /** The fields of a launch that a browser needs. A launch from the API has them all. */
7
+ export interface UiLaunch {
8
+ readonly sessionId: string;
9
+ /** `embedded` posts into an iframe; `page` posts into a window of its own. */
10
+ readonly mode: 'embedded' | 'page';
11
+ /** The session's own origin. */
12
+ readonly origin: string;
13
+ /** Where the browser posts the grant. It is on `origin`. */
14
+ readonly exchangeUrl: string;
15
+ /** One use. Post it once, from the origin the launch named. */
16
+ readonly grant: string;
17
+ }
18
+ /** A message that an embedded session posts to the page that frames it. */
19
+ export type UiSessionMessage = {
20
+ readonly event: 'ready';
21
+ readonly sessionId: string;
22
+ } | {
23
+ readonly event: 'logout';
24
+ readonly sessionId: string;
25
+ } | {
26
+ readonly event: 'failure';
27
+ /** Null when the session failed before it knew its ID, such as when the browser blocked its cookie. */
28
+ readonly sessionId: string | null;
29
+ /** A short code, such as `ui_access_required`, or null. */
30
+ readonly reason: string | null;
31
+ };
32
+ export interface ListenOptions {
33
+ /** Removes the listener when it aborts. */
34
+ readonly signal?: AbortSignal;
35
+ }
36
+ /**
37
+ * Posts the launch's grant to its exchange URL, targeted at `target`: an
38
+ * iframe for an `embedded` launch, or a window for a `page` launch. Open the
39
+ * window in the click handler, such as with `window.open('about:blank',
40
+ * name)`, so the browser does not block it. The session then loads in
41
+ * `target`, and a window loses its `opener`. A launch posts once; a second
42
+ * post of the same grant is refused.
43
+ *
44
+ * The posting page must send its `Origin`, so its `Referrer-Policy` must not
45
+ * be `no-referrer`.
46
+ */
47
+ export declare function submitLaunch(launch: UiLaunch, target: HTMLIFrameElement | Window): void;
48
+ /**
49
+ * The session message in `data`, or null when `data` is not exactly one of
50
+ * the messages for `sessionId`. A failure may carry a null session ID.
51
+ */
52
+ export declare function parseSessionMessage(data: unknown, sessionId: string): UiSessionMessage | null;
53
+ /**
54
+ * Calls `onMessage` with each message that the session in `source` posts:
55
+ * only from the launch's exact origin, only from `source`'s window, and only
56
+ * for the launch's session. Every other message is ignored. Answers the
57
+ * function that removes the listener.
58
+ */
59
+ export declare function listenToSession(launch: Pick<UiLaunch, 'sessionId' | 'origin'>, source: HTMLIFrameElement | Window, onMessage: (message: UiSessionMessage) => void, options?: ListenOptions): () => void;
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Browser helpers for a UI session that a trusted server launched. This
3
+ * module imports nothing: it holds no management client, API key or token,
4
+ * so a browser bundle that imports it holds none either.
5
+ */
6
+ const MESSAGE_TYPE = 'state-ui';
7
+ const EVENTS = new Set(['ready', 'logout', 'failure']);
8
+ const REASON = /^[a-z][a-z0-9_]{0,63}$/;
9
+ function isFrame(target) {
10
+ return typeof target.tagName === 'string';
11
+ }
12
+ function sessionOrigin(launch) {
13
+ const origin = URL.canParse(launch.origin) ? new URL(launch.origin) : null;
14
+ const exchange = URL.canParse(launch.exchangeUrl)
15
+ ? new URL(launch.exchangeUrl)
16
+ : null;
17
+ if (!origin ||
18
+ !exchange ||
19
+ origin.protocol !== 'https:' ||
20
+ origin.origin !== launch.origin ||
21
+ exchange.origin !== launch.origin) {
22
+ throw new TypeError('The launch must name an HTTPS session origin and an exchange URL on it.');
23
+ }
24
+ return launch.origin;
25
+ }
26
+ /**
27
+ * Posts the launch's grant to its exchange URL, targeted at `target`: an
28
+ * iframe for an `embedded` launch, or a window for a `page` launch. Open the
29
+ * window in the click handler, such as with `window.open('about:blank',
30
+ * name)`, so the browser does not block it. The session then loads in
31
+ * `target`, and a window loses its `opener`. A launch posts once; a second
32
+ * post of the same grant is refused.
33
+ *
34
+ * The posting page must send its `Origin`, so its `Referrer-Policy` must not
35
+ * be `no-referrer`.
36
+ */
37
+ export function submitLaunch(launch, target) {
38
+ sessionOrigin(launch);
39
+ const frame = isFrame(target);
40
+ if (frame !== (launch.mode === 'embedded')) {
41
+ throw new TypeError(launch.mode === 'embedded'
42
+ ? 'Post an embedded launch into an iframe.'
43
+ : 'Post a page launch into a window.');
44
+ }
45
+ if (!target.name) {
46
+ const name = `state-ui-${launch.sessionId}`;
47
+ target.name = name;
48
+ if (frame) {
49
+ // Chromium and WebKit keep the name an iframe's frame had when it was
50
+ // attached, so a later name attribute alone sends the form to a new
51
+ // window. Name the frame's window too.
52
+ try {
53
+ target.contentWindow.name = name;
54
+ }
55
+ catch {
56
+ throw new TypeError('Name the iframe before you attach it, or let the page reach its frame.');
57
+ }
58
+ }
59
+ }
60
+ const document = frame ? target.ownerDocument : globalThis.document;
61
+ const form = document.createElement('form');
62
+ form.method = 'post';
63
+ form.action = launch.exchangeUrl;
64
+ form.target = target.name;
65
+ form.hidden = true;
66
+ const grant = document.createElement('input');
67
+ grant.type = 'hidden';
68
+ grant.name = 'grant';
69
+ grant.value = launch.grant;
70
+ form.append(grant);
71
+ document.body.append(form);
72
+ try {
73
+ form.submit();
74
+ }
75
+ finally {
76
+ form.remove();
77
+ }
78
+ if (!frame) {
79
+ // The session page gets no handle on this page. Clearing it before the
80
+ // submit makes WebKit open another window instead.
81
+ target.opener = null;
82
+ }
83
+ }
84
+ function hasExactKeys(value, keys) {
85
+ const own = Object.keys(value);
86
+ return (own.length === keys.length && keys.every((key) => Object.hasOwn(value, key)));
87
+ }
88
+ /**
89
+ * The session message in `data`, or null when `data` is not exactly one of
90
+ * the messages for `sessionId`. A failure may carry a null session ID.
91
+ */
92
+ export function parseSessionMessage(data, sessionId) {
93
+ if (typeof data !== 'object' || data === null || Array.isArray(data)) {
94
+ return null;
95
+ }
96
+ const fields = data;
97
+ const { type, event, reason, sessionId: id } = fields;
98
+ if (type !== MESSAGE_TYPE || !EVENTS.has(event)) {
99
+ return null;
100
+ }
101
+ if (event === 'failure') {
102
+ if (!(hasExactKeys(fields, ['type', 'event', 'sessionId']) ||
103
+ hasExactKeys(fields, ['type', 'event', 'sessionId', 'reason'])) ||
104
+ (id !== sessionId && id !== null) ||
105
+ (reason !== undefined &&
106
+ !(typeof reason === 'string' && REASON.test(reason)))) {
107
+ return null;
108
+ }
109
+ return {
110
+ event,
111
+ sessionId: id,
112
+ reason: typeof reason === 'string' ? reason : null,
113
+ };
114
+ }
115
+ return hasExactKeys(fields, ['type', 'event', 'sessionId']) &&
116
+ id === sessionId
117
+ ? { event: event, sessionId }
118
+ : null;
119
+ }
120
+ /**
121
+ * Calls `onMessage` with each message that the session in `source` posts:
122
+ * only from the launch's exact origin, only from `source`'s window, and only
123
+ * for the launch's session. Every other message is ignored. Answers the
124
+ * function that removes the listener.
125
+ */
126
+ export function listenToSession(launch, source, onMessage, options = {}) {
127
+ const launcher = isFrame(source)
128
+ ? source.ownerDocument.defaultView
129
+ : globalThis.window;
130
+ if (!launcher) {
131
+ throw new TypeError('The iframe is not in a window.');
132
+ }
133
+ const listener = (event) => {
134
+ const from = isFrame(source) ? source.contentWindow : source;
135
+ if (event.origin !== launch.origin || !from || event.source !== from) {
136
+ return;
137
+ }
138
+ const message = parseSessionMessage(event.data, launch.sessionId);
139
+ if (message) {
140
+ onMessage(message);
141
+ }
142
+ };
143
+ const remove = () => {
144
+ launcher.removeEventListener('message', listener);
145
+ options.signal?.removeEventListener('abort', remove);
146
+ };
147
+ if (options.signal?.aborted) {
148
+ return remove;
149
+ }
150
+ launcher.addEventListener('message', listener);
151
+ options.signal?.addEventListener('abort', remove, { once: true });
152
+ return remove;
153
+ }
@@ -0,0 +1,15 @@
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
+ /**
13
+ * Launches a browser session of one actor in an app's UI. The answer holds a one-use grant and no reusable credential. Return it only to the browser of the user it is for, which posts the grant to `exchangeUrl` from `launcherOrigin`.
14
+ */
15
+ export declare function launchUiSession(client: StateMachinesCore, request: operations.LaunchUiSessionRequest, options?: RequestOptions): APIPromise<Result<models.UiSessionLaunch, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
@@ -0,0 +1,101 @@
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 models from "../models/index.js";
14
+ import * as operations from "../models/operations/index.js";
15
+ import { APIPromise } from "../types/async.js";
16
+ /**
17
+ * Launches a browser session of one actor in an app's UI. The answer holds a one-use grant and no reusable credential. Return it only to the browser of the user it is for, which posts the grant to `exchangeUrl` from `launcherOrigin`.
18
+ */
19
+ export function launchUiSession(client, request, options) {
20
+ return new APIPromise($do(client, request, options));
21
+ }
22
+ async function $do(client, request, options) {
23
+ const parsed = safeParse(request, (value) => z.parse(operations.LaunchUiSessionRequest$outboundSchema, value), "Input validation failed");
24
+ if (!parsed.ok) {
25
+ return [parsed, { status: "invalid" }];
26
+ }
27
+ const payload = parsed.value;
28
+ const body = encodeJSON("body", payload.body, { explode: true });
29
+ const pathParams = {
30
+ appName: encodeSimple("appName", payload.appName, {
31
+ explode: false,
32
+ charEncoding: "percent",
33
+ }),
34
+ environmentId: encodeSimple("environmentId", payload.environmentId, {
35
+ explode: false,
36
+ charEncoding: "percent",
37
+ }),
38
+ };
39
+ const path = pathToFunc("/v1/environments/{environmentId}/apps/{appName}/ui-sessions")(pathParams);
40
+ const headers = new Headers(compactMap({
41
+ "Content-Type": "application/json",
42
+ Accept: "application/json",
43
+ }));
44
+ const secConfig = await extractSecurity(client._options.apiKey);
45
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
46
+ const requestSecurity = resolveGlobalSecurity(securityInput);
47
+ const context = {
48
+ options: client._options,
49
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
50
+ operationID: "launchUiSession",
51
+ oAuth2Scopes: null,
52
+ resolvedSecurity: requestSecurity,
53
+ securitySource: client._options.apiKey,
54
+ retryConfig: options?.retries
55
+ || client._options.retryConfig
56
+ || {
57
+ strategy: "backoff",
58
+ backoff: {
59
+ initialInterval: 1000,
60
+ maxInterval: 5000,
61
+ exponent: 1.5,
62
+ maxElapsedTime: 600000,
63
+ },
64
+ retryConnectionErrors: true,
65
+ }
66
+ || { strategy: "none" },
67
+ retryCodes: options?.retryCodes || ["502", "503", "504"],
68
+ };
69
+ const requestRes = client._createRequest(context, {
70
+ security: requestSecurity,
71
+ method: "POST",
72
+ baseURL: options?.serverURL,
73
+ path: path,
74
+ headers: headers,
75
+ body: body,
76
+ userAgent: client._options.userAgent,
77
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
78
+ }, options);
79
+ if (!requestRes.ok) {
80
+ return [requestRes, { status: "invalid" }];
81
+ }
82
+ const req = requestRes.value;
83
+ const doResult = await client._do(req, {
84
+ context,
85
+ isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
86
+ retryConfig: context.retryConfig,
87
+ retryCodes: context.retryCodes,
88
+ });
89
+ if (!doResult.ok) {
90
+ return [doResult, { status: "request-error", request: req }];
91
+ }
92
+ const response = doResult.value;
93
+ const responseFields = {
94
+ HttpMeta: { Response: response, Request: req },
95
+ };
96
+ const [result] = await M.match(M.json(201, models.UiSessionLaunch$inboundSchema), M.jsonErr([400, 401, 403, 404, 409, 413, 422, 429], errors.ErrorT$inboundSchema), M.jsonErr([500, 503], errors.ErrorT$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
97
+ if (!result.ok) {
98
+ return [result, { status: "complete", request: req, response }];
99
+ }
100
+ return [result, { status: "complete", request: req, response }];
101
+ }
@@ -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 listSnapshotCreators(client: StateMachinesCore, request?: operations.ListSnapshotCreatorsRequest | undefined, options?: RequestOptions): APIPromise<Result<operations.ListSnapshotCreatorsResponse, errors.ErrorT | 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 listSnapshotCreators(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.ListSnapshotCreatorsRequest$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/snapshots/creators")();
26
+ const query = encodeFormQuery({
27
+ "workspaceId": payload?.workspaceId,
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: "listSnapshotCreators",
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.ListSnapshotCreatorsResponse$inboundSchema), M.jsonErr([400, 401, 403, 404, 409, 413, 422, 429], errors.ErrorT$inboundSchema), M.jsonErr([500, 503], errors.ErrorT$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,15 @@
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
+ /**
13
+ * Revokes a browser session that the caller's own credential launched. Revoking again answers the same result. Another credential's session is not found.
14
+ */
15
+ export declare function revokeUiSession(client: StateMachinesCore, request: operations.RevokeUiSessionRequest, options?: RequestOptions): APIPromise<Result<models.UiSessionRevocation, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
@@ -0,0 +1,104 @@
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 models from "../models/index.js";
14
+ import * as operations from "../models/operations/index.js";
15
+ import { APIPromise } from "../types/async.js";
16
+ /**
17
+ * Revokes a browser session that the caller's own credential launched. Revoking again answers the same result. Another credential's session is not found.
18
+ */
19
+ export function revokeUiSession(client, request, options) {
20
+ return new APIPromise($do(client, request, options));
21
+ }
22
+ async function $do(client, request, options) {
23
+ const parsed = safeParse(request, (value) => z.parse(operations.RevokeUiSessionRequest$outboundSchema, value), "Input validation failed");
24
+ if (!parsed.ok) {
25
+ return [parsed, { status: "invalid" }];
26
+ }
27
+ const payload = parsed.value;
28
+ const body = null;
29
+ const pathParams = {
30
+ appName: encodeSimple("appName", payload.appName, {
31
+ explode: false,
32
+ charEncoding: "percent",
33
+ }),
34
+ environmentId: encodeSimple("environmentId", payload.environmentId, {
35
+ explode: false,
36
+ charEncoding: "percent",
37
+ }),
38
+ sessionId: encodeSimple("sessionId", payload.sessionId, {
39
+ explode: false,
40
+ charEncoding: "percent",
41
+ }),
42
+ };
43
+ const path = pathToFunc("/v1/environments/{environmentId}/apps/{appName}/ui-sessions/{sessionId}")(pathParams);
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: "revokeUiSession",
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: "DELETE",
75
+ baseURL: options?.serverURL,
76
+ path: path,
77
+ headers: headers,
78
+ body: body,
79
+ userAgent: client._options.userAgent,
80
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
81
+ }, options);
82
+ if (!requestRes.ok) {
83
+ return [requestRes, { status: "invalid" }];
84
+ }
85
+ const req = requestRes.value;
86
+ const doResult = await client._do(req, {
87
+ context,
88
+ isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
89
+ retryConfig: context.retryConfig,
90
+ retryCodes: context.retryCodes,
91
+ });
92
+ if (!doResult.ok) {
93
+ return [doResult, { status: "request-error", request: req }];
94
+ }
95
+ const response = doResult.value;
96
+ const responseFields = {
97
+ HttpMeta: { Response: response, Request: req },
98
+ };
99
+ const [result] = await M.match(M.json(200, models.UiSessionRevocation$inboundSchema), M.jsonErr([400, 401, 403, 404, 409, 413, 422, 429], errors.ErrorT$inboundSchema), M.jsonErr([500, 503], errors.ErrorT$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
100
+ if (!result.ok) {
101
+ return [result, { status: "complete", request: req, response }];
102
+ }
103
+ return [result, { status: "complete", request: req, response }];
104
+ }
@@ -24,9 +24,12 @@ async function $do(client, request, options) {
24
24
  const body = null;
25
25
  const path = pathToFunc("/v1/snapshots")();
26
26
  const query = encodeFormQuery({
27
+ "appId": payload?.appId,
28
+ "createdBy": payload?.createdBy,
27
29
  "cursor": payload?.cursor,
28
30
  "environmentId": payload?.environmentId,
29
31
  "limit": payload?.limit,
32
+ "search": payload?.search,
30
33
  "status": payload?.status,
31
34
  "workspaceId": payload?.workspaceId,
32
35
  });
@@ -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.8.1";
34
+ readonly sdkVersion: "0.9.1";
35
35
  readonly genVersion: "2.941.0";
36
- readonly userAgent: "speakeasy-sdk/typescript 0.8.1 2.941.0 1.0.0 @usestatemachines/sdk";
36
+ readonly userAgent: "speakeasy-sdk/typescript 0.9.1 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.8.1",
27
+ sdkVersion: "0.9.1",
28
28
  genVersion: "2.941.0",
29
- userAgent: "speakeasy-sdk/typescript 0.8.1 2.941.0 1.0.0 @usestatemachines/sdk",
29
+ userAgent: "speakeasy-sdk/typescript 0.9.1 2.941.0 1.0.0 @usestatemachines/sdk",
30
30
  };
@@ -0,0 +1,12 @@
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 BrowserCapability = {
5
+ acceptsClients: Array<string>;
6
+ contract: string;
7
+ documents: Array<string>;
8
+ entry: string;
9
+ };
10
+ /** @internal */
11
+ export declare const BrowserCapability$inboundSchema: z.ZodMiniType<BrowserCapability, unknown>;
12
+ export declare function browserCapabilityFromJSON(jsonString: string): SafeParseResult<BrowserCapability, SDKValidationError>;
@@ -0,0 +1,16 @@
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 BrowserCapability$inboundSchema = z.object({
9
+ acceptsClients: z.array(types.string()),
10
+ contract: types.string(),
11
+ documents: z.array(types.string()),
12
+ entry: types.string(),
13
+ });
14
+ export function browserCapabilityFromJSON(jsonString) {
15
+ return safeParse(jsonString, (x) => BrowserCapability$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BrowserCapability' from JSON`);
16
+ }
@@ -5,8 +5,13 @@ import { EnvironmentFailure } from "./environment-failure.js";
5
5
  import { EnvironmentStatus } from "./environment-status.js";
6
6
  import { SDKValidationError } from "./errors/sdk-validation-error.js";
7
7
  import { Principal } from "./principal.js";
8
+ export type BrowserService = {
9
+ documents: Array<string>;
10
+ id: string;
11
+ };
8
12
  export type EnvironmentApp = {
9
13
  appId: string;
14
+ browserServices?: Array<BrowserService> | undefined;
10
15
  name: string;
11
16
  services: {
12
17
  [k: string]: any;
@@ -45,6 +50,9 @@ export type Environment = {
45
50
  workspaceId: string;
46
51
  };
47
52
  /** @internal */
53
+ export declare const BrowserService$inboundSchema: z.ZodMiniType<BrowserService, unknown>;
54
+ export declare function browserServiceFromJSON(jsonString: string): SafeParseResult<BrowserService, SDKValidationError>;
55
+ /** @internal */
48
56
  export declare const EnvironmentApp$inboundSchema: z.ZodMiniType<EnvironmentApp, unknown>;
49
57
  export declare function environmentAppFromJSON(jsonString: string): SafeParseResult<EnvironmentApp, SDKValidationError>;
50
58
  /** @internal */
@@ -14,8 +14,17 @@ export const Reason = {
14
14
  Failed: "failed",
15
15
  };
16
16
  /** @internal */
17
+ export const BrowserService$inboundSchema = z.object({
18
+ documents: z.array(types.string()),
19
+ id: types.string(),
20
+ });
21
+ export function browserServiceFromJSON(jsonString) {
22
+ return safeParse(jsonString, (x) => BrowserService$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BrowserService' from JSON`);
23
+ }
24
+ /** @internal */
17
25
  export const EnvironmentApp$inboundSchema = z.object({
18
26
  appId: types.string(),
27
+ browserServices: types.optional(z.array(z.lazy(() => BrowserService$inboundSchema))),
19
28
  name: types.string(),
20
29
  services: z.record(z.string(), z.any()),
21
30
  setup: z.record(z.string(), z.any()),