@statelyai/sdk 0.10.0 → 0.10.2
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/README.md +97 -13
- package/dist/{graph-DmXh22Zu.d.mts → graph-GeuH-mFK.d.mts} +13 -2
- package/dist/graph.d.mts +1 -1
- package/dist/graphToXStateTS-DOaLOySy.mjs +5486 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.mjs +1 -1
- package/dist/protocol.d.mts +11 -0
- package/dist/studio.mjs +20 -2
- package/dist/sync.d.mts +1 -1
- package/dist/sync.mjs +3225 -30
- package/package.json +2 -2
- package/schemas/statelyai.schema.json +2 -2
- package/dist/graphToXStateTS-moihsH_U.mjs +0 -710
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, 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-
|
|
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-GeuH-mFK.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";
|
|
@@ -35,6 +35,14 @@ declare function upsertStatelyPragma(sourceText: string, id: string, options?: U
|
|
|
35
35
|
interface MachineConfigOptions {
|
|
36
36
|
showDescriptions?: boolean;
|
|
37
37
|
showMeta?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Emit inline-code guards as a `{ type }` reference instead of an inline code
|
|
40
|
+
* expression directive. The simulation needs this: it can't evaluate guard
|
|
41
|
+
* source, so it stubs each guard by `type` (see getSimImplementations). A
|
|
42
|
+
* code-expression guard has no `type`, so XState reads `undefined` and throws
|
|
43
|
+
* "Guard 'undefined' is not implemented" the moment that transition is taken.
|
|
44
|
+
*/
|
|
45
|
+
inlineGuardsAsTypeRef?: boolean;
|
|
38
46
|
}
|
|
39
47
|
declare function graphToMachineConfig(graph: CodeGenGraph, options?: MachineConfigOptions): UnknownMachineConfig;
|
|
40
48
|
//#endregion
|
|
@@ -42,6 +50,7 @@ declare function graphToMachineConfig(graph: CodeGenGraph, options?: MachineConf
|
|
|
42
50
|
interface XStateTSOptions extends MachineConfigOptions {
|
|
43
51
|
exportStyle?: 'named' | 'default' | 'none';
|
|
44
52
|
targetLanguage?: 'typescript' | 'javascript';
|
|
53
|
+
xstateVersion?: 5 | 6;
|
|
45
54
|
}
|
|
46
55
|
declare function graphToXStateTS(graph: CodeGenGraph, options?: XStateTSOptions): string;
|
|
47
56
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./
|
|
|
4
4
|
import { createStatelyInspector } from "./inspect.mjs";
|
|
5
5
|
import { StudioApiError, createStatelyClient } from "./studio.mjs";
|
|
6
6
|
import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { S as upsertStatelyPragma, a as graphToMachineConfig, b as findStatelyPragmaAttachments, c as serializeJS, i as jsonSchemaToTSType, n as contextSchemaToTSType, o as RawCode, r as eventsSchemaToTSType, s as raw, t as graphToXStateTS, x as getStatelyPragma } from "./graphToXStateTS-DOaLOySy.mjs";
|
|
8
8
|
import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
|
|
9
9
|
|
|
10
10
|
export { RawCode, StatelyApiError, StudioApiError, contextSchemaToTSType, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, eventsSchemaToTSType, findStatelyPragmaAttachments, fromStudioMachine, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
package/dist/protocol.d.mts
CHANGED
|
@@ -45,6 +45,7 @@ interface StateSourceLocation extends SourceLocation {
|
|
|
45
45
|
interface MachineSourceLocations {
|
|
46
46
|
version: 1;
|
|
47
47
|
root?: SourceLocation;
|
|
48
|
+
statesObject?: StateSourceLocation;
|
|
48
49
|
states: StateSourceLocation[];
|
|
49
50
|
staticValues?: Array<SourceLocation & {
|
|
50
51
|
value: string;
|
|
@@ -78,6 +79,12 @@ interface ExportFormatMap {
|
|
|
78
79
|
options: object;
|
|
79
80
|
result: Record<string, unknown>;
|
|
80
81
|
};
|
|
82
|
+
d2: {
|
|
83
|
+
options: {
|
|
84
|
+
includeLayout?: boolean;
|
|
85
|
+
};
|
|
86
|
+
result: string;
|
|
87
|
+
};
|
|
81
88
|
mermaid: {
|
|
82
89
|
options: object;
|
|
83
90
|
result: string;
|
|
@@ -159,6 +166,7 @@ interface MachineInitOptions {
|
|
|
159
166
|
};
|
|
160
167
|
comments?: CommentsConfig;
|
|
161
168
|
sourceLocations?: MachineSourceLocations;
|
|
169
|
+
settings?: Record<string, unknown>;
|
|
162
170
|
/**
|
|
163
171
|
* Show a persistent "Save to apply" pill in the embed whenever Viz has
|
|
164
172
|
* local edits that have not yet been saved. Intended for contexts like
|
|
@@ -189,6 +197,7 @@ interface ProjectInitOptions {
|
|
|
189
197
|
activePanels?: string[];
|
|
190
198
|
};
|
|
191
199
|
commentsByMachineId?: Record<string, CommentsConfig>;
|
|
200
|
+
settings?: Record<string, unknown>;
|
|
192
201
|
unsavedIndicator?: {
|
|
193
202
|
enabled?: boolean;
|
|
194
203
|
mode?: "structural" | "all";
|
|
@@ -208,6 +217,7 @@ interface InitMessage {
|
|
|
208
217
|
activePanels?: string[];
|
|
209
218
|
comments?: CommentsConfig;
|
|
210
219
|
sourceLocations?: MachineSourceLocations;
|
|
220
|
+
settings?: Record<string, unknown>;
|
|
211
221
|
/** Mirror of `InitOptions.unsavedIndicator`. */
|
|
212
222
|
unsavedIndicator?: {
|
|
213
223
|
enabled?: boolean;
|
|
@@ -228,6 +238,7 @@ interface ProjectInitMessage {
|
|
|
228
238
|
rightPanels?: string[];
|
|
229
239
|
activePanels?: string[];
|
|
230
240
|
commentsByMachineId?: Record<string, CommentsConfig>;
|
|
241
|
+
settings?: Record<string, unknown>;
|
|
231
242
|
unsavedIndicator?: {
|
|
232
243
|
enabled?: boolean;
|
|
233
244
|
mode?: "structural" | "all";
|
package/dist/studio.mjs
CHANGED
|
@@ -40,13 +40,31 @@ function unwrapResponseData(data) {
|
|
|
40
40
|
if (typeof data === "object" && data !== null && "data" in data) return data.data;
|
|
41
41
|
return data;
|
|
42
42
|
}
|
|
43
|
+
function normalizeProjectMachine(machine) {
|
|
44
|
+
if (typeof machine !== "object" || machine === null) return null;
|
|
45
|
+
const candidate = machine;
|
|
46
|
+
const machineId = typeof candidate.machineId === "string" ? candidate.machineId : typeof candidate.id === "string" ? candidate.id : void 0;
|
|
47
|
+
if (!machineId) return null;
|
|
48
|
+
return {
|
|
49
|
+
machineId,
|
|
50
|
+
name: typeof candidate.name === "string" && candidate.name.trim().length > 0 ? candidate.name : typeof candidate.key === "string" && candidate.key.trim().length > 0 ? candidate.key : machineId
|
|
51
|
+
};
|
|
52
|
+
}
|
|
43
53
|
function normalizeProjectData(project) {
|
|
44
|
-
|
|
54
|
+
const machines = Array.isArray(project.machines) ? project.machines.map((machine) => normalizeProjectMachine(machine)).filter((machine) => machine != null) : [];
|
|
55
|
+
if (project.projectVersionId) return {
|
|
56
|
+
...project,
|
|
57
|
+
machines
|
|
58
|
+
};
|
|
45
59
|
if (project.projectId && project.id) return {
|
|
46
60
|
...project,
|
|
61
|
+
machines,
|
|
47
62
|
projectVersionId: project.id
|
|
48
63
|
};
|
|
49
|
-
return
|
|
64
|
+
return {
|
|
65
|
+
...project,
|
|
66
|
+
machines
|
|
67
|
+
};
|
|
50
68
|
}
|
|
51
69
|
function normalizeRepoUrl(url) {
|
|
52
70
|
if (!url) return;
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as DigraphConfig, i as StatelyGraph } from "./graph-
|
|
1
|
+
import { b as DigraphConfig, i as StatelyGraph } from "./graph-GeuH-mFK.mjs";
|
|
2
2
|
import { CreateProjectInput, ProjectData, StudioClient, StudioMachineRecord, XStateVersion } from "./studio.mjs";
|
|
3
3
|
import { GraphDiff } from "@statelyai/graph";
|
|
4
4
|
|