@statelyai/sdk 0.12.1 → 0.12.3

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 CHANGED
@@ -30,11 +30,14 @@ embed.init({
30
30
 
31
31
  Restrict an embed by passing a resolved access policy:
32
32
 
33
+ <!-- restricted MachineInitOptions from src/protocol.ts -->
34
+
33
35
  ```ts
34
36
  embed.init({
35
37
  machine: myMachineConfig,
36
38
  mode: 'viewing',
37
39
  readOnly: true,
40
+ readOnlyReason: 'free-plan',
38
41
  capabilities: {
39
42
  edit: false,
40
43
  export: false,
@@ -51,6 +54,10 @@ embed.on('capabilityDenied', (event) => {
51
54
  });
52
55
  ```
53
56
 
57
+ `readOnlyReason: 'free-plan'` shows a persistent **Upgrade to edit** action.
58
+ Use `access-unverified` when reopening or signing in, rather than upgrading, is
59
+ the appropriate recovery action.
60
+
54
61
  Key capabilities:
55
62
 
56
63
  - **Mount or attach** to any container element or existing iframe
package/dist/embed.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as toInitMessage, i as createPendingExportManager, r as createEventRegistry, t as createPostMessageTransport } from "./transport-D0nlFaLn.mjs";
1
+ import { a as toInitMessage, i as createPendingExportManager, r as createEventRegistry, t as createPostMessageTransport } from "./transport-DysvAtl5.mjs";
2
2
 
3
3
  //#region src/embed.ts
4
4
  function buildEmbedUrl(options) {
@@ -26,6 +26,7 @@ function extractInitOptions(options) {
26
26
  mode: options.mode,
27
27
  theme: options.theme,
28
28
  readOnly: options.readOnly,
29
+ readOnlyReason: options.readOnlyReason,
29
30
  depth: options.depth,
30
31
  capabilities: options.capabilities,
31
32
  panels: options.panels,
@@ -1,4 +1,4 @@
1
- import { r as CodeExpression } from "./index-BpUKBSiq.mjs";
1
+ import { r as CodeExpression } from "./index-BRW2DecD.mjs";
2
2
  import * as _statelyai_graph0 from "@statelyai/graph";
3
3
  import { Graph } from "@statelyai/graph";
4
4
 
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-Bm4_GZX_.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-Dq5ycdSq.mjs";
2
2
  export { StatelyAction, StatelyActorImplementation, StatelyEdgeData, StatelyGraph, StatelyGraphData, StatelyGuard, StatelyImplementation, StatelyInvoke, StatelyNodeData, StatelyTagImplementation, StudioAction, StudioEdge, StudioEventTypeData, StudioMachine, StudioNode, fromStudioMachine, studioMachineConverter, toStudioMachine };
@@ -2473,8 +2473,8 @@ declare const actionLocationSchema: ZodUnion<readonly [ZodObject<{
2473
2473
  }, $strip>]>;
2474
2474
  type ActionLocation = output<typeof actionLocationSchema>;
2475
2475
  declare const implementationSourceTypeSchema: ZodEnum<{
2476
- action: "action";
2477
2476
  guard: "guard";
2477
+ action: "action";
2478
2478
  actor: "actor";
2479
2479
  delay: "delay";
2480
2480
  }>;
@@ -2745,8 +2745,8 @@ declare const graphPatchSchema: ZodDiscriminatedUnion<[ZodObject<{
2745
2745
  op: ZodLiteral<"createImplementation">;
2746
2746
  description: ZodOptional<ZodString>;
2747
2747
  sourceType: ZodEnum<{
2748
- action: "action";
2749
2748
  guard: "guard";
2749
+ action: "action";
2750
2750
  actor: "actor";
2751
2751
  delay: "delay";
2752
2752
  }>;
@@ -2759,8 +2759,8 @@ declare const graphPatchSchema: ZodDiscriminatedUnion<[ZodObject<{
2759
2759
  op: ZodLiteral<"updateImplementation">;
2760
2760
  description: ZodOptional<ZodString>;
2761
2761
  sourceType: ZodEnum<{
2762
- action: "action";
2763
2762
  guard: "guard";
2763
+ action: "action";
2764
2764
  actor: "actor";
2765
2765
  delay: "delay";
2766
2766
  }>;
@@ -2773,8 +2773,8 @@ declare const graphPatchSchema: ZodDiscriminatedUnion<[ZodObject<{
2773
2773
  op: ZodLiteral<"deleteImplementation">;
2774
2774
  description: ZodOptional<ZodString>;
2775
2775
  sourceType: ZodEnum<{
2776
- action: "action";
2777
2776
  guard: "guard";
2777
+ action: "action";
2778
2778
  actor: "actor";
2779
2779
  delay: "delay";
2780
2780
  }>;
package/dist/index.d.mts CHANGED
@@ -3,13 +3,12 @@ import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, Edit
3
3
  import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
4
4
  import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-DO1-eQcU.mjs";
5
5
  import { AssetConfig, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
6
- import { _ as serializeJS, c as MachineConfigOptions, d as contextSchemaToTSType, f as eventsSchemaToTSType, g as raw, h as jsonSchemaToTSType, i as CodeGenGraph, l as RawCode, m as graphToXStateTS, o as GraphPatch, p as graphToMachineConfig, t as ActionLocation, u as XStateTSOptions } from "./index-BpUKBSiq.mjs";
7
- 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-Bm4_GZX_.mjs";
6
+ import { _ as serializeJS, c as MachineConfigOptions, d as contextSchemaToTSType, f as eventsSchemaToTSType, g as raw, h as jsonSchemaToTSType, i as CodeGenGraph, l as RawCode, m as graphToXStateTS, o as GraphPatch, p as graphToMachineConfig, t as ActionLocation, u as XStateTSOptions } from "./index-BRW2DecD.mjs";
7
+ 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-Dq5ycdSq.mjs";
8
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-BmZUcnZB.mjs";
9
9
  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";
10
10
  import { OAuthAuthorizationServerMetadata, OAuthClientRegistrationResponse, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
11
11
  import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
12
-
13
12
  //#region src/statelyPragma.d.ts
14
13
  interface StatelyPragma {
15
14
  tag: '@statelyai';
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-D0nlFaLn.mjs";
1
+ import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-DysvAtl5.mjs";
2
2
  import { createStatelyEmbed } from "./embed.mjs";
3
3
  import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
4
4
  import { createStatelyInspector } from "./inspect.mjs";
@@ -6,7 +6,7 @@ import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
6
6
  import { StudioApiError, createStatelyClient } from "./studio.mjs";
7
7
  import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
8
8
  import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
9
- import { a as eventsSchemaToTSType, c as jsonSchemaToTSType, f as findStatelyPragmaAttachments, l as raw, m as upsertStatelyPragma, n as RawCode, o as graphToMachineConfig, p as getStatelyPragma, r as contextSchemaToTSType, s as graphToXStateTS, u as serializeJS } from "./dist-cQdIPK_n.mjs";
9
+ import { a as eventsSchemaToTSType, c as jsonSchemaToTSType, f as findStatelyPragmaAttachments, l as raw, m as upsertStatelyPragma, n as RawCode, o as graphToMachineConfig, p as getStatelyPragma, r as contextSchemaToTSType, s as graphToXStateTS, u as serializeJS } from "./dist-C-AdA8Iw.mjs";
10
10
  import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
11
11
 
12
12
  export { RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
package/dist/inspect.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as createPendingExportManager, n as createWebSocketTransport, r as createEventRegistry } from "./transport-D0nlFaLn.mjs";
1
+ import { i as createPendingExportManager, n as createWebSocketTransport, r as createEventRegistry } from "./transport-DysvAtl5.mjs";
2
2
 
3
3
  //#region src/inspect.ts
4
4
  const defaultSerializeSnapshot = (snapshot) => ({
@@ -1,2 +1,2 @@
1
- import { a as EditorStateType, n as CanvasColor, o as GraphPatch, s as ImplementationSourceType, t as ActionLocation } from "./index-BpUKBSiq.mjs";
1
+ import { a as EditorStateType, n as CanvasColor, o as GraphPatch, s as ImplementationSourceType, t as ActionLocation } from "./index-BRW2DecD.mjs";
2
2
  export { type ActionLocation, type CanvasColor, type EditorStateType, type GraphPatch, type ImplementationSourceType };
@@ -29,6 +29,7 @@ interface EditorCapabilities {
29
29
  panels?: string[];
30
30
  commands?: string[];
31
31
  }
32
+ type ReadOnlyReason = "free-plan" | "access-unverified";
32
33
  type CapabilityDeniedCapability = "edit" | "export" | "ai" | "simulate" | "inspect" | "navigateHierarchy" | "panel" | "mode";
33
34
  interface CapabilityDeniedEvent {
34
35
  capability: CapabilityDeniedCapability;
@@ -178,6 +179,7 @@ interface MachineInitOptions {
178
179
  mode?: EmbedMode;
179
180
  theme?: "light" | "dark";
180
181
  readOnly?: boolean;
182
+ readOnlyReason?: ReadOnlyReason;
181
183
  depth?: number;
182
184
  capabilities?: EditorCapabilities;
183
185
  panels?: {
@@ -233,6 +235,7 @@ interface InitMessage {
233
235
  mode?: EmbedMode;
234
236
  theme?: "light" | "dark";
235
237
  readOnly?: boolean;
238
+ readOnlyReason?: ReadOnlyReason;
236
239
  depth?: number;
237
240
  capabilities?: EditorCapabilities;
238
241
  leftPanels?: string[];
@@ -249,6 +252,10 @@ interface InitMessage {
249
252
  /** Optional session id override (multiplexed clients only). */
250
253
  sessionId?: string;
251
254
  }
255
+ interface SetApiKeyMessage {
256
+ type: "@statelyai.setApiKey";
257
+ apiKey: string;
258
+ }
252
259
  interface ProjectInitMessage {
253
260
  type: "@statelyai.project.init";
254
261
  machines: ProjectEmbedMachine[];
@@ -456,7 +463,7 @@ interface UploadResponseMessage {
456
463
  result: UploadResult;
457
464
  }
458
465
  /** All messages a client (embed/inspector) can send to the viz. */
459
- type ClientMessage = InitMessage | ProjectInitMessage | ProjectUpdateMessage | ProjectSelectMachineMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | SystemInitMessage | SystemActorRegisteredMessage | SystemActorSnapshotMessage | SystemActorStoppedMessage | UploadCapabilitiesMessage | UploadResponseMessage | ErrorMessage;
466
+ type ClientMessage = InitMessage | SetApiKeyMessage | ProjectInitMessage | ProjectUpdateMessage | ProjectSelectMachineMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | SystemInitMessage | SystemActorRegisteredMessage | SystemActorSnapshotMessage | SystemActorStoppedMessage | UploadCapabilitiesMessage | UploadResponseMessage | ErrorMessage;
460
467
  /** All messages the viz can send back to a client. */
461
468
  type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | ProjectMachineSelectedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | UploadRequestMessage;
462
469
  interface RegisterMessage {
@@ -506,4 +513,4 @@ type SessionMessage = RegisterMessage | RegisteredMessage | RequestOpenMessage |
506
513
  type ProtocolMessage = ClientMessage | VizMessage | SessionMessage;
507
514
  declare const PREFIX = "@statelyai.";
508
515
  //#endregion
509
- export { ActorSystemEntry, AddSessionMessage, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, CommentsConfig, EditorCapabilities, 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 };
516
+ export { ActorSystemEntry, AddSessionMessage, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, InitMessage, InitOptions, InspectSnapshotMessage, LoadedMessage, MachineInitOptions, MachineSourceLocations, PREFIX, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectUpdateMessage, ProtocolMessage, ReadOnlyReason, ReadyMessage, RegisterMessage, RegisteredMessage, RequestOpenMessage, RetrieveMessage, RetrievedMessage, SaveMessage, SessionAddedMessage, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VizMessage };
package/dist/sync.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { b as DigraphConfig, i as StatelyGraph } from "./graph-Bm4_GZX_.mjs";
1
+ import { b as DigraphConfig, i as StatelyGraph } from "./graph-Dq5ycdSq.mjs";
2
2
  import { CreateProjectInput, ProjectData, StudioClient, StudioMachineRecord, XStateVersion } from "./studio.mjs";
3
3
  import { GraphDiff } from "@statelyai/graph";
4
4
 
package/dist/sync.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createStatelyClient } from "./studio.mjs";
2
- import { d as xstateSourceToConfig, f as findStatelyPragmaAttachments, i as detectXStateSourceProfile, m as upsertStatelyPragma, p as getStatelyPragma, s as graphToXStateTS, t as INLINE_EXPRESSION_DIRECTIVE_FIELDS, u as serializeJS } from "./dist-cQdIPK_n.mjs";
2
+ import { d as xstateSourceToConfig, f as findStatelyPragmaAttachments, i as detectXStateSourceProfile, m as upsertStatelyPragma, p as getStatelyPragma, s as graphToXStateTS, t as INLINE_EXPRESSION_DIRECTIVE_FIELDS, u as serializeJS } from "./dist-C-AdA8Iw.mjs";
3
3
  import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
4
4
  import * as ts$1 from "typescript";
5
5
  import ts from "typescript";
@@ -113,6 +113,7 @@ function toInitMessage(options) {
113
113
  mode: options.mode,
114
114
  theme: options.theme,
115
115
  readOnly: options.readOnly,
116
+ readOnlyReason: options.readOnlyReason,
116
117
  depth: options.depth,
117
118
  capabilities: options.capabilities,
118
119
  leftPanels: options.panels?.leftPanels,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/sdk",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",
@@ -76,7 +76,7 @@
76
76
  "jsdom": "^27.4.0",
77
77
  "tsdown": "0.21.0-beta.2",
78
78
  "vitest": "^3.2.4",
79
- "@statelyai/graph-tools": "0.0.3"
79
+ "@statelyai/graph-tools": "0.0.4"
80
80
  },
81
81
  "scripts": {
82
82
  "build": "tsdown",