@statelyai/sdk 0.27.0 → 0.28.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/dist/embed.d.mts +1 -4
- package/dist/embed.mjs +4 -2
- package/dist/index.mjs +3 -3
- package/dist/{inspect-_E2lVbQA.mjs → inspect-DSDnyzZ5.mjs} +2 -2
- package/dist/inspect.mjs +2 -2
- package/dist/protocol.d.mts +19 -3
- package/dist/{statelyPragma-DD7wx7-b.mjs → statelyPragma-ByF0-L-N.mjs} +7 -6
- package/dist/sync.mjs +1 -1
- package/dist/{version-7SUCFMqb.mjs → version-D_SqbrSy.mjs} +1 -1
- package/package.json +3 -3
package/dist/embed.d.mts
CHANGED
|
@@ -109,10 +109,7 @@ interface StatelyEmbedOptions extends Partial<MachineInitOptions> {
|
|
|
109
109
|
onViewModeChanged?: (viewMode: 'graph' | 'list') => void;
|
|
110
110
|
onPanelChanged?: (event: EmbedEventMap['panelChanged']) => void;
|
|
111
111
|
onModeChanged?: (event: EmbedEventMap['modeChanged']) => void;
|
|
112
|
-
onError?: (error:
|
|
113
|
-
code: string;
|
|
114
|
-
message: string;
|
|
115
|
-
}) => void;
|
|
112
|
+
onError?: (error: EmbedEventMap['error']) => void;
|
|
116
113
|
onCapabilityDenied?: (event: CapabilityDeniedEvent) => void;
|
|
117
114
|
}
|
|
118
115
|
interface StatelyEmbed {
|
package/dist/embed.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createEventRegistry, o as createPendingExportManager, r as createPostMessageTransport, s as toInitMessage, t as SDK_VERSION } from "./version-
|
|
1
|
+
import { a as createEventRegistry, o as createPendingExportManager, r as createPostMessageTransport, s as toInitMessage, t as SDK_VERSION } from "./version-D_SqbrSy.mjs";
|
|
2
2
|
import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-Bko7wge8.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/embed.ts
|
|
@@ -364,7 +364,9 @@ function createStatelyEmbed(options) {
|
|
|
364
364
|
const error = data;
|
|
365
365
|
const err = {
|
|
366
366
|
code: error.code,
|
|
367
|
-
message: error.message
|
|
367
|
+
message: error.message,
|
|
368
|
+
...error.machineId !== void 0 ? { machineId: error.machineId } : {},
|
|
369
|
+
...error.details !== void 0 ? { details: error.details } : {}
|
|
368
370
|
};
|
|
369
371
|
exportManager.reject(new Error(err.message), error.requestId);
|
|
370
372
|
options.onError?.(err);
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "./openapi-BTDjYWXd.mjs";
|
|
2
2
|
import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine } from "./protocol.mjs";
|
|
3
|
-
import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-
|
|
3
|
+
import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-D_SqbrSy.mjs";
|
|
4
4
|
import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-Bko7wge8.mjs";
|
|
5
5
|
import { createStatelyEmbed } from "./embed.mjs";
|
|
6
6
|
import { i as fetchEditorSyncAccess, r as createRemoteEditorSyncBackend, t as EditorHostSession } from "./editorHostSession-shrjfosC.mjs";
|
|
7
7
|
import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-CNkxMZyz.mjs";
|
|
8
|
-
import { a as RawCode, d as getXStateFSMCompatibilityIssues, g as jsonSchemaToTSType, h as graphToXStateTS, m as graphToXStateFSM, n as getStatelyPragma, p as graphToMachineConfig, r as upsertStatelyPragma, s as contextSchemaToTSType, t as findStatelyPragmaAttachments, u as eventsSchemaToTSType, v as raw, y as serializeJS } from "./statelyPragma-
|
|
8
|
+
import { a as RawCode, d as getXStateFSMCompatibilityIssues, g as jsonSchemaToTSType, h as graphToXStateTS, m as graphToXStateFSM, n as getStatelyPragma, p as graphToMachineConfig, r as upsertStatelyPragma, s as contextSchemaToTSType, t as findStatelyPragmaAttachments, u as eventsSchemaToTSType, v as raw, y as serializeJS } from "./statelyPragma-ByF0-L-N.mjs";
|
|
9
9
|
import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
|
|
10
|
-
import { n as createStatelyInspector, t as createInspector } from "./inspect-
|
|
10
|
+
import { n as createStatelyInspector, t as createInspector } from "./inspect-DSDnyzZ5.mjs";
|
|
11
11
|
import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
|
|
12
12
|
import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
|
|
13
13
|
import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { INSPECTION_PROTOCOL_VERSION, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
2
|
-
import { a as createEventRegistry, i as createWebSocketTransport, n as inspectionRuntime, o as createPendingExportManager, t as SDK_VERSION } from "./version-
|
|
2
|
+
import { a as createEventRegistry, i as createWebSocketTransport, n as inspectionRuntime, o as createPendingExportManager, t as SDK_VERSION } from "./version-D_SqbrSy.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/openBrowser.ts
|
|
5
5
|
async function openBrowser(url) {
|
|
@@ -360,7 +360,7 @@ function createInspector(options = {}) {
|
|
|
360
360
|
return {
|
|
361
361
|
sourceStateId: typeof source === "string" ? source : source?.id ?? null,
|
|
362
362
|
targetStateIds: targets.map((target) => typeof target === "string" ? target : target.id ?? "").filter(Boolean),
|
|
363
|
-
...(raw?.eventType ?? json?.eventType) && { eventType: raw?.eventType ?? json?.eventType },
|
|
363
|
+
...(raw?.eventType ?? json?.eventType) !== void 0 && { eventType: raw?.eventType ?? json?.eventType },
|
|
364
364
|
...(raw?.reenter ?? json?.reenter) !== void 0 && { reenter: raw?.reenter ?? json?.reenter }
|
|
365
365
|
};
|
|
366
366
|
}
|
package/dist/inspect.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./version-
|
|
2
|
-
import { n as createStatelyInspector, t as createInspector } from "./inspect-
|
|
1
|
+
import "./version-D_SqbrSy.mjs";
|
|
2
|
+
import { n as createStatelyInspector, t as createInspector } from "./inspect-DSDnyzZ5.mjs";
|
|
3
3
|
|
|
4
4
|
export { createInspector, createStatelyInspector };
|
package/dist/protocol.d.mts
CHANGED
|
@@ -254,8 +254,10 @@ interface EmbedEventMap {
|
|
|
254
254
|
sourceLocations?: MachineSourceLocations;
|
|
255
255
|
};
|
|
256
256
|
error: {
|
|
257
|
-
code:
|
|
257
|
+
code: ErrorCode;
|
|
258
258
|
message: string;
|
|
259
|
+
machineId?: string;
|
|
260
|
+
details?: string[];
|
|
259
261
|
};
|
|
260
262
|
capabilityDenied: CapabilityDeniedEvent;
|
|
261
263
|
snapshot: {
|
|
@@ -706,10 +708,24 @@ interface RetrievedMessage {
|
|
|
706
708
|
requestId: string;
|
|
707
709
|
data: unknown;
|
|
708
710
|
}
|
|
711
|
+
/**
|
|
712
|
+
* Error codes the editor emits. Open-ended (`string`) so an older SDK keeps
|
|
713
|
+
* forwarding codes a newer editor adds.
|
|
714
|
+
*
|
|
715
|
+
* - `unsupported_protocol` — editor/SDK protocol versions disagree.
|
|
716
|
+
* - `conversion_failed` — a machine source could not be converted to a graph.
|
|
717
|
+
* - `invalid_graph` — a host-supplied graph is structurally invalid; see `details`.
|
|
718
|
+
* - `render_failed` — the editor threw while rendering a machine.
|
|
719
|
+
*/
|
|
720
|
+
type ErrorCode = 'unsupported_protocol' | 'conversion_failed' | 'invalid_graph' | 'render_failed' | (string & {});
|
|
709
721
|
interface ErrorMessage {
|
|
710
722
|
type: '@statelyai.error';
|
|
711
|
-
code:
|
|
723
|
+
code: ErrorCode;
|
|
712
724
|
message: string;
|
|
725
|
+
/** Machine the error belongs to, when the editor knows which one failed. */
|
|
726
|
+
machineId?: string;
|
|
727
|
+
/** Per-problem explanations, e.g. one line per structural graph error. */
|
|
728
|
+
details?: string[];
|
|
713
729
|
requestId?: string;
|
|
714
730
|
}
|
|
715
731
|
interface CapabilityDeniedMessage extends CapabilityDeniedEvent {
|
|
@@ -800,4 +816,4 @@ declare const PREFIX = "@statelyai.";
|
|
|
800
816
|
/** Current WebSocket inspection protocol version. */
|
|
801
817
|
declare const INSPECTION_PROTOCOL_VERSION = 2;
|
|
802
818
|
//#endregion
|
|
803
|
-
export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, ClipboardReadMessage, ClipboardReadResponseMessage, ClipboardWriteMessage, ClipboardWriteResponseMessage, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EditorHandshakeMessage, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExample, EmbedExtensionsManifest, EmbedFormatManifest, EmbedMode, type EmbedPanelConfig, type EmbedPanelPosition, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, ExtensionCallMessage, ExtensionResultMessage, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitMessage, InitOptions, InspectSnapshotMessage, InspectionAction, InspectionClientMetadata, InspectionRoomUrls, InspectionSentEvent, InspectionTakenTransition, LoadedMessage, MachineInitOptions, MachineSourceLocations, MachineVersionAutoSaveOptions, ModeChangedMessage, PREFIX, PanelChangedMessage, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectSetWorkspaceOpenMessage, ProjectUpdateMessage, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceActionMessage, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceMachineOrigin, ProjectWorkspaceOpenChangedMessage, ProjectWorkspaceProject, ProtocolMessage, ReadOnlyReason, ReadyMessage, RegisterMessage, RegisteredMessage, RetrieveMessage, RetrievedMessage, SaveMessage, SavedMessage, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorEventMessage, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, SystemSelectActorMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VersionSaveRequestedMessage, ViewModeChangedMessage, VizMessage, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine };
|
|
819
|
+
export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, ClipboardReadMessage, ClipboardReadResponseMessage, ClipboardWriteMessage, ClipboardWriteResponseMessage, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EditorHandshakeMessage, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExample, EmbedExtensionsManifest, EmbedFormatManifest, EmbedMode, type EmbedPanelConfig, type EmbedPanelPosition, ErrorCode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, ExtensionCallMessage, ExtensionResultMessage, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitMessage, InitOptions, InspectSnapshotMessage, InspectionAction, InspectionClientMetadata, InspectionRoomUrls, InspectionSentEvent, InspectionTakenTransition, LoadedMessage, MachineInitOptions, MachineSourceLocations, MachineVersionAutoSaveOptions, ModeChangedMessage, PREFIX, PanelChangedMessage, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectSetWorkspaceOpenMessage, ProjectUpdateMessage, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceActionMessage, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceMachineOrigin, ProjectWorkspaceOpenChangedMessage, ProjectWorkspaceProject, ProtocolMessage, ReadOnlyReason, ReadyMessage, RegisterMessage, RegisteredMessage, RetrieveMessage, RetrievedMessage, SaveMessage, SavedMessage, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorEventMessage, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, SystemSelectActorMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VersionSaveRequestedMessage, ViewModeChangedMessage, VizMessage, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine };
|
|
@@ -3535,7 +3535,7 @@ function deepSimplify(config) {
|
|
|
3535
3535
|
return config;
|
|
3536
3536
|
}
|
|
3537
3537
|
function buildMeta(meta, color) {
|
|
3538
|
-
if (isCodeExpression$
|
|
3538
|
+
if (isCodeExpression$3(meta)) return meta;
|
|
3539
3539
|
const result = {};
|
|
3540
3540
|
if (meta) {
|
|
3541
3541
|
for (const [k, v] of Object.entries(meta)) if (v !== void 0 && v !== null) result[k] = v;
|
|
@@ -3543,7 +3543,7 @@ function buildMeta(meta, color) {
|
|
|
3543
3543
|
if (color) result["@statelyai.color"] = color;
|
|
3544
3544
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
3545
3545
|
}
|
|
3546
|
-
function isCodeExpression$
|
|
3546
|
+
function isCodeExpression$3(value) {
|
|
3547
3547
|
return Boolean(value && typeof value === "object" && !Array.isArray(value) && value["@type"] === "code" && typeof value.expr === "string");
|
|
3548
3548
|
}
|
|
3549
3549
|
/** Format event param — supports { type: string } (new) and plain string (legacy) */
|
|
@@ -3554,7 +3554,7 @@ function formatEventParam(event) {
|
|
|
3554
3554
|
}
|
|
3555
3555
|
function formatStringParam(value) {
|
|
3556
3556
|
if (typeof value === "string") return `'${value}'`;
|
|
3557
|
-
return isCodeExpression$
|
|
3557
|
+
return isCodeExpression$3(value) ? serializeJS(value) : "undefined";
|
|
3558
3558
|
}
|
|
3559
3559
|
function formatInlineObject(value) {
|
|
3560
3560
|
return `{ ${Object.entries(value).filter(([, item]) => item !== void 0).map(([key, item]) => `${formatObjectKey(key)}: ${serializeJS(item)}`).join(", ")} }`;
|
|
@@ -3692,6 +3692,7 @@ const XSTATE_BUILT_IN_ACTIONS = {
|
|
|
3692
3692
|
importKind: "named",
|
|
3693
3693
|
paramsSchema: builtInActionParamSchemas["xstate.assign"],
|
|
3694
3694
|
emit(params) {
|
|
3695
|
+
if (isCodeExpression$3(params?.assignment)) return `assign(${serializeJS(params.assignment)})`;
|
|
3695
3696
|
const assignments = params?.assignment && typeof params.assignment === "object" && !Array.isArray(params.assignment) ? params.assignment : params;
|
|
3696
3697
|
const entries = Object.entries(assignments ?? {}).filter(([k, v]) => k && v !== void 0);
|
|
3697
3698
|
if (entries.length === 0) return "assign({})";
|
|
@@ -6366,7 +6367,7 @@ function getXStateFSMCompatibilityIssues(graph) {
|
|
|
6366
6367
|
if (!edge.data.eventType) issues.add("eventless transitions");
|
|
6367
6368
|
if (!stateIds.has(edge.targetId) && edge.data.transitionType !== "targetless") issues.add("transitions outside the flat state set");
|
|
6368
6369
|
if (edge.data.guard || edge.data.actions?.length || edge.data.matches || edge.data.input !== void 0 || edge.data.transitionType === "reenter") issues.add("guards, actions, matching, transition input, or reentry");
|
|
6369
|
-
if (isCodeExpression$
|
|
6370
|
+
if (isCodeExpression$2(edge.data.context)) issues.add("dynamic transition context");
|
|
6370
6371
|
}
|
|
6371
6372
|
if ([...eventCounts.values()].some((count) => count > 1)) issues.add("multiple transitions for one event");
|
|
6372
6373
|
return [...issues];
|
|
@@ -6408,7 +6409,7 @@ function buildState(graph, state, stateById) {
|
|
|
6408
6409
|
}
|
|
6409
6410
|
function buildTransition$1(edge, stateById) {
|
|
6410
6411
|
const target = edge.data.transitionType === "targetless" ? void 0 : stateById.get(edge.targetId)?.data.key;
|
|
6411
|
-
const context = isCodeExpression$
|
|
6412
|
+
const context = isCodeExpression$2(edge.data.context) ? void 0 : edge.data.context;
|
|
6412
6413
|
if (context !== void 0) return {
|
|
6413
6414
|
target,
|
|
6414
6415
|
context
|
|
@@ -6446,7 +6447,7 @@ function eventPayloadType(schema) {
|
|
|
6446
6447
|
required
|
|
6447
6448
|
});
|
|
6448
6449
|
}
|
|
6449
|
-
function isCodeExpression$
|
|
6450
|
+
function isCodeExpression$2(value) {
|
|
6450
6451
|
return !!value && typeof value === "object" && !Array.isArray(value) && value["@type"] === "code";
|
|
6451
6452
|
}
|
|
6452
6453
|
const colorSchema = _enum([
|
package/dist/sync.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./openapi-BTDjYWXd.mjs";
|
|
2
2
|
import { r as createStatelyClient } from "./studio-CNkxMZyz.mjs";
|
|
3
|
-
import { _ as normalizeMachineProfile, b as xstateSourceToConfig, c as detectXStateSourceProfile, f as graphChangeToPatchesResult, h as graphToXStateTS, i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, l as diffGraphsSemantically, n as getStatelyPragma, o as alignCompareGraphIds, p as graphToMachineConfig, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, y as serializeJS } from "./statelyPragma-
|
|
3
|
+
import { _ as normalizeMachineProfile, b as xstateSourceToConfig, c as detectXStateSourceProfile, f as graphChangeToPatchesResult, h as graphToXStateTS, i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, l as diffGraphsSemantically, n as getStatelyPragma, o as alignCompareGraphIds, p as graphToMachineConfig, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, y as serializeJS } from "./statelyPragma-ByF0-L-N.mjs";
|
|
4
4
|
import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
|
|
5
5
|
import * as ts$1 from "typescript";
|
|
6
6
|
import ts from "typescript";
|
|
@@ -364,7 +364,7 @@ function createWebSocketTransport(options) {
|
|
|
364
364
|
|
|
365
365
|
//#endregion
|
|
366
366
|
//#region src/version.ts
|
|
367
|
-
const SDK_VERSION = "0.
|
|
367
|
+
const SDK_VERSION = "0.28.0";
|
|
368
368
|
function inspectionRuntime() {
|
|
369
369
|
if (typeof window !== "undefined") return "browser";
|
|
370
370
|
if (typeof process !== "undefined" && process.versions?.node) return "node";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statelyai/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"stately-sdk": "./dist/bin.mjs"
|
|
@@ -93,8 +93,8 @@
|
|
|
93
93
|
"jsdom": "^27.4.0",
|
|
94
94
|
"tsdown": "0.21.0-beta.2",
|
|
95
95
|
"vitest": "^3.2.4",
|
|
96
|
-
"@statelyai/api-contract": "0.3.
|
|
97
|
-
"@statelyai/graph-tools": "0.
|
|
96
|
+
"@statelyai/api-contract": "0.3.15",
|
|
97
|
+
"@statelyai/graph-tools": "0.6.0"
|
|
98
98
|
},
|
|
99
99
|
"engines": {
|
|
100
100
|
"node": ">=22.4"
|