@usestatemachines/sdk 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -18
- package/agents/SKILL.md +18 -8
- package/agents/index.js +6 -6
- package/agents/llms.txt +22 -9
- package/agents/prompt.md +2 -2
- package/esm/extensions/apps.d.ts +11 -1
- package/esm/extensions/apps.js +16 -0
- package/esm/extensions/client.d.ts +47 -4
- package/esm/extensions/client.js +107 -12
- package/esm/extensions/errors.d.ts +26 -1
- package/esm/extensions/errors.js +34 -1
- package/esm/extensions/index.d.ts +4 -4
- package/esm/extensions/index.js +1 -1
- package/esm/extensions/running-environment.d.ts +20 -3
- package/esm/extensions/running-environment.js +33 -2
- package/esm/extensions/wait.d.ts +13 -4
- package/esm/extensions/wait.js +38 -13
- package/esm/funcs/environments-list.js +1 -0
- package/esm/funcs/environments-resume.d.ts +11 -0
- package/esm/funcs/environments-resume.js +92 -0
- package/esm/funcs/environments-suspend.d.ts +11 -0
- package/esm/funcs/environments-suspend.js +92 -0
- package/esm/funcs/get-environment-exchange.d.ts +11 -0
- package/esm/funcs/get-environment-exchange.js +96 -0
- package/esm/funcs/get-environment-position.d.ts +11 -0
- package/esm/funcs/get-environment-position.js +92 -0
- package/esm/funcs/list-environment-history.d.ts +11 -0
- package/esm/funcs/list-environment-history.js +97 -0
- package/esm/funcs/snapshots-capture.d.ts +11 -0
- package/esm/funcs/snapshots-capture.js +94 -0
- package/esm/funcs/snapshots-delete.d.ts +11 -0
- package/esm/funcs/snapshots-delete.js +92 -0
- package/esm/funcs/snapshots-get.d.ts +11 -0
- package/esm/funcs/snapshots-get.js +92 -0
- package/esm/funcs/snapshots-list.d.ts +11 -0
- package/esm/funcs/snapshots-list.js +98 -0
- package/esm/funcs/snapshots-update.d.ts +11 -0
- package/esm/funcs/snapshots-update.js +93 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/app-instance-snapshot.d.ts +15 -0
- package/esm/models/app-instance-snapshot.js +19 -0
- package/esm/models/create-environment-input.d.ts +6 -2
- package/esm/models/create-environment-input.js +3 -1
- package/esm/models/environment-app.d.ts +11 -0
- package/esm/models/environment-app.js +13 -0
- package/esm/models/environment-exchange.d.ts +116 -0
- package/esm/models/environment-exchange.js +126 -0
- package/esm/models/environment-position.d.ts +25 -0
- package/esm/models/environment-position.js +32 -0
- package/esm/models/environment-snapshot.d.ts +40 -0
- package/esm/models/environment-snapshot.js +42 -0
- package/esm/models/environment.d.ts +5 -0
- package/esm/models/environment.js +5 -0
- package/esm/models/error-response.d.ts +9 -0
- package/esm/models/error-response.js +9 -0
- package/esm/models/history-body.d.ts +28 -0
- package/esm/models/history-body.js +33 -0
- package/esm/models/history-cause.d.ts +48 -0
- package/esm/models/history-cause.js +63 -0
- package/esm/models/history-position.d.ts +11 -0
- package/esm/models/history-position.js +15 -0
- package/esm/models/history-transaction.d.ts +16 -0
- package/esm/models/history-transaction.js +20 -0
- package/esm/models/index.d.ts +8 -0
- package/esm/models/index.js +8 -0
- package/esm/models/operations/capture-snapshot.d.ts +41 -0
- package/esm/models/operations/capture-snapshot.js +36 -0
- package/esm/models/operations/create-environment-definition.d.ts +92 -10
- package/esm/models/operations/create-environment-definition.js +63 -4
- package/esm/models/operations/delete-snapshot.d.ts +23 -0
- package/esm/models/operations/delete-snapshot.js +20 -0
- package/esm/models/operations/get-environment-exchange.d.ts +25 -0
- package/esm/models/operations/get-environment-exchange.js +21 -0
- package/esm/models/operations/get-environment-position.d.ts +23 -0
- package/esm/models/operations/get-environment-position.js +20 -0
- package/esm/models/operations/get-snapshot.d.ts +23 -0
- package/esm/models/operations/get-snapshot.js +20 -0
- package/esm/models/operations/index.d.ts +10 -0
- package/esm/models/operations/index.js +10 -0
- package/esm/models/operations/list-environment-history.d.ts +28 -0
- package/esm/models/operations/list-environment-history.js +24 -0
- package/esm/models/operations/list-environments.d.ts +2 -0
- package/esm/models/operations/list-environments.js +1 -0
- package/esm/models/operations/list-snapshots.d.ts +30 -0
- package/esm/models/operations/list-snapshots.js +25 -0
- package/esm/models/operations/resume-environment.d.ts +23 -0
- package/esm/models/operations/resume-environment.js +20 -0
- package/esm/models/operations/stop-environment.d.ts +1 -1
- package/esm/models/operations/suspend-environment.d.ts +23 -0
- package/esm/models/operations/suspend-environment.js +20 -0
- package/esm/models/operations/update-snapshot.d.ts +37 -0
- package/esm/models/operations/update-snapshot.js +29 -0
- package/esm/models/release.d.ts +11 -0
- package/esm/models/release.js +10 -0
- package/esm/sdk/environments.d.ts +2 -0
- package/esm/sdk/environments.js +8 -0
- package/esm/sdk/sdk.d.ts +6 -0
- package/esm/sdk/sdk.js +17 -0
- package/esm/sdk/snapshots.d.ts +9 -0
- package/esm/sdk/snapshots.js +27 -0
- package/esm/types/discriminated-union.d.ts +24 -0
- package/esm/types/discriminated-union.js +60 -0
- package/esm/types/smart-union.js +2 -1
- package/openapi.json +2473 -242
- package/package.json +11 -11
package/esm/sdk/sdk.js
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
import { createEnvironmentDefinition } from "../funcs/create-environment-definition.js";
|
|
5
|
+
import { getEnvironmentExchange } from "../funcs/get-environment-exchange.js";
|
|
6
|
+
import { getEnvironmentPosition } from "../funcs/get-environment-position.js";
|
|
7
|
+
import { listEnvironmentHistory } from "../funcs/list-environment-history.js";
|
|
5
8
|
import { ClientSDK } from "../lib/sdks.js";
|
|
6
9
|
import { unwrapAsync } from "../types/fp.js";
|
|
7
10
|
import { Catalog } from "./catalog.js";
|
|
8
11
|
import { Credential } from "./credential.js";
|
|
9
12
|
import { Environments } from "./environments.js";
|
|
13
|
+
import { Snapshots } from "./snapshots.js";
|
|
10
14
|
import { Workspaces } from "./workspaces.js";
|
|
11
15
|
export class StateMachines extends ClientSDK {
|
|
12
16
|
_catalog;
|
|
@@ -21,10 +25,23 @@ export class StateMachines extends ClientSDK {
|
|
|
21
25
|
get environments() {
|
|
22
26
|
return (this._environments ?? (this._environments = new Environments(this._options)));
|
|
23
27
|
}
|
|
28
|
+
_snapshots;
|
|
29
|
+
get snapshots() {
|
|
30
|
+
return (this._snapshots ?? (this._snapshots = new Snapshots(this._options)));
|
|
31
|
+
}
|
|
24
32
|
_workspaces;
|
|
25
33
|
get workspaces() {
|
|
26
34
|
return (this._workspaces ?? (this._workspaces = new Workspaces(this._options)));
|
|
27
35
|
}
|
|
36
|
+
async listEnvironmentHistory(request, options) {
|
|
37
|
+
return unwrapAsync(listEnvironmentHistory(this, request, options));
|
|
38
|
+
}
|
|
39
|
+
async getEnvironmentPosition(request, options) {
|
|
40
|
+
return unwrapAsync(getEnvironmentPosition(this, request, options));
|
|
41
|
+
}
|
|
42
|
+
async getEnvironmentExchange(request, options) {
|
|
43
|
+
return unwrapAsync(getEnvironmentExchange(this, request, options));
|
|
44
|
+
}
|
|
28
45
|
async createEnvironmentDefinition(request, options) {
|
|
29
46
|
return unwrapAsync(createEnvironmentDefinition(this, request, options));
|
|
30
47
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
2
|
+
import * as operations from "../models/operations/index.js";
|
|
3
|
+
export declare class Snapshots extends ClientSDK {
|
|
4
|
+
delete(request: operations.DeleteSnapshotRequest, options?: RequestOptions): Promise<operations.DeleteSnapshotResponse>;
|
|
5
|
+
get(request: operations.GetSnapshotRequest, options?: RequestOptions): Promise<operations.GetSnapshotResponse>;
|
|
6
|
+
update(request: operations.UpdateSnapshotRequest, options?: RequestOptions): Promise<operations.UpdateSnapshotResponse>;
|
|
7
|
+
list(request: operations.ListSnapshotsRequest, options?: RequestOptions): Promise<operations.ListSnapshotsResponse>;
|
|
8
|
+
capture(request: operations.CaptureSnapshotRequest, options?: RequestOptions): Promise<operations.CaptureSnapshotResponse>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import { snapshotsCapture } from "../funcs/snapshots-capture.js";
|
|
5
|
+
import { snapshotsDelete } from "../funcs/snapshots-delete.js";
|
|
6
|
+
import { snapshotsGet } from "../funcs/snapshots-get.js";
|
|
7
|
+
import { snapshotsList } from "../funcs/snapshots-list.js";
|
|
8
|
+
import { snapshotsUpdate } from "../funcs/snapshots-update.js";
|
|
9
|
+
import { ClientSDK } from "../lib/sdks.js";
|
|
10
|
+
import { unwrapAsync } from "../types/fp.js";
|
|
11
|
+
export class Snapshots extends ClientSDK {
|
|
12
|
+
async delete(request, options) {
|
|
13
|
+
return unwrapAsync(snapshotsDelete(this, request, options));
|
|
14
|
+
}
|
|
15
|
+
async get(request, options) {
|
|
16
|
+
return unwrapAsync(snapshotsGet(this, request, options));
|
|
17
|
+
}
|
|
18
|
+
async update(request, options) {
|
|
19
|
+
return unwrapAsync(snapshotsUpdate(this, request, options));
|
|
20
|
+
}
|
|
21
|
+
async list(request, options) {
|
|
22
|
+
return unwrapAsync(snapshotsList(this, request, options));
|
|
23
|
+
}
|
|
24
|
+
async capture(request, options) {
|
|
25
|
+
return unwrapAsync(snapshotsCapture(this, request, options));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as z from "zod/v4-mini";
|
|
2
|
+
export type Unknown<Discriminator extends string, UnknownValue = "UNKNOWN"> = {
|
|
3
|
+
[K in Discriminator]: UnknownValue;
|
|
4
|
+
} & {
|
|
5
|
+
raw: unknown;
|
|
6
|
+
isUnknown: true;
|
|
7
|
+
};
|
|
8
|
+
export declare function isUnknown<Discriminator extends string>(value: unknown): value is Unknown<Discriminator>;
|
|
9
|
+
/**
|
|
10
|
+
* Forward-compatible discriminated union parser.
|
|
11
|
+
*
|
|
12
|
+
* If the input does not match one of the predefined options, it will be
|
|
13
|
+
* captured and available as `{ raw: <original input>, [discriminator]: "UNKNOWN", isUnknown: true }`.
|
|
14
|
+
*
|
|
15
|
+
* @param inputPropertyName - The discriminator property name in the input payload
|
|
16
|
+
* @param options - Map of discriminator values to their corresponding schemas
|
|
17
|
+
* @param opts - Optional configuration object
|
|
18
|
+
* @param opts.unknownValue - The value to use for the discriminator when the input is unknown (default: "UNKNOWN")
|
|
19
|
+
* @param opts.outputPropertyName - Output property name if the sanitized (camelCase) property name differs from inputPropertyName
|
|
20
|
+
*/
|
|
21
|
+
export declare function discriminatedUnion<InputDiscriminator extends string, TOptions extends Readonly<Record<string, z.ZodMiniType>>, UnknownValue extends string = "UNKNOWN", OutputDiscriminator extends string = InputDiscriminator>(inputPropertyName: InputDiscriminator, options: TOptions, opts?: {
|
|
22
|
+
unknownValue?: UnknownValue;
|
|
23
|
+
outputPropertyName?: OutputDiscriminator;
|
|
24
|
+
}): z.ZodMiniType<z.output<TOptions[keyof TOptions]> | Unknown<OutputDiscriminator, UnknownValue>, unknown>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4-mini";
|
|
5
|
+
import { startCountingDefaultToZeroValue } from "./default-to-zero-value.js";
|
|
6
|
+
import { startCountingUnrecognized } from "./unrecognized.js";
|
|
7
|
+
const UNKNOWN = Symbol("UNKNOWN");
|
|
8
|
+
export function isUnknown(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && UNKNOWN in value;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Forward-compatible discriminated union parser.
|
|
13
|
+
*
|
|
14
|
+
* If the input does not match one of the predefined options, it will be
|
|
15
|
+
* captured and available as `{ raw: <original input>, [discriminator]: "UNKNOWN", isUnknown: true }`.
|
|
16
|
+
*
|
|
17
|
+
* @param inputPropertyName - The discriminator property name in the input payload
|
|
18
|
+
* @param options - Map of discriminator values to their corresponding schemas
|
|
19
|
+
* @param opts - Optional configuration object
|
|
20
|
+
* @param opts.unknownValue - The value to use for the discriminator when the input is unknown (default: "UNKNOWN")
|
|
21
|
+
* @param opts.outputPropertyName - Output property name if the sanitized (camelCase) property name differs from inputPropertyName
|
|
22
|
+
*/
|
|
23
|
+
export function discriminatedUnion(inputPropertyName, options, opts = {}) {
|
|
24
|
+
const { unknownValue = "UNKNOWN", outputPropertyName } = opts;
|
|
25
|
+
return z.pipe(z.unknown(), z.transform((input) => {
|
|
26
|
+
const fallback = Object.defineProperties({
|
|
27
|
+
raw: input,
|
|
28
|
+
[outputPropertyName ?? inputPropertyName]: unknownValue,
|
|
29
|
+
isUnknown: true,
|
|
30
|
+
}, { [UNKNOWN]: { value: true, enumerable: false, configurable: false } });
|
|
31
|
+
const isObject = typeof input === "object" && input !== null;
|
|
32
|
+
if (!isObject)
|
|
33
|
+
return fallback;
|
|
34
|
+
const discriminator = input[inputPropertyName];
|
|
35
|
+
if (typeof discriminator !== "string")
|
|
36
|
+
return fallback;
|
|
37
|
+
if (!(discriminator in options))
|
|
38
|
+
return fallback;
|
|
39
|
+
const schema = options[discriminator];
|
|
40
|
+
if (!schema)
|
|
41
|
+
return fallback;
|
|
42
|
+
// Start counters before parsing to track nested unrecognized/zeroDefault values
|
|
43
|
+
const unrecognizedCtr = startCountingUnrecognized();
|
|
44
|
+
const zeroDefaultCtr = startCountingDefaultToZeroValue();
|
|
45
|
+
const result = z.safeParse(schema, input);
|
|
46
|
+
if (!result.success) {
|
|
47
|
+
// Parse failed - don't propagate any counts from the failed attempt
|
|
48
|
+
unrecognizedCtr.end(0);
|
|
49
|
+
zeroDefaultCtr.end(0);
|
|
50
|
+
return fallback;
|
|
51
|
+
}
|
|
52
|
+
// Parse succeeded - propagate the actual counts
|
|
53
|
+
unrecognizedCtr.end();
|
|
54
|
+
zeroDefaultCtr.end();
|
|
55
|
+
if (outputPropertyName) {
|
|
56
|
+
result.data[outputPropertyName] = discriminator;
|
|
57
|
+
}
|
|
58
|
+
return result.data;
|
|
59
|
+
}));
|
|
60
|
+
}
|
package/esm/types/smart-union.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// Not needed if lax mode
|
|
5
5
|
import * as z from "zod/v4-mini";
|
|
6
6
|
import { startCountingDefaultToZeroValue } from "./default-to-zero-value.js";
|
|
7
|
+
import { isUnknown as isDiscriminatedUnionUnknown } from "./discriminated-union.js";
|
|
7
8
|
import { RFCDate } from "./rfcdate.js";
|
|
8
9
|
import { startCountingUnrecognized } from "./unrecognized.js";
|
|
9
10
|
/**
|
|
@@ -87,7 +88,7 @@ function countFieldsRecursive(parsed) {
|
|
|
87
88
|
let index = 0;
|
|
88
89
|
while (index < queue.length) {
|
|
89
90
|
const value = queue[index++];
|
|
90
|
-
if (value === undefined) {
|
|
91
|
+
if (value === undefined || isDiscriminatedUnionUnknown(value)) {
|
|
91
92
|
continue;
|
|
92
93
|
}
|
|
93
94
|
// Check if it's a primitive value
|