@statelyai/sdk 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,256 @@
1
1
  import * as _statelyai_graph0 from "@statelyai/graph";
2
2
  import { Graph } from "@statelyai/graph";
3
3
 
4
+ //#region ../../node_modules/.pnpm/@types+json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts
5
+ // ==================================================================================================
6
+ // JSON Schema Draft 07
7
+ // ==================================================================================================
8
+ // https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
9
+ // --------------------------------------------------------------------------------------------------
10
+ /**
11
+ * Primitive type
12
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
13
+ */
14
+ type JSONSchema7TypeName = "string" //
15
+ | "number" | "integer" | "boolean" | "object" | "array" | "null";
16
+ /**
17
+ * Primitive type
18
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
19
+ */
20
+ type JSONSchema7Type = string //
21
+ | number | boolean | JSONSchema7Object | JSONSchema7Array | null;
22
+ // Workaround for infinite type recursion
23
+ interface JSONSchema7Object {
24
+ [key: string]: JSONSchema7Type;
25
+ }
26
+ // Workaround for infinite type recursion
27
+ // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
28
+ interface JSONSchema7Array extends Array<JSONSchema7Type> {}
29
+ /**
30
+ * Meta schema
31
+ *
32
+ * Recommended values:
33
+ * - 'http://json-schema.org/schema#'
34
+ * - 'http://json-schema.org/hyper-schema#'
35
+ * - 'http://json-schema.org/draft-07/schema#'
36
+ * - 'http://json-schema.org/draft-07/hyper-schema#'
37
+ *
38
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
39
+ */
40
+ type JSONSchema7Version = string;
41
+ /**
42
+ * JSON Schema v7
43
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
44
+ */
45
+ type JSONSchema7Definition = JSONSchema7 | boolean;
46
+ interface JSONSchema7 {
47
+ $id?: string | undefined;
48
+ $ref?: string | undefined;
49
+ $schema?: JSONSchema7Version | undefined;
50
+ $comment?: string | undefined;
51
+ /**
52
+ * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
53
+ * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
54
+ */
55
+ $defs?: {
56
+ [key: string]: JSONSchema7Definition;
57
+ } | undefined;
58
+ /**
59
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
60
+ */
61
+ type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
62
+ enum?: JSONSchema7Type[] | undefined;
63
+ const?: JSONSchema7Type | undefined;
64
+ /**
65
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
66
+ */
67
+ multipleOf?: number | undefined;
68
+ maximum?: number | undefined;
69
+ exclusiveMaximum?: number | undefined;
70
+ minimum?: number | undefined;
71
+ exclusiveMinimum?: number | undefined;
72
+ /**
73
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
74
+ */
75
+ maxLength?: number | undefined;
76
+ minLength?: number | undefined;
77
+ pattern?: string | undefined;
78
+ /**
79
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
80
+ */
81
+ items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
82
+ additionalItems?: JSONSchema7Definition | undefined;
83
+ maxItems?: number | undefined;
84
+ minItems?: number | undefined;
85
+ uniqueItems?: boolean | undefined;
86
+ contains?: JSONSchema7Definition | undefined;
87
+ /**
88
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
89
+ */
90
+ maxProperties?: number | undefined;
91
+ minProperties?: number | undefined;
92
+ required?: string[] | undefined;
93
+ properties?: {
94
+ [key: string]: JSONSchema7Definition;
95
+ } | undefined;
96
+ patternProperties?: {
97
+ [key: string]: JSONSchema7Definition;
98
+ } | undefined;
99
+ additionalProperties?: JSONSchema7Definition | undefined;
100
+ dependencies?: {
101
+ [key: string]: JSONSchema7Definition | string[];
102
+ } | undefined;
103
+ propertyNames?: JSONSchema7Definition | undefined;
104
+ /**
105
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
106
+ */
107
+ if?: JSONSchema7Definition | undefined;
108
+ then?: JSONSchema7Definition | undefined;
109
+ else?: JSONSchema7Definition | undefined;
110
+ /**
111
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
112
+ */
113
+ allOf?: JSONSchema7Definition[] | undefined;
114
+ anyOf?: JSONSchema7Definition[] | undefined;
115
+ oneOf?: JSONSchema7Definition[] | undefined;
116
+ not?: JSONSchema7Definition | undefined;
117
+ /**
118
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
119
+ */
120
+ format?: string | undefined;
121
+ /**
122
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
123
+ */
124
+ contentMediaType?: string | undefined;
125
+ contentEncoding?: string | undefined;
126
+ /**
127
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
128
+ */
129
+ definitions?: {
130
+ [key: string]: JSONSchema7Definition;
131
+ } | undefined;
132
+ /**
133
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
134
+ */
135
+ title?: string | undefined;
136
+ description?: string | undefined;
137
+ default?: JSONSchema7Type | undefined;
138
+ readOnly?: boolean | undefined;
139
+ writeOnly?: boolean | undefined;
140
+ examples?: JSONSchema7Type | undefined;
141
+ }
142
+ //#endregion
143
+ //#region ../graph-tools/src/codegenTypes.d.ts
144
+ interface CodeGenAction {
145
+ type: string;
146
+ params?: Record<string, unknown>;
147
+ }
148
+ interface CodeGenGuard {
149
+ type: string;
150
+ code?: string;
151
+ params?: Record<string, unknown>;
152
+ }
153
+ /**
154
+ * Serialized inline expression directive.
155
+ *
156
+ * Code generation treats this object as JavaScript/TypeScript source, not as a
157
+ * machine config object. It is used for fields such as invoke `input` and
158
+ * `output` where XState accepts mapper expressions.
159
+ */
160
+ interface CodeExpression {
161
+ '@type': 'code';
162
+ lang: 'js' | 'ts';
163
+ expr: string;
164
+ }
165
+ interface CodeGenInvoke {
166
+ src: string;
167
+ id: string;
168
+ input?: Record<string, unknown> | CodeExpression;
169
+ output?: Record<string, unknown> | CodeExpression;
170
+ }
171
+ interface CodeGenNodeData {
172
+ nodeId?: string | null;
173
+ key: string;
174
+ type?: 'normal' | 'parallel' | 'final' | 'history' | null;
175
+ initialId?: string | null;
176
+ history?: 'shallow' | 'deep' | boolean;
177
+ entry?: CodeGenAction[];
178
+ exit?: CodeGenAction[];
179
+ invokes?: CodeGenInvoke[];
180
+ tags?: Array<string | {
181
+ name: string;
182
+ }>;
183
+ description?: string | null;
184
+ meta?: Record<string, unknown> | null;
185
+ color?: string;
186
+ parentId?: string | null;
187
+ temp?: boolean;
188
+ }
189
+ interface CodeGenEdgeData {
190
+ eventType: string;
191
+ transitionType?: 'normal' | 'targetless' | 'reenter';
192
+ guard?: CodeGenGuard | null;
193
+ actions?: CodeGenAction[];
194
+ description?: string | null;
195
+ color?: string;
196
+ meta?: Record<string, unknown> | null;
197
+ temp?: boolean;
198
+ }
199
+ interface CodeGenImplementation {
200
+ id: string;
201
+ name: string;
202
+ description?: string | null;
203
+ icon?: string;
204
+ paramsSchema?: JSONSchema7 | null;
205
+ code?: {
206
+ body: string;
207
+ lang?: string;
208
+ } | null;
209
+ }
210
+ interface CodeGenActorImplementation {
211
+ id: string;
212
+ name: string;
213
+ description?: string | null;
214
+ icon?: string;
215
+ inputSchema?: JSONSchema7 | null;
216
+ outputSchema?: JSONSchema7 | null;
217
+ code?: {
218
+ body: string;
219
+ lang?: string;
220
+ } | null;
221
+ }
222
+ interface CodeGenGraphData {
223
+ schemas?: {
224
+ context?: Record<string, JSONSchema7> | null;
225
+ events?: Record<string, JSONSchema7> | null;
226
+ input?: JSONSchema7 | null;
227
+ output?: JSONSchema7 | null;
228
+ } | null;
229
+ implementations?: {
230
+ actions: CodeGenImplementation[];
231
+ guards: CodeGenImplementation[];
232
+ actors: CodeGenActorImplementation[];
233
+ delays: CodeGenImplementation[];
234
+ } | null;
235
+ }
236
+ interface CodeGenNode {
237
+ id: string;
238
+ parentId?: string | null;
239
+ data: CodeGenNodeData;
240
+ }
241
+ interface CodeGenEdge {
242
+ id: string;
243
+ sourceId: string;
244
+ targetId: string;
245
+ data: CodeGenEdgeData;
246
+ }
247
+ interface CodeGenGraph {
248
+ id: string;
249
+ nodes: CodeGenNode[];
250
+ edges: CodeGenEdge[];
251
+ data: CodeGenGraphData;
252
+ }
253
+ //#endregion
4
254
  //#region src/digraphTypes.d.ts
5
255
  type CanvasColor = undefined | 'green' | 'red' | 'purple' | 'blue' | 'orange' | 'yellow' | 'pink' | 'teal';
6
256
  type ExtractorGuard = {
@@ -306,7 +556,7 @@ interface StatelyGuard {
306
556
  interface StatelyInvoke {
307
557
  src: string;
308
558
  id: string;
309
- input?: Record<string, unknown>;
559
+ input?: Record<string, unknown> | CodeExpression;
310
560
  }
311
561
  interface StatelyNodeData {
312
562
  key: string;
@@ -390,4 +640,4 @@ declare function toStudioMachine(graph: StatelyGraph): StudioMachine;
390
640
  declare function fromStudioMachine(studioMachine: StudioMachine): StatelyGraph;
391
641
  declare const studioMachineConverter: _statelyai_graph0.GraphFormatConverter<DigraphConfig, StatelyNodeData, StatelyEdgeData, StatelyGraphData>;
392
642
  //#endregion
393
- export { EventTypeData as C, DigraphNodeConfig as S, studioMachineConverter as _, StatelyGraphData as a, DigraphConfig as b, StatelyInvoke as c, StudioAction as d, StudioEdge as f, fromStudioMachine as g, StudioNode as h, StatelyGraph as i, StatelyNodeData as l, StudioMachine as m, StatelyActorImplementation as n, StatelyGuard as o, StudioEventTypeData as p, StatelyEdgeData as r, StatelyImplementation as s, StatelyAction as t, StatelyTagImplementation as u, toStudioMachine as v, StateNodeJSONData as w, DigraphEdgeConfig as x, DigraphAction as y };
643
+ export { EventTypeData as C, JSONSchema7 as E, DigraphNodeConfig as S, CodeGenGraph as T, studioMachineConverter as _, StatelyGraphData as a, DigraphConfig as b, StatelyInvoke as c, StudioAction as d, StudioEdge as f, fromStudioMachine as g, StudioNode as h, StatelyGraph as i, StatelyNodeData as l, StudioMachine as m, StatelyActorImplementation as n, StatelyGuard as o, StudioEventTypeData as p, StatelyEdgeData as r, StatelyImplementation as s, StatelyAction as t, StatelyTagImplementation as u, toStudioMachine as v, StateNodeJSONData as w, DigraphEdgeConfig as x, DigraphAction as y };
package/dist/graph.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as studioMachineConverter, a as StatelyGraphData, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, n as StatelyActorImplementation, o as StatelyGuard, p as StudioEventTypeData, r as StatelyEdgeData, s as StatelyImplementation, t as StatelyAction, u as StatelyTagImplementation, v as toStudioMachine } from "./graph-CJ3N2r43.mjs";
1
+ import { _ as studioMachineConverter, a as StatelyGraphData, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, n as StatelyActorImplementation, o as StatelyGuard, p as StudioEventTypeData, r as StatelyEdgeData, s as StatelyImplementation, t as StatelyAction, u as StatelyTagImplementation, v as toStudioMachine } from "./graph-DmXh22Zu.mjs";
2
2
  export { StatelyAction, StatelyActorImplementation, StatelyEdgeData, StatelyGraph, StatelyGraphData, StatelyGuard, StatelyImplementation, StatelyInvoke, StatelyNodeData, StatelyTagImplementation, StudioAction, StudioEdge, StudioEventTypeData, StudioMachine, StudioNode, fromStudioMachine, studioMachineConverter, toStudioMachine };
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createS
2
2
  import { CommentsConfig, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
3
3
  import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
4
4
  import { AssetConfig, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
5
- import { C as EventTypeData, S as DigraphNodeConfig, _ as studioMachineConverter, a as StatelyGraphData, b as DigraphConfig, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, o as StatelyGuard, r as StatelyEdgeData, t as StatelyAction, v as toStudioMachine, w as StateNodeJSONData, x as DigraphEdgeConfig, y as DigraphAction } from "./graph-CJ3N2r43.mjs";
5
+ import { C as EventTypeData, E as JSONSchema7, S as DigraphNodeConfig, T as CodeGenGraph, _ as studioMachineConverter, a as StatelyGraphData, b as DigraphConfig, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, o as StatelyGuard, r as StatelyEdgeData, t as StatelyAction, v as toStudioMachine, w as StateNodeJSONData, x as DigraphEdgeConfig, y as DigraphAction } from "./graph-DmXh22Zu.mjs";
6
6
  import { a as ManualActorOptions, c as createPostMessageTransport, i as InspectorEvents, l as createWebSocketTransport, n as CreateInspectorOptions, o as createStatelyInspector, r as Inspector, s as Transport, t as AdoptedActor } from "./inspect-BLlM3qKf.mjs";
7
7
  import { ConnectedRepo, CreateMachineFromDefinitionInput, CreateMachineFromTemplateInput, CreateMachineInput, CreateMachineTemplate, CreateProjectInput, EnsureProjectInput, ExtractMachinesResponse, ExtractedMachine, GetMachineOptions, ProjectData, ProjectMachine, ProjectVisibility, RepoType, StudioApiError, StudioClient, StudioClientOptions, StudioMachineRecord, UpdateMachineInput, VerifyApiKeyResponse, XStateVersion, createStatelyClient } from "./studio.mjs";
8
8
  import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
@@ -31,256 +31,6 @@ declare function findStatelyPragmaAttachments(sourceText: string, fileName?: str
31
31
  declare function getStatelyPragma(sourceText: string, fileName?: string, machineIndex?: number): StatelyPragma | undefined;
32
32
  declare function upsertStatelyPragma(sourceText: string, id: string, options?: UpsertStatelyPragmaOptions): string;
33
33
  //#endregion
34
- //#region ../../node_modules/.pnpm/@types+json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts
35
- // ==================================================================================================
36
- // JSON Schema Draft 07
37
- // ==================================================================================================
38
- // https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
39
- // --------------------------------------------------------------------------------------------------
40
- /**
41
- * Primitive type
42
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
43
- */
44
- type JSONSchema7TypeName = "string" //
45
- | "number" | "integer" | "boolean" | "object" | "array" | "null";
46
- /**
47
- * Primitive type
48
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
49
- */
50
- type JSONSchema7Type = string //
51
- | number | boolean | JSONSchema7Object | JSONSchema7Array | null;
52
- // Workaround for infinite type recursion
53
- interface JSONSchema7Object {
54
- [key: string]: JSONSchema7Type;
55
- }
56
- // Workaround for infinite type recursion
57
- // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
58
- interface JSONSchema7Array extends Array<JSONSchema7Type> {}
59
- /**
60
- * Meta schema
61
- *
62
- * Recommended values:
63
- * - 'http://json-schema.org/schema#'
64
- * - 'http://json-schema.org/hyper-schema#'
65
- * - 'http://json-schema.org/draft-07/schema#'
66
- * - 'http://json-schema.org/draft-07/hyper-schema#'
67
- *
68
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
69
- */
70
- type JSONSchema7Version = string;
71
- /**
72
- * JSON Schema v7
73
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
74
- */
75
- type JSONSchema7Definition = JSONSchema7 | boolean;
76
- interface JSONSchema7 {
77
- $id?: string | undefined;
78
- $ref?: string | undefined;
79
- $schema?: JSONSchema7Version | undefined;
80
- $comment?: string | undefined;
81
- /**
82
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
83
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
84
- */
85
- $defs?: {
86
- [key: string]: JSONSchema7Definition;
87
- } | undefined;
88
- /**
89
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
90
- */
91
- type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
92
- enum?: JSONSchema7Type[] | undefined;
93
- const?: JSONSchema7Type | undefined;
94
- /**
95
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
96
- */
97
- multipleOf?: number | undefined;
98
- maximum?: number | undefined;
99
- exclusiveMaximum?: number | undefined;
100
- minimum?: number | undefined;
101
- exclusiveMinimum?: number | undefined;
102
- /**
103
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
104
- */
105
- maxLength?: number | undefined;
106
- minLength?: number | undefined;
107
- pattern?: string | undefined;
108
- /**
109
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
110
- */
111
- items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
112
- additionalItems?: JSONSchema7Definition | undefined;
113
- maxItems?: number | undefined;
114
- minItems?: number | undefined;
115
- uniqueItems?: boolean | undefined;
116
- contains?: JSONSchema7Definition | undefined;
117
- /**
118
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
119
- */
120
- maxProperties?: number | undefined;
121
- minProperties?: number | undefined;
122
- required?: string[] | undefined;
123
- properties?: {
124
- [key: string]: JSONSchema7Definition;
125
- } | undefined;
126
- patternProperties?: {
127
- [key: string]: JSONSchema7Definition;
128
- } | undefined;
129
- additionalProperties?: JSONSchema7Definition | undefined;
130
- dependencies?: {
131
- [key: string]: JSONSchema7Definition | string[];
132
- } | undefined;
133
- propertyNames?: JSONSchema7Definition | undefined;
134
- /**
135
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
136
- */
137
- if?: JSONSchema7Definition | undefined;
138
- then?: JSONSchema7Definition | undefined;
139
- else?: JSONSchema7Definition | undefined;
140
- /**
141
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
142
- */
143
- allOf?: JSONSchema7Definition[] | undefined;
144
- anyOf?: JSONSchema7Definition[] | undefined;
145
- oneOf?: JSONSchema7Definition[] | undefined;
146
- not?: JSONSchema7Definition | undefined;
147
- /**
148
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
149
- */
150
- format?: string | undefined;
151
- /**
152
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
153
- */
154
- contentMediaType?: string | undefined;
155
- contentEncoding?: string | undefined;
156
- /**
157
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
158
- */
159
- definitions?: {
160
- [key: string]: JSONSchema7Definition;
161
- } | undefined;
162
- /**
163
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
164
- */
165
- title?: string | undefined;
166
- description?: string | undefined;
167
- default?: JSONSchema7Type | undefined;
168
- readOnly?: boolean | undefined;
169
- writeOnly?: boolean | undefined;
170
- examples?: JSONSchema7Type | undefined;
171
- }
172
- //#endregion
173
- //#region ../graph-tools/src/codegenTypes.d.ts
174
- interface CodeGenAction {
175
- type: string;
176
- params?: Record<string, unknown>;
177
- }
178
- interface CodeGenGuard {
179
- type: string;
180
- code?: string;
181
- params?: Record<string, unknown>;
182
- }
183
- /**
184
- * Serialized inline expression directive.
185
- *
186
- * Code generation treats this object as JavaScript/TypeScript source, not as a
187
- * machine config object. It is used for fields such as invoke `input` and
188
- * `output` where XState accepts mapper expressions.
189
- */
190
- interface CodeExpression {
191
- '@type': 'code';
192
- lang: 'js' | 'ts';
193
- expr: string;
194
- }
195
- interface CodeGenInvoke {
196
- src: string;
197
- id: string;
198
- input?: Record<string, unknown> | CodeExpression;
199
- output?: Record<string, unknown> | CodeExpression;
200
- }
201
- interface CodeGenNodeData {
202
- nodeId?: string | null;
203
- key: string;
204
- type?: 'normal' | 'parallel' | 'final' | 'history' | null;
205
- initialId?: string | null;
206
- history?: 'shallow' | 'deep' | boolean;
207
- entry?: CodeGenAction[];
208
- exit?: CodeGenAction[];
209
- invokes?: CodeGenInvoke[];
210
- tags?: Array<string | {
211
- name: string;
212
- }>;
213
- description?: string | null;
214
- meta?: Record<string, unknown> | null;
215
- color?: string;
216
- parentId?: string | null;
217
- temp?: boolean;
218
- }
219
- interface CodeGenEdgeData {
220
- eventType: string;
221
- transitionType?: 'normal' | 'targetless' | 'reenter';
222
- guard?: CodeGenGuard | null;
223
- actions?: CodeGenAction[];
224
- description?: string | null;
225
- color?: string;
226
- meta?: Record<string, unknown> | null;
227
- temp?: boolean;
228
- }
229
- interface CodeGenImplementation {
230
- id: string;
231
- name: string;
232
- description?: string | null;
233
- icon?: string;
234
- paramsSchema?: JSONSchema7 | null;
235
- code?: {
236
- body: string;
237
- lang?: string;
238
- } | null;
239
- }
240
- interface CodeGenActorImplementation {
241
- id: string;
242
- name: string;
243
- description?: string | null;
244
- icon?: string;
245
- inputSchema?: JSONSchema7 | null;
246
- outputSchema?: JSONSchema7 | null;
247
- code?: {
248
- body: string;
249
- lang?: string;
250
- } | null;
251
- }
252
- interface CodeGenGraphData {
253
- schemas?: {
254
- context?: Record<string, JSONSchema7> | null;
255
- events?: Record<string, JSONSchema7> | null;
256
- input?: JSONSchema7 | null;
257
- output?: JSONSchema7 | null;
258
- } | null;
259
- implementations?: {
260
- actions: CodeGenImplementation[];
261
- guards: CodeGenImplementation[];
262
- actors: CodeGenActorImplementation[];
263
- delays: CodeGenImplementation[];
264
- } | null;
265
- }
266
- interface CodeGenNode {
267
- id: string;
268
- parentId?: string | null;
269
- data: CodeGenNodeData;
270
- }
271
- interface CodeGenEdge {
272
- id: string;
273
- sourceId: string;
274
- targetId: string;
275
- data: CodeGenEdgeData;
276
- }
277
- interface CodeGenGraph {
278
- id: string;
279
- nodes: CodeGenNode[];
280
- edges: CodeGenEdge[];
281
- data: CodeGenGraphData;
282
- }
283
- //#endregion
284
34
  //#region ../graph-tools/src/graphToMachineConfig.d.ts
285
35
  interface MachineConfigOptions {
286
36
  showDescriptions?: boolean;
package/dist/sync.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { b as DigraphConfig, i as StatelyGraph } from "./graph-CJ3N2r43.mjs";
1
+ import { b as DigraphConfig, i as StatelyGraph } from "./graph-DmXh22Zu.mjs";
2
2
  import { CreateProjectInput, ProjectData, StudioClient, StudioMachineRecord, XStateVersion } from "./studio.mjs";
3
3
  import { GraphDiff } from "@statelyai/graph";
4
4
 
@@ -45,6 +45,7 @@ interface PushSyncProjectOptions extends CreateProjectInput {
45
45
  interface PushSyncOptions extends Omit<PlanSyncOptions, 'target'> {
46
46
  project?: PushSyncProjectOptions;
47
47
  xstateVersion?: XStateVersion;
48
+ relink?: boolean;
48
49
  }
49
50
  interface PushSyncResult {
50
51
  source: ResolvedSyncInput;
package/dist/sync.mjs CHANGED
@@ -586,10 +586,15 @@ function offsetAtRangePosition(text, line, character) {
586
586
  return text.length;
587
587
  }
588
588
 
589
+ //#endregion
590
+ //#region ../graph-tools/src/codegenTypes.ts
591
+ const INLINE_EXPRESSION_DIRECTIVE_FIELDS = ["input", "output"];
592
+
589
593
  //#endregion
590
594
  //#region src/sync.ts
591
595
  const execFileAsync = promisify(execFile);
592
596
  const MAX_CAPTURED_LOCAL_MACHINES = 100;
597
+ const INLINE_EXPRESSION_FIELD_SET = new Set(INLINE_EXPRESSION_DIRECTIVE_FIELDS);
593
598
  async function extractMachinesFromLocalSource(sourcePath, contents) {
594
599
  try {
595
600
  return { machines: extractMachineConfigsFromAst(sourcePath, parseSourceToMachine(contents, createTextDocument(sourcePath, contents), { resolver: createFileSourceDocumentResolver() })) };
@@ -704,7 +709,12 @@ function evaluateExpression(expression, sourceFile, bindings, seenBindings) {
704
709
  if (!ts.isPropertyAssignment(property)) continue;
705
710
  const key = resolvePropertyNameValue(property.name, sourceFile, bindings, seenBindings);
706
711
  if (key == null) continue;
707
- result[String(key)] = evaluateExpression(property.initializer, sourceFile, bindings, seenBindings);
712
+ const fieldName = String(key);
713
+ if (shouldPreserveInlineExpression(fieldName, property.initializer, sourceFile, bindings, seenBindings)) {
714
+ result[fieldName] = createInlineExpressionDirective(property.initializer.getText(sourceFile));
715
+ continue;
716
+ }
717
+ result[fieldName] = evaluateExpression(property.initializer, sourceFile, bindings, seenBindings);
708
718
  }
709
719
  return result;
710
720
  }
@@ -728,6 +738,26 @@ function evaluateExpression(expression, sourceFile, bindings, seenBindings) {
728
738
  }
729
739
  return unwrapped.getText(sourceFile);
730
740
  }
741
+ function shouldPreserveInlineExpression(fieldName, expression, sourceFile, bindings, seenBindings) {
742
+ if (!INLINE_EXPRESSION_FIELD_SET.has(fieldName)) return false;
743
+ const unwrapped = unwrapExpression(expression);
744
+ if (ts.isIdentifier(unwrapped)) {
745
+ const binding = bindings.get(unwrapped.text);
746
+ if (!binding || binding.kind !== "value" || seenBindings.has(unwrapped.text)) return true;
747
+ const nextSeen = new Set(seenBindings);
748
+ nextSeen.add(unwrapped.text);
749
+ return shouldPreserveInlineExpression(fieldName, binding.expression, sourceFile, bindings, nextSeen);
750
+ }
751
+ if (ts.isStringLiteral(unwrapped) || ts.isNoSubstitutionTemplateLiteral(unwrapped) || ts.isNumericLiteral(unwrapped) || unwrapped.kind === ts.SyntaxKind.TrueKeyword || unwrapped.kind === ts.SyntaxKind.FalseKeyword || unwrapped.kind === ts.SyntaxKind.NullKeyword || ts.isObjectLiteralExpression(unwrapped) || ts.isArrayLiteralExpression(unwrapped)) return false;
752
+ return unwrapped.getText(sourceFile).trim().length > 0;
753
+ }
754
+ function createInlineExpressionDirective(expr) {
755
+ return {
756
+ "@type": "code",
757
+ lang: "ts",
758
+ expr
759
+ };
760
+ }
731
761
  function resolvePropertyNameValue(name, sourceFile, bindings, seenBindings) {
732
762
  if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNumericLiteral(name)) return name.text;
733
763
  if (!ts.isComputedPropertyName(name)) return null;
@@ -990,7 +1020,7 @@ async function pushLocalMachineLinks(options) {
990
1020
  });
991
1021
  continue;
992
1022
  }
993
- if (attachment.pragma?.id) {
1023
+ if (attachment.pragma?.id && !options.relink) {
994
1024
  const updatedMachine = await client.machines.update({
995
1025
  id: attachment.pragma.id,
996
1026
  definition: toStudioMachine(fromXStateConfig(extractedMachine.config))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/sdk",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",