@statelyai/sdk 0.7.0 → 0.8.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/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-DpBGHZwl.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-CJ3N2r43.mjs";
2
2
  export { StatelyAction, StatelyActorImplementation, StatelyEdgeData, StatelyGraph, StatelyGraphData, StatelyGuard, StatelyImplementation, StatelyInvoke, StatelyNodeData, StatelyTagImplementation, StudioAction, StudioEdge, StudioEventTypeData, StudioMachine, StudioNode, fromStudioMachine, studioMachineConverter, toStudioMachine };
@@ -535,9 +535,10 @@ function stripExportDefault(code) {
535
535
  //#endregion
536
536
  //#region src/graphToXStateTS.ts
537
537
  function graphToXStateTS(graph, options = {}) {
538
- const { exportStyle = "named", ...configOptions } = options;
538
+ const { exportStyle = "named", targetLanguage = "typescript", ...configOptions } = options;
539
539
  const schemas = graph.data.schemas;
540
540
  const impls = filterInlineImplementations(graph.data.implementations);
541
+ const supportsTypeSyntax = targetLanguage === "typescript";
541
542
  const hasSchemas = !!(schemas && (schemas.context || schemas.events || schemas.input || schemas.output));
542
543
  const hasActions = !!impls?.actions.length;
543
544
  const hasGuards = !!impls?.guards.length;
@@ -554,7 +555,7 @@ function graphToXStateTS(graph, options = {}) {
554
555
  const machineConfig = graphToMachineConfig(graph, configOptions);
555
556
  let machineExpr;
556
557
  if (hasSetup) {
557
- const setupObj = buildSetupObject(schemas, impls);
558
+ const setupObj = buildSetupObject(schemas, impls, { includeTypeSyntax: supportsTypeSyntax });
558
559
  const configStr = serializeJS(machineConfig, 2);
559
560
  machineExpr = `setup(${serializeJS(setupObj, 0)}).createMachine(${configStr})`;
560
561
  } else machineExpr = `createMachine(${serializeJS(machineConfig, 0)})`;
@@ -621,22 +622,22 @@ function buildImports({ hasSetup, hasActors, actors, builtInActions }) {
621
622
  else xstateImports.push("createMachine");
622
623
  for (const name of builtInActions) xstateImports.push(name);
623
624
  if (hasActors) {
624
- if (actors.some((a) => a.code?.body)) xstateImports.push("fromPromise");
625
+ if (actors.length > 0) xstateImports.push("fromPromise");
625
626
  }
626
627
  return `import { ${xstateImports.join(", ")} } from 'xstate';`;
627
628
  }
628
- function buildSetupObject(schemas, impls) {
629
+ function buildSetupObject(schemas, impls, options) {
629
630
  const setup = {};
630
- const types = buildTypesBlock(schemas);
631
+ const types = buildTypesBlock(schemas, options);
631
632
  if (types) setup.types = types;
632
- if (impls?.actions.length) setup.actions = buildActionsBlock(impls.actions);
633
- if (impls?.guards.length) setup.guards = buildGuardsBlock(impls.guards);
634
- if (impls?.actors.length) setup.actors = buildActorsBlock(impls.actors);
633
+ if (impls?.actions.length) setup.actions = buildActionsBlock(impls.actions, options);
634
+ if (impls?.guards.length) setup.guards = buildGuardsBlock(impls.guards, options);
635
+ if (impls?.actors.length) setup.actors = buildActorsBlock(impls.actors, options);
635
636
  if (impls?.delays.length) setup.delays = buildDelaysBlock(impls.delays);
636
637
  return setup;
637
638
  }
638
- function buildTypesBlock(schemas) {
639
- if (!schemas) return void 0;
639
+ function buildTypesBlock(schemas, options) {
640
+ if (!schemas || !options.includeTypeSyntax) return void 0;
640
641
  const types = {};
641
642
  const contextType = contextSchemaToTSType(schemas.context);
642
643
  if (contextType) types.context = raw(`{} as ${contextType}`);
@@ -654,7 +655,7 @@ function hasSchemaProperties(schema) {
654
655
  }
655
656
  return true;
656
657
  }
657
- function buildActionsBlock(actions) {
658
+ function buildActionsBlock(actions, options) {
658
659
  const block = {};
659
660
  for (const implementation of actions) if (implementation.code?.body) {
660
661
  const exportedExpression = getExportDefaultExpression(implementation.code.body);
@@ -662,12 +663,12 @@ function buildActionsBlock(actions) {
662
663
  block[implementation.name] = raw(exportedExpression);
663
664
  continue;
664
665
  }
665
- const params = hasSchemaProperties(implementation.paramsSchema) ? `, params: ${jsonSchemaToTSType(implementation.paramsSchema)}` : "";
666
+ const params = hasSchemaProperties(implementation.paramsSchema) ? options.includeTypeSyntax ? `, params: ${jsonSchemaToTSType(implementation.paramsSchema)}` : ", params" : "";
666
667
  block[implementation.name] = raw(`function ({ context, event }${params ? params : ""}) {\n ${dedent(implementation.code.body)}\n}`);
667
668
  } else block[implementation.name] = raw(`function ({ context, event }) {\n // TODO: implement ${implementation.name}\n}`);
668
669
  return block;
669
670
  }
670
- function buildGuardsBlock(guards) {
671
+ function buildGuardsBlock(guards, options) {
671
672
  const block = {};
672
673
  for (const guard of guards) if (guard.code?.body) {
673
674
  const exportedExpression = getExportDefaultExpression(guard.code.body);
@@ -675,15 +676,15 @@ function buildGuardsBlock(guards) {
675
676
  block[guard.name] = raw(exportedExpression);
676
677
  continue;
677
678
  }
678
- const params = hasSchemaProperties(guard.paramsSchema) ? `, params: ${jsonSchemaToTSType(guard.paramsSchema)}` : "";
679
+ const params = hasSchemaProperties(guard.paramsSchema) ? options.includeTypeSyntax ? `, params: ${jsonSchemaToTSType(guard.paramsSchema)}` : ", params" : "";
679
680
  block[guard.name] = raw(`function ({ context, event }${params ? params : ""}) {\n ${dedent(guard.code.body)}\n}`);
680
681
  } else block[guard.name] = raw(`function ({ context, event }) {\n // TODO: implement ${guard.name}\n return false;\n}`);
681
682
  return block;
682
683
  }
683
- function buildActorsBlock(actors) {
684
+ function buildActorsBlock(actors, options) {
684
685
  const block = {};
685
686
  for (const actor of actors) if (actor.code?.body) {
686
- const inputType = hasSchemaProperties(actor.inputSchema) ? `: ${jsonSchemaToTSType(actor.inputSchema)}` : "";
687
+ const inputType = options.includeTypeSyntax && hasSchemaProperties(actor.inputSchema) ? `: ${jsonSchemaToTSType(actor.inputSchema)}` : "";
687
688
  block[actor.name] = raw(`fromPromise(async ({ input }${inputType ? `: { input${inputType} }` : ""}) => {\n ${dedent(actor.code.body)}\n})`);
688
689
  } else block[actor.name] = raw(`fromPromise(async ({ input }) => {\n // TODO: implement ${actor.name}\n})`);
689
690
  return block;
package/dist/index.d.mts CHANGED
@@ -1,13 +1,12 @@
1
1
  import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
2
- import { a as EmbedMode, c as ExportFormatMap, f as ProjectEmbedMachine, i as EmbedEventName, l as InitOptions, m as UploadResult, n as EmbedEventHandler, o as ExportCallOptions, r as EmbedEventMap, s as ExportFormat, t as CommentsConfig } from "./protocol-DN4mH4jR.mjs";
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
+ 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";
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";
4
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";
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-DpBGHZwl.mjs";
6
8
  import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
7
- import { AssetConfig, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
8
- 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-Bg9FTvb3.mjs";
9
9
  import { ActionLocation, GraphPatch } from "./patchTypes.mjs";
10
- import { JSONSchema7 } from "json-schema";
11
10
  import { UnknownMachineConfig } from "xstate";
12
11
 
13
12
  //#region src/statelyPragma.d.ts
@@ -32,6 +31,145 @@ declare function findStatelyPragmaAttachments(sourceText: string, fileName?: str
32
31
  declare function getStatelyPragma(sourceText: string, fileName?: string, machineIndex?: number): StatelyPragma | undefined;
33
32
  declare function upsertStatelyPragma(sourceText: string, id: string, options?: UpsertStatelyPragmaOptions): string;
34
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
35
173
  //#region ../graph-tools/src/codegenTypes.d.ts
36
174
  interface CodeGenAction {
37
175
  type: string;
@@ -153,6 +291,7 @@ declare function graphToMachineConfig(graph: CodeGenGraph, options?: MachineConf
153
291
  //#region src/graphToXStateTS.d.ts
154
292
  interface XStateTSOptions extends MachineConfigOptions {
155
293
  exportStyle?: 'named' | 'default' | 'none';
294
+ targetLanguage?: 'typescript' | 'javascript';
156
295
  }
157
296
  declare function graphToXStateTS(graph: CodeGenGraph, options?: XStateTSOptions): string;
158
297
  //#endregion
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-C8UTS3Fa.mjs";
1
+ import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-CVZGF0w9.mjs";
2
2
  import { createStatelyEmbed } from "./embed.mjs";
3
3
  import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
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 { a as graphToMachineConfig, c as serializeJS, d as upsertStatelyPragma, i as jsonSchemaToTSType, l as findStatelyPragmaAttachments, n as contextSchemaToTSType, o as RawCode, r as eventsSchemaToTSType, s as raw, t as graphToXStateTS, u as getStatelyPragma } from "./graphToXStateTS-Gzh0ZqbN.mjs";
7
+ import { a as graphToMachineConfig, c as serializeJS, d as upsertStatelyPragma, i as jsonSchemaToTSType, l as findStatelyPragmaAttachments, n as contextSchemaToTSType, o as RawCode, r as eventsSchemaToTSType, s as raw, t as graphToXStateTS, u as getStatelyPragma } from "./graphToXStateTS-moihsH_U.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 };
@@ -1,4 +1,4 @@
1
- import { c as ExportFormatMap, o as ExportCallOptions, p as ProtocolMessage, r as EmbedEventMap, s as ExportFormat } from "./protocol-DN4mH4jR.mjs";
1
+ import { EmbedEventMap, ExportCallOptions, ExportFormat, ExportFormatMap, ProtocolMessage } from "./protocol.mjs";
2
2
 
3
3
  //#region src/transport.d.ts
4
4
  interface Transport {
@@ -1,3 +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-DN4mH4jR.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-Bg9FTvb3.mjs";
1
+ import { EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap } from "./protocol.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-BLlM3qKf.mjs";
3
3
  export { AdoptedActor, CreateInspectorOptions, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, Inspector, InspectorEvents, ManualActorOptions, Transport, createStatelyInspector };
package/dist/inspect.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as createPendingExportManager, n as createWebSocketTransport, r as createEventRegistry } from "./transport-C8UTS3Fa.mjs";
1
+ import { i as createPendingExportManager, n as createWebSocketTransport, r as createEventRegistry } from "./transport-CVZGF0w9.mjs";
2
2
 
3
3
  //#region src/inspect.ts
4
4
  const defaultSerializeSnapshot = (snapshot) => ({
@@ -461,5 +461,6 @@ interface SessionAddedMessage {
461
461
  type SessionMessage = RegisterMessage | RegisteredMessage | RequestOpenMessage | AddSessionMessage | SessionAddedMessage;
462
462
  /** Any valid protocol message. */
463
463
  type ProtocolMessage = ClientMessage | VizMessage | SessionMessage;
464
+ declare const PREFIX = "@statelyai.";
464
465
  //#endregion
465
- export { EmbedMode as a, ExportFormatMap as c, MachineSourceLocations as d, ProjectEmbedMachine as f, EmbedEventName as i, InitOptions as l, UploadResult as m, EmbedEventHandler as n, ExportCallOptions as o, ProtocolMessage as p, EmbedEventMap as r, ExportFormat as s, CommentsConfig as t, MachineInitOptions as u };
466
+ export { ActorSystemEntry, AddSessionMessage, ChangeMessage, ClientMessage, CommentsConfig, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, InitMessage, InitOptions, InspectSnapshotMessage, LoadedMessage, MachineInitOptions, MachineSourceLocations, PREFIX, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectUpdateMessage, ProtocolMessage, ReadyMessage, RegisterMessage, RegisteredMessage, RequestOpenMessage, RetrieveMessage, RetrievedMessage, SaveMessage, SessionAddedMessage, SessionMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VizMessage };
@@ -0,0 +1,5 @@
1
+ //#region src/protocol.ts
2
+ const PREFIX = "@statelyai.";
3
+
4
+ //#endregion
5
+ export { PREFIX };
package/dist/studio.mjs CHANGED
@@ -40,6 +40,14 @@ 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 normalizeProjectData(project) {
44
+ if (project.projectVersionId) return project;
45
+ if (project.projectId && project.id) return {
46
+ ...project,
47
+ projectVersionId: project.id
48
+ };
49
+ return project;
50
+ }
43
51
  function normalizeRepoUrl(url) {
44
52
  if (!url) return;
45
53
  return url.replace(/\.git$/i, "").replace(/\/+$/, "");
@@ -71,14 +79,14 @@ function createStatelyClient(options = {}) {
71
79
  } },
72
80
  projects: {
73
81
  list() {
74
- return request("/projects", { method: "GET" });
82
+ return request("/projects", { method: "GET" }).then((projects) => projects.map(normalizeProjectData));
75
83
  },
76
84
  create(input) {
77
85
  return request("/projects/create", {
78
86
  method: "POST",
79
87
  headers: { "Content-Type": "application/json" },
80
88
  body: JSON.stringify(input)
81
- });
89
+ }).then(normalizeProjectData);
82
90
  },
83
91
  async ensure(input) {
84
92
  if (input.repo && input.matchConnectedRepo !== false) {
@@ -88,7 +96,7 @@ function createStatelyClient(options = {}) {
88
96
  return this.create(input);
89
97
  },
90
98
  get(projectId) {
91
- return request(`/projects/${encodeURIComponent(projectId)}`, { method: "GET" });
99
+ return request(`/projects/${encodeURIComponent(projectId)}`, { method: "GET" }).then(normalizeProjectData);
92
100
  }
93
101
  },
94
102
  machines: {
package/dist/sync.d.mts CHANGED
@@ -1,5 +1,5 @@
1
+ import { b as DigraphConfig, i as StatelyGraph } from "./graph-CJ3N2r43.mjs";
1
2
  import { CreateProjectInput, ProjectData, StudioClient, StudioMachineRecord, XStateVersion } from "./studio.mjs";
2
- import { b as DigraphConfig, i as StatelyGraph } from "./graph-DpBGHZwl.mjs";
3
3
  import { GraphDiff } from "@statelyai/graph";
4
4
 
5
5
  //#region src/sync.d.ts