@statelyai/sdk 0.26.0 → 0.26.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/README.md +28 -24
- package/dist/embed.mjs +3 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +5 -5
- package/dist/{inspect-DNM-Qs93.mjs → inspect-nZNCuv4E.mjs} +1 -1
- package/dist/inspect.mjs +2 -2
- package/dist/protocol.d.mts +19 -1
- package/dist/protocol.mjs +28 -1
- package/dist/{statelyPragma-B-axv279.mjs → statelyPragma-CWxhEIcZ.mjs} +0 -1
- package/dist/sync.mjs +1 -1
- package/dist/{version-u0s4xat2.mjs → version-BDSD4qfI.mjs} +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,24 +23,24 @@ npm install @statelyai/sdk
|
|
|
23
23
|
Drop a fully interactive state machine editor into any web app. The embed communicates over `postMessage` and gives you full control over theme, layout, panels, read-only mode, and more.
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
|
-
import { createStatelyEmbed } from
|
|
26
|
+
import { createStatelyEmbed } from "@statelyai/sdk";
|
|
27
27
|
|
|
28
28
|
const embed = createStatelyEmbed({
|
|
29
|
-
baseUrl:
|
|
30
|
-
apiKey:
|
|
29
|
+
baseUrl: "https://editor.stately.ai",
|
|
30
|
+
apiKey: "your-api-key",
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
embed.mount(document.getElementById(
|
|
33
|
+
embed.mount(document.getElementById("editor")!);
|
|
34
34
|
|
|
35
35
|
embed.init({
|
|
36
36
|
machine: myMachineConfig,
|
|
37
|
-
format:
|
|
38
|
-
mode:
|
|
39
|
-
theme:
|
|
40
|
-
settings: { canvas: { viewMode:
|
|
37
|
+
format: "xstate",
|
|
38
|
+
mode: "editing",
|
|
39
|
+
theme: "dark",
|
|
40
|
+
settings: { canvas: { viewMode: "list" } },
|
|
41
41
|
documents: [
|
|
42
|
-
{ path:
|
|
43
|
-
{ path:
|
|
42
|
+
{ path: "README.md", content: "# How this workflow works" },
|
|
43
|
+
{ path: "src/machine.ts", content: machineSource },
|
|
44
44
|
],
|
|
45
45
|
});
|
|
46
46
|
```
|
|
@@ -59,6 +59,11 @@ RPC methods and payloads are validated before host code runs, and malformed
|
|
|
59
59
|
graphs returned by custom importers are rejected.
|
|
60
60
|
Use `defaultProfile` and `defaultFormat` to choose the initial custom pair.
|
|
61
61
|
|
|
62
|
+
The Get started launchpad is host-configurable. Pass serializable `examples` to
|
|
63
|
+
`embed.init()` (or the project equivalent) to show the Examples section; omit
|
|
64
|
+
the option or pass an empty array to keep it hidden. The editor does not ship a
|
|
65
|
+
default catalog, so self-hosted deployments can provide their own examples.
|
|
66
|
+
|
|
62
67
|
<!-- Embed version configuration and events from src/embed.ts and src/protocol.ts -->
|
|
63
68
|
|
|
64
69
|
Automatic version capture is opt-in. Pass `versionAutoSave: { intervalMs }` to
|
|
@@ -73,9 +78,9 @@ Restrict an embed by passing a resolved access policy:
|
|
|
73
78
|
```ts
|
|
74
79
|
embed.init({
|
|
75
80
|
machine: myMachineConfig,
|
|
76
|
-
mode:
|
|
81
|
+
mode: "viewing",
|
|
77
82
|
readOnly: true,
|
|
78
|
-
readOnlyReason:
|
|
83
|
+
readOnlyReason: "free-plan",
|
|
79
84
|
capabilities: {
|
|
80
85
|
edit: false,
|
|
81
86
|
export: false,
|
|
@@ -83,11 +88,11 @@ embed.init({
|
|
|
83
88
|
simulate: false,
|
|
84
89
|
navigateHierarchy: false,
|
|
85
90
|
maxDepth: 1,
|
|
86
|
-
panels: [
|
|
91
|
+
panels: ["structure", "details", "validations"],
|
|
87
92
|
},
|
|
88
93
|
});
|
|
89
94
|
|
|
90
|
-
embed.on(
|
|
95
|
+
embed.on("capabilityDenied", (event) => {
|
|
91
96
|
console.warn(event.message);
|
|
92
97
|
});
|
|
93
98
|
```
|
|
@@ -132,17 +137,17 @@ Programmatic access to hosted Stately resources, credential verification, and
|
|
|
132
137
|
deterministic machine-config extraction.
|
|
133
138
|
|
|
134
139
|
```ts
|
|
135
|
-
import { createStatelyClient } from
|
|
140
|
+
import { createStatelyClient } from "@statelyai/sdk";
|
|
136
141
|
|
|
137
142
|
const studio = createStatelyClient({
|
|
138
143
|
credential: {
|
|
139
|
-
type:
|
|
144
|
+
type: "oauth",
|
|
140
145
|
accessToken: process.env.STATELY_ACCESS_TOKEN!,
|
|
141
146
|
},
|
|
142
147
|
});
|
|
143
148
|
|
|
144
149
|
const projects = await studio.projects.list();
|
|
145
|
-
const machine = await studio.machines.get(
|
|
150
|
+
const machine = await studio.machines.get("machine-id");
|
|
146
151
|
const extracted = await studio.code.extractMachines({
|
|
147
152
|
code: sourceCode,
|
|
148
153
|
});
|
|
@@ -201,8 +206,8 @@ Stream live actor-system state to the hosted Stately inspector. Zero-config
|
|
|
201
206
|
inspection needs no API key or local relay.
|
|
202
207
|
|
|
203
208
|
```ts
|
|
204
|
-
import { createActor } from
|
|
205
|
-
import { createInspector } from
|
|
209
|
+
import { createActor } from "xstate";
|
|
210
|
+
import { createInspector } from "@statelyai/sdk";
|
|
206
211
|
|
|
207
212
|
const inspector = createInspector();
|
|
208
213
|
const { inspect } = inspector;
|
|
@@ -220,8 +225,7 @@ JSON-safe machine structure:
|
|
|
220
225
|
|
|
221
226
|
```ts
|
|
222
227
|
const inspector = createInspector({
|
|
223
|
-
extractMachine: (actor) =>
|
|
224
|
-
actor.logic === machine ? machineSource : actor.logic?.config,
|
|
228
|
+
extractMachine: (actor) => (actor.logic === machine ? machineSource : actor.logic?.config),
|
|
225
229
|
});
|
|
226
230
|
```
|
|
227
231
|
|
|
@@ -328,7 +332,7 @@ A fully self-contained deployment with no external auth looks like:
|
|
|
328
332
|
|
|
329
333
|
```ts
|
|
330
334
|
const embed = createStatelyEmbed({
|
|
331
|
-
baseUrl:
|
|
335
|
+
baseUrl: "https://your-editor.example.com",
|
|
332
336
|
});
|
|
333
337
|
```
|
|
334
338
|
|
|
@@ -340,8 +344,8 @@ npx @statelyai/sdk relay
|
|
|
340
344
|
|
|
341
345
|
```ts
|
|
342
346
|
const inspector = createInspector({
|
|
343
|
-
url:
|
|
344
|
-
inspectorBaseUrl:
|
|
347
|
+
url: "ws://localhost:4242",
|
|
348
|
+
inspectorBaseUrl: "http://localhost:3000/inspect",
|
|
345
349
|
});
|
|
346
350
|
```
|
|
347
351
|
|
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-BDSD4qfI.mjs";
|
|
2
2
|
import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-Bko7wge8.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/embed.ts
|
|
@@ -82,6 +82,7 @@ function extractInitOptions(options) {
|
|
|
82
82
|
readOnly: options.readOnly,
|
|
83
83
|
depth: options.depth,
|
|
84
84
|
capabilities: options.capabilities,
|
|
85
|
+
examples: options.examples,
|
|
85
86
|
panels: options.panels,
|
|
86
87
|
commentsByMachineId: options.commentsByMachineId,
|
|
87
88
|
projectWorkspace: options.projectWorkspace,
|
|
@@ -101,6 +102,7 @@ function extractInitOptions(options) {
|
|
|
101
102
|
readOnlyReason: options.readOnlyReason,
|
|
102
103
|
depth: options.depth,
|
|
103
104
|
capabilities: options.capabilities,
|
|
105
|
+
examples: options.examples,
|
|
104
106
|
panels: options.panels,
|
|
105
107
|
comments: options.comments,
|
|
106
108
|
sourceLocations: options.sourceLocations,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
|
|
2
2
|
import { _ as GraphPatch, a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, f as raw, l as graphToMachineConfig, m as ActionLocation, n as CodeGenGraph, o as XStateTSOptions, p as serializeJS, r as MachineConfigOptions, s as contextSchemaToTSType, u as graphToXStateTS } from "./index-DKRB-u93.mjs";
|
|
3
3
|
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-DoUReqxz.mjs";
|
|
4
|
-
import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, MachineVersionAutoSaveOptions, ProjectEmbedMachine, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceMachineOrigin, ProjectWorkspaceProject, UploadResult, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
4
|
+
import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExample, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, MachineVersionAutoSaveOptions, ProjectEmbedMachine, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceMachineOrigin, ProjectWorkspaceProject, UploadResult, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine } from "./protocol.mjs";
|
|
5
5
|
import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
|
|
6
6
|
import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-B0ZTKri2.mjs";
|
|
7
7
|
import { c as fetchEditorSyncAccess, d as EditorHostInboundMessage, f as EditorHostInitOptions, i as EditorSyncBackend, l as EDITOR_PROTOCOL_VERSION, m as EditorHostValidationIssue, n as EditorHostSessionOptions, o as RemoteEditorSyncBackendOptions, p as EditorHostOutboundMessage, r as EditorSourceHost, s as createRemoteEditorSyncBackend, t as EditorHostSession, u as EditorHostExportFormat } from "./editorHostSession-DTXKcLhR.mjs";
|
|
@@ -33,4 +33,4 @@ declare function findStatelyPragmaAttachments(sourceText: string, fileName?: str
|
|
|
33
33
|
declare function getStatelyPragma(sourceText: string, fileName?: string, machineIndex?: number): StatelyPragma | undefined;
|
|
34
34
|
declare function upsertStatelyPragma(sourceText: string, id: string, options?: UpsertStatelyPragmaOptions): string;
|
|
35
35
|
//#endregion
|
|
36
|
-
export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EditorHostExportFormat, type EditorHostInboundMessage, type EditorHostInitOptions, type EditorHostOutboundMessage, EditorHostSession, type EditorHostSessionOptions, type EditorHostValidationIssue, type EditorSourceHost, type EditorSyncBackend, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedFormatContext, type EmbedFormatDefinition, type EmbedGraph, type EmbedMode, type EmbedProfileDefinition, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorConnection, type InspectorDiscoveryEntry, type InspectorEvents, type InspectorInspectionEvent, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineConfigOptions, type MachineVersion, type MachineVersionAutoSaveOptions, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceMachineOrigin, type ProjectWorkspaceProject, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RemoteEditorSyncBackendOptions, type RepoType, type ResolvedSyncInput, type ResourceErrorCode, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyAuthMode, type StatelyCredential, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type VerifyResult, type XStateTSOptions, type XStateVersion, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
|
36
|
+
export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EditorHostExportFormat, type EditorHostInboundMessage, type EditorHostInitOptions, type EditorHostOutboundMessage, EditorHostSession, type EditorHostSessionOptions, type EditorHostValidationIssue, type EditorSourceHost, type EditorSyncBackend, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExample, type EmbedFormatContext, type EmbedFormatDefinition, type EmbedGraph, type EmbedMode, type EmbedProfileDefinition, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorConnection, type InspectorDiscoveryEntry, type InspectorEvents, type InspectorInspectionEvent, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineConfigOptions, type MachineVersion, type MachineVersionAutoSaveOptions, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceMachineOrigin, type ProjectWorkspaceProject, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RemoteEditorSyncBackendOptions, type RepoType, type ResolvedSyncInput, type ResourceErrorCode, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyAuthMode, type StatelyCredential, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type VerifyResult, type XStateTSOptions, type XStateVersion, assertEmbedExamples, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, isEmbedExample, isEmbedExampleMachine, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import "./openapi-BTDjYWXd.mjs";
|
|
2
|
-
import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
3
|
-
import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-
|
|
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-BDSD4qfI.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-BwS-EiBJ.mjs";
|
|
7
7
|
import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-iNSHtNmP.mjs";
|
|
8
|
-
import { a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, l as graphToMachineConfig, m as serializeJS, n as getStatelyPragma, o as contextSchemaToTSType, p as raw, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-
|
|
8
|
+
import { a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, l as graphToMachineConfig, m as serializeJS, n as getStatelyPragma, o as contextSchemaToTSType, p as raw, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-CWxhEIcZ.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-nZNCuv4E.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";
|
|
14
14
|
import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
|
|
15
15
|
import { createInspectionRelay } from "./relay.mjs";
|
|
16
16
|
|
|
17
|
-
export { DEFAULT_STATELY_BASE_URL, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorHostSession, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
|
17
|
+
export { DEFAULT_STATELY_BASE_URL, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorHostSession, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, RawCode, StatelyApiError, StudioApiError, assertEmbedExamples, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, isEmbedExample, isEmbedExampleMachine, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
|
@@ -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-BDSD4qfI.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/openBrowser.ts
|
|
5
5
|
async function openBrowser(url) {
|
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-BDSD4qfI.mjs";
|
|
2
|
+
import { n as createStatelyInspector, t as createInspector } from "./inspect-nZNCuv4E.mjs";
|
|
3
3
|
|
|
4
4
|
export { createInspector, createStatelyInspector };
|
package/dist/protocol.d.mts
CHANGED
|
@@ -293,6 +293,20 @@ interface EmbedExtensionsManifest {
|
|
|
293
293
|
defaultProfile?: string;
|
|
294
294
|
defaultFormat?: string;
|
|
295
295
|
}
|
|
296
|
+
/** Host-provided examples shown in the editor's Get started launchpad. */
|
|
297
|
+
interface EmbedExample {
|
|
298
|
+
id: string;
|
|
299
|
+
title: string;
|
|
300
|
+
description: string;
|
|
301
|
+
category: string;
|
|
302
|
+
machine: unknown;
|
|
303
|
+
}
|
|
304
|
+
/** Check whether an example machine has a shape supported by the editor. */
|
|
305
|
+
declare function isEmbedExampleMachine(value: unknown): value is Record<string, unknown>;
|
|
306
|
+
/** Check whether an unknown value is a valid serialized embed example. */
|
|
307
|
+
declare function isEmbedExample(value: unknown): value is EmbedExample;
|
|
308
|
+
/** Reject malformed host-provided examples before creating an init message. */
|
|
309
|
+
declare function assertEmbedExamples(examples: readonly EmbedExample[] | undefined): void;
|
|
296
310
|
interface MachineInitOptions {
|
|
297
311
|
machine: unknown;
|
|
298
312
|
/** Ephemeral, read-only reference documents owned by the embed host. */
|
|
@@ -305,6 +319,7 @@ interface MachineInitOptions {
|
|
|
305
319
|
readOnlyReason?: ReadOnlyReason;
|
|
306
320
|
depth?: number;
|
|
307
321
|
capabilities?: EditorCapabilities;
|
|
322
|
+
examples?: readonly EmbedExample[];
|
|
308
323
|
panels?: {
|
|
309
324
|
leftPanels?: string[];
|
|
310
325
|
rightPanels?: string[];
|
|
@@ -342,6 +357,7 @@ interface ProjectInitOptions {
|
|
|
342
357
|
readOnly?: boolean;
|
|
343
358
|
depth?: number;
|
|
344
359
|
capabilities?: EditorCapabilities;
|
|
360
|
+
examples?: readonly EmbedExample[];
|
|
345
361
|
panels?: {
|
|
346
362
|
leftPanels?: string[];
|
|
347
363
|
rightPanels?: string[];
|
|
@@ -371,6 +387,7 @@ interface InitMessage {
|
|
|
371
387
|
readOnlyReason?: ReadOnlyReason;
|
|
372
388
|
depth?: number;
|
|
373
389
|
capabilities?: EditorCapabilities;
|
|
390
|
+
examples?: readonly EmbedExample[];
|
|
374
391
|
leftPanels?: string[];
|
|
375
392
|
rightPanels?: string[];
|
|
376
393
|
activePanels?: string[];
|
|
@@ -421,6 +438,7 @@ interface ProjectInitMessage {
|
|
|
421
438
|
readOnly?: boolean;
|
|
422
439
|
depth?: number;
|
|
423
440
|
capabilities?: EditorCapabilities;
|
|
441
|
+
examples?: readonly EmbedExample[];
|
|
424
442
|
leftPanels?: string[];
|
|
425
443
|
rightPanels?: string[];
|
|
426
444
|
activePanels?: string[];
|
|
@@ -748,4 +766,4 @@ declare const PREFIX = "@statelyai.";
|
|
|
748
766
|
/** Current WebSocket inspection protocol version. */
|
|
749
767
|
declare const INSPECTION_PROTOCOL_VERSION = 2;
|
|
750
768
|
//#endregion
|
|
751
|
-
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, EmbedExtensionsManifest, EmbedFormatManifest, EmbedMode, 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, PREFIX, 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, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId };
|
|
769
|
+
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, 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, PREFIX, 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 };
|
package/dist/protocol.mjs
CHANGED
|
@@ -52,9 +52,36 @@ const EMBED_DOCUMENT_LIMITS = {
|
|
|
52
52
|
maxDocumentLength: 512 * 1024,
|
|
53
53
|
maxTotalLength: 2 * 1024 * 1024
|
|
54
54
|
};
|
|
55
|
+
function isRecord(value) {
|
|
56
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
57
|
+
}
|
|
58
|
+
function hasOwn(value, key) {
|
|
59
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
60
|
+
}
|
|
61
|
+
/** Check whether an example machine has a shape supported by the editor. */
|
|
62
|
+
function isEmbedExampleMachine(value) {
|
|
63
|
+
if (!isRecord(value)) return false;
|
|
64
|
+
if (hasOwn(value, "rootNode")) return isRecord(value.rootNode);
|
|
65
|
+
if (hasOwn(value, "root") && hasOwn(value, "states")) return isRecord(value.states);
|
|
66
|
+
if (hasOwn(value, "states")) return isRecord(value.states);
|
|
67
|
+
if (hasOwn(value, "States")) return isRecord(value.States);
|
|
68
|
+
return hasOwn(value, "nodes") && Array.isArray(value.nodes) && hasOwn(value, "edges") && Array.isArray(value.edges) && hasOwn(value, "data") && isRecord(value.data);
|
|
69
|
+
}
|
|
70
|
+
/** Check whether an unknown value is a valid serialized embed example. */
|
|
71
|
+
function isEmbedExample(value) {
|
|
72
|
+
return isRecord(value) && typeof value.id === "string" && typeof value.title === "string" && typeof value.description === "string" && typeof value.category === "string" && isEmbedExampleMachine(value.machine);
|
|
73
|
+
}
|
|
74
|
+
/** Reject malformed host-provided examples before creating an init message. */
|
|
75
|
+
function assertEmbedExamples(examples) {
|
|
76
|
+
if (examples === void 0) return;
|
|
77
|
+
if (!Array.isArray(examples)) throw new TypeError("Embed examples must be an array.");
|
|
78
|
+
examples.forEach((example, index) => {
|
|
79
|
+
if (!isEmbedExample(example)) throw new TypeError(`Invalid embed example at index ${index}.`);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
55
82
|
const PREFIX = "@statelyai.";
|
|
56
83
|
/** Current WebSocket inspection protocol version. */
|
|
57
84
|
const INSPECTION_PROTOCOL_VERSION = 2;
|
|
58
85
|
|
|
59
86
|
//#endregion
|
|
60
|
-
export { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, PREFIX, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId };
|
|
87
|
+
export { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, PREFIX, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { a as discriminatedUnion, c as object, d as union, f as unknown, i as custom, l as record, n as array, o as literal, r as boolean, s as number, t as _enum, u as string } from "./openapi-BTDjYWXd.mjs";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import "xstate";
|
|
4
3
|
import "xstate/graph";
|
|
5
4
|
|
|
6
5
|
//#region ../../node_modules/.pnpm/js-yaml@4.2.0/node_modules/js-yaml/dist/js-yaml.mjs
|
package/dist/sync.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./openapi-BTDjYWXd.mjs";
|
|
2
2
|
import { r as createStatelyClient } from "./studio-iNSHtNmP.mjs";
|
|
3
|
-
import { f as normalizeMachineProfile, h as xstateSourceToConfig, i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as serializeJS, n as getStatelyPragma, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-
|
|
3
|
+
import { f as normalizeMachineProfile, h as xstateSourceToConfig, i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as serializeJS, n as getStatelyPragma, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-CWxhEIcZ.mjs";
|
|
4
4
|
import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
|
|
5
5
|
import * as ts$1 from "typescript";
|
|
6
6
|
import ts from "typescript";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, PREFIX } from "./protocol.mjs";
|
|
1
|
+
import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, PREFIX, assertEmbedExamples } from "./protocol.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/clientUtils.ts
|
|
4
4
|
const embedDocumentLanguages = new Set(EMBED_DOCUMENT_LANGUAGES);
|
|
@@ -113,6 +113,7 @@ function createPendingExportManager(sendRetrieve) {
|
|
|
113
113
|
}
|
|
114
114
|
function toInitMessage(options) {
|
|
115
115
|
assertEmbedDocuments(options.documents);
|
|
116
|
+
assertEmbedExamples(options.examples);
|
|
116
117
|
if ("machines" in options) return {
|
|
117
118
|
type: "@statelyai.project.init",
|
|
118
119
|
machines: options.machines,
|
|
@@ -123,6 +124,7 @@ function toInitMessage(options) {
|
|
|
123
124
|
readOnly: options.readOnly,
|
|
124
125
|
depth: options.depth,
|
|
125
126
|
capabilities: options.capabilities,
|
|
127
|
+
examples: options.examples,
|
|
126
128
|
leftPanels: options.panels?.leftPanels,
|
|
127
129
|
rightPanels: options.panels?.rightPanels,
|
|
128
130
|
activePanels: options.panels?.activePanels,
|
|
@@ -145,6 +147,7 @@ function toInitMessage(options) {
|
|
|
145
147
|
readOnlyReason: options.readOnlyReason,
|
|
146
148
|
depth: options.depth,
|
|
147
149
|
capabilities: options.capabilities,
|
|
150
|
+
examples: options.examples,
|
|
148
151
|
leftPanels: options.panels?.leftPanels,
|
|
149
152
|
rightPanels: options.panels?.rightPanels,
|
|
150
153
|
activePanels: options.panels?.activePanels,
|
|
@@ -335,7 +338,7 @@ function createWebSocketTransport(options) {
|
|
|
335
338
|
|
|
336
339
|
//#endregion
|
|
337
340
|
//#region src/version.ts
|
|
338
|
-
const SDK_VERSION = "0.26.
|
|
341
|
+
const SDK_VERSION = "0.26.1";
|
|
339
342
|
function inspectionRuntime() {
|
|
340
343
|
if (typeof window !== "undefined") return "browser";
|
|
341
344
|
if (typeof process !== "undefined" && process.versions?.node) return "node";
|