@statelyai/sdk 0.4.1 → 0.5.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.
- package/LICENSE +7 -675
- package/README.md +269 -161
- package/dist/cli.d.mts +24 -5
- package/dist/cli.mjs +719 -18
- package/dist/embed.d.mts +3 -3
- package/dist/embed.mjs +23 -9
- package/dist/graph.mjs +27 -19
- package/dist/{graphToXStateTS-Cfp_fxSH.mjs → graphToXStateTS-CtecEESq.mjs} +58 -20
- package/dist/index.d.mts +20 -35
- package/dist/index.mjs +2 -2
- package/dist/inspect-ttRIjoCu.d.mts +206 -0
- package/dist/inspect.d.mts +3 -49
- package/dist/inspect.mjs +229 -62
- package/dist/patchTypes.d.mts +249 -0
- package/dist/patchTypes.mjs +1 -0
- package/dist/protocol-BPuwbNCz.d.mts +401 -0
- package/dist/sync.mjs +1 -1
- package/dist/{transport-C1fRAuv-.mjs → transport-DoCHBLTu.mjs} +19 -14
- package/package.json +12 -4
- package/dist/protocol-CZVFCSg3.d.mts +0 -225
package/dist/inspect.d.mts
CHANGED
|
@@ -1,49 +1,3 @@
|
|
|
1
|
-
import { a as EmbedMode, c as ExportFormatMap, i as EmbedEventName, n as EmbedEventHandler, o as ExportCallOptions, r as EmbedEventMap, s as ExportFormat } from "./protocol-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface CreateInspectorOptions {
|
|
5
|
-
/** WebSocket URL of the devtools server. Default: 'ws://localhost:4242' */
|
|
6
|
-
url?: string;
|
|
7
|
-
/** Auto-open browser to visualizer. Default: true */
|
|
8
|
-
autoOpen?: boolean;
|
|
9
|
-
/** Unique session ID. Auto-generated if not provided. */
|
|
10
|
-
sessionId?: string;
|
|
11
|
-
/** Display name for this connection in the visualizer. */
|
|
12
|
-
name?: string;
|
|
13
|
-
}
|
|
14
|
-
interface Inspector {
|
|
15
|
-
/** Send a machine for inspection (starts visualization). */
|
|
16
|
-
inspect(options: InspectOptions): void;
|
|
17
|
-
/** Update the machine currently being inspected. */
|
|
18
|
-
update(machine: unknown, format?: string): void;
|
|
19
|
-
/** Change the visualization mode. */
|
|
20
|
-
setMode(mode: EmbedMode): void;
|
|
21
|
-
/** Export the current machine in a given format. Returns a promise. */
|
|
22
|
-
export<F extends ExportFormat>(format: F, options?: ExportCallOptions<F>): Promise<ExportFormatMap[F]['result']>;
|
|
23
|
-
/** Subscribe to events from the visualizer. */
|
|
24
|
-
on<K extends EmbedEventName>(event: K, handler: EmbedEventHandler<K>): void;
|
|
25
|
-
/** Unsubscribe from an event. */
|
|
26
|
-
off<K extends EmbedEventName>(event: K, handler: EmbedEventHandler<K>): void;
|
|
27
|
-
/** Send a state snapshot for real-time inspection. */
|
|
28
|
-
sendSnapshot(snapshot: unknown, event?: unknown): void;
|
|
29
|
-
/** Clean up the connection. */
|
|
30
|
-
destroy(): void;
|
|
31
|
-
/** Session ID for this connection. */
|
|
32
|
-
readonly sessionId: string;
|
|
33
|
-
}
|
|
34
|
-
interface InspectOptions {
|
|
35
|
-
machine: unknown;
|
|
36
|
-
format?: string;
|
|
37
|
-
mode?: EmbedMode;
|
|
38
|
-
theme?: 'light' | 'dark';
|
|
39
|
-
readOnly?: boolean;
|
|
40
|
-
depth?: number;
|
|
41
|
-
panels?: {
|
|
42
|
-
leftPanels?: string[];
|
|
43
|
-
rightPanels?: string[];
|
|
44
|
-
activePanels?: string[];
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
declare function createStatelyInspector(options?: CreateInspectorOptions): Inspector;
|
|
48
|
-
//#endregion
|
|
49
|
-
export { CreateInspectorOptions, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type ExportCallOptions, type ExportFormat, type ExportFormatMap, InspectOptions, Inspector, createStatelyInspector };
|
|
1
|
+
import { a as EmbedMode, c as ExportFormatMap, i as EmbedEventName, n as EmbedEventHandler, o as ExportCallOptions, r as EmbedEventMap, s as ExportFormat } from "./protocol-BPuwbNCz.mjs";
|
|
2
|
+
import { a as ManualActorOptions, i as InspectorEvents, n as CreateInspectorOptions, o as createStatelyInspector, r as Inspector, s as Transport, t as AdoptedActor } from "./inspect-ttRIjoCu.mjs";
|
|
3
|
+
export { AdoptedActor, CreateInspectorOptions, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, Inspector, InspectorEvents, ManualActorOptions, Transport, createStatelyInspector };
|
package/dist/inspect.mjs
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as createPendingExportManager, n as createWebSocketTransport, r as createEventRegistry } from "./transport-DoCHBLTu.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/inspect.ts
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const defaultSerializeSnapshot = (snapshot) => ({
|
|
5
|
+
value: snapshot?.value,
|
|
6
|
+
status: snapshot?.status
|
|
7
|
+
});
|
|
8
|
+
const defaultExtractMachineConfig = (actor) => actor?.logic?.config ?? null;
|
|
9
|
+
let nextManualId = 0;
|
|
10
|
+
function generateSessionId() {
|
|
11
|
+
return `manual-${Date.now()}-${nextManualId++}`;
|
|
6
12
|
}
|
|
7
13
|
function createStatelyInspector(options) {
|
|
8
|
-
const { url = "ws://localhost:4242", autoOpen = true,
|
|
14
|
+
const { url = "ws://localhost:4242", autoOpen = true, actor: rootActor, name, serializeSnapshot = defaultSerializeSnapshot, extractMachineConfig = defaultExtractMachineConfig, selectedActorId, panels, theme, readOnly, depth, transport: injectedTransport } = options;
|
|
15
|
+
const root = rootActor ? rootActor : null;
|
|
16
|
+
const rootActorId = root?.sessionId ?? generateSessionId();
|
|
17
|
+
const sessionId = options.sessionId ?? rootActorId;
|
|
18
|
+
const displayName = name ?? (root ? `system:${root.id}` : "system:manual");
|
|
9
19
|
let destroyed = false;
|
|
20
|
+
let initSent = false;
|
|
10
21
|
const pendingMessages = [];
|
|
11
22
|
const events = createEventRegistry();
|
|
12
|
-
const
|
|
23
|
+
const localListeners = {};
|
|
24
|
+
const transport = injectedTransport ?? createWebSocketTransport({
|
|
13
25
|
url,
|
|
14
26
|
role: "client",
|
|
15
27
|
sessionId,
|
|
16
|
-
|
|
28
|
+
metadata: { name: displayName }
|
|
17
29
|
});
|
|
30
|
+
const ownsTransport = !injectedTransport;
|
|
18
31
|
const exportManager = createPendingExportManager((message) => send(message));
|
|
19
32
|
function send(msg) {
|
|
20
33
|
if (!transport.ready) {
|
|
@@ -23,17 +36,11 @@ function createStatelyInspector(options) {
|
|
|
23
36
|
}
|
|
24
37
|
transport.send(msg);
|
|
25
38
|
}
|
|
26
|
-
function flush() {
|
|
27
|
-
while (pendingMessages.length > 0) {
|
|
28
|
-
const msg = pendingMessages.shift();
|
|
29
|
-
transport.send(msg);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
39
|
transport.onReady(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
transport.send({
|
|
40
|
+
pendingMessages.length = 0;
|
|
41
|
+
initSent = false;
|
|
42
|
+
sendInit();
|
|
43
|
+
if (autoOpen) transport.send({
|
|
37
44
|
type: "@statelyai.requestOpen",
|
|
38
45
|
sessionId
|
|
39
46
|
});
|
|
@@ -41,79 +48,239 @@ function createStatelyInspector(options) {
|
|
|
41
48
|
transport.onMessage((msg) => {
|
|
42
49
|
if (destroyed) return;
|
|
43
50
|
switch (msg.type) {
|
|
44
|
-
case "@statelyai.ready":
|
|
45
|
-
events.emit("ready", { version: msg.version });
|
|
46
|
-
break;
|
|
47
|
-
case "@statelyai.loaded":
|
|
48
|
-
events.emit("loaded", { graph: msg.graph });
|
|
49
|
-
break;
|
|
50
|
-
case "@statelyai.change":
|
|
51
|
-
events.emit("change", {
|
|
52
|
-
graph: msg.graph,
|
|
53
|
-
machineConfig: msg.machineConfig
|
|
54
|
-
});
|
|
55
|
-
break;
|
|
56
|
-
case "@statelyai.save":
|
|
57
|
-
events.emit("save", {
|
|
58
|
-
graph: msg.graph,
|
|
59
|
-
machineConfig: msg.machineConfig
|
|
60
|
-
});
|
|
61
|
-
break;
|
|
62
51
|
case "@statelyai.retrieved":
|
|
63
52
|
exportManager.resolve(msg.requestId, msg.data);
|
|
64
53
|
break;
|
|
65
54
|
case "@statelyai.error":
|
|
66
55
|
exportManager.reject(new Error(msg.message), msg.requestId);
|
|
56
|
+
emitLocal("error", {
|
|
57
|
+
code: msg.code,
|
|
58
|
+
message: msg.message
|
|
59
|
+
});
|
|
67
60
|
events.emit("error", {
|
|
68
61
|
code: msg.code,
|
|
69
62
|
message: msg.message
|
|
70
63
|
});
|
|
71
64
|
break;
|
|
65
|
+
default: break;
|
|
72
66
|
}
|
|
73
67
|
});
|
|
68
|
+
function emitLocal(event, data) {
|
|
69
|
+
const set = localListeners[event];
|
|
70
|
+
if (!set) return;
|
|
71
|
+
for (const handler of set) handler(data);
|
|
72
|
+
}
|
|
73
|
+
const actors = /* @__PURE__ */ new Map();
|
|
74
|
+
/** Tracks which actors we've already emitted local 'register' events for. */
|
|
75
|
+
const locallyRegistered = /* @__PURE__ */ new Set();
|
|
76
|
+
/**
|
|
77
|
+
* Maps target actorId → source actorId for the most recent `@xstate.event`.
|
|
78
|
+
* Read + cleared by `handleSnapshot` so the source info propagates into the
|
|
79
|
+
* `actorSnapshot` message. xstate emits `@xstate.event` immediately before
|
|
80
|
+
* `@xstate.snapshot` for the same actor.
|
|
81
|
+
*/
|
|
82
|
+
const pendingEventSource = /* @__PURE__ */ new Map();
|
|
83
|
+
function emitRegisterOnce(entry) {
|
|
84
|
+
if (locallyRegistered.has(entry.actorId)) return;
|
|
85
|
+
locallyRegistered.add(entry.actorId);
|
|
86
|
+
emitLocal("register", entry);
|
|
87
|
+
}
|
|
88
|
+
function snapshotValue(actorRef) {
|
|
89
|
+
try {
|
|
90
|
+
return serializeSnapshot(actorRef.getSnapshot());
|
|
91
|
+
} catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function toEntry(actorRef) {
|
|
96
|
+
return {
|
|
97
|
+
actorId: actorRef.sessionId,
|
|
98
|
+
parentActorId: actorRef._parent?.sessionId ?? null,
|
|
99
|
+
rootId: rootActorId,
|
|
100
|
+
id: actorRef.id,
|
|
101
|
+
systemId: actorRef.systemId,
|
|
102
|
+
snapshot: snapshotValue(actorRef),
|
|
103
|
+
machineConfig: extractMachineConfig(actorRef)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function toSystemEntry(entry) {
|
|
107
|
+
return {
|
|
108
|
+
actorId: entry.actorId,
|
|
109
|
+
parentActorId: entry.parentActorId,
|
|
110
|
+
id: entry.id,
|
|
111
|
+
machine: entry.machineConfig,
|
|
112
|
+
snapshot: entry.snapshot ?? void 0
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Walk the actor tree and populate the local `actors` map. Idempotent —
|
|
117
|
+
* existing entries stay in place but have their snapshot refreshed.
|
|
118
|
+
*/
|
|
119
|
+
function backfillActorTree(actorRef) {
|
|
120
|
+
const existing = actors.get(actorRef.sessionId);
|
|
121
|
+
const entry = existing ?? toEntry(actorRef);
|
|
122
|
+
if (existing) existing.snapshot = snapshotValue(actorRef);
|
|
123
|
+
else actors.set(entry.actorId, entry);
|
|
124
|
+
emitRegisterOnce(entry);
|
|
125
|
+
const children = actorRef.getSnapshot()?.children ?? {};
|
|
126
|
+
for (const child of Object.values(children)) if (child) backfillActorTree(child);
|
|
127
|
+
}
|
|
128
|
+
function sendInit() {
|
|
129
|
+
if (root) backfillActorTree(root);
|
|
130
|
+
send({
|
|
131
|
+
type: "@statelyai.system.init",
|
|
132
|
+
mode: "inspecting",
|
|
133
|
+
actors: Array.from(actors.values()).map(toSystemEntry),
|
|
134
|
+
selectedActorId: selectedActorId ?? rootActorId,
|
|
135
|
+
...theme && { theme },
|
|
136
|
+
...readOnly !== void 0 && { readOnly },
|
|
137
|
+
...depth !== void 0 && { depth },
|
|
138
|
+
...panels?.leftPanels && { leftPanels: panels.leftPanels },
|
|
139
|
+
...panels?.rightPanels && { rightPanels: panels.rightPanels },
|
|
140
|
+
...panels?.activePanels && { activePanels: panels.activePanels }
|
|
141
|
+
});
|
|
142
|
+
initSent = true;
|
|
143
|
+
}
|
|
144
|
+
function handleActor(actorRef) {
|
|
145
|
+
if (actors.has(actorRef.sessionId)) return;
|
|
146
|
+
const entry = toEntry(actorRef);
|
|
147
|
+
actors.set(entry.actorId, entry);
|
|
148
|
+
if (!initSent) return;
|
|
149
|
+
send({
|
|
150
|
+
type: "@statelyai.system.actorRegistered",
|
|
151
|
+
actorId: entry.actorId,
|
|
152
|
+
parentActorId: entry.parentActorId,
|
|
153
|
+
id: entry.id,
|
|
154
|
+
machine: entry.machineConfig,
|
|
155
|
+
snapshot: entry.snapshot ?? void 0
|
|
156
|
+
});
|
|
157
|
+
emitRegisterOnce(entry);
|
|
158
|
+
}
|
|
159
|
+
function handleSnapshot(actorRef, snapshot, triggeringEvent) {
|
|
160
|
+
if (!actors.has(actorRef.sessionId)) handleActor(actorRef);
|
|
161
|
+
const entry = actors.get(actorRef.sessionId);
|
|
162
|
+
if (!entry) return;
|
|
163
|
+
const serialized = serializeSnapshot(snapshot);
|
|
164
|
+
entry.snapshot = serialized;
|
|
165
|
+
const sourceActorId = pendingEventSource.get(entry.actorId) ?? null;
|
|
166
|
+
pendingEventSource.delete(entry.actorId);
|
|
167
|
+
if (initSent) send({
|
|
168
|
+
type: "@statelyai.system.actorSnapshot",
|
|
169
|
+
actorId: entry.actorId,
|
|
170
|
+
snapshot: serialized,
|
|
171
|
+
event: triggeringEvent ?? null,
|
|
172
|
+
...sourceActorId ? { sourceActorId } : {}
|
|
173
|
+
});
|
|
174
|
+
emitLocal("snapshot", entry);
|
|
175
|
+
const status = snapshot?.status;
|
|
176
|
+
if (status === "done" || status === "stopped" || status === "error") {
|
|
177
|
+
actors.delete(entry.actorId);
|
|
178
|
+
pendingEventSource.delete(entry.actorId);
|
|
179
|
+
if (initSent) send({
|
|
180
|
+
type: "@statelyai.system.actorStopped",
|
|
181
|
+
actorId: entry.actorId
|
|
182
|
+
});
|
|
183
|
+
emitLocal("stopped", { actorId: entry.actorId });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (root) backfillActorTree(root);
|
|
187
|
+
const subscription = root ? root.system.inspect((inspectionEvent) => {
|
|
188
|
+
if (destroyed) return;
|
|
189
|
+
switch (inspectionEvent.type) {
|
|
190
|
+
case "@xstate.actor":
|
|
191
|
+
handleActor(inspectionEvent.actorRef);
|
|
192
|
+
break;
|
|
193
|
+
case "@xstate.event":
|
|
194
|
+
if (inspectionEvent.sourceRef) pendingEventSource.set(inspectionEvent.actorRef.sessionId, inspectionEvent.sourceRef.sessionId);
|
|
195
|
+
break;
|
|
196
|
+
case "@xstate.snapshot":
|
|
197
|
+
handleSnapshot(inspectionEvent.actorRef, inspectionEvent.snapshot, inspectionEvent.event);
|
|
198
|
+
break;
|
|
199
|
+
default: break;
|
|
200
|
+
}
|
|
201
|
+
}) : null;
|
|
202
|
+
function manualRegister(id, opts) {
|
|
203
|
+
if (actors.has(id)) return;
|
|
204
|
+
const entry = {
|
|
205
|
+
actorId: id,
|
|
206
|
+
parentActorId: opts?.parent ?? null,
|
|
207
|
+
rootId: rootActorId,
|
|
208
|
+
id,
|
|
209
|
+
systemId: opts?.systemId,
|
|
210
|
+
snapshot: opts?.snapshot ?? null,
|
|
211
|
+
machineConfig: opts?.machine ?? null
|
|
212
|
+
};
|
|
213
|
+
actors.set(id, entry);
|
|
214
|
+
if (initSent) send({
|
|
215
|
+
type: "@statelyai.system.actorRegistered",
|
|
216
|
+
actorId: id,
|
|
217
|
+
parentActorId: entry.parentActorId,
|
|
218
|
+
id,
|
|
219
|
+
machine: entry.machineConfig,
|
|
220
|
+
snapshot: entry.snapshot ?? void 0
|
|
221
|
+
});
|
|
222
|
+
emitRegisterOnce(entry);
|
|
223
|
+
}
|
|
224
|
+
function manualSnapshot(actorId, snapshot, event, sourceActorId) {
|
|
225
|
+
if (!actors.has(actorId)) manualRegister(actorId);
|
|
226
|
+
const entry = actors.get(actorId);
|
|
227
|
+
entry.snapshot = snapshot;
|
|
228
|
+
if (initSent) send({
|
|
229
|
+
type: "@statelyai.system.actorSnapshot",
|
|
230
|
+
actorId,
|
|
231
|
+
snapshot,
|
|
232
|
+
event: event ?? null,
|
|
233
|
+
...sourceActorId ? { sourceActorId } : {}
|
|
234
|
+
});
|
|
235
|
+
emitLocal("snapshot", entry);
|
|
236
|
+
}
|
|
237
|
+
function manualEvent(actorId, event, eventOpts) {
|
|
238
|
+
const eventObj = typeof event === "string" ? { type: event } : { ...event };
|
|
239
|
+
manualSnapshot(actorId, actors.get(actorId)?.snapshot ?? null, eventObj, eventOpts?.source ?? null);
|
|
240
|
+
}
|
|
241
|
+
function manualStop(actorId) {
|
|
242
|
+
if (!actors.has(actorId)) return;
|
|
243
|
+
actors.delete(actorId);
|
|
244
|
+
if (initSent) send({
|
|
245
|
+
type: "@statelyai.system.actorStopped",
|
|
246
|
+
actorId
|
|
247
|
+
});
|
|
248
|
+
emitLocal("stopped", { actorId });
|
|
249
|
+
}
|
|
74
250
|
return {
|
|
251
|
+
actors,
|
|
75
252
|
get sessionId() {
|
|
76
253
|
return sessionId;
|
|
77
254
|
},
|
|
78
|
-
inspect(opts) {
|
|
79
|
-
send(toInitMessage(opts));
|
|
80
|
-
},
|
|
81
|
-
update(machine, format) {
|
|
82
|
-
send({
|
|
83
|
-
type: "@statelyai.update",
|
|
84
|
-
machine,
|
|
85
|
-
format
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
setMode(mode) {
|
|
89
|
-
send({
|
|
90
|
-
type: "@statelyai.setMode",
|
|
91
|
-
mode
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
export(format, callOptions) {
|
|
95
|
-
return exportManager.start(format, callOptions, "Inspector is destroyed", () => destroyed);
|
|
96
|
-
},
|
|
97
255
|
on(event, handler) {
|
|
98
|
-
|
|
256
|
+
if (!localListeners[event]) localListeners[event] = /* @__PURE__ */ new Set();
|
|
257
|
+
localListeners[event].add(handler);
|
|
258
|
+
return () => {
|
|
259
|
+
localListeners[event].delete(handler);
|
|
260
|
+
};
|
|
99
261
|
},
|
|
100
262
|
off(event, handler) {
|
|
101
|
-
|
|
263
|
+
localListeners[event]?.delete(handler);
|
|
102
264
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
type: "@statelyai.inspectSnapshot",
|
|
106
|
-
snapshot,
|
|
107
|
-
event: event ?? null
|
|
108
|
-
});
|
|
265
|
+
export(format, callOptions) {
|
|
266
|
+
return exportManager.start(format, callOptions, "Inspector is destroyed", () => destroyed);
|
|
109
267
|
},
|
|
268
|
+
actor: manualRegister,
|
|
269
|
+
snapshot: manualSnapshot,
|
|
270
|
+
event: manualEvent,
|
|
271
|
+
stop: manualStop,
|
|
110
272
|
destroy() {
|
|
111
273
|
if (destroyed) return;
|
|
112
274
|
destroyed = true;
|
|
113
|
-
|
|
275
|
+
try {
|
|
276
|
+
subscription?.unsubscribe();
|
|
277
|
+
} catch {}
|
|
278
|
+
if (ownsTransport) transport.destroy();
|
|
114
279
|
exportManager.clear("Inspector destroyed");
|
|
115
280
|
events.clear();
|
|
281
|
+
actors.clear();
|
|
116
282
|
pendingMessages.length = 0;
|
|
283
|
+
for (const set of Object.values(localListeners)) set?.clear();
|
|
117
284
|
}
|
|
118
285
|
};
|
|
119
286
|
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
//#region src/patchTypes.d.ts
|
|
2
|
+
type EditorStateType = 'normal' | 'parallel' | 'history' | 'final' | null;
|
|
3
|
+
type CanvasColor = 'green' | 'red' | 'purple' | 'blue' | 'orange' | 'yellow' | 'pink' | 'teal';
|
|
4
|
+
type ActionLocation = {
|
|
5
|
+
nodeId: string;
|
|
6
|
+
group: 'entry' | 'exit';
|
|
7
|
+
} | {
|
|
8
|
+
edgeId: string;
|
|
9
|
+
group: 'transition';
|
|
10
|
+
};
|
|
11
|
+
type ImplementationSourceType = 'action' | 'guard' | 'actor' | 'delay';
|
|
12
|
+
type GraphPatch = {
|
|
13
|
+
op: 'createNode';
|
|
14
|
+
description?: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
parentId: string;
|
|
17
|
+
key: string;
|
|
18
|
+
type?: EditorStateType;
|
|
19
|
+
x?: number;
|
|
20
|
+
y?: number;
|
|
21
|
+
} | {
|
|
22
|
+
op: 'updateNode';
|
|
23
|
+
description?: string;
|
|
24
|
+
nodeId: string;
|
|
25
|
+
data: {
|
|
26
|
+
key?: string;
|
|
27
|
+
type?: EditorStateType;
|
|
28
|
+
description?: string;
|
|
29
|
+
initialId?: string | null;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
op: 'deleteNode';
|
|
33
|
+
description?: string;
|
|
34
|
+
nodeId: string;
|
|
35
|
+
} | {
|
|
36
|
+
op: 'createEdge';
|
|
37
|
+
description?: string;
|
|
38
|
+
id?: string;
|
|
39
|
+
sourceId: string;
|
|
40
|
+
targetId: string;
|
|
41
|
+
eventType: string;
|
|
42
|
+
transitionType?: 'normal' | 'targetless' | 'reenter';
|
|
43
|
+
} | {
|
|
44
|
+
op: 'updateEdge';
|
|
45
|
+
description?: string;
|
|
46
|
+
edgeId: string;
|
|
47
|
+
data: {
|
|
48
|
+
sourceId?: string;
|
|
49
|
+
targetId?: string;
|
|
50
|
+
eventType?: string;
|
|
51
|
+
transitionType?: 'normal' | 'targetless' | 'reenter';
|
|
52
|
+
description?: string | null;
|
|
53
|
+
};
|
|
54
|
+
} | {
|
|
55
|
+
op: 'deleteEdge';
|
|
56
|
+
description?: string;
|
|
57
|
+
edgeId: string;
|
|
58
|
+
} | {
|
|
59
|
+
op: 'createState';
|
|
60
|
+
description?: string;
|
|
61
|
+
id?: string;
|
|
62
|
+
parentId: string;
|
|
63
|
+
key: string;
|
|
64
|
+
type?: EditorStateType;
|
|
65
|
+
x?: number;
|
|
66
|
+
y?: number;
|
|
67
|
+
color?: CanvasColor | null;
|
|
68
|
+
initial?: boolean;
|
|
69
|
+
} | {
|
|
70
|
+
op: 'updateState';
|
|
71
|
+
description?: string;
|
|
72
|
+
stateId: string;
|
|
73
|
+
key?: string;
|
|
74
|
+
type?: EditorStateType;
|
|
75
|
+
stateDescription?: string;
|
|
76
|
+
initialId?: string | null;
|
|
77
|
+
color?: CanvasColor | null;
|
|
78
|
+
meta?: Record<string, unknown> | null;
|
|
79
|
+
history?: 'shallow' | 'deep' | null;
|
|
80
|
+
} | {
|
|
81
|
+
op: 'deleteState';
|
|
82
|
+
description?: string;
|
|
83
|
+
stateId: string;
|
|
84
|
+
} | {
|
|
85
|
+
op: 'createTransition';
|
|
86
|
+
description?: string;
|
|
87
|
+
id?: string;
|
|
88
|
+
sourceId: string;
|
|
89
|
+
targetId: string;
|
|
90
|
+
eventType: string;
|
|
91
|
+
transitionType?: 'normal' | 'targetless' | 'reenter';
|
|
92
|
+
guard?: {
|
|
93
|
+
type: string;
|
|
94
|
+
code?: string;
|
|
95
|
+
params?: Record<string, unknown>;
|
|
96
|
+
};
|
|
97
|
+
color?: CanvasColor | null;
|
|
98
|
+
transitionDescription?: string | null;
|
|
99
|
+
} | {
|
|
100
|
+
op: 'updateTransition';
|
|
101
|
+
description?: string;
|
|
102
|
+
transitionId: string;
|
|
103
|
+
sourceId?: string;
|
|
104
|
+
targetId?: string;
|
|
105
|
+
eventType?: string;
|
|
106
|
+
transitionType?: 'normal' | 'targetless' | 'reenter';
|
|
107
|
+
transitionDescription?: string | null;
|
|
108
|
+
color?: CanvasColor | null;
|
|
109
|
+
meta?: Record<string, unknown> | null;
|
|
110
|
+
} | {
|
|
111
|
+
op: 'deleteTransition';
|
|
112
|
+
description?: string;
|
|
113
|
+
transitionId: string;
|
|
114
|
+
} | {
|
|
115
|
+
op: 'createAction';
|
|
116
|
+
description?: string;
|
|
117
|
+
location: ActionLocation;
|
|
118
|
+
action: {
|
|
119
|
+
id?: string;
|
|
120
|
+
type: string;
|
|
121
|
+
params?: Record<string, unknown>;
|
|
122
|
+
code?: string;
|
|
123
|
+
};
|
|
124
|
+
index?: number;
|
|
125
|
+
} | {
|
|
126
|
+
op: 'updateAction';
|
|
127
|
+
description?: string;
|
|
128
|
+
location: ActionLocation;
|
|
129
|
+
actionId: string;
|
|
130
|
+
data: {
|
|
131
|
+
type?: string;
|
|
132
|
+
params?: Record<string, unknown>;
|
|
133
|
+
code?: string;
|
|
134
|
+
};
|
|
135
|
+
} | {
|
|
136
|
+
op: 'deleteAction';
|
|
137
|
+
description?: string;
|
|
138
|
+
location: ActionLocation;
|
|
139
|
+
actionId: string;
|
|
140
|
+
} | {
|
|
141
|
+
op: 'createInvoke';
|
|
142
|
+
description?: string;
|
|
143
|
+
nodeId: string;
|
|
144
|
+
invoke: {
|
|
145
|
+
id?: string;
|
|
146
|
+
src: string;
|
|
147
|
+
code?: string;
|
|
148
|
+
input?: Record<string, unknown>;
|
|
149
|
+
output?: Record<string, unknown>;
|
|
150
|
+
};
|
|
151
|
+
} | {
|
|
152
|
+
op: 'updateInvoke';
|
|
153
|
+
description?: string;
|
|
154
|
+
nodeId: string;
|
|
155
|
+
invokeId: string;
|
|
156
|
+
data: {
|
|
157
|
+
src?: string;
|
|
158
|
+
code?: string;
|
|
159
|
+
input?: Record<string, unknown>;
|
|
160
|
+
output?: Record<string, unknown>;
|
|
161
|
+
};
|
|
162
|
+
} | {
|
|
163
|
+
op: 'deleteInvoke';
|
|
164
|
+
description?: string;
|
|
165
|
+
nodeId: string;
|
|
166
|
+
invokeId: string;
|
|
167
|
+
} | {
|
|
168
|
+
op: 'createImplementation';
|
|
169
|
+
description?: string;
|
|
170
|
+
sourceType: ImplementationSourceType;
|
|
171
|
+
implementation: {
|
|
172
|
+
id: string;
|
|
173
|
+
name?: string;
|
|
174
|
+
code?: string;
|
|
175
|
+
};
|
|
176
|
+
} | {
|
|
177
|
+
op: 'updateImplementation';
|
|
178
|
+
description?: string;
|
|
179
|
+
sourceType: ImplementationSourceType;
|
|
180
|
+
implementationId: string;
|
|
181
|
+
data: {
|
|
182
|
+
name?: string;
|
|
183
|
+
code?: string;
|
|
184
|
+
};
|
|
185
|
+
} | {
|
|
186
|
+
op: 'deleteImplementation';
|
|
187
|
+
description?: string;
|
|
188
|
+
sourceType: ImplementationSourceType;
|
|
189
|
+
implementationId: string;
|
|
190
|
+
} | {
|
|
191
|
+
op: 'setGuard';
|
|
192
|
+
description?: string;
|
|
193
|
+
edgeId: string;
|
|
194
|
+
guard: {
|
|
195
|
+
type: string;
|
|
196
|
+
code?: string;
|
|
197
|
+
params?: Record<string, unknown>;
|
|
198
|
+
};
|
|
199
|
+
} | {
|
|
200
|
+
op: 'deleteGuard';
|
|
201
|
+
description?: string;
|
|
202
|
+
edgeId: string;
|
|
203
|
+
} | {
|
|
204
|
+
op: 'createTag';
|
|
205
|
+
description?: string;
|
|
206
|
+
nodeId: string;
|
|
207
|
+
tag: {
|
|
208
|
+
name: string;
|
|
209
|
+
};
|
|
210
|
+
} | {
|
|
211
|
+
op: 'deleteTag';
|
|
212
|
+
description?: string;
|
|
213
|
+
nodeId: string;
|
|
214
|
+
tagName: string;
|
|
215
|
+
} | {
|
|
216
|
+
op: 'createAnnotation';
|
|
217
|
+
description?: string;
|
|
218
|
+
id?: string;
|
|
219
|
+
parentId: string | null;
|
|
220
|
+
content: string;
|
|
221
|
+
x?: number;
|
|
222
|
+
y?: number;
|
|
223
|
+
} | {
|
|
224
|
+
op: 'updateAnnotation';
|
|
225
|
+
description?: string;
|
|
226
|
+
annotationId: string;
|
|
227
|
+
data: {
|
|
228
|
+
content?: string;
|
|
229
|
+
};
|
|
230
|
+
} | {
|
|
231
|
+
op: 'deleteAnnotation';
|
|
232
|
+
description?: string;
|
|
233
|
+
annotationId: string;
|
|
234
|
+
} | {
|
|
235
|
+
op: 'setContext';
|
|
236
|
+
description?: string;
|
|
237
|
+
context: Record<string, unknown>;
|
|
238
|
+
} | {
|
|
239
|
+
op: 'updateSchemas';
|
|
240
|
+
description?: string;
|
|
241
|
+
schemas: {
|
|
242
|
+
context?: Record<string, unknown> | null;
|
|
243
|
+
events?: Record<string, unknown> | null;
|
|
244
|
+
input?: unknown | null;
|
|
245
|
+
output?: unknown | null;
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
//#endregion
|
|
249
|
+
export { ActionLocation, CanvasColor, EditorStateType, GraphPatch, ImplementationSourceType };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|