@statelyai/sdk 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@statelyai/sdk",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
8
  "type": "module",
9
9
  "bin": {
10
- "stately": "./dist/cli.mjs"
10
+ "statelyai": "./dist/cli.mjs"
11
11
  },
12
12
  "main": "./dist/index.mjs",
13
13
  "types": "./dist/index.d.mts",
@@ -28,10 +28,18 @@
28
28
  "types": "./dist/graph.d.mts",
29
29
  "import": "./dist/graph.mjs"
30
30
  },
31
+ "./patchTypes": {
32
+ "types": "./dist/patchTypes.d.mts",
33
+ "import": "./dist/patchTypes.mjs"
34
+ },
31
35
  "./sync": {
32
36
  "types": "./dist/sync.d.mts",
33
37
  "import": "./dist/sync.mjs"
34
38
  },
39
+ "./cli": {
40
+ "types": "./dist/cli.d.mts",
41
+ "import": "./dist/cli.mjs"
42
+ },
35
43
  "./studio": {
36
44
  "types": "./dist/studio.d.mts",
37
45
  "import": "./dist/studio.mjs"
@@ -40,10 +48,11 @@
40
48
  "dependencies": {
41
49
  "@oclif/core": "^4.10.3",
42
50
  "@statelyai/graph": "^0.9.0",
51
+ "typescript": "^5.9.3",
43
52
  "xstate": "^5.0.0"
44
53
  },
45
54
  "oclif": {
46
- "bin": "stately",
55
+ "bin": "statelyai",
47
56
  "commands": {
48
57
  "strategy": "explicit",
49
58
  "target": "./dist/cli.mjs",
@@ -54,8 +63,8 @@
54
63
  "@types/json-schema": "^7.0.15",
55
64
  "jsdom": "^27.4.0",
56
65
  "tsdown": "0.21.0-beta.2",
57
- "typescript": "^5.9.3",
58
- "vitest": "^3.2.4"
66
+ "vitest": "^3.2.4",
67
+ "@statelyai/editor-sync": "0.0.0"
59
68
  },
60
69
  "scripts": {
61
70
  "build": "tsdown",
@@ -1,225 +0,0 @@
1
- //#region src/protocol.d.ts
2
- type EmbedMode = 'editing' | 'viewing' | 'simulating' | 'inspecting';
3
- interface CommentsConfig {
4
- roomId: string;
5
- userId?: string | null;
6
- publicApiKey?: string;
7
- authEndpoint?: string;
8
- baseUrl?: string;
9
- }
10
- interface ExportFormatMap {
11
- xstate: {
12
- options: {
13
- version?: 4 | 5;
14
- addTSTypes?: boolean;
15
- showIds?: boolean;
16
- showDescriptions?: boolean;
17
- };
18
- result: string;
19
- };
20
- json: {
21
- options: {
22
- simplifyArrays?: boolean;
23
- version?: 4 | 5;
24
- };
25
- result: Record<string, unknown>;
26
- };
27
- digraph: {
28
- options: object;
29
- result: Record<string, unknown>;
30
- };
31
- mermaid: {
32
- options: object;
33
- result: string;
34
- };
35
- scxml: {
36
- options: object;
37
- result: string;
38
- };
39
- }
40
- type ExportFormat = keyof ExportFormatMap;
41
- type ExportCallOptions<F extends ExportFormat> = ExportFormatMap[F]['options'] & {
42
- timeout?: number;
43
- };
44
- interface EmbedEventMap {
45
- ready: {
46
- version: string;
47
- };
48
- loaded: {
49
- graph: unknown;
50
- };
51
- change: {
52
- graph: unknown;
53
- machineConfig: unknown;
54
- };
55
- save: {
56
- graph: unknown;
57
- machineConfig: unknown;
58
- };
59
- error: {
60
- code: string;
61
- message: string;
62
- };
63
- snapshot: {
64
- snapshot: unknown;
65
- event: unknown | null;
66
- };
67
- }
68
- type EmbedEventName = keyof EmbedEventMap;
69
- type EmbedEventHandler<K extends EmbedEventName> = (data: EmbedEventMap[K]) => void;
70
- interface InitOptions {
71
- machine: unknown;
72
- format?: string;
73
- mode?: EmbedMode;
74
- theme?: 'light' | 'dark';
75
- readOnly?: boolean;
76
- depth?: number;
77
- panels?: {
78
- leftPanels?: string[];
79
- rightPanels?: string[];
80
- activePanels?: string[];
81
- };
82
- comments?: CommentsConfig;
83
- }
84
- interface InitMessage {
85
- type: '@statelyai.init';
86
- machine: unknown;
87
- format?: string;
88
- mode?: EmbedMode;
89
- theme?: 'light' | 'dark';
90
- readOnly?: boolean;
91
- depth?: number;
92
- leftPanels?: string[];
93
- rightPanels?: string[];
94
- activePanels?: string[];
95
- comments?: CommentsConfig;
96
- }
97
- interface UpdateMessage {
98
- type: '@statelyai.update';
99
- machine: unknown;
100
- format?: string;
101
- }
102
- interface SetModeMessage {
103
- type: '@statelyai.setMode';
104
- mode: EmbedMode;
105
- }
106
- interface SetThemeMessage {
107
- type: '@statelyai.setTheme';
108
- theme: 'light' | 'dark';
109
- }
110
- interface SetSettingsMessage {
111
- type: '@statelyai.setSettings';
112
- settings: Record<string, unknown>;
113
- }
114
- interface RetrieveMessage {
115
- type: '@statelyai.retrieve';
116
- requestId: string;
117
- format: ExportFormat;
118
- options?: Record<string, unknown>;
119
- }
120
- interface ToastMessage {
121
- type: '@statelyai.toast';
122
- message: string;
123
- toastType?: 'success' | 'error' | 'info' | 'warning';
124
- }
125
- interface InspectSnapshotMessage {
126
- type: '@statelyai.inspectSnapshot';
127
- snapshot: unknown;
128
- event: unknown | null;
129
- }
130
- interface ReadyMessage {
131
- type: '@statelyai.ready';
132
- version: string;
133
- }
134
- interface LoadedMessage {
135
- type: '@statelyai.loaded';
136
- graph: unknown;
137
- }
138
- interface ChangeMessage {
139
- type: '@statelyai.change';
140
- graph: unknown;
141
- machineConfig: unknown;
142
- }
143
- interface SaveMessage {
144
- type: '@statelyai.save';
145
- graph: unknown;
146
- machineConfig: unknown;
147
- }
148
- interface RetrievedMessage {
149
- type: '@statelyai.retrieved';
150
- requestId: string;
151
- data: unknown;
152
- }
153
- interface ErrorMessage {
154
- type: '@statelyai.error';
155
- code: string;
156
- message: string;
157
- requestId?: string;
158
- }
159
- /** File metadata sent from viz to SDK when a file needs uploading. */
160
- interface UploadFileInfo {
161
- /** Original filename (e.g. "screenshot.png") */
162
- name: string;
163
- /** MIME type (e.g. "image/png") */
164
- mimeType: string;
165
- /** File size in bytes */
166
- size: number;
167
- /** File content as base64-encoded string */
168
- data: string;
169
- }
170
- /** The result the consumer returns after uploading. */
171
- interface UploadResult {
172
- /** The publicly accessible URL of the uploaded file */
173
- url: string;
174
- /** Optional display name (defaults to original filename) */
175
- name?: string;
176
- /** Optional metadata stored on the asset */
177
- metadata?: Record<string, unknown>;
178
- }
179
- /** Viz requests the parent to upload a file. */
180
- interface UploadRequestMessage {
181
- type: '@statelyai.uploadRequest';
182
- requestId: string;
183
- file: UploadFileInfo;
184
- stateNodeId: string;
185
- }
186
- /** Parent tells the viz the upload capabilities on init. */
187
- interface UploadCapabilitiesMessage {
188
- type: '@statelyai.uploadCapabilities';
189
- enabled: boolean;
190
- accept?: string[];
191
- maxFileSize?: number;
192
- }
193
- /** Parent sends the upload result back to the viz. */
194
- interface UploadResponseMessage {
195
- type: '@statelyai.uploadResponse';
196
- requestId: string;
197
- result: UploadResult;
198
- }
199
- /** All messages a client (embed/inspector) can send to the viz. */
200
- type ClientMessage = InitMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | UploadCapabilitiesMessage | UploadResponseMessage | ErrorMessage;
201
- /** All messages the viz can send back to a client. */
202
- type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | RetrievedMessage | ErrorMessage | UploadRequestMessage;
203
- interface RegisterMessage {
204
- type: '@statelyai.register';
205
- role: 'client' | 'viz';
206
- sessionId: string;
207
- metadata?: {
208
- name?: string;
209
- machineId?: string;
210
- };
211
- }
212
- interface RegisteredMessage {
213
- type: '@statelyai.registered';
214
- sessionId: string;
215
- }
216
- interface RequestOpenMessage {
217
- type: '@statelyai.requestOpen';
218
- sessionId: string;
219
- }
220
- /** All session-management messages for the WS relay. */
221
- type SessionMessage = RegisterMessage | RegisteredMessage | RequestOpenMessage;
222
- /** Any valid protocol message. */
223
- type ProtocolMessage = ClientMessage | VizMessage | SessionMessage;
224
- //#endregion
225
- export { EmbedMode as a, ExportFormatMap as c, UploadResult as d, EmbedEventName as i, InitOptions as l, EmbedEventHandler as n, ExportCallOptions as o, EmbedEventMap as r, ExportFormat as s, CommentsConfig as t, ProtocolMessage as u };