@w6w/embed 0.2.34 → 0.2.35
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-glk2zg1r.js → CreateFunctionModal-CYNHJUGJ.js} +3 -3
- package/dist/{CreateFunctionModal-glk2zg1r.js.map → CreateFunctionModal-CYNHJUGJ.js.map} +1 -1
- package/dist/{DocumentFormModal-B3OkvI5v.js → DocumentFormModal-CLmdGx34.js} +2 -2
- package/dist/{DocumentFormModal-B3OkvI5v.js.map → DocumentFormModal-CLmdGx34.js.map} +1 -1
- package/dist/ImportSpecModal-BzEyiNWD.js +378 -0
- package/dist/ImportSpecModal-BzEyiNWD.js.map +1 -0
- package/dist/WorkflowEditor-CxTuK8_d.js +1272 -0
- package/dist/WorkflowEditor-CxTuK8_d.js.map +1 -0
- package/dist/{apps-CFWdgGst.js → apps-CyEszfIu.js} +33 -33
- package/dist/{apps-CFWdgGst.js.map → apps-CyEszfIu.js.map} +1 -1
- package/dist/callable-row-actions-BPBPflMn.js +56 -0
- package/dist/callable-row-actions-BPBPflMn.js.map +1 -0
- package/dist/callables-dLF2IcwA.js +317 -0
- package/dist/callables-dLF2IcwA.js.map +1 -0
- package/dist/chrome/TagEditor.d.ts +6 -1
- package/dist/chrome/workspace.d.ts +16 -0
- package/dist/documents-hgltn0xe.js +1017 -0
- package/dist/documents-hgltn0xe.js.map +1 -0
- package/dist/draft.mjs +1 -1
- package/dist/editor/WaitingForm.d.ts +19 -0
- package/dist/{editor-apps-ShwCmvLY.js → editor-apps-DsGrGKfe.js} +3 -3
- package/dist/{editor-apps-ShwCmvLY.js.map → editor-apps-DsGrGKfe.js.map} +1 -1
- package/dist/{editor-tools-rY9nddqr.js → editor-tools-Ct7YPPj8.js} +682 -784
- package/dist/editor-tools-Ct7YPPj8.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +18 -18
- package/dist/{endpoints-zOuwci2U.js → endpoints-DJxXRh-I.js} +12 -12
- package/dist/{endpoints-zOuwci2U.js.map → endpoints-DJxXRh-I.js.map} +1 -1
- package/dist/forms.mjs +1 -1
- package/dist/index.mjs +140 -115
- package/dist/index.mjs.map +1 -1
- package/dist/lib/callable-row-actions.d.ts +17 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/run-event-stream.d.ts +122 -0
- package/dist/lib/tag-editor.d.ts +6 -0
- package/dist/lib/workflow-live-run.d.ts +7 -0
- package/dist/lib/workflow-validity.d.ts +7 -1
- package/dist/lib.mjs +52 -47
- package/dist/lists/CallableKindList.d.ts +12 -0
- package/dist/lists/CallableRowParts.d.ts +8 -1
- package/dist/lists/EndpointList.d.ts +3 -0
- package/dist/lists/FunctionList.d.ts +3 -0
- package/dist/lists/WorkflowList.d.ts +3 -0
- package/dist/lists.d.ts +1 -0
- package/dist/lists.mjs +1589 -1513
- package/dist/lists.mjs.map +1 -1
- package/dist/rail.mjs +1 -1
- package/dist/repos/callables.d.ts +25 -0
- package/dist/repos/documents.d.ts +9 -1
- package/dist/repos/saved-file-names.d.ts +10 -0
- package/dist/repos/workflows.d.ts +19 -13
- package/dist/repos.mjs +333 -328
- package/dist/{setup-incomplete-BHs3Lpfy.js → setup-incomplete-6PAbN0EW.js} +50 -49
- package/dist/setup-incomplete-6PAbN0EW.js.map +1 -0
- package/dist/spec-import-BKyfhTYG.js +200 -0
- package/dist/spec-import-BKyfhTYG.js.map +1 -0
- package/dist/{use-callable-draft-w4tDTYcb.js → use-callable-draft-7HwfTuYQ.js} +3 -3
- package/dist/{use-callable-draft-w4tDTYcb.js.map → use-callable-draft-7HwfTuYQ.js.map} +1 -1
- package/package.json +3 -3
- package/src/styles.css +43 -0
- package/dist/ImportSpecModal-SQvTwtcX.js +0 -252
- package/dist/ImportSpecModal-SQvTwtcX.js.map +0 -1
- package/dist/WorkflowEditor-D2EfEP-U.js +0 -1201
- package/dist/WorkflowEditor-D2EfEP-U.js.map +0 -1
- package/dist/callable-record-Bhxim8C1.js +0 -14
- package/dist/callable-record-Bhxim8C1.js.map +0 -1
- package/dist/callables-B49tS2vv.js +0 -297
- package/dist/callables-B49tS2vv.js.map +0 -1
- package/dist/editor-tools-rY9nddqr.js.map +0 -1
- package/dist/setup-incomplete-BHs3Lpfy.js.map +0 -1
- package/dist/spec-import-CPbDnnuv.js +0 -272
- package/dist/spec-import-CPbDnnuv.js.map +0 -1
- package/dist/workflows-RhR8kwt7.js +0 -667
- package/dist/workflows-RhR8kwt7.js.map +0 -1
|
@@ -1,297 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,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