@statelyai/sdk 0.13.1 → 0.13.2
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 +40 -30
- package/dist/studio.mjs +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,31 +80,6 @@ Key capabilities:
|
|
|
80
80
|
- **Asset uploads** with built-in S3 and Supabase adapters, or bring your own upload handler
|
|
81
81
|
- **Runtime settings** - toggle color mode, grid, snap lines, autolayout, and view mode on the fly
|
|
82
82
|
|
|
83
|
-
### Self-hosting
|
|
84
|
-
|
|
85
|
-
<!-- self-host configuration from the editor app auth and editor-sync routes -->
|
|
86
|
-
|
|
87
|
-
The SDK works with both the hosted Stately editor (`editor.stately.ai`) and
|
|
88
|
-
self-hosted deployments.
|
|
89
|
-
|
|
90
|
-
When self-hosting, authentication is handled by your editor server, not by this npm package. The editor host supports configurable auth strategies, and you can disable API-key checks for editor-sync endpoints when running behind your own auth layer.
|
|
91
|
-
|
|
92
|
-
A fully self-contained deployment with no external auth looks like:
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
const embed = createStatelyEmbed({
|
|
96
|
-
baseUrl: 'https://your-editor.example.com',
|
|
97
|
-
});
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Key environment variables for self-hosted deployments:
|
|
101
|
-
|
|
102
|
-
| Variable | Purpose |
|
|
103
|
-
| --------------------------- | -------------------------------------------- |
|
|
104
|
-
| `AUTH_PROVIDER` | Auth strategy used by the editor host |
|
|
105
|
-
| `EDITOR_SYNC_AUTH_REQUIRED` | Set to `false` to skip editor-sync API-key checks |
|
|
106
|
-
| `NEXT_PUBLIC_BASE_URL` | Public-facing editor URL |
|
|
107
|
-
|
|
108
83
|
### Studio API client
|
|
109
84
|
|
|
110
85
|
Programmatic access to Stately Studio for managing projects and machines, extracting machine configs from source code, and verifying API keys.
|
|
@@ -125,8 +100,10 @@ const extracted = await studio.code.extractMachines(sourceCode);
|
|
|
125
100
|
```
|
|
126
101
|
|
|
127
102
|
Legacy `apiKey` is still accepted as an alias for
|
|
128
|
-
`credential: { type: 'api_key', token }`.
|
|
129
|
-
|
|
103
|
+
`credential: { type: 'api_key', token }`. The default `authMode: 'auto'` sends
|
|
104
|
+
a credential when present and otherwise lets the server accept or reject an
|
|
105
|
+
unauthenticated request. Use `authMode: 'bearer'` to require a credential before
|
|
106
|
+
making requests, or `authMode: 'none'` to ignore a configured credential.
|
|
130
107
|
|
|
131
108
|
### Inspector
|
|
132
109
|
|
|
@@ -160,12 +137,14 @@ Node process does not need a Stately API key.
|
|
|
160
137
|
|
|
161
138
|
The separate [`statelyai`](https://www.npmjs.com/package/statelyai) CLI syncs
|
|
162
139
|
local XState source files with Stately Studio projects: push local machines,
|
|
163
|
-
pull remote changes,
|
|
164
|
-
session.
|
|
140
|
+
pull remote changes, inspect project inventory, compare machines, and open a
|
|
141
|
+
local file in a browser-backed visual editor session.
|
|
165
142
|
|
|
166
143
|
```bash
|
|
144
|
+
npx statelyai status
|
|
167
145
|
npx statelyai push
|
|
168
146
|
npx statelyai pull
|
|
147
|
+
npx statelyai diff ./checkout.machine.ts machine-id
|
|
169
148
|
npx statelyai open ./checkout.machine.ts
|
|
170
149
|
```
|
|
171
150
|
|
|
@@ -175,5 +154,36 @@ Convert between Studio graph data, XState machine configs, and TypeScript source
|
|
|
175
154
|
|
|
176
155
|
## Support
|
|
177
156
|
|
|
178
|
-
For pricing and
|
|
157
|
+
For pricing and support, contact
|
|
158
|
+
[team@stately.ai](mailto:team@stately.ai).
|
|
159
|
+
|
|
160
|
+
## Self-hosting
|
|
161
|
+
|
|
162
|
+
<!-- self-host configuration from the editor app auth and editor-sync routes -->
|
|
163
|
+
|
|
164
|
+
The SDK works with both the hosted Stately editor (`editor.stately.ai`) and
|
|
165
|
+
self-hosted deployments.
|
|
166
|
+
|
|
167
|
+
When self-hosting, authentication is handled by your editor server, not by this
|
|
168
|
+
npm package. The editor host supports configurable auth strategies, and you can
|
|
169
|
+
disable API-key checks for editor-sync endpoints when running behind your own
|
|
170
|
+
auth layer.
|
|
171
|
+
|
|
172
|
+
A fully self-contained deployment with no external auth looks like:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
const embed = createStatelyEmbed({
|
|
176
|
+
baseUrl: 'https://your-editor.example.com',
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Key environment variables for self-hosted deployments:
|
|
181
|
+
|
|
182
|
+
| Variable | Purpose |
|
|
183
|
+
| --------------------------- | ------------------------------------------------- |
|
|
184
|
+
| `AUTH_PROVIDER` | Auth strategy used by the editor host |
|
|
185
|
+
| `EDITOR_SYNC_AUTH_REQUIRED` | Set to `false` to skip editor-sync API-key checks |
|
|
186
|
+
| `NEXT_PUBLIC_BASE_URL` | Public-facing editor URL |
|
|
187
|
+
|
|
188
|
+
For self-hosting details, contact
|
|
179
189
|
[team@stately.ai](mailto:team@stately.ai).
|
package/dist/studio.mjs
CHANGED
|
@@ -91,8 +91,9 @@ function createStatelyClient(options = {}) {
|
|
|
91
91
|
const authMode = authModeOverride ?? defaultAuthMode;
|
|
92
92
|
const credential = credentialOverride ?? defaultCredential;
|
|
93
93
|
if (authMode !== "none") {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const token = getCredentialToken(credential);
|
|
95
|
+
if (authMode === "bearer" && (!token || !credential)) throw new StudioApiError("No Stately credential configured. Pass createStatelyClient({ credential }) or use authMode: \"auto\" to let the server decide whether authentication is required.", 401);
|
|
96
|
+
if (token && credential) headers.set("Authorization", createAuthorizationHeader(credential));
|
|
96
97
|
}
|
|
97
98
|
const response = await fetchImpl(joinApiUrl(baseUrl, path), {
|
|
98
99
|
...init,
|