@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
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import { useQueryClient as r, useMutation as u } from "@tanstack/react-query";
|
|
2
|
-
import { path as d } from "@w6w/sdk";
|
|
3
|
-
import { u as s } from "./client-context-CX61Bgw-.js";
|
|
4
|
-
import { a as l, c as p, k as f, n as w, u as h, m as b, i as c, o as k } from "./callables-tOlflvbl.js";
|
|
5
|
-
import "@w6w/sdk/console";
|
|
6
|
-
const v = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", T = 248, E = (n) => crypto.getRandomValues(new Uint8Array(n));
|
|
7
|
-
function F(n, e = 16, t = E) {
|
|
8
|
-
let o = "";
|
|
9
|
-
for (; o.length < e; )
|
|
10
|
-
for (const i of t(Math.max(e - o.length, 8)))
|
|
11
|
-
if (!(i >= T) && (o += v[i % 62], o.length === e))
|
|
12
|
-
break;
|
|
13
|
-
return `${n}_${o}`;
|
|
14
|
-
}
|
|
15
|
-
const S = {
|
|
16
|
-
function: {
|
|
17
|
-
kind: "function",
|
|
18
|
-
listTitle: "Functions",
|
|
19
|
-
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.',
|
|
20
|
-
emptyCopy: "None yet — click “New function” to create one, or “Import” to bring in a spec document.",
|
|
21
|
-
newLabel: "+ New function",
|
|
22
|
-
newIdPrefix: "fn",
|
|
23
|
-
importOpenTestId: "functions-import-open",
|
|
24
|
-
showArchivedTestId: "functions-show-archived",
|
|
25
|
-
archivedBadgeTestId: "function-archived",
|
|
26
|
-
openRowTitle: "Open this function in the editor.",
|
|
27
|
-
editor: {
|
|
28
|
-
backLabel: "← Functions",
|
|
29
|
-
newTitle: "New function",
|
|
30
|
-
notFoundTitle: "Function not found",
|
|
31
|
-
saveLabel: "Save"
|
|
32
|
-
},
|
|
33
|
-
settings: {
|
|
34
|
-
canEditKey: !0,
|
|
35
|
-
hasTags: !0,
|
|
36
|
-
namePlaceholder: "Send Email",
|
|
37
|
-
keyPlaceholder: "send-email",
|
|
38
|
-
keyHintSuffix: ""
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
endpoint: {
|
|
42
|
-
kind: "endpoint",
|
|
43
|
-
listTitle: "Endpoints",
|
|
44
|
-
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.",
|
|
45
|
-
emptyCopy: "None yet — click “New endpoint” to create one.",
|
|
46
|
-
newLabel: "+ New endpoint",
|
|
47
|
-
newIdPrefix: "ep",
|
|
48
|
-
importOpenTestId: "endpoints-import-open",
|
|
49
|
-
showArchivedTestId: "endpoints-show-archived",
|
|
50
|
-
archivedBadgeTestId: "endpoint-archived",
|
|
51
|
-
openRowTitle: "Open this endpoint in the editor.",
|
|
52
|
-
editor: {
|
|
53
|
-
backLabel: "← Endpoints",
|
|
54
|
-
newTitle: "New endpoint",
|
|
55
|
-
notFoundTitle: "Endpoint not found",
|
|
56
|
-
saveLabel: "Save"
|
|
57
|
-
},
|
|
58
|
-
settings: {
|
|
59
|
-
canEditKey: !1,
|
|
60
|
-
hasTags: !0,
|
|
61
|
-
namePlaceholder: "My endpoint",
|
|
62
|
-
keyPlaceholder: "send-email",
|
|
63
|
-
keyHintSuffix: ""
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
workflow: {
|
|
67
|
-
kind: "workflow",
|
|
68
|
-
listTitle: "Workflows",
|
|
69
|
-
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.",
|
|
70
|
-
emptyCopy: "None yet — click “New workflow” to create one.",
|
|
71
|
-
newLabel: "+ New workflow",
|
|
72
|
-
newIdPrefix: "wf",
|
|
73
|
-
importOpenTestId: "workflows-import-open",
|
|
74
|
-
showArchivedTestId: "workflows-show-archived",
|
|
75
|
-
archivedBadgeTestId: "workflow-archived",
|
|
76
|
-
openRowTitle: "Open this workflow in the visual editor.",
|
|
77
|
-
editor: {
|
|
78
|
-
backLabel: "← Workflows",
|
|
79
|
-
newTitle: "New workflow",
|
|
80
|
-
notFoundTitle: "Workflow not found",
|
|
81
|
-
saveLabel: "Save"
|
|
82
|
-
},
|
|
83
|
-
settings: {
|
|
84
|
-
canEditKey: !0,
|
|
85
|
-
hasTags: !0,
|
|
86
|
-
namePlaceholder: "My workflow",
|
|
87
|
-
keyPlaceholder: "unset",
|
|
88
|
-
keyHintSuffix: " Leave empty to unset."
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
function I(n) {
|
|
93
|
-
return S[n];
|
|
94
|
-
}
|
|
95
|
-
function x(n) {
|
|
96
|
-
return F(I(n).newIdPrefix);
|
|
97
|
-
}
|
|
98
|
-
const g = p("function"), D = "2";
|
|
99
|
-
function K(n) {
|
|
100
|
-
return n.console.functions.list();
|
|
101
|
-
}
|
|
102
|
-
function R(n = !0) {
|
|
103
|
-
return b("function", n);
|
|
104
|
-
}
|
|
105
|
-
const C = (n) => l("function", n);
|
|
106
|
-
function Q(n, e) {
|
|
107
|
-
return n.console.functions.get(e);
|
|
108
|
-
}
|
|
109
|
-
function W(n, e = !0) {
|
|
110
|
-
return h("function", n, e);
|
|
111
|
-
}
|
|
112
|
-
function _() {
|
|
113
|
-
return k("function");
|
|
114
|
-
}
|
|
115
|
-
function q() {
|
|
116
|
-
const n = s(), e = r();
|
|
117
|
-
return u({
|
|
118
|
-
mutationFn: (t) => n.console.functions.upsert(t.definition, {
|
|
119
|
-
ifUnmodifiedSince: t.ifUnmodifiedSince
|
|
120
|
-
}),
|
|
121
|
-
onSuccess: (t) => c(e, g, C(t.id))
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function M(n, e, t, o) {
|
|
125
|
-
const i = { inputs: t };
|
|
126
|
-
return (o == null ? void 0 : o.allowUnpublished) === !0 && (i.allowUnpublished = !0), n.request({
|
|
127
|
-
method: "POST",
|
|
128
|
-
path: d`/functions/${e}/invoke`,
|
|
129
|
-
body: i
|
|
130
|
-
}).then(({ body: a }) => ({
|
|
131
|
-
output: a.output,
|
|
132
|
-
invocationId: a.invocationId,
|
|
133
|
-
status: a.status,
|
|
134
|
-
durationMs: a.durationMs
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
function B() {
|
|
138
|
-
const n = s();
|
|
139
|
-
return u({
|
|
140
|
-
mutationFn: (e) => M(n, e.id, e.inputs, { allowUnpublished: !0 })
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
function H() {
|
|
144
|
-
return f("function");
|
|
145
|
-
}
|
|
146
|
-
function V() {
|
|
147
|
-
return w("function");
|
|
148
|
-
}
|
|
149
|
-
function $(n) {
|
|
150
|
-
return n.status !== void 0 ? n.status !== "ready" : n.incomplete === !0;
|
|
151
|
-
}
|
|
152
|
-
const G = "2", m = p("endpoint");
|
|
153
|
-
function j(n = !0) {
|
|
154
|
-
return b("endpoint", n);
|
|
155
|
-
}
|
|
156
|
-
function z(n, e) {
|
|
157
|
-
return n.console.endpoints.get(e);
|
|
158
|
-
}
|
|
159
|
-
const y = (n) => l("endpoint", n);
|
|
160
|
-
function J(n, e = !0) {
|
|
161
|
-
return h("endpoint", n, e);
|
|
162
|
-
}
|
|
163
|
-
function X() {
|
|
164
|
-
const n = s(), e = r();
|
|
165
|
-
return u({
|
|
166
|
-
// Same widening as `getEndpoint` — the save's 201 carries `invokeUrls[]` too.
|
|
167
|
-
mutationFn: (t) => n.console.endpoints.upsert(t),
|
|
168
|
-
onSuccess: (t) => c(e, m, y(t.endpoint.id))
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
function Y() {
|
|
172
|
-
const n = s(), e = r();
|
|
173
|
-
return u({
|
|
174
|
-
mutationFn: (t) => n.console.endpoints.upsert(t.definition, {
|
|
175
|
-
ifUnmodifiedSince: t.ifUnmodifiedSince
|
|
176
|
-
}),
|
|
177
|
-
onSuccess: (t) => c(e, m, y(t.endpoint.id))
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
function N(n, e, t, o) {
|
|
181
|
-
const i = { input: t };
|
|
182
|
-
return (o == null ? void 0 : o.allowUnpublished) === !0 && (i.allowUnpublished = !0), n.request({
|
|
183
|
-
method: "POST",
|
|
184
|
-
path: d`/endpoints/${e}/invoke`,
|
|
185
|
-
body: i
|
|
186
|
-
}).then((a) => a.body);
|
|
187
|
-
}
|
|
188
|
-
function Z() {
|
|
189
|
-
const n = s();
|
|
190
|
-
return u({
|
|
191
|
-
mutationFn: (e) => N(n, e.id, e.input, { allowUnpublished: !0 })
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
function nn() {
|
|
195
|
-
return f("endpoint");
|
|
196
|
-
}
|
|
197
|
-
function en() {
|
|
198
|
-
return w("endpoint");
|
|
199
|
-
}
|
|
200
|
-
export {
|
|
201
|
-
B as A,
|
|
202
|
-
S as C,
|
|
203
|
-
G as E,
|
|
204
|
-
D as F,
|
|
205
|
-
v as I,
|
|
206
|
-
X as a,
|
|
207
|
-
R as b,
|
|
208
|
-
_ as c,
|
|
209
|
-
I as d,
|
|
210
|
-
y as e,
|
|
211
|
-
m as f,
|
|
212
|
-
C as g,
|
|
213
|
-
g as h,
|
|
214
|
-
z as i,
|
|
215
|
-
Q as j,
|
|
216
|
-
N as k,
|
|
217
|
-
M as l,
|
|
218
|
-
$ as m,
|
|
219
|
-
x as n,
|
|
220
|
-
K as o,
|
|
221
|
-
F as p,
|
|
222
|
-
nn as q,
|
|
223
|
-
H as r,
|
|
224
|
-
en as s,
|
|
225
|
-
V as t,
|
|
226
|
-
j as u,
|
|
227
|
-
J as v,
|
|
228
|
-
W as w,
|
|
229
|
-
Y as x,
|
|
230
|
-
q as y,
|
|
231
|
-
Z as z
|
|
232
|
-
};
|
|
233
|
-
//# sourceMappingURL=endpoints-DArAqoLT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoints-DArAqoLT.js","sources":["../src/lib/new-id.ts","../src/lib/callable-descriptors.ts","../src/repos/functions.ts","../src/repos/endpoints.ts"],"sourcesContent":["/**\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","import { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { path, type W6WClient } from \"@w6w/sdk\";\nimport type { FunctionSummary as SdkFunctionSummary } from \"@w6w/sdk/console\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n/**\n * The Function-bound facade over the kind-parametrised repo (`src/repos/callables.ts`, T4.2.1).\n *\n * Everything here that is not Function-specific is one line delegating to `callables.ts` with\n * `\"function\"` bound in — the list/get queries, the save mutation, archive and delete — so the\n * Function arm of every kind-wide behaviour has exactly ONE implementation to fix. What stays is\n * what only a Function has: the `manifestVersion: \"2\"` literal, the SDK's Function type re-exports,\n * the `valid`-carrying summary widening, and the run-plane invoke (`client.request`)\n * that no other kind's page uses.\n *\n * The delegations keep their original names and call shapes on purpose: `ui/rail/SettingsTool.tsx`,\n * `ui/rail/AliasesTool.tsx`, `ui/rail/ErrorHandlingTool.tsx`, `components/TargetSelector.tsx`,\n * `components/FunctionIdentityModal.tsx` and `api/w6wApiFacade.tsx` all import from here, and this\n * node moves no behaviour — only where the code lives.\n */\nimport { callableKey } from \"../lib/callable-kind.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\nimport {\n callableListKey,\n useArchiveCallableMutation,\n useCallableListQuery,\n useCallableQuery,\n useDeleteCallableMutation,\n useSaveCallableMutation,\n} from \"./callables.ts\";\n\nexport type {\n FunctionDef,\n FunctionImpl,\n FunctionInput,\n FunctionOutputField,\n} from \"@w6w/sdk/console\";\n\n/** A Function list row — the SDK's own summary (it carries `archivedAt` since W-12). */\nexport type FunctionSummary = SdkFunctionSummary;\n\n/** The list key {@link useFunctionsQuery} reads — `callables.ts`'s own\n * `callableListKey(\"function\")`, kept as a named export because\n * `lib/spec-import-invalidation.ts` invalidates it by value. */\nexport const functionsKey = callableListKey(\"function\");\n\n/** Function definitions carry `manifestVersion: \"2\"` - the one literal, shared\n * by the editor's blank draft and the create modal's first POST. */\nexport const FUNCTION_MANIFEST_VERSION = \"2\";\n\nexport function listFunctions(client: W6WClient) {\n return client.console.functions.list();\n}\n\nexport function useFunctionsQuery(enabled = true) {\n return useCallableListQuery<FunctionSummary>(\"function\", enabled);\n}\n\nexport const functionKey = (id: string) => callableKey(\"function\", id);\n\n/** The Function arm's own reader: the SDK's typed `get`, whose `{...function, valid}` splice is\n * what `FunctionEditor` hydrates its draft from (pin 5 — the server computes `valid`; studio\n * never reimplements the check). */\nexport function getFunction(client: W6WClient, id: string) {\n return client.console.functions.get(id);\n}\n\nexport function useFunctionQuery(id: string, enabled = true) {\n return useCallableQuery<Awaited<ReturnType<typeof getFunction>>>(\"function\", id, enabled);\n}\n\nexport function useSaveFunctionMutation() {\n return useSaveCallableMutation(\"function\");\n}\n\n/**\n * The GUARDED Function save: `console.functions.upsert(definition, {ifUnmodifiedSince})`, so a\n * save made from a stale copy answers `409 function_stale` instead of overwriting the newer one.\n * `ifUnmodifiedSince` is REQUIRED in the variables (pass `null` to opt out explicitly) so a call\n * site cannot forget the token; it is the `updatedAt` of the copy the definition was edited from\n * (`callableRecord(\"function\", …).updatedAt`). Same invalidation as {@link useSaveFunctionMutation}\n * (list + the saved resource's key); resolves `{id, key, updatedAt}`. Additive: the unguarded\n * hook's `mutate(definition)` shape is unchanged.\n */\nexport function useGuardedSaveFunctionMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { definition: unknown; ifUnmodifiedSince: string | null }) =>\n apiClient.console.functions.upsert(vars.definition as never, {\n ifUnmodifiedSince: vars.ifUnmodifiedSince,\n }),\n onSuccess: (saved) => invalidateSavedCallable(qc, functionsKey, functionKey(saved.id)),\n });\n}\n\n/**\n * One test invoke's result: the Function's own output, plus the platform's\n * record of the attempt.\n *\n * The two are kept apart rather than merged because they answer different\n * questions, and merging them is what the invocation envelope exists to stop:\n * a vendor payload reading `{\"statusCode\": 202}` is SendGrid describing its own\n * request, while `status` here is whether w6w considered the call a success.\n * The frame fields are optional — an older server sends only the output.\n */\nexport interface FunctionInvokeResult {\n output: unknown;\n invocationId?: string;\n status?: string;\n durationMs?: number;\n}\n\n/**\n * `POST /functions/:id/invoke` through the `client.request` escape hatch (D2: no wrappers change).\n * The route answers the invocation frame `{ kind: \"function\", output, invocationId, status,\n * durationMs }`. `allowUnpublished: true` is sent ONLY when the caller opts in (the editor's Test\n * invoke hook); every other caller keeps the publish gate, so the key is absent otherwise.\n */\nexport function invokeFunction(\n client: W6WClient,\n id: string,\n inputs: Record<string, unknown>,\n opts?: { allowUnpublished?: boolean },\n): Promise<FunctionInvokeResult> {\n const body: Record<string, unknown> = { inputs };\n if (opts?.allowUnpublished === true) body.allowUnpublished = true;\n return client\n .request<Record<string, unknown>>({\n method: \"POST\",\n path: path`/functions/${id}/invoke`,\n body,\n })\n .then(({ body: res }) => ({\n output: res.output,\n invocationId: res.invocationId as string | undefined,\n status: res.status as string | undefined,\n durationMs: res.durationMs as number | undefined,\n }));\n}\n\nexport function useInvokeFunctionMutation() {\n const apiClient = useEmbedClient();\n return useMutation({\n mutationFn: (vars: { id: string; inputs: Record<string, unknown> }) =>\n invokeFunction(apiClient, vars.id, vars.inputs, { allowUnpublished: true }),\n });\n}\n\n/**\n * T4.1.1/A7/D-I0-7: `POST /functions/:id/archive`, `DELETE /functions/:id` — the Function arm of\n * `callables.ts`'s generic pair (the plain `apiClient.request()` escape hatch, NOT a typed\n * `@w6w/sdk` method, which would drag `packages/wrappers` into this task's scope for two internal\n * routes). Both invalidate `functionsKey`, so the list's `archivedAt` refreshes and the rail's\n * Delete control appears in Archive's place.\n */\nexport function useArchiveFunctionMutation() {\n return useArchiveCallableMutation(\"function\");\n}\n\nexport function useDeleteFunctionMutation() {\n return useDeleteCallableMutation(\"function\");\n}\n","import { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { path, type W6WClient } from \"@w6w/sdk\";\nimport type {\n EndpointInvokeResult,\n EndpointDef as SdkEndpointDef,\n EndpointSummary as SdkEndpointSummary,\n EndpointTarget as SdkEndpointTarget,\n} from \"@w6w/sdk/console\";\n/**\n * The Endpoint-bound facade over the kind-parametrised repo (`src/repos/callables.ts`, T4.2.2).\n *\n * Everything here that is not Endpoint-specific is one line delegating to `callables.ts` with\n * `\"endpoint\"` bound in — the list/get queries, archive and delete — so the Endpoint arm of every\n * kind-wide behaviour has exactly ONE implementation to fix (the shape `repos/functions.ts` took in\n * T4.2.1, and the \"keep the facade's exports\" rule that module documents). What stays is what only\n * an Endpoint has: the `manifestVersion: \"2\"` literal, the SDK's Endpoint type re-exports, the\n * `status`/`incomplete`/`archivedAt`-carrying summary widening with its one reader\n * {@link isEndpointDraft}, the server-rendered `invokeUrls[]` widening, the synchronous invoke\n * (`client.console.endpoints.invoke`), and the SAVE — whose 201 carries those `invokeUrls[]` back to\n * the editor's URL card, which is why its `mutationFn` is the one arm the generic `saveCallable`\n * cannot serve.\n *\n * The delegations keep their original names and call shapes on purpose: `ui/rail/SettingsTool.tsx`,\n * `ui/rail/AliasesTool.tsx`, `ui/rail/ErrorHandlingTool.tsx`, `components/TargetSelector.tsx`,\n * `components/EndpointIdentityModal.tsx`, `repos/versions.ts` (the revert arm's `endpointKey`) and\n * `repos/spec-import.ts` (`endpointsKey`) all import from here, and this node moves no behaviour —\n * only where the code lives. The two key exports stay byte-identical because both are the builders\n * `callables.ts` already documents as frozen (`[\"endpoints\"]`, `[\"endpoint\", id]`).\n */\nimport { callableKey } from \"../lib/callable-kind.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\n\nexport type {\n ActionTarget,\n CallableRef,\n CallableOnError,\n ErrorHandlerTarget,\n EndpointAuthMode,\n EndpointInput,\n EndpointInvokeResult,\n EndpointSecurity,\n EndpointTarget,\n ErrorReroute,\n Exposure,\n RetryPolicy,\n} from \"@w6w/sdk/console\";\nexport { SECRET_MASK } from \"@w6w/sdk/console\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport {\n callableListKey,\n useArchiveCallableMutation,\n useCallableListQuery,\n useCallableQuery,\n useDeleteCallableMutation,\n} from \"./callables.ts\";\n\n/** An Endpoint's OWN target: the alias-only `endpoint` arm excluded, mirroring the\n * server fence in admin/endpoints.ts's validateDefinition. Aliases use the full union\n * (`EndpointTarget`, re-exported above verbatim). */\nexport type EndpointOwnTarget = Exclude<SdkEndpointTarget, { kind: \"endpoint\" }>;\nexport type EndpointDef = Omit<SdkEndpointDef, \"target\"> & { target: EndpointOwnTarget };\n\n/**\n * One entry of the `invokeUrls[]` array the server renders on `GET\n * /endpoints/:id` and the `POST /endpoints` 201 (T3.4.1, `admin/endpoints.ts`'s\n * `InvokeUrlEntry` — the shapes are kept in sync by hand, not shared, because\n * `@w6w/sdk` does not type this field yet: it is server-fresh and\n * `packages/wrappers` publishes in lockstep at one `VERSION` across four\n * languages, outside this project's boundary (HITL-10). `entries[0]` is always\n * the platform entry; every entry after it is one of the tenant's domains.\n * `default` mirrors the tenant's stored default domain and, since D-S1\n * (intake T-0.2), it is what CHOOSES the open-on entry: absent an\n * in-session pick, the URL card opens on whichever entry carries it,\n * falling back to `entries[0]` only when no entry does. `resolves` is a\n * static host comparison the server already made; the client never\n * re-derives it.\n */\nexport interface InvokeUrlOption {\n domain: string;\n default: boolean;\n url: string;\n urlByKey?: string;\n resolves: boolean;\n}\n\n/** The two SDK-typed URL fields, widened with the untyped `invokeUrls[]`\n * array — the ONE seam `getEndpoint`, the save mutation and the editor's own\n * 201 read all widen through, so `EndpointsPage.tsx` never casts. */\ntype WithInvokeUrls = {\n invokeUrl: string;\n invokeUrlByKey?: string;\n invokeUrls?: InvokeUrlOption[];\n};\n\n/** An Endpoint list row — the SDK's own summary (`status`, `incomplete` and `archivedAt` are\n * on it since W-12), read for draft-ness only through {@link isEndpointDraft}. */\nexport type EndpointSummary = SdkEndpointSummary;\n\n/** Is this row a draft — not authorised to dispatch (HITL-7/HITL-8,\n * `rfcs/endpoint.md` § Amendment — 2026-08-14b)? Prefers the server's `status`\n * field (`!== \"ready\"`), falling back to the older `incomplete` boolean only\n * when `status` is absent (a server that has not shipped it yet). The sole\n * reader of both fields in studio; every \"unfinished\" UI decision (the\n * list's tag, and any future one) calls this rather than reading either\n * field inline. */\nexport function isEndpointDraft(ep: Pick<EndpointSummary, \"status\" | \"incomplete\">): boolean {\n return ep.status !== undefined ? ep.status !== \"ready\" : ep.incomplete === true;\n}\n\n/** Endpoint definitions carry `manifestVersion: \"2\"` — the one literal, shared\n * by the editor's blank draft and the create modal's first POST. */\nexport const ENDPOINT_MANIFEST_VERSION = \"2\";\n\n/** The list key {@link useEndpointsQuery} reads — `callables.ts`'s own\n * `callableListKey(\"endpoint\")` (byte-identical `[\"endpoints\"]`), kept as a named export because\n * `repos/spec-import.ts` invalidates it by value. */\nexport const endpointsKey = callableListKey(\"endpoint\");\n\nexport function useEndpointsQuery(enabled = true) {\n return useCallableListQuery<EndpointSummary>(\"endpoint\", enabled);\n}\n\n/** Fetch one Endpoint. Widens the SDK's return once — the server sends\n * `invokeUrls[]` (T3.4.1) that `@w6w/sdk`'s typed `get()` does not know about\n * yet; see {@link WithInvokeUrls}. */\nexport function getEndpoint(\n client: W6WClient,\n id: string,\n): Promise<{ endpoint: EndpointDef } & WithInvokeUrls> {\n return client.console.endpoints.get(id) as Promise<{ endpoint: EndpointDef } & WithInvokeUrls>;\n}\n\n/** The single-resource key — `callables.ts`'s own `callableKey(\"endpoint\", id)` (byte-identical\n * `[\"endpoint\", id]`), kept as a named export because `repos/versions.ts`'s revert arm invalidates\n * it by value. */\nexport const endpointKey = (id: string) => callableKey(\"endpoint\", id);\n\n/** `TargetSelector`'s `endpoint` arm needs one Endpoint's own `input` contract\n * to project into fields — mirrors `useFunctionQuery`/`useWorkflowQuery`\n * (`repos/functions.ts`/`repos/workflows.ts`) exactly. */\nexport function useEndpointQuery(id: string, enabled = true) {\n return useCallableQuery<Awaited<ReturnType<typeof getEndpoint>>>(\"endpoint\", id, enabled);\n}\n\n/**\n * The Endpoint arm's SAVE — the one delegated name whose `mutationFn` is NOT `callables.ts`'s\n * `saveCallable`: that helper normalises every kind's success envelope down to `{id, key}` for the\n * invalidation below, while this kind's 201 also carries the fresh server-rendered `invokeUrl`/\n * `invokeUrlByKey`/`invokeUrls[]` the editor's URL card renders from (`onSaveSuccess` in\n * `EndpointsPage.tsx`). Its KEYS and its invalidation, though, are the generic pair's — so the\n * \"which keys does an Endpoint save refresh\" answer still has one home.\n */\nexport function useSaveEndpointMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n // Same widening as `getEndpoint` — the save's 201 carries `invokeUrls[]` too.\n mutationFn: (definition: unknown) =>\n apiClient.console.endpoints.upsert(definition as never) as Promise<\n { endpoint: { id: string; key: string } } & WithInvokeUrls\n >,\n onSuccess: (saved) => invalidateSavedCallable(qc, endpointsKey, endpointKey(saved.endpoint.id)),\n });\n}\n\n/**\n * The GUARDED Endpoint save: `console.endpoints.upsert(definition, {ifUnmodifiedSince})`, so a\n * save from a stale copy answers `409 endpoint_stale`. Variables and invalidation as\n * {@link useSaveEndpointMutation}'s, plus the required token (`null` opts out explicitly; it is\n * `callableRecord(\"endpoint\", …).updatedAt`, the envelope's TOP-LEVEL `updatedAt`). Resolves the\n * verbatim upsert body (`{endpoint:{id,key}, invokeUrl, …, updatedAt}`). Additive: the unguarded\n * hook's `mutate(definition)` shape is unchanged.\n */\nexport function useGuardedSaveEndpointMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { definition: unknown; ifUnmodifiedSince: string | null }) =>\n apiClient.console.endpoints.upsert(vars.definition as never, {\n ifUnmodifiedSince: vars.ifUnmodifiedSince,\n }) as Promise<{ endpoint: { id: string; key: string }; updatedAt: string } & WithInvokeUrls>,\n onSuccess: (saved) => invalidateSavedCallable(qc, endpointsKey, endpointKey(saved.endpoint.id)),\n });\n}\n\n/**\n * `POST /endpoints/:id/invoke` through `client.request` (D2). Answers `{ kind, output }`, or a 202\n * `{ kind: \"workflow\", runId }` (success). `allowUnpublished: true` only when the caller opts in.\n */\nexport function invokeEndpoint(\n client: W6WClient,\n id: string,\n input: Record<string, unknown>,\n opts?: { allowUnpublished?: boolean },\n): Promise<EndpointInvokeResult> {\n const body: Record<string, unknown> = { input };\n if (opts?.allowUnpublished === true) body.allowUnpublished = true;\n return client\n .request<EndpointInvokeResult>({\n method: \"POST\",\n path: path`/endpoints/${id}/invoke`,\n body,\n })\n .then((res) => res.body as EndpointInvokeResult);\n}\n\nexport function useInvokeEndpointMutation() {\n const apiClient = useEmbedClient();\n return useMutation({\n mutationFn: (vars: { id: string; input: Record<string, unknown> }) =>\n invokeEndpoint(apiClient, vars.id, vars.input, { allowUnpublished: true }),\n });\n}\n\n/**\n * T4.1.1/A7/D-I0-7: `POST /endpoints/:id/archive` — the Endpoint arm of `callables.ts`'s generic\n * pair (the plain `apiClient.request()` escape hatch, NOT a typed `@w6w/sdk` method, which would\n * drag `packages/wrappers` into this task's scope for one internal route). Invalidates\n * `endpointsKey`, so the list's `archivedAt` refreshes and the rail's Delete control appears in\n * Archive's place.\n */\nexport function useArchiveEndpointMutation() {\n return useArchiveCallableMutation(\"endpoint\");\n}\n\n/** `DELETE /endpoints/:id` — the Endpoint arm of the same generic pair. */\nexport function useDeleteEndpointMutation() {\n return useDeleteCallableMutation(\"endpoint\");\n}\n"],"names":["ID_ALPHABET","REJECT_AT","defaultBytes","newId","prefix","len","bytes","out","b","CALLABLE_DESCRIPTORS","descriptorFor","kind","newCallableId","functionsKey","callableListKey","FUNCTION_MANIFEST_VERSION","listFunctions","client","useFunctionsQuery","enabled","useCallableListQuery","functionKey","id","callableKey","getFunction","useFunctionQuery","useCallableQuery","useSaveFunctionMutation","useSaveCallableMutation","useGuardedSaveFunctionMutation","apiClient","useEmbedClient","qc","useQueryClient","useMutation","vars","saved","invalidateSavedCallable","invokeFunction","inputs","opts","body","path","res","useInvokeFunctionMutation","useArchiveFunctionMutation","useArchiveCallableMutation","useDeleteFunctionMutation","useDeleteCallableMutation","isEndpointDraft","ep","ENDPOINT_MANIFEST_VERSION","endpointsKey","useEndpointsQuery","getEndpoint","endpointKey","useEndpointQuery","useSaveEndpointMutation","definition","useGuardedSaveEndpointMutation","invokeEndpoint","input","useInvokeEndpointMutation","useArchiveEndpointMutation","useDeleteEndpointMutation"],"mappings":";;;;;AAMO,MAAMA,IAAc,kEAGrBC,IAAY,KAKZC,IAA2B,CAAC,MAAM,OAAO,gBAAgB,IAAI,WAAW,CAAC,CAAC;AAGzE,SAASC,EAAMC,GAAgBC,IAAM,IAAIC,IAAoBJ,GAAsB;AACxF,MAAIK,IAAM;AACV,SAAOA,EAAI,SAASF;AAClB,eAAWG,KAAKF,EAAM,KAAK,IAAID,IAAME,EAAI,QAAQ,CAAC,CAAC;AACjD,UAAI,EAAAC,KAAKP,OACTM,KAAOP,EAAYQ,IAAI,EAAE,GACrBD,EAAI,WAAWF;AAAK;AAG5B,SAAO,GAAGD,CAAM,IAAIG,CAAG;AACzB;ACsEO,MAAME,IAAiE;AAAA,EAC5E,UAAU;AAAA,IACR,MAAM;AAAA,IACN,WAAW;AAAA,IACX,iBACE;AAAA,IAGF,WACE;AAAA,IACF,UAAU;AAAA,IACV,aAAa;AAAA,IACb,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB,qBAAqB;AAAA,IACrB,cAAc;AAAA,IACd,QAAQ;AAAA,MACN,WAAW;AAAA,MACX,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SAAS,EAAE,CAAC;AAAA,EAAA,CAC/F;AACH;AAMO,SAASwB,EACd3C,GACAK,GACAuC,GACArB,GAC+B;AAC/B,QAAMC,IAAgC,EAAE,OAAAoB,EAAA;AACxC,UAAIrB,KAAA,gBAAAA,EAAM,sBAAqB,OAAMC,EAAK,mBAAmB,KACtDxB,EACJ,QAA8B;AAAA,IAC7B,QAAQ;AAAA,IACR,MAAMyB,eAAkBpB,CAAE;AAAA,IAC1B,MAAAmB;AAAA,EAAA,CACD,EACA,KAAK,CAACE,MAAQA,EAAI,IAA4B;AACnD;AAEO,SAASmB,IAA4B;AAC1C,QAAMhC,IAAYC,EAAA;AAClB,SAAOG,EAAY;AAAA,IACjB,YAAY,CAACC,MACXyB,EAAe9B,GAAWK,EAAK,IAAIA,EAAK,OAAO,EAAE,kBAAkB,GAAA,CAAM;AAAA,EAAA,CAC5E;AACH;AASO,SAAS4B,KAA6B;AAC3C,SAAOjB,EAA2B,UAAU;AAC9C;AAGO,SAASkB,KAA4B;AAC1C,SAAOhB,EAA0B,UAAU;AAC7C;"}
|
package/dist/fields-DvS8XZFc.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { path as o, ApiError as c } from "@w6w/sdk";
|
|
2
|
-
async function l(t, a, i, s, e) {
|
|
3
|
-
try {
|
|
4
|
-
return (await t.request({
|
|
5
|
-
method: "POST",
|
|
6
|
-
path: o`/apps/${a}/actions/${i}/fields`,
|
|
7
|
-
body: s,
|
|
8
|
-
signal: e == null ? void 0 : e.signal
|
|
9
|
-
})).body;
|
|
10
|
-
} catch (r) {
|
|
11
|
-
if (r instanceof c && r.status === 424)
|
|
12
|
-
return {
|
|
13
|
-
fields: Object.fromEntries(s.fields.map((n) => [n, { error: r.message }]))
|
|
14
|
-
};
|
|
15
|
-
throw r;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
l as r
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=fields-DvS8XZFc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fields-DvS8XZFc.js","sources":["../src/repos/fields.ts"],"sourcesContent":["import type { W6WClient } from \"@w6w/sdk\";\nimport { path, ApiError } from \"@w6w/sdk\";\n/**\n * Dynamic-field resolution — `POST /apps/:id/actions/:key/fields` over `client.request()`.\n * A 424 (the vendor lookup failed) becomes a per-field error result so one bad lookup does not\n * blank the form; every other failure (400/403/404/network/abort) rethrows for the ui to handle.\n */\n\n/**\n * Structural mirror of ui's `W6WApi.resolveActionFields` shapes (this barrel may not import\n * `@w6w/ui`); the facade/UiBridge assignment typechecks against W6WApi structurally.\n */\nexport interface ResolveActionFieldsBody {\n connectionId: string;\n version?: string;\n reason: \"init\" | \"change\";\n form: Record<string, unknown>;\n previous?: Record<string, unknown>;\n changed?: string[];\n fields: string[];\n unresolved: string[];\n}\nexport interface ResolveActionFieldsResult {\n fields: Record<\n string,\n { options?: { value: string | number; label: string; description?: string }[]; error?: string }\n >;\n}\nexport interface ResolveActionFieldsOpts {\n signal?: AbortSignal;\n}\n\nexport async function resolveActionFields(\n client: W6WClient,\n appId: string,\n actionKey: string,\n body: ResolveActionFieldsBody,\n opts?: ResolveActionFieldsOpts,\n): Promise<ResolveActionFieldsResult> {\n try {\n const res = await client.request<ResolveActionFieldsResult>({\n method: \"POST\",\n path: path`/apps/${appId}/actions/${actionKey}/fields`,\n body,\n signal: opts?.signal,\n });\n return res.body;\n } catch (err) {\n if (err instanceof ApiError && err.status === 424) {\n return {\n fields: Object.fromEntries(body.fields.map((k) => [k, { error: err.message }])),\n };\n }\n throw err;\n }\n}\n"],"names":["resolveActionFields","client","appId","actionKey","body","opts","path","err","ApiError","k"],"mappings":";AAgCA,eAAsBA,EACpBC,GACAC,GACAC,GACAC,GACAC,GACoC;AACpC,MAAI;AAOF,YANY,MAAMJ,EAAO,QAAmC;AAAA,MAC1D,QAAQ;AAAA,MACR,MAAMK,UAAaJ,CAAK,YAAYC,CAAS;AAAA,MAC7C,MAAAC;AAAA,MACA,QAAQC,KAAA,gBAAAA,EAAM;AAAA,IAAA,CACf,GACU;AAAA,EACb,SAASE,GAAK;AACZ,QAAIA,aAAeC,KAAYD,EAAI,WAAW;AAC5C,aAAO;AAAA,QACL,QAAQ,OAAO,YAAYH,EAAK,OAAO,IAAI,CAACK,MAAM,CAACA,GAAG,EAAE,OAAOF,EAAI,QAAA,CAAS,CAAC,CAAC;AAAA,MAAA;AAGlF,UAAMA;AAAA,EACR;AACF;"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
function l(r, n) {
|
|
2
|
-
if (typeof n != "object" || n === null || Array.isArray(n)) return null;
|
|
3
|
-
const t = n, e = typeof t.updatedAt == "string" ? t.updatedAt : null;
|
|
4
|
-
if (r === "function") {
|
|
5
|
-
const { valid: i, updatedAt: f, ...u } = t;
|
|
6
|
-
return { definition: u, updatedAt: e };
|
|
7
|
-
}
|
|
8
|
-
const o = t.endpoint;
|
|
9
|
-
return typeof o != "object" || o === null || Array.isArray(o) ? null : { definition: o, updatedAt: e };
|
|
10
|
-
}
|
|
11
|
-
function a(r) {
|
|
12
|
-
return r ? r.kind === "function" || r.kind === "endpoint" ? !0 : r.kind === "workflow" && typeof r.onPolicyChange == "function" : !1;
|
|
13
|
-
}
|
|
14
|
-
function s(r) {
|
|
15
|
-
const n = {};
|
|
16
|
-
return r.retry && (n.retry = r.retry), r.onError && r.onError !== "fail" && (n.onError = r.onError), r.reroute && (n.reroute = r.reroute), n;
|
|
17
|
-
}
|
|
18
|
-
function d(r, n) {
|
|
19
|
-
const { retry: t, onError: e, reroute: o, ...i } = r;
|
|
20
|
-
return {
|
|
21
|
-
...i,
|
|
22
|
-
...n.retry ? { retry: n.retry } : {},
|
|
23
|
-
...n.onError && n.onError !== "fail" ? { onError: n.onError } : {},
|
|
24
|
-
...n.reroute ? { reroute: n.reroute } : {}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
l as c,
|
|
29
|
-
d,
|
|
30
|
-
a as i,
|
|
31
|
-
s as p
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=settings-rail--GdRMusb.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-rail--GdRMusb.js","sources":["../src/lib/callable-record.ts","../src/lib/settings-rail.ts"],"sourcesContent":["/**\n * The ONE split of a Function's / Endpoint's `get` response into the editable definition and the\n * stale-write token. `useCallableDraft` (seed, external-change detection, the posted body) and the\n * rail's write paths (B-4) both read through it, so \"what do we post, and which `updatedAt` do we\n * guard it with\" has one answer.\n *\n * - **function** — the `console.functions.get` result is `FunctionDef & {valid, updatedAt}` with the\n * top-level values spread LAST. The definition is that object minus `valid` and `updatedAt`\n * (both read-only splices that must never ride back in a save body); the token is its top-level\n * `updatedAt`, so a stale `updatedAt` stored INSIDE a definition never wins.\n * - **endpoint** — the response is the verbatim envelope `{endpoint, invokeUrl, …, updatedAt}`.\n * The definition is `data.endpoint` as-is; the token is the TOP-LEVEL `data.updatedAt`, never\n * `data.endpoint.updatedAt`.\n *\n * `null` when `data` is absent or is not the shape the kind answers with. Pure, no imports:\n * loadable by `node --test`.\n */\nexport function callableRecord(\n kind: \"function\" | \"endpoint\",\n data: unknown,\n): { definition: Record<string, unknown>; updatedAt: string | null } | null {\n if (typeof data !== \"object\" || data === null || Array.isArray(data)) return null;\n const top = data as Record<string, unknown>;\n const updatedAt = typeof top.updatedAt === \"string\" ? top.updatedAt : null;\n if (kind === \"function\") {\n const { valid: _valid, updatedAt: _updatedAt, ...definition } = top;\n return { definition, updatedAt };\n }\n const endpoint = top.endpoint;\n if (typeof endpoint !== \"object\" || endpoint === null || Array.isArray(endpoint)) return null;\n return { definition: endpoint as Record<string, unknown>, updatedAt };\n}\n","/**\n * Pure decisions behind the right rail's Error handling tool\n * (`src/ui/rail/SettingsTool.tsx`, D-10) — the third `railTools` entry,\n * rendering `@w6w/ui`'s `NodeConfigForm` for a Function or an Endpoint and\n * persisting `retry` / `onError` / `reroute` onto that resource's own\n * definition. Split out so `node --test` can gate them directly — mirrors\n * `code-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 — `import type … from\n * \"@w6w/sdk/console\"` is safe and precedented (`src/lib/workflow-poll.ts:15`,\n * `src/lib/tenant-oauth-patch.ts:69`, both unit-tested today).\n */\nimport type { CallableOnError, ErrorReroute, RetryPolicy } from \"@w6w/sdk/console\";\n\n/** Structural mirror of `WorkspaceCallable` (`src/ui/workspace.tsx`) — only\n * the fields this module reads. `onPolicyChange` is the WORKFLOW arm's\n * injected writer (see {@link isAvailable}); the two callable arms have no\n * such member and never read it. */\nexport type SettingsCallable = {\n kind: string;\n id: string;\n onPolicyChange?: (policy: CallablePolicy) => void;\n} | null;\n\n/** The three fields this tool owns on a Function/Endpoint definition —\n * TC2's pinned shape, shared by both `Fn` and `Endpoint`. */\nexport interface CallablePolicy {\n retry?: RetryPolicy;\n onError?: CallableOnError;\n reroute?: ErrorReroute;\n}\n\n/** A definition carrying (at least) the three fields above, plus whatever\n * else `Fn`/`Endpoint` declares — `definitionWithPolicy` preserves every\n * field this type doesn't name. */\nexport type CallableDefinition = CallablePolicy;\n\n/**\n * Is the Error handling tool meaningful for this context?\n *\n * A Function and an Endpoint: always — the panel owns their whole\n * read-modify-write, because nothing else on the page is editing the same\n * definition at the same time.\n *\n * A Workflow: only when the publishing page injects `onPolicyChange` (core\n * Workflow RFC — *Amendment — 2026-08-21: the run-level error handler*). This\n * is not fussiness. The workflow canvas holds the definition as JSON TEXT it\n * owns, and auto-saves it (`settings.autoSave` defaults to ON), so a rail\n * panel doing its own read-modify-write against the server would be racing the\n * editor: whichever wrote last would silently drop the other's edit, and the\n * loser would most often be the rail, since the canvas re-sends its whole\n * buffer on the next keystroke. Injecting the writer instead means the rail\n * edits the SAME buffer the canvas is about to save. A page that does not own\n * that buffer (the run-detail page) publishes no writer, and the tool simply\n * does not appear there.\n *\n * A Connection has no run-level policy at all. `null` (no resource published)\n * fails closed, house style (mirrors `code-rail.ts`'s `isAvailable`).\n */\nexport function isAvailable(ctx: SettingsCallable): boolean {\n if (!ctx) return false;\n if (ctx.kind === \"function\" || ctx.kind === \"endpoint\") return true;\n return ctx.kind === \"workflow\" && typeof ctx.onPolicyChange === \"function\";\n}\n\n/**\n * Read a definition's `{retry, onError, reroute}` into the shape the panel's\n * local editing state starts from. Normalizes the same way\n * `definitionWithPolicy` writes: a stored `onError: \"fail\"` (never written by\n * this tool, but defensive against a hand-edited or older definition) reads\n * back as absent, matching how `NodeConfigForm` already treats `\"fail\"` as\n * its own default.\n */\nexport function policyFromDefinition(def: CallableDefinition): CallablePolicy {\n const policy: CallablePolicy = {};\n if (def.retry) policy.retry = def.retry;\n if (def.onError && def.onError !== \"fail\") policy.onError = def.onError;\n if (def.reroute) policy.reroute = def.reroute;\n return policy;\n}\n\n/**\n * Read-modify-write: apply `policy`'s `{retry, onError, reroute}` onto `def`,\n * preserving every OTHER field untouched (`impl`/`inputs`/`key` on a\n * Function, `target`/`input`/`key` on an Endpoint, …) — the save this tool\n * issues is never a bare `{retry, onError, reroute}` object. A field whose\n * value is the default is OMITTED entirely, not written as `undefined`:\n * `policy.onError === \"fail\"` (or absent) drops the key, matching\n * `NodeConfigForm`'s own \"fail\" -> absent convention for the field it edits\n * in place. Built by destructuring the three fields OUT of `def` and\n * conditionally re-spreading them, rather than `delete`, so the key is\n * genuinely absent from the returned object, not merely `undefined`-valued —\n * `node:assert/strict`'s deep-equal distinguishes the two (this module's own\n * test pins it).\n */\nexport function definitionWithPolicy<T extends CallableDefinition>(\n def: T,\n policy: CallablePolicy,\n): T {\n const { retry: _retry, onError: _onError, reroute: _reroute, ...rest } = def;\n return {\n ...rest,\n ...(policy.retry ? { retry: policy.retry } : {}),\n ...(policy.onError && policy.onError !== \"fail\" ? { onError: policy.onError } : {}),\n ...(policy.reroute ? { reroute: policy.reroute } : {}),\n } as T;\n}\n"],"names":["callableRecord","kind","data","top","updatedAt","_valid","_updatedAt","definition","endpoint","isAvailable","ctx","policyFromDefinition","def","policy","definitionWithPolicy","_retry","_onError","_reroute","rest"],"mappings":"AAiBO,SAASA,EACdC,GACAC,GAC0E;AAC1E,MAAI,OAAOA,KAAS,YAAYA,MAAS,QAAQ,MAAM,QAAQA,CAAI,EAAG,QAAO;AAC7E,QAAMC,IAAMD,GACNE,IAAY,OAAOD,EAAI,aAAc,WAAWA,EAAI,YAAY;AACtE,MAAIF,MAAS,YAAY;AACvB,UAAM,EAAE,OAAOI,GAAQ,WAAWC,GAAY,GAAGC,MAAeJ;AAChE,WAAO,EAAE,YAAAI,GAAY,WAAAH,EAAA;AAAA,EACvB;AACA,QAAMI,IAAWL,EAAI;AACrB,SAAI,OAAOK,KAAa,YAAYA,MAAa,QAAQ,MAAM,QAAQA,CAAQ,IAAU,OAClF,EAAE,YAAYA,GAAqC,WAAAJ,EAAA;AAC5D;AC8BO,SAASK,EAAYC,GAAgC;AAC1D,SAAKA,IACDA,EAAI,SAAS,cAAcA,EAAI,SAAS,aAAmB,KACxDA,EAAI,SAAS,cAAc,OAAOA,EAAI,kBAAmB,aAF/C;AAGnB;AAUO,SAASC,EAAqBC,GAAyC;AAC5E,QAAMC,IAAyB,CAAA;AAC/B,SAAID,EAAI,UAAOC,EAAO,QAAQD,EAAI,QAC9BA,EAAI,WAAWA,EAAI,YAAY,WAAQC,EAAO,UAAUD,EAAI,UAC5DA,EAAI,YAASC,EAAO,UAAUD,EAAI,UAC/BC;AACT;AAgBO,SAASC,EACdF,GACAC,GACG;AACH,QAAM,EAAE,OAAOE,GAAQ,SAASC,GAAU,SAASC,GAAU,GAAGC,EAAA,IAASN;AACzE,SAAO;AAAA,IACL,GAAGM;AAAA,IACH,GAAIL,EAAO,QAAQ,EAAE,OAAOA,EAAO,MAAA,IAAU,CAAA;AAAA,IAC7C,GAAIA,EAAO,WAAWA,EAAO,YAAY,SAAS,EAAE,SAASA,EAAO,QAAA,IAAY,CAAA;AAAA,IAChF,GAAIA,EAAO,UAAU,EAAE,SAASA,EAAO,QAAA,IAAY,CAAA;AAAA,EAAC;AAExD;"}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { useQueryClient as c, useMutation as l, useQuery as w } from "@tanstack/react-query";
|
|
2
|
-
import { path as u } from "@w6w/sdk";
|
|
3
|
-
import { u as i } from "./client-context-CX61Bgw-.js";
|
|
4
|
-
import { i as y, a as d } from "./callables-tOlflvbl.js";
|
|
5
|
-
import { o as p, a2 as b } from "./workflows-Dz8LMjnt.js";
|
|
6
|
-
const h = (t) => d("endpoint", t), m = (t) => d("function", t), a = {
|
|
7
|
-
function: "functions",
|
|
8
|
-
workflow: "workflows",
|
|
9
|
-
endpoint: "endpoints"
|
|
10
|
-
}, q = {
|
|
11
|
-
function: "invoke",
|
|
12
|
-
endpoint: "invoke",
|
|
13
|
-
workflow: "run"
|
|
14
|
-
};
|
|
15
|
-
function f(t, n) {
|
|
16
|
-
return ["versions", t, n];
|
|
17
|
-
}
|
|
18
|
-
function $(t, n, o) {
|
|
19
|
-
return ["version", t, n, o];
|
|
20
|
-
}
|
|
21
|
-
function Q(t, n, o) {
|
|
22
|
-
const e = i();
|
|
23
|
-
return w({
|
|
24
|
-
queryKey: f(t, n),
|
|
25
|
-
queryFn: async () => {
|
|
26
|
-
switch (t) {
|
|
27
|
-
case "workflow":
|
|
28
|
-
return await e.workflows.listVersions(n);
|
|
29
|
-
case "function":
|
|
30
|
-
return await e.functions.listVersions(n);
|
|
31
|
-
case "endpoint":
|
|
32
|
-
return (await e.request({
|
|
33
|
-
method: "GET",
|
|
34
|
-
path: u`/${a.endpoint}/${n}/versions`
|
|
35
|
-
})).body;
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
enabled: o && t !== null && n !== ""
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function F(t, n, o, e) {
|
|
42
|
-
const s = i();
|
|
43
|
-
return w({
|
|
44
|
-
queryKey: $(t, n, o),
|
|
45
|
-
queryFn: async () => {
|
|
46
|
-
const r = o;
|
|
47
|
-
switch (t) {
|
|
48
|
-
case "workflow":
|
|
49
|
-
return await s.workflows.getVersion(n, r);
|
|
50
|
-
case "function":
|
|
51
|
-
return await s.functions.getVersion(n, r);
|
|
52
|
-
case "endpoint":
|
|
53
|
-
return (await s.request({
|
|
54
|
-
method: "GET",
|
|
55
|
-
path: u`/${a.endpoint}/${n}/versions/${String(r)}`
|
|
56
|
-
})).body.version;
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
enabled: e && t !== null && n !== "" && o !== null
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function O(t) {
|
|
63
|
-
const n = i(), o = c();
|
|
64
|
-
return l({
|
|
65
|
-
mutationFn: async (e) => {
|
|
66
|
-
switch (t) {
|
|
67
|
-
case "workflow":
|
|
68
|
-
return await n.workflows.publish(e);
|
|
69
|
-
case "function":
|
|
70
|
-
return await n.functions.publish(e);
|
|
71
|
-
case "endpoint":
|
|
72
|
-
return (await n.request({
|
|
73
|
-
method: "POST",
|
|
74
|
-
path: u`/${a.endpoint}/${e}/publish`
|
|
75
|
-
})).body;
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
onSuccess: (e, s) => o.invalidateQueries({ queryKey: f(t, s) })
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
function v(t) {
|
|
82
|
-
const n = i(), o = c();
|
|
83
|
-
return l({
|
|
84
|
-
mutationFn: async (e) => {
|
|
85
|
-
switch (t) {
|
|
86
|
-
case "workflow":
|
|
87
|
-
return e.enabled ? await n.workflows.enable(e.id) : await n.workflows.disable(e.id), { enabled: e.enabled };
|
|
88
|
-
case "function":
|
|
89
|
-
return e.enabled ? await n.functions.enable(e.id) : await n.functions.disable(e.id), { enabled: e.enabled };
|
|
90
|
-
case "endpoint":
|
|
91
|
-
return (await n.request({
|
|
92
|
-
method: "POST",
|
|
93
|
-
path: u`/${a.endpoint}/${e.id}/${e.enabled ? "enable" : "disable"}`
|
|
94
|
-
})).body;
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
onSuccess: (e, s) => {
|
|
98
|
-
o.invalidateQueries({ queryKey: f(t, s.id) });
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
function g(t) {
|
|
103
|
-
const n = i(), o = c();
|
|
104
|
-
return l({
|
|
105
|
-
mutationFn: async (e) => {
|
|
106
|
-
switch (t) {
|
|
107
|
-
case "workflow":
|
|
108
|
-
return { reverted: await n.workflows.revert(e.id, e.versionNumber) };
|
|
109
|
-
case "function":
|
|
110
|
-
return { reverted: await n.functions.revert(e.id, e.versionNumber) };
|
|
111
|
-
case "endpoint":
|
|
112
|
-
return (await n.request({
|
|
113
|
-
method: "POST",
|
|
114
|
-
path: u`/${a.endpoint}/${e.id}/versions/${String(e.versionNumber)}/revert`
|
|
115
|
-
})).body;
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
onSuccess: (e, s) => {
|
|
119
|
-
let r;
|
|
120
|
-
switch (t) {
|
|
121
|
-
case "function":
|
|
122
|
-
r = m(s.id);
|
|
123
|
-
break;
|
|
124
|
-
case "workflow":
|
|
125
|
-
r = b(s.id);
|
|
126
|
-
break;
|
|
127
|
-
case "endpoint":
|
|
128
|
-
r = h(s.id);
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
y(o, f(t, s.id), r);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
function I(t) {
|
|
136
|
-
const n = i(), o = c();
|
|
137
|
-
return l({
|
|
138
|
-
mutationFn: async (e) => {
|
|
139
|
-
if (t === "workflow") {
|
|
140
|
-
const r = await n.workflows.runVersion(e.id, e.versionNumber, {});
|
|
141
|
-
return { runId: r.runId, status: r.status };
|
|
142
|
-
}
|
|
143
|
-
return (await n.request({
|
|
144
|
-
method: "POST",
|
|
145
|
-
path: u`/${a[t]}/${e.id}/versions/${String(e.versionNumber)}/${q[t]}`,
|
|
146
|
-
body: {}
|
|
147
|
-
})).body;
|
|
148
|
-
},
|
|
149
|
-
onSettled: () => o.invalidateQueries({ queryKey: p.root })
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
function K() {
|
|
153
|
-
return ["constants"];
|
|
154
|
-
}
|
|
155
|
-
function N() {
|
|
156
|
-
const t = i();
|
|
157
|
-
return w({
|
|
158
|
-
queryKey: K(),
|
|
159
|
-
queryFn: async () => (await t.request({
|
|
160
|
-
method: "GET",
|
|
161
|
-
path: "/constants"
|
|
162
|
-
})).body.constants
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function P(t, n, o) {
|
|
166
|
-
const e = i();
|
|
167
|
-
return w({
|
|
168
|
-
queryKey: ["spec", t, n],
|
|
169
|
-
queryFn: async () => (await e.request({
|
|
170
|
-
method: "GET",
|
|
171
|
-
path: u`/${t}/${n}/spec`
|
|
172
|
-
})).body.spec,
|
|
173
|
-
enabled: o && t !== null
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
export {
|
|
177
|
-
I as a,
|
|
178
|
-
O as b,
|
|
179
|
-
K as c,
|
|
180
|
-
g as d,
|
|
181
|
-
v as e,
|
|
182
|
-
P as f,
|
|
183
|
-
F as g,
|
|
184
|
-
Q as h,
|
|
185
|
-
f as i,
|
|
186
|
-
N as u,
|
|
187
|
-
$ as v
|
|
188
|
-
};
|
|
189
|
-
//# sourceMappingURL=spec-export-DMMET5VM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spec-export-DMMET5VM.js","sources":["../src/repos/versions.ts","../src/repos/constants.ts","../src/repos/spec-export.ts"],"sourcesContent":["/**\n * The `/<collection>/:id/{publish,versions,enable,disable}` repo (T3.1.1) — the Settings rail's\n * read-only version-history browser plus Publish and Enable/Disable. A NEW file, mirroring\n * `src/repos/spec-export.ts` in full: kept out of `repos/functions.ts` / `repos/workflows.ts` /\n * `repos/endpoints.ts` so this node never collides with any of them on the same file, exactly the\n * reason `spec-export.ts`'s own docblock gives for the sibling `/spec` route.\n *\n * **Workflow and Function arms go through the public `@w6w/sdk` methods** (`listVersions`,\n * `getVersion`, `publish`, `revert`, `enable`, `disable`, and `workflows.runVersion`), never\n * `apiClient.console.*`. Each hook dispatches with an explicit per-kind `switch` over LITERAL\n * receivers (`apiClient.workflows.publish(id)`, `apiClient.functions.publish(id)`) and no `default:`\n * — the same reasoning `COLLECTION_PATH` and `useRevertMutation` give against derived dispatch.\n *\n * **Two arms deliberately stay on `W6WClient.request<T>()`:** the ENDPOINT arm of every hook\n * (R-5: endpoint versions have no SDK method — intentionally excluded from the public surface),\n * and the FUNCTION arm of {@link useInvokeVersionMutation} (F-P4: `VersionHistoryModal` renders the\n * raw invocation frame, but `functions.runVersion` unwraps the output like `functions.run`, so the\n * SDK method would drop the frame; follow-up F-6).\n *\n * Every query below is gated on the CALLER'S OWN `enabled` flag, ANDed with `kind !== null` and\n * `id !== \"\"` — never on mount alone (`packages/studio/.ai/PLANNER.md` fact 11): a hook that fires\n * unconditionally against an unresolved `null`/`\"\"` argument 404s once and, because `main.tsx`\n * sets `retry: false` and an unchanged query key never re-fetches, never self-corrects. Opening\n * the Settings panel must issue ZERO `/versions` requests; only opening its History section (or\n * `WorkflowsPage.tsx`'s own editor, a separate call site with its own gate) flips `enabled`.\n *\n * T5.3.1 (project.md Phase 2, Amendments #5/#6): a version can now be reverted to and invoked\n * directly, superseding the earlier \"read-only history, restore out of scope\" pin. `useRevertMutation`\n * overwrites the LIVE resource's `definition` with the archived version's content — never its\n * `key`/address (HITL-4's pinned default) — and does post a `definition` back, by design.\n * `useInvokeVersionMutation` runs that ARCHIVED version's own definition, not the live one, which is\n * exactly why it exists as a separate call from the live invoke/run routes `functions.ts`/\n * `endpoints.ts`/`workflows.ts` already expose.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { callableKey } from \"../lib/callable-kind.ts\";\nimport { historyKeys } from \"../lib/history-query.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\nimport { workflowKey } from \"./workflows.ts\";\n\n/** The Endpoint / Function single-resource keys the revert arm invalidates: the same\n * `callableKey(\"<kind>\", id)` Studio's `repos/endpoints.ts` / `repos/functions.ts` export as\n * `endpointKey` / `functionKey` (byte-identical `[\"endpoint\", id]` / `[\"function\", id]`). */\nconst endpointKey = (id: string) => callableKey(\"endpoint\", id);\nconst functionKey = (id: string) => callableKey(\"function\", id);\n\n/** The three kinds the wire contract's version-history routes exist for — `connection` has none\n * (see `hasVersionHistory`, `../lib/rail-settings.ts`). */\nexport type VersionsKind = \"function\" | \"workflow\" | \"endpoint\";\n\n/** `<coll>` — the wire contract's own path segment for each kind, every one of the three arms\n * named explicitly (never derived by string pluralization), mirroring `specCollectionForKind`'s\n * own reasoning (`../lib/rail-settings.ts:69`): a typo'd suffix rule would silently send one\n * kind's requests at another kind's collection. */\nconst COLLECTION_PATH: Record<VersionsKind, \"functions\" | \"workflows\" | \"endpoints\"> = {\n function: \"functions\",\n workflow: \"workflows\",\n endpoint: \"endpoints\",\n};\n\n/** One row of `GET /<coll>/:id/versions`'s `versions` array — newest first, per the wire contract. */\nexport interface VersionSummary {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n}\n\n/** `GET /<coll>/:id/versions`'s full 200 body. */\nexport interface VersionsEnvelope {\n enabled: boolean;\n currentPublishedVersion: number | null;\n versions: VersionSummary[];\n}\n\n/** `GET /<coll>/:id/versions/:n`'s `version` field — `definition` is the redacted stored\n * definition for THIS query; {@link useRevertMutation} is what posts a version's definition\n * back onto the live resource, and {@link useInvokeVersionMutation} is what runs it. */\nexport interface VersionDetail {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n definition: Record<string, unknown>;\n}\n\n/** `POST /<coll>/:id/publish`'s 200 body. */\nexport interface PublishResult {\n version: {\n kind: string;\n callableId: string;\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n };\n currentPublishedVersion: number;\n}\n\n/** `POST /<coll>/:id/versions/:n/revert`'s 200 body. */\nexport interface RevertResult {\n reverted: {\n kind: string;\n callableId: string;\n versionNumber: number;\n };\n}\n\n/** `<coll>` per kind ends its live invoke/run route in `/invoke` (Function, Endpoint) or `/run`\n * (Workflow, matching that kind's existing unversioned route) — every arm named explicitly\n * (never derived by suffix rule), mirroring `COLLECTION_PATH`'s own reasoning above: a derived\n * rule would silently send one kind's requests at the wrong verb. */\nconst VERSION_INVOKE_VERB: Record<VersionsKind, \"invoke\" | \"run\"> = {\n function: \"invoke\",\n endpoint: \"invoke\",\n workflow: \"run\",\n};\n\nexport function versionsKey(kind: VersionsKind | null, id: string) {\n return [\"versions\", kind, id] as const;\n}\n\nexport function versionKey(kind: VersionsKind | null, id: string, versionNumber: number | null) {\n return [\"version\", kind, id, versionNumber] as const;\n}\n\n/**\n * `GET /<collection>/:id/versions`. Never fires on mount — `enabled` is the caller's own flag\n * (the Settings panel's History-open state, or `WorkflowsPage.tsx`'s own editor-open gate), ANDed\n * with `kind !== null` and `id !== \"\"`, exactly `useSpecQuery`'s shape (`spec-export.ts:45-57`).\n */\nexport function useVersionsQuery(kind: VersionsKind | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionsKey(kind, id),\n queryFn: async (): Promise<VersionsEnvelope> => {\n switch (kind as VersionsKind) {\n case \"workflow\":\n return await apiClient.workflows.listVersions(id);\n case \"function\":\n return await apiClient.functions.listVersions(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<VersionsEnvelope>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions`,\n });\n return res.body;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\",\n });\n}\n\n/**\n * `GET /<collection>/:id/versions/:n`. Same gating shape as {@link useVersionsQuery}, plus\n * `versionNumber !== null` — the modal opens this only once a row has been clicked.\n */\nexport function useVersionQuery(\n kind: VersionsKind | null,\n id: string,\n versionNumber: number | null,\n enabled: boolean,\n) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionKey(kind, id, versionNumber),\n queryFn: async (): Promise<VersionDetail> => {\n // The SDK's `getVersion` already unwraps the `{ version }` envelope.\n const n = versionNumber as number;\n switch (kind as VersionsKind) {\n case \"workflow\":\n return (await apiClient.workflows.getVersion(id, n)) as VersionDetail;\n case \"function\":\n return (await apiClient.functions.getVersion(id, n)) as VersionDetail;\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ version: VersionDetail }>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions/${String(n)}`,\n });\n return res.body.version;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\" && versionNumber !== null,\n });\n}\n\n/**\n * `POST /<collection>/:id/publish`. `kind` is fixed per hook instance — the caller already knows\n * which kind it is publishing (the rail's `ctx.kind`, or `WorkflowsPage.tsx`'s hardcoded\n * `\"workflow\"`) — and `mutate(id)` supplies the resource. `onSuccess` invalidates the SAME\n * `[\"versions\", kind, id]` key {@link useVersionsQuery} reads, so the panel's published pointer\n * and version list are fresh without a reload (A3), mirroring `useSaveFunctionMutation`'s\n * `onSuccess` shape (`./functions.ts`).\n */\nexport function usePublishMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string): Promise<PublishResult> => {\n switch (kind) {\n case \"workflow\":\n return await apiClient.workflows.publish(id);\n case \"function\":\n return await apiClient.functions.publish(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<PublishResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/publish`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, id) => {\n return qc.invalidateQueries({ queryKey: versionsKey(kind, id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/{enable,disable}`. One mutation for both — the wire contract is two\n * routes distinguished only by which one is called, so `vars.enabled` picks the path segment\n * rather than this module carrying two near-identical mutations. `onSuccess` invalidates the same\n * key {@link usePublishMutation} does, for the same reason.\n */\nexport function useSetEnabledMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; enabled: boolean }): Promise<{ enabled: boolean }> => {\n // The SDK's `enable`/`disable` return void; the hook's result stays `{ enabled }`.\n switch (kind) {\n case \"workflow\":\n if (vars.enabled) await apiClient.workflows.enable(vars.id);\n else await apiClient.workflows.disable(vars.id);\n return { enabled: vars.enabled };\n case \"function\":\n if (vars.enabled) await apiClient.functions.enable(vars.id);\n else await apiClient.functions.disable(vars.id);\n return { enabled: vars.enabled };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ enabled: boolean }>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/${vars.enabled ? \"enable\" : \"disable\"}`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n qc.invalidateQueries({ queryKey: versionsKey(kind, vars.id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/revert`, no body — overwrites the LIVE resource's\n * `definition` with the archived version's content, preserving its `key`/address (HITL-4's\n * pinned default; see the module docblock). This is the first mutation in this family that\n * changes `definition` rather than merely appending to or flipping a flag on the version history\n * (`usePublishMutation`/`useSetEnabledMutation` above do neither), so `onSuccess` invalidates\n * BOTH `versionsKey(kind, id)` (the same key those two invalidate) AND the kind's own\n * definition-edit key — via the shared `invalidateSavedCallable` helper\n * `useSaveFunctionMutation`/`useSaveEndpointMutation` already route through\n * (`../lib/save-invalidation.ts`) — or the page a user reverted FROM keeps showing the\n * pre-revert draft until a manual reload. The definition key is picked by a `switch` naming all\n * three arms explicitly, with no `default:` — the same reasoning `COLLECTION_PATH`'s own docblock\n * gives: a derived rule would silently send one kind at another kind's key.\n */\nexport function useRevertMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; versionNumber: number }): Promise<RevertResult> => {\n // The SDK's `revert` unwraps `{ reverted }`; the hook re-wraps it to keep its result shape.\n switch (kind) {\n case \"workflow\":\n return { reverted: await apiClient.workflows.revert(vars.id, vars.versionNumber) };\n case \"function\":\n return { reverted: await apiClient.functions.revert(vars.id, vars.versionNumber) };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<RevertResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/versions/${String(vars.versionNumber)}/revert`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n let definitionKey: readonly unknown[];\n switch (kind) {\n case \"function\":\n definitionKey = functionKey(vars.id);\n break;\n case \"workflow\":\n definitionKey = workflowKey(vars.id);\n break;\n case \"endpoint\":\n definitionKey = endpointKey(vars.id);\n break;\n }\n invalidateSavedCallable(qc, versionsKey(kind, vars.id), definitionKey);\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/{invoke,run}`, an EMPTY JSON body — identical to that\n * kind's unversioned invoke/run route's success body, except the requested version's OWN\n * `impl`/definition runs instead of the live one (T5.3.1's wire contract table). Unlike\n * {@link useRevertMutation}, invoking changes no resource state, so it invalidates History ONLY\n * (`onSettled`, `historyKeys.root` — a version run is a run, failed ones included, like every other\n * run path) and no resource query — the caller (`VersionHistoryModal`) renders the mutation's own `data`/`error` state\n * directly, and that state is naturally cleared whenever the modal remounts for a different\n * version (`SettingsTool.tsx`'s `openVersion` gate fully unmounts/remounts it, never leaves it\n * mounted across a prop change).\n */\nexport function useInvokeVersionMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n versionNumber: number;\n }): Promise<Record<string, unknown>> => {\n // The workflow arm moves to `workflows.runVersion`. The FUNCTION arm (F-P4 / F-6) and the\n // ENDPOINT arm (R-5) stay on `request()`: this hook's caller renders the raw invocation\n // frame, and `functions.runVersion` unwraps the output like `functions.run` — it would drop\n // the frame. The workflow arm returns only `{ runId, status }`, as the raw body did.\n if (kind === \"workflow\") {\n const run = await apiClient.workflows.runVersion(vars.id, vars.versionNumber, {});\n // Project back to the server's own run-start body: the SDK adds `steps`/`terminal`/\n // `httpStatus`, and `VersionHistoryModal` prints this value verbatim as JSON.\n return { runId: run.runId, status: run.status };\n }\n const res = await apiClient.request<Record<string, unknown>>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH[kind]}/${vars.id}/versions/${String(vars.versionNumber)}/${VERSION_INVOKE_VERB[kind]}`,\n body: {},\n });\n return res.body;\n },\n onSettled: () => qc.invalidateQueries({ queryKey: historyKeys.root }),\n });\n}\n","/**\n * The `constants` domain repo — account-level, read-only values set by an\n * administrator and referenced as `{{ const.<name> }}`. There is no write\n * route; the server derives the account from the token.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport interface Constant {\n name: string;\n type: \"string\" | \"number\" | \"boolean\" | \"json\";\n value: unknown;\n description: string;\n /** Computed by the server (e.g. `account_id`), not stored. */\n derived: boolean;\n}\n\n/** Query key for the constants list. */\nexport function constantsKey() {\n return [\"constants\"] as const;\n}\n\n/** The account's constants (read-only). */\nexport function useConstantsQuery() {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: constantsKey(),\n queryFn: async () => {\n const res = await apiClient.request<{ constants: Constant[] }>({\n method: \"GET\",\n path: \"/constants\",\n });\n return res.body.constants;\n },\n });\n}\n","/**\n * The `/<collection>/:id/spec` export repo (T3.3.1) — the Settings rail's Export\n * button. A NEW file, deliberately kept out of `repos/functions.ts` /\n * `repos/endpoints.ts` (T3.1.1 owns both), exactly as T3.2.1 put `/spec/import` in\n * its own `repos/spec-import.ts` for the same reason — the two nodes never\n * collide on the same file.\n *\n * **Goes through `W6WClient.request<T>()`, never `apiClient.console.*`.** There\n * is no SDK method for this route, exactly as `repos/spec-import.ts`'s own\n * docblock records for the sibling `/spec/import` route.\n *\n * `useSpecQuery` is gated on the caller's `enabled` flag (the export modal's own\n * open state) AND `collection !== null` — never on `ctx.kind` alone, and never\n * on mount: the contract pins that opening the Settings panel must issue ZERO\n * `/spec` requests, and exactly one fires per Export click.\n */\nimport { useQuery } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/** The collections that carry a `/spec` export route — `specCollectionForKind`\n * (`../lib/rail-settings.ts`) is the sole producer of this type's values. */\nexport type SpecCollection = \"functions\" | \"endpoints\" | \"workflows\";\n\n/**\n * Mirrors T2.1.1's `SpecDocument`, also mirrored by `repos/spec-import.ts`'s\n * `SpecImportDocument` for the sibling import route: the portable document a\n * `GET /<kind>/:id/spec` export produces. Not a bare `FunctionDef`/`EndpointDef`\n * — `id` is deleted server-side (`admin/spec.ts:96-108`) and connection/var\n * references ride as re-bindable `rebind` entries, never live ids.\n */\nexport interface SpecDocument {\n specVersion: string;\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: Record<string, unknown>;\n rebind: unknown[];\n}\n\n/**\n * `GET /<collection>/:id/spec`. `collection` is `null` for a kind the Export\n * button never renders on (`specCollectionForKind`'s `connection`\n * arm) — passing `null` disables the query regardless of `enabled`, so a\n * caller need not re-derive that guard itself.\n */\nexport function useSpecQuery(collection: SpecCollection | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: [\"spec\", collection, id],\n queryFn: async () => {\n const res = await apiClient.request<{ spec: SpecDocument }>({\n method: \"GET\",\n path: path`/${collection as SpecCollection}/${id}/spec`,\n });\n return res.body.spec;\n },\n enabled: enabled && collection !== null,\n });\n}\n"],"names":["endpointKey","id","callableKey","functionKey","COLLECTION_PATH","VERSION_INVOKE_VERB","versionsKey","kind","versionKey","versionNumber","useVersionsQuery","enabled","apiClient","useEmbedClient","useQuery","path","useVersionQuery","n","usePublishMutation","qc","useQueryClient","useMutation","_result","useSetEnabledMutation","vars","useRevertMutation","definitionKey","workflowKey","invalidateSavedCallable","useInvokeVersionMutation","run","historyKeys","constantsKey","useConstantsQuery","useSpecQuery","collection"],"mappings":";;;;;AA6CA,MAAMA,IAAc,CAACC,MAAeC,EAAY,YAAYD,CAAE,GACxDE,IAAc,CAACF,MAAeC,EAAY,YAAYD,CAAE,GAUxDG,IAAiF;AAAA,EACrF,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ,GAqDMC,IAA8D;AAAA,EAClE,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ;AAEO,SAASC,EAAYC,GAA2BN,GAAY;AACjE,SAAO,CAAC,YAAYM,GAAMN,CAAE;AAC9B;AAEO,SAASO,EAAWD,GAA2BN,GAAYQ,GAA8B;AAC9F,SAAO,CAAC,WAAWF,GAAMN,GAAIQ,CAAa;AAC5C;AAOO,SAASC,EAAiBH,GAA2BN,GAAYU,GAAkB;AACxF,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUR,EAAYC,GAAMN,CAAE;AAAA,IAC9B,SAAS,YAAuC;AAC9C,cAAQM,GAAA;AAAA,QACN,KAAK;AACH,iBAAO,MAAMK,EAAU,UAAU,aAAaX,CAAE;AAAA,QAClD,KAAK;AACH,iBAAO,MAAMW,EAAU,UAAU,aAAaX,CAAE;AAAA,QAClD,KAAK;AAMH,kBAJY,MAAMW,EAAU,QAA0B;AAAA,YACpD,QAAQ;AAAA,YACR,MAAMG,KAAQX,EAAgB,QAAQ,IAAIH,CAAE;AAAA,UAAA,CAC7C,GACU;AAAA,MACb;AAAA,IAEJ;AA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