@statelyai/sdk 0.20.1 → 0.20.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/dist/embed.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as createEventRegistry, o as createPendingExportManager, r as createPostMessageTransport, s as toInitMessage, t as SDK_VERSION } from "./version-YJizbJxR.mjs";
1
+ import { a as createEventRegistry, o as createPendingExportManager, r as createPostMessageTransport, s as toInitMessage, t as SDK_VERSION } from "./version-C-1n7MoR.mjs";
2
2
  import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-D_h4y3rX.mjs";
3
3
 
4
4
  //#region src/embed.ts
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
2
- import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-YJizbJxR.mjs";
2
+ import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-C-1n7MoR.mjs";
3
3
  import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-D_h4y3rX.mjs";
4
4
  import { createStatelyEmbed } from "./embed.mjs";
5
5
  import { n as createRemoteEditorSyncBackend, r as fetchEditorSyncAccess, t as EditorHostSession } from "./editorHostSession-CCTwvUOB.mjs";
6
6
  import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-DHGspwII.mjs";
7
- import { a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, l as graphToMachineConfig, m as serializeJS, n as getStatelyPragma, o as contextSchemaToTSType, p as raw, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-CIzsR_Sx.mjs";
7
+ import { a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, l as graphToMachineConfig, m as serializeJS, n as getStatelyPragma, o as contextSchemaToTSType, p as raw, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-Cnj58Rua.mjs";
8
8
  import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
9
- import { n as createStatelyInspector, t as createInspector } from "./inspect-DWu20a8g.mjs";
9
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-CwN52e61.mjs";
10
10
  import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
11
11
  import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
12
12
  import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
@@ -1,5 +1,5 @@
1
1
  import { INSPECTION_PROTOCOL_VERSION, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
2
- import { a as createEventRegistry, i as createWebSocketTransport, n as inspectionRuntime, o as createPendingExportManager, t as SDK_VERSION } from "./version-YJizbJxR.mjs";
2
+ import { a as createEventRegistry, i as createWebSocketTransport, n as inspectionRuntime, o as createPendingExportManager, t as SDK_VERSION } from "./version-C-1n7MoR.mjs";
3
3
 
4
4
  //#region src/openBrowser.ts
5
5
  async function openBrowser(url) {
package/dist/inspect.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import "./version-YJizbJxR.mjs";
2
- import { n as createStatelyInspector, t as createInspector } from "./inspect-DWu20a8g.mjs";
1
+ import "./version-C-1n7MoR.mjs";
2
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-CwN52e61.mjs";
3
3
 
4
4
  export { createInspector, createStatelyInspector };
package/dist/oauth.mjs CHANGED
@@ -27,6 +27,7 @@ async function createOAuthTokenRequestError(response, message) {
27
27
  try {
28
28
  const parsed = JSON.parse(body);
29
29
  if (typeof parsed.error === "string") oauthError = parsed.error;
30
+ else if (typeof parsed.error_code === "string") oauthError = parsed.error_code;
30
31
  } catch {}
31
32
  const detail = body.trim() ? `: ${body.trim()}` : "";
32
33
  return new OAuthTokenRequestError(`${message} with HTTP ${response.status}${detail}`, response.status, oauthError);
@@ -1,5 +1,6 @@
1
1
  import { a as discriminatedUnion, c as object, d as union, f as unknown, i as custom, l as record, n as array, o as literal, r as boolean, s as number, t as _enum, u as string } from "./schemas-b9wG-zYl.mjs";
2
2
  import ts from "typescript";
3
+ import "xstate";
3
4
  import "xstate/graph";
4
5
 
5
6
  //#region ../../node_modules/.pnpm/js-yaml@4.2.0/node_modules/js-yaml/dist/js-yaml.mjs
@@ -2333,175 +2334,6 @@ var index_vite_proxy_tmp_default = import_js_yaml.default;
2333
2334
 
2334
2335
  //#endregion
2335
2336
  //#region ../graph-tools/dist/index.mjs
2336
- /**
2337
- * Converts a graph to an adjacency list representation.
2338
- *
2339
- * @example
2340
- * ```ts
2341
- * import { createGraph, toAdjacencyList } from '@statelyai/graph';
2342
- *
2343
- * const graph = createGraph({
2344
- * nodes: { a: {}, b: {}, c: {} },
2345
- * edges: [{ source: 'a', target: 'b' }, { source: 'a', target: 'c' }],
2346
- * });
2347
- *
2348
- * toAdjacencyList(graph);
2349
- * // { a: ['b', 'c'], b: [], c: [] }
2350
- * ```
2351
- */
2352
- function toAdjacencyList(graph) {
2353
- const adj = {};
2354
- for (const node of graph.nodes) adj[node.id] = [];
2355
- for (const edge of graph.edges) {
2356
- adj[edge.sourceId]?.push(edge.targetId);
2357
- if (graph.mode !== "directed") adj[edge.targetId]?.push(edge.sourceId);
2358
- }
2359
- return adj;
2360
- }
2361
- /**
2362
- * Parses an adjacency list into a graph.
2363
- *
2364
- * @example
2365
- * ```ts
2366
- * import { fromAdjacencyList } from '@statelyai/graph';
2367
- *
2368
- * const graph = fromAdjacencyList({
2369
- * a: ['b', 'c'],
2370
- * b: ['c'],
2371
- * c: [],
2372
- * });
2373
- *
2374
- * graph.nodes; // [{id: 'a', ...}, {id: 'b', ...}, {id: 'c', ...}]
2375
- * graph.edges; // [{sourceId: 'a', targetId: 'b', ...}, ...]
2376
- * ```
2377
- */
2378
- function fromAdjacencyList(adj, options) {
2379
- const directed = options?.directed ?? true;
2380
- const seen = /* @__PURE__ */ new Set();
2381
- const nodes = Object.keys(adj).map((id) => ({
2382
- type: "node",
2383
- id,
2384
- parentId: null,
2385
- initialNodeId: null,
2386
- label: "",
2387
- data: void 0
2388
- }));
2389
- const edges = [];
2390
- let edgeIdx = 0;
2391
- for (const [sourceId, targets] of Object.entries(adj)) for (const targetId of targets) {
2392
- const key = directed ? `${sourceId}->${targetId}` : [sourceId, targetId].sort().join("<->");
2393
- if (!seen.has(key)) {
2394
- seen.add(key);
2395
- edges.push({
2396
- type: "edge",
2397
- id: `e${edgeIdx++}`,
2398
- sourceId,
2399
- targetId,
2400
- label: "",
2401
- data: void 0
2402
- });
2403
- }
2404
- }
2405
- return {
2406
- id: options?.id ?? "",
2407
- mode: directed ? "directed" : "undirected",
2408
- initialNodeId: null,
2409
- nodes,
2410
- edges,
2411
- data: void 0
2412
- };
2413
- }
2414
- /**
2415
- * Converts a graph to an edge list of `[source, target]` tuples.
2416
- *
2417
- * @example
2418
- * ```ts
2419
- * import { createGraph, toEdgeList } from '@statelyai/graph';
2420
- *
2421
- * const graph = createGraph({
2422
- * nodes: { a: {}, b: {}, c: {} },
2423
- * edges: [{ source: 'a', target: 'b' }, { source: 'b', target: 'c' }],
2424
- * });
2425
- *
2426
- * toEdgeList(graph);
2427
- * // [['a', 'b'], ['b', 'c']]
2428
- * ```
2429
- */
2430
- function toEdgeList(graph) {
2431
- return graph.edges.map((e) => [e.sourceId, e.targetId]);
2432
- }
2433
- /**
2434
- * Parses an edge list of `[source, target]` tuples into a graph.
2435
- *
2436
- * @example
2437
- * ```ts
2438
- * import { fromEdgeList } from '@statelyai/graph';
2439
- *
2440
- * const graph = fromEdgeList([
2441
- * ['a', 'b'],
2442
- * ['b', 'c'],
2443
- * ]);
2444
- *
2445
- * graph.nodes; // [{id: 'a', ...}, {id: 'b', ...}, {id: 'c', ...}]
2446
- * graph.edges; // [{sourceId: 'a', targetId: 'b', ...}, ...]
2447
- * ```
2448
- */
2449
- function fromEdgeList(edges, options) {
2450
- const directed = options?.directed ?? true;
2451
- const nodeIds = /* @__PURE__ */ new Set();
2452
- for (const [source, target] of edges) {
2453
- nodeIds.add(source);
2454
- nodeIds.add(target);
2455
- }
2456
- const nodes = [...nodeIds].map((id) => ({
2457
- type: "node",
2458
- id,
2459
- parentId: null,
2460
- initialNodeId: null,
2461
- label: "",
2462
- data: void 0
2463
- }));
2464
- const edgeObjects = edges.map(([sourceId, targetId], i) => ({
2465
- type: "edge",
2466
- id: `e${i}`,
2467
- sourceId,
2468
- targetId,
2469
- label: "",
2470
- data: void 0
2471
- }));
2472
- return {
2473
- id: options?.id ?? "",
2474
- mode: directed ? "directed" : "undirected",
2475
- initialNodeId: null,
2476
- nodes,
2477
- edges: edgeObjects,
2478
- data: void 0
2479
- };
2480
- }
2481
- /**
2482
- * Create a `GraphFormatConverter` from a pair of `to`/`from` functions.
2483
- *
2484
- * @example
2485
- * ```ts
2486
- * import { createFormatConverter } from '@statelyai/graph';
2487
- *
2488
- * const yamlConverter = createFormatConverter(
2489
- * (graph) => toYAML(graph),
2490
- * (yaml) => fromYAML(yaml),
2491
- * );
2492
- *
2493
- * const yaml = yamlConverter.to(graph);
2494
- * const graph = yamlConverter.from(yaml);
2495
- * ```
2496
- */
2497
- function createFormatConverter(to, from) {
2498
- return {
2499
- to,
2500
- from
2501
- };
2502
- }
2503
- createFormatConverter(toAdjacencyList, fromAdjacencyList);
2504
- createFormatConverter(toEdgeList, fromEdgeList);
2505
2337
  const LAYOUT_KEYS = {
2506
2338
  node: [
2507
2339
  "x",
@@ -2517,6 +2349,8 @@ const LAYOUT_KEYS = {
2517
2349
  "y",
2518
2350
  "width",
2519
2351
  "height",
2352
+ "points",
2353
+ "routing",
2520
2354
  "style",
2521
2355
  "color"
2522
2356
  ]
@@ -3165,7 +2999,7 @@ function graphToMachineConfig(graph, options = {}) {
3165
2999
  }
3166
3000
  return nodeConfig;
3167
3001
  }
3168
- const rootNode = graph.nodes.find((node) => node.data.parentId === null || node.parentId == null);
3002
+ const rootNode = graph.nodes.find((node) => node.parentId === null || node.parentId == null);
3169
3003
  if (!rootNode) throw new Error("No root node found");
3170
3004
  getNodeConfig(rootNode);
3171
3005
  if (graph.data.context !== void 0 && graph.data.context !== null) config.context = graph.data.context;
package/dist/sync.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { r as createStatelyClient } from "./studio-DHGspwII.mjs";
2
- import { f as normalizeMachineProfile, h as xstateSourceToConfig, i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as serializeJS, n as getStatelyPragma, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-CIzsR_Sx.mjs";
2
+ import { f as normalizeMachineProfile, h as xstateSourceToConfig, i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as serializeJS, n as getStatelyPragma, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-Cnj58Rua.mjs";
3
3
  import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
4
4
  import * as ts$1 from "typescript";
5
5
  import ts from "typescript";
@@ -328,7 +328,7 @@ function createWebSocketTransport(options) {
328
328
 
329
329
  //#endregion
330
330
  //#region src/version.ts
331
- const SDK_VERSION = "0.20.1";
331
+ const SDK_VERSION = "0.20.2";
332
332
  function inspectionRuntime() {
333
333
  if (typeof window !== "undefined") return "browser";
334
334
  if (typeof process !== "undefined" && process.versions?.node) return "node";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/sdk",
3
- "version": "0.20.1",
3
+ "version": "0.20.2",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "stately-sdk": "./dist/bin.mjs"
@@ -81,7 +81,7 @@
81
81
  "./schemas/xstate-json.schema.json": "./schemas/xstate.schema.json"
82
82
  },
83
83
  "dependencies": {
84
- "@statelyai/graph": "^1.0.0",
84
+ "@statelyai/graph": "^2.1.0",
85
85
  "esbuild": "^0.27.0",
86
86
  "typescript": "^5.9.3",
87
87
  "ws": "^8.19.0",
@@ -93,8 +93,8 @@
93
93
  "jsdom": "^27.4.0",
94
94
  "tsdown": "0.21.0-beta.2",
95
95
  "vitest": "^3.2.4",
96
- "@statelyai/api-contract": "0.1.1",
97
- "@statelyai/graph-tools": "0.0.9"
96
+ "@statelyai/api-contract": "0.3.2",
97
+ "@statelyai/graph-tools": "0.1.0"
98
98
  },
99
99
  "engines": {
100
100
  "node": ">=22.4"