@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 +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/embed.d.mts +3 -2
- package/dist/embed.mjs +9 -1
- package/dist/{graph-GeuH-mFK.d.mts → graph-CszT5J6W.d.mts} +3 -1
- package/dist/graph.d.mts +1 -1
- package/dist/{graphToXStateTS-DV62vO_d.mjs → graphToXStateTS-D12GTMBp.mjs} +22 -1
- package/dist/index.d.mts +6 -4
- package/dist/index.mjs +5 -3
- package/dist/{inspect-CZ8iLJR7.d.mts → inspect-BibyPhFj.d.mts} +2 -1
- package/dist/inspect.d.mts +3 -3
- package/dist/inspect.mjs +3 -2
- package/dist/oauth.d.mts +60 -0
- package/dist/oauth.mjs +98 -0
- 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 +527 -42
- package/dist/{transport-CVZGF0w9.mjs → transport-D0nlFaLn.mjs} +2 -0
- package/package.json +9 -1
package/dist/studio.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/studio.ts
|
|
2
4
|
var StudioApiError = class extends Error {
|
|
3
5
|
status;
|
|
@@ -79,10 +81,19 @@ function connectedReposMatch(left, right) {
|
|
|
79
81
|
function createStatelyClient(options = {}) {
|
|
80
82
|
const baseUrl = options.baseUrl ?? "https://stately.ai";
|
|
81
83
|
const fetchImpl = getFetch(options.fetch);
|
|
82
|
-
|
|
84
|
+
const defaultCredential = options.credential ?? (options.apiKey ? {
|
|
85
|
+
type: "api_key",
|
|
86
|
+
token: options.apiKey
|
|
87
|
+
} : void 0);
|
|
88
|
+
const defaultAuthMode = options.authMode ?? "auto";
|
|
89
|
+
async function request(path, init = {}, credentialOverride, authModeOverride) {
|
|
83
90
|
const headers = new Headers(init.headers);
|
|
84
|
-
const
|
|
85
|
-
|
|
91
|
+
const authMode = authModeOverride ?? defaultAuthMode;
|
|
92
|
+
const credential = credentialOverride ?? defaultCredential;
|
|
93
|
+
if (authMode !== "none") {
|
|
94
|
+
if (!getCredentialToken(credential) || !credential) throw new StudioApiError("No Stately credential configured. Pass createStatelyClient({ credential }) or set authMode: \"none\" for no-auth self-hosted deployments.", 401);
|
|
95
|
+
headers.set("Authorization", createAuthorizationHeader(credential));
|
|
96
|
+
}
|
|
86
97
|
const response = await fetchImpl(joinApiUrl(baseUrl, path), {
|
|
87
98
|
...init,
|
|
88
99
|
headers
|
|
@@ -92,8 +103,8 @@ function createStatelyClient(options = {}) {
|
|
|
92
103
|
return unwrapResponseData(data);
|
|
93
104
|
}
|
|
94
105
|
return {
|
|
95
|
-
auth: { verify(
|
|
96
|
-
return request("/verify", { method: "GET" },
|
|
106
|
+
auth: { verify(credential) {
|
|
107
|
+
return request("/verify", { method: "GET" }, credential);
|
|
97
108
|
} },
|
|
98
109
|
projects: {
|
|
99
110
|
list() {
|
|
@@ -143,12 +154,15 @@ function createStatelyClient(options = {}) {
|
|
|
143
154
|
}
|
|
144
155
|
},
|
|
145
156
|
code: { extractMachines(code, extractOptions = {}) {
|
|
146
|
-
const
|
|
157
|
+
const credential = extractOptions.credential ?? (extractOptions.apiKey ? {
|
|
158
|
+
type: "api_key",
|
|
159
|
+
token: extractOptions.apiKey
|
|
160
|
+
} : void 0);
|
|
147
161
|
return request("/code", {
|
|
148
162
|
method: "POST",
|
|
149
163
|
headers: { "Content-Type": "application/json" },
|
|
150
164
|
body: JSON.stringify({ code })
|
|
151
|
-
},
|
|
165
|
+
}, credential, extractOptions.authMode);
|
|
152
166
|
} }
|
|
153
167
|
};
|
|
154
168
|
}
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as DigraphConfig, i as StatelyGraph } from "./graph-
|
|
1
|
+
import { b as DigraphConfig, i as StatelyGraph } from "./graph-CszT5J6W.mjs";
|
|
2
2
|
import { CreateProjectInput, ProjectData, StudioClient, StudioMachineRecord, XStateVersion } from "./studio.mjs";
|
|
3
3
|
import { GraphDiff } from "@statelyai/graph";
|
|
4
4
|
|