@statelyai/sdk 0.14.2 → 0.15.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.
@@ -0,0 +1,303 @@
1
+ import { A as $strip, C as ZodObject, D as ZodUnion, E as ZodString, O as ZodUnknown, S as ZodNumber, T as ZodRecord, b as ZodLiteral, k as output, v as ZodArray, w as ZodOptional, x as ZodNullable, y as ZodEnum } from "./index-ag6K2iAS.mjs";
2
+ import { n as StatelyCredential, t as StatelyAuthMode } from "./auth-2Thaw42j.mjs";
3
+
4
+ //#region ../api-contract/dist/errors.d.mts
5
+ /**
6
+ * Canonical error codes for the `/api/v1` resource operations. Machine
7
+ * operations keep the flat `{ error: string }` shape above unchanged; the
8
+ * nested envelope below applies to resource operations only.
9
+ */
10
+ declare const resourceErrorCodeSchema: ZodEnum<{
11
+ bad_request: "bad_request";
12
+ unauthenticated: "unauthenticated";
13
+ forbidden: "forbidden";
14
+ not_found: "not_found";
15
+ conflict: "conflict";
16
+ payload_too_large: "payload_too_large";
17
+ rate_limited: "rate_limited";
18
+ capability_disabled: "capability_disabled";
19
+ upstream_error: "upstream_error";
20
+ internal_error: "internal_error";
21
+ }>;
22
+ type ResourceErrorCode = output<typeof resourceErrorCodeSchema>;
23
+ /** Factory, matching `createApiErrorResponseSchema`, for per-route OpenAPI components. */
24
+ //#endregion
25
+ //#region ../api-contract/dist/resources.d.mts
26
+ //#region src/resources.d.ts
27
+ /**
28
+ * XState major versions the editor targets (see
29
+ * `packages/editor/src/formats/xstate.ts`).
30
+ */
31
+ declare const xstateVersionSchema: ZodUnion<readonly [ZodLiteral<5>, ZodLiteral<6>]>;
32
+ type XStateVersion = output<typeof xstateVersionSchema>;
33
+ declare const projectVisibilitySchema: ZodEnum<{
34
+ public: "public";
35
+ unlisted: "unlisted";
36
+ private: "private";
37
+ }>;
38
+ type ProjectVisibility = output<typeof projectVisibilitySchema>;
39
+ declare const verifyResultSchema: ZodObject<{
40
+ valid: ZodLiteral<true>;
41
+ tokenScope: ZodEnum<{
42
+ user: "user";
43
+ project: "project";
44
+ }>;
45
+ }, $strip>;
46
+ type VerifyResult = output<typeof verifyResultSchema>;
47
+ declare const projectSummarySchema: ZodObject<{
48
+ projectId: ZodString;
49
+ projectVersionId: ZodString;
50
+ name: ZodString;
51
+ description: ZodNullable<ZodString>;
52
+ visibility: ZodEnum<{
53
+ public: "public";
54
+ unlisted: "unlisted";
55
+ private: "private";
56
+ }>;
57
+ createdAt: ZodString;
58
+ updatedAt: ZodString;
59
+ }, $strip>;
60
+ type ProjectSummary = output<typeof projectSummarySchema>;
61
+ declare const projectSchema: ZodObject<{
62
+ projectId: ZodString;
63
+ projectVersionId: ZodString;
64
+ name: ZodString;
65
+ description: ZodNullable<ZodString>;
66
+ visibility: ZodEnum<{
67
+ public: "public";
68
+ unlisted: "unlisted";
69
+ private: "private";
70
+ }>;
71
+ createdAt: ZodString;
72
+ updatedAt: ZodString;
73
+ rootMachineId: ZodNullable<ZodString>;
74
+ machines: ZodArray<ZodObject<{
75
+ machineId: ZodString;
76
+ }, $strip>>;
77
+ }, $strip>;
78
+ type Project = output<typeof projectSchema>;
79
+ /**
80
+ * `name` is optional: the Registry project envelope only returns machine ids.
81
+ * Providers that can supply names cheaply should.
82
+ */
83
+ declare const projectMachineSummarySchema: ZodObject<{
84
+ machineId: ZodString;
85
+ name: ZodOptional<ZodString>;
86
+ }, $strip>;
87
+ type ProjectMachineSummary = output<typeof projectMachineSummarySchema>;
88
+ declare const machineSchema: ZodObject<{
89
+ machineId: ZodString;
90
+ name: ZodString;
91
+ projectId: ZodOptional<ZodString>;
92
+ projectVersionId: ZodString;
93
+ definition: ZodUnknown;
94
+ createdAt: ZodOptional<ZodString>;
95
+ updatedAt: ZodOptional<ZodString>;
96
+ }, $strip>;
97
+ type Machine = output<typeof machineSchema>;
98
+ declare const machineVersionSchema: ZodObject<{
99
+ machineVersionId: ZodString;
100
+ machineId: ZodString;
101
+ versionNumber: ZodNumber;
102
+ name: ZodString;
103
+ definition: ZodUnknown;
104
+ createdAt: ZodString;
105
+ updatedAt: ZodString;
106
+ }, $strip>;
107
+ type MachineVersion = output<typeof machineVersionSchema>;
108
+ declare const extractedMachinesSchema: ZodObject<{
109
+ machines: ZodArray<ZodObject<{
110
+ config: ZodRecord<ZodString, ZodUnknown>;
111
+ }, $strip>>;
112
+ }, $strip>;
113
+ type ExtractedMachines = output<typeof extractedMachinesSchema>;
114
+ //#endregion
115
+ //#region src/studio.d.ts
116
+ /** Default base URL of the editor/API deployment hosting `/api/v1`. */
117
+ declare const DEFAULT_STATELY_BASE_URL = "https://editor.stately.ai";
118
+ interface StudioClientOptions {
119
+ /** Editor/API base URL. Defaults to {@link DEFAULT_STATELY_BASE_URL}. */
120
+ baseUrl?: string;
121
+ credential?: StatelyCredential;
122
+ /** @deprecated Use `credential: { type: 'api_key', token }`. */
123
+ apiKey?: string;
124
+ authMode?: StatelyAuthMode;
125
+ fetch?: typeof fetch;
126
+ }
127
+ /** Per-call options accepted by every client method. */
128
+ interface StudioRequestOptions {
129
+ signal?: AbortSignal;
130
+ credential?: StatelyCredential | string | null;
131
+ authMode?: StatelyAuthMode;
132
+ }
133
+ /** @deprecated Use {@link VerifyResult}. */
134
+ type VerifyApiKeyResponse = VerifyResult;
135
+ /** @deprecated Visibility is lowercase in the canonical contract. */
136
+ type LegacyProjectVisibility = 'Public' | 'Private' | 'Unlisted';
137
+ type RepoType = 'GITHUB';
138
+ /**
139
+ * @deprecated The canonical contract does not model connected repositories.
140
+ * Accepted by {@link StudioClient.projects.ensure} for compatibility only.
141
+ */
142
+ interface ConnectedRepo {
143
+ id?: string;
144
+ type?: RepoType;
145
+ url: string;
146
+ owner: string;
147
+ repo: string;
148
+ branch: string;
149
+ treeSha: string;
150
+ autoSync?: boolean;
151
+ pathForNewFiles?: string;
152
+ selectedPaths?: string[];
153
+ lastSyncedAt?: string;
154
+ }
155
+ /** @deprecated Use {@link ProjectMachineSummary}. */
156
+ type ProjectMachine = ProjectMachineSummary;
157
+ /**
158
+ * @deprecated Use {@link Project}. Retained so existing consumers keep
159
+ * compiling; the extra members are SDK-only compatibility aliases.
160
+ */
161
+ type ProjectData = Project & {
162
+ /** @deprecated Use `projectVersionId`. */id?: string;
163
+ keywords?: string[];
164
+ connectedRepo?: ConnectedRepo | null;
165
+ };
166
+ /** @deprecated Use {@link ExtractedMachines}`['machines'][number]`. */
167
+ interface ExtractedMachine {
168
+ config: Record<string, unknown>;
169
+ id?: string;
170
+ setupConfig?: Record<string, unknown>;
171
+ implementations?: Record<string, unknown>;
172
+ _type?: 'setup.createMachine' | 'createMachine';
173
+ }
174
+ /** @deprecated Use {@link ExtractedMachines}. */
175
+ interface ExtractMachinesResponse {
176
+ machines: ExtractedMachine[];
177
+ /** @deprecated Extraction failures now reject with a {@link StudioApiError}. */
178
+ error?: string;
179
+ }
180
+ /**
181
+ * Canonical {@link Machine} with the deprecated `id` alias the previous SDK
182
+ * returned. `id` always equals `machineId`.
183
+ */
184
+ type StudioMachineRecord<TDefinition = unknown> = Omit<Machine, 'definition'> & {
185
+ definition: TDefinition; /** @deprecated Use `machineId`. */
186
+ id: string;
187
+ };
188
+ interface CreateProjectInput {
189
+ name: string;
190
+ visibility: ProjectVisibility | LegacyProjectVisibility;
191
+ /** @deprecated Not part of `projects.create`; use `projects.update`. */
192
+ description?: string;
193
+ /** @deprecated Keywords are not part of the canonical contract. */
194
+ keywords?: string[];
195
+ /** @deprecated Connected repositories are not part of the canonical contract. */
196
+ repo?: ConnectedRepo;
197
+ }
198
+ interface UpdateProjectInput {
199
+ name?: string;
200
+ description?: string | null;
201
+ visibility?: ProjectVisibility | LegacyProjectVisibility;
202
+ }
203
+ interface EnsureProjectInput extends CreateProjectInput {
204
+ /** @deprecated Repository matching is best-effort; see `projects.ensure`. */
205
+ matchConnectedRepo?: boolean;
206
+ }
207
+ interface CreateMachineInput<TDefinition = unknown> {
208
+ projectVersionId: string;
209
+ /**
210
+ * Defaults to `5`. Legacy XState `4` is normalized to `5`; the canonical
211
+ * contract only accepts `5 | 6`.
212
+ */
213
+ xstateVersion?: XStateVersion | 4;
214
+ name?: string;
215
+ definition?: TDefinition;
216
+ /** @deprecated Templates are not part of the canonical contract; ignored. */
217
+ template?: 'blank' | 'starter';
218
+ }
219
+ /** @deprecated Use {@link CreateMachineInput}. */
220
+ type CreateMachineFromDefinitionInput<TDefinition = unknown> = CreateMachineInput<TDefinition>;
221
+ /** @deprecated Use {@link CreateMachineInput}. */
222
+ type CreateMachineFromTemplateInput = CreateMachineInput;
223
+ /** @deprecated Templates are not part of the canonical contract. */
224
+ type CreateMachineTemplate = 'blank' | 'starter';
225
+ interface UpdateMachineInput<TDefinition = unknown> {
226
+ name?: string;
227
+ definition?: TDefinition;
228
+ }
229
+ /** @deprecated Pass the machine id as the first argument instead. */
230
+ interface LegacyUpdateMachineInput<TDefinition = unknown> extends UpdateMachineInput<TDefinition> {
231
+ /** @deprecated Use `machineId`. */
232
+ id?: string;
233
+ machineId?: string;
234
+ }
235
+ interface ExtractMachinesInput {
236
+ code: string;
237
+ /** Optional override. Omit to infer the source profile structurally. */
238
+ xstateVersion?: XStateVersion | 4;
239
+ }
240
+ /** @deprecated Options object of the previous `code.extractMachines(code, options)`. */
241
+ interface LegacyExtractMachinesOptions extends StudioRequestOptions {
242
+ /** @deprecated Use `credential`. */
243
+ apiKey?: string | null;
244
+ xstateVersion?: XStateVersion | 4;
245
+ }
246
+ /** @deprecated `machines.get` no longer resolves versions; use `machines.getVersion`. */
247
+ interface GetMachineOptions extends StudioRequestOptions {
248
+ /** @deprecated Use `machines.getVersion(machineId, versionId)`. */
249
+ version?: string;
250
+ }
251
+ interface StudioApiErrorOptions {
252
+ code?: ResourceErrorCode;
253
+ issues?: unknown[];
254
+ retryable?: boolean;
255
+ }
256
+ declare class StudioApiError extends Error {
257
+ readonly status: number;
258
+ /** Canonical resource error code, when the server sent one. */
259
+ readonly code?: ResourceErrorCode;
260
+ readonly issues?: unknown[];
261
+ readonly retryable?: boolean;
262
+ constructor(message: string, status: number, options?: StudioApiErrorOptions);
263
+ }
264
+ interface StudioClient {
265
+ auth: {
266
+ /** `GET /api/v1/auth/verify` */verify(credentialOrOptions?: StatelyCredential | string | StudioRequestOptions, options?: StudioRequestOptions): Promise<VerifyResult>;
267
+ };
268
+ projects: {
269
+ /** `GET /api/v1/projects` */list(options?: StudioRequestOptions): Promise<ProjectSummary[]>; /** `POST /api/v1/projects` */
270
+ create(input: CreateProjectInput, options?: StudioRequestOptions): Promise<ProjectData>; /** `GET /api/v1/projects/:projectId` */
271
+ get(projectId: string, options?: StudioRequestOptions): Promise<ProjectData>; /** `PATCH /api/v1/projects/:projectId` */
272
+ update(projectId: string, input: UpdateProjectInput, options?: StudioRequestOptions): Promise<ProjectData>; /** `DELETE /api/v1/projects/:projectId` (SDK-only surface) */
273
+ delete(projectId: string, options?: StudioRequestOptions): Promise<{
274
+ projectId: string;
275
+ }>; /** `GET /api/v1/projects/:projectId/machines` */
276
+ listMachines(projectId: string, options?: StudioRequestOptions): Promise<ProjectMachineSummary[]>;
277
+ /**
278
+ * Client workflow (not a route): find an existing project matching the
279
+ * input, otherwise create one. Composed of `projects.list`,
280
+ * `projects.get` and `projects.create`.
281
+ */
282
+ ensure(input: EnsureProjectInput, options?: StudioRequestOptions): Promise<ProjectData>;
283
+ };
284
+ machines: {
285
+ /** `POST /api/v1/machines` */create<TDefinition = unknown>(input: CreateMachineInput<TDefinition>, options?: StudioRequestOptions): Promise<StudioMachineRecord<TDefinition>>;
286
+ /**
287
+ * @deprecated Singular semantics: creates one machine and returns it in a
288
+ * single-element array. Use `machines.create`.
289
+ */
290
+ createMany<TDefinition = unknown>(input: CreateMachineInput<TDefinition>, options?: StudioRequestOptions): Promise<Array<StudioMachineRecord<TDefinition>>>; /** `GET /api/v1/machines/:machineId` */
291
+ get<TDefinition = unknown>(machineId: string, options?: GetMachineOptions): Promise<StudioMachineRecord<TDefinition>>; /** `GET /api/v1/machines/:machineId/versions/:versionId` */
292
+ getVersion(machineId: string, versionId: string, options?: StudioRequestOptions): Promise<MachineVersion>; /** `PATCH /api/v1/machines/:machineId` */
293
+ update<TDefinition = unknown>(machineId: string, input: UpdateMachineInput<TDefinition>, options?: StudioRequestOptions): Promise<StudioMachineRecord<TDefinition>>; /** @deprecated Pass the machine id as the first argument. */
294
+ update<TDefinition = unknown>(input: LegacyUpdateMachineInput<TDefinition>, options?: StudioRequestOptions): Promise<StudioMachineRecord<TDefinition>>;
295
+ };
296
+ code: {
297
+ /** `POST /api/v1/code/extract-machines` */extractMachines(input: ExtractMachinesInput, options?: StudioRequestOptions): Promise<ExtractedMachines>; /** @deprecated Pass `{ code, xstateVersion }`. */
298
+ extractMachines(code: string, options?: LegacyExtractMachinesOptions): Promise<ExtractedMachines>;
299
+ };
300
+ }
301
+ declare function createStatelyClient(options?: StudioClientOptions): StudioClient;
302
+ //#endregion
303
+ export { Machine as A, StudioMachineRecord as C, VerifyApiKeyResponse as D, UpdateProjectInput as E, ProjectVisibility as F, VerifyResult as I, XStateVersion as L, Project as M, ProjectMachineSummary as N, createStatelyClient as O, ProjectSummary as P, ResourceErrorCode as R, StudioClientOptions as S, UpdateMachineInput as T, ProjectMachine as _, CreateMachineTemplate as a, StudioApiErrorOptions as b, EnsureProjectInput as c, ExtractedMachine as d, GetMachineOptions as f, ProjectData as g, LegacyUpdateMachineInput as h, CreateMachineInput as i, MachineVersion as j, ExtractedMachines as k, ExtractMachinesInput as l, LegacyProjectVisibility as m, CreateMachineFromDefinitionInput as n, CreateProjectInput as o, LegacyExtractMachinesOptions as p, CreateMachineFromTemplateInput as r, DEFAULT_STATELY_BASE_URL as s, ConnectedRepo as t, ExtractMachinesResponse as u, RepoType as v, StudioRequestOptions as w, StudioClient as x, StudioApiError as y };