@w6w/embed 0.2.11 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -5
- package/dist/ConfirmModal-Pv2-A_3U.js +186 -0
- package/dist/ConfirmModal-Pv2-A_3U.js.map +1 -0
- package/dist/{CreateFunctionModal-D6CQLpa_.js → CreateFunctionModal-DScxp_LN.js} +2 -2
- package/dist/{CreateFunctionModal-D6CQLpa_.js.map → CreateFunctionModal-DScxp_LN.js.map} +1 -1
- package/dist/{DocumentFormModal-YauVdolr.js → DocumentFormModal-Br4s8wmi.js} +3 -3
- package/dist/{DocumentFormModal-YauVdolr.js.map → DocumentFormModal-Br4s8wmi.js.map} +1 -1
- package/dist/ImportSpecModal-Cpzp8ndt.js +251 -0
- package/dist/ImportSpecModal-Cpzp8ndt.js.map +1 -0
- package/dist/{ModelRoutesManager-BGESQahw.js → ModelRoutesManager-1Ac5wcas.js} +3 -3
- package/dist/{ModelRoutesManager-BGESQahw.js.map → ModelRoutesManager-1Ac5wcas.js.map} +1 -1
- package/dist/WorkflowEditor-CmhXHRxi.js +1109 -0
- package/dist/WorkflowEditor-CmhXHRxi.js.map +1 -0
- package/dist/apps-ItBvnWX3.js +92 -0
- package/dist/apps-ItBvnWX3.js.map +1 -0
- package/dist/chrome/DangerZone.d.ts +4 -3
- package/dist/chrome/ExecutionProfileHeader.d.ts +3 -3
- package/dist/chrome/JsonToggle.d.ts +29 -20
- package/dist/chrome/Modal.d.ts +3 -1
- package/dist/chrome/RightRail.d.ts +6 -1
- package/dist/chrome/VersionHistoryModal.d.ts +2 -0
- package/dist/chrome/index.d.ts +1 -0
- package/dist/chrome/workspace.d.ts +32 -1
- package/dist/{coerce-input-DttlcSdO.js → coerce-input-DFJ4n_wc.js} +68 -69
- package/dist/coerce-input-DFJ4n_wc.js.map +1 -0
- package/dist/{connections-D7cgXhDS.js → connections-CzsCyIxY.js} +10 -10
- package/dist/{connections-D7cgXhDS.js.map → connections-CzsCyIxY.js.map} +1 -1
- package/dist/{credentials-DaQU3Ca_.js → credentials-Cn92LGhJ.js} +4 -4
- package/dist/{credentials-DaQU3Ca_.js.map → credentials-Cn92LGhJ.js.map} +1 -1
- package/dist/data-stores-UeQvwVCa.js +170 -0
- package/dist/data-stores-UeQvwVCa.js.map +1 -0
- package/dist/document-sources-DNmBojx6.js +169 -0
- package/dist/document-sources-DNmBojx6.js.map +1 -0
- package/dist/draft/use-workflow-draft.d.ts +2 -0
- package/dist/draft.mjs +2 -2
- package/dist/editor/PublishTooltip.d.ts +7 -0
- package/dist/editor/SetupIncompleteBanner.d.ts +12 -0
- package/dist/editor/StartingStateModal.d.ts +14 -0
- package/dist/editor/WorkflowSettingsModal.d.ts +6 -1
- package/dist/editor/WorkflowVariablesEditor.d.ts +6 -0
- package/dist/editor/definition.d.ts +4 -0
- package/dist/editor/json-apply.d.ts +29 -0
- package/dist/editor/step-problems-feed.d.ts +5 -0
- package/dist/editor/types.d.ts +2 -2
- package/dist/editor-apps-DkkC7wOQ.js +152 -0
- package/dist/editor-apps-DkkC7wOQ.js.map +1 -0
- package/dist/editor-tools-BR27RGto.js +1683 -0
- package/dist/editor-tools-BR27RGto.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +536 -478
- package/dist/editors.mjs.map +1 -1
- package/dist/forms.mjs +3 -3
- package/dist/{rail-settings-XYGToh00.js → import-bindings-EUtxZ9Ti.js} +90 -24
- package/dist/import-bindings-EUtxZ9Ti.js.map +1 -0
- package/dist/index.mjs +138 -108
- package/dist/index.mjs.map +1 -1
- package/dist/lib/binding-problems.d.ts +5 -1
- package/dist/lib/history-query.d.ts +45 -0
- package/dist/lib/import-bindings.d.ts +89 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/rail-settings.d.ts +1 -1
- package/dist/lib/setup-incomplete.d.ts +22 -0
- package/dist/lib/starting-data.d.ts +31 -0
- package/dist/lib/state-panel.d.ts +29 -0
- package/dist/lib/target-fields.d.ts +3 -15
- package/dist/lib/workflow-live-run.d.ts +84 -6
- package/dist/lib/workflow-validity.d.ts +64 -16
- package/dist/lib/workflow-variables.d.ts +1 -1
- package/dist/lib/workflow-version.d.ts +2 -0
- package/dist/lib.mjs +87 -72
- package/dist/lists/DataStoreList.d.ts +17 -0
- package/dist/lists/DataStoreView.d.ts +19 -0
- package/dist/lists/Logs.d.ts +19 -0
- package/dist/lists.d.ts +6 -0
- package/dist/lists.mjs +1255 -816
- package/dist/lists.mjs.map +1 -1
- package/dist/rail/ConnectionsTool.d.ts +2 -0
- package/dist/rail/HistoryTool.d.ts +2 -0
- package/dist/rail/StartingStateTool.d.ts +2 -0
- package/dist/rail/settings-sections.d.ts +4 -1
- package/dist/rail.mjs +1 -1
- package/dist/repos/connections.d.ts +1 -0
- package/dist/repos/constants.d.ts +12 -0
- package/dist/repos/data-stores.d.ts +84 -0
- package/dist/repos/history.d.ts +9 -0
- package/dist/repos/index.d.ts +2 -0
- package/dist/repos/spec-export.d.ts +3 -3
- package/dist/repos/spec-import.d.ts +30 -1
- package/dist/repos/step-tests.d.ts +2 -0
- package/dist/repos/webhook-listen.d.ts +35 -0
- package/dist/repos/workflows.d.ts +105 -2
- package/dist/repos.mjs +370 -328
- package/dist/repos.mjs.map +1 -1
- package/dist/setup-incomplete-BHs3Lpfy.js +199 -0
- package/dist/setup-incomplete-BHs3Lpfy.js.map +1 -0
- package/dist/{spec-export-CBbloO_n.js → spec-export-DGy5ijps.js} +72 -59
- package/dist/spec-export-DGy5ijps.js.map +1 -0
- package/dist/spec-import-SWOonsNr.js +116 -0
- package/dist/spec-import-SWOonsNr.js.map +1 -0
- package/dist/{step-tests-CivICmTq.js → step-tests-B4E4W3ly.js} +8 -7
- package/dist/step-tests-B4E4W3ly.js.map +1 -0
- package/dist/{use-callable-draft-DsALnSfF.js → use-callable-draft-DCauHt5o.js} +2 -2
- package/dist/{use-callable-draft-DsALnSfF.js.map → use-callable-draft-DCauHt5o.js.map} +1 -1
- package/dist/use-workflow-draft-l3P5KZzw.js +338 -0
- package/dist/use-workflow-draft-l3P5KZzw.js.map +1 -0
- package/dist/workflows-BZN4Hyz1.js +623 -0
- package/dist/workflows-BZN4Hyz1.js.map +1 -0
- package/package.json +4 -3
- package/src/styles.css +153 -1
- package/dist/ConfirmModal-BE-SdX-O.js +0 -185
- package/dist/ConfirmModal-BE-SdX-O.js.map +0 -1
- package/dist/ImportSpecModal-B7qd1Km2.js +0 -136
- package/dist/ImportSpecModal-B7qd1Km2.js.map +0 -1
- package/dist/WorkflowEditor-CwvmAGp2.js +0 -925
- package/dist/WorkflowEditor-CwvmAGp2.js.map +0 -1
- package/dist/apps-CboASBKr.js +0 -77
- package/dist/apps-CboASBKr.js.map +0 -1
- package/dist/coerce-input-DttlcSdO.js.map +0 -1
- package/dist/document-sources-UCwe8x77.js +0 -91
- package/dist/document-sources-UCwe8x77.js.map +0 -1
- package/dist/editor-apps-BUZWld-m.js +0 -95
- package/dist/editor-apps-BUZWld-m.js.map +0 -1
- package/dist/editor-tools-B_Lfx3kw.js +0 -1279
- package/dist/editor-tools-B_Lfx3kw.js.map +0 -1
- package/dist/rail-settings-XYGToh00.js.map +0 -1
- package/dist/spec-export-CBbloO_n.js.map +0 -1
- package/dist/spec-import-CW6R_Wk1.js +0 -469
- package/dist/spec-import-CW6R_Wk1.js.map +0 -1
- package/dist/step-tests-CivICmTq.js.map +0 -1
- package/dist/trigger-preview-DKxfjzUY.js +0 -145
- package/dist/trigger-preview-DKxfjzUY.js.map +0 -1
- package/dist/use-workflow-draft-DzAyUeA6.js +0 -316
- package/dist/use-workflow-draft-DzAyUeA6.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useQueryClient as c, useMutation as l, useQuery as
|
|
2
|
-
import { path as
|
|
3
|
-
import { u } from "./client-context-CX61Bgw-.js";
|
|
4
|
-
import { i as
|
|
5
|
-
import { o as
|
|
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-BZN4Hyz1.js";
|
|
6
6
|
const h = (t) => d("endpoint", t), m = (t) => d("function", t), a = {
|
|
7
7
|
function: "functions",
|
|
8
8
|
workflow: "workflows",
|
|
@@ -12,16 +12,16 @@ const h = (t) => d("endpoint", t), m = (t) => d("function", t), a = {
|
|
|
12
12
|
endpoint: "invoke",
|
|
13
13
|
workflow: "run"
|
|
14
14
|
};
|
|
15
|
-
function
|
|
15
|
+
function f(t, n) {
|
|
16
16
|
return ["versions", t, n];
|
|
17
17
|
}
|
|
18
|
-
function $(t, n,
|
|
19
|
-
return ["version", t, n,
|
|
18
|
+
function $(t, n, o) {
|
|
19
|
+
return ["version", t, n, o];
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const e =
|
|
23
|
-
return
|
|
24
|
-
queryKey:
|
|
21
|
+
function Q(t, n, o) {
|
|
22
|
+
const e = i();
|
|
23
|
+
return w({
|
|
24
|
+
queryKey: f(t, n),
|
|
25
25
|
queryFn: async () => {
|
|
26
26
|
switch (t) {
|
|
27
27
|
case "workflow":
|
|
@@ -31,36 +31,36 @@ function T(t, n, s) {
|
|
|
31
31
|
case "endpoint":
|
|
32
32
|
return (await e.request({
|
|
33
33
|
method: "GET",
|
|
34
|
-
path:
|
|
34
|
+
path: u`/${a.endpoint}/${n}/versions`
|
|
35
35
|
})).body;
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
-
enabled:
|
|
38
|
+
enabled: o && t !== null && n !== ""
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
return
|
|
44
|
-
queryKey: $(t, n,
|
|
41
|
+
function F(t, n, o, e) {
|
|
42
|
+
const s = i();
|
|
43
|
+
return w({
|
|
44
|
+
queryKey: $(t, n, o),
|
|
45
45
|
queryFn: async () => {
|
|
46
|
-
const r =
|
|
46
|
+
const r = o;
|
|
47
47
|
switch (t) {
|
|
48
48
|
case "workflow":
|
|
49
|
-
return await
|
|
49
|
+
return await s.workflows.getVersion(n, r);
|
|
50
50
|
case "function":
|
|
51
|
-
return await
|
|
51
|
+
return await s.functions.getVersion(n, r);
|
|
52
52
|
case "endpoint":
|
|
53
|
-
return (await
|
|
53
|
+
return (await s.request({
|
|
54
54
|
method: "GET",
|
|
55
|
-
path:
|
|
55
|
+
path: u`/${a.endpoint}/${n}/versions/${String(r)}`
|
|
56
56
|
})).body.version;
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
enabled: e && t !== null && n !== "" &&
|
|
59
|
+
enabled: e && t !== null && n !== "" && o !== null
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const n =
|
|
62
|
+
function O(t) {
|
|
63
|
+
const n = i(), o = c();
|
|
64
64
|
return l({
|
|
65
65
|
mutationFn: async (e) => {
|
|
66
66
|
switch (t) {
|
|
@@ -71,17 +71,15 @@ function Q(t) {
|
|
|
71
71
|
case "endpoint":
|
|
72
72
|
return (await n.request({
|
|
73
73
|
method: "POST",
|
|
74
|
-
path:
|
|
74
|
+
path: u`/${a.endpoint}/${e}/publish`
|
|
75
75
|
})).body;
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
-
onSuccess: (e,
|
|
79
|
-
s.invalidateQueries({ queryKey: w(t, o) });
|
|
80
|
-
}
|
|
78
|
+
onSuccess: (e, s) => o.invalidateQueries({ queryKey: f(t, s) })
|
|
81
79
|
});
|
|
82
80
|
}
|
|
83
81
|
function v(t) {
|
|
84
|
-
const n =
|
|
82
|
+
const n = i(), o = c();
|
|
85
83
|
return l({
|
|
86
84
|
mutationFn: async (e) => {
|
|
87
85
|
switch (t) {
|
|
@@ -92,17 +90,17 @@ function v(t) {
|
|
|
92
90
|
case "endpoint":
|
|
93
91
|
return (await n.request({
|
|
94
92
|
method: "POST",
|
|
95
|
-
path:
|
|
93
|
+
path: u`/${a.endpoint}/${e.id}/${e.enabled ? "enable" : "disable"}`
|
|
96
94
|
})).body;
|
|
97
95
|
}
|
|
98
96
|
},
|
|
99
|
-
onSuccess: (e,
|
|
100
|
-
|
|
97
|
+
onSuccess: (e, s) => {
|
|
98
|
+
o.invalidateQueries({ queryKey: f(t, s.id) });
|
|
101
99
|
}
|
|
102
100
|
});
|
|
103
101
|
}
|
|
104
|
-
function
|
|
105
|
-
const n =
|
|
102
|
+
function g(t) {
|
|
103
|
+
const n = i(), o = c();
|
|
106
104
|
return l({
|
|
107
105
|
mutationFn: async (e) => {
|
|
108
106
|
switch (t) {
|
|
@@ -113,29 +111,29 @@ function F(t) {
|
|
|
113
111
|
case "endpoint":
|
|
114
112
|
return (await n.request({
|
|
115
113
|
method: "POST",
|
|
116
|
-
path:
|
|
114
|
+
path: u`/${a.endpoint}/${e.id}/versions/${String(e.versionNumber)}/revert`
|
|
117
115
|
})).body;
|
|
118
116
|
}
|
|
119
117
|
},
|
|
120
|
-
onSuccess: (e,
|
|
118
|
+
onSuccess: (e, s) => {
|
|
121
119
|
let r;
|
|
122
120
|
switch (t) {
|
|
123
121
|
case "function":
|
|
124
|
-
r = m(
|
|
122
|
+
r = m(s.id);
|
|
125
123
|
break;
|
|
126
124
|
case "workflow":
|
|
127
|
-
r = b(
|
|
125
|
+
r = b(s.id);
|
|
128
126
|
break;
|
|
129
127
|
case "endpoint":
|
|
130
|
-
r = h(
|
|
128
|
+
r = h(s.id);
|
|
131
129
|
break;
|
|
132
130
|
}
|
|
133
|
-
|
|
131
|
+
y(o, f(t, s.id), r);
|
|
134
132
|
}
|
|
135
133
|
});
|
|
136
134
|
}
|
|
137
|
-
function
|
|
138
|
-
const n =
|
|
135
|
+
function I(t) {
|
|
136
|
+
const n = i(), o = c();
|
|
139
137
|
return l({
|
|
140
138
|
mutationFn: async (e) => {
|
|
141
139
|
if (t === "workflow") {
|
|
@@ -144,33 +142,48 @@ function _(t) {
|
|
|
144
142
|
}
|
|
145
143
|
return (await n.request({
|
|
146
144
|
method: "POST",
|
|
147
|
-
path:
|
|
145
|
+
path: u`/${a[t]}/${e.id}/versions/${String(e.versionNumber)}/${q[t]}`,
|
|
148
146
|
body: {}
|
|
149
147
|
})).body;
|
|
150
148
|
},
|
|
151
|
-
onSettled: () =>
|
|
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
|
|
152
163
|
});
|
|
153
164
|
}
|
|
154
|
-
function
|
|
155
|
-
const e =
|
|
156
|
-
return
|
|
165
|
+
function P(t, n, o) {
|
|
166
|
+
const e = i();
|
|
167
|
+
return w({
|
|
157
168
|
queryKey: ["spec", t, n],
|
|
158
169
|
queryFn: async () => (await e.request({
|
|
159
170
|
method: "GET",
|
|
160
|
-
path:
|
|
171
|
+
path: u`/${t}/${n}/spec`
|
|
161
172
|
})).body.spec,
|
|
162
|
-
enabled:
|
|
173
|
+
enabled: o && t !== null
|
|
163
174
|
});
|
|
164
175
|
}
|
|
165
176
|
export {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
I as a,
|
|
178
|
+
O as b,
|
|
179
|
+
K as c,
|
|
169
180
|
g as d,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
181
|
+
v as e,
|
|
182
|
+
P as f,
|
|
183
|
+
F as g,
|
|
184
|
+
Q as h,
|
|
185
|
+
f as i,
|
|
186
|
+
N as u,
|
|
174
187
|
$ as v
|
|
175
188
|
};
|
|
176
|
-
//# sourceMappingURL=spec-export-
|
|
189
|
+
//# sourceMappingURL=spec-export-DGy5ijps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-export-DGy5ijps.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,QAC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I,CAAC,IAAIiB,EAAK,EAAE,aAAa,OAAOA,EAAK,aAAa,CAAC,IAAInB,EAAoBE,CAAI,CAAC;AAAA,QAClH,MAAM,CAAA;AAAA,MAAC,CACR,GACU;AAAA,IACb;AAAA,IACA,WAAW,MAAMY,EAAG,kBAAkB,EAAE,UAAUY,EAAY,MAAM;AAAA,EAAA,CACrE;AACH;AC/UO,SAASC,IAAe;AAC7B,SAAO,CAAC,WAAW;AACrB;AAGO,SAASC,IAAoB;AAClC,QAAMrB,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUkB,EAAA;AAAA,IACV,SAAS,aACK,MAAMpB,EAAU,QAAmC;AAAA,MAC7D,QAAQ;AAAA,MACR,MAAM;AAAA,IAAA,CACP,GACU,KAAK;AAAA,EAClB,CACD;AACH;ACSO,SAASsB,EAAaC,GAAmClC,GAAYU,GAAkB;AAC5F,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAU,CAAC,QAAQqB,GAAYlC,CAAE;AAAA,IACjC,SAAS,aACK,MAAMW,EAAU,QAAgC;AAAA,MAC1D,QAAQ;AAAA,MACR,MAAMG,KAAQoB,CAA4B,IAAIlC,CAAE;AAAA,IAAA,CACjD,GACU,KAAK;AAAA,IAElB,SAASU,KAAWwB,MAAe;AAAA,EAAA,CACpC;AACH;"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { useQueryClient as c, useMutation as o, useQuery as r } from "@tanstack/react-query";
|
|
2
|
+
import { path as m } from "@w6w/sdk";
|
|
3
|
+
import { u } from "./client-context-CX61Bgw-.js";
|
|
4
|
+
import { i as d } from "./spec-import-invalidation-D3retX4Q.js";
|
|
5
|
+
function b(e) {
|
|
6
|
+
return e.shared ? e.sourceRepo == null ? "pending" : "synced" : "private";
|
|
7
|
+
}
|
|
8
|
+
function p(e) {
|
|
9
|
+
return ["documents", e];
|
|
10
|
+
}
|
|
11
|
+
function y(e, t) {
|
|
12
|
+
return ["documents", "detail", e, t];
|
|
13
|
+
}
|
|
14
|
+
function j(e, t, n = !0) {
|
|
15
|
+
const s = u();
|
|
16
|
+
return r({
|
|
17
|
+
queryKey: y(e, t),
|
|
18
|
+
queryFn: async () => await s.documents.get(e, { project: t }),
|
|
19
|
+
enabled: n
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function F(e, t = !0) {
|
|
23
|
+
const n = u();
|
|
24
|
+
return r({
|
|
25
|
+
queryKey: p(e),
|
|
26
|
+
// Cast to DocWithProvenance[], same as useDocumentQuery above: the wire
|
|
27
|
+
// response already carries `shared`/`source*`/`syncedAt` (repo.list()
|
|
28
|
+
// serializes every document the same way repo.get() does), but the SDK's
|
|
29
|
+
// own `Doc` type doesn't declare them yet (D-5). Without this cast,
|
|
30
|
+
// DocumentsPage.tsx's list rows have no type-visible way to branch on
|
|
31
|
+
// `d.shared` the way DocumentDetailPage.tsx already does.
|
|
32
|
+
queryFn: async () => await n.documents.list({ project: e }),
|
|
33
|
+
enabled: t
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function K() {
|
|
37
|
+
const e = u(), t = c();
|
|
38
|
+
return o({
|
|
39
|
+
mutationFn: (n) => e.documents.create(n.input, { project: n.project }),
|
|
40
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function Q() {
|
|
44
|
+
const e = u(), t = c();
|
|
45
|
+
return o({
|
|
46
|
+
mutationFn: (n) => e.documents.update(n.id, n.patch, { project: n.project }),
|
|
47
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function w() {
|
|
51
|
+
const e = u(), t = c();
|
|
52
|
+
return o({
|
|
53
|
+
mutationFn: (n) => e.documents.delete(n.id, { project: n.project }),
|
|
54
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function D() {
|
|
58
|
+
const e = u(), t = c();
|
|
59
|
+
return o({
|
|
60
|
+
mutationFn: (n) => e.request({
|
|
61
|
+
method: "POST",
|
|
62
|
+
path: m`/documents/${n.id}/sync`,
|
|
63
|
+
query: { project: n.project }
|
|
64
|
+
}),
|
|
65
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function a(e, t) {
|
|
69
|
+
return { ...e, project: t };
|
|
70
|
+
}
|
|
71
|
+
function l(e, t, n) {
|
|
72
|
+
return { ...a(e, t), selections: n };
|
|
73
|
+
}
|
|
74
|
+
function M(e) {
|
|
75
|
+
const t = u();
|
|
76
|
+
return o({
|
|
77
|
+
mutationFn: async (n) => (await t.request({
|
|
78
|
+
method: "POST",
|
|
79
|
+
path: "/spec/preview",
|
|
80
|
+
body: a(n, e)
|
|
81
|
+
})).body
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function P(e, t) {
|
|
85
|
+
const n = u(), s = c();
|
|
86
|
+
return o({
|
|
87
|
+
mutationFn: async (i) => (await n.request({
|
|
88
|
+
method: "POST",
|
|
89
|
+
path: "/spec/import",
|
|
90
|
+
body: l(i.document, e, i.selections)
|
|
91
|
+
})).body,
|
|
92
|
+
// A row exists in every `201` outcome (T2.1.2 §E creates it even when
|
|
93
|
+
// some references stayed unresolved), so the list is stale either way —
|
|
94
|
+
// but ONLY the list the imported kind actually belongs to (AC-3): the
|
|
95
|
+
// unconditional `functionsKey` this used to invalidate left an imported
|
|
96
|
+
// Endpoint or Workflow's own list stale while pointlessly invalidating
|
|
97
|
+
// Functions.
|
|
98
|
+
onSuccess: (i) => d(s, i.kind, t, e)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
Q as a,
|
|
103
|
+
P as b,
|
|
104
|
+
M as c,
|
|
105
|
+
l as d,
|
|
106
|
+
a as e,
|
|
107
|
+
y as f,
|
|
108
|
+
b as g,
|
|
109
|
+
p as h,
|
|
110
|
+
w as i,
|
|
111
|
+
j,
|
|
112
|
+
F as k,
|
|
113
|
+
D as l,
|
|
114
|
+
K as u
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=spec-import-SWOonsNr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-import-SWOonsNr.js","sources":["../src/repos/documents.ts","../src/repos/spec-import.ts"],"sourcesContent":["/**\n * The `documents` domain repo — wraps `@w6w/sdk`'s `client.documents.*` in\n * react-query (HITL-6). `QueryClientProvider` (`main.tsx`) stays the actual\n * cache; this module only centralizes the query-key factory and the\n * `queryFn`/`mutationFn` pairs so every page reads documents the same way.\n *\n * Documents are project-scoped (`documents.ts`'s `DocumentOptions.project`);\n * every mutation here invalidates the unscoped `[\"documents\"]` key, which\n * prefix-matches every project-scoped query key produced by\n * {@linkcode documentsKey} — the same invalidation shape `DocumentsPage.tsx`\n * used before this migration.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path, type Doc, type DocumentCreateInput, type DocumentPatch } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/**\n * T1.1.1's wire shape for one document, pinned here ahead of that node\n * merging (this node is dispatched speculatively against it — see this\n * task's contract). `shared` and the six `source*`/`syncedAt` fields are all\n * additive over the SDK's own `Doc`, so a locally-created document simply\n * carries them as `null` (or `false` for `shared`) rather than omitting\n * them. Do not rename a field — the server produces these names verbatim.\n */\nexport interface DocWithProvenance extends Doc {\n shared: boolean;\n /** \"owner/name\" of the bound repository this document was pulled from. */\n sourceRepo: string | null;\n /** Repo-relative file path the document was pulled from. */\n sourcePath: string | null;\n /** The pulled file's content hash — NOT a commit SHA. */\n sourceSha: string | null;\n /** The repository's HEAD commit SHA at pull time — NOT a content hash. */\n sourceRefSha: string | null;\n /** Web link to the file; may be absent even when the rest of provenance is set. */\n sourceUrl: string | null;\n /** ISO-8601. Stamped at the document's last actual change, not at every sync. */\n syncedAt: string | null;\n}\n\n/**\n * Which provenance state `DocumentDetailPage.tsx`'s \"Source\" card should\n * render for `doc`. `shared` (not `sourceRepo`) is the gate: a shared\n * document whose provenance columns haven't been stamped yet (any document\n * synced before this feature shipped, until its next real-content sync —\n * tier-1 \"unchanged\" syncs never restamp provenance) is still shared, and\n * must say so, distinct from a genuinely private document.\n *\n * - `\"private\"` — `doc.shared` is false. No card.\n * - `\"pending\"` — shared, but `sourceRepo` hasn't been stamped yet.\n * - `\"synced\"` — shared, with full provenance available.\n */\nexport function documentProvenanceState(doc: DocWithProvenance): \"private\" | \"pending\" | \"synced\" {\n if (!doc.shared) return \"private\";\n return doc.sourceRepo == null ? \"pending\" : \"synced\";\n}\n\n/** Query key for a documents list, optionally scoped to a project. */\nexport function documentsKey(projectId?: string) {\n return [\"documents\", projectId] as const;\n}\n\n/**\n * Query key for a single document, scoped to a project (mirrors\n * {@linkcode useDocumentsQuery}'s fix at :72-79/:80-87 below — `projectId`\n * belongs in the key itself, not just the `queryFn`, so a render where the\n * key was cached under `projectId === undefined` genuinely changes key once\n * `ProjectContext` resolves the real one, instead of reusing the same cache\n * entry — and its `retry: false` wrong-project 404 — forever). Still sits\n * under the bare `[\"documents\"]` prefix every mutation below invalidates, so\n * an edit/delete refreshes this page too — `\"detail\"` keeps it from\n * colliding with {@linkcode documentsKey}'s own `[\"documents\", projectId]`\n * shape.\n */\nexport function documentKey(id: string, projectId?: string) {\n return [\"documents\", \"detail\", id, projectId] as const;\n}\n\n/**\n * A single document by id, cast to {@link DocWithProvenance} (D-5): the SDK's\n * `Doc` doesn't model T1.1.1's provenance fields yet, and this repo is not\n * the place to fork or extend `@w6w/sdk` (D-4). The `project` option is\n * passed exactly as {@linkcode useDocumentsQuery} passes it — a document in a\n * non-default project 404s without it. `enabled` defaults `true` to preserve\n * that unscoped fallback for a caller that genuinely wants it — same as\n * {@linkcode useDocumentsQuery}'s own `enabled` doc comment below — a\n * project-scoped page should instead pass `enabled: projectId != null` so it\n * never queries (and never renders) against the wrong project while\n * `ProjectContext`'s own project list is still resolving.\n */\nexport function useDocumentQuery(id: string, projectId?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: documentKey(id, projectId),\n queryFn: async () =>\n (await apiClient.documents.get(id, { project: projectId })) as DocWithProvenance,\n enabled,\n });\n}\n\n/**\n * The current project's documents (or the tenant default when unscoped).\n * `enabled` defaults `true` to preserve that unscoped fallback for a caller\n * that genuinely wants it — a project-scoped page should instead pass\n * `enabled: projectId != null` so it never queries (and never renders)\n * against the wrong project while `ProjectContext`'s own project list is\n * still resolving.\n */\nexport function useDocumentsQuery(projectId?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: documentsKey(projectId),\n // Cast to DocWithProvenance[], same as useDocumentQuery above: the wire\n // response already carries `shared`/`source*`/`syncedAt` (repo.list()\n // serializes every document the same way repo.get() does), but the SDK's\n // own `Doc` type doesn't declare them yet (D-5). Without this cast,\n // DocumentsPage.tsx's list rows have no type-visible way to branch on\n // `d.shared` the way DocumentDetailPage.tsx already does.\n queryFn: async () =>\n (await apiClient.documents.list({ project: projectId })) as DocWithProvenance[],\n enabled,\n });\n}\n\nexport function useCreateDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { input: DocumentCreateInput; project?: string }) =>\n apiClient.documents.create(vars.input, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\nexport function useUpdateDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; patch: DocumentPatch; project?: string }) =>\n apiClient.documents.update(vars.id, vars.patch, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\nexport function useDeleteDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project?: string }) =>\n apiClient.documents.delete(vars.id, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\n/**\n * Re-pulls a shared document from its bound repository (\"Sync\" button, T2.1.4)\n * — `POST /documents/:id/sync` (T3.1.1). No SDK method exists for this route\n * yet (D-4/D-5), so this goes through `apiClient.request()` directly, same\n * escape hatch `repo-sync.ts`'s `useSyncRepoNowMutation` uses. The document\n * routes are project-scoped by QUERY param, not a path segment (unlike\n * `repo-binding`'s `/projects/:id/...` shape), so `project` travels in\n * `query`, mirroring {@linkcode useDocumentQuery}'s own `{ project: … }` use.\n */\nexport function useSyncDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project?: string }) =>\n apiClient.request<{ document: DocWithProvenance }>({\n method: \"POST\",\n path: path`/documents/${vars.id}/sync`,\n query: { project: vars.project },\n }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n","/**\n * The `/spec/import` repo (T3.2.1). A NEW file, deliberately kept out of\n * `repos/functions.ts` / `repos/endpoints.ts` (T3.1.1 owns both) so the two\n * nodes never collide on the same file.\n *\n * **Every operation here goes through `W6WClient.request<T>()`, never\n * `apiClient.console.*`.** `T2.1.2`'s `inputs.touch` has no\n * `packages/wrappers` entry — there is no SDK method for this route — so\n * `request()` is the client's public escape hatch, exactly as\n * `repos/vars.ts`'s own docblock explains for the same reason.\n *\n * The posted `document` is forwarded to the server as-is (spread, never edited):\n * this module adds only `project` (and, on import, `selections`) beside it, validates nothing, and — this is the mechanism pin note 1\n * of the contract states from the side a wrong implementation must break —\n * never falls back to the sibling whole-definition save mutation\n * `FunctionIdentityModal.tsx` uses, on any response. `/spec/import` is where\n * the server-side sealed-secret walker lives (T2.1.2 §B runs\n * `assertNoSecretEnvelopes` over the WHOLE supplied body before any write);\n * a \"helpful\" fallback to that other write path would route a pasted\n * document straight around that check.\n *\n * T1.2.1 generalizes this over all three kinds: `onSuccess` invalidates the\n * ONE list key the imported document's own kind reads (`result.kind`, which\n * the server always echoes), never an unconditional `functionsKey`. The\n * decision of which key that is lives in `../lib/spec-import-invalidation.ts`\n * (a pure, `node --test`-loadable module). The three list keys are INJECTED by the host\n * (`listKeys`): Studio's `functionsKey`/`endpointsKey` live in its own `repos/callables`.\n */\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport type { PreviewDependency, Selection, SpecDependency } from \"../lib/import-bindings.ts\";\nimport {\n type SpecImportListKeys,\n invalidateImportedCallable,\n} from \"../lib/spec-import-invalidation.ts\";\n\n/**\n * Mirrors `T2.1.1`'s `SpecDocument` (`T2.1.1.contract.md:134-141`): the\n * portable document a `GET /<kind>/:id/spec` export produces and this\n * route consumes. Not a bare `FunctionDef` — connection/var references ride\n * as re-bindable `rebind` entries, never live ids.\n */\nexport interface SpecImportDocument {\n specVersion: string;\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: Record<string, unknown>;\n rebind: unknown[];\n}\n\n/** One reference site's outcome (T2.1.2 §E's `SpecImportReferenceReport`). */\nexport interface SpecImportReferenceReport {\n path: string;\n kind: string;\n resolved: boolean;\n /** Present only when `resolved` is `true`. */\n boundTo?: string;\n /** Present only when `resolved` is `false`. */\n reason?: string;\n}\n\n/** The `201` body `POST /spec/import` returns (T2.1.2 §E). */\nexport interface SpecImportResult {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: { id: string; key?: string; name?: string };\n references: SpecImportReferenceReport[];\n dependencies?: ImportDependencyStatus[];\n}\n\n/** IF-1 `POST /spec/preview` result: one entry per dependency, with server options + suggestion. */\nexport interface PreviewResult {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n dependencies: PreviewDependency[];\n references?: SpecImportReferenceReport[];\n}\n\n/** One dependency's outcome in the import result (IF-1 `dependencies` status[]). */\nexport interface ImportDependencyStatus {\n key: string;\n kind?: SpecDependency[\"kind\"];\n name?: string;\n status: \"bound\" | \"created\" | \"unconfigured\" | string;\n boundTo?: string;\n reason?: string;\n}\n\n/** The preview request body: the document plus the host project, sent explicitly. */\nexport function buildPreviewBody(\n document: Record<string, unknown>,\n project: string | undefined,\n): Record<string, unknown> {\n return { ...document, project };\n}\n\n/** The import request body: the preview body plus the FULL selections map (`unconfigured` included). */\nexport function buildImportBody(\n document: Record<string, unknown>,\n project: string | undefined,\n selections: Record<string, Selection>,\n): Record<string, unknown> {\n return { ...buildPreviewBody(document, project), selections };\n}\n\n/**\n * `POST /spec/preview` (IF-1). Read-only on the server; a failure rejects the mutation and the\n * caller blocks Create — there is NO fallback to posting the document verbatim to `/spec/import`.\n */\nexport function useSpecPreviewMutation(project: string | undefined) {\n const apiClient = useEmbedClient();\n return useMutation({\n mutationFn: async (document: Record<string, unknown>) => {\n const res = await apiClient.request<PreviewResult>({\n method: \"POST\",\n path: \"/spec/preview\",\n body: buildPreviewBody(document, project),\n });\n return res.body;\n },\n });\n}\n\n/**\n * `POST /spec/import`. Success is always `201` — including a partially\n * resolved import (T2.1.2 §E: \"report, never fail silently\"). This mutation\n * resolves on ANY `201`; branching on `references.every(r => r.resolved)` is\n * the caller's job (A5), never this repo's.\n *\n * `project` is the caller's current project — only the workflow arm reads it\n * (`listKeys.workflowsKey(project)`), but every caller passes it uniformly rather than branching on kind itself; see\n * `../lib/spec-import-invalidation.ts` for why the key differs by kind.\n */\nexport function useImportSpecMutation(project: string | undefined, listKeys: SpecImportListKeys) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: {\n document: Record<string, unknown>;\n selections: Record<string, Selection>;\n }) => {\n const res = await apiClient.request<SpecImportResult>({\n method: \"POST\",\n path: \"/spec/import\",\n body: buildImportBody(input.document, project, input.selections),\n });\n return res.body;\n },\n // A row exists in every `201` outcome (T2.1.2 §E creates it even when\n // some references stayed unresolved), so the list is stale either way —\n // but ONLY the list the imported kind actually belongs to (AC-3): the\n // unconditional `functionsKey` this used to invalidate left an imported\n // Endpoint or Workflow's own list stale while pointlessly invalidating\n // Functions.\n onSuccess: (result) => invalidateImportedCallable(qc, result.kind, listKeys, project),\n });\n}\n"],"names":["documentProvenanceState","doc","documentsKey","projectId","documentKey","id","useDocumentQuery","enabled","apiClient","useEmbedClient","useQuery","useDocumentsQuery","useCreateDocumentMutation","qc","useQueryClient","useMutation","vars","useUpdateDocumentMutation","useDeleteDocumentMutation","useSyncDocumentMutation","path","buildPreviewBody","document","project","buildImportBody","selections","useSpecPreviewMutation","useImportSpecMutation","listKeys","input","result","invalidateImportedCallable"],"mappings":";;;;AAoDO,SAASA,EAAwBC,GAA0D;AAChG,SAAKA,EAAI,SACFA,EAAI,cAAc,OAAO,YAAY,WADpB;AAE1B;AAGO,SAASC,EAAaC,GAAoB;AAC/C,SAAO,CAAC,aAAaA,CAAS;AAChC;AAcO,SAASC,EAAYC,GAAYF,GAAoB;AAC1D,SAAO,CAAC,aAAa,UAAUE,GAAIF,CAAS;AAC9C;AAcO,SAASG,EAAiBD,GAAYF,GAAoBI,IAAU,IAAM;AAC/E,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUN,EAAYC,GAAIF,CAAS;AAAA,IACnC,SAAS,YACN,MAAMK,EAAU,UAAU,IAAIH,GAAI,EAAE,SAASF,GAAW;AAAA,IAC3D,SAAAI;AAAA,EAAA,CACD;AACH;AAUO,SAASI,EAAkBR,GAAoBI,IAAU,IAAM;AACpE,QAAMC,IAAYC,EAAA;AAClB,SAAOC,EAAS;AAAA,IACd,UAAUR,EAAaC,CAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOhC,SAAS,YACN,MAAMK,EAAU,UAAU,KAAK,EAAE,SAASL,GAAW;AAAA,IACxD,SAAAI;AAAA,EAAA,CACD;AACH;AAEO,SAASK,IAA4B;AAC1C,QAAMJ,IAAYC,EAAA,GACZI,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB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EAAiBC,GAAUC,CAAO,GAAG,YAAAE,EAAA;AACnD;AAMO,SAASC,EAAuBH,GAA6B;AAClE,QAAMf,IAAYC,EAAA;AAClB,SAAOM,EAAY;AAAA,IACjB,YAAY,OAAOO,OACL,MAAMd,EAAU,QAAuB;AAAA,MACjD,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAMa,EAAiBC,GAAUC,CAAO;AAAA,IAAA,CACzC,GACU;AAAA,EACb,CACD;AACH;AAYO,SAASI,EAAsBJ,GAA6BK,GAA8B;AAC/F,QAAMpB,IAAYC,EAAA,GACZI,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,OAAOc,OAIL,MAAMrB,EAAU,QAA0B;AAAA,MACpD,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAMgB,EAAgBK,EAAM,UAAUN,GAASM,EAAM,UAAU;AAAA,IAAA,CAChE,GACU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQb,WAAW,CAACC,MAAWC,EAA2BlB,GAAIiB,EAAO,MAAMF,GAAUL,CAAO;AAAA,EAAA,CACrF;AACH;"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
const o = (s, e) => ["stepTests", s, e];
|
|
2
|
-
function
|
|
1
|
+
const o = (s, e) => ["stepTests", s, e], r = (s) => ["stepTests", s];
|
|
2
|
+
function p(s, e, t) {
|
|
3
3
|
return s.console.stepTests.list(e, t);
|
|
4
4
|
}
|
|
5
5
|
function c(s, e, t, n) {
|
|
6
6
|
return s.console.stepTests.save(e, t, n);
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function T(s, e, t, n) {
|
|
9
9
|
return s.console.stepTests.recordRun(e, t, n).then(() => {
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
13
|
o as a,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
c as s
|
|
14
|
+
p as l,
|
|
15
|
+
T as r,
|
|
16
|
+
c as s,
|
|
17
|
+
r as w
|
|
17
18
|
};
|
|
18
|
-
//# sourceMappingURL=step-tests-
|
|
19
|
+
//# sourceMappingURL=step-tests-B4E4W3ly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-tests-B4E4W3ly.js","sources":["../src/repos/step-tests.ts"],"sourcesContent":["/**\n * The `step tests` domain repo — wraps `@w6w/sdk`'s `client.console.stepTests.*`\n * (T2.6.1). Unlike every other domain migrated so far, its one read\n * (`listStepTests`) exports ONLY a query-key factory + a plain, explicit-client\n * fetcher — no hook. `WorkflowsPage.tsx`'s `stepTestsQueries` (`useQueries`\n * looping over `testGatedSteps`) is the sole read call site and cannot call a\n * hook inside `.map(...)` (Rules of Hooks); no other studio call site needs a\n * hook form. Mirrors `repos/apps.ts`'s \"build what's needed\" discipline,\n * applied to a query for the first time (every prior no-hook export in this\n * project was a mutation).\n *\n * None of these methods take a `project` scoping parameter — step tests are\n * scoped by workflow/tenant server-side, mirroring `console.connections`'s\n * own host shape.\n */\nimport type { W6WClient } from \"@w6w/sdk\";\nimport type { StepTest } from \"@w6w/sdk/console\";\n\nexport type { StepTest } from \"@w6w/sdk/console\";\n\n// ── step tests (list) — key + plain fetcher ONLY, no hook. See header. ────\n\nexport const stepTestsKey = (workflowId: string, stepId: string) =>\n [\"stepTests\", workflowId, stepId] as const;\n\n/** The prefix of every {@link stepTestsKey} of one workflow — invalidates all its steps at once. */\nexport const workflowStepTestsKey = (workflowId: string) => [\"stepTests\", workflowId] as const;\n\nexport function listStepTests(\n client: W6WClient,\n workflowId: string,\n stepId: string,\n): Promise<StepTest[]> {\n return client.console.stepTests.list(workflowId, stepId);\n}\n\n// ── mutations (facade-only) ─────────────────────────────────────────────\n\nexport function saveStepTest(\n client: W6WClient,\n workflowId: string,\n stepId: string,\n body: { name?: string; input: Record<string, unknown>; with: Record<string, unknown> },\n): Promise<StepTest> {\n return client.console.stepTests.save(workflowId, stepId, body);\n}\n\n/** Same void-discard reasoning as `recordTestRun` above — see that function's doc comment. */\nexport function recordStepTestRun(\n client: W6WClient,\n workflowId: string,\n stepId: string,\n body: {\n stepTestId?: string | null;\n status: string;\n input?: unknown;\n output?: unknown;\n error?: unknown;\n meta?: unknown;\n },\n): Promise<void> {\n return client.console.stepTests.recordRun(workflowId, stepId, body).then(() => undefined);\n}\n"],"names":["stepTestsKey","workflowId","stepId","workflowStepTestsKey","listStepTests","client","saveStepTest","body","recordStepTestRun"],"mappings":"AAsBO,MAAMA,IAAe,CAACC,GAAoBC,MAC/C,CAAC,aAAaD,GAAYC,CAAM,GAGrBC,IAAuB,CAACF,MAAuB,CAAC,aAAaA,CAAU;AAE7E,SAASG,EACdC,GACAJ,GACAC,GACqB;AACrB,SAAOG,EAAO,QAAQ,UAAU,KAAKJ,GAAYC,CAAM;AACzD;AAIO,SAASI,EACdD,GACAJ,GACAC,GACAK,GACmB;AACnB,SAAOF,EAAO,QAAQ,UAAU,KAAKJ,GAAYC,GAAQK,CAAI;AAC/D;AAGO,SAASC,EACdH,GACAJ,GACAC,GACAK,GAQe;AACf,SAAOF,EAAO,QAAQ,UAAU,UAAUJ,GAAYC,GAAQK,CAAI,EAAE,KAAK,MAAA;AAAA,GAAe;AAC1F;"}
|
|
@@ -2,7 +2,7 @@ import { useQueryClient as be } from "@tanstack/react-query";
|
|
|
2
2
|
import { useState as b, useRef as p, useCallback as f, useEffect as T, useMemo as Y } from "react";
|
|
3
3
|
import { u as Ee, i as Re, c as De, a as Te } from "./callables-tOlflvbl.js";
|
|
4
4
|
import { c as Z, p as Ce, d as Ae } from "./settings-rail--GdRMusb.js";
|
|
5
|
-
import { c as Oe, r as xe, n as Ne, i as Pe } from "./use-workflow-draft-
|
|
5
|
+
import { c as Oe, r as xe, n as Ne, i as Pe } from "./use-workflow-draft-l3P5KZzw.js";
|
|
6
6
|
import { u as Je } from "./client-context-CX61Bgw-.js";
|
|
7
7
|
import { u as qe } from "./draft-registry-YF0tqNN0.js";
|
|
8
8
|
function le(s, E, h) {
|
|
@@ -268,4 +268,4 @@ export {
|
|
|
268
268
|
Me as b,
|
|
269
269
|
ie as u
|
|
270
270
|
};
|
|
271
|
-
//# sourceMappingURL=use-callable-draft-
|
|
271
|
+
//# sourceMappingURL=use-callable-draft-DCauHt5o.js.map
|