@statelyai/sdk 0.13.1 → 0.13.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 +43 -32
- 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
|
|
|
@@ -158,14 +135,17 @@ Node process does not need a Stately API key.
|
|
|
158
135
|
|
|
159
136
|
<!-- CLI package identity and commands from ../cli/package.json and ../cli/src/cli.ts#COMMANDS -->
|
|
160
137
|
|
|
161
|
-
The separate [`statelyai`](https://www.npmjs.com/package/statelyai) CLI
|
|
162
|
-
local XState
|
|
163
|
-
|
|
164
|
-
session.
|
|
138
|
+
The separate [`statelyai`](https://www.npmjs.com/package/statelyai) CLI lists
|
|
139
|
+
local XState machines without authentication and can connect them to Stately
|
|
140
|
+
Studio projects for push, pull, comparison, and browser-backed visual editing.
|
|
165
141
|
|
|
166
142
|
```bash
|
|
143
|
+
npx statelyai scan
|
|
144
|
+
npx statelyai init --local --scan
|
|
145
|
+
npx statelyai status
|
|
167
146
|
npx statelyai push
|
|
168
147
|
npx statelyai pull
|
|
148
|
+
npx statelyai diff ./checkout.machine.ts machine-id
|
|
169
149
|
npx statelyai open ./checkout.machine.ts
|
|
170
150
|
```
|
|
171
151
|
|
|
@@ -175,5 +155,36 @@ Convert between Studio graph data, XState machine configs, and TypeScript source
|
|
|
175
155
|
|
|
176
156
|
## Support
|
|
177
157
|
|
|
178
|
-
For pricing and
|
|
158
|
+
For pricing and support, contact
|
|
179
159
|
[team@stately.ai](mailto:team@stately.ai).
|
|
160
|
+
|
|
161
|
+
## Self-hosting
|
|
162
|
+
|
|
163
|
+
<!-- self-host configuration from the editor app auth and editor-sync routes -->
|
|
164
|
+
|
|
165
|
+
The SDK works with both the hosted Stately editor (`editor.stately.ai`) and
|
|
166
|
+
self-hosted deployments.
|
|
167
|
+
|
|
168
|
+
When self-hosting, authentication is handled by your editor server, not by this
|
|
169
|
+
npm package. The editor host supports configurable auth strategies, and you can
|
|
170
|
+
disable API-key checks for editor-sync endpoints when running behind your own
|
|
171
|
+
auth layer.
|
|
172
|
+
|
|
173
|
+
A fully self-contained deployment with no external auth looks like:
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
const embed = createStatelyEmbed({
|
|
177
|
+
baseUrl: 'https://your-editor.example.com',
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Key environment variables for self-hosted deployments:
|
|
182
|
+
|
|
183
|
+
| Variable | Purpose |
|
|
184
|
+
| --------------------------- | ------------------------------------------------- |
|
|
185
|
+
| `AUTH_PROVIDER` | Auth strategy used by the editor host |
|
|
186
|
+
| `EDITOR_SYNC_AUTH_REQUIRED` | Set to `false` to skip editor-sync API-key checks |
|
|
187
|
+
| `NEXT_PUBLIC_BASE_URL` | Public-facing editor URL |
|
|
188
|
+
|
|
189
|
+
For enterprise self-hosting options, [see pricing and contact
|
|
190
|
+
us](https://stately.ai/pricing).
|
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,
|