@usestatemachines/sdk 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -3
- package/agents/SKILL.md +46 -30
- package/agents/index.js +6 -6
- package/agents/llms.txt +15 -8
- package/agents/prompt.md +1 -1
- package/esm/extensions/client.d.ts +31 -1
- package/esm/extensions/client.js +74 -2
- package/esm/extensions/errors.d.ts +7 -0
- package/esm/extensions/errors.js +46 -2
- package/esm/extensions/index.d.ts +2 -2
- package/esm/funcs/imports-complete.d.ts +12 -0
- package/esm/funcs/imports-complete.js +93 -0
- package/esm/funcs/imports-create.d.ts +12 -0
- package/esm/funcs/imports-create.js +89 -0
- package/esm/funcs/imports-delete.d.ts +12 -0
- package/esm/funcs/imports-delete.js +93 -0
- package/esm/funcs/imports-get.d.ts +12 -0
- package/esm/funcs/imports-get.js +93 -0
- package/esm/funcs/imports-list.d.ts +11 -0
- package/esm/funcs/imports-list.js +93 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/absent-reason.d.ts +36 -0
- package/esm/models/absent-reason.js +44 -0
- package/esm/models/absent-record-source.d.ts +13 -0
- package/esm/models/absent-record-source.js +14 -0
- package/esm/models/absent-record.d.ts +23 -0
- package/esm/models/absent-record.js +18 -0
- package/esm/models/create-snapshot-from-environment.d.ts +13 -0
- package/esm/models/create-snapshot-from-environment.js +12 -0
- package/esm/models/create-snapshot-from-import.d.ts +16 -0
- package/esm/models/create-snapshot-from-import.js +12 -0
- package/esm/models/create-snapshot.d.ts +9 -0
- package/esm/models/create-snapshot.js +14 -0
- package/esm/models/created-import.d.ts +38 -0
- package/esm/models/created-import.js +30 -0
- package/esm/models/import-problem.d.ts +40 -0
- package/esm/models/import-problem.js +28 -0
- package/esm/models/import-status.d.ts +13 -0
- package/esm/models/import-status.js +14 -0
- package/esm/models/import.d.ts +45 -0
- package/esm/models/import.js +36 -0
- package/esm/models/index.d.ts +12 -0
- package/esm/models/index.js +12 -0
- package/esm/models/operations/complete-import.d.ts +11 -0
- package/esm/models/operations/complete-import.js +11 -0
- package/esm/models/operations/create-import.d.ts +36 -0
- package/esm/models/operations/create-import.js +26 -0
- package/esm/models/operations/create-snapshot.d.ts +3 -14
- package/esm/models/operations/create-snapshot.js +2 -9
- package/esm/models/operations/delete-import.d.ts +11 -0
- package/esm/models/operations/delete-import.js +11 -0
- package/esm/models/operations/get-import.d.ts +11 -0
- package/esm/models/operations/get-import.js +11 -0
- package/esm/models/operations/index.d.ts +5 -0
- package/esm/models/operations/index.js +5 -0
- package/esm/models/operations/list-imports.d.ts +30 -0
- package/esm/models/operations/list-imports.js +25 -0
- package/esm/models/snapshot-app-load.d.ts +20 -0
- package/esm/models/snapshot-app-load.js +15 -0
- package/esm/models/snapshot-failure-union.d.ts +40 -0
- package/esm/models/snapshot-failure-union.js +42 -0
- package/esm/models/snapshot.d.ts +15 -17
- package/esm/models/snapshot.js +6 -17
- package/esm/sdk/imports.d.ts +10 -0
- package/esm/sdk/imports.js +27 -0
- package/esm/sdk/sdk.d.ts +3 -0
- package/esm/sdk/sdk.js +5 -0
- package/openapi.json +1258 -184
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { App } from '../models/app.js';
|
|
2
2
|
import type { AuditEvent } from '../models/audit-event.js';
|
|
3
3
|
import type { CreateEnvironment } from '../models/create-environment.js';
|
|
4
|
+
import type { Import } from '../models/import.js';
|
|
4
5
|
import type { Me } from '../models/me.js';
|
|
5
6
|
import type { CreateCredentialsRequestBody } from '../models/operations/create-credentials.js';
|
|
6
7
|
import type { GetRequestStatsRequest } from '../models/operations/get-request-stats.js';
|
|
7
8
|
import type { ListAuditEventsRequest } from '../models/operations/list-audit-events.js';
|
|
8
9
|
import type { ListEnvironmentsRequest } from '../models/operations/list-environments.js';
|
|
10
|
+
import type { ListImportsRequest } from '../models/operations/list-imports.js';
|
|
9
11
|
import type { ListRequestsRequest } from '../models/operations/list-requests.js';
|
|
10
12
|
import type { ListSnapshotsRequest } from '../models/operations/list-snapshots.js';
|
|
11
13
|
import type { ListWorkspacesRequest } from '../models/operations/list-workspaces.js';
|
|
@@ -42,6 +44,12 @@ export interface CreateEnvironmentOptions extends SignalOptions {
|
|
|
42
44
|
idempotencyKey?: string;
|
|
43
45
|
}
|
|
44
46
|
export type CreateSnapshotOptions = CreateEnvironmentOptions;
|
|
47
|
+
export interface UploadImportOptions extends SignalOptions {
|
|
48
|
+
/** The import's workspace. Defaults to the client's `workspaceId`; an API key has its own. */
|
|
49
|
+
workspaceId?: string;
|
|
50
|
+
/** A repeat with the same key and the same bytes finds the same import. Defaults to a new UUID. */
|
|
51
|
+
idempotencyKey?: string;
|
|
52
|
+
}
|
|
45
53
|
/**
|
|
46
54
|
* The body of the credentials call. `actorId` defaults to the app's default
|
|
47
55
|
* actor (for Salesforce, the administrator). `services` names more services
|
|
@@ -59,6 +67,7 @@ export type PageQuery = {
|
|
|
59
67
|
};
|
|
60
68
|
export type ListEnvironmentsQuery = ListEnvironmentsRequest;
|
|
61
69
|
export type ListSnapshotsQuery = ListSnapshotsRequest;
|
|
70
|
+
export type ListImportsQuery = ListImportsRequest;
|
|
62
71
|
export type ListAuditEventsQuery = ListAuditEventsRequest;
|
|
63
72
|
export type ListWorkspacesQuery = ListWorkspacesRequest;
|
|
64
73
|
export type ListRequestsQuery = ListRequestsRequest;
|
|
@@ -96,10 +105,18 @@ export declare class StateMachines {
|
|
|
96
105
|
connect: (environmentId: string, appName: string, options?: ConnectOptions) => Promise<Credentials>;
|
|
97
106
|
};
|
|
98
107
|
readonly snapshots: {
|
|
99
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Creates a snapshot of a running environment, or builds one from a `ready` import,
|
|
110
|
+
* and, unless `wait` is false, waits until it is `ready`. A snapshot from an import
|
|
111
|
+
* takes every app of the import, each on its default version, with empty setup and
|
|
112
|
+
* services. An import that an app refuses throws `SnapshotFailedError` with its problems.
|
|
113
|
+
*/
|
|
100
114
|
create: (input: {
|
|
101
115
|
environmentId: string;
|
|
102
116
|
name?: string | null;
|
|
117
|
+
} | {
|
|
118
|
+
importId: string;
|
|
119
|
+
name?: string | null;
|
|
103
120
|
}, options?: CreateEnvironmentOptions) => Promise<Snapshot>;
|
|
104
121
|
/** Newest first. Leaves deleted snapshots out unless `status` asks for them. */
|
|
105
122
|
list: (query?: ListSnapshotsRequest) => Promise<Page<Snapshot>>;
|
|
@@ -116,6 +133,19 @@ export declare class StateMachines {
|
|
|
116
133
|
*/
|
|
117
134
|
wait: (snapshotId: string, options: WaitOptions<KnownSnapshotStatus>) => Promise<Snapshot>;
|
|
118
135
|
};
|
|
136
|
+
readonly imports: {
|
|
137
|
+
/**
|
|
138
|
+
* Uploads an import's zip file and resolves with the import as its check left it:
|
|
139
|
+
* `ready`, or `invalid` with its problems. An import that is no longer `uploading` resolves
|
|
140
|
+
* as it is. The zip file goes to the upload URL under `signal` alone, without `attemptTimeoutMs`.
|
|
141
|
+
*/
|
|
142
|
+
upload: (zip: Uint8Array<ArrayBufferLike>, options?: UploadImportOptions) => Promise<Import>;
|
|
143
|
+
/** Newest first. Leaves deleted imports out unless `status` asks for them. */
|
|
144
|
+
list: (query?: ListImportsRequest) => Promise<Page<Import>>;
|
|
145
|
+
get: (importId: string) => Promise<Import>;
|
|
146
|
+
/** Removes the import's zip file once no build reads it. Snapshots built from it keep their data. Safe to repeat. */
|
|
147
|
+
delete: (importId: string, options?: SignalOptions) => Promise<Import>;
|
|
148
|
+
};
|
|
119
149
|
readonly requests: {
|
|
120
150
|
/** Calls the gateway recorded for one environment, newest first. Recording is best effort. */
|
|
121
151
|
list: (query: ListRequestsRequest) => Promise<Page<Request>>;
|
package/esm/extensions/client.js
CHANGED
|
@@ -2,7 +2,7 @@ import { SDK_METADATA } from '../lib/config.js';
|
|
|
2
2
|
import { HTTPClient } from '../lib/http.js';
|
|
3
3
|
import { StateMachines as Generated } from '../sdk/sdk.js';
|
|
4
4
|
import { bindCredentials } from './credentials.js';
|
|
5
|
-
import { CallerAbortedError, toStateMachinesError } from './errors.js';
|
|
5
|
+
import { CallerAbortedError, StateMachinesError, toStateMachinesError, uploadRefused, uploadUnanswered, } from './errors.js';
|
|
6
6
|
import { linkSignal } from './signal.js';
|
|
7
7
|
import { environmentAt, poll, snapshotAt, } from './wait.js';
|
|
8
8
|
export class StateMachines {
|
|
@@ -83,7 +83,12 @@ export class StateMachines {
|
|
|
83
83
|
connect: (environmentId, appName, options = {}) => this.#connect(environmentId, appName, options),
|
|
84
84
|
};
|
|
85
85
|
snapshots = {
|
|
86
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Creates a snapshot of a running environment, or builds one from a `ready` import,
|
|
88
|
+
* and, unless `wait` is false, waits until it is `ready`. A snapshot from an import
|
|
89
|
+
* takes every app of the import, each on its default version, with empty setup and
|
|
90
|
+
* services. An import that an app refuses throws `SnapshotFailedError` with its problems.
|
|
91
|
+
*/
|
|
87
92
|
create: async (input, options = {}) => {
|
|
88
93
|
const idempotencyKey = options.idempotencyKey ?? crypto.randomUUID();
|
|
89
94
|
const created = await this.#call(options.signal, (call) => this.#sdk.snapshots.create({ idempotencyKey, body: input }, call));
|
|
@@ -107,6 +112,36 @@ export class StateMachines {
|
|
|
107
112
|
*/
|
|
108
113
|
wait: (snapshotId, options) => poll(snapshotId, (signal) => this.#read(signal, (call) => this.#sdk.snapshots.get({ snapshotId }, call)), snapshotAt(options.status), options),
|
|
109
114
|
};
|
|
115
|
+
imports = {
|
|
116
|
+
/**
|
|
117
|
+
* Uploads an import's zip file and resolves with the import as its check left it:
|
|
118
|
+
* `ready`, or `invalid` with its problems. An import that is no longer `uploading` resolves
|
|
119
|
+
* as it is. The zip file goes to the upload URL under `signal` alone, without `attemptTimeoutMs`.
|
|
120
|
+
*/
|
|
121
|
+
upload: async (zip, options = {}) => {
|
|
122
|
+
const { signal } = options;
|
|
123
|
+
const bytes = unshared(zip);
|
|
124
|
+
const idempotencyKey = options.idempotencyKey ?? crypto.randomUUID();
|
|
125
|
+
const body = this.#inWorkspace({
|
|
126
|
+
...(options.workspaceId === undefined
|
|
127
|
+
? {}
|
|
128
|
+
: { workspaceId: options.workspaceId }),
|
|
129
|
+
sizeBytes: bytes.byteLength,
|
|
130
|
+
digest: await sha256(bytes),
|
|
131
|
+
});
|
|
132
|
+
const created = await this.#call(signal, (call) => this.#sdk.imports.create({ idempotencyKey, body }, call));
|
|
133
|
+
if (created.upload === null) {
|
|
134
|
+
return created.import;
|
|
135
|
+
}
|
|
136
|
+
await this.#send(created.upload, bytes, signal);
|
|
137
|
+
return this.#call(signal, (call) => this.#sdk.imports.complete({ importId: created.import.id }, call));
|
|
138
|
+
},
|
|
139
|
+
/** Newest first. Leaves deleted imports out unless `status` asks for them. */
|
|
140
|
+
list: (query = {}) => this.#call(undefined, (call) => this.#sdk.imports.list(this.#inWorkspace(query), call)),
|
|
141
|
+
get: (importId) => this.#call(undefined, (call) => this.#sdk.imports.get({ importId }, call)),
|
|
142
|
+
/** Removes the import's zip file once no build reads it. Snapshots built from it keep their data. Safe to repeat. */
|
|
143
|
+
delete: (importId, options = {}) => this.#call(options.signal, (call) => this.#sdk.imports.delete({ importId }, call)),
|
|
144
|
+
};
|
|
110
145
|
requests = {
|
|
111
146
|
/** Calls the gateway recorded for one environment, newest first. Recording is best effort. */
|
|
112
147
|
list: (query) => this.#call(undefined, (call) => this.#sdk.requests.list(query, call)),
|
|
@@ -137,6 +172,34 @@ export class StateMachines {
|
|
|
137
172
|
const credentials = await this.#call(undefined, (call) => this.#sdk.environments.connect({ environmentId, appName, body }, call));
|
|
138
173
|
return bindCredentials(credentials, this.#fetch);
|
|
139
174
|
}
|
|
175
|
+
async #send(upload, zip, signal) {
|
|
176
|
+
const fetcher = this.#fetch ?? fetch;
|
|
177
|
+
const scope = linkSignal(signal);
|
|
178
|
+
// fetch sets Content-Length from the body, and a browser refuses to set it.
|
|
179
|
+
const headers = Object.entries(upload.headers).filter(([name]) => name.toLowerCase() !== 'content-length');
|
|
180
|
+
try {
|
|
181
|
+
const response = await fetcher(new Request(upload.url, {
|
|
182
|
+
method: upload.method,
|
|
183
|
+
headers,
|
|
184
|
+
body: zip,
|
|
185
|
+
signal: scope.signal,
|
|
186
|
+
}));
|
|
187
|
+
// A bucket answers 412 to `If-None-Match: *` once the bytes arrived.
|
|
188
|
+
if (!(response.ok || response.status === 409 || response.status === 412)) {
|
|
189
|
+
throw uploadRefused(response);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
throw signal?.aborted
|
|
194
|
+
? toStateMachinesError(new CallerAbortedError(signal.reason))
|
|
195
|
+
: error instanceof StateMachinesError
|
|
196
|
+
? error
|
|
197
|
+
: uploadUnanswered(error);
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
scope.close();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
140
203
|
#bind(data) {
|
|
141
204
|
const { id } = data;
|
|
142
205
|
const helpers = {
|
|
@@ -216,6 +279,15 @@ function addAttemptTimeout(httpClient, timeoutMs, calls) {
|
|
|
216
279
|
}
|
|
217
280
|
});
|
|
218
281
|
}
|
|
282
|
+
function unshared(bytes) {
|
|
283
|
+
return bytes.buffer instanceof ArrayBuffer
|
|
284
|
+
? new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
285
|
+
: new Uint8Array(bytes);
|
|
286
|
+
}
|
|
287
|
+
async function sha256(bytes) {
|
|
288
|
+
const hash = new Uint8Array(await crypto.subtle.digest('SHA-256', bytes));
|
|
289
|
+
return `sha256:${Array.from(hash, (byte) => byte.toString(16).padStart(2, '0')).join('')}`;
|
|
290
|
+
}
|
|
219
291
|
function waitOptions(options) {
|
|
220
292
|
return {
|
|
221
293
|
...(options.timeoutMs === undefined
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Environment as EnvironmentData } from '../models/environment.js';
|
|
2
2
|
import type { ErrorCode } from '../models/error.js';
|
|
3
|
+
import type { ImportProblem } from '../models/import-problem.js';
|
|
3
4
|
import type { Snapshot } from '../models/snapshot.js';
|
|
4
5
|
export interface ErrorDetails {
|
|
5
6
|
readonly message: string;
|
|
@@ -37,6 +38,8 @@ export declare class EnvironmentFailedError extends StateMachinesError {
|
|
|
37
38
|
export declare class SnapshotFailedError extends StateMachinesError {
|
|
38
39
|
readonly snapshot: Snapshot;
|
|
39
40
|
readonly name = "SnapshotFailedError";
|
|
41
|
+
/** The problems of an import that an app refused, errors before warnings. Empty for every other failure. */
|
|
42
|
+
readonly problems: readonly ImportProblem[];
|
|
40
43
|
constructor(snapshot: Snapshot);
|
|
41
44
|
}
|
|
42
45
|
/** The resource reached a status from which the awaited one needs a call of yours. */
|
|
@@ -58,6 +61,10 @@ export declare class CallerAbortedError extends Error {
|
|
|
58
61
|
readonly name = "CallerAbortedError";
|
|
59
62
|
constructor(reason: unknown);
|
|
60
63
|
}
|
|
64
|
+
/** An upload URL that answered with a status that ends the upload. The message never includes the body. */
|
|
65
|
+
export declare function uploadRefused(response: Response): StateMachinesError;
|
|
66
|
+
/** An upload URL that gave no answer. The message never names the URL, which carries a signature. */
|
|
67
|
+
export declare function uploadUnanswered(cause: unknown): StateMachinesError;
|
|
61
68
|
/** The SDK refused input before sending it, as the API would with `invalid_request`. */
|
|
62
69
|
export declare function invalidInput(message: string, fields: Record<string, string[]>): StateMachinesError;
|
|
63
70
|
export declare function toStateMachinesError(error: unknown): StateMachinesError;
|
package/esm/extensions/errors.js
CHANGED
|
@@ -2,6 +2,7 @@ import { ErrorT } from '../models/errors/error.js';
|
|
|
2
2
|
import { ConnectionError, RequestTimeoutError, } from '../models/errors/http-client-errors.js';
|
|
3
3
|
import { ResponseValidationError } from '../models/errors/response-validation-error.js';
|
|
4
4
|
import { StateMachinesHTTPError } from '../models/errors/state-machines-http-error.js';
|
|
5
|
+
import { isUnknown } from '../types/discriminated-union.js';
|
|
5
6
|
/**
|
|
6
7
|
* Any failed call: an error response, an invalid response, no response at all, or input
|
|
7
8
|
* the SDK refused before sending. The message never includes a response body.
|
|
@@ -54,19 +55,41 @@ export class EnvironmentFailedError extends StateMachinesError {
|
|
|
54
55
|
this.environment = environment;
|
|
55
56
|
}
|
|
56
57
|
}
|
|
58
|
+
function firstProblem(problems) {
|
|
59
|
+
const [first] = problems;
|
|
60
|
+
if (first === undefined) {
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
return problems.length === 1
|
|
64
|
+
? ` ${problemLine(first)}`
|
|
65
|
+
: ` First of ${problems.length} listed problems: ${problemLine(first)}`;
|
|
66
|
+
}
|
|
67
|
+
function problemLine(problem) {
|
|
68
|
+
const place = problem.line === null ? problem.file : `${problem.file}:${problem.line}`;
|
|
69
|
+
const at = problem.pointer === null ? '' : ` ${problem.pointer || '/'}`;
|
|
70
|
+
return `${place}${at} ${problem.severity} ${problem.code} ${problem.message}`;
|
|
71
|
+
}
|
|
57
72
|
/** A snapshot that ended `failed` while the SDK waited for it. */
|
|
58
73
|
export class SnapshotFailedError extends StateMachinesError {
|
|
59
74
|
snapshot;
|
|
60
75
|
name = 'SnapshotFailedError';
|
|
76
|
+
/** The problems of an import that an app refused, errors before warnings. Empty for every other failure. */
|
|
77
|
+
problems;
|
|
61
78
|
constructor(snapshot) {
|
|
62
|
-
const failure = snapshot.failure
|
|
79
|
+
const failure = snapshot.failure === null || isUnknown(snapshot.failure)
|
|
80
|
+
? null
|
|
81
|
+
: snapshot.failure;
|
|
82
|
+
const refused = failure?.code === 'invalid_import' ? failure : null;
|
|
83
|
+
const problems = refused?.problems ?? [];
|
|
84
|
+
const app = refused?.appName === undefined ? '' : `, app ${refused.appName}`;
|
|
63
85
|
super({
|
|
64
86
|
...noResponse,
|
|
65
87
|
message: failure
|
|
66
|
-
? `Snapshot ${snapshot.id} failed: ${failure.message} (${failure.code})
|
|
88
|
+
? `Snapshot ${snapshot.id} failed: ${failure.message} (${failure.code}${app}).${firstProblem(problems)}`
|
|
67
89
|
: `Snapshot ${snapshot.id} failed.`,
|
|
68
90
|
});
|
|
69
91
|
this.snapshot = snapshot;
|
|
92
|
+
this.problems = problems;
|
|
70
93
|
}
|
|
71
94
|
}
|
|
72
95
|
/** The resource reached a status from which the awaited one needs a call of yours. */
|
|
@@ -98,6 +121,27 @@ export class CallerAbortedError extends Error {
|
|
|
98
121
|
super('The caller aborted the request.', { cause: reason });
|
|
99
122
|
}
|
|
100
123
|
}
|
|
124
|
+
/** An upload URL that answered with a status that ends the upload. The message never includes the body. */
|
|
125
|
+
export function uploadRefused(response) {
|
|
126
|
+
const details = {
|
|
127
|
+
...noResponse,
|
|
128
|
+
message: `HTTP ${response.status} from the upload URL`,
|
|
129
|
+
status: response.status,
|
|
130
|
+
requestId: response.headers.get('request-id'),
|
|
131
|
+
retryAfterMs: retryAfterMs(response.headers),
|
|
132
|
+
};
|
|
133
|
+
return retryableStatuses.has(response.status)
|
|
134
|
+
? transientError(details)
|
|
135
|
+
: new StateMachinesError(details);
|
|
136
|
+
}
|
|
137
|
+
/** An upload URL that gave no answer. The message never names the URL, which carries a signature. */
|
|
138
|
+
export function uploadUnanswered(cause) {
|
|
139
|
+
return transientError({
|
|
140
|
+
...noResponse,
|
|
141
|
+
message: 'The upload URL did not answer.',
|
|
142
|
+
cause,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
101
145
|
/** The SDK refused input before sending it, as the API would with `invalid_request`. */
|
|
102
146
|
export function invalidInput(message, fields) {
|
|
103
147
|
return new StateMachinesError({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type { Actor, App, AppEntry, AuditEvent, BodyPreview, CreateEnvironment, CreateEnvironmentApp, EnvironmentApp, EnvironmentFailure, EnvironmentFailureCode, EnvironmentStatus, ErrorCode, Me, Permission, Principal, RequestDetail, RequestStats, RequestT as Request, Snapshot, SnapshotStatus, Version, Workspace, } from '../models/index.js';
|
|
2
|
-
export type { ConnectOptions, CreateEnvironmentOptions, CreateSnapshotOptions, ListAuditEventsQuery, ListEnvironmentsQuery, ListRequestsQuery, ListSnapshotsQuery, ListWorkspacesQuery, Page, PageQuery, RequestStatsQuery, SignalOptions, StateMachinesOptions, } from './client.js';
|
|
1
|
+
export type { Actor, App, AppEntry, AuditEvent, BodyPreview, CreateEnvironment, CreateEnvironmentApp, EnvironmentApp, EnvironmentFailure, EnvironmentFailureCode, EnvironmentStatus, ErrorCode, Import, ImportApp, ImportProblem, ImportStatus, Me, Permission, Principal, RequestDetail, RequestStats, RequestT as Request, Snapshot, SnapshotStatus, Version, Workspace, } from '../models/index.js';
|
|
2
|
+
export type { ConnectOptions, CreateEnvironmentOptions, CreateSnapshotOptions, ListAuditEventsQuery, ListEnvironmentsQuery, ListImportsQuery, ListRequestsQuery, ListSnapshotsQuery, ListWorkspacesQuery, Page, PageQuery, RequestStatsQuery, SignalOptions, StateMachinesOptions, UploadImportOptions, } from './client.js';
|
|
3
3
|
export { StateMachines } from './client.js';
|
|
4
4
|
export type { Credentials, McpServerCredentials, ServiceCredentials, } from './credentials.js';
|
|
5
5
|
export type { Environment, EnvironmentHelpers } from './environment.js';
|
|
@@ -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 importsComplete(client: StateMachinesCore, request: operations.CompleteImportRequest, options?: RequestOptions): APIPromise<Result<models.Import, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
6
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as models from "../models/index.js";
|
|
14
|
+
import * as operations from "../models/operations/index.js";
|
|
15
|
+
import { APIPromise } from "../types/async.js";
|
|
16
|
+
export function importsComplete(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.CompleteImportRequest$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
|
+
importId: encodeSimple("importId", payload.importId, {
|
|
28
|
+
explode: false,
|
|
29
|
+
charEncoding: "percent",
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
const path = pathToFunc("/v1/imports/{importId}/complete")(pathParams);
|
|
33
|
+
const headers = new Headers(compactMap({
|
|
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: "completeImport",
|
|
43
|
+
oAuth2Scopes: null,
|
|
44
|
+
resolvedSecurity: requestSecurity,
|
|
45
|
+
securitySource: client._options.apiKey,
|
|
46
|
+
retryConfig: options?.retries
|
|
47
|
+
|| client._options.retryConfig
|
|
48
|
+
|| {
|
|
49
|
+
strategy: "backoff",
|
|
50
|
+
backoff: {
|
|
51
|
+
initialInterval: 1000,
|
|
52
|
+
maxInterval: 5000,
|
|
53
|
+
exponent: 1.5,
|
|
54
|
+
maxElapsedTime: 600000,
|
|
55
|
+
},
|
|
56
|
+
retryConnectionErrors: true,
|
|
57
|
+
}
|
|
58
|
+
|| { strategy: "none" },
|
|
59
|
+
retryCodes: options?.retryCodes || ["502", "503", "504"],
|
|
60
|
+
};
|
|
61
|
+
const requestRes = client._createRequest(context, {
|
|
62
|
+
security: requestSecurity,
|
|
63
|
+
method: "POST",
|
|
64
|
+
baseURL: options?.serverURL,
|
|
65
|
+
path: path,
|
|
66
|
+
headers: headers,
|
|
67
|
+
body: body,
|
|
68
|
+
userAgent: client._options.userAgent,
|
|
69
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
70
|
+
}, options);
|
|
71
|
+
if (!requestRes.ok) {
|
|
72
|
+
return [requestRes, { status: "invalid" }];
|
|
73
|
+
}
|
|
74
|
+
const req = requestRes.value;
|
|
75
|
+
const doResult = await client._do(req, {
|
|
76
|
+
context,
|
|
77
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
78
|
+
retryConfig: context.retryConfig,
|
|
79
|
+
retryCodes: context.retryCodes,
|
|
80
|
+
});
|
|
81
|
+
if (!doResult.ok) {
|
|
82
|
+
return [doResult, { status: "request-error", request: req }];
|
|
83
|
+
}
|
|
84
|
+
const response = doResult.value;
|
|
85
|
+
const responseFields = {
|
|
86
|
+
HttpMeta: { Response: response, Request: req },
|
|
87
|
+
};
|
|
88
|
+
const [result] = await M.match(M.json(200, models.Import$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 });
|
|
89
|
+
if (!result.ok) {
|
|
90
|
+
return [result, { status: "complete", request: req, response }];
|
|
91
|
+
}
|
|
92
|
+
return [result, { status: "complete", request: req, response }];
|
|
93
|
+
}
|
|
@@ -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 importsCreate(client: StateMachinesCore, request: operations.CreateImportRequest, options?: RequestOptions): APIPromise<Result<models.CreatedImport, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
export function importsCreate(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.CreateImportRequest$outboundSchema, value), "Input validation failed");
|
|
21
|
+
if (!parsed.ok) {
|
|
22
|
+
return [parsed, { status: "invalid" }];
|
|
23
|
+
}
|
|
24
|
+
const payload = parsed.value;
|
|
25
|
+
const body = encodeJSON("body", payload.body, { explode: true });
|
|
26
|
+
const path = pathToFunc("/v1/imports")();
|
|
27
|
+
const headers = new Headers(compactMap({
|
|
28
|
+
"Content-Type": "application/json",
|
|
29
|
+
Accept: "application/json",
|
|
30
|
+
"idempotency-key": encodeSimple("idempotency-key", payload["idempotency-key"], { explode: false, charEncoding: "none" }),
|
|
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: "createImport",
|
|
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: "POST",
|
|
60
|
+
baseURL: options?.serverURL,
|
|
61
|
+
path: path,
|
|
62
|
+
headers: headers,
|
|
63
|
+
body: body,
|
|
64
|
+
userAgent: client._options.userAgent,
|
|
65
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
66
|
+
}, options);
|
|
67
|
+
if (!requestRes.ok) {
|
|
68
|
+
return [requestRes, { status: "invalid" }];
|
|
69
|
+
}
|
|
70
|
+
const req = requestRes.value;
|
|
71
|
+
const doResult = await client._do(req, {
|
|
72
|
+
context,
|
|
73
|
+
isErrorStatusCode: (statusCode) => matchStatusCode({ status: statusCode }, ["4XX", "5XX"]),
|
|
74
|
+
retryConfig: context.retryConfig,
|
|
75
|
+
retryCodes: context.retryCodes,
|
|
76
|
+
});
|
|
77
|
+
if (!doResult.ok) {
|
|
78
|
+
return [doResult, { status: "request-error", request: req }];
|
|
79
|
+
}
|
|
80
|
+
const response = doResult.value;
|
|
81
|
+
const responseFields = {
|
|
82
|
+
HttpMeta: { Response: response, Request: req },
|
|
83
|
+
};
|
|
84
|
+
const [result] = await M.match(M.json([200, 201], models.CreatedImport$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 });
|
|
85
|
+
if (!result.ok) {
|
|
86
|
+
return [result, { status: "complete", request: req, response }];
|
|
87
|
+
}
|
|
88
|
+
return [result, { status: "complete", request: req, response }];
|
|
89
|
+
}
|
|
@@ -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 importsDelete(client: StateMachinesCore, request: operations.DeleteImportRequest, options?: RequestOptions): APIPromise<Result<models.Import, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
6
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import * as errors from "../models/errors/index.js";
|
|
13
|
+
import * as models from "../models/index.js";
|
|
14
|
+
import * as operations from "../models/operations/index.js";
|
|
15
|
+
import { APIPromise } from "../types/async.js";
|
|
16
|
+
export function importsDelete(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.DeleteImportRequest$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
|
+
importId: encodeSimple("importId", payload.importId, {
|
|
28
|
+
explode: false,
|
|
29
|
+
charEncoding: "percent",
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
const path = pathToFunc("/v1/imports/{importId}")(pathParams);
|
|
33
|
+
const headers = new Headers(compactMap({
|
|
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: "deleteImport",
|
|
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: "DELETE",
|
|
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, models.Import$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 });
|
|
89
|
+
if (!result.ok) {
|
|
90
|
+
return [result, { status: "complete", request: req, response }];
|
|
91
|
+
}
|
|
92
|
+
return [result, { status: "complete", request: req, response }];
|
|
93
|
+
}
|
|
@@ -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 importsGet(client: StateMachinesCore, request: operations.GetImportRequest, options?: RequestOptions): APIPromise<Result<models.Import, errors.ErrorT | StateMachinesHTTPError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
|