@w6w/embed 0.2.33 → 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-Cw85R4wk.js → DocumentFormModal-CLmdGx34.js} +2 -2
- package/dist/{DocumentFormModal-Cw85R4wk.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-CyEszfIu.js +106 -0
- package/dist/apps-CyEszfIu.js.map +1 -0
- 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/HistoryView.d.ts +3 -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-DsGrGKfe.js +178 -0
- package/dist/editor-apps-DsGrGKfe.js.map +1 -0
- package/dist/{editor-tools-Dn7TgCP4.js → editor-tools-Ct7YPPj8.js} +681 -783
- 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/history-query.d.ts +22 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/run-event-stream.d.ts +122 -0
- package/dist/lib/run-log-nodes.d.ts +43 -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/history.d.ts +5 -1
- package/dist/repos/saved-file-names.d.ts +10 -0
- package/dist/repos/workflows.d.ts +19 -13
- package/dist/repos.mjs +338 -329
- 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-fU5RsVTa.js +0 -252
- package/dist/ImportSpecModal-fU5RsVTa.js.map +0 -1
- package/dist/WorkflowEditor-C7oudiIb.js +0 -1169
- package/dist/WorkflowEditor-C7oudiIb.js.map +0 -1
- package/dist/apps-FMcQfyL2.js +0 -92
- package/dist/apps-FMcQfyL2.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-apps-HEOclsxL.js +0 -152
- package/dist/editor-apps-HEOclsxL.js.map +0 -1
- package/dist/editor-tools-Dn7TgCP4.js.map +0 -1
- package/dist/setup-incomplete-BHs3Lpfy.js.map +0 -1
- package/dist/spec-import-CGPqUUjN.js +0 -272
- package/dist/spec-import-CGPqUUjN.js.map +0 -1
- package/dist/workflows-Dz8LMjnt.js +0 -626
- package/dist/workflows-Dz8LMjnt.js.map +0 -1
package/dist/editors.mjs
CHANGED
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
var tn = Object.defineProperty;
|
|
3
3
|
var an = (t, i, a) => i in t ? tn(t, i, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[i] = a;
|
|
4
4
|
var Se = (t, i, a) => an(t, typeof i != "symbol" ? i + "" : i, a);
|
|
5
|
-
import { H as sn, E as on, B as rn, a as Re, J as xe, b as De } from "./WorkflowEditor-
|
|
6
|
-
import { W as Wt } from "./WorkflowEditor-
|
|
5
|
+
import { H as sn, E as on, B as rn, a as Re, J as xe, b as De } from "./WorkflowEditor-CxTuK8_d.js";
|
|
6
|
+
import { W as Wt } from "./WorkflowEditor-CxTuK8_d.js";
|
|
7
7
|
import { jsx as e, jsxs as o, Fragment as D } from "react/jsx-runtime";
|
|
8
8
|
import { EditButton as ln, DeleteButton as dn, Copyable as Ke, CodeBlock as cn, IconButton as pe, AppIcon as un, ExpressionInput as hn, StepBuilderModal as mn, ExpressionOptionsProvider as Te } from "@w6w/ui";
|
|
9
9
|
import { useState as g, Component as fn, useRef as _, useEffect as se, useMemo as L, useCallback as he } from "react";
|
|
10
10
|
import { b as pn, C as yn } from "./ConfirmModal-WqBfWftD.js";
|
|
11
|
-
import { D as vn } from "./DocumentFormModal-
|
|
11
|
+
import { D as vn } from "./DocumentFormModal-CLmdGx34.js";
|
|
12
12
|
import { u as ke } from "./project-context-Tvp-La7A.js";
|
|
13
|
-
import {
|
|
13
|
+
import { a2 as bn, a0 as gn, v as Oe, ad as kn, ac as wn } from "./documents-hgltn0xe.js";
|
|
14
14
|
import { ApiError as ye } from "@w6w/sdk";
|
|
15
|
-
import {
|
|
16
|
-
import { C as Sn, c as Ae } from "./editor-tools-
|
|
17
|
-
import { a as En, b as In } from "./use-callable-draft-
|
|
18
|
-
import { E as Fn, F as Pn } from "./CreateFunctionModal-
|
|
19
|
-
import { j as je } from "./callables-
|
|
15
|
+
import { l as Nn, j as Cn } from "./apps-CyEszfIu.js";
|
|
16
|
+
import { C as Sn, c as Ae } from "./editor-tools-Ct7YPPj8.js";
|
|
17
|
+
import { a as En, b as In } from "./use-callable-draft-7HwfTuYQ.js";
|
|
18
|
+
import { E as Fn, F as Pn } from "./CreateFunctionModal-CYNHJUGJ.js";
|
|
19
|
+
import { j as je } from "./callables-dLF2IcwA.js";
|
|
20
20
|
import { t as Bn, a as Me, c as Je, I as Rn, b as xn, p as ve, f as Dn, u as Ee, s as Le, m as We, g as Qe, i as Ie, e as Kn, h as Tn } from "./coerce-input-DFJ4n_wc.js";
|
|
21
21
|
import { e as me } from "./import-bindings-EUtxZ9Ti.js";
|
|
22
|
-
import { w as On, b as An, u as jn, s as Ue, r as qe, x as Mn } from "./endpoints-
|
|
22
|
+
import { w as On, b as An, u as jn, s as Ue, r as qe, x as Mn } from "./endpoints-DJxXRh-I.js";
|
|
23
|
+
import { i as $e, d as Jn, f as Ln } from "./spec-import-BKyfhTYG.js";
|
|
23
24
|
import { useQueryClient as we } from "@tanstack/react-query";
|
|
24
|
-
import { o as $e, a1 as Jn, a0 as Ln } from "./workflows-Dz8LMjnt.js";
|
|
25
25
|
import { SECRET_MASK as Wn } from "@w6w/sdk/console";
|
|
26
|
-
import { f as He, d as Qn } from "./setup-incomplete-
|
|
26
|
+
import { f as He, d as Qn } from "./setup-incomplete-6PAbN0EW.js";
|
|
27
27
|
import { n as _e, d as Un } from "./connections-CzsCyIxY.js";
|
|
28
|
-
import { u as qn } from "./editor-apps-
|
|
28
|
+
import { u as qn } from "./editor-apps-DsGrGKfe.js";
|
|
29
29
|
import { s as $n } from "./slug-BVdgiP_L.js";
|
|
30
30
|
function Hn(t) {
|
|
31
31
|
switch (t) {
|
|
@@ -227,7 +227,7 @@ function zn(t, i, a) {
|
|
|
227
227
|
const Xn = (t) => t instanceof Error ? t.message : String(t);
|
|
228
228
|
function Zn(t) {
|
|
229
229
|
var y;
|
|
230
|
-
const { kind: i, id: a, onError: h } = t, d =
|
|
230
|
+
const { kind: i, id: a, onError: h } = t, d = $e(i, a, !0), n = Jn(i), [c, I] = g(!1), v = ((y = d.data) == null ? void 0 : y.currentPublishedVersion) != null, N = i === "function" ? "fn-publish" : "ep-publish";
|
|
231
231
|
async function m() {
|
|
232
232
|
h(null), I(!0);
|
|
233
233
|
try {
|
|
@@ -491,7 +491,7 @@ function tt(t) {
|
|
|
491
491
|
} catch (r) {
|
|
492
492
|
c(void 0), v(fe(r));
|
|
493
493
|
} finally {
|
|
494
|
-
m(!1), y.invalidateQueries({ queryKey:
|
|
494
|
+
m(!1), y.invalidateQueries({ queryKey: Oe.root });
|
|
495
495
|
}
|
|
496
496
|
};
|
|
497
497
|
return /* @__PURE__ */ o("div", { className: "card", children: [
|
|
@@ -639,7 +639,7 @@ const at = ["action", "function", "workflow", "endpoint"], it = {
|
|
|
639
639
|
};
|
|
640
640
|
function Ze(t) {
|
|
641
641
|
var F;
|
|
642
|
-
const { kind: i, id: a, uses: h, dirty: d } = t, n = (h == null ? void 0 : h.app) ?? "", c = (h == null ? void 0 : h.connection) ?? "", I = we(), v = _e(n, n !== ""), N = (F =
|
|
642
|
+
const { kind: i, id: a, uses: h, dirty: d } = t, n = (h == null ? void 0 : h.app) ?? "", c = (h == null ? void 0 : h.connection) ?? "", I = we(), v = _e(n, n !== ""), N = (F = $e(i, a, !0).data) == null ? void 0 : F.enabled, m = Ln(i), y = v.isSuccess && !v.isFetching, s = L(() => new Set((v.data ?? []).map((k) => k.id)), [v.data]), P = He(
|
|
643
643
|
[{ id: "target", uses: h }],
|
|
644
644
|
() => y ? { state: "ready", ids: s } : void 0
|
|
645
645
|
).length, u = _({ id: a, had: !1 });
|
|
@@ -696,7 +696,7 @@ function en(t) {
|
|
|
696
696
|
).length > 0, R = L(
|
|
697
697
|
() => (Q.data ?? []).find((l) => l.key === F),
|
|
698
698
|
[Q.data, F]
|
|
699
|
-
), $ = ["function", "workflow"].filter(P), re = `Choose ${c.charAt(0).toLowerCase()}${c.slice(1)}`, S = An(P("function")), f =
|
|
699
|
+
), $ = ["function", "workflow"].filter(P), re = `Choose ${c.charAt(0).toLowerCase()}${c.slice(1)}`, S = An(P("function")), f = kn(void 0, P("workflow")), x = jn(P("endpoint")), Y = Ue(k, s === "function" && k !== ""), G = wn(k, s === "workflow" && k !== ""), Z = qe(k, s === "endpoint" && k !== ""), A = L(() => {
|
|
700
700
|
var l, E, w;
|
|
701
701
|
return s === "action" ? ve((R == null ? void 0 : R.params) ?? []) : s === "function" ? ve(((l = Y.data) == null ? void 0 : l.inputs) ?? []) : s === "workflow" ? W ? Dn(
|
|
702
702
|
(E = G.data) == null ? void 0 : E.workflow,
|
|
@@ -1455,7 +1455,7 @@ function ct(t) {
|
|
|
1455
1455
|
} catch (r) {
|
|
1456
1456
|
c(void 0), v(fe(r));
|
|
1457
1457
|
} finally {
|
|
1458
|
-
m(!1), y.invalidateQueries({ queryKey:
|
|
1458
|
+
m(!1), y.invalidateQueries({ queryKey: Oe.root });
|
|
1459
1459
|
}
|
|
1460
1460
|
}
|
|
1461
1461
|
return /* @__PURE__ */ o("div", { className: "card", children: [
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useQueryClient as c, useMutation as s } from "@tanstack/react-query";
|
|
2
2
|
import { path as d } from "@w6w/sdk";
|
|
3
3
|
import { u as a } from "./client-context-CX61Bgw-.js";
|
|
4
|
-
import { a as l, c as f, p,
|
|
4
|
+
import { a as l, c as f, r as p, w as m, u as b, t as F, i as r, z as M } from "./callables-dLF2IcwA.js";
|
|
5
5
|
import "@w6w/sdk/console";
|
|
6
|
-
const h = f("function"),
|
|
7
|
-
function
|
|
6
|
+
const h = f("function"), Q = "2";
|
|
7
|
+
function q(n) {
|
|
8
8
|
return n.console.functions.list();
|
|
9
9
|
}
|
|
10
10
|
function K(n = !0) {
|
|
11
11
|
return F("function", n);
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const E = (n) => l("function", n);
|
|
14
14
|
function O(n, t) {
|
|
15
15
|
return n.console.functions.get(t);
|
|
16
16
|
}
|
|
@@ -26,10 +26,10 @@ function A() {
|
|
|
26
26
|
mutationFn: (i) => n.console.functions.upsert(i.definition, {
|
|
27
27
|
ifUnmodifiedSince: i.ifUnmodifiedSince
|
|
28
28
|
}),
|
|
29
|
-
onSuccess: (i) => r(t, h,
|
|
29
|
+
onSuccess: (i) => r(t, h, E(i.id))
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function v(n, t, i, e) {
|
|
33
33
|
const u = { inputs: i };
|
|
34
34
|
return (e == null ? void 0 : e.allowUnpublished) === !0 && (u.allowUnpublished = !0), n.request({
|
|
35
35
|
method: "POST",
|
|
@@ -45,7 +45,7 @@ function E(n, t, i, e) {
|
|
|
45
45
|
function D() {
|
|
46
46
|
const n = a();
|
|
47
47
|
return s({
|
|
48
|
-
mutationFn: (t) =>
|
|
48
|
+
mutationFn: (t) => v(n, t.id, t.inputs, { allowUnpublished: !0 })
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
function _() {
|
|
@@ -107,20 +107,20 @@ function H() {
|
|
|
107
107
|
}
|
|
108
108
|
export {
|
|
109
109
|
G as E,
|
|
110
|
-
|
|
110
|
+
Q as F,
|
|
111
111
|
$ as a,
|
|
112
112
|
K as b,
|
|
113
113
|
g as c,
|
|
114
114
|
S as d,
|
|
115
115
|
y as e,
|
|
116
|
-
|
|
116
|
+
E as f,
|
|
117
117
|
h as g,
|
|
118
118
|
R as h,
|
|
119
119
|
O as i,
|
|
120
120
|
C as j,
|
|
121
|
-
|
|
121
|
+
v as k,
|
|
122
122
|
x as l,
|
|
123
|
-
|
|
123
|
+
q as m,
|
|
124
124
|
B as n,
|
|
125
125
|
_ as o,
|
|
126
126
|
H as p,
|
|
@@ -133,4 +133,4 @@ export {
|
|
|
133
133
|
z as w,
|
|
134
134
|
D as x
|
|
135
135
|
};
|
|
136
|
-
//# sourceMappingURL=endpoints-
|
|
136
|
+
//# sourceMappingURL=endpoints-DJxXRh-I.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoints-zOuwci2U.js","sources":["../src/repos/functions.ts","../src/repos/endpoints.ts"],"sourcesContent":["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":["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":";;;;;AA2CO,MAAMA,IAAeC,EAAgB,UAAU,GAIzCC,IAA4B;AAElC,SAASC,EAAcC,GAAmB;AAC/C,SAAOA,EAAO,QAAQ,UAAU,KAAA;AAClC;AAEO,SAASC,EAAkBC,IAAU,IAAM;AAChD,SAAOC,EAAsC,YAAYD,CAAO;AAClE;AAEO,MAAME,IAAc,CAACC,MAAeC,EAAY,YAAYD,CAAE;AAK9D,SAASE,EAAYP,GAAmBK,GAAY;AACzD,SAAOL,EAAO,QAAQ,UAAU,IAAIK,CAAE;AACxC;AAEO,SAASG,EAAiBH,GAAYH,IAAU,IAAM;AAC3D,SAAOO,EAA0D,YAAYJ,GAAIH,CAAO;AAC1F;AAEO,SAASQ,IAA0B;AACxC,SAAOC,EAAwB,UAAU;AAC3C;AAWO,SAASC,IAAiC;AAC/C,QAAMC,IAAYC,EAAA,GACZC,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACC,MACXL,EAAU,QAAQ,UAAU,OAAOK,EAAK,YAAqB;AAAA,MAC3D,mBAAmBA,EAAK;AAAA,IAAA,CACzB;AAAA,IACH,WAAW,CAACC,MAAUC,EAAwBL,GAAInB,GAAcQ,EAAYe,EAAM,EAAE,CAAC;AAAA,EAAA,CACtF;AACH;AAyBO,SAASE,EACdrB,GACAK,GACAiB,GACAC,GAC+B;AAC/B,QAAMC,IAAgC,EAAE,QAAAF,EAAA;AACxC,UAAIC,KAAA,gBAAAA,EAAM,sBAAqB,OAAMC,EAAK,mBAAmB,KACtDxB,EACJ,QAAiC;AAAA,IAChC,QAAQ;AAAA,IACR,MAAMyB,eAAkBpB,CAAE;AAAA,IAC1B,MAAAmB;AAAA,EAAA,CACD,EACA,KAAK,CAAC,EAAE,MAAME,SAAW;AAAA,IACxB,QAAQA,EAAI;AAAA,IACZ,cAAcA,EAAI;AAAA,IAClB,QAAQA,EAAI;AAAA,IACZ,YAAYA,EAAI;AAAA,EAAA,EAChB;AACN;AAEO,SAASC,IAA4B;AAC1C,QAAMd,IAAYC,EAAA;AAClB,SAAOG,EAAY;AAAA,IACjB,YAAY,CAACC,MACXG,EAAeR,GAAWK,EAAK,IAAIA,EAAK,QAAQ,EAAE,kBAAkB,GAAA,CAAM;AAAA,EAAA,CAC7E;AACH;AASO,SAASU,IAA6B;AAC3C,SAAOC,EAA2B,UAAU;AAC9C;AAEO,SAASC,IAA4B;AAC1C,SAAOC,EAA0B,UAAU;AAC7C;ACxDO,SAASC,EAAgBC,GAA6D;AAC3F,SAAOA,EAAG,WAAW,SAAYA,EAAG,WAAW,UAAUA,EAAG,eAAe;AAC7E;AAIO,MAAMC,IAA4B,KAK5BC,IAAetC,EAAgB,UAAU;AAE/C,SAASuC,EAAkBlC,IAAU,IAAM;AAChD,SAAOC,EAAsC,YAAYD,CAAO;AAClE;AAKO,SAASmC,EACdrC,GACAK,GACqD;AACrD,SAAOL,EAAO,QAAQ,UAAU,IAAIK,CAAE;AACxC;AAKO,MAAMiC,IAAc,CAACjC,MAAeC,EAAY,YAAYD,CAAE;AAK9D,SAASkC,EAAiBlC,GAAYH,IAAU,IAAM;AAC3D,SAAOO,EAA0D,YAAYJ,GAAIH,CAAO;AAC1F;AAUO,SAASsC,IAA0B;AACxC,QAAM3B,IAAYC,EAAA,GACZC,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA;AAAA,IAEjB,YAAY,CAACwB,MACX5B,EAAU,QAAQ,UAAU,OAAO4B,CAAmB;AAAA,IAGxD,WAAW,CAACtB,MAAUC,EAAwBL,GAAIoB,GAAcG,EAAYnB,EAAM,SAAS,EAAE,CAAC;AAAA,EAAA,CAC/F;AACH;AAUO,SAASuB,IAAiC;AAC/C,QAAM7B,IAAYC,EAAA,GACZC,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACC,MACXL,EAAU,QAAQ,UAAU,OAAOK,EAAK,YAAqB;AAAA,MAC3D,mBAAmBA,EAAK;AAAA,IAAA,CACzB;AAAA,IACH,WAAW,CAACC,MAAUC,EAAwBL,GAAIoB,GAAcG,EAAYnB,EAAM,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,IAA6B;AAC3C,SAAOjB,EAA2B,UAAU;AAC9C;AAGO,SAASkB,IAA4B;AAC1C,SAAOhB,EAA0B,UAAU;AAC7C;"}
|
|
1
|
+
{"version":3,"file":"endpoints-DJxXRh-I.js","sources":["../src/repos/functions.ts","../src/repos/endpoints.ts"],"sourcesContent":["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":["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":"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"}
|
package/dist/forms.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { C as _e, a as Je } from "./CreateFunctionModal-
|
|
2
|
+
import { C as _e, a as Je } from "./CreateFunctionModal-CYNHJUGJ.js";
|
|
3
3
|
import { jsx as t, jsxs as l, Fragment as te } from "react/jsx-runtime";
|
|
4
4
|
import { ApiError as I } from "@w6w/sdk";
|
|
5
5
|
import { EmptyState as A, DataTable as P, RowActionsMenu as U, useEnterSubmit as T, BudgetMeter as ie } from "@w6w/ui";
|
package/dist/index.mjs
CHANGED
|
@@ -1,147 +1,172 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { QueryClientProvider as
|
|
4
|
-
import { W6WProvider as
|
|
5
|
-
import { W6WUIProvider as
|
|
6
|
-
import { useState as v, useRef as x, useEffect as j, useCallback as F, useMemo as g, useContext as
|
|
7
|
-
import { E as
|
|
2
|
+
import { jsx as c, jsxs as Q } from "react/jsx-runtime";
|
|
3
|
+
import { QueryClientProvider as z, QueryClient as N, useQuery as O } from "@tanstack/react-query";
|
|
4
|
+
import { W6WProvider as _, useW6WClient as D, useW6WSession as V, createW6WUiAdapter as X } from "@w6w/react";
|
|
5
|
+
import { W6WUIProvider as H } from "@w6w/ui";
|
|
6
|
+
import { useState as v, useRef as x, useEffect as j, useCallback as F, useMemo as g, useContext as J, createContext as Y } from "react";
|
|
7
|
+
import { E as Z } from "./client-context-CX61Bgw-.js";
|
|
8
8
|
import { c as ee, D as te } from "./draft-registry-YF0tqNN0.js";
|
|
9
|
-
import { E as re, a as
|
|
10
|
-
import { b as
|
|
11
|
-
import { j as
|
|
9
|
+
import { E as re, a as se } from "./project-context-Tvp-La7A.js";
|
|
10
|
+
import { b as _e } from "./project-context-Tvp-La7A.js";
|
|
11
|
+
import { j as oe } from "./connections-CzsCyIxY.js";
|
|
12
12
|
import { D as ne } from "./credentials-4Nf2GfMc.js";
|
|
13
13
|
import { e as ie, c as ue } from "./data-stores-UeQvwVCa.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { z as ae, A as ce, B as le, T as de } from "./documents-hgltn0xe.js";
|
|
15
|
+
import { r as fe, a as pe } from "./fields-CXHRR5eK.js";
|
|
16
|
+
import { l as ye } from "./models-CI0vLJ6o.js";
|
|
17
|
+
import { path as P } from "@w6w/sdk";
|
|
18
18
|
import { E as me } from "./theme-context-E2ZhlXDX.js";
|
|
19
|
-
class
|
|
20
|
-
constructor(
|
|
21
|
-
super("The w6w API rejected the embed session token (401).", { cause:
|
|
19
|
+
class he extends Error {
|
|
20
|
+
constructor(i) {
|
|
21
|
+
super("The w6w API rejected the embed session token (401).", { cause: i }), this.name = "EmbedAuthError";
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function be(o, i, e) {
|
|
25
25
|
if (e) return { status: "error", error: e };
|
|
26
|
-
switch (
|
|
26
|
+
switch (o) {
|
|
27
27
|
case "ready":
|
|
28
28
|
case "renewing":
|
|
29
29
|
return { status: "ready", error: null };
|
|
30
30
|
case "error":
|
|
31
|
-
return { status: "error", error:
|
|
31
|
+
return { status: "error", error: i };
|
|
32
32
|
case "loading":
|
|
33
33
|
case "expired":
|
|
34
34
|
return { status: "connecting", error: null };
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const ve = 10;
|
|
38
|
+
async function je(o, i) {
|
|
39
|
+
var a;
|
|
40
|
+
const e = [];
|
|
41
|
+
let n;
|
|
42
|
+
for (let r = 0; r < ve; r++) {
|
|
43
|
+
const s = { project: i, kind: "saved_file" };
|
|
44
|
+
n !== void 0 && (s.cursor = n);
|
|
45
|
+
const t = await o.request({
|
|
46
|
+
method: "GET",
|
|
47
|
+
path: "/assets",
|
|
48
|
+
query: s
|
|
49
|
+
});
|
|
50
|
+
for (const u of t.body.assets ?? [])
|
|
51
|
+
e.push({ path: u.name, size: (a = u.latestVersion) == null ? void 0 : a.totalBytes });
|
|
52
|
+
if (n = typeof t.body.nextCursor == "string" && t.body.nextCursor !== "" ? t.body.nextCursor : void 0, !n) break;
|
|
53
|
+
}
|
|
54
|
+
return e;
|
|
55
|
+
}
|
|
56
|
+
async function ge(o, i) {
|
|
57
|
+
return (await o.request({
|
|
39
58
|
method: "POST",
|
|
40
|
-
path:
|
|
59
|
+
path: P`/subscriptions/${i}/listen`,
|
|
41
60
|
body: {}
|
|
42
61
|
})).body;
|
|
43
62
|
}
|
|
44
|
-
async function
|
|
45
|
-
return (await
|
|
63
|
+
async function we(o, i, e, n) {
|
|
64
|
+
return (await o.request({
|
|
46
65
|
method: "GET",
|
|
47
|
-
path:
|
|
48
|
-
query: { wait: String((
|
|
49
|
-
signal:
|
|
66
|
+
path: P`/subscriptions/${i}/listen/${e}`,
|
|
67
|
+
query: { wait: String((n == null ? void 0 : n.waitSeconds) ?? 0) },
|
|
68
|
+
signal: n == null ? void 0 : n.signal
|
|
50
69
|
})).body.session;
|
|
51
70
|
}
|
|
52
|
-
async function
|
|
53
|
-
await
|
|
71
|
+
async function Ee(o, i, e) {
|
|
72
|
+
await o.request({
|
|
54
73
|
method: "DELETE",
|
|
55
|
-
path:
|
|
74
|
+
path: P`/subscriptions/${i}/listen/${e}`
|
|
56
75
|
});
|
|
57
76
|
}
|
|
58
77
|
function R() {
|
|
59
|
-
return new
|
|
78
|
+
return new N({
|
|
60
79
|
defaultOptions: { queries: { retry: !1, refetchOnWindowFocus: !1 } }
|
|
61
80
|
});
|
|
62
81
|
}
|
|
63
|
-
function
|
|
64
|
-
return /* @__PURE__ */
|
|
82
|
+
function Se({ children: o }) {
|
|
83
|
+
return /* @__PURE__ */ c(Z, { client: D(), children: o });
|
|
65
84
|
}
|
|
66
|
-
function
|
|
67
|
-
const e =
|
|
68
|
-
const
|
|
69
|
-
return typeof
|
|
70
|
-
const
|
|
71
|
-
return
|
|
72
|
-
}), typeof
|
|
73
|
-
const
|
|
74
|
-
return
|
|
75
|
-
}), typeof
|
|
76
|
-
const u =
|
|
77
|
-
return u ? ue(e, u,
|
|
78
|
-
}), typeof
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
function Ce({ theme: o, children: i }) {
|
|
86
|
+
const e = D(), n = se(), a = g(() => {
|
|
87
|
+
const r = X(e);
|
|
88
|
+
return typeof r.updateConnection != "function" && (r.updateConnection = (s, t) => oe(e, s, t)), ne(r, e), typeof r.listModelRoutes != "function" && (r.listModelRoutes = async (s) => {
|
|
89
|
+
const t = s || n;
|
|
90
|
+
return t ? (await ye(e, t)).map((l) => ({ name: l.name, model: l.modelId, status: l.status })) : [];
|
|
91
|
+
}), typeof r.listDataStores != "function" && (r.listDataStores = async (s) => {
|
|
92
|
+
const t = s || n;
|
|
93
|
+
return t ? ie(e, t) : [];
|
|
94
|
+
}), typeof r.listDataStoreEntries != "function" && (r.listDataStoreEntries = async (s, t) => {
|
|
95
|
+
const u = t.project || n;
|
|
96
|
+
return u ? ue(e, u, s, t) : { items: [] };
|
|
97
|
+
}), typeof r.listDocuments != "function" && (r.listDocuments = async (s) => {
|
|
98
|
+
const t = s || n;
|
|
99
|
+
return t ? ae(e, t) : [];
|
|
100
|
+
}), typeof r.listSavedFiles != "function" && (r.listSavedFiles = async (s) => {
|
|
101
|
+
const t = s || n;
|
|
102
|
+
return t ? je(e, t) : [];
|
|
103
|
+
}), typeof r.loadNodeSamples != "function" && (r.loadNodeSamples = (s) => ce(e, s)), typeof r.loadTestInputs != "function" && (r.loadTestInputs = (s) => le(e, s)), typeof r.saveTestInput != "function" && (r.saveTestInput = (s, t, u) => de(e, s, t, u)), typeof r.resolveActionFields != "function" && (r.resolveActionFields = (s, t, u, l) => fe(e, s, t, u, l)), typeof r.resolveTriggerFields != "function" && (r.resolveTriggerFields = (s, t, u, l) => pe(e, s, t, u, l)), typeof r.startWebhookListen != "function" && (r.startWebhookListen = (s) => ge(e, s), r.pollWebhookListen = (s, t, u) => we(e, s, t, u), r.stopWebhookListen = (s, t) => Ee(e, s, t)), r;
|
|
104
|
+
}, [e, n]);
|
|
105
|
+
return /* @__PURE__ */ c(H, { api: a, theme: o, children: /* @__PURE__ */ c(me.Provider, { value: o, children: i }) });
|
|
81
106
|
}
|
|
82
|
-
const I =
|
|
83
|
-
function
|
|
84
|
-
return
|
|
107
|
+
const I = Y({ status: "connecting", error: null });
|
|
108
|
+
function Qe() {
|
|
109
|
+
return J(I);
|
|
85
110
|
}
|
|
86
|
-
function
|
|
87
|
-
eager:
|
|
88
|
-
authError:
|
|
111
|
+
function We({
|
|
112
|
+
eager: o,
|
|
113
|
+
authError: i,
|
|
89
114
|
onAcquire: e,
|
|
90
|
-
children:
|
|
115
|
+
children: n
|
|
91
116
|
}) {
|
|
92
|
-
const { status: a, error:
|
|
117
|
+
const { status: a, error: r, refresh: s } = V();
|
|
93
118
|
j(() => {
|
|
94
|
-
|
|
95
|
-
}, [
|
|
119
|
+
o && s();
|
|
120
|
+
}, [o, s]), j(() => {
|
|
96
121
|
(a === "loading" || a === "renewing") && e();
|
|
97
122
|
}, [a, e]);
|
|
98
|
-
const
|
|
99
|
-
() =>
|
|
100
|
-
[a,
|
|
123
|
+
const t = g(
|
|
124
|
+
() => be(a, r, i),
|
|
125
|
+
[a, r, i]
|
|
101
126
|
);
|
|
102
|
-
return /* @__PURE__ */
|
|
127
|
+
return /* @__PURE__ */ c(I.Provider, { value: t, children: n });
|
|
103
128
|
}
|
|
104
|
-
function
|
|
105
|
-
identityKey:
|
|
106
|
-
enabled:
|
|
129
|
+
function De({
|
|
130
|
+
identityKey: o,
|
|
131
|
+
enabled: i,
|
|
107
132
|
onState: e
|
|
108
133
|
}) {
|
|
109
|
-
const
|
|
134
|
+
const n = D(), a = O({
|
|
110
135
|
queryKey: ["w6w-embed", "default-project"],
|
|
111
|
-
enabled:
|
|
136
|
+
enabled: i,
|
|
112
137
|
queryFn: async () => {
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
115
|
-
return
|
|
138
|
+
const m = (await n.projects.list()).find((d) => d.isDefault === !0);
|
|
139
|
+
if (!m) throw new Error("The account has no default project.");
|
|
140
|
+
return m.id;
|
|
116
141
|
}
|
|
117
|
-
}), { isError:
|
|
118
|
-
() =>
|
|
119
|
-
[
|
|
142
|
+
}), { isError: r, error: s, data: t } = a, u = g(
|
|
143
|
+
() => r ? { project: null, status: "error", error: s } : t !== void 0 ? { project: t, status: "ready" } : { project: null, status: "resolving" },
|
|
144
|
+
[r, s, t]
|
|
120
145
|
);
|
|
121
146
|
return j(() => {
|
|
122
|
-
e(
|
|
123
|
-
}, [
|
|
147
|
+
e(o, u);
|
|
148
|
+
}, [o, u, e]), null;
|
|
124
149
|
}
|
|
125
|
-
function
|
|
126
|
-
apiOrigin:
|
|
127
|
-
getSession:
|
|
150
|
+
function ze({
|
|
151
|
+
apiOrigin: o,
|
|
152
|
+
getSession: i,
|
|
128
153
|
identityKey: e,
|
|
129
|
-
fallback:
|
|
154
|
+
fallback: n = null,
|
|
130
155
|
eager: a = !1,
|
|
131
|
-
theme:
|
|
132
|
-
ready:
|
|
133
|
-
project:
|
|
156
|
+
theme: r,
|
|
157
|
+
ready: s,
|
|
158
|
+
project: t,
|
|
134
159
|
fetch: u,
|
|
135
|
-
children:
|
|
160
|
+
children: l
|
|
136
161
|
}) {
|
|
137
|
-
const [
|
|
162
|
+
const [m] = v(ee), [d, L] = v(() => ({
|
|
138
163
|
identityKey: e,
|
|
139
164
|
queryClient: R()
|
|
140
|
-
})), M = e !== d.identityKey,
|
|
141
|
-
M || (
|
|
142
|
-
const w =
|
|
143
|
-
|
|
144
|
-
const [
|
|
165
|
+
})), M = e !== d.identityKey, T = x({ apiOrigin: o, project: t, getSession: i });
|
|
166
|
+
M || (T.current = { apiOrigin: o, project: t, getSession: i });
|
|
167
|
+
const w = T.current, q = x(w.getSession);
|
|
168
|
+
q.current = w.getSession;
|
|
169
|
+
const [B] = v(() => () => q.current());
|
|
145
170
|
j(() => {
|
|
146
171
|
if (e === d.identityKey) return;
|
|
147
172
|
let p = !1;
|
|
@@ -150,48 +175,48 @@ function Qe({
|
|
|
150
175
|
};
|
|
151
176
|
return d.identityKey === null ? (f(), () => {
|
|
152
177
|
p = !0;
|
|
153
|
-
}) : (
|
|
178
|
+
}) : (m.flushAll().then(f, f), () => {
|
|
154
179
|
p = !0;
|
|
155
180
|
});
|
|
156
|
-
}, [e, d.identityKey,
|
|
181
|
+
}, [e, d.identityKey, m]);
|
|
157
182
|
const E = d.queryClient;
|
|
158
183
|
j(() => () => E.clear(), [E]);
|
|
159
|
-
const [
|
|
160
|
-
|
|
184
|
+
const [S, K] = v(null), U = F((p, f) => {
|
|
185
|
+
K(
|
|
161
186
|
(b) => b && b.key === p && b.state.project === f.project && b.state.status === f.status && b.state.error === f.error ? b : { key: p, state: f }
|
|
162
187
|
);
|
|
163
|
-
}, []), [
|
|
188
|
+
}, []), [C, A] = v(null), $ = g(() => {
|
|
164
189
|
const p = d.queryClient;
|
|
165
190
|
return (f) => {
|
|
166
|
-
|
|
191
|
+
A({ key: p, error: new he(f) });
|
|
167
192
|
};
|
|
168
|
-
}, [d.queryClient]),
|
|
169
|
-
return h === null ?
|
|
170
|
-
|
|
193
|
+
}, [d.queryClient]), G = F(() => A(null), []), h = d.identityKey, y = w.project, W = typeof y == "object" && y !== null && !Array.isArray(y) && y.use === "default", k = g(() => typeof y == "string" ? { project: y, status: "ready" } : W ? S && S.key === h ? S.state : { project: null, status: "resolving" } : { project: null, status: "ready" }, [y, W, S, h]);
|
|
194
|
+
return h === null ? n : /* @__PURE__ */ c(te, { registry: m, children: /* @__PURE__ */ c(z, { client: E, children: /* @__PURE__ */ Q(
|
|
195
|
+
_,
|
|
171
196
|
{
|
|
172
197
|
baseUrl: w.apiOrigin,
|
|
173
|
-
getSession:
|
|
198
|
+
getSession: B,
|
|
174
199
|
identityKey: h,
|
|
175
|
-
ready:
|
|
176
|
-
project:
|
|
200
|
+
ready: s,
|
|
201
|
+
project: k.project ?? void 0,
|
|
177
202
|
fetch: u,
|
|
178
|
-
onUnauthorized:
|
|
203
|
+
onUnauthorized: $,
|
|
179
204
|
children: [
|
|
180
|
-
W ? /* @__PURE__ */
|
|
181
|
-
|
|
205
|
+
W ? /* @__PURE__ */ c(
|
|
206
|
+
De,
|
|
182
207
|
{
|
|
183
208
|
identityKey: h,
|
|
184
|
-
enabled:
|
|
185
|
-
onState:
|
|
209
|
+
enabled: s !== !1,
|
|
210
|
+
onState: U
|
|
186
211
|
}
|
|
187
212
|
) : null,
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
|
|
213
|
+
/* @__PURE__ */ c(re.Provider, { value: k, children: /* @__PURE__ */ c(
|
|
214
|
+
We,
|
|
190
215
|
{
|
|
191
216
|
eager: a,
|
|
192
|
-
authError:
|
|
193
|
-
onAcquire:
|
|
194
|
-
children: /* @__PURE__ */
|
|
217
|
+
authError: C && C.key === E ? C.error : null,
|
|
218
|
+
onAcquire: G,
|
|
219
|
+
children: /* @__PURE__ */ c(Se, { children: /* @__PURE__ */ c(Ce, { theme: r, children: l }) })
|
|
195
220
|
}
|
|
196
221
|
) })
|
|
197
222
|
]
|
|
@@ -199,9 +224,9 @@ function Qe({
|
|
|
199
224
|
) }, h) });
|
|
200
225
|
}
|
|
201
226
|
export {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
227
|
+
he as EmbedAuthError,
|
|
228
|
+
ze as W6WEmbedProvider,
|
|
229
|
+
_e as useEmbedProject,
|
|
230
|
+
Qe as useEmbedStatus
|
|
206
231
|
};
|
|
207
232
|
//# sourceMappingURL=index.mjs.map
|