@statelyai/sdk 0.11.0 → 0.12.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 +32 -1
- package/dist/auth-DO1-eQcU.d.mts +15 -0
- package/dist/auth.d.mts +2 -0
- package/dist/auth.mjs +11 -0
- package/dist/dist-C-AdA8Iw.mjs +9195 -0
- package/dist/{graphToXStateTS-DV62vO_d.mjs → dist-cQdIPK_n.mjs} +3755 -51
- package/dist/embed.d.mts +3 -2
- package/dist/embed.mjs +9 -1
- package/dist/{graph-GeuH-mFK.d.mts → graph-Bm4_GZX_.d.mts} +2 -262
- package/dist/graph.d.mts +1 -1
- package/dist/index-BpUKBSiq.d.mts +2843 -0
- package/dist/index.d.mts +7 -58
- package/dist/index.mjs +5 -3
- package/dist/{inspect-CZ8iLJR7.d.mts → inspect-BmZUcnZB.d.mts} +2 -1
- package/dist/inspect.d.mts +3 -3
- package/dist/inspect.mjs +3 -2
- package/dist/oauth.d.mts +77 -0
- package/dist/oauth.mjs +118 -0
- package/dist/patchTypes.d.mts +2 -249
- package/dist/protocol.d.mts +30 -2
- package/dist/studio.d.mts +8 -1
- package/dist/studio.mjs +21 -7
- package/dist/sync.d.mts +1 -1
- package/dist/sync.mjs +1 -3091
- package/dist/{transport-CVZGF0w9.mjs → transport-D0nlFaLn.mjs} +2 -0
- package/package.json +11 -2
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
|
-
|
|
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 };
|
package/dist/auth.d.mts
ADDED
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 };
|