@w6w/embed 0.2.29 → 0.2.31
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/{CreateFunctionModal-CCYi9deY.js → CreateFunctionModal-glk2zg1r.js} +28 -27
- package/dist/{CreateFunctionModal-CCYi9deY.js.map → CreateFunctionModal-glk2zg1r.js.map} +1 -1
- package/dist/{DocumentFormModal-CCIgA7pR.js → DocumentFormModal-Cw85R4wk.js} +2 -2
- package/dist/{DocumentFormModal-CCIgA7pR.js.map → DocumentFormModal-Cw85R4wk.js.map} +1 -1
- package/dist/{ImportSpecModal-DoxsVxru.js → ImportSpecModal-fU5RsVTa.js} +2 -2
- package/dist/{ImportSpecModal-DoxsVxru.js.map → ImportSpecModal-fU5RsVTa.js.map} +1 -1
- package/dist/WorkflowEditor-B-Wc_r4X.js +1140 -0
- package/dist/WorkflowEditor-B-Wc_r4X.js.map +1 -0
- package/dist/callable-record-Bhxim8C1.js +14 -0
- package/dist/callable-record-Bhxim8C1.js.map +1 -0
- package/dist/callables-B49tS2vv.js +297 -0
- package/dist/callables-B49tS2vv.js.map +1 -0
- package/dist/{document-sources-DNmBojx6.js → document-sources-Khcw2zB5.js} +16 -16
- package/dist/document-sources-Khcw2zB5.js.map +1 -0
- package/dist/draft.mjs +1 -1
- package/dist/editor/WorkflowInputsModal.d.ts +12 -0
- package/dist/editor/WorkflowVariablesEditor.d.ts +1 -1
- package/dist/{editor-tools--Y3wlBZE.js → editor-tools-Ch1cAE4F.js} +434 -377
- package/dist/editor-tools-Ch1cAE4F.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +85 -85
- package/dist/endpoints-zOuwci2U.js +136 -0
- package/dist/endpoints-zOuwci2U.js.map +1 -0
- package/dist/fields-CXHRR5eK.js +28 -0
- package/dist/fields-CXHRR5eK.js.map +1 -0
- package/dist/forms.mjs +1 -1
- package/dist/index.mjs +91 -91
- package/dist/index.mjs.map +1 -1
- package/dist/lib/callable-duplicate.d.ts +26 -0
- package/dist/lib/recent-activity.d.ts +2 -2
- package/dist/lib/variable-preview.d.ts +6 -0
- package/dist/lib/workflow-version.d.ts +19 -2
- package/dist/lib.mjs +41 -40
- package/dist/lib.mjs.map +1 -1
- package/dist/lists/AiKeyCreate.d.ts +20 -0
- package/dist/lists/CallableKindList.d.ts +21 -2
- package/dist/lists/CallableRowParts.d.ts +38 -0
- package/dist/lists/CredentialCreate.d.ts +17 -17
- package/dist/lists/CredentialDetail.d.ts +2 -0
- package/dist/lists/CredentialFields.d.ts +18 -0
- package/dist/lists/CredentialList.d.ts +35 -3
- package/dist/lists/EndpointList.d.ts +2 -1
- package/dist/lists/WorkflowList.d.ts +2 -1
- package/dist/lists.d.ts +2 -0
- package/dist/lists.mjs +2185 -1615
- package/dist/lists.mjs.map +1 -1
- package/dist/rail.mjs +1 -1
- package/dist/repos/callables.d.ts +23 -0
- package/dist/repos/fields.d.ts +4 -1
- package/dist/repos.mjs +287 -284
- package/dist/settings-rail-BjsTjg2u.js +22 -0
- package/dist/settings-rail-BjsTjg2u.js.map +1 -0
- package/dist/spec-export-BtnoV0ex.js +33 -0
- package/dist/spec-export-BtnoV0ex.js.map +1 -0
- package/dist/spec-import-CGPqUUjN.js +272 -0
- package/dist/spec-import-CGPqUUjN.js.map +1 -0
- package/dist/{use-callable-draft-DCauHt5o.js → use-callable-draft-DjW7_9qb.js} +8 -7
- package/dist/{use-callable-draft-DCauHt5o.js.map → use-callable-draft-DjW7_9qb.js.map} +1 -1
- package/package.json +5 -5
- package/src/styles.css +221 -10
- package/dist/WorkflowEditor-CBUwh85L.js +0 -1117
- package/dist/WorkflowEditor-CBUwh85L.js.map +0 -1
- package/dist/callables-tOlflvbl.js +0 -151
- package/dist/callables-tOlflvbl.js.map +0 -1
- package/dist/document-sources-DNmBojx6.js.map +0 -1
- package/dist/editor-tools--Y3wlBZE.js.map +0 -1
- package/dist/endpoints-DArAqoLT.js +0 -233
- package/dist/endpoints-DArAqoLT.js.map +0 -1
- package/dist/fields-DvS8XZFc.js +0 -21
- package/dist/fields-DvS8XZFc.js.map +0 -1
- package/dist/settings-rail--GdRMusb.js +0 -33
- package/dist/settings-rail--GdRMusb.js.map +0 -1
- package/dist/spec-export-DMMET5VM.js +0 -189
- package/dist/spec-export-DMMET5VM.js.map +0 -1
- package/dist/spec-import-0B6oUewa.js +0 -116
- package/dist/spec-import-0B6oUewa.js.map +0 -1
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { useQueryClient as u, useMutation as f, useQuery as w } from "@tanstack/react-query";
|
|
2
|
+
import { u as s } from "./client-context-CX61Bgw-.js";
|
|
3
|
+
import { c as C } from "./callable-record-Bhxim8C1.js";
|
|
4
|
+
const v = {
|
|
5
|
+
function: (e) => ["function", e],
|
|
6
|
+
endpoint: (e) => ["endpoint", e],
|
|
7
|
+
workflow: (e) => ["workflow", e]
|
|
8
|
+
};
|
|
9
|
+
function y(e, n) {
|
|
10
|
+
return v[e](n);
|
|
11
|
+
}
|
|
12
|
+
function T(e, n, t) {
|
|
13
|
+
e.invalidateQueries({ queryKey: n }), e.invalidateQueries({ queryKey: t });
|
|
14
|
+
}
|
|
15
|
+
const g = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", E = 248, I = (e) => crypto.getRandomValues(new Uint8Array(e));
|
|
16
|
+
function L(e, n = 16, t = I) {
|
|
17
|
+
let i = "";
|
|
18
|
+
for (; i.length < n; )
|
|
19
|
+
for (const o of t(Math.max(n - i.length, 8)))
|
|
20
|
+
if (!(o >= E) && (i += g[o % 62], i.length === n))
|
|
21
|
+
break;
|
|
22
|
+
return `${e}_${i}`;
|
|
23
|
+
}
|
|
24
|
+
const S = {
|
|
25
|
+
function: {
|
|
26
|
+
kind: "function",
|
|
27
|
+
listTitle: "Functions",
|
|
28
|
+
listDescription: 'A Function is a reusable, vendor-abstracted operation — "Send Email", "Create Contact" — with a stable interface bound to one swappable app action. Switch provider by re-binding; callers never change.',
|
|
29
|
+
emptyCopy: "None yet — click “New function” to create one, or “Import” to bring in a spec document.",
|
|
30
|
+
newLabel: "+ New function",
|
|
31
|
+
newIdPrefix: "fn",
|
|
32
|
+
importOpenTestId: "functions-import-open",
|
|
33
|
+
showArchivedTestId: "functions-show-archived",
|
|
34
|
+
archivedBadgeTestId: "function-archived",
|
|
35
|
+
openRowTitle: "Open this function in the editor.",
|
|
36
|
+
editor: {
|
|
37
|
+
backLabel: "← Functions",
|
|
38
|
+
newTitle: "New function",
|
|
39
|
+
notFoundTitle: "Function not found",
|
|
40
|
+
saveLabel: "Save"
|
|
41
|
+
},
|
|
42
|
+
settings: {
|
|
43
|
+
canEditKey: !0,
|
|
44
|
+
hasTags: !0,
|
|
45
|
+
namePlaceholder: "Send Email",
|
|
46
|
+
keyPlaceholder: "send-email",
|
|
47
|
+
keyHintSuffix: ""
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
endpoint: {
|
|
51
|
+
kind: "endpoint",
|
|
52
|
+
listTitle: "Endpoints",
|
|
53
|
+
listDescription: "An Endpoint is a named, stable entry point that dispatches to one app action, Function, or Workflow. Callers bind to the Endpoint; the target behind it can change — promote an action to a Function or a Workflow, or re-bind it — without breaking a single caller.",
|
|
54
|
+
emptyCopy: "None yet — click “New endpoint” to create one.",
|
|
55
|
+
newLabel: "+ New endpoint",
|
|
56
|
+
newIdPrefix: "ep",
|
|
57
|
+
importOpenTestId: "endpoints-import-open",
|
|
58
|
+
showArchivedTestId: "endpoints-show-archived",
|
|
59
|
+
archivedBadgeTestId: "endpoint-archived",
|
|
60
|
+
openRowTitle: "Open this endpoint in the editor.",
|
|
61
|
+
editor: {
|
|
62
|
+
backLabel: "← Endpoints",
|
|
63
|
+
newTitle: "New endpoint",
|
|
64
|
+
notFoundTitle: "Endpoint not found",
|
|
65
|
+
saveLabel: "Save"
|
|
66
|
+
},
|
|
67
|
+
settings: {
|
|
68
|
+
canEditKey: !1,
|
|
69
|
+
hasTags: !0,
|
|
70
|
+
namePlaceholder: "My endpoint",
|
|
71
|
+
keyPlaceholder: "send-email",
|
|
72
|
+
keyHintSuffix: ""
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
workflow: {
|
|
76
|
+
kind: "workflow",
|
|
77
|
+
listTitle: "Workflows",
|
|
78
|
+
listDescription: "A Workflow is a durable, multi-node run: each node calls an app action, a Function, or another Workflow, and a run keeps its own state, history and error handling.",
|
|
79
|
+
emptyCopy: "None yet — click “New workflow” to create one.",
|
|
80
|
+
newLabel: "+ New workflow",
|
|
81
|
+
newIdPrefix: "wf",
|
|
82
|
+
importOpenTestId: "workflows-import-open",
|
|
83
|
+
showArchivedTestId: "workflows-show-archived",
|
|
84
|
+
archivedBadgeTestId: "workflow-archived",
|
|
85
|
+
openRowTitle: "Open this workflow in the visual editor.",
|
|
86
|
+
editor: {
|
|
87
|
+
backLabel: "← Workflows",
|
|
88
|
+
newTitle: "New workflow",
|
|
89
|
+
notFoundTitle: "Workflow not found",
|
|
90
|
+
saveLabel: "Save"
|
|
91
|
+
},
|
|
92
|
+
settings: {
|
|
93
|
+
canEditKey: !0,
|
|
94
|
+
hasTags: !0,
|
|
95
|
+
namePlaceholder: "My workflow",
|
|
96
|
+
keyPlaceholder: "unset",
|
|
97
|
+
keyHintSuffix: " Leave empty to unset."
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
function N(e) {
|
|
102
|
+
return S[e];
|
|
103
|
+
}
|
|
104
|
+
function A(e) {
|
|
105
|
+
return L(N(e).newIdPrefix);
|
|
106
|
+
}
|
|
107
|
+
const F = 39;
|
|
108
|
+
function $(e, n) {
|
|
109
|
+
const t = /* @__PURE__ */ new Set();
|
|
110
|
+
for (const o of n) o && t.add(o.trim().toLowerCase());
|
|
111
|
+
const i = e.replace(/\s*\(copy(?: \d+)?\)$/i, "").trim() || e.trim();
|
|
112
|
+
for (let o = 1; ; o++) {
|
|
113
|
+
const a = o === 1 ? `${i} (copy)` : `${i} (copy ${o})`;
|
|
114
|
+
if (!t.has(a.toLowerCase())) return a;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function K(e, n) {
|
|
118
|
+
const t = /* @__PURE__ */ new Set();
|
|
119
|
+
for (const o of n) o && t.add(o);
|
|
120
|
+
const i = e.replace(/-copy(?:-\d+)?$/, "") || e;
|
|
121
|
+
for (let o = 1; ; o++) {
|
|
122
|
+
const a = o === 1 ? "-copy" : `-copy-${o}`, c = `${i.slice(0, F - a.length).replace(/-+$/, "").replace(/--+/g, "-")}${a}`;
|
|
123
|
+
if (!t.has(c)) return c;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function P(e, n, t, i) {
|
|
127
|
+
const { key: o, ...a } = n, r = structuredClone(a), c = n.id;
|
|
128
|
+
r.id = t;
|
|
129
|
+
const d = typeof n.key == "string" && n.key ? n.key : null;
|
|
130
|
+
d && (r.key = K(d, i.keys));
|
|
131
|
+
const m = typeof n.displayName == "string" && n.displayName || d || typeof n.name == "string" && n.name || "Untitled";
|
|
132
|
+
return r.displayName = $(m, i.names), e === "workflow" && n.name === c && (r.name = t), r;
|
|
133
|
+
}
|
|
134
|
+
const p = {
|
|
135
|
+
function: "functions",
|
|
136
|
+
endpoint: "endpoints",
|
|
137
|
+
workflow: "workflows"
|
|
138
|
+
}, q = {
|
|
139
|
+
function: () => ["functions"],
|
|
140
|
+
endpoint: () => ["endpoints"],
|
|
141
|
+
workflow: (e) => ["workflows", e]
|
|
142
|
+
};
|
|
143
|
+
function H(e) {
|
|
144
|
+
return p[e];
|
|
145
|
+
}
|
|
146
|
+
function R(e, n) {
|
|
147
|
+
const t = p[e];
|
|
148
|
+
return n === void 0 ? t : `${t}/${n}`;
|
|
149
|
+
}
|
|
150
|
+
function h(e, n) {
|
|
151
|
+
return `/${p[e]}/${n}`;
|
|
152
|
+
}
|
|
153
|
+
function j(e, n) {
|
|
154
|
+
return `${R(e, n)}/history`;
|
|
155
|
+
}
|
|
156
|
+
function l(e, n) {
|
|
157
|
+
return q[e](n);
|
|
158
|
+
}
|
|
159
|
+
function D(e, n, t) {
|
|
160
|
+
switch (n) {
|
|
161
|
+
case "function":
|
|
162
|
+
return e.console.functions.list();
|
|
163
|
+
case "endpoint":
|
|
164
|
+
return e.console.endpoints.list();
|
|
165
|
+
case "workflow":
|
|
166
|
+
return e.workflows.list({ project: t });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function b(e, n, t) {
|
|
170
|
+
switch (n) {
|
|
171
|
+
case "function":
|
|
172
|
+
return e.console.functions.get(t);
|
|
173
|
+
case "endpoint":
|
|
174
|
+
return e.console.endpoints.get(t);
|
|
175
|
+
case "workflow":
|
|
176
|
+
return e.console.workflows.get(t);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function k(e, n, t, i) {
|
|
180
|
+
switch (n) {
|
|
181
|
+
case "function":
|
|
182
|
+
return e.console.functions.upsert(t).then((o) => ({ id: o.id, key: o.key }));
|
|
183
|
+
case "endpoint":
|
|
184
|
+
return e.console.endpoints.upsert(t).then((o) => ({ id: o.endpoint.id, key: o.endpoint.key }));
|
|
185
|
+
case "workflow": {
|
|
186
|
+
const o = i == null ? void 0 : i.project;
|
|
187
|
+
return o ? e.console.workflows.upsert(t, { project: o }).then((a) => ({
|
|
188
|
+
id: a.workflow.id,
|
|
189
|
+
key: a.workflow.key ?? ""
|
|
190
|
+
})) : Promise.reject(new Error("No project selected yet."));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function O(e, n, t) {
|
|
195
|
+
switch (n) {
|
|
196
|
+
case "function":
|
|
197
|
+
case "endpoint":
|
|
198
|
+
return e.request({
|
|
199
|
+
method: "POST",
|
|
200
|
+
path: `${h(n, encodeURIComponent(t))}/archive`
|
|
201
|
+
});
|
|
202
|
+
case "workflow":
|
|
203
|
+
return e.console.workflows.archive(t);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function x(e, n, t) {
|
|
207
|
+
switch (n) {
|
|
208
|
+
case "function":
|
|
209
|
+
case "endpoint":
|
|
210
|
+
return e.request({ method: "DELETE", path: h(n, encodeURIComponent(t)) });
|
|
211
|
+
case "workflow":
|
|
212
|
+
return e.console.workflows.delete(t);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function M(e, n) {
|
|
216
|
+
var i;
|
|
217
|
+
if (e !== "workflow") return ((i = C(e, n)) == null ? void 0 : i.definition) ?? null;
|
|
218
|
+
const t = n == null ? void 0 : n.workflow;
|
|
219
|
+
return typeof t == "object" && t !== null && !Array.isArray(t) ? t : null;
|
|
220
|
+
}
|
|
221
|
+
async function Q(e, n, t, i, o) {
|
|
222
|
+
const a = M(n, await b(e, n, t));
|
|
223
|
+
if (!a) throw new Error(`Could not read the ${n} to duplicate.`);
|
|
224
|
+
const r = P(n, a, A(n), i);
|
|
225
|
+
return k(e, n, r, o);
|
|
226
|
+
}
|
|
227
|
+
function U(e, n = !0, t) {
|
|
228
|
+
const i = s();
|
|
229
|
+
return w({
|
|
230
|
+
queryKey: l(e, t),
|
|
231
|
+
queryFn: () => D(i, e, t),
|
|
232
|
+
enabled: n
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function Y(e, n, t = !0) {
|
|
236
|
+
const i = s();
|
|
237
|
+
return w({
|
|
238
|
+
queryKey: y(e, n),
|
|
239
|
+
queryFn: () => b(i, e, n),
|
|
240
|
+
enabled: t
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function J(e, n) {
|
|
244
|
+
const t = s(), i = u();
|
|
245
|
+
return f({
|
|
246
|
+
mutationFn: (o) => k(t, e, o, n),
|
|
247
|
+
onSuccess: (o) => T(i, l(e), y(e, o.id))
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
function V(e) {
|
|
251
|
+
const n = s(), t = u();
|
|
252
|
+
return f({
|
|
253
|
+
mutationFn: (i) => O(n, e, i),
|
|
254
|
+
onSuccess: () => t.invalidateQueries({ queryKey: l(e) })
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function X(e) {
|
|
258
|
+
const n = s(), t = u();
|
|
259
|
+
return f({
|
|
260
|
+
mutationFn: (i) => x(n, e, i),
|
|
261
|
+
onSuccess: () => t.invalidateQueries({ queryKey: l(e) })
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function z(e, n) {
|
|
265
|
+
const t = s(), i = u();
|
|
266
|
+
return f({
|
|
267
|
+
mutationFn: (o) => Q(t, e, o.id, o.siblings, n),
|
|
268
|
+
onSuccess: () => i.invalidateQueries({ queryKey: [l(e)[0]] })
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
export {
|
|
272
|
+
S as C,
|
|
273
|
+
g as I,
|
|
274
|
+
y as a,
|
|
275
|
+
O as b,
|
|
276
|
+
l as c,
|
|
277
|
+
H as d,
|
|
278
|
+
j as e,
|
|
279
|
+
h as f,
|
|
280
|
+
R as g,
|
|
281
|
+
x as h,
|
|
282
|
+
T as i,
|
|
283
|
+
N as j,
|
|
284
|
+
Q as k,
|
|
285
|
+
b as l,
|
|
286
|
+
D as m,
|
|
287
|
+
A as n,
|
|
288
|
+
L as o,
|
|
289
|
+
V as p,
|
|
290
|
+
U as q,
|
|
291
|
+
X as r,
|
|
292
|
+
k as s,
|
|
293
|
+
z as t,
|
|
294
|
+
Y as u,
|
|
295
|
+
J as v
|
|
296
|
+
};
|
|
297
|
+
//# sourceMappingURL=callables-B49tS2vv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callables-B49tS2vv.js","sources":["../src/lib/callable-kind.ts","../src/lib/save-invalidation.ts","../src/lib/new-id.ts","../src/lib/callable-descriptors.ts","../src/lib/callable-duplicate.ts","../src/repos/callables.ts"],"sourcesContent":["/**\n * The three callable kinds and the single-resource query key per kind.\n *\n * Moved verbatim out of Studio's `repos/callables.ts` (`CallableKind`, `callableKey` and the one\n * pure table `callableKey` closes over, `RESOURCE_KEY`) so `repos/versions.ts` — which ships in\n * this package for all three kind arms — can invalidate a definition by key without importing a\n * Studio module. `repos/callables.ts` imports these from `@w6w/embed/repos` and does NOT re-export\n * them. No React, no client: loadable by `node --test`.\n */\n\n/** The three kinds the callable repos are total over. */\nexport type CallableKind = \"function\" | \"endpoint\" | \"workflow\";\n\n/** The single-resource key's own prefix — byte-identical to `functionKey`/`endpointKey`/\n * `workflowKey`. */\nconst RESOURCE_KEY: Record<CallableKind, (id: string) => readonly unknown[]> = {\n function: (id) => [\"function\", id],\n endpoint: (id) => [\"endpoint\", id],\n workflow: (id) => [\"workflow\", id],\n};\n\n/** `GET /<coll>/:id`'s own query key — the literal `lib/save-invalidation.ts` invalidates. */\nexport function callableKey(kind: CallableKind, id: string): readonly unknown[] {\n return RESOURCE_KEY[kind](id);\n}\n","/**\n * Shared invalidation for a whole-definition save (T3.1.1). `useSaveFunctionMutation` and\n * `useSaveEndpointMutation` (`src/repos/functions.ts`, `src/repos/endpoints.ts`) both route their\n * `onSuccess` through this one helper rather than inlining the two `invalidateQueries` calls at\n * each site — so a save invalidates the LIST key (both list pages and the editor depend on it)\n * *and* the saved resource's own single-resource key (`functionKey(id)` / `endpointKey(id)`),\n * never just the list.\n *\n * No value imports on purpose: `node --test` throws `ERR_UNKNOWN_FILE_EXTENSION` on anything that\n * reaches the `@w6w/ui` / `Layout.tsx` import graph, and `src/repos/*.ts` reaches it through\n * `../api/apiClient.tsx` (JSX). This module has none of that, so it is loadable by `node --test`\n * directly — see `src/lib/alias-rail.ts`'s docstring for the same reasoning.\n */\n\nexport interface QueryInvalidator {\n invalidateQueries(filters: { queryKey: readonly unknown[] }): unknown;\n}\n\n/**\n * Invalidate the list key, then the saved resource's own key. List first: both keys are\n * invalidated regardless of order, but the order is asserted (see the unit test) so a future edit\n * that drops one call is a diff a reviewer can spot in a single line.\n */\nexport function invalidateSavedCallable(\n qc: QueryInvalidator,\n listKey: readonly unknown[],\n callableKey: readonly unknown[],\n): void {\n qc.invalidateQueries({ queryKey: listKey });\n qc.invalidateQueries({ queryKey: callableKey });\n}\n","/**\n * Platform id minter (studio copy). Algorithm is byte-identical to the server's\n * `packages/ids/ids.ts`: alphabet base62, drop byte b >= 248 (largest multiple of 62\n * that fits a byte), keep ALPHABET[b % 62]. No modulo bias.\n */\n\nexport const ID_ALPHABET = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";\n\n/** Largest multiple of 62 <= 256; bytes at or above it are rejected. */\nconst REJECT_AT = 248;\n\n/** Byte source seam; defaults to `crypto.getRandomValues`. */\nexport type ByteSource = (n: number) => Uint8Array;\n\nconst defaultBytes: ByteSource = (n) => crypto.getRandomValues(new Uint8Array(n));\n\n/** `<prefix>_<len chars of base62>`. */\nexport function newId(prefix: string, len = 16, bytes: ByteSource = defaultBytes): string {\n let out = \"\";\n while (out.length < len) {\n for (const b of bytes(Math.max(len - out.length, 8))) {\n if (b >= REJECT_AT) continue;\n out += ID_ALPHABET[b % 62];\n if (out.length === len) break;\n }\n }\n return `${prefix}_${out}`;\n}\n","/**\n * `CALLABLE_DESCRIPTORS` — the ONE place the three resource kinds' chrome copy,\n * their Settings-modal behaviour and their id minting are named (T4.2.1,\n * `building-blocks.F3.md` §F-3).\n *\n * Before this file, every \"is this a workflow?\" branch lived inline at its call\n * site: `CallableSettingsModal.tsx` carried seven `kind ===` conditionals for\n * three different questions (may the key be edited? does this kind have tags?\n * which placeholder does the name field use?), and each list page repeated the\n * same title/description/empty-state/`data-testid` literals. A fourth kind — or\n * a rename — meant finding them all by hand.\n *\n * **Data only, never JSX.** A `Descriptor` holds strings, booleans and the one\n * id prefix; the kind-specific *editor body* stays React code in its own page\n * (`src/pages/FunctionsPage.tsx`), because this file is `.ts` and is loaded by\n * `node --test` (`.tsx` cannot be — `package.json`'s `test:unit` glob), exactly\n * the constraint `src/lib/save-invalidation.ts` and `src/lib/alias-rail.ts`\n * document for themselves. So `kind ===` moves OUT of the modal and the pages\n * and INTO a total `Record`, never into a render function.\n *\n * The wire plumbing these descriptors describe — collection segment, query keys,\n * the SDK call per kind — lives one layer down, in `src/repos/callables.ts`,\n * which owns its own total `Record` per kind (mirroring `src/repos/versions.ts`'s\n * `COLLECTION_PATH`). `callable-descriptors.test.ts` asserts the two tables name\n * the same three kinds and the same three collections, so they cannot drift.\n */\nimport type { CallableKind } from \"./callable-kind.ts\";\nimport { newId } from \"./new-id.ts\";\n\nexport type { CallableKind };\n\n/** The Settings modal's own per-kind behaviour (T4.2.1's formalization of the\n * seven `kind ===` conditionals `CallableSettingsModal.tsx` used to carry). */\nexport interface CallableSettingsDescriptor {\n /** May the `key` be typed here at all? Function/Workflow yes, Endpoint no\n * (`rfcs/endpoint.md` — an Endpoint's address is its identity). */\n canEditKey: boolean;\n /** Does this kind store tags? All three (`callables.meta.tags`). */\n hasTags: boolean;\n /** Placeholder for the Name field. */\n namePlaceholder: string;\n /** Placeholder for the Key field (read only when {@link canEditKey}). */\n keyPlaceholder: string;\n /** Appended to the shared \"Lowercase, kebab-case, 3–39 characters.\" hint —\n * `\"\"` for a kind that cannot unset its key, the \"Leave empty to unset.\"\n * sentence for the one that can. */\n keyHintSuffix: string;\n}\n\n/** The editor chrome's own per-kind copy. */\nexport interface CallableEditorDescriptor {\n /** The back control's label, e.g. `\"← Functions\"`. */\n backLabel: string;\n /** Heading fallback while the definition is still hydrating. */\n newTitle: string;\n /** Rendered in place of the form when the hydration GET 404s. */\n notFoundTitle: string;\n /** The Save button's idle label. */\n saveLabel: string;\n}\n\nexport interface CallableDescriptor {\n kind: CallableKind;\n /** The list page's `<h2>`, and the editor document title's second segment. */\n listTitle: string;\n /** The list page's explanatory paragraph. */\n listDescription: string;\n /** The empty-state paragraph (verbatim, including its typographic quotes). */\n emptyCopy: string;\n /** The create button's label, e.g. `\"+ New function\"`. */\n newLabel: string;\n /** The synthetic id's own prefix — `fn_…`/`ep_…`/`wf_…`, never user-edited. */\n newIdPrefix: string;\n /** `data-testid` of the list's Import affordance. */\n importOpenTestId: string;\n /** `data-testid` of the list's \"Show archived\" checkbox. */\n showArchivedTestId: string;\n /** `data-testid` of a row's \"archived\" badge. */\n archivedBadgeTestId: string;\n /** The row button's `title` tooltip (T4.2.3 — replaces the shared template literal\n * `` `Open this ${kind} in the editor.` ``, since Workflow's own row opens the visual editor,\n * not \"the editor\"). */\n openRowTitle: string;\n editor: CallableEditorDescriptor;\n settings: CallableSettingsDescriptor;\n}\n\n/**\n * The three kinds, every arm named explicitly — a total `Record<CallableKind,\n * …>`, so a fourth kind fails to compile here rather than silently rendering\n * another kind's copy (the same reasoning `COLLECTION_PATH` gives in\n * `src/repos/versions.ts`).\n *\n * Only the `function` arm is consumed today: Endpoints and Workflows keep their\n * own pages until T4.2.2/T4.2.3. Their arms are filled from those pages'\n * current literals so the later nodes are a deletion, not a re-derivation.\n */\nexport const CALLABLE_DESCRIPTORS: Record<CallableKind, CallableDescriptor> = {\n function: {\n kind: \"function\",\n listTitle: \"Functions\",\n listDescription:\n 'A Function is a reusable, vendor-abstracted operation — \"Send Email\", \"Create Contact\" — ' +\n \"with a stable interface bound to one swappable app action. Switch provider by \" +\n \"re-binding; callers never change.\",\n emptyCopy:\n \"None yet — click “New function” to create one, or “Import” to bring in a spec document.\",\n newLabel: \"+ New function\",\n newIdPrefix: \"fn\",\n importOpenTestId: \"functions-import-open\",\n showArchivedTestId: \"functions-show-archived\",\n archivedBadgeTestId: \"function-archived\",\n openRowTitle: \"Open this function in the editor.\",\n editor: {\n backLabel: \"← Functions\",\n newTitle: \"New function\",\n notFoundTitle: \"Function not found\",\n saveLabel: \"Save\",\n },\n settings: {\n canEditKey: true,\n hasTags: true,\n namePlaceholder: \"Send Email\",\n keyPlaceholder: \"send-email\",\n keyHintSuffix: \"\",\n },\n },\n endpoint: {\n kind: \"endpoint\",\n listTitle: \"Endpoints\",\n listDescription:\n \"An Endpoint is a named, stable entry point that dispatches to one app action, Function, \" +\n \"or Workflow. Callers bind to the Endpoint; the target behind it can change — promote an \" +\n \"action to a Function or a Workflow, or re-bind it — without breaking a single caller.\",\n emptyCopy: \"None yet — click “New endpoint” to create one.\",\n newLabel: \"+ New endpoint\",\n newIdPrefix: \"ep\",\n importOpenTestId: \"endpoints-import-open\",\n showArchivedTestId: \"endpoints-show-archived\",\n archivedBadgeTestId: \"endpoint-archived\",\n openRowTitle: \"Open this endpoint in the editor.\",\n editor: {\n backLabel: \"← Endpoints\",\n newTitle: \"New endpoint\",\n notFoundTitle: \"Endpoint not found\",\n saveLabel: \"Save\",\n },\n settings: {\n canEditKey: false,\n hasTags: true,\n namePlaceholder: \"My endpoint\",\n keyPlaceholder: \"send-email\",\n keyHintSuffix: \"\",\n },\n },\n workflow: {\n kind: \"workflow\",\n listTitle: \"Workflows\",\n listDescription:\n \"A Workflow is a durable, multi-node run: each node calls an app action, a Function, or \" +\n \"another Workflow, and a run keeps its own state, history and error handling.\",\n emptyCopy: \"None yet — click “New workflow” to create one.\",\n newLabel: \"+ New workflow\",\n newIdPrefix: \"wf\",\n importOpenTestId: \"workflows-import-open\",\n showArchivedTestId: \"workflows-show-archived\",\n archivedBadgeTestId: \"workflow-archived\",\n openRowTitle: \"Open this workflow in the visual editor.\",\n editor: {\n backLabel: \"← Workflows\",\n newTitle: \"New workflow\",\n notFoundTitle: \"Workflow not found\",\n saveLabel: \"Save\",\n },\n settings: {\n canEditKey: true,\n hasTags: true,\n namePlaceholder: \"My workflow\",\n keyPlaceholder: \"unset\",\n keyHintSuffix: \" Leave empty to unset.\",\n },\n },\n};\n\n/** Look a descriptor up by kind. A plain index, never a `switch`: the `Record`\n * above already made every arm total. */\nexport function descriptorFor(kind: CallableKind): CallableDescriptor {\n return CALLABLE_DESCRIPTORS[kind];\n}\n\n/**\n * A fresh synthetic id for a create-modal's first POST — `fn_<uuid>` for a\n * Function (verbatim the `newFunctionId` `FunctionsPage.tsx` used to hold),\n * `ep_`/`wf_` for the other two, whose pages mint the same shapes today. The\n * prefix comes from the descriptor, so \"which kind is this?\" is answered by the\n * same table that answers every other kind question.\n */\nexport function newCallableId(kind: CallableKind): string {\n return newId(descriptorFor(kind).newIdPrefix);\n}\n","/**\n * The copy a row menu's Duplicate posts: the source definition under a fresh id, a key no sibling\n * of the same kind already holds, and a \"(copy)\" display name. Everything else — nodes, target,\n * input contract, settings — rides across verbatim; the copy is a new draft, so publish state and\n * the enabled switch are not carried (the server starts every created row at its defaults).\n *\n * Pure, no imports beyond types: loadable by `node --test`.\n */\nimport type { CallableKind } from \"./callable-kind.ts\";\n\n/** The longest key the server accepts for a Function/Endpoint (`isEndpointKey`'s 39). */\nconst KEY_MAX = 39;\n\n/** `name (copy)`, `name (copy 2)`, … — the first one no row in `taken` already shows. */\nexport function copyDisplayName(name: string, taken: Iterable<string | null | undefined>): string {\n const used = new Set<string>();\n for (const t of taken) if (t) used.add(t.trim().toLowerCase());\n const base = name.replace(/\\s*\\(copy(?: \\d+)?\\)$/i, \"\").trim() || name.trim();\n for (let n = 1; ; n++) {\n const candidate = n === 1 ? `${base} (copy)` : `${base} (copy ${n})`;\n if (!used.has(candidate.toLowerCase())) return candidate;\n }\n}\n\n/**\n * `key-copy`, `key-copy-2`, … — the first one not in `taken`, cut so it stays within the key\n * grammar's 39 characters (the cut drops the base's tail, never the suffix, and never leaves a\n * trailing or doubled `-`).\n */\nexport function copyKey(key: string, taken: Iterable<string | null | undefined>): string {\n const used = new Set<string>();\n for (const t of taken) if (t) used.add(t);\n const base = key.replace(/-copy(?:-\\d+)?$/, \"\") || key;\n for (let n = 1; ; n++) {\n const suffix = n === 1 ? \"-copy\" : `-copy-${n}`;\n const head = base\n .slice(0, KEY_MAX - suffix.length)\n .replace(/-+$/, \"\")\n .replace(/--+/g, \"-\");\n const candidate = `${head}${suffix}`;\n if (!used.has(candidate)) return candidate;\n }\n}\n\n/** The siblings a copy must not collide with: their keys and their display names. */\nexport interface DuplicateSiblings {\n keys: Iterable<string | null | undefined>;\n names: Iterable<string | null | undefined>;\n}\n\n/**\n * The definition to POST for a copy of `source` under `newId`. `source` is the kind's editable\n * definition (`callableRecord(...).definition` for a Function/Endpoint, the `workflow` body of a\n * Workflow's `get`) and is never mutated.\n *\n * - `key` — a fresh sibling-free key when the source has one; a Workflow without a key stays\n * without one (its key is optional).\n * - `displayName` — `\"<name> (copy)\"`, falling back to the key when the source has no name.\n * - Workflow `name` — a blank Workflow's `name` IS its id (`blankDefinition`), so a `name` equal\n * to the old id follows the id; any other `name` is kept.\n */\nexport function duplicateDefinition(\n kind: CallableKind,\n source: Record<string, unknown>,\n newId: string,\n siblings: DuplicateSiblings,\n): Record<string, unknown> {\n const { key: _key, ...rest } = source;\n const copy: Record<string, unknown> = structuredClone(rest);\n const oldId = source.id;\n copy.id = newId;\n const key = typeof source.key === \"string\" && source.key ? source.key : null;\n if (key) copy.key = copyKey(key, siblings.keys);\n const shown =\n (typeof source.displayName === \"string\" && source.displayName) ||\n key ||\n (typeof source.name === \"string\" && source.name) ||\n \"Untitled\";\n copy.displayName = copyDisplayName(shown, siblings.names);\n if (kind === \"workflow\" && source.name === oldId) copy.name = newId;\n return copy;\n}\n","import { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type { W6WClient } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n/**\n * The kind-parametrised resource repo (T4.2.1, `building-blocks.F3.md` §F-3) — ONE module\n * answering \"list / get / save / archive / delete a resource of kind K\" for all three kinds,\n * instead of `functions.ts`/`endpoints.ts`/`workflows.ts` each restating the same five shapes with\n * their own key builder.\n *\n * **Mirrors `src/repos/versions.ts`'s `COLLECTION_PATH: Record<VersionsKind, …>` idiom**: every\n * per-kind fact is a TOTAL `Record` whose arms are all named explicitly, never a string\n * pluralisation rule — a typo'd suffix would silently send one kind's requests at another kind's\n * collection (that module's own docblock gives the reasoning in full). The two tables that are\n * genuinely per-kind *data* — the collection segment and the two query-key shapes — are `Record`s;\n * the three calls whose SIGNATURE differs per kind (get's return shape, save's envelope key,\n * archive/delete's SDK-vs-escape-hatch split) are `switch`es with every arm named and no\n * `default:`, so a fourth kind is a compile error rather than a silent fall-through.\n *\n * **Query keys are byte-identical to the ones this repo replaces** — `[\"functions\"]`,\n * `[\"function\", id]`, `[\"endpoints\"]`, `[\"endpoint\", id]`, `[\"workflows\", project]`,\n * `[\"workflow\", id]` — because `lib/save-invalidation.ts`, `lib/spec-import-invalidation.ts` and\n * `repos/versions.ts`'s revert arm all invalidate those literals through helpers that take a key,\n * not a hook. A renamed key here would leave a saved resource's page showing its pre-save draft,\n * invisible to `tsc` and to every page guard (this is `spec-import-invalidation.ts`'s own\n * argument, restated for the whole family).\n *\n * `repos/functions.ts` stays as the Function-bound facade over this module — every existing\n * importer (`ui/rail/SettingsTool.tsx`, `ui/rail/AliasesTool.tsx`, `ui/rail/ErrorHandlingTool.tsx`,\n * `components/TargetSelector.tsx`, `components/FunctionIdentityModal.tsx`, `api/w6wApiFacade.tsx`)\n * keeps its import and its call shape; only where the code lives changed.\n */\nimport { newCallableId } from \"../lib/callable-descriptors.ts\";\nimport { type DuplicateSiblings, duplicateDefinition } from \"../lib/callable-duplicate.ts\";\nimport { type CallableKind, callableKey } from \"../lib/callable-kind.ts\";\nimport { callableRecord } from \"../lib/callable-record.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\n\n/** `<coll>` — the wire contract's own path segment per kind, every arm named explicitly\n * (never derived by string pluralisation), mirroring `versions.ts`'s `COLLECTION_PATH`. */\nconst COLLECTION_PATH: Record<CallableKind, \"functions\" | \"endpoints\" | \"workflows\"> = {\n function: \"functions\",\n endpoint: \"endpoints\",\n workflow: \"workflows\",\n};\n\n/**\n * The LIST query key per kind — byte-identical to `functionsKey`, `endpointsKey` and\n * `workflowsKey(project)`. A function per kind, not a literal, because the Workflow arm is\n * genuinely project-scoped (`repos/workflows.ts`'s own note: `[\"workflows\", undefined]` and\n * `[\"workflows\", \"prj_x\"]` are DIFFERENT cache entries, deliberately).\n */\nconst LIST_KEY: Record<CallableKind, (project?: string) => readonly unknown[]> = {\n function: () => [\"functions\"],\n endpoint: () => [\"endpoints\"],\n workflow: (project) => [\"workflows\", project],\n};\n\n/**\n * The structural minimum every list row of every kind satisfies — what the shared list chrome\n * (`pages/CallablePage.tsx`) renders and the Settings rail reads by id. Kind-specific widening\n * (`archivedAt`, an Endpoint's `status`/`incomplete`) stays in the kind's own facade, which is\n * where the comment explaining \"the SDK does not know this column yet\" belongs.\n */\nexport interface CallableRow {\n id: string;\n /** `null` for a Workflow that has no key of its own yet (`WorkflowSummary`'s own\n * type) — never coerced to `\"\"` here, so the list renders exactly what the server sent. */\n key: string | null;\n displayName?: string | null;\n description?: string | null;\n archivedAt?: string | null;\n}\n\n/** `<coll>` for a kind — the wire segment AND (studio mirrors the wire) the route segment. */\nexport function callableCollection(kind: CallableKind): string {\n return COLLECTION_PATH[kind];\n}\n\n/** The studio route for a kind, or for one of its resources: `\"functions\"`, `\"functions/fn_x\"`. */\nexport function callableRoute(kind: CallableKind, id?: string): string {\n const collection = COLLECTION_PATH[kind];\n return id === undefined ? collection : `${collection}/${id}`;\n}\n\n/** The wire path for one resource: `/functions/fn_x`. */\nexport function callablePath(kind: CallableKind, id: string): string {\n return `/${COLLECTION_PATH[kind]}/${id}`;\n}\n\n/** The studio route for one resource's History tab/page (T2.3.1/T2.4.1):\n * `\"functions/fn_x/history\"`. A sibling of {@link callableRoute}, not a\n * hand-written string per call site. */\nexport function callableHistoryRoute(kind: CallableKind, id: string): string {\n return `${callableRoute(kind, id)}/history`;\n}\n\n/** `GET /<coll>`'s own query key — the literal `lib/spec-import-invalidation.ts` invalidates. */\nexport function callableListKey(kind: CallableKind, project?: string): readonly unknown[] {\n return LIST_KEY[kind](project);\n}\n\n/**\n * `GET /<coll>`. A `switch`, not a table: the three SDK calls return three different summary\n * types, and the union is what the shared chrome consumes structurally.\n */\nexport function listCallables(\n client: W6WClient,\n kind: CallableKind,\n project?: string,\n): Promise<CallableRow[]> {\n switch (kind) {\n case \"function\":\n return client.console.functions.list();\n case \"endpoint\":\n return client.console.endpoints.list();\n case \"workflow\":\n return client.workflows.list({ project });\n }\n}\n\n/**\n * `GET /<coll>/:id`, each arm returning exactly what that kind's existing repo function returns —\n * Function's `{...function, valid}` splice, Endpoint's `{endpoint, invokeUrl, …}` envelope,\n * Workflow's three-field body — never re-shaped here. The return type is the honest `unknown`:\n * the per-kind reader in the kind's own facade is what narrows it.\n */\nexport function getCallable(client: W6WClient, kind: CallableKind, id: string): Promise<unknown> {\n switch (kind) {\n case \"function\":\n return client.console.functions.get(id);\n case \"endpoint\":\n return client.console.endpoints.get(id);\n case \"workflow\":\n return client.console.workflows.get(id);\n }\n}\n\n/**\n * `POST /<coll>`, normalised to the one thing EVERY caller of a save needs — the saved resource's\n * id and key, for the invalidation below and for a create modal's own \"created\" callback. The two\n * envelopes (`{endpoint: {id, key}}`, `{workflow: {id, key}}`) and the flat one (`{id, key}`) are\n * unwrapped in the arm that knows its own shape, so no caller outside this module ever has to.\n *\n * Workflow refuses without a `project` for the same reason `repos/workflows.ts`'s own save does:\n * a missing project on a WRITE lands the definition in the account's default project instead of\n * the one the operator is looking at.\n */\nexport function saveCallable(\n client: W6WClient,\n kind: CallableKind,\n definition: unknown,\n options?: { project?: string },\n): Promise<{ id: string; key: string }> {\n switch (kind) {\n case \"function\":\n return client.console.functions\n .upsert(definition as never)\n .then((saved) => ({ id: saved.id, key: saved.key }));\n case \"endpoint\":\n return client.console.endpoints\n .upsert(definition as never)\n .then((saved) => ({ id: saved.endpoint.id, key: saved.endpoint.key }));\n case \"workflow\": {\n const project = options?.project;\n if (!project) return Promise.reject(new Error(\"No project selected yet.\"));\n return client.console.workflows.upsert(definition, { project }).then((saved) => ({\n id: saved.workflow.id,\n key: saved.workflow.key ?? \"\",\n }));\n }\n }\n}\n\n/**\n * `POST /<coll>/:id/archive`. Function and Endpoint go through the plain `apiClient.request()`\n * escape hatch (T4.1.1/A7/D-I0-7: no typed `@w6w/sdk` method exists, and adding one would drag\n * `packages/wrappers` into this task's scope for an internal route); Workflow keeps the typed\n * `console.workflows.archive` it has had since the rail's DangerZone landed.\n */\nexport function archiveCallable(\n client: W6WClient,\n kind: CallableKind,\n id: string,\n): Promise<unknown> {\n switch (kind) {\n case \"function\":\n case \"endpoint\":\n return client.request({\n method: \"POST\",\n path: `${callablePath(kind, encodeURIComponent(id))}/archive`,\n });\n case \"workflow\":\n return client.console.workflows.archive(id);\n }\n}\n\n/** `DELETE /<coll>/:id` — same split, and the same reasoning, as {@link archiveCallable}. */\nexport function deleteCallable(\n client: W6WClient,\n kind: CallableKind,\n id: string,\n): Promise<unknown> {\n switch (kind) {\n case \"function\":\n case \"endpoint\":\n return client.request({ method: \"DELETE\", path: callablePath(kind, encodeURIComponent(id)) });\n case \"workflow\":\n return client.console.workflows.delete(id);\n }\n}\n\n/**\n * The editable definition out of {@link getCallable}'s per-kind answer: Function/Endpoint through\n * `callableRecord` (the same split the editor's draft reads), Workflow its `workflow` body.\n */\nfunction editableDefinition(kind: CallableKind, data: unknown): Record<string, unknown> | null {\n if (kind !== \"workflow\") return callableRecord(kind, data)?.definition ?? null;\n const body = (data as { workflow?: unknown } | null)?.workflow;\n return typeof body === \"object\" && body !== null && !Array.isArray(body)\n ? (body as Record<string, unknown>)\n : null;\n}\n\n/**\n * Duplicate: `GET /<coll>/:id`, then `POST /<coll>` of {@link duplicateDefinition}'s copy — a new\n * id, a sibling-free key and a \"(copy)\" name. The copy is a fresh draft: never published, enabled\n * at the server's default. `siblings` is the kind's list as the caller has it (keys and names a\n * copy must not repeat); the server's own key index still refuses a race, as a 409.\n */\nexport async function duplicateCallable(\n client: W6WClient,\n kind: CallableKind,\n id: string,\n siblings: DuplicateSiblings,\n options?: { project?: string },\n): Promise<{ id: string; key: string }> {\n const source = editableDefinition(kind, await getCallable(client, kind, id));\n if (!source) throw new Error(`Could not read the ${kind} to duplicate.`);\n const copy = duplicateDefinition(kind, source, newCallableId(kind), siblings);\n return saveCallable(client, kind, copy, options);\n}\n\n/**\n * `useQuery` over {@link listCallables}, keyed by {@link callableListKey}. Generic over the row\n * type so a kind's own facade can narrow it to that kind's widened summary (Function's\n * `archivedAt`, Endpoint's `status`/`incomplete`) without a cast at the call site.\n */\nexport function useCallableListQuery<Row extends CallableRow = CallableRow>(\n kind: CallableKind,\n enabled = true,\n project?: string,\n) {\n const apiClient = useEmbedClient();\n return useQuery<Row[]>({\n queryKey: callableListKey(kind, project),\n queryFn: () => listCallables(apiClient, kind, project) as Promise<Row[]>,\n enabled,\n });\n}\n\n/** `useQuery` over {@link getCallable}, keyed by {@link callableKey}. */\nexport function useCallableQuery<Def = unknown>(kind: CallableKind, id: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery<Def>({\n queryKey: callableKey(kind, id),\n queryFn: () => getCallable(apiClient, kind, id) as Promise<Def>,\n enabled,\n });\n}\n\n/**\n * `useMutation` over {@link saveCallable}. `onSuccess` routes through the SAME\n * `invalidateSavedCallable` helper every save in studio already uses, with the SAME two keys —\n * the list AND the saved resource — so the Function arm's invalidation is the one\n * `repos/functions.ts` performs today, byte for byte.\n */\nexport function useSaveCallableMutation(kind: CallableKind, options?: { project?: string }) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (definition: unknown) => saveCallable(apiClient, kind, definition, options),\n onSuccess: (saved) =>\n invalidateSavedCallable(qc, callableListKey(kind), callableKey(kind, saved.id)),\n });\n}\n\n/** `useMutation` over {@link archiveCallable} — the list key, so the row's archived badge\n * refreshes and the rail's Delete control appears in Archive's place. */\nexport function useArchiveCallableMutation(kind: CallableKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => archiveCallable(apiClient, kind, id),\n onSuccess: () => qc.invalidateQueries({ queryKey: callableListKey(kind) }),\n });\n}\n\n/** `useMutation` over {@link deleteCallable}. */\nexport function useDeleteCallableMutation(kind: CallableKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => deleteCallable(apiClient, kind, id),\n onSuccess: () => qc.invalidateQueries({ queryKey: callableListKey(kind) }),\n });\n}\n\n/** `useMutation` over {@link duplicateCallable}; refreshes every project's copy of the list. */\nexport function useDuplicateCallableMutation(kind: CallableKind, options?: { project?: string }) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; siblings: DuplicateSiblings }) =>\n duplicateCallable(apiClient, kind, vars.id, vars.siblings, options),\n onSuccess: () => qc.invalidateQueries({ queryKey: [callableListKey(kind)[0]] }),\n });\n}\n"],"names":["RESOURCE_KEY","id","callableKey","kind","invalidateSavedCallable","qc","listKey","ID_ALPHABET","REJECT_AT","defaultBytes","n","newId","prefix","len","bytes","out","b","CALLABLE_DESCRIPTORS","descriptorFor","newCallableId","KEY_MAX","copyDisplayName","name","taken","used","t","base","candidate","copyKey","key","suffix","duplicateDefinition","source","siblings","_key","rest","copy","oldId","shown","COLLECTION_PATH","LIST_KEY","project","callableCollection","callableRoute","collection","callablePath","callableHistoryRoute","callableListKey","listCallables","client","getCallable","saveCallable","definition","options","saved","archiveCallable","deleteCallable","editableDefinition","data","_a","callableRecord","body","duplicateCallable","useCallableListQuery","enabled","apiClient","useEmbedClient","useQuery","useCallableQuery","useSaveCallableMutation","useQueryClient","useMutation","useArchiveCallableMutation","useDeleteCallableMutation","useDuplicateCallableMutation","vars"],"mappings":";;;AAeA,MAAMA,IAAyE;AAAA,EAC7E,UAAU,CAACC,MAAO,CAAC,YAAYA,CAAE;AAAA,EACjC,UAAU,CAACA,MAAO,CAAC,YAAYA,CAAE;AAAA,EACjC,UAAU,CAACA,MAAO,CAAC,YAAYA,CAAE;AACnC;AAGO,SAASC,EAAYC,GAAoBF,GAAgC;AAC9E,SAAOD,EAAaG,CAAI,EAAEF,CAAE;AAC9B;ACDO,SAASG,EACdC,GACAC,GACAJ,GACM;AACN,EAAAG,EAAG,kBAAkB,EAAE,UAAUC,EAAA,CAAS,GAC1CD,EAAG,kBAA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W,MAAMI,EAAG,kBAAkB,EAAE,UAAU0C,EAAgB5C,CAAI,EAAA,CAAG;AAAA,EAAA,CAC1E;AACH;AAGO,SAASsE,EAA0BtE,GAAoB;AAC5D,QAAM8D,IAAYC,EAAA,GACZ7D,IAAKiE,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACtE,MAAeuD,EAAeS,GAAW9D,GAAMF,CAAE;AAAA,IAC9D,WAAW,MAAMI,EAAG,kBAAkB,EAAE,UAAU0C,EAAgB5C,CAAI,EAAA,CAAG;AAAA,EAAA,CAC1E;AACH;AAGO,SAASuE,EAA6BvE,GAAoBkD,GAAgC;AAC/F,QAAMY,IAAYC,EAAA,GACZ7D,IAAKiE,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACI,MACXb,EAAkBG,GAAW9D,GAAMwE,EAAK,IAAIA,EAAK,UAAUtB,CAAO;AAAA,IACpE,WAAW,MAAMhD,EAAG,kBAAkB,EAAE,UAAU,CAAC0C,EAAgB5C,CAAI,EAAE,CAAC,CAAC,GAAG;AAAA,EAAA,CAC/E;AACH;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { STATE_LIMITS as
|
|
2
|
-
import { parse as
|
|
1
|
+
import { STATE_LIMITS as f } from "@w6w/expr";
|
|
2
|
+
import { parse as l } from "yaml";
|
|
3
3
|
const y = /* @__PURE__ */ new Set(["string", "number", "boolean", "object", "array"]);
|
|
4
4
|
function p(e) {
|
|
5
5
|
if (!Array.isArray(e)) return [];
|
|
6
6
|
const n = [];
|
|
7
7
|
for (const t of e) {
|
|
8
8
|
if (typeof t != "object" || t === null || Array.isArray(t)) continue;
|
|
9
|
-
const r = t,
|
|
10
|
-
typeof r.type == "string" && y.has(r.type) && (
|
|
9
|
+
const r = t, i = { key: typeof r.key == "string" ? r.key : "" };
|
|
10
|
+
typeof r.type == "string" && y.has(r.type) && (i.type = r.type), typeof r.required == "boolean" && (i.required = r.required), r.default !== void 0 && (i.default = r.default), n.push(i);
|
|
11
11
|
}
|
|
12
12
|
return n;
|
|
13
13
|
}
|
|
@@ -20,15 +20,15 @@ function m(e) {
|
|
|
20
20
|
}
|
|
21
21
|
function h(e) {
|
|
22
22
|
const n = /* @__PURE__ */ new Set(), t = [];
|
|
23
|
-
return e.forEach((r,
|
|
24
|
-
n.has(r.key) ? t.push(
|
|
23
|
+
return e.forEach((r, i) => {
|
|
24
|
+
r.key !== "" && (n.has(r.key) ? t.push(i) : n.add(r.key));
|
|
25
25
|
}), t;
|
|
26
26
|
}
|
|
27
27
|
function b(e, n, t) {
|
|
28
|
-
const r = /* @__PURE__ */ new Set(),
|
|
29
|
-
for (const
|
|
30
|
-
|
|
31
|
-
return
|
|
28
|
+
const r = /* @__PURE__ */ new Set(), i = [];
|
|
29
|
+
for (const o of [...e.slice(0, n).map((s) => s.key), ...t])
|
|
30
|
+
o === "" || r.has(o) || (r.add(o), i.push(o));
|
|
31
|
+
return i;
|
|
32
32
|
}
|
|
33
33
|
function c(e) {
|
|
34
34
|
return typeof e == "object" && e !== null && !Array.isArray(e) && e.type === "expr" && Array.isArray(e.parts);
|
|
@@ -59,7 +59,7 @@ function S(e) {
|
|
|
59
59
|
} catch {
|
|
60
60
|
return { ok: !1, reason: "invalid_json" };
|
|
61
61
|
}
|
|
62
|
-
return a(n) ? JSON.stringify(n).length >
|
|
62
|
+
return a(n) ? JSON.stringify(n).length > f.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
63
|
}
|
|
64
64
|
function j(e, n) {
|
|
65
65
|
if (!e) return [];
|
|
@@ -123,7 +123,7 @@ function u(e) {
|
|
|
123
123
|
}
|
|
124
124
|
else if (e.format === "yaml")
|
|
125
125
|
try {
|
|
126
|
-
n =
|
|
126
|
+
n = l(e.content);
|
|
127
127
|
} catch {
|
|
128
128
|
return null;
|
|
129
129
|
}
|
|
@@ -136,7 +136,7 @@ function q(e) {
|
|
|
136
136
|
const t = u(n);
|
|
137
137
|
if (!t) return { key: n.key };
|
|
138
138
|
const r = Object.keys(t);
|
|
139
|
-
return r.length > 0 ? { key: n.key, fields: r.map((
|
|
139
|
+
return r.length > 0 ? { key: n.key, fields: r.map((i) => ({ key: i })) } : { key: n.key };
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
function F(e) {
|
|
@@ -145,8 +145,8 @@ function F(e) {
|
|
|
145
145
|
n[`documents.${t.key}`] = t.content;
|
|
146
146
|
const r = u(t);
|
|
147
147
|
if (r)
|
|
148
|
-
for (const [
|
|
149
|
-
n[`documents.${t.key}.${
|
|
148
|
+
for (const [i, o] of Object.entries(r))
|
|
149
|
+
n[`documents.${t.key}.${i}`] = o;
|
|
150
150
|
}
|
|
151
151
|
return n;
|
|
152
152
|
}
|
|
@@ -166,4 +166,4 @@ export {
|
|
|
166
166
|
g as t,
|
|
167
167
|
m as v
|
|
168
168
|
};
|
|
169
|
-
//# sourceMappingURL=document-sources-
|
|
169
|
+
//# sourceMappingURL=document-sources-Khcw2zB5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-sources-Khcw2zB5.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 // A blank key is a row not yet named, not a duplicate: adding two rows must not warn.\n if (r.key === \"\") return;\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","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,EAAE,MAAM,GAAA;AAC5E,IAAI,OAAOA,EAAE,QAAS,YAAYL,EAAe,IAAIK,EAAE,IAAI,MACzDC,EAAI,OAAOD,EAAE,OAEX,OAAOA,EAAE,YAAa,cAAWC,EAAI,WAAWD,EAAE,WAClDA,EAAE,YAAY,WAAWC,EAAI,UAAUD,EAAE,UAC7CF,EAAI,KAAKG,CAAG;AAAA,EACd;AACA,SAAOH;AACT;AAsBO,SAASI,EAAiBC,GAAgE;AAC/F,MAAIA,EAAK,WAAW;AACpB,WAAOA,EAAK,IAAI,CAACC,MAAM;AACrB,YAAMN,IAA2B,EAAE,KAAKM,EAAE,IAAA;AAC1C,aAAIA,EAAE,SAAS,WAAWN,EAAI,OAAOM,EAAE,OACnCA,EAAE,aAAUN,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AYA,MAAW,QAAQ,MAAM,QAAQA,CAAM,IAAU,OAC5EA;AACT;AASO,SAASe,EAAuBC,GAA+B;AACpE,SAAOA,EAAK,IAAI,CAACC,MAAM;AACrB,UAAMjB,IAASY,EAAYK,CAAC;AAC5B,QAAI,CAACjB,EAAQ,QAAO,EAAE,KAAKiB,EAAE,IAAA;AAC7B,UAAMC,IAAO,OAAO,KAAKlB,CAAM;AAC/B,WAAOkB,EAAK,SAAS,IAAI,EAAE,KAAKD,EAAE,KAAK,QAAQC,EAAK,IAAI,CAACC,OAAS,EAAE,KAAAA,IAAM,EAAA,IAAM,EAAE,KAAKF,EAAE,IAAA;AAAA,EAC3F,CAAC;AACH;AAUO,SAASG,EAAqBJ,GAAsC;AACzE,QAAMtC,IAA+B,CAAA;AACrC,aAAWuC,KAAKD,GAAM;AACpB,IAAAtC,EAAI,aAAauC,EAAE,GAAG,EAAE,IAAIA,EAAE;AAC9B,UAAMjB,IAASY,EAAYK,CAAC;AAC5B,QAAKjB;AACL,iBAAW,CAACmB,GAAKE,CAAK,KAAK,OAAO,QAAQrB,CAAM;AAC9C,QAAAtB,EAAI,aAAauC,EAAE,GAAG,IAAIE,CAAG,EAAE,IAAIE;AAAA,EAEvC;AACA,SAAO3C;AACT;"}
|
package/dist/draft.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
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-DjW7_9qb.js";
|
|
6
6
|
export {
|
|
7
7
|
a as AUTOSAVE_DEBOUNCE_MS,
|
|
8
8
|
E as DraftRegistryProvider,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WorkflowVariableRow } from '../lib/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The workflow's declared inputs (`variables`, its public input schema), edited in a wide modal
|
|
4
|
+
* opened from the Data rail: the rail is too narrow for key, type, default and required side by
|
|
5
|
+
* side. Every edit goes through `onVariablesChange` (the auto-saver), exactly as the rail's inline
|
|
6
|
+
* editor did, so "Done" only closes.
|
|
7
|
+
*/
|
|
8
|
+
export declare function WorkflowInputsModal({ variables, onVariablesChange, onClose, }: {
|
|
9
|
+
variables: WorkflowVariableRow[];
|
|
10
|
+
onVariablesChange: (next: WorkflowVariableRow[]) => void;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WorkflowVariableRow } from '../lib/index.ts';
|
|
2
|
-
/** Shared workflow input editor
|
|
2
|
+
/** Shared workflow input editor: the Data rail's Workflow inputs modal and the legacy settings dialog. */
|
|
3
3
|
export declare function WorkflowVariablesEditor({ variables, onVariablesChange, }: {
|
|
4
4
|
variables: WorkflowVariableRow[];
|
|
5
5
|
onVariablesChange: (next: WorkflowVariableRow[]) => void;
|