@statelyai/sdk 0.11.0 → 0.12.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/README.md CHANGED
@@ -28,11 +28,35 @@ embed.init({
28
28
  });
29
29
  ```
30
30
 
31
+ Restrict an embed by passing a resolved access policy:
32
+
33
+ ```ts
34
+ embed.init({
35
+ machine: myMachineConfig,
36
+ mode: 'viewing',
37
+ readOnly: true,
38
+ capabilities: {
39
+ edit: false,
40
+ export: false,
41
+ ai: false,
42
+ simulate: false,
43
+ navigateHierarchy: false,
44
+ maxDepth: 1,
45
+ panels: ['structure', 'details', 'validations'],
46
+ },
47
+ });
48
+
49
+ embed.on('capabilityDenied', (event) => {
50
+ console.warn(event.message);
51
+ });
52
+ ```
53
+
31
54
  Key capabilities:
32
55
 
33
56
  - **Mount or attach** to any container element or existing iframe
34
57
  - **Two-way sync** - push machine configs in, get changes and saves back via event callbacks
35
58
  - **Export** to multiple formats: XState v5, XState JSON, Mermaid, Redux, Zustand, ASL, SCXML, and more
59
+ - **Access policies** for read-only, no-export, no-AI, shallow-viewer embeds
36
60
  - **Comments** via Liveblocks integration (optional)
37
61
  - **Asset uploads** with built-in S3 and Supabase adapters, or bring your own upload handler
38
62
  - **Runtime settings** - toggle color mode, grid, snap lines, autolayout, and view mode on the fly
@@ -69,7 +93,10 @@ Programmatic access to Stately Studio for managing projects and machines, extrac
69
93
  import { createStatelyClient } from '@statelyai/sdk';
70
94
 
71
95
  const studio = createStatelyClient({
72
- apiKey: process.env.STATELY_API_KEY,
96
+ credential: {
97
+ type: 'oauth',
98
+ accessToken: process.env.STATELY_ACCESS_TOKEN!,
99
+ },
73
100
  });
74
101
 
75
102
  const projects = await studio.projects.list();
@@ -77,6 +104,10 @@ const machine = await studio.machines.get('machine-id');
77
104
  const extracted = await studio.code.extractMachines(sourceCode);
78
105
  ```
79
106
 
107
+ Legacy `apiKey` is still accepted as an alias for
108
+ `credential: { type: 'api_key', token }`. Use `authMode: 'none'` only for
109
+ self-hosted deployments that intentionally accept unauthenticated calls.
110
+
80
111
  ### Inspector
81
112
 
82
113
  Stream live actor-system state to the Stately inspector over WebSockets, with support for automatic XState actor adoption and manual actor registration.
@@ -0,0 +1,15 @@
1
+ //#region src/auth.d.ts
2
+ type StatelyCredential = {
3
+ type: 'api_key';
4
+ token: string;
5
+ } | {
6
+ type: 'oauth';
7
+ accessToken: string;
8
+ refreshToken?: string;
9
+ expiresAt?: number;
10
+ };
11
+ type StatelyAuthMode = 'auto' | 'none' | 'bearer';
12
+ declare function getCredentialToken(credential: StatelyCredential | string | null | undefined): string | undefined;
13
+ declare function createAuthorizationHeader(credential: StatelyCredential | string): string;
14
+ //#endregion
15
+ export { getCredentialToken as i, StatelyCredential as n, createAuthorizationHeader as r, StatelyAuthMode as t };
@@ -0,0 +1,2 @@
1
+ import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-DO1-eQcU.mjs";
2
+ export { StatelyAuthMode, StatelyCredential, createAuthorizationHeader, getCredentialToken };
package/dist/auth.mjs ADDED
@@ -0,0 +1,11 @@
1
+ //#region src/auth.ts
2
+ function getCredentialToken(credential) {
3
+ if (!credential) return;
4
+ return typeof credential === "string" ? credential : credential.type === "oauth" ? credential.accessToken : credential.token;
5
+ }
6
+ function createAuthorizationHeader(credential) {
7
+ return `Bearer ${getCredentialToken(credential)}`;
8
+ }
9
+
10
+ //#endregion
11
+ export { createAuthorizationHeader, getCredentialToken };
package/dist/embed.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { CommentsConfig, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, MachineInitOptions, MachineSourceLocations, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
1
+ import { CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, MachineInitOptions, MachineSourceLocations, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
2
2
  import { AssetUploadAdapter } from "./assetStorage.mjs";
3
3
 
4
4
  //#region src/embed.d.ts
@@ -56,6 +56,7 @@ interface StatelyEmbedOptions extends Partial<MachineInitOptions> {
56
56
  code: string;
57
57
  message: string;
58
58
  }) => void;
59
+ onCapabilityDenied?: (event: CapabilityDeniedEvent) => void;
59
60
  }
60
61
  interface StatelyEmbed {
61
62
  /** Attach to an existing iframe element. Sets src and begins handshake. */
@@ -89,4 +90,4 @@ interface StatelyEmbed {
89
90
  }
90
91
  declare function createStatelyEmbed(options: StatelyEmbedOptions): StatelyEmbed;
91
92
  //#endregion
92
- export { AssetConfig, type CommentsConfig, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type MachineInitOptions, type MachineSourceLocations, type ProjectEmbedMachine, StatelyEmbed, StatelyEmbedOptions, type UploadResult, createStatelyEmbed };
93
+ export { AssetConfig, type CapabilityDeniedEvent, type CommentsConfig, type EditorCapabilities, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type MachineInitOptions, type MachineSourceLocations, type ProjectEmbedMachine, StatelyEmbed, StatelyEmbedOptions, type UploadResult, createStatelyEmbed };
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-CVZGF0w9.mjs";
1
+ import { a as toInitMessage, i as createPendingExportManager, r as createEventRegistry, t as createPostMessageTransport } from "./transport-D0nlFaLn.mjs";
2
2
 
3
3
  //#region src/embed.ts
4
4
  function buildEmbedUrl(options) {
@@ -15,6 +15,7 @@ function extractInitOptions(options) {
15
15
  theme: options.theme,
16
16
  readOnly: options.readOnly,
17
17
  depth: options.depth,
18
+ capabilities: options.capabilities,
18
19
  panels: options.panels,
19
20
  commentsByMachineId: options.commentsByMachineId,
20
21
  unsavedIndicator: options.unsavedIndicator
@@ -26,6 +27,7 @@ function extractInitOptions(options) {
26
27
  theme: options.theme,
27
28
  readOnly: options.readOnly,
28
29
  depth: options.depth,
30
+ capabilities: options.capabilities,
29
31
  panels: options.panels,
30
32
  comments: options.comments,
31
33
  sourceLocations: options.sourceLocations,
@@ -134,6 +136,12 @@ function createStatelyEmbed(options) {
134
136
  events.emit("error", err);
135
137
  break;
136
138
  }
139
+ case "@statelyai.capabilityDenied": {
140
+ const { type: _type, ...event } = data;
141
+ options.onCapabilityDenied?.(event);
142
+ events.emit("capabilityDenied", event);
143
+ break;
144
+ }
137
145
  case "@statelyai.uploadRequest": {
138
146
  const req = data;
139
147
  if (!uploadAsset) {
@@ -181,9 +181,10 @@ interface CodeGenInvoke {
181
181
  interface CodeGenNodeData {
182
182
  nodeId?: string | null;
183
183
  key: string;
184
- type?: 'normal' | 'parallel' | 'final' | 'history' | null;
184
+ type?: 'normal' | 'parallel' | 'final' | 'history' | 'choice' | null;
185
185
  initialId?: string | null;
186
186
  history?: 'shallow' | 'deep' | boolean;
187
+ output?: Record<string, unknown> | CodeExpression;
187
188
  entry?: CodeGenAction[];
188
189
  exit?: CodeGenAction[];
189
190
  invokes?: CodeGenInvoke[];
@@ -200,6 +201,7 @@ interface CodeGenEdgeData {
200
201
  eventType: string;
201
202
  transitionType?: 'normal' | 'targetless' | 'reenter';
202
203
  guard?: CodeGenGuard | null;
204
+ context?: Record<string, unknown> | CodeExpression;
203
205
  actions?: CodeGenAction[];
204
206
  description?: string | null;
205
207
  color?: string;
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-GeuH-mFK.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-CszT5J6W.mjs";
2
2
  export { StatelyAction, StatelyActorImplementation, StatelyEdgeData, StatelyGraph, StatelyGraphData, StatelyGuard, StatelyImplementation, StatelyInvoke, StatelyNodeData, StatelyTagImplementation, StudioAction, StudioEdge, StudioEventTypeData, StudioMachine, StudioNode, fromStudioMachine, studioMachineConverter, toStudioMachine };
@@ -4697,6 +4697,10 @@ function formatObjectKey(key) {
4697
4697
  const eventParamSchema = union([string(), object({ type: string() }).catchall(unknown())]);
4698
4698
  const delayParamSchema = union([number(), string()]);
4699
4699
  const builtInActionParamSchemas = {
4700
+ "xstate.enqueue": object({
4701
+ code: string().optional(),
4702
+ lang: string().optional()
4703
+ }),
4700
4704
  "xstate.raise": object({
4701
4705
  event: eventParamSchema.optional(),
4702
4706
  id: string().optional(),
@@ -4720,6 +4724,16 @@ const builtInActionParamSchemas = {
4720
4724
  "xstate.assign": object({ assignment: record(string(), unknown()).optional() }).catchall(unknown())
4721
4725
  };
4722
4726
  const XSTATE_BUILT_IN_ACTIONS = {
4727
+ "xstate.enqueue": {
4728
+ package: "xstate",
4729
+ version: "^6",
4730
+ import: "enqueue",
4731
+ importKind: "named",
4732
+ paramsSchema: builtInActionParamSchemas["xstate.enqueue"],
4733
+ emit(params) {
4734
+ return typeof params?.code === "string" ? stripExportDefault$1(params.code) : "";
4735
+ }
4736
+ },
4723
4737
  "xstate.raise": {
4724
4738
  package: "xstate",
4725
4739
  version: "^5",
@@ -4862,6 +4876,7 @@ function serializeGuard(guard, asTypeRef) {
4862
4876
  */
4863
4877
  function serializeActionItem(action) {
4864
4878
  const { type, params } = action;
4879
+ if (type === "xstate.enqueue" && typeof params?.code === "string") return inlineCodeExpression(params.code);
4865
4880
  const exprCode = type === "xstate.expr" && typeof params?.code === "string" ? params.code : void 0;
4866
4881
  if (isBuiltInActionType(type)) {
4867
4882
  const builtInAction = XSTATE_BUILT_IN_ACTIONS[type];
@@ -4894,7 +4909,8 @@ function graphToMachineConfig(graph, options = {}) {
4894
4909
  const nodeType = [
4895
4910
  "final",
4896
4911
  "history",
4897
- "parallel"
4912
+ "parallel",
4913
+ "choice"
4898
4914
  ].includes(node.data.type) ? node.data.type : void 0;
4899
4915
  const tags = node.data.tags;
4900
4916
  Object.assign(nodeConfig, {
@@ -4909,6 +4925,7 @@ function graphToMachineConfig(graph, options = {}) {
4909
4925
  ...inv.input ? { input: inv.input } : void 0,
4910
4926
  ...inv.output ? { output: inv.output } : void 0
4911
4927
  })) } : void 0,
4928
+ ...node.data.output !== void 0 ? { output: node.data.output } : void 0,
4912
4929
  ...tags?.length ? { tags: tags.map(tagToString) } : void 0,
4913
4930
  ...showDescriptions && node.data.description ? { description: node.data.description } : void 0,
4914
4931
  ...showMeta && node.data.meta && Object.keys(node.data.meta).length > 0 ? { meta: node.data.meta } : void 0,
@@ -4920,6 +4937,7 @@ function graphToMachineConfig(graph, options = {}) {
4920
4937
  const on = {};
4921
4938
  const after = {};
4922
4939
  const alwaysArr = [];
4940
+ const choiceArr = [];
4923
4941
  const onDone = {};
4924
4942
  const invokeMap = {};
4925
4943
  for (const edge of edges) {
@@ -4931,6 +4949,7 @@ function graphToMachineConfig(graph, options = {}) {
4931
4949
  target: edge.data.transitionType === "targetless" ? void 0 : `${resolvedTarget}`,
4932
4950
  ...edge.data.transitionType === "reenter" ? { reenter: true } : void 0,
4933
4951
  guard: edge.data.guard ? serializeGuard(edge.data.guard, inlineGuardsAsTypeRef) : void 0,
4952
+ ...edge.data.context !== void 0 ? { context: edge.data.context } : void 0,
4934
4953
  actions: edge.data.actions?.length ? edge.data.actions.map(serializeActionItem) : void 0,
4935
4954
  description: edge.data.description ?? void 0,
4936
4955
  ...transitionMeta ? { meta: transitionMeta } : void 0
@@ -4953,6 +4972,7 @@ function graphToMachineConfig(graph, options = {}) {
4953
4972
  if (!onDone[type]) onDone[type] = [];
4954
4973
  onDone[type].push(transitionObject);
4955
4974
  } else pushOn(`xstate.${ref.kind === "actionDone" ? "done" : "error"}.actor.${resolveSpawnActorId(node, ref.blockId)}`);
4975
+ else if (type === "" && node.data.type === "choice") choiceArr.push(transitionObject);
4956
4976
  else if (type === "") alwaysArr.push(transitionObject);
4957
4977
  else if (type.startsWith("xstate.after.")) {
4958
4978
  const delayKey = type.slice(13).split(".")[0];
@@ -4972,6 +4992,7 @@ function graphToMachineConfig(graph, options = {}) {
4972
4992
  if (Object.keys(on).length > 0) nodeConfig.on = singleOrArrayRecord(on);
4973
4993
  if (Object.keys(after).length > 0) nodeConfig.after = singleOrArrayRecord(after);
4974
4994
  if (alwaysArr.length > 0) nodeConfig.always = singleOrArray(alwaysArr);
4995
+ if (choiceArr.length > 0) nodeConfig.choice = singleOrArray(choiceArr);
4975
4996
  if (Object.keys(onDone).length > 0) nodeConfig.onDone = singleOrArray(Object.values(onDone).flat());
4976
4997
  if (Object.keys(invokeMap).length > 0 && Array.isArray(nodeConfig.invoke)) nodeConfig.invoke = nodeConfig.invoke.map((inv, index) => {
4977
4998
  const mapped = invokeMap[node.data.invokes?.[index]?.id ?? inv.id];
package/dist/index.d.mts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
2
- import { CommentsConfig, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
2
+ import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, 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 { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-DO1-eQcU.mjs";
4
5
  import { AssetConfig, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
5
- import { C as EventTypeData, E as JSONSchema7, S as DigraphNodeConfig, T as CodeGenGraph, _ as studioMachineConverter, a as StatelyGraphData, b as DigraphConfig, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, o as StatelyGuard, r as StatelyEdgeData, t as StatelyAction, v as toStudioMachine, w as StateNodeJSONData, x as DigraphEdgeConfig, y as DigraphAction } from "./graph-GeuH-mFK.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-CZ8iLJR7.mjs";
6
+ import { C as EventTypeData, E as JSONSchema7, S as DigraphNodeConfig, T as CodeGenGraph, _ as studioMachineConverter, a as StatelyGraphData, b as DigraphConfig, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, o as StatelyGuard, r as StatelyEdgeData, t as StatelyAction, v as toStudioMachine, w as StateNodeJSONData, x as DigraphEdgeConfig, y as DigraphAction } from "./graph-CszT5J6W.mjs";
7
+ 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-BibyPhFj.mjs";
7
8
  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";
9
+ import { OAuthAuthorizationServerMetadata, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken } from "./oauth.mjs";
8
10
  import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
9
11
  import { ActionLocation, GraphPatch } from "./patchTypes.mjs";
10
12
  import { UnknownMachineConfig } from "xstate";
@@ -83,4 +85,4 @@ declare function contextSchemaToTSType(context: Record<string, JSONSchema7> | nu
83
85
  */
84
86
  declare function eventsSchemaToTSType(events: Record<string, JSONSchema7> | null | undefined): string | null;
85
87
  //#endregion
86
- export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesResponse, type ExtractedMachine, type GetMachineOptions, type GraphPatch, type InitOptions, type Inspector, type InspectorEvents, type MachineConfigOptions, type ManualActorOptions, type PlanSyncOptions, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectVisibility, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RepoType, type ResolvedSyncInput, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type UpdateMachineInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type XStateTSOptions, type XStateVersion, contextSchemaToTSType, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, eventsSchemaToTSType, findStatelyPragmaAttachments, fromStudioMachine, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
88
+ export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, type EditorCapabilities, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesResponse, type ExtractedMachine, type GetMachineOptions, type GraphPatch, type InitOptions, type Inspector, type InspectorEvents, type MachineConfigOptions, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectVisibility, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RepoType, type ResolvedSyncInput, 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 StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type UpdateMachineInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type XStateTSOptions, type XStateVersion, 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, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
package/dist/index.mjs CHANGED
@@ -1,10 +1,12 @@
1
- import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-CVZGF0w9.mjs";
1
+ import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-D0nlFaLn.mjs";
2
2
  import { createStatelyEmbed } from "./embed.mjs";
3
3
  import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
4
4
  import { createStatelyInspector } from "./inspect.mjs";
5
+ import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
5
6
  import { StudioApiError, createStatelyClient } from "./studio.mjs";
7
+ import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken } from "./oauth.mjs";
6
8
  import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
7
- import { S as upsertStatelyPragma, a as graphToMachineConfig, b as findStatelyPragmaAttachments, c as serializeJS, i as jsonSchemaToTSType, n as contextSchemaToTSType, o as RawCode, r as eventsSchemaToTSType, s as raw, t as graphToXStateTS, x as getStatelyPragma } from "./graphToXStateTS-DV62vO_d.mjs";
9
+ import { S as upsertStatelyPragma, a as graphToMachineConfig, b as findStatelyPragmaAttachments, c as serializeJS, i as jsonSchemaToTSType, n as contextSchemaToTSType, o as RawCode, r as eventsSchemaToTSType, s as raw, t as graphToXStateTS, x as getStatelyPragma } from "./graphToXStateTS-D12GTMBp.mjs";
8
10
  import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
9
11
 
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 };
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, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
@@ -1,4 +1,4 @@
1
- import { EmbedEventMap, ExportCallOptions, ExportFormat, ExportFormatMap, ProtocolMessage } from "./protocol.mjs";
1
+ import { EditorCapabilities, EmbedEventMap, ExportCallOptions, ExportFormat, ExportFormatMap, ProtocolMessage } from "./protocol.mjs";
2
2
 
3
3
  //#region src/transport.d.ts
4
4
  interface Transport {
@@ -153,6 +153,7 @@ interface CreateInspectorOptions {
153
153
  theme?: 'light' | 'dark';
154
154
  readOnly?: boolean;
155
155
  depth?: number;
156
+ capabilities?: EditorCapabilities;
156
157
  /**
157
158
  * Advanced: inject a pre-built transport (e.g. a channel from a
158
159
  * multiplexed connection). When provided, `url`/`name` are ignored and the
@@ -1,3 +1,3 @@
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-CZ8iLJR7.mjs";
3
- export { AdoptedActor, CreateInspectorOptions, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, Inspector, InspectorEvents, ManualActorOptions, Transport, createStatelyInspector };
1
+ import { EditorCapabilities, 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-BibyPhFj.mjs";
3
+ export { AdoptedActor, CreateInspectorOptions, EditorCapabilities, 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-CVZGF0w9.mjs";
1
+ import { i as createPendingExportManager, n as createWebSocketTransport, r as createEventRegistry } from "./transport-D0nlFaLn.mjs";
2
2
 
3
3
  //#region src/inspect.ts
4
4
  const defaultSerializeSnapshot = (snapshot) => ({
@@ -11,7 +11,7 @@ function generateSessionId() {
11
11
  return `manual-${Date.now()}-${nextManualId++}`;
12
12
  }
13
13
  function createStatelyInspector(options = {}) {
14
- const { url = "ws://localhost:4242", autoOpen = true, name, serializeSnapshot = defaultSerializeSnapshot, extractMachineConfig = defaultExtractMachineConfig, selectedActorId, panels, theme, readOnly, depth, transport: injectedTransport } = options;
14
+ const { url = "ws://localhost:4242", autoOpen = true, name, serializeSnapshot = defaultSerializeSnapshot, extractMachineConfig = defaultExtractMachineConfig, selectedActorId, panels, theme, readOnly, depth, capabilities, transport: injectedTransport } = options;
15
15
  const sessionId = options.sessionId ?? generateSessionId();
16
16
  const displayName = name ?? "system:manual";
17
17
  let destroyed = false;
@@ -134,6 +134,7 @@ function createStatelyInspector(options = {}) {
134
134
  ...theme && { theme },
135
135
  ...readOnly !== void 0 && { readOnly },
136
136
  ...depth !== void 0 && { depth },
137
+ ...capabilities !== void 0 && { capabilities },
137
138
  ...panels?.leftPanels && { leftPanels: panels.leftPanels },
138
139
  ...panels?.rightPanels && { rightPanels: panels.rightPanels },
139
140
  ...panels?.activePanels && { activePanels: panels.activePanels }
@@ -0,0 +1,60 @@
1
+ //#region src/oauth.d.ts
2
+ interface OAuthProtectedResourceMetadata {
3
+ resource: string;
4
+ authorization_servers?: string[];
5
+ bearer_methods_supported?: string[];
6
+ scopes_supported?: string[];
7
+ [key: string]: unknown;
8
+ }
9
+ interface OAuthAuthorizationServerMetadata {
10
+ issuer: string;
11
+ authorization_endpoint?: string;
12
+ token_endpoint?: string;
13
+ code_challenge_methods_supported?: string[];
14
+ scopes_supported?: string[];
15
+ [key: string]: unknown;
16
+ }
17
+ interface PkcePair {
18
+ codeVerifier: string;
19
+ codeChallenge: string;
20
+ }
21
+ interface OAuthTokenResponse {
22
+ access_token: string;
23
+ refresh_token?: string;
24
+ expires_in?: number;
25
+ expires_at?: number;
26
+ token_type?: string;
27
+ scope?: string;
28
+ [key: string]: unknown;
29
+ }
30
+ declare function discoverProtectedResource(resourceUrl: string | URL, options?: {
31
+ fetch?: typeof fetch;
32
+ }): Promise<OAuthProtectedResourceMetadata>;
33
+ declare function discoverAuthorizationServer(issuer: string | URL, options?: {
34
+ fetch?: typeof fetch;
35
+ }): Promise<OAuthAuthorizationServerMetadata>;
36
+ declare function createPkcePair(): Promise<PkcePair>;
37
+ declare function buildAuthorizeUrl(options: {
38
+ authorizationEndpoint: string | URL;
39
+ clientId: string;
40
+ redirectUri: string;
41
+ codeChallenge: string;
42
+ state: string;
43
+ scopes?: string[];
44
+ }): string;
45
+ declare function exchangeCodeForToken(options: {
46
+ tokenEndpoint: string | URL;
47
+ code: string;
48
+ codeVerifier: string;
49
+ redirectUri: string;
50
+ clientId: string;
51
+ fetch?: typeof fetch;
52
+ }): Promise<OAuthTokenResponse>;
53
+ declare function refreshToken(options: {
54
+ tokenEndpoint: string | URL;
55
+ refreshToken: string;
56
+ clientId: string;
57
+ fetch?: typeof fetch;
58
+ }): Promise<OAuthTokenResponse>;
59
+ //#endregion
60
+ export { OAuthAuthorizationServerMetadata, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken };
package/dist/oauth.mjs ADDED
@@ -0,0 +1,98 @@
1
+ //#region src/oauth.ts
2
+ function getFetch(fetchImpl) {
3
+ const resolvedFetch = fetchImpl ?? globalThis.fetch;
4
+ if (!resolvedFetch) throw new Error("No fetch implementation available.");
5
+ return resolvedFetch;
6
+ }
7
+ async function fetchJson(url, fetchImpl) {
8
+ const response = await getFetch(fetchImpl)(url, { headers: { Accept: "application/json" } });
9
+ if (!response.ok) throw new Error(`${url} failed with HTTP ${response.status}`);
10
+ return response.json();
11
+ }
12
+ async function discoverProtectedResource(resourceUrl, options = {}) {
13
+ const resource = new URL(String(resourceUrl));
14
+ const pathParts = resource.pathname.split("/").filter(Boolean);
15
+ const baseParts = pathParts.length > 2 && pathParts[0] !== "api" ? pathParts.slice(0, 1) : [];
16
+ const metadataUrl = new URL(resource.origin);
17
+ metadataUrl.pathname = [
18
+ ...baseParts,
19
+ ".well-known",
20
+ "oauth-protected-resource",
21
+ ...pathParts
22
+ ].join("/");
23
+ return fetchJson(metadataUrl.toString(), options.fetch);
24
+ }
25
+ async function discoverAuthorizationServer(issuer, options = {}) {
26
+ const issuerUrl = new URL(String(issuer));
27
+ const metadataUrls = [new URL(".well-known/oauth-authorization-server", ensureTrailingSlash(issuerUrl)), new URL(".well-known/openid-configuration", ensureTrailingSlash(issuerUrl))];
28
+ let lastError;
29
+ for (const metadataUrl of metadataUrls) try {
30
+ return await fetchJson(metadataUrl.toString(), options.fetch);
31
+ } catch (error) {
32
+ lastError = error;
33
+ }
34
+ throw lastError instanceof Error ? lastError : /* @__PURE__ */ new Error(`Unable to discover authorization server metadata for ${issuerUrl}`);
35
+ }
36
+ function ensureTrailingSlash(url) {
37
+ const next = new URL(url);
38
+ if (!next.pathname.endsWith("/")) next.pathname = `${next.pathname}/`;
39
+ return next;
40
+ }
41
+ function base64UrlEncode(bytes) {
42
+ let binary = "";
43
+ for (const byte of bytes) binary += String.fromCharCode(byte);
44
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
45
+ }
46
+ async function createPkcePair() {
47
+ const verifierBytes = new Uint8Array(32);
48
+ crypto.getRandomValues(verifierBytes);
49
+ const codeVerifier = base64UrlEncode(verifierBytes);
50
+ return {
51
+ codeVerifier,
52
+ codeChallenge: base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(codeVerifier))))
53
+ };
54
+ }
55
+ function buildAuthorizeUrl(options) {
56
+ const url = new URL(String(options.authorizationEndpoint));
57
+ url.searchParams.set("response_type", "code");
58
+ url.searchParams.set("client_id", options.clientId);
59
+ url.searchParams.set("redirect_uri", options.redirectUri);
60
+ url.searchParams.set("code_challenge", options.codeChallenge);
61
+ url.searchParams.set("code_challenge_method", "S256");
62
+ url.searchParams.set("state", options.state);
63
+ if (options.scopes?.length) url.searchParams.set("scope", options.scopes.join(" "));
64
+ return url.toString();
65
+ }
66
+ async function exchangeCodeForToken(options) {
67
+ const body = new URLSearchParams({
68
+ grant_type: "authorization_code",
69
+ code: options.code,
70
+ code_verifier: options.codeVerifier,
71
+ redirect_uri: options.redirectUri,
72
+ client_id: options.clientId
73
+ });
74
+ const response = await getFetch(options.fetch)(String(options.tokenEndpoint), {
75
+ method: "POST",
76
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
77
+ body
78
+ });
79
+ if (!response.ok) throw new Error(`Token exchange failed with HTTP ${response.status}`);
80
+ return response.json();
81
+ }
82
+ async function refreshToken(options) {
83
+ const body = new URLSearchParams({
84
+ grant_type: "refresh_token",
85
+ refresh_token: options.refreshToken,
86
+ client_id: options.clientId
87
+ });
88
+ const response = await getFetch(options.fetch)(String(options.tokenEndpoint), {
89
+ method: "POST",
90
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
91
+ body
92
+ });
93
+ if (!response.ok) throw new Error(`Token refresh failed with HTTP ${response.status}`);
94
+ return response.json();
95
+ }
96
+
97
+ //#endregion
98
+ export { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken };
@@ -18,6 +18,25 @@ interface ValidationIssue {
18
18
  level: "info" | "warning" | "error";
19
19
  message: string;
20
20
  }
21
+ interface EditorCapabilities {
22
+ edit?: boolean;
23
+ export?: boolean;
24
+ ai?: boolean;
25
+ simulate?: boolean;
26
+ inspect?: boolean;
27
+ navigateHierarchy?: boolean;
28
+ maxDepth?: number;
29
+ panels?: string[];
30
+ commands?: string[];
31
+ }
32
+ type CapabilityDeniedCapability = "edit" | "export" | "ai" | "simulate" | "inspect" | "navigateHierarchy" | "panel" | "mode";
33
+ interface CapabilityDeniedEvent {
34
+ capability: CapabilityDeniedCapability;
35
+ action: "openPanel" | "openDialog" | "editSource" | "navigateHierarchy" | "setMode" | "simulationStart" | "inspectStart" | "retrieve";
36
+ requested?: string;
37
+ message: string;
38
+ dedupeKey: string;
39
+ }
21
40
  interface SourceRange {
22
41
  startLine: number;
23
42
  startChar: number;
@@ -142,6 +161,7 @@ interface EmbedEventMap {
142
161
  code: string;
143
162
  message: string;
144
163
  };
164
+ capabilityDenied: CapabilityDeniedEvent;
145
165
  snapshot: {
146
166
  snapshot: unknown;
147
167
  event: unknown | null;
@@ -159,6 +179,7 @@ interface MachineInitOptions {
159
179
  theme?: "light" | "dark";
160
180
  readOnly?: boolean;
161
181
  depth?: number;
182
+ capabilities?: EditorCapabilities;
162
183
  panels?: {
163
184
  leftPanels?: string[];
164
185
  rightPanels?: string[];
@@ -191,6 +212,7 @@ interface ProjectInitOptions {
191
212
  theme?: "light" | "dark";
192
213
  readOnly?: boolean;
193
214
  depth?: number;
215
+ capabilities?: EditorCapabilities;
194
216
  panels?: {
195
217
  leftPanels?: string[];
196
218
  rightPanels?: string[];
@@ -212,6 +234,7 @@ interface InitMessage {
212
234
  theme?: "light" | "dark";
213
235
  readOnly?: boolean;
214
236
  depth?: number;
237
+ capabilities?: EditorCapabilities;
215
238
  leftPanels?: string[];
216
239
  rightPanels?: string[];
217
240
  activePanels?: string[];
@@ -234,6 +257,7 @@ interface ProjectInitMessage {
234
257
  theme?: "light" | "dark";
235
258
  readOnly?: boolean;
236
259
  depth?: number;
260
+ capabilities?: EditorCapabilities;
237
261
  leftPanels?: string[];
238
262
  rightPanels?: string[];
239
263
  activePanels?: string[];
@@ -317,6 +341,7 @@ interface SystemInitMessage {
317
341
  theme?: "light" | "dark";
318
342
  readOnly?: boolean;
319
343
  depth?: number;
344
+ capabilities?: EditorCapabilities;
320
345
  leftPanels?: string[];
321
346
  rightPanels?: string[];
322
347
  activePanels?: string[];
@@ -387,6 +412,9 @@ interface ErrorMessage {
387
412
  message: string;
388
413
  requestId?: string;
389
414
  }
415
+ interface CapabilityDeniedMessage extends CapabilityDeniedEvent {
416
+ type: "@statelyai.capabilityDenied";
417
+ }
390
418
  /** File metadata sent from viz to SDK when a file needs uploading. */
391
419
  interface UploadFileInfo {
392
420
  /** Original filename (e.g. "screenshot.png") */
@@ -430,7 +458,7 @@ interface UploadResponseMessage {
430
458
  /** All messages a client (embed/inspector) can send to the viz. */
431
459
  type ClientMessage = InitMessage | ProjectInitMessage | ProjectUpdateMessage | ProjectSelectMachineMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | SystemInitMessage | SystemActorRegisteredMessage | SystemActorSnapshotMessage | SystemActorStoppedMessage | UploadCapabilitiesMessage | UploadResponseMessage | ErrorMessage;
432
460
  /** All messages the viz can send back to a client. */
433
- type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | ProjectMachineSelectedMessage | RetrievedMessage | ErrorMessage | UploadRequestMessage;
461
+ type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | ProjectMachineSelectedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | UploadRequestMessage;
434
462
  interface RegisterMessage {
435
463
  type: "@statelyai.register";
436
464
  role: "client" | "viz";
@@ -478,4 +506,4 @@ type SessionMessage = RegisterMessage | RegisteredMessage | RequestOpenMessage |
478
506
  type ProtocolMessage = ClientMessage | VizMessage | SessionMessage;
479
507
  declare const PREFIX = "@statelyai.";
480
508
  //#endregion
481
- 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 };
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 };
package/dist/studio.d.mts CHANGED
@@ -1,7 +1,12 @@
1
+ import { n as StatelyCredential, t as StatelyAuthMode } from "./auth-DO1-eQcU.mjs";
2
+
1
3
  //#region src/studio.d.ts
2
4
  interface StudioClientOptions {
3
5
  baseUrl?: string;
6
+ credential?: StatelyCredential;
7
+ /** @deprecated Use credential: { type: 'api_key', token }. */
4
8
  apiKey?: string;
9
+ authMode?: StatelyAuthMode;
5
10
  fetch?: typeof fetch;
6
11
  }
7
12
  interface VerifyApiKeyResponse {
@@ -93,7 +98,7 @@ declare class StudioApiError extends Error {
93
98
  }
94
99
  interface StudioClient {
95
100
  auth: {
96
- verify(apiKey?: string): Promise<VerifyApiKeyResponse>;
101
+ verify(credential?: StatelyCredential | string): Promise<VerifyApiKeyResponse>;
97
102
  };
98
103
  projects: {
99
104
  list(): Promise<ProjectData[]>;
@@ -109,7 +114,9 @@ interface StudioClient {
109
114
  };
110
115
  code: {
111
116
  extractMachines(code: string, options?: {
117
+ credential?: StatelyCredential | null; /** @deprecated Use credential. */
112
118
  apiKey?: string | null;
119
+ authMode?: StatelyAuthMode;
113
120
  }): Promise<ExtractMachinesResponse>;
114
121
  };
115
122
  }