@statelyai/sdk 0.28.0 → 0.29.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.
@@ -1,4 +1,4 @@
1
- import { A as ZodString, C as ZodEnum, D as ZodObject, E as ZodNumber, M as ZodUnknown, N as output, O as ZodOptional, P as $strip, S as ZodArray, T as ZodNullable, j as ZodUnion, k as ZodRecord, w as ZodLiteral } from "./index-D2I1qPsf.mjs";
1
+ import { A as ZodObject, D as ZodLiteral, E as ZodEnum, F as ZodUnknown, I as output, L as $loose, M as ZodRecord, N as ZodString, O as ZodNullable, P as ZodUnion, R as $strip, T as ZodBoolean, j as ZodOptional, k as ZodNumber, w as ZodArray } from "./index-D4pdeDpT.mjs";
2
2
  import { n as StatelyCredential, t as StatelyAuthMode } from "./auth-BPyCCHYo.mjs";
3
3
 
4
4
  //#region ../api-contract/dist/errors.d.mts
@@ -44,6 +44,17 @@ declare const verifyResultSchema: ZodObject<{
44
44
  }>;
45
45
  }, $strip>;
46
46
  type VerifyResult = output<typeof verifyResultSchema>;
47
+ /**
48
+ * Entitlements for the authenticated caller.
49
+ *
50
+ * Internal contract: this is not published as an `/api/v1` operation. Editor
51
+ * feature gating resolves it server-side through the resource provider and
52
+ * hands the mapped result to the client (see
53
+ * `packages/editor/src/entitlements`).
54
+ *
55
+ * `entitlements` is an open set of provider-defined strings; unknown values are
56
+ * ignored rather than rejected.
57
+ */
47
58
  declare const projectSummarySchema: ZodObject<{
48
59
  projectId: ZodString;
49
60
  projectVersionId: ZodString;
@@ -58,6 +69,16 @@ declare const projectSummarySchema: ZodObject<{
58
69
  updatedAt: ZodString;
59
70
  }, $strip>;
60
71
  type ProjectSummary = output<typeof projectSummarySchema>;
72
+ /**
73
+ * `name` and `updatedAt` are optional: some upstream project envelopes only
74
+ * return machine ids. Providers that can supply them cheaply should.
75
+ */
76
+ declare const projectMachineSummarySchema: ZodObject<{
77
+ machineId: ZodString;
78
+ name: ZodOptional<ZodString>;
79
+ updatedAt: ZodOptional<ZodString>;
80
+ }, $strip>;
81
+ type ProjectMachineSummary = output<typeof projectMachineSummarySchema>;
61
82
  declare const projectSchema: ZodObject<{
62
83
  projectId: ZodString;
63
84
  projectVersionId: ZodString;
@@ -73,24 +94,79 @@ declare const projectSchema: ZodObject<{
73
94
  rootMachineId: ZodNullable<ZodString>;
74
95
  machines: ZodArray<ZodObject<{
75
96
  machineId: ZodString;
97
+ name: ZodOptional<ZodString>;
98
+ updatedAt: ZodOptional<ZodString>;
76
99
  }, $strip>>;
100
+ permissions: ZodObject<{
101
+ canEdit: ZodBoolean;
102
+ }, $strip>;
103
+ allowedVisibility: ZodOptional<ZodArray<ZodEnum<{
104
+ public: "public";
105
+ unlisted: "unlisted";
106
+ private: "private";
107
+ }>>>;
77
108
  }, $strip>;
78
109
  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
110
  declare const machineSchema: ZodObject<{
89
111
  machineId: ZodString;
90
112
  name: ZodString;
91
113
  projectId: ZodOptional<ZodString>;
92
114
  projectVersionId: ZodString;
93
115
  definition: ZodUnknown;
116
+ graph: ZodOptional<ZodObject<{
117
+ xgraphSchemaVersion: ZodOptional<ZodLiteral<"1.0.0">>;
118
+ id: ZodString;
119
+ type: ZodOptional<ZodString>;
120
+ parentId: ZodOptional<ZodNullable<ZodString>>;
121
+ initialNodeId: ZodOptional<ZodNullable<ZodString>>;
122
+ nodes: ZodArray<ZodObject<{
123
+ id: ZodString;
124
+ type: ZodOptional<ZodString>;
125
+ parentId: ZodOptional<ZodNullable<ZodString>>;
126
+ sourceId: ZodOptional<ZodString>;
127
+ targetId: ZodOptional<ZodString>;
128
+ label: ZodOptional<ZodNullable<ZodString>>;
129
+ data: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
130
+ x: ZodOptional<ZodNumber>;
131
+ y: ZodOptional<ZodNumber>;
132
+ width: ZodOptional<ZodNumber>;
133
+ height: ZodOptional<ZodNumber>;
134
+ position: ZodOptional<ZodObject<{
135
+ x: ZodNumber;
136
+ y: ZodNumber;
137
+ }, $strip>>;
138
+ dx: ZodOptional<ZodNumber>;
139
+ dy: ZodOptional<ZodNumber>;
140
+ }, $loose>>;
141
+ edges: ZodArray<ZodObject<{
142
+ id: ZodString;
143
+ type: ZodOptional<ZodString>;
144
+ sourceId: ZodString;
145
+ targetId: ZodString;
146
+ label: ZodOptional<ZodNullable<ZodString>>;
147
+ data: ZodUnknown;
148
+ x: ZodOptional<ZodNumber>;
149
+ y: ZodOptional<ZodNumber>;
150
+ width: ZodOptional<ZodNumber>;
151
+ height: ZodOptional<ZodNumber>;
152
+ position: ZodOptional<ZodObject<{
153
+ x: ZodNumber;
154
+ y: ZodNumber;
155
+ }, $strip>>;
156
+ dx: ZodOptional<ZodNumber>;
157
+ dy: ZodOptional<ZodNumber>;
158
+ }, $loose>>;
159
+ data: ZodOptional<ZodUnknown>;
160
+ layout: ZodOptional<ZodNullable<ZodUnknown>>;
161
+ annotations: ZodOptional<ZodArray<ZodUnknown>>;
162
+ direction: ZodOptional<ZodEnum<{
163
+ up: "up";
164
+ down: "down";
165
+ left: "left";
166
+ right: "right";
167
+ }>>;
168
+ style: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
169
+ }, $loose>>;
94
170
  createdAt: ZodOptional<ZodString>;
95
171
  updatedAt: ZodOptional<ZodString>;
96
172
  }, $strip>;
@@ -105,6 +181,7 @@ declare const machineVersionSchema: ZodObject<{
105
181
  updatedAt: ZodString;
106
182
  }, $strip>;
107
183
  type MachineVersion = output<typeof machineVersionSchema>;
184
+ /** Version-history row without the definition payload. */
108
185
  declare const extractedMachinesSchema: ZodObject<{
109
186
  machines: ZodArray<ZodObject<{
110
187
  config: ZodRecord<ZodString, ZodUnknown>;
@@ -42,6 +42,66 @@ function createResourceApiErrorResponseSchema() {
42
42
  }
43
43
  const resourceApiErrorResponseSchema = createResourceApiErrorResponseSchema();
44
44
 
45
+ //#endregion
46
+ //#region ../api-contract/dist/xgraph.mjs
47
+ const looseRecordSchema = record(string(), unknown());
48
+ const pointSchema = object({
49
+ x: number(),
50
+ y: number()
51
+ });
52
+ const nodeDataSchema = looseRecordSchema.refine((data) => !("parentId" in data), "XGraph node data must not contain parentId; use node.parentId.");
53
+ const xgraphNodeSchema = object({
54
+ id: string(),
55
+ type: string().optional(),
56
+ parentId: string().nullable().optional(),
57
+ sourceId: string().optional(),
58
+ targetId: string().optional(),
59
+ label: string().nullable().optional(),
60
+ data: nodeDataSchema.optional(),
61
+ x: number().optional(),
62
+ y: number().optional(),
63
+ width: number().optional(),
64
+ height: number().optional(),
65
+ position: pointSchema.optional(),
66
+ dx: number().optional(),
67
+ dy: number().optional()
68
+ }).passthrough();
69
+ const xgraphEdgeSchema = object({
70
+ id: string(),
71
+ type: string().optional(),
72
+ sourceId: string(),
73
+ targetId: string(),
74
+ label: string().nullable().optional(),
75
+ data: unknown(),
76
+ x: number().optional(),
77
+ y: number().optional(),
78
+ width: number().optional(),
79
+ height: number().optional(),
80
+ position: pointSchema.optional(),
81
+ dx: number().optional(),
82
+ dy: number().optional()
83
+ }).passthrough();
84
+ /** XGraph wire shape accepted and emitted at API boundaries. */
85
+ const xgraphSchema = object({
86
+ xgraphSchemaVersion: literal("1.0.0").optional(),
87
+ id: string(),
88
+ type: string().optional(),
89
+ parentId: string().nullable().optional(),
90
+ initialNodeId: string().nullable().optional(),
91
+ nodes: array(xgraphNodeSchema),
92
+ edges: array(xgraphEdgeSchema),
93
+ data: unknown().optional(),
94
+ layout: unknown().nullable().optional(),
95
+ annotations: array(unknown()).optional(),
96
+ direction: _enum([
97
+ "up",
98
+ "down",
99
+ "left",
100
+ "right"
101
+ ]).optional(),
102
+ style: looseRecordSchema.optional()
103
+ }).passthrough();
104
+
45
105
  //#endregion
46
106
  //#region ../api-contract/dist/resources.mjs
47
107
  /**
@@ -67,6 +127,24 @@ const verifyResultSchema = object({
67
127
  valid: literal(true),
68
128
  tokenScope: _enum(["user", "project"])
69
129
  });
130
+ /**
131
+ * Entitlements for the authenticated caller.
132
+ *
133
+ * Internal contract: this is not published as an `/api/v1` operation. Editor
134
+ * feature gating resolves it server-side through the resource provider and
135
+ * hands the mapped result to the client (see
136
+ * `packages/editor/src/entitlements`).
137
+ *
138
+ * `entitlements` is an open set of provider-defined strings; unknown values are
139
+ * ignored rather than rejected.
140
+ */
141
+ const entitlementsResultSchema = object({
142
+ subscription: object({
143
+ tier: string(),
144
+ status: string()
145
+ }).nullable(),
146
+ entitlements: array(string())
147
+ });
70
148
  const projectSummarySchema = object({
71
149
  projectId: string(),
72
150
  projectVersionId: string(),
@@ -76,17 +154,20 @@ const projectSummarySchema = object({
76
154
  createdAt: string(),
77
155
  updatedAt: string()
78
156
  });
79
- const projectSchema = projectSummarySchema.extend({
80
- rootMachineId: string().nullable(),
81
- machines: array(object({ machineId: string() }))
82
- });
83
157
  /**
84
- * `name` is optional: the Registry project envelope only returns machine ids.
85
- * Providers that can supply names cheaply should.
158
+ * `name` and `updatedAt` are optional: some upstream project envelopes only
159
+ * return machine ids. Providers that can supply them cheaply should.
86
160
  */
87
161
  const projectMachineSummarySchema = object({
88
162
  machineId: string(),
89
- name: string().optional()
163
+ name: string().optional(),
164
+ updatedAt: string().optional()
165
+ });
166
+ const projectSchema = projectSummarySchema.extend({
167
+ rootMachineId: string().nullable(),
168
+ machines: array(projectMachineSummarySchema),
169
+ permissions: object({ canEdit: boolean() }),
170
+ allowedVisibility: array(projectVisibilitySchema).optional()
90
171
  });
91
172
  const machineSchema = object({
92
173
  machineId: string(),
@@ -94,6 +175,7 @@ const machineSchema = object({
94
175
  projectId: string().optional(),
95
176
  projectVersionId: string(),
96
177
  definition: unknown(),
178
+ graph: xgraphSchema.optional(),
97
179
  createdAt: string().optional(),
98
180
  updatedAt: string().optional()
99
181
  });
@@ -106,6 +188,67 @@ const machineVersionSchema = object({
106
188
  createdAt: string(),
107
189
  updatedAt: string()
108
190
  });
191
+ /** Version-history row without the definition payload. */
192
+ const machineVersionSummarySchema = object({
193
+ machineVersionId: string(),
194
+ machineId: string(),
195
+ versionNumber: number(),
196
+ name: string().nullable(),
197
+ status: string(),
198
+ parentVersionId: string().nullable(),
199
+ createdAt: string(),
200
+ updatedAt: string()
201
+ });
202
+ /** Result of converting a machine's stored definition to XGraph in place. */
203
+ const machinesConvertResultSchema = object({
204
+ machine: machineSchema,
205
+ created: boolean(),
206
+ version: object({
207
+ machineVersionId: string(),
208
+ versionNumber: number(),
209
+ name: string().nullable()
210
+ })
211
+ });
212
+ /**
213
+ * A project the caller may fork a machine into, with the version ids a fork
214
+ * can target. `projectVersionIds` is ordered as the provider reports it.
215
+ */
216
+ const projectDestinationProjectSchema = object({
217
+ projectId: string(),
218
+ name: string(),
219
+ visibility: projectVisibilitySchema,
220
+ projectVersionIds: array(string())
221
+ });
222
+ /**
223
+ * Fork destinations grouped by owner. The caller's personal projects are one
224
+ * owner alongside each team; `ownerId` is opaque and provider-defined.
225
+ */
226
+ const projectDestinationSchema = object({
227
+ ownerId: string(),
228
+ name: string(),
229
+ projects: array(projectDestinationProjectSchema)
230
+ });
231
+ /** Result of forking a machine into a new or existing project version. */
232
+ const machinesForkResultSchema = object({
233
+ machine: machineSchema,
234
+ projectVersionId: string(),
235
+ projectId: string()
236
+ });
237
+ /**
238
+ * The version holding a machine's pre-conversion (legacy editor) definition.
239
+ * `versionId` is `null` when the machine has no such version, which is the
240
+ * signal that the legacy editor cannot be re-entered for it.
241
+ */
242
+ const machineLegacyVersionSchema = object({ versionId: string().nullable() });
243
+ /** Result of restoring a machine's legacy-editor definition. */
244
+ const machinesRestoreLegacyResultSchema = object({
245
+ machine: machineSchema,
246
+ version: object({
247
+ machineVersionId: string(),
248
+ versionNumber: number(),
249
+ name: string().nullable()
250
+ })
251
+ });
109
252
  const extractedMachinesSchema = object({ machines: array(object({
110
253
  config: record(string(), unknown()),
111
254
  machineIndex: number().int().nonnegative().optional()
@@ -129,6 +272,40 @@ const machinesUpdateRequestSchema = object({
129
272
  name: string().min(1).optional(),
130
273
  definition: unknown().optional()
131
274
  }).refine((value) => value.name !== void 0 || value.definition !== void 0, { message: "At least one of `name` or `definition` is required." });
275
+ /**
276
+ * `status` is canonical lowercase; providers map it to their own casing.
277
+ * Omitting `definition` snapshots the machine's current definition.
278
+ */
279
+ const machineVersionsCreateRequestSchema = object({
280
+ name: string().min(1).optional(),
281
+ definition: unknown().optional(),
282
+ status: _enum(["committed", "auto"]).optional(),
283
+ parentVersionId: string().min(1).optional()
284
+ });
285
+ const machinesConvertRequestSchema = object({
286
+ definition: xgraphSchema,
287
+ expectedUpdatedAt: string().min(1),
288
+ keepOriginalVersion: boolean().optional()
289
+ });
290
+ /**
291
+ * Fork a machine into exactly one target: an existing project version, or a
292
+ * new project to create for it. Both, or neither, is a client bug.
293
+ */
294
+ const machinesForkRequestSchema = object({
295
+ targetProjectVersionId: string().min(1).optional(),
296
+ targetProject: object({
297
+ name: string().min(1),
298
+ visibility: projectVisibilitySchema,
299
+ teamId: string().min(1).optional()
300
+ }).optional(),
301
+ machineName: string().min(1).optional(),
302
+ xstateVersion: xstateVersionSchema.optional()
303
+ }).refine((value) => value.targetProjectVersionId === void 0 !== (value.targetProject === void 0), { message: "Exactly one of `targetProjectVersionId` or `targetProject` is required." });
304
+ const machinesRestoreLegacyRequestSchema = object({
305
+ versionId: string().min(1).optional(),
306
+ expectedUpdatedAt: string().min(1),
307
+ reason: string().optional()
308
+ });
132
309
  const codeExtractMachinesRequestSchema = object({
133
310
  code: string().min(1),
134
311
  xstateVersion: xstateVersionSchema.optional()
@@ -140,10 +317,17 @@ const projectsCreateResponseSchema = projectSchema;
140
317
  const projectsUpdateResponseSchema = projectSchema;
141
318
  const projectsDeleteResponseSchema = object({ projectId: string() });
142
319
  const projectsListMachinesResponseSchema = array(projectMachineSummarySchema);
320
+ const projectsDestinationsResponseSchema = array(projectDestinationSchema);
143
321
  const machinesCreateResponseSchema = machineSchema;
144
322
  const machinesGetResponseSchema = machineSchema;
145
323
  const machinesUpdateResponseSchema = machineSchema;
146
324
  const machinesGetVersionResponseSchema = machineVersionSchema;
325
+ const machineVersionsListResponseSchema = array(machineVersionSummarySchema);
326
+ const machineVersionsCreateResponseSchema = machineVersionSchema;
327
+ const machinesConvertDefinitionResponseSchema = machinesConvertResultSchema;
328
+ const machinesForkResponseSchema = machinesForkResultSchema;
329
+ const machinesGetLegacyVersionResponseSchema = machineLegacyVersionSchema;
330
+ const machinesRestoreLegacyResponseSchema = machinesRestoreLegacyResultSchema;
147
331
  const codeExtractMachinesResponseSchema = extractedMachinesSchema;
148
332
  /**
149
333
  * Request/response schema pairs keyed by resource capability name. Kept here
@@ -164,6 +348,7 @@ const resourceOperationSchemas = {
164
348
  },
165
349
  "projects.delete": { response: projectsDeleteResponseSchema },
166
350
  "projects.listMachines": { response: projectsListMachinesResponseSchema },
351
+ "projects.destinations": { response: projectsDestinationsResponseSchema },
167
352
  "machines.create": {
168
353
  request: machinesCreateRequestSchema,
169
354
  response: machinesCreateResponseSchema
@@ -173,6 +358,24 @@ const resourceOperationSchemas = {
173
358
  "machines.update": {
174
359
  request: machinesUpdateRequestSchema,
175
360
  response: machinesUpdateResponseSchema
361
+ },
362
+ "machines.versions.list": { response: machineVersionsListResponseSchema },
363
+ "machines.versions.create": {
364
+ request: machineVersionsCreateRequestSchema,
365
+ response: machineVersionsCreateResponseSchema
366
+ },
367
+ "machines.convertDefinition": {
368
+ request: machinesConvertRequestSchema,
369
+ response: machinesConvertDefinitionResponseSchema
370
+ },
371
+ "machines.fork": {
372
+ request: machinesForkRequestSchema,
373
+ response: machinesForkResponseSchema
374
+ },
375
+ "machines.getLegacyVersion": { response: machinesGetLegacyVersionResponseSchema },
376
+ "machines.restoreLegacy": {
377
+ request: machinesRestoreLegacyRequestSchema,
378
+ response: machinesRestoreLegacyResponseSchema
176
379
  }
177
380
  };
178
381
  /** Provider-independent operations implemented by this repository. */
package/dist/studio.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, p as LegacyExtractMachinesOptions, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-B9-1Ynrx.mjs";
1
+ import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, p as LegacyExtractMachinesOptions, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-D-yqFd0u.mjs";
2
2
  export { ConnectedRepo, CreateMachineFromDefinitionInput, CreateMachineFromTemplateInput, CreateMachineInput, CreateMachineTemplate, CreateProjectInput, DEFAULT_STATELY_BASE_URL, EnsureProjectInput, ExtractMachinesInput, ExtractMachinesResponse, ExtractedMachine, ExtractedMachines, GetMachineOptions, LegacyExtractMachinesOptions, LegacyProjectVisibility, LegacyUpdateMachineInput, Machine, MachineVersion, Project, ProjectData, ProjectMachine, ProjectMachineSummary, ProjectSummary, ProjectVisibility, RepoType, ResourceErrorCode, StudioApiError, StudioApiErrorOptions, StudioClient, StudioClientOptions, StudioMachineRecord, StudioRequestOptions, UpdateMachineInput, UpdateProjectInput, VerifyApiKeyResponse, VerifyResult, XStateVersion, createStatelyClient };
package/dist/studio.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./openapi-BTDjYWXd.mjs";
2
- import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-CNkxMZyz.mjs";
2
+ import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-rSI54Ese.mjs";
3
3
 
4
4
  export { DEFAULT_STATELY_BASE_URL, StudioApiError, createStatelyClient };
package/dist/sync.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as DigraphConfig, i as StatelyGraph } from "./graph-BwHnhzpC.mjs";
2
- import { C as StudioMachineRecord, L as XStateVersion, g as ProjectData, o as CreateProjectInput, x as StudioClient } from "./studio-B9-1Ynrx.mjs";
1
+ import { b as DigraphConfig, i as StatelyGraph } from "./graph-C8E1Exad.mjs";
2
+ import { C as StudioMachineRecord, L as XStateVersion, g as ProjectData, o as CreateProjectInput, x as StudioClient } from "./studio-D-yqFd0u.mjs";
3
3
  import { GraphDiff } from "@statelyai/graph";
4
4
 
5
5
  //#region src/sync.d.ts
package/dist/sync.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./openapi-BTDjYWXd.mjs";
2
- import { r as createStatelyClient } from "./studio-CNkxMZyz.mjs";
3
- import { _ as normalizeMachineProfile, b as xstateSourceToConfig, c as detectXStateSourceProfile, f as graphChangeToPatchesResult, h as graphToXStateTS, i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, l as diffGraphsSemantically, n as getStatelyPragma, o as alignCompareGraphIds, p as graphToMachineConfig, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, y as serializeJS } from "./statelyPragma-ByF0-L-N.mjs";
2
+ import { r as createStatelyClient } from "./studio-rSI54Ese.mjs";
3
+ import { b as serializeJS, c as detectXStateSourceProfile, f as graphChangeToPatchesResult, h as graphToXStateTS, i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, l as diffGraphsSemantically, n as getStatelyPragma, o as alignCompareGraphIds, p as graphToMachineConfig, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, v as normalizeMachineProfile, x as xstateSourceToConfig } from "./statelyPragma-p1vu8PmH.mjs";
4
4
  import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
5
5
  import * as ts$1 from "typescript";
6
6
  import ts from "typescript";
@@ -580,9 +580,10 @@ function resolveIdentifierObject(expression, bindings) {
580
580
  }
581
581
  function resolveObjectLiteralProperty(objectLiteral, propertyName, bindings) {
582
582
  for (const property of objectLiteral.properties) {
583
- if (!ts$1.isPropertyAssignment(property)) continue;
583
+ if (!ts$1.isPropertyAssignment(property) && !ts$1.isShorthandPropertyAssignment(property)) continue;
584
584
  if (getPropertyNameText$2(property.name) !== propertyName) continue;
585
- const inlineObject = unwrapObjectLiteralExpression$1(property.initializer);
585
+ const initializer = ts$1.isShorthandPropertyAssignment(property) ? property.name : property.initializer;
586
+ const inlineObject = unwrapObjectLiteralExpression$1(initializer);
586
587
  if (inlineObject) return {
587
588
  object: inlineObject,
588
589
  kind: "inline",
@@ -591,15 +592,15 @@ function resolveObjectLiteralProperty(objectLiteral, propertyName, bindings) {
591
592
  uri: getSourceFileUri(property.getSourceFile()),
592
593
  bindings
593
594
  };
594
- if (ts$1.isIdentifier(property.initializer)) {
595
- const binding = bindings.get(property.initializer.text);
595
+ if (ts$1.isIdentifier(initializer)) {
596
+ const binding = bindings.get(initializer.text);
596
597
  if (binding?.kind !== "objectReference") return null;
597
598
  return {
598
599
  object: binding.node,
599
600
  kind: binding.kind,
600
- symbol: property.initializer.text,
601
+ symbol: initializer.text,
601
602
  keyRange: toSourceRange$1(property.getSourceFile(), property.name),
602
- referenceRange: toSourceRange$1(property.getSourceFile(), property.initializer),
603
+ referenceRange: toSourceRange$1(property.getSourceFile(), initializer),
603
604
  sourceFile: binding.sourceFile,
604
605
  uri: binding.uri,
605
606
  bindings: binding.bindings
@@ -809,7 +810,7 @@ function parseSourceToMachine(text, document, options = {}) {
809
810
  const statesText = readHydratedStatesObject(sourceLocations.statesObject.uri, sourceLocations.statesObject.range, sourceLocations.states, options.resolver);
810
811
  return statesText ? [{
811
812
  range: sourceLocations.statesObject.referenceRange,
812
- newText: statesText
813
+ newText: areSourceRangesEqual(sourceLocations.statesObject.referenceRange, sourceLocations.statesObject.keyRange) ? `states: ${statesText}` : statesText
813
814
  }] : [];
814
815
  })() : [];
815
816
  const importReplacements = collectHydratedImportReplacements(text, document, new Set([...sourceLocations.states.filter((location) => location.path.length === 1 && location.referenceRange).map((location) => location.symbol).filter((symbol) => typeof symbol === "string"), ...sourceLocations.statesObject?.symbol ? [sourceLocations.statesObject.symbol] : []]));
@@ -138,6 +138,7 @@ function toInitMessage(options) {
138
138
  mode: options.mode,
139
139
  theme: options.theme,
140
140
  readOnly: options.readOnly,
141
+ readOnlyReason: options.readOnlyReason,
141
142
  depth: options.depth,
142
143
  capabilities: options.capabilities,
143
144
  examples: options.examples,
@@ -303,7 +304,7 @@ function createWebSocketTransport(options) {
303
304
  code: "unsupported_protocol",
304
305
  message: `Relay selected protocol ${data.protocolVersion}; expected ${INSPECTION_PROTOCOL_VERSION}`
305
306
  });
306
- ws?.close(1002, "Unsupported inspection protocol");
307
+ ws?.close(4002, "Unsupported inspection protocol");
307
308
  return;
308
309
  }
309
310
  reconnectAttempts = 0;
@@ -316,7 +317,7 @@ function createWebSocketTransport(options) {
316
317
  code: data.code,
317
318
  message: data.message
318
319
  });
319
- ws?.close(1002, data.message.slice(0, 123));
320
+ ws?.close(4002, "Inspection registration rejected");
320
321
  }
321
322
  messageHandlers.forEach((fn) => fn(data));
322
323
  };
@@ -364,7 +365,7 @@ function createWebSocketTransport(options) {
364
365
 
365
366
  //#endregion
366
367
  //#region src/version.ts
367
- const SDK_VERSION = "0.28.0";
368
+ const SDK_VERSION = "0.29.1";
368
369
  function inspectionRuntime() {
369
370
  if (typeof window !== "undefined") return "browser";
370
371
  if (typeof process !== "undefined" && process.versions?.node) return "node";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/sdk",
3
- "version": "0.28.0",
3
+ "version": "0.29.1",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "stately-sdk": "./dist/bin.mjs"
@@ -93,8 +93,8 @@
93
93
  "jsdom": "^27.4.0",
94
94
  "tsdown": "0.21.0-beta.2",
95
95
  "vitest": "^3.2.4",
96
- "@statelyai/api-contract": "0.3.15",
97
- "@statelyai/graph-tools": "0.6.0"
96
+ "@statelyai/graph-tools": "0.7.2",
97
+ "@statelyai/api-contract": "0.4.3"
98
98
  },
99
99
  "engines": {
100
100
  "node": ">=22.4"