@statelyai/sdk 0.29.1 → 0.31.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 +15 -0
- package/dist/assetStorage.d.mts +1 -1
- package/dist/auth.d.mts +1 -1
- package/dist/{statelyPragma-p1vu8PmH.mjs → dist-wbhkeGh6.mjs} +468 -204
- package/dist/{editor-sync-types-DB1N6QUK.d.mts → editor-sync-types-CPpzTSnT.d.mts} +4 -0
- package/dist/{editorHostSession-vSt07IJV.d.mts → editorHostSession-Bo-YhDEG.d.mts} +105 -6
- package/dist/{editorHostSession-DNpXPNAc.mjs → editorHostSession-CT8y0yzG.mjs} +380 -20
- package/dist/editorHostSession.d.mts +2 -2
- package/dist/editorHostSession.mjs +3 -2
- package/dist/embed.d.mts +3 -4
- package/dist/embed.mjs +5 -2
- package/dist/{graph-C8E1Exad.d.mts → graph-CR_g-mOq.d.mts} +1 -1
- package/dist/graph.d.mts +1 -1
- package/dist/{index-D4pdeDpT.d.mts → index-DlOZxzrW.d.mts} +92 -2
- package/dist/index.d.mts +8 -9
- package/dist/index.mjs +6 -5
- package/dist/{inspect-D61HS-t7.d.mts → inspect-BoWXrB-V.d.mts} +3 -2
- package/dist/{inspect-dmCvrIl1.mjs → inspect-DoDj7iWa.mjs} +25 -1
- package/dist/inspect.d.mts +2 -2
- package/dist/inspect.mjs +2 -2
- package/dist/patchTypes.d.mts +1 -1
- package/dist/protocol-2cvzJtGN.d.mts +846 -0
- package/dist/protocol.d.mts +2 -821
- package/dist/relay.d.mts +1 -1
- package/dist/statelyPragma-D46lczJR.mjs +102 -0
- package/dist/{studio-D-yqFd0u.d.mts → studio-DV5IIGhV.d.mts} +2 -2
- package/dist/studio.d.mts +1 -1
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +411 -30
- package/dist/{version-DC3yW9Dk.mjs → version-B6OHpDiz.mjs} +1 -1
- package/package.json +3 -3
- package/schemas/statelyai.schema.json +6 -0
- package/dist/embedPanel-Bpbq4sfJ.d.mts +0 -13
- /package/dist/{auth-BPyCCHYo.d.mts → auth-Dg7prjeL.d.mts} +0 -0
package/dist/relay.d.mts
CHANGED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
//#region src/statelyPragma.ts
|
|
4
|
+
function findStatelyPragmaAttachments(sourceText, fileName = "machine.ts") {
|
|
5
|
+
const sourceFile = ts.createSourceFile(fileName, sourceText, ts.ScriptTarget.Latest, true, getScriptKind(fileName));
|
|
6
|
+
const attachments = [];
|
|
7
|
+
const visit = (node) => {
|
|
8
|
+
if (ts.isCallExpression(node) && isCreateMachineExpression(node.expression)) {
|
|
9
|
+
const attachNode = findAttachNode(node);
|
|
10
|
+
if (attachNode) attachments.push({
|
|
11
|
+
machineStart: getMachineExpressionStart(node.expression, sourceFile),
|
|
12
|
+
attachStart: attachNode.getStart(sourceFile),
|
|
13
|
+
pragma: findAttachedStatelyPragma(sourceText, attachNode)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
ts.forEachChild(node, visit);
|
|
17
|
+
};
|
|
18
|
+
visit(sourceFile);
|
|
19
|
+
return attachments;
|
|
20
|
+
}
|
|
21
|
+
function getStatelyPragma(sourceText, fileName = "machine.ts", machineIndex = 0) {
|
|
22
|
+
return findStatelyPragmaAttachments(sourceText, fileName)[machineIndex]?.pragma;
|
|
23
|
+
}
|
|
24
|
+
function upsertStatelyPragma(sourceText, id, options = {}) {
|
|
25
|
+
const attachment = findStatelyPragmaAttachments(sourceText, options.fileName ?? "machine.ts")[options.machineIndex ?? 0];
|
|
26
|
+
if (!attachment) return sourceText;
|
|
27
|
+
const lineEnding = options.lineEnding ?? detectLineEnding(sourceText);
|
|
28
|
+
const canonicalComment = `// @statelyai id=${id}`;
|
|
29
|
+
if (attachment.pragma) return sourceText.slice(0, attachment.pragma.start) + canonicalComment + sourceText.slice(attachment.pragma.end);
|
|
30
|
+
const insertText = `${getIndentationAtOffset(sourceText, attachment.attachStart)}${canonicalComment}${lineEnding}`;
|
|
31
|
+
return sourceText.slice(0, attachment.attachStart) + insertText + sourceText.slice(attachment.attachStart);
|
|
32
|
+
}
|
|
33
|
+
function findAttachedStatelyPragma(sourceText, node) {
|
|
34
|
+
const comments = ts.getLeadingCommentRanges(sourceText, node.getFullStart()) ?? [];
|
|
35
|
+
for (let index = comments.length - 1; index >= 0; index -= 1) {
|
|
36
|
+
const comment = comments[index];
|
|
37
|
+
const parsed = parseStatelyPragma(sourceText, comment.pos, comment.end);
|
|
38
|
+
if (parsed) return parsed;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function parseStatelyPragma(sourceText, start, end) {
|
|
42
|
+
const match = normalizeCommentContent(sourceText.slice(start, end)).match(/^@statelyai(?:\s+(.*))?$/s);
|
|
43
|
+
if (!match) return;
|
|
44
|
+
const fields = parseFields(match[1] ?? "");
|
|
45
|
+
return {
|
|
46
|
+
tag: "@statelyai",
|
|
47
|
+
id: fields.id,
|
|
48
|
+
fields,
|
|
49
|
+
start,
|
|
50
|
+
end
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function normalizeCommentContent(rawComment) {
|
|
54
|
+
if (rawComment.startsWith("//")) return rawComment.slice(2).trim();
|
|
55
|
+
if (rawComment.startsWith("/*")) return rawComment.slice(2, rawComment.endsWith("*/") ? -2 : void 0).split(/\r?\n/).map((line) => line.replace(/^\s*\*\s?/, "")).join(" ").trim();
|
|
56
|
+
return rawComment.trim();
|
|
57
|
+
}
|
|
58
|
+
function parseFields(input) {
|
|
59
|
+
const fields = {};
|
|
60
|
+
for (const token of input.split(/\s+/)) {
|
|
61
|
+
if (!token) continue;
|
|
62
|
+
const equalsIndex = token.indexOf("=");
|
|
63
|
+
if (equalsIndex <= 0) continue;
|
|
64
|
+
const key = token.slice(0, equalsIndex);
|
|
65
|
+
const value = token.slice(equalsIndex + 1);
|
|
66
|
+
if (!key || !value) continue;
|
|
67
|
+
fields[key] = value;
|
|
68
|
+
}
|
|
69
|
+
return fields;
|
|
70
|
+
}
|
|
71
|
+
function findAttachNode(node) {
|
|
72
|
+
let current = node;
|
|
73
|
+
while (current?.parent) {
|
|
74
|
+
if (ts.isVariableStatement(current.parent) || ts.isExpressionStatement(current.parent) || ts.isExportAssignment(current.parent)) return current.parent;
|
|
75
|
+
current = current.parent;
|
|
76
|
+
}
|
|
77
|
+
return current;
|
|
78
|
+
}
|
|
79
|
+
function isCreateMachineExpression(expression) {
|
|
80
|
+
const isMachineFactoryName = (name) => name === "createMachine" || name === "createMachineFromConfig";
|
|
81
|
+
return ts.isIdentifier(expression) && isMachineFactoryName(expression.text) || ts.isPropertyAccessExpression(expression) && isMachineFactoryName(expression.name.text);
|
|
82
|
+
}
|
|
83
|
+
function getMachineExpressionStart(expression, sourceFile) {
|
|
84
|
+
if (ts.isPropertyAccessExpression(expression)) return expression.name.getStart(sourceFile);
|
|
85
|
+
return expression.getStart(sourceFile);
|
|
86
|
+
}
|
|
87
|
+
function getIndentationAtOffset(sourceText, offset) {
|
|
88
|
+
const lineStart = sourceText.lastIndexOf("\n", Math.max(0, offset - 1)) + 1;
|
|
89
|
+
return sourceText.slice(lineStart, offset).match(/^[ \t]*/)?.[0] ?? "";
|
|
90
|
+
}
|
|
91
|
+
function detectLineEnding(sourceText) {
|
|
92
|
+
return sourceText.includes("\r\n") ? "\r\n" : "\n";
|
|
93
|
+
}
|
|
94
|
+
function getScriptKind(fileName) {
|
|
95
|
+
if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
96
|
+
if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
97
|
+
if (fileName.endsWith(".js")) return ts.ScriptKind.JS;
|
|
98
|
+
return ts.ScriptKind.TS;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { getStatelyPragma as n, upsertStatelyPragma as r, findStatelyPragmaAttachments as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ZodObject, D as ZodLiteral, E as ZodEnum, F as ZodUnknown, I as output, L as $loose, M as ZodRecord, N as ZodString, O as ZodNullable, P as ZodUnion, R as $strip, T as ZodBoolean, j as ZodOptional, k as ZodNumber, w as ZodArray } from "./index-
|
|
2
|
-
import { n as StatelyCredential, t as StatelyAuthMode } from "./auth-
|
|
1
|
+
import { A as ZodObject, D as ZodLiteral, E as ZodEnum, F as ZodUnknown, I as output, L as $loose, M as ZodRecord, N as ZodString, O as ZodNullable, P as ZodUnion, R as $strip, T as ZodBoolean, j as ZodOptional, k as ZodNumber, w as ZodArray } from "./index-DlOZxzrW.mjs";
|
|
2
|
+
import { n as StatelyCredential, t as StatelyAuthMode } from "./auth-Dg7prjeL.mjs";
|
|
3
3
|
|
|
4
4
|
//#region ../api-contract/dist/errors.d.mts
|
|
5
5
|
/**
|
package/dist/studio.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, p as LegacyExtractMachinesOptions, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-
|
|
1
|
+
import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, p as LegacyExtractMachinesOptions, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-DV5IIGhV.mjs";
|
|
2
2
|
export { ConnectedRepo, CreateMachineFromDefinitionInput, CreateMachineFromTemplateInput, CreateMachineInput, CreateMachineTemplate, CreateProjectInput, DEFAULT_STATELY_BASE_URL, EnsureProjectInput, ExtractMachinesInput, ExtractMachinesResponse, ExtractedMachine, ExtractedMachines, GetMachineOptions, LegacyExtractMachinesOptions, LegacyProjectVisibility, LegacyUpdateMachineInput, Machine, MachineVersion, Project, ProjectData, ProjectMachine, ProjectMachineSummary, ProjectSummary, ProjectVisibility, RepoType, ResourceErrorCode, StudioApiError, StudioApiErrorOptions, StudioClient, StudioClientOptions, StudioMachineRecord, StudioRequestOptions, UpdateMachineInput, UpdateProjectInput, VerifyApiKeyResponse, VerifyResult, XStateVersion, createStatelyClient };
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as DigraphConfig, i as StatelyGraph } from "./graph-
|
|
2
|
-
import { C as StudioMachineRecord, L as XStateVersion, g as ProjectData, o as CreateProjectInput, x as StudioClient } from "./studio-
|
|
1
|
+
import { b as DigraphConfig, i as StatelyGraph } from "./graph-CR_g-mOq.mjs";
|
|
2
|
+
import { C as StudioMachineRecord, L as XStateVersion, g as ProjectData, o as CreateProjectInput, x as StudioClient } from "./studio-DV5IIGhV.mjs";
|
|
3
3
|
import { GraphDiff } from "@statelyai/graph";
|
|
4
4
|
|
|
5
5
|
//#region src/sync.d.ts
|