@w6w/embed 0.2.11 → 0.2.19
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 +22 -5
- package/dist/ConfirmModal-Pv2-A_3U.js +186 -0
- package/dist/ConfirmModal-Pv2-A_3U.js.map +1 -0
- package/dist/{CreateFunctionModal-D6CQLpa_.js → CreateFunctionModal-DScxp_LN.js} +2 -2
- package/dist/{CreateFunctionModal-D6CQLpa_.js.map → CreateFunctionModal-DScxp_LN.js.map} +1 -1
- package/dist/{DocumentFormModal-YauVdolr.js → DocumentFormModal-Br4s8wmi.js} +3 -3
- package/dist/{DocumentFormModal-YauVdolr.js.map → DocumentFormModal-Br4s8wmi.js.map} +1 -1
- package/dist/ImportSpecModal-Cpzp8ndt.js +251 -0
- package/dist/ImportSpecModal-Cpzp8ndt.js.map +1 -0
- package/dist/{ModelRoutesManager-BGESQahw.js → ModelRoutesManager-1Ac5wcas.js} +3 -3
- package/dist/{ModelRoutesManager-BGESQahw.js.map → ModelRoutesManager-1Ac5wcas.js.map} +1 -1
- package/dist/WorkflowEditor-CmhXHRxi.js +1109 -0
- package/dist/WorkflowEditor-CmhXHRxi.js.map +1 -0
- package/dist/apps-ItBvnWX3.js +92 -0
- package/dist/apps-ItBvnWX3.js.map +1 -0
- package/dist/chrome/DangerZone.d.ts +4 -3
- package/dist/chrome/ExecutionProfileHeader.d.ts +3 -3
- package/dist/chrome/JsonToggle.d.ts +29 -20
- package/dist/chrome/Modal.d.ts +3 -1
- package/dist/chrome/RightRail.d.ts +6 -1
- package/dist/chrome/VersionHistoryModal.d.ts +2 -0
- package/dist/chrome/index.d.ts +1 -0
- package/dist/chrome/workspace.d.ts +32 -1
- package/dist/{coerce-input-DttlcSdO.js → coerce-input-DFJ4n_wc.js} +68 -69
- package/dist/coerce-input-DFJ4n_wc.js.map +1 -0
- package/dist/{connections-D7cgXhDS.js → connections-CzsCyIxY.js} +10 -10
- package/dist/{connections-D7cgXhDS.js.map → connections-CzsCyIxY.js.map} +1 -1
- package/dist/{credentials-DaQU3Ca_.js → credentials-Cn92LGhJ.js} +4 -4
- package/dist/{credentials-DaQU3Ca_.js.map → credentials-Cn92LGhJ.js.map} +1 -1
- package/dist/data-stores-UeQvwVCa.js +170 -0
- package/dist/data-stores-UeQvwVCa.js.map +1 -0
- package/dist/document-sources-DNmBojx6.js +169 -0
- package/dist/document-sources-DNmBojx6.js.map +1 -0
- package/dist/draft/use-workflow-draft.d.ts +2 -0
- package/dist/draft.mjs +2 -2
- package/dist/editor/PublishTooltip.d.ts +7 -0
- package/dist/editor/SetupIncompleteBanner.d.ts +12 -0
- package/dist/editor/StartingStateModal.d.ts +14 -0
- package/dist/editor/WorkflowSettingsModal.d.ts +6 -1
- package/dist/editor/WorkflowVariablesEditor.d.ts +6 -0
- package/dist/editor/definition.d.ts +4 -0
- package/dist/editor/json-apply.d.ts +29 -0
- package/dist/editor/step-problems-feed.d.ts +5 -0
- package/dist/editor/types.d.ts +2 -2
- package/dist/editor-apps-DkkC7wOQ.js +152 -0
- package/dist/editor-apps-DkkC7wOQ.js.map +1 -0
- package/dist/editor-tools-BR27RGto.js +1683 -0
- package/dist/editor-tools-BR27RGto.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +536 -478
- package/dist/editors.mjs.map +1 -1
- package/dist/forms.mjs +3 -3
- package/dist/{rail-settings-XYGToh00.js → import-bindings-EUtxZ9Ti.js} +90 -24
- package/dist/import-bindings-EUtxZ9Ti.js.map +1 -0
- package/dist/index.mjs +138 -108
- package/dist/index.mjs.map +1 -1
- package/dist/lib/binding-problems.d.ts +5 -1
- package/dist/lib/history-query.d.ts +45 -0
- package/dist/lib/import-bindings.d.ts +89 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/rail-settings.d.ts +1 -1
- package/dist/lib/setup-incomplete.d.ts +22 -0
- package/dist/lib/starting-data.d.ts +31 -0
- package/dist/lib/state-panel.d.ts +29 -0
- package/dist/lib/target-fields.d.ts +3 -15
- package/dist/lib/workflow-live-run.d.ts +84 -6
- package/dist/lib/workflow-validity.d.ts +64 -16
- package/dist/lib/workflow-variables.d.ts +1 -1
- package/dist/lib/workflow-version.d.ts +2 -0
- package/dist/lib.mjs +87 -72
- package/dist/lists/DataStoreList.d.ts +17 -0
- package/dist/lists/DataStoreView.d.ts +19 -0
- package/dist/lists/Logs.d.ts +19 -0
- package/dist/lists.d.ts +6 -0
- package/dist/lists.mjs +1255 -816
- package/dist/lists.mjs.map +1 -1
- package/dist/rail/ConnectionsTool.d.ts +2 -0
- package/dist/rail/HistoryTool.d.ts +2 -0
- package/dist/rail/StartingStateTool.d.ts +2 -0
- package/dist/rail/settings-sections.d.ts +4 -1
- package/dist/rail.mjs +1 -1
- package/dist/repos/constants.d.ts +12 -0
- package/dist/repos/data-stores.d.ts +84 -0
- package/dist/repos/history.d.ts +9 -0
- package/dist/repos/index.d.ts +2 -0
- package/dist/repos/spec-export.d.ts +3 -3
- package/dist/repos/spec-import.d.ts +30 -1
- package/dist/repos/step-tests.d.ts +2 -0
- package/dist/repos/webhook-listen.d.ts +35 -0
- package/dist/repos/workflows.d.ts +105 -2
- package/dist/repos.mjs +370 -328
- package/dist/repos.mjs.map +1 -1
- package/dist/setup-incomplete-BHs3Lpfy.js +199 -0
- package/dist/setup-incomplete-BHs3Lpfy.js.map +1 -0
- package/dist/{spec-export-CBbloO_n.js → spec-export-DGy5ijps.js} +72 -59
- package/dist/spec-export-DGy5ijps.js.map +1 -0
- package/dist/spec-import-SWOonsNr.js +116 -0
- package/dist/spec-import-SWOonsNr.js.map +1 -0
- package/dist/{step-tests-CivICmTq.js → step-tests-B4E4W3ly.js} +8 -7
- package/dist/step-tests-B4E4W3ly.js.map +1 -0
- package/dist/{use-callable-draft-DsALnSfF.js → use-callable-draft-DCauHt5o.js} +2 -2
- package/dist/{use-callable-draft-DsALnSfF.js.map → use-callable-draft-DCauHt5o.js.map} +1 -1
- package/dist/use-workflow-draft-l3P5KZzw.js +338 -0
- package/dist/use-workflow-draft-l3P5KZzw.js.map +1 -0
- package/dist/workflows-BZN4Hyz1.js +623 -0
- package/dist/workflows-BZN4Hyz1.js.map +1 -0
- package/package.json +3 -2
- package/src/styles.css +153 -1
- package/dist/ConfirmModal-BE-SdX-O.js +0 -185
- package/dist/ConfirmModal-BE-SdX-O.js.map +0 -1
- package/dist/ImportSpecModal-B7qd1Km2.js +0 -136
- package/dist/ImportSpecModal-B7qd1Km2.js.map +0 -1
- package/dist/WorkflowEditor-CwvmAGp2.js +0 -925
- package/dist/WorkflowEditor-CwvmAGp2.js.map +0 -1
- package/dist/apps-CboASBKr.js +0 -77
- package/dist/apps-CboASBKr.js.map +0 -1
- package/dist/coerce-input-DttlcSdO.js.map +0 -1
- package/dist/document-sources-UCwe8x77.js +0 -91
- package/dist/document-sources-UCwe8x77.js.map +0 -1
- package/dist/editor-apps-BUZWld-m.js +0 -95
- package/dist/editor-apps-BUZWld-m.js.map +0 -1
- package/dist/editor-tools-B_Lfx3kw.js +0 -1279
- package/dist/editor-tools-B_Lfx3kw.js.map +0 -1
- package/dist/rail-settings-XYGToh00.js.map +0 -1
- package/dist/spec-export-CBbloO_n.js.map +0 -1
- package/dist/spec-import-CW6R_Wk1.js +0 -469
- package/dist/spec-import-CW6R_Wk1.js.map +0 -1
- package/dist/step-tests-CivICmTq.js.map +0 -1
- package/dist/trigger-preview-DKxfjzUY.js +0 -145
- package/dist/trigger-preview-DKxfjzUY.js.map +0 -1
- package/dist/use-workflow-draft-DzAyUeA6.js +0 -316
- package/dist/use-workflow-draft-DzAyUeA6.js.map +0 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { useQueryClient as l, useMutation as u, useQuery as m, useInfiniteQuery as C } from "@tanstack/react-query";
|
|
2
|
+
import { u as i } from "./client-context-CX61Bgw-.js";
|
|
3
|
+
const f = 10, p = 200;
|
|
4
|
+
function K(e) {
|
|
5
|
+
return ["data-stores", e, "list"];
|
|
6
|
+
}
|
|
7
|
+
function Q(e, n) {
|
|
8
|
+
return ["data-stores", n, "detail", e];
|
|
9
|
+
}
|
|
10
|
+
function x(e, n, t) {
|
|
11
|
+
return ["data-stores", n, "entries", e, t];
|
|
12
|
+
}
|
|
13
|
+
async function q(e, n) {
|
|
14
|
+
const t = [];
|
|
15
|
+
let s;
|
|
16
|
+
for (let r = 0; r < f; r++) {
|
|
17
|
+
const a = await e.dataStores.list({ project: n, cursor: s, limit: p });
|
|
18
|
+
if (t.push(...a.items), a.nextCursor === void 0) break;
|
|
19
|
+
s = a.nextCursor;
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
}
|
|
23
|
+
async function v(e, n) {
|
|
24
|
+
return (await q(e, n)).map((t) => ({ name: t.name, kind: t.kind }));
|
|
25
|
+
}
|
|
26
|
+
const y = /* @__PURE__ */ new Map();
|
|
27
|
+
async function D(e, n, t, s = {}) {
|
|
28
|
+
var S;
|
|
29
|
+
const r = `${n}\0${t}`;
|
|
30
|
+
let a = y.get(r);
|
|
31
|
+
if (a === void 0) {
|
|
32
|
+
let o;
|
|
33
|
+
for (let c = 0; c < f && a === void 0; c++) {
|
|
34
|
+
const d = await e.dataStores.list({
|
|
35
|
+
project: n,
|
|
36
|
+
cursor: o,
|
|
37
|
+
limit: p,
|
|
38
|
+
signal: s.signal
|
|
39
|
+
});
|
|
40
|
+
if (a = (S = d.items.find((g) => g.name === t)) == null ? void 0 : S.id, d.nextCursor === void 0) break;
|
|
41
|
+
o = d.nextCursor;
|
|
42
|
+
}
|
|
43
|
+
if (a === void 0) return { items: [], more: !1 };
|
|
44
|
+
y.set(r, a);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const o = await e.dataStores.entries.list(a, {
|
|
48
|
+
project: n,
|
|
49
|
+
prefix: s.prefix,
|
|
50
|
+
limit: s.limit,
|
|
51
|
+
signal: s.signal
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
items: o.items.map((c) => ({ key: c.key, value: c.value, updatedAt: c.updatedAt })),
|
|
55
|
+
more: o.nextCursor !== void 0
|
|
56
|
+
};
|
|
57
|
+
} catch (o) {
|
|
58
|
+
throw y.delete(r), o;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function F(e) {
|
|
62
|
+
const n = i();
|
|
63
|
+
return m({
|
|
64
|
+
queryKey: K(e),
|
|
65
|
+
queryFn: () => q(n, e),
|
|
66
|
+
enabled: e != null
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function j(e, n) {
|
|
70
|
+
const t = i();
|
|
71
|
+
return m({
|
|
72
|
+
queryKey: Q(e, n),
|
|
73
|
+
queryFn: () => t.dataStores.get(e, { project: n }),
|
|
74
|
+
enabled: n != null
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function k(e, n, t) {
|
|
78
|
+
const s = i();
|
|
79
|
+
return C({
|
|
80
|
+
queryKey: x(e, n, t),
|
|
81
|
+
queryFn: ({ pageParam: r }) => s.dataStores.entries.list(e, {
|
|
82
|
+
project: n,
|
|
83
|
+
prefix: t === "" ? void 0 : t,
|
|
84
|
+
cursor: r
|
|
85
|
+
}),
|
|
86
|
+
initialPageParam: void 0,
|
|
87
|
+
getNextPageParam: (r) => r.nextCursor,
|
|
88
|
+
enabled: n != null
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function A(e, n, t, s) {
|
|
92
|
+
return e.dataStores.entries.get(n, t, { project: s });
|
|
93
|
+
}
|
|
94
|
+
function w() {
|
|
95
|
+
const e = i(), n = l();
|
|
96
|
+
return u({
|
|
97
|
+
mutationFn: (t) => e.dataStores.create(t.input, { project: t.project }),
|
|
98
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["data-stores"] })
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function b() {
|
|
102
|
+
const e = i(), n = l();
|
|
103
|
+
return u({
|
|
104
|
+
mutationFn: (t) => e.dataStores.archive(t.id, { project: t.project }),
|
|
105
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["data-stores"] })
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function h() {
|
|
109
|
+
const e = i(), n = l();
|
|
110
|
+
return u({
|
|
111
|
+
mutationFn: (t) => e.dataStores.entries.set(
|
|
112
|
+
t.id,
|
|
113
|
+
t.key,
|
|
114
|
+
{ value: t.value, ifVersion: t.ifVersion, ttlSeconds: t.ttlSeconds },
|
|
115
|
+
{ project: t.project }
|
|
116
|
+
),
|
|
117
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["data-stores"] })
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function P() {
|
|
121
|
+
const e = i(), n = l();
|
|
122
|
+
return u({
|
|
123
|
+
mutationFn: (t) => e.dataStores.entries.insert(t.id, t.row, {
|
|
124
|
+
project: t.project,
|
|
125
|
+
ttlSeconds: t.ttlSeconds
|
|
126
|
+
}),
|
|
127
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["data-stores"] })
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function _() {
|
|
131
|
+
const e = i(), n = l();
|
|
132
|
+
return u({
|
|
133
|
+
mutationFn: (t) => e.dataStores.entries.delete(t.id, t.key, { project: t.project }),
|
|
134
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["data-stores"] })
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function T() {
|
|
138
|
+
const e = i(), n = l();
|
|
139
|
+
return u({
|
|
140
|
+
mutationFn: (t) => e.dataStores.importCsv(t.id, t.csv, { project: t.project }),
|
|
141
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["data-stores"] })
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function G() {
|
|
145
|
+
const e = i();
|
|
146
|
+
return u({
|
|
147
|
+
mutationFn: (n) => e.dataStores.exportCsv(n.id, { project: n.project })
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
f as D,
|
|
152
|
+
Q as a,
|
|
153
|
+
K as b,
|
|
154
|
+
D as c,
|
|
155
|
+
x as d,
|
|
156
|
+
v as e,
|
|
157
|
+
w as f,
|
|
158
|
+
A as g,
|
|
159
|
+
j as h,
|
|
160
|
+
F as i,
|
|
161
|
+
_ as j,
|
|
162
|
+
k,
|
|
163
|
+
q as l,
|
|
164
|
+
G as m,
|
|
165
|
+
T as n,
|
|
166
|
+
P as o,
|
|
167
|
+
h as p,
|
|
168
|
+
b as u
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=data-stores-UeQvwVCa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-stores-UeQvwVCa.js","sources":["../src/repos/data-stores.ts"],"sourcesContent":["/**\n * The `data-stores` domain repo — wraps `@w6w/sdk`'s `client.dataStores.*` in react-query. The\n * repo never builds a request itself (no `client.request`, no `fetch`): every call is one SDK op,\n * and `project` is passed on every one of them (an omitted project would silently fall to the\n * account's default project).\n *\n * Every key starts with the bare `[\"data-stores\"]` prefix and every mutation invalidates that\n * prefix, so a write refreshes the list and any open store in whatever project it was cached\n * under. Reads are `enabled: projectId != null` and carry `projectId` in the key, so a render\n * before the project resolves never queries (or caches) the wrong project.\n *\n * Parsing, row building and conflict logic are `@w6w/ui`'s data-store util (E-2); this file only\n * moves data.\n */\nimport { useInfiniteQuery, useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type {\n DataStore,\n DataStoreCreateInput,\n DataStoreEntry,\n DataStoreEntryPage,\n DataStoreKind,\n W6WClient,\n} from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/** The most requests one \"walk every page\" read makes (200 stores a page). */\nexport const DATA_STORE_MAX_PAGES = 10;\nconst PAGE_LIMIT = 200;\n\n/** Query key for a project's store list. */\nexport function dataStoresKey(projectId?: string) {\n return [\"data-stores\", projectId, \"list\"] as const;\n}\n\n/** Query key for one store. */\nexport function dataStoreKey(id: string, projectId?: string) {\n return [\"data-stores\", projectId, \"detail\", id] as const;\n}\n\n/** Query key for one store's entries under a key prefix (`\"\"` = no filter). */\nexport function dataStoreEntriesKey(id: string, projectId: string | undefined, prefix: string) {\n return [\"data-stores\", projectId, \"entries\", id, prefix] as const;\n}\n\n/**\n * The project's stores, walked page by page (at most {@link DATA_STORE_MAX_PAGES} requests),\n * server order kept. Hook-less so the ui picker's `listDataStores` seam can call it too.\n */\nexport async function listAllDataStores(client: W6WClient, project: string): Promise<DataStore[]> {\n const out: DataStore[] = [];\n let cursor: string | undefined;\n for (let i = 0; i < DATA_STORE_MAX_PAGES; i++) {\n const page = await client.dataStores.list({ project, cursor, limit: PAGE_LIMIT });\n out.push(...page.items);\n if (page.nextCursor === undefined) break;\n cursor = page.nextCursor;\n }\n return out;\n}\n\n/** The picker's shape: store names and kinds only. */\nexport async function listDataStores(\n client: W6WClient,\n project: string,\n): Promise<{ name: string; kind: DataStoreKind }[]> {\n return (await listAllDataStores(client, project)).map((s) => ({ name: s.name, kind: s.kind }));\n}\n\n/** Store id by `project \\0 name`: a key picker's every keystroke must not re-walk the list. */\nconst storeIds = new Map<string, string>();\n\n/**\n * ONE page of the entries of the project's store named `store`, for the ui's `data-store-key`\n * picker (`W6WApi.listDataStoreEntries`): the name is resolved to its id (remembered), then\n * `prefix` is the host's server-side key search and `limit` caps the page. An unknown name is an\n * empty page; a failed entries read forgets the id (renamed or archived) and rethrows.\n */\nexport async function listDataStoreEntries(\n client: W6WClient,\n project: string,\n store: string,\n opts: { prefix?: string; limit?: number; signal?: AbortSignal } = {},\n): Promise<{ items: { key: string; value: unknown; updatedAt: string }[]; more: boolean }> {\n const memo = `${project}\\0${store}`;\n let id = storeIds.get(memo);\n if (id === undefined) {\n let cursor: string | undefined;\n for (let i = 0; i < DATA_STORE_MAX_PAGES && id === undefined; i++) {\n const page = await client.dataStores.list({\n project,\n cursor,\n limit: PAGE_LIMIT,\n signal: opts.signal,\n });\n id = page.items.find((s) => s.name === store)?.id;\n if (page.nextCursor === undefined) break;\n cursor = page.nextCursor;\n }\n if (id === undefined) return { items: [], more: false };\n storeIds.set(memo, id);\n }\n try {\n const page = await client.dataStores.entries.list(id, {\n project,\n prefix: opts.prefix,\n limit: opts.limit,\n signal: opts.signal,\n });\n return {\n items: page.items.map((e) => ({ key: e.key, value: e.value, updatedAt: e.updatedAt })),\n more: page.nextCursor !== undefined,\n };\n } catch (e) {\n storeIds.delete(memo);\n throw e;\n }\n}\n\nexport function useDataStoresQuery(projectId?: string) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: dataStoresKey(projectId),\n queryFn: () => listAllDataStores(client, projectId as string),\n enabled: projectId != null,\n });\n}\n\nexport function useDataStoreQuery(id: string, projectId?: string) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: dataStoreKey(id, projectId),\n queryFn: () => client.dataStores.get(id, { project: projectId }),\n enabled: projectId != null,\n });\n}\n\nexport function useEntriesQuery(id: string, projectId: string | undefined, prefix: string) {\n const client = useEmbedClient();\n return useInfiniteQuery({\n queryKey: dataStoreEntriesKey(id, projectId, prefix),\n queryFn: ({ pageParam }): Promise<DataStoreEntryPage> =>\n client.dataStores.entries.list(id, {\n project: projectId,\n prefix: prefix === \"\" ? undefined : prefix,\n cursor: pageParam,\n }),\n initialPageParam: undefined as string | undefined,\n getNextPageParam: (last) => last.nextCursor,\n enabled: projectId != null,\n });\n}\n\n/** One entry by key, read fresh (the conflict prompt's Reload). */\nexport function getEntry(\n client: W6WClient,\n id: string,\n key: string,\n project: string,\n): Promise<DataStoreEntry> {\n return client.dataStores.entries.get(id, key, { project });\n}\n\nexport function useCreateDataStoreMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { input: DataStoreCreateInput; project: string }) =>\n client.dataStores.create(vars.input, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"data-stores\"] }),\n });\n}\n\nexport function useArchiveDataStoreMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project: string }) =>\n client.dataStores.archive(vars.id, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"data-stores\"] }),\n });\n}\n\n/** `PUT` one entry. `ifVersion` is the optimistic-concurrency guard; `ttlSeconds` keeps an expiry. */\nexport function useSetEntryMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: {\n id: string;\n key: string;\n value: unknown;\n ifVersion?: number;\n ttlSeconds?: number;\n project: string;\n }) =>\n client.dataStores.entries.set(\n vars.id,\n vars.key,\n { value: vars.value, ifVersion: vars.ifVersion, ttlSeconds: vars.ttlSeconds },\n { project: vars.project },\n ),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"data-stores\"] }),\n });\n}\n\n/** `POST` one table row; the server generates the key. */\nexport function useInsertRowMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: {\n id: string;\n row: Record<string, unknown>;\n ttlSeconds?: number;\n project: string;\n }) =>\n client.dataStores.entries.insert(vars.id, vars.row, {\n project: vars.project,\n ttlSeconds: vars.ttlSeconds,\n }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"data-stores\"] }),\n });\n}\n\nexport function useDeleteEntryMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; key: string; project: string }) =>\n client.dataStores.entries.delete(vars.id, vars.key, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"data-stores\"] }),\n });\n}\n\n/** Import CSV text verbatim (`text/csv`). Resolves `{imported}`; a refusal throws an `ApiError`. */\nexport function useImportCsvMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; csv: string; project: string }) =>\n client.dataStores.importCsv(vars.id, vars.csv, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"data-stores\"] }),\n });\n}\n\n/** Export a table store as CSV text. Read-only: nothing is invalidated. */\nexport function useExportCsvMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (vars: { id: string; project: string }) =>\n client.dataStores.exportCsv(vars.id, { project: vars.project }),\n });\n}\n"],"names":["DATA_STORE_MAX_PAGES","PAGE_LIMIT","dataStoresKey","projectId","dataStoreKey","id","dataStoreEntriesKey","prefix","listAllDataStores","client","project","out","cursor","i","page","listDataStores","s","storeIds","listDataStoreEntries","store","opts","memo","_a","e","useDataStoresQuery","useEmbedClient","useQuery","useDataStoreQuery","useEntriesQuery","useInfiniteQuery","pageParam","last","getEntry","key","useCreateDataStoreMutation","qc","useQueryClient","useMutation","vars","useArchiveDataStoreMutation","useSetEntryMutation","useInsertRowMutation","useDeleteEntryMutation","useImportCsvMutation","useExportCsvMutation"],"mappings":";;AA0BO,MAAMA,IAAuB,IAC9BC,IAAa;AAGZ,SAASC,EAAcC,GAAoB;AAChD,SAAO,CAAC,eAAeA,GAAW,MAAM;AAC1C;AAGO,SAASC,EAAaC,GAAYF,GAAoB;AAC3D,SAAO,CAAC,eAAeA,GAAW,UAAUE,CAAE;AAChD;AAGO,SAASC,EAAoBD,GAAYF,GAA+BI,GAAgB;AAC7F,SAAO,CAAC,eAAeJ,GAAW,WAAWE,GAAIE,CAAM;AACzD;AAMA,eAAsBC,EAAkBC,GAAmBC,GAAuC;AAChG,QAAMC,IAAmB,CAAA;AACzB,MAAIC;AACJ,WAASC,IAAI,GAAGA,IAAIb,GAAsBa,KAAK;AAC7C,UAAMC,IAAO,MAAML,EAAO,WAAW,KAAK,EAAE,SAAAC,GAAS,QAAAE,GAAQ,OAAOX,GAAY;AAEhF,QADAU,EAAI,KAAK,GAAGG,EAAK,KAAK,GAClBA,EAAK,eAAe,OAAW;AACnC,IAAAF,IAASE,EAAK;AAAA,EAChB;AACA,SAAOH;AACT;AAGA,eAAsBI,EACpBN,GACAC,GACkD;AAClD,UAAQ,MAAMF,EAAkBC,GAAQC,CAAO,GAAG,IAAI,CAACM,OAAO,EAAE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,aAAa,EAAA,CAAG;AAAA,EAAA,CACpE;AACH;AAGO,SAASQ,IAAuB;AACrC,QAAMlC,IAASgB,EAAA,GACTU,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACC,MACX7B,EAAO,WAAW,UAAU6B,EAAK,IAAIA,EAAK,KAAK,EAAE,SAASA,EAAK,SAAS;AAAA,IAC1E,WAAW,MAAMH,EAAG,kBAAkB,EAAE,UAAU,CAAC,aAAa,EAAA,CAAG;AAAA,EAAA,CACpE;AACH;AAGO,SAASS,IAAuB;AACrC,QAAMnC,IAASgB,EAAA;AACf,SAAOY,EAAY;AAAA,IACjB,YAAY,CAACC,MACX7B,EAAO,WAAW,UAAU6B,EAAK,IAAI,EAAE,SAASA,EAAK,QAAA,CAAS;AAAA,EAAA,CACjE;AACH;"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { STATE_LIMITS as l } from "@w6w/expr";
|
|
2
|
+
import { parse as f } from "yaml";
|
|
3
|
+
const y = /* @__PURE__ */ new Set(["string", "number", "boolean", "object", "array"]);
|
|
4
|
+
function p(e) {
|
|
5
|
+
if (!Array.isArray(e)) return [];
|
|
6
|
+
const n = [];
|
|
7
|
+
for (const t of e) {
|
|
8
|
+
if (typeof t != "object" || t === null || Array.isArray(t)) continue;
|
|
9
|
+
const r = t, o = { key: typeof r.key == "string" ? r.key : "" };
|
|
10
|
+
typeof r.type == "string" && y.has(r.type) && (o.type = r.type), typeof r.required == "boolean" && (o.required = r.required), r.default !== void 0 && (o.default = r.default), n.push(o);
|
|
11
|
+
}
|
|
12
|
+
return n;
|
|
13
|
+
}
|
|
14
|
+
function m(e) {
|
|
15
|
+
if (e.length !== 0)
|
|
16
|
+
return e.map((n) => {
|
|
17
|
+
const t = { key: n.key };
|
|
18
|
+
return n.type !== void 0 && (t.type = n.type), n.required && (t.required = !0), n.default !== void 0 && (t.default = n.default), t;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function h(e) {
|
|
22
|
+
const n = /* @__PURE__ */ new Set(), t = [];
|
|
23
|
+
return e.forEach((r, o) => {
|
|
24
|
+
n.has(r.key) ? t.push(o) : n.add(r.key);
|
|
25
|
+
}), t;
|
|
26
|
+
}
|
|
27
|
+
function b(e, n, t) {
|
|
28
|
+
const r = /* @__PURE__ */ new Set(), o = [];
|
|
29
|
+
for (const i of [...e.slice(0, n).map((s) => s.key), ...t])
|
|
30
|
+
i === "" || r.has(i) || (r.add(i), o.push(i));
|
|
31
|
+
return o;
|
|
32
|
+
}
|
|
33
|
+
function c(e) {
|
|
34
|
+
return typeof e == "object" && e !== null && !Array.isArray(e) && e.type === "expr" && Array.isArray(e.parts);
|
|
35
|
+
}
|
|
36
|
+
function v(e) {
|
|
37
|
+
const n = [], t = [];
|
|
38
|
+
for (const r of e)
|
|
39
|
+
if (r.key.trim() !== "") {
|
|
40
|
+
if (c(r.default)) {
|
|
41
|
+
n.push({ key: r.key, type: r.type, required: !1 }), t.push(r.key);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
n.push({ key: r.key, type: r.type, default: r.default, required: r.required });
|
|
45
|
+
}
|
|
46
|
+
return { fields: n, computed: t };
|
|
47
|
+
}
|
|
48
|
+
function a(e) {
|
|
49
|
+
return e !== null && typeof e == "object" && !Array.isArray(e);
|
|
50
|
+
}
|
|
51
|
+
function A(e) {
|
|
52
|
+
return a(e) ? e : void 0;
|
|
53
|
+
}
|
|
54
|
+
function S(e) {
|
|
55
|
+
if (e.trim() === "") return { ok: !0, value: void 0 };
|
|
56
|
+
let n;
|
|
57
|
+
try {
|
|
58
|
+
n = JSON.parse(e);
|
|
59
|
+
} catch {
|
|
60
|
+
return { ok: !1, reason: "invalid_json" };
|
|
61
|
+
}
|
|
62
|
+
return a(n) ? JSON.stringify(n).length > l.initialChars ? { ok: !1, reason: "too_large" } : Object.keys(n).length === 0 ? { ok: !0, value: void 0 } : { ok: !0, value: n } : { ok: !1, reason: "not_object" };
|
|
63
|
+
}
|
|
64
|
+
function j(e, n) {
|
|
65
|
+
if (!e) return [];
|
|
66
|
+
const t = [];
|
|
67
|
+
for (const r of n)
|
|
68
|
+
r.key === "" || t.includes(r.key) || Object.hasOwn(e, r.key) && t.push(r.key);
|
|
69
|
+
return t;
|
|
70
|
+
}
|
|
71
|
+
function w(e) {
|
|
72
|
+
if (!e) return !1;
|
|
73
|
+
switch (e.kind) {
|
|
74
|
+
case "function":
|
|
75
|
+
case "endpoint":
|
|
76
|
+
case "workflow":
|
|
77
|
+
return !0;
|
|
78
|
+
// A bare connection has no snippet; only the action page (which names one) does.
|
|
79
|
+
case "connection":
|
|
80
|
+
return !!e.action;
|
|
81
|
+
default:
|
|
82
|
+
return !1;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function g(e) {
|
|
86
|
+
if (!e) return null;
|
|
87
|
+
switch (e.kind) {
|
|
88
|
+
case "function":
|
|
89
|
+
return { kind: "function", id: e.id, key: e.key, inputs: e.inputs, alias: e.alias };
|
|
90
|
+
case "endpoint":
|
|
91
|
+
return {
|
|
92
|
+
kind: "endpoint",
|
|
93
|
+
id: e.id,
|
|
94
|
+
key: e.key,
|
|
95
|
+
invokeUrl: e.invokeUrl,
|
|
96
|
+
invokeUrlByKey: e.invokeUrlByKey,
|
|
97
|
+
urlForm: e.urlForm,
|
|
98
|
+
alias: e.alias,
|
|
99
|
+
inputs: e.inputs
|
|
100
|
+
};
|
|
101
|
+
case "workflow":
|
|
102
|
+
return { kind: "workflow", id: e.id, displayName: e.label, key: e.key };
|
|
103
|
+
case "connection":
|
|
104
|
+
return e.action ? { kind: "connection", id: e.id, action: e.action, params: e.params } : null;
|
|
105
|
+
default:
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function O({
|
|
110
|
+
resource: e,
|
|
111
|
+
target: n,
|
|
112
|
+
hasAdapter: t
|
|
113
|
+
}) {
|
|
114
|
+
return (n.kind === "function" || n.kind === "workflow") && n.kind === e.kind && n.id === e.id ? t ? "warn" : "block" : "allow";
|
|
115
|
+
}
|
|
116
|
+
function u(e) {
|
|
117
|
+
let n;
|
|
118
|
+
if (e.format === "json")
|
|
119
|
+
try {
|
|
120
|
+
n = JSON.parse(e.content);
|
|
121
|
+
} catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
else if (e.format === "yaml")
|
|
125
|
+
try {
|
|
126
|
+
n = f(e.content);
|
|
127
|
+
} catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
else
|
|
131
|
+
return null;
|
|
132
|
+
return typeof n != "object" || n === null || Array.isArray(n) ? null : n;
|
|
133
|
+
}
|
|
134
|
+
function q(e) {
|
|
135
|
+
return e.map((n) => {
|
|
136
|
+
const t = u(n);
|
|
137
|
+
if (!t) return { key: n.key };
|
|
138
|
+
const r = Object.keys(t);
|
|
139
|
+
return r.length > 0 ? { key: n.key, fields: r.map((o) => ({ key: o })) } : { key: n.key };
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function F(e) {
|
|
143
|
+
const n = {};
|
|
144
|
+
for (const t of e) {
|
|
145
|
+
n[`documents.${t.key}`] = t.content;
|
|
146
|
+
const r = u(t);
|
|
147
|
+
if (r)
|
|
148
|
+
for (const [o, i] of Object.entries(r))
|
|
149
|
+
n[`documents.${t.key}.${o}`] = i;
|
|
150
|
+
}
|
|
151
|
+
return n;
|
|
152
|
+
}
|
|
153
|
+
export {
|
|
154
|
+
h as a,
|
|
155
|
+
c as b,
|
|
156
|
+
p as c,
|
|
157
|
+
F as d,
|
|
158
|
+
O as e,
|
|
159
|
+
v as f,
|
|
160
|
+
S as g,
|
|
161
|
+
b as h,
|
|
162
|
+
w as i,
|
|
163
|
+
q as p,
|
|
164
|
+
A as r,
|
|
165
|
+
j as s,
|
|
166
|
+
g as t,
|
|
167
|
+
m as v
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=document-sources-DNmBojx6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-sources-DNmBojx6.js","sources":["../src/lib/workflow-variables.ts","../src/lib/starting-data.ts","../src/lib/code-rail.ts","../src/lib/error-handler-self.ts","../src/lib/document-sources.ts"],"sourcesContent":["/**\n * The pure decisions behind a workflow's `variables` list (T1.1.5) — the\n * Variables tab's authoring surface and the run page's generated-form\n * projection. `variables` rides inside the workflow **definition**\n * (`w6w-workflow/packages/types/mod.ts:170`), the same JSON document that\n * already carries `steps`, so there is no column, no migration and no server\n * change behind it.\n *\n * Pure, React-free, `.ts`, **no value import of `@w6w/ui`** — studio's\n * `test:unit` is a bare `node --test` with no jsx loader\n * (`studio/package.json:17`), so a value import of the barrel (which\n * re-exports `.tsx`) kills the test. Same shape as `workflow-settings.ts`'s\n * reader/writer discipline and `input-seeding.ts`'s pure-module docstring\n * rule.\n *\n * The row type is defined **locally**, structurally identical to\n * `WorkflowVariable` (`w6w-workflow/packages/types/mod.ts:40-45`: `key`,\n * `type?`, `required?`, `default?`), so no cast is needed at the `.tsx`\n * boundary in either direction.\n */\n\n/** One row of a workflow's declared `variables` list. */\nexport interface WorkflowVariableRow {\n key: string;\n type?: \"string\" | \"number\" | \"boolean\" | \"object\" | \"array\";\n required?: boolean;\n default?: unknown;\n}\n\n/** The declared type union `WorkflowVariable.type` accepts. */\nconst VARIABLE_TYPES = new Set([\"string\", \"number\", \"boolean\", \"object\", \"array\"]);\n\n/**\n * Read a workflow definition's `variables` field as an array of rows.\n *\n * Takes `unknown` because the source is `JSON.parse`d and the `</>` editor\n * lets an author type anything: a non-array reads as no variables, and a\n * non-object array entry is dropped rather than crashing the tab. **Never\n * sorts, never de-dups, never re-orders** — declaration order *is*\n * resolution order (D-5) and `resolveVariables` iterates the array in order\n * (`w6w-workflow/packages/engine/src/run.ts:70-83`), so two rows sharing a\n * key both survive, in the order they were declared.\n */\nexport function readVariables(raw: unknown): WorkflowVariableRow[] {\n if (!Array.isArray(raw)) return [];\n const out: WorkflowVariableRow[] = [];\n for (const entry of raw) {\n if (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) continue;\n const e = entry as Record<string, unknown>;\n const row: WorkflowVariableRow = { key: typeof e.key === \"string\" ? e.key : \"\" };\n if (typeof e.type === \"string\" && VARIABLE_TYPES.has(e.type)) {\n row.type = e.type as WorkflowVariableRow[\"type\"];\n }\n if (typeof e.required === \"boolean\") row.required = e.required;\n if (e.default !== undefined) row.default = e.default;\n out.push(row);\n }\n return out;\n}\n\n/**\n * The rows ready to write back into the definition's `variables` field.\n *\n * Mirrors `workflow-settings.ts`'s \"default written as absent\" rule, but here\n * it applies to a row's **optional flags, not the value**: `required` is\n * omitted when `false` and `type` is omitted when unset, so opening the tab\n * and touching nothing does not rewrite a legacy definition into\n * `{required:false,type:undefined}` rows. `default` is user data and is kept\n * **verbatim** — including `false`, `0`, `\"\"` and `null` — never dropped as\n * an optimisation (a \"drop falsy\" implementation would lose a `false`\n * default, which is exactly the case the tests pin).\n *\n * Returns `undefined` for an empty array (never `[]`) so the caller\n * (`patchMeta`, via `JSON.stringify`) drops the key entirely — which matters\n * beyond hygiene here: `draftFromWorkflowVariables`\n * (`server/packages/api/mcp/tool-schema.ts:310-326`) treats `undefined` and\n * `length === 0` identically (pass-through), so `[]` and absent already agree\n * on the wire; this just keeps the definition itself from growing an empty\n * `\"variables\": []` on the first open of the tab.\n */\nexport function variablesForSave(rows: WorkflowVariableRow[]): WorkflowVariableRow[] | undefined {\n if (rows.length === 0) return undefined;\n return rows.map((r) => {\n const out: WorkflowVariableRow = { key: r.key };\n if (r.type !== undefined) out.type = r.type;\n if (r.required) out.required = true;\n if (r.default !== undefined) out.default = r.default;\n return out;\n });\n}\n\n/**\n * Every index whose `key` repeats an earlier row's key. `resolveVariables`\n * writes `vars[v.key]` in a loop with no duplicate check (`run.ts:74-80`), so\n * a later row silently wins — this is informational only (the tab marks the\n * row; nothing here blocks a save), never de-duping or rejecting.\n */\nexport function duplicateKeyIndexes(rows: WorkflowVariableRow[]): number[] {\n const seen = new Set<string>();\n const out: number[] = [];\n rows.forEach((r, i) => {\n if (seen.has(r.key)) out.push(i);\n else seen.add(r.key);\n });\n return out;\n}\n\n/**\n * The `var.*` names to offer row `index`'s expression rail: the keys of\n * rows **strictly above** it, then `projectVars`, deduped, with blanks\n * dropped. Declaration order is resolution order (D-5), so a row can only\n * reference a variable declared earlier than itself — offering a row at or\n * below `index` would suggest a forward reference the engine rejects\n * (T2.1.1). This is the offered rail only; it is not validation.\n */\nexport function varsRailFor(\n rows: WorkflowVariableRow[],\n index: number,\n projectVars: string[],\n): string[] {\n const seen = new Set<string>();\n const out: string[] = [];\n for (const k of [...rows.slice(0, index).map((r) => r.key), ...projectVars]) {\n if (k === \"\" || seen.has(k)) continue;\n seen.add(k);\n out.push(k);\n }\n return out;\n}\n\n/** `true` if `v` is an `ExprValue` envelope — the two-key check `@w6w/ui`'s\n * `isExprValue` (`ui/src/types.ts:301-309`) makes, re-implemented locally\n * because this module cannot import `@w6w/ui` at value level (see the\n * module docstring). Mirrors `trigger-preview.ts:102-119`'s sanctioned\n * pattern for the same constraint — this is not duplication. */\nexport function isExprDefault(v: unknown): boolean {\n return (\n typeof v === \"object\" &&\n v !== null &&\n !Array.isArray(v) &&\n (v as { type?: unknown }).type === \"expr\" &&\n Array.isArray((v as { parts?: unknown }).parts)\n );\n}\n\n/** One field the run page's generated form fills — structurally assignable\n * to `@w6w/ui/flow`'s `TriggerFieldDef` (all fields optional) with no cast. */\nexport interface RunFormField {\n key: string;\n type?: WorkflowVariableRow[\"type\"];\n default?: unknown;\n required?: boolean;\n}\n\n/**\n * Project a workflow's declared variables into the run page's form fields.\n *\n * A row whose `default` is an `ExprValue` envelope is a server-side\n * computation (its value is resolved at run time, not authored on the\n * client), so it is emitted with **`default` dropped and `required: false`**\n * — never as a value `ui`'s `seedValues` would `String(...)` the envelope\n * into — and its key is listed in `computed` so the host can label the field\n * \"computed at run time\" and post nothing for it. A row with a blank/missing\n * key is dropped, mirroring `@w6w/ui`'s `fieldsToParams`, which does the same\n * before turning field definitions into a fillable form.\n */\nexport function runFormFields(rows: WorkflowVariableRow[]): {\n fields: RunFormField[];\n computed: string[];\n} {\n const fields: RunFormField[] = [];\n const computed: string[] = [];\n for (const r of rows) {\n if (r.key.trim() === \"\") continue;\n if (isExprDefault(r.default)) {\n fields.push({ key: r.key, type: r.type, required: false });\n computed.push(r.key);\n continue;\n }\n fields.push({ key: r.key, type: r.type, default: r.default, required: r.required });\n }\n return { fields, computed };\n}\n","/**\n * The pure decisions behind a workflow's **Starting data** (`Workflow.initialState`,\n * core/rfcs/workflow.md; ruling R8): a literal JSON object that seeds the run's\n * state tree. It rides inside the workflow definition as a top-level key, the\n * same way `variables` does, so the Settings tab only reads and writes that key.\n *\n * Seed layering (R2', later wins): project variables → starting data → the\n * workflow's own / the caller's variables.\n *\n * Pure, React-free, `.ts`, **no value import of `@w6w/ui`** — the same header\n * rule as `workflow-variables.ts` (studio's `test:unit` has no jsx loader).\n */\nimport { STATE_LIMITS } from \"@w6w/expr\";\nimport type { WorkflowVariableRow } from \"./workflow-variables.ts\";\n\n/** Why a Starting data draft cannot be saved. */\nexport type StartingDataProblem = \"invalid_json\" | \"not_object\" | \"too_large\";\n\n/** The outcome of reading a Starting data draft for save. `value: undefined` drops the key. */\nexport type StartingDataForSave =\n | { ok: true; value: Record<string, unknown> | undefined }\n | { ok: false; reason: StartingDataProblem };\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return v !== null && typeof v === \"object\" && !Array.isArray(v);\n}\n\n/**\n * Read a definition's `initialState` field. Takes `unknown` because the source is\n * `JSON.parse`d and the `</>` editor lets an author type anything: only a plain\n * object counts; anything else reads as \"no starting data\".\n */\nexport function readStartingData(raw: unknown): Record<string, unknown> | undefined {\n return isPlainObject(raw) ? raw : undefined;\n}\n\n/**\n * Turn the tab's JSON text into the value `patchMeta({ initialState })` saves.\n * Blank text and `{}` both mean \"no starting data\" (`value: undefined`, so the\n * key is dropped from the definition). Anything but a plain object is refused,\n * as is an object whose serialised form exceeds `STATE_LIMITS.initialChars`\n * (measured exactly as the server measures it: `JSON.stringify(v).length`).\n */\nexport function startingDataForSave(text: string): StartingDataForSave {\n if (text.trim() === \"\") return { ok: true, value: undefined };\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n return { ok: false, reason: \"invalid_json\" };\n }\n if (!isPlainObject(parsed)) return { ok: false, reason: \"not_object\" };\n if (JSON.stringify(parsed).length > STATE_LIMITS.initialChars) {\n return { ok: false, reason: \"too_large\" };\n }\n if (Object.keys(parsed).length === 0) return { ok: true, value: undefined };\n return { ok: true, value: parsed };\n}\n\n/**\n * The declared variable keys that are also top-level keys of the starting data —\n * on those keys the variable's value wins (R2'). Variable declaration order, no\n * duplicates, no empty keys.\n */\nexport function startingDataCollisions(\n initial: Record<string, unknown> | undefined,\n variables: readonly WorkflowVariableRow[],\n): string[] {\n if (!initial) return [];\n const out: string[] = [];\n for (const v of variables) {\n if (v.key === \"\" || out.includes(v.key)) continue;\n if (Object.hasOwn(initial, v.key)) out.push(v.key);\n }\n return out;\n}\n","/**\n * Pure decisions behind the right rail's Code tool (`src/ui/rail/CodeTool.tsx`).\n * Split out so `node --test` can gate them directly — mirrors\n * `src/lib/alias-rail.ts`'s own reason for existing: `node --test` throws\n * `ERR_UNKNOWN_FILE_EXTENSION` on any `@w6w/ui`-adjacent import, and\n * `src/ui/workspace.tsx` sits one hop from that barrel through `Layout.tsx`'s\n * import graph. So this module declares its own structural mirror of\n * `WorkspaceCallable` instead of importing it.\n */\nimport type { SnippetCallable, SnippetInput } from \"./sdk-snippets.ts\";\n\n/** Structural mirror of T2.1.2's widened `WorkspaceCallable` (`src/ui/workspace.tsx`). */\nexport type RailCallable =\n | { kind: \"function\"; id: string; key?: string; inputs?: readonly SnippetInput[]; alias?: string }\n | {\n kind: \"endpoint\";\n id: string;\n key?: string;\n invokeUrl?: string;\n invokeUrlByKey?: string;\n urlForm?: \"id\" | \"key\";\n alias?: string;\n inputs?: readonly SnippetInput[];\n }\n | { kind: \"workflow\"; id: string; label?: string; key?: string }\n | { kind: \"connection\"; id: string; action?: string; params?: readonly SnippetInput[] }\n | null;\n\n/**\n * Is a \"Call from code\" panel meaningful for this context? Mirrors\n * `alias-rail.ts`'s `targetForCallable` fail-closed shape exactly (its own\n * comment: *\"'connection' and no resource at all both fail closed to null —\n * house style\"*) — a bare `\"connection\"` (no `action`) and `null` both answer `false`.\n */\nexport function isAvailable(ctx: RailCallable): boolean {\n if (!ctx) return false;\n switch (ctx.kind) {\n case \"function\":\n case \"endpoint\":\n case \"workflow\":\n return true;\n // A bare connection has no snippet; only the action page (which names one) does.\n case \"connection\":\n return !!ctx.action;\n default:\n return false;\n }\n}\n\n/**\n * The widened-union -> `SnippetCallable` conversion `CodeTool.Panel` hands to\n * `CallFromCodeBody`. `null` for a context this tool has no snippet for\n * (a connection without an `action`, or no resource at all) — defensive, since `isAvailable`\n * already keeps the tool off the strip for those.\n *\n * The one easy-to-miss field: `WorkspaceCallable`'s `label` maps to\n * `SnippetCallable`'s `workflow` arm's `displayName` — NOT the same field\n * name. A naive `{...ctx}` spread compiles (both optional) but silently\n * drops the label everywhere it matters, never caught by `tsc`.\n */\nexport function toSnippetCallable(ctx: RailCallable): SnippetCallable | null {\n if (!ctx) return null;\n switch (ctx.kind) {\n case \"function\":\n return { kind: \"function\", id: ctx.id, key: ctx.key, inputs: ctx.inputs, alias: ctx.alias };\n case \"endpoint\":\n return {\n kind: \"endpoint\",\n id: ctx.id,\n key: ctx.key,\n invokeUrl: ctx.invokeUrl,\n invokeUrlByKey: ctx.invokeUrlByKey,\n urlForm: ctx.urlForm,\n alias: ctx.alias,\n inputs: ctx.inputs,\n };\n case \"workflow\":\n return { kind: \"workflow\", id: ctx.id, displayName: ctx.label, key: ctx.key };\n case \"connection\":\n return ctx.action\n ? { kind: \"connection\", id: ctx.id, action: ctx.action, params: ctx.params }\n : null;\n default:\n return null;\n }\n}\n","/**\n * The authoring-time half of the error-handler recursion guard. The server\n * compares resolved values at dispatch time; this small, pure decision keeps\n * the rail from creating the known-identical no-adapter case in the first\n * place without losing an adapter imported or authored elsewhere.\n */\nexport type ErrorHandlerSelfDecision = \"allow\" | \"warn\" | \"block\";\n\nexport interface ErrorHandlerSelfInput {\n resource: { kind: string; id: string };\n target: { kind: string; id: string };\n hasAdapter: boolean;\n}\n\n/**\n * Only Function and Workflow targets can re-enter the currently edited\n * resource. Actions are always allowed. A self-target with no adapter passes\n * the failed input through unchanged, so it is refused; an adapter is kept\n * and called out because only the runtime can determine its resolved values.\n */\nexport function errorHandlerSelfDecision({\n resource,\n target,\n hasAdapter,\n}: ErrorHandlerSelfInput): ErrorHandlerSelfDecision {\n const selfTarget =\n (target.kind === \"function\" || target.kind === \"workflow\") &&\n target.kind === resource.kind &&\n target.id === resource.id;\n if (!selfTarget) return \"allow\";\n return hasAdapter ? \"warn\" : \"block\";\n}\n","/**\n * Pure `Doc[]` → `ExpressionOptions` projections for the ƒx picker's\n * Documents group — extracted out of `ExpressionScope.tsx` so studio's\n * Node-native `test:unit` runner (globbed to `src/lib/__tests__/`,\n * `src/api/__tests__/` and `src/repos/__tests__/` only — `.ai/PLANNER.md`\n * fact 10) can reach it. No React, no import from `src/ui/` — `@w6w/ui`'s\n * `ExpressionDocumentSource` interface is not imported either (it is not\n * exported from `@w6w/ui`'s barrel, D-P3): the object literals returned below\n * are structurally identical to it, so TypeScript carries the shape without a\n * type import.\n *\n * ## The gate — mirrors the engine's own, bit-for-bit\n *\n * A document contributes field data **iff**: `doc.format === \"json\"` AND\n * `JSON.parse(doc.content)` succeeds into a plain object, OR\n * `doc.format === \"yaml\"` AND npm `yaml`'s `parse(doc.content)` succeeds into\n * a plain object — where *plain object* means\n * `typeof v === \"object\" && v !== null && !Array.isArray(v)`. This mirrors\n * the engine's own gate (`documentsSeed` /\n * `packages/server/packages/api/run-seed.ts`, read-only, out of scope)\n * bit-for-bit for each format: `format === \"json\"` or `format === \"yaml\"`,\n * then a `try/catch` parse, falling back to the raw content string on either\n * a non-matching format or a throw. Reproduced here so the picker never\n * offers a ref the run scope itself would refuse to resolve\n * (`render_ref_unresolved`) — `text`/`markdown`/`html` documents, and a\n * `json`/`yaml` document whose parse throws or yields a non-plain-object, are\n * excluded.\n *\n * The two parsers are not identical for every input — `@std/yaml` (server,\n * `{ schema: \"core\" }`) and npm `yaml` (here) diverge on tab-indented content\n * and on an unresolvable custom tag (`!!js/function`), both accepted, tested\n * debt (D-3). Every other input, including a plain JSON object (JSON is a\n * subset of YAML), agrees between the two.\n *\n * Field keys are enumerated RAW and UNFILTERED by {@link projectDocumentSources}\n * — arbitrary user-authored JSON keys (which can contain `.`/`{`/`}`/\n * whitespace) reach the modal; `isRefSafeKey` filters them exactly once, at\n * the modal's render site (`ExpressionEditorModal.tsx`), never here\n * (`building-blocks.md`: \"enumerate raw at the source, filter once at the\n * single render site\").\n */\nimport type { Doc } from \"@w6w/sdk\";\nimport { parse as parseYaml } from \"yaml\";\n\n/** One document's contribution to `ExpressionOptions.documents` — structurally\n * identical to `@w6w/ui`'s (unexported) `ExpressionDocumentSource`. */\nexport interface DocumentSource {\n key: string;\n fields?: { key: string }[];\n}\n\n/**\n * `doc`'s parsed content when the gate holds, else `null`. The one place both\n * functions below apply the gate, so they cannot silently disagree on it.\n */\nfunction gatedFields(doc: Doc): Record<string, unknown> | null {\n let parsed: unknown;\n if (doc.format === \"json\") {\n try {\n parsed = JSON.parse(doc.content);\n } catch {\n return null;\n }\n } else if (doc.format === \"yaml\") {\n try {\n parsed = parseYaml(doc.content);\n } catch {\n return null;\n }\n } else {\n return null;\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return null;\n return parsed as Record<string, unknown>;\n}\n\n/**\n * The `ExpressionOptions.documents` array: `{ key }` for every document, plus\n * `fields` (raw, unfiltered top-level keys) when the gate holds AND the\n * parsed object has at least one key. `fields` is OMITTED (not `[]`) both\n * when the gate fails and when it holds but yields zero keys — a consumer\n * must be able to tell \"nothing declared\" from \"declared none\".\n */\nexport function projectDocumentSources(docs: Doc[]): DocumentSource[] {\n return docs.map((d) => {\n const parsed = gatedFields(d);\n if (!parsed) return { key: d.key };\n const keys = Object.keys(parsed);\n return keys.length > 0 ? { key: d.key, fields: keys.map((key) => ({ key })) } : { key: d.key };\n });\n}\n\n/**\n * The `sampleValues` entries the ƒx Result preview substitutes for document\n * refs: `documents.<key>` → the document's raw content, for every document\n * (unconditional, exactly as before this project), PLUS `documents.<key>.<field>`\n * → the field's own parsed value, for the gated set only. Without the second\n * half, every field ref this project newly makes pickable would preview as\n * the empty string (`renderResult` does an exact flat-key lookup).\n */\nexport function documentSampleValues(docs: Doc[]): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const d of docs) {\n out[`documents.${d.key}`] = d.content;\n const parsed = gatedFields(d);\n if (!parsed) continue;\n for (const [key, value] of Object.entries(parsed)) {\n out[`documents.${d.key}.${key}`] = value;\n }\n }\n return out;\n}\n"],"names":["VARIABLE_TYPES","readVariables","raw","out","entry","e","row","variablesForSave","rows","r","duplicateKeyIndexes","seen","i","varsRailFor","index","projectVars","k","isExprDefault","v","runFormFields","fields","computed","isPlainObject","readStartingData","startingDataForSave","text","parsed","STATE_LIMITS","startingDataCollisions","initial","variables","isAvailable","ctx","toSnippetCallable","errorHandlerSelfDecision","resource","target","hasAdapter","gatedFields","doc","parseYaml","projectDocumentSources","docs","d","keys","key","documentSampleValues","value"],"mappings":";;AA8BA,MAAMA,wBAAqB,IAAI,CAAC,UAAU,UAAU,WAAW,UAAU,OAAO,CAAC;AAa1E,SAASC,EAAcC,GAAqC;AACjE,MAAI,CAAC,MAAM,QAAQA,CAAG,UAAU,CAAA;AAChC,QAAMC,IAA6B,CAAA;AACnC,aAAWC,KAASF,GAAK;AACvB,QAAI,OAAOE,KAAU,YAAYA,MAAU,QAAQ,MAAM,QAAQA,CAAK,EAAG;AACzE,UAAMC,IAAID,GACJE,IAA2B,EAAE,KAAK,OAAOD,EAAE,OAAQ,WAAWA,EA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@@ -63,5 +63,7 @@ export interface WorkflowDraft {
|
|
|
63
63
|
commit(next: string): Promise<FlushOutcome>;
|
|
64
64
|
/** 409 recovery: GET, replace the buffer and token, clear `stale`. */
|
|
65
65
|
reload(): Promise<void>;
|
|
66
|
+
/** Stop pending saves, drain an in-flight save, replace the server draft, then reload. */
|
|
67
|
+
discardThen(action: () => Promise<unknown>): Promise<void>;
|
|
66
68
|
}
|
|
67
69
|
export declare function useWorkflowDraft(o: UseWorkflowDraftOptions): WorkflowDraft;
|
package/dist/draft.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { A as a, c as s, i as t, n as o, r as i, u } from "./use-workflow-draft-
|
|
2
|
+
import { A as a, c as s, i as t, n as o, r as i, u } from "./use-workflow-draft-l3P5KZzw.js";
|
|
3
3
|
import { E as n, u as l } from "./client-context-CX61Bgw-.js";
|
|
4
4
|
import { D as E, c, u as d } from "./draft-registry-YF0tqNN0.js";
|
|
5
|
-
import { u as p, a as x, b as S } from "./use-callable-draft-
|
|
5
|
+
import { u as p, a as x, b as S } from "./use-callable-draft-DCauHt5o.js";
|
|
6
6
|
export {
|
|
7
7
|
a as AUTOSAVE_DEBOUNCE_MS,
|
|
8
8
|
E as DraftRegistryProvider,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** Immediate, keyboard-accessible publish help; no native title delay. */
|
|
3
|
+
export declare function PublishTooltip({ message, disabled, children, }: {
|
|
4
|
+
message: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
children: (descriptionId: string) => ReactNode;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface SetupIncompleteBannerProps {
|
|
2
|
+
/** Node id -> what is missing there (the detector's output). */
|
|
3
|
+
problems: Record<string, string[]>;
|
|
4
|
+
/** Node id -> display label; falls back to the id. */
|
|
5
|
+
nodeLabel?: (nodeId: string) => string;
|
|
6
|
+
}
|
|
7
|
+
/** Non-blocking "Setup incomplete" banner; renders nothing when no node has a problem. */
|
|
8
|
+
export declare function SetupIncompleteBanner(props: SetupIncompleteBannerProps): import('react').DetailedReactHTMLElement<{
|
|
9
|
+
role: "status";
|
|
10
|
+
className: string;
|
|
11
|
+
"data-testid": string;
|
|
12
|
+
}, HTMLElement> | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one editor for a workflow's starting state (`Workflow.initialState`), opened from the
|
|
3
|
+
* rail's State tool (`rail/StartingStateTool.tsx`) and from Settings → Starting data: the expression manager in its
|
|
4
|
+
* starting-state mode. Its `{{ }}` references are resolved once when a run starts, before any
|
|
5
|
+
* step, so the rail has no Previous steps or State section, and no Secrets (a secret never
|
|
6
|
+
* enters state). A click inserts a reference or, with "Value", the source's current value. Save
|
|
7
|
+
* goes through `startingDataForSave` and `validateInitialState` (the server's own check); `{}`
|
|
8
|
+
* or empty drops the key.
|
|
9
|
+
*/
|
|
10
|
+
export declare function StartingStateModal(props: {
|
|
11
|
+
initialState: Record<string, unknown> | undefined;
|
|
12
|
+
onChange: (next: Record<string, unknown> | undefined) => void;
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
@@ -5,13 +5,18 @@ import { WorkflowVariableRow } from '../lib/index.ts';
|
|
|
5
5
|
* Both General flags are on unless the workflow says otherwise and persist
|
|
6
6
|
* immediately (`saveMeta`, via `onChange`); every Variables edit instead goes
|
|
7
7
|
* through the auto-saver (`onVariablesChange` → `patchMeta`, never an
|
|
8
|
-
* immediate save — see the module docstring's Save path decision).
|
|
8
|
+
* immediate save — see the module docstring's Save path decision). The
|
|
9
|
+
* Starting data tab (`Workflow.initialState`, the state tree's seed) shows what
|
|
10
|
+
* is set and how it layers with variables; its editor is the one the rail's
|
|
11
|
+
* State tool opens (`StartingStateModal`), reached through `onEditStartingData`.
|
|
9
12
|
*/
|
|
10
13
|
export declare function WorkflowSettingsModal(props: {
|
|
11
14
|
autoSave: boolean;
|
|
12
15
|
savePosition: boolean;
|
|
13
16
|
variables: WorkflowVariableRow[];
|
|
17
|
+
initialState: Record<string, unknown> | undefined;
|
|
14
18
|
onClose: () => void;
|
|
15
19
|
onChange: (key: "autoSave" | "savePosition", value: boolean) => void;
|
|
16
20
|
onVariablesChange: (next: WorkflowVariableRow[]) => void;
|
|
21
|
+
onEditStartingData: () => void;
|
|
17
22
|
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WorkflowVariableRow } from '../lib/index.ts';
|
|
2
|
+
/** Shared workflow input editor, used in the Data rail and the legacy settings dialog. */
|
|
3
|
+
export declare function WorkflowVariablesEditor({ variables, onVariablesChange, }: {
|
|
4
|
+
variables: WorkflowVariableRow[];
|
|
5
|
+
onVariablesChange: (next: WorkflowVariableRow[]) => void;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -9,6 +9,10 @@ export type Parsed = Record<string, unknown> & {
|
|
|
9
9
|
* this is ever ASSIGNED; this page only ever reads it back. */
|
|
10
10
|
key?: string | null;
|
|
11
11
|
nodes?: unknown[];
|
|
12
|
+
connections?: Record<string, {
|
|
13
|
+
app: string;
|
|
14
|
+
connection: string | null;
|
|
15
|
+
}>;
|
|
12
16
|
/** Legacy name for `nodes`; read via `workflowNodes`. */
|
|
13
17
|
steps?: unknown[];
|
|
14
18
|
status?: WorkflowStatus;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { JsonApplyCheck } from '../chrome/JsonToggle.tsx';
|
|
2
|
+
import { Parsed } from './definition.ts';
|
|
3
|
+
/**
|
|
4
|
+
* The top-level fields the raw-JSON dialog may not change: `id` names the row the save writes to,
|
|
5
|
+
* `key` is assigned only by the rail's Settings → Key control (`workflowKeyEditAllowed`), and
|
|
6
|
+
* `manifestVersion` is the one value the server's `parseWorkflowDefinition` accepts. An edit that
|
|
7
|
+
* alters or deletes one is not refused: Apply puts the loaded value back and says so.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PROTECTED_WORKFLOW_FIELDS: readonly ["id", "key", "manifestVersion"];
|
|
10
|
+
/**
|
|
11
|
+
* The offset of the first character that makes `text` invalid JSON, or `null` when it is valid.
|
|
12
|
+
* Engines disagree on whether `JSON.parse` reports a position at all (current V8 quotes a snippet
|
|
13
|
+
* instead), so the dialog finds it itself with this small strict scanner.
|
|
14
|
+
*/
|
|
15
|
+
export declare function jsonErrorOffset(text: string): number | null;
|
|
16
|
+
/** `JSON.parse`'s message, prefixed with the 1-based line and column of the first bad character. */
|
|
17
|
+
export declare function jsonSyntaxError(text: string, e: unknown): string;
|
|
18
|
+
/**
|
|
19
|
+
* The save-time shape rules the server applies (`parseWorkflowDefinition` + the step-id gate),
|
|
20
|
+
* restated for the fields the canvas reads, plus the one the canvas needs on top: every edge names
|
|
21
|
+
* a node that exists, or React Flow drops it silently and the next canvas edit deletes it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function workflowShapeError(def: Record<string, unknown>): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Everything Apply checks, in order: the text parses, it is an object, the protected fields carry
|
|
26
|
+
* the loaded values (restored when not), and the result has a shape the canvas and the save accept.
|
|
27
|
+
* `ok` hands back the text to apply — re-serialized when a field was restored, verbatim otherwise.
|
|
28
|
+
*/
|
|
29
|
+
export declare function prepareWorkflowJsonApply(text: string, loaded: Parsed | null): JsonApplyCheck;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { StepProblems } from '@w6w/ui/flow';
|
|
2
|
+
import { BindingProblem } from '../lib/binding-problems.ts';
|
|
3
|
+
/** Per step: its connection problem first, then its loop problems, then its state
|
|
4
|
+
* problems, then its setup-incomplete problem; all kept, empty lists skipped. */
|
|
5
|
+
export declare function mergeStepProblems(bindingProblems: readonly BindingProblem[], loopProblems: StepProblems | undefined, stateProblems?: StepProblems, setupProblems?: StepProblems): StepProblems;
|
package/dist/editor/types.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export interface WorkflowEditorSlots {
|
|
|
17
17
|
header?: ReactNode;
|
|
18
18
|
/** Rendered after the built-in header actions. Ignored when `header` replaces the header. */
|
|
19
19
|
headerActions?: ReactNode;
|
|
20
|
-
/** Label of the back control. Default `"← Workflows"`. */
|
|
21
|
-
backLabel?: string;
|
|
20
|
+
/** Label of the back control. Default `"← Workflows"`. `null` hides the back control. */
|
|
21
|
+
backLabel?: string | null;
|
|
22
22
|
}
|
|
23
23
|
export interface WorkflowEditorProps {
|
|
24
24
|
workflowId: string;
|