@w6w/embed 0.1.1 → 0.2.0

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.
Files changed (148) hide show
  1. package/README.md +231 -4
  2. package/dist/ConfirmModal-RLbZT5_k.js +181 -0
  3. package/dist/ConfirmModal-RLbZT5_k.js.map +1 -0
  4. package/dist/CreateFunctionModal-DRsFx-FB.js +221 -0
  5. package/dist/CreateFunctionModal-DRsFx-FB.js.map +1 -0
  6. package/dist/DocumentFormModal-BExK1V-B.js +89 -0
  7. package/dist/DocumentFormModal-BExK1V-B.js.map +1 -0
  8. package/dist/ImportSpecModal-BDQIf6rg.js +136 -0
  9. package/dist/ImportSpecModal-BDQIf6rg.js.map +1 -0
  10. package/dist/W6WEmbedProvider.d.ts +22 -4
  11. package/dist/WorkflowEditor-DlbVv6Fs.js +854 -0
  12. package/dist/WorkflowEditor-DlbVv6Fs.js.map +1 -0
  13. package/dist/api-calls--JHyif6a.js +107 -0
  14. package/dist/api-calls--JHyif6a.js.map +1 -0
  15. package/dist/apps-1FNUwbGv.js +77 -0
  16. package/dist/apps-1FNUwbGv.js.map +1 -0
  17. package/dist/callables-3mFrMVG_.js +151 -0
  18. package/dist/callables-3mFrMVG_.js.map +1 -0
  19. package/dist/chrome/index.d.ts +6 -0
  20. package/dist/chrome/workspace.d.ts +29 -1
  21. package/dist/coerce-input-BicYr7nc.js +139 -0
  22. package/dist/coerce-input-BicYr7nc.js.map +1 -0
  23. package/dist/connections-CjjYeRqb.js +78 -0
  24. package/dist/connections-CjjYeRqb.js.map +1 -0
  25. package/dist/document-sources-C0grrtdq.js +86 -0
  26. package/dist/document-sources-C0grrtdq.js.map +1 -0
  27. package/dist/draft/index.d.ts +3 -1
  28. package/dist/draft/use-callable-draft.d.ts +65 -0
  29. package/dist/draft/workflow-save.d.ts +3 -0
  30. package/dist/draft.mjs +9 -5
  31. package/dist/draft.mjs.map +1 -1
  32. package/dist/editor/CallableEditorFrame.d.ts +33 -0
  33. package/dist/editor/EditorShell.d.ts +16 -0
  34. package/dist/editor/EndpointCards.d.ts +56 -0
  35. package/dist/editor/EndpointEditor.d.ts +26 -0
  36. package/dist/editor/FunctionEditor.d.ts +21 -0
  37. package/dist/editor/InputListEditor.d.ts +29 -0
  38. package/dist/editor/TargetSelector.d.ts +30 -0
  39. package/dist/editor/TargetSelector.types.d.ts +62 -0
  40. package/dist/editor/editor-apps.d.ts +8 -2
  41. package/dist/editor/types.d.ts +57 -0
  42. package/dist/editor-apps-BdenSV1o.js +95 -0
  43. package/dist/editor-apps-BdenSV1o.js.map +1 -0
  44. package/dist/editor-tools-RxmY5iyi.js +1279 -0
  45. package/dist/editor-tools-RxmY5iyi.js.map +1 -0
  46. package/dist/editor.mjs +2 -2166
  47. package/dist/editor.mjs.map +1 -1
  48. package/dist/editors/DocumentEditor.d.ts +20 -0
  49. package/dist/editors/doc-format.d.ts +3 -0
  50. package/dist/editors.d.ts +12 -0
  51. package/dist/editors.mjs +1313 -0
  52. package/dist/editors.mjs.map +1 -0
  53. package/dist/embed-status.d.ts +20 -0
  54. package/dist/endpoints-B2ynbZo-.js +227 -0
  55. package/dist/endpoints-B2ynbZo-.js.map +1 -0
  56. package/dist/forms/CreateEndpointModal.d.ts +54 -0
  57. package/dist/forms/CreateFunctionModal.d.ts +55 -0
  58. package/dist/forms/DocumentFormModal.d.ts +8 -0
  59. package/dist/forms/SecretsManager.d.ts +12 -0
  60. package/dist/forms/VarsManager.d.ts +29 -0
  61. package/dist/forms.d.ts +6 -0
  62. package/dist/forms.mjs +407 -0
  63. package/dist/forms.mjs.map +1 -0
  64. package/dist/index.d.ts +3 -1
  65. package/dist/index.mjs +153 -50
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/lib/callable-record.d.ts +21 -0
  68. package/dist/lib/coerce-input.d.ts +6 -0
  69. package/dist/lib/endpoint-editor.d.ts +23 -0
  70. package/dist/lib/index.d.ts +7 -0
  71. package/dist/lib/input-coverage.d.ts +28 -0
  72. package/dist/lib/input-seeding.d.ts +67 -0
  73. package/dist/lib/rail-settings.d.ts +3 -3
  74. package/dist/lib/recent-activity.d.ts +128 -0
  75. package/dist/lib/target-fields.d.ts +168 -0
  76. package/dist/lib/workflow-blank.d.ts +2 -0
  77. package/dist/lib.mjs +70 -48
  78. package/dist/lib.mjs.map +1 -1
  79. package/dist/lists/ActivitySummary.d.ts +29 -0
  80. package/dist/lists/CallableKindList.d.ts +34 -0
  81. package/dist/lists/ConnectionDetail.d.ts +17 -0
  82. package/dist/lists/ConnectionList.d.ts +16 -0
  83. package/dist/lists/DocumentList.d.ts +29 -0
  84. package/dist/lists/EndpointList.d.ts +19 -0
  85. package/dist/lists/FunctionList.d.ts +18 -0
  86. package/dist/lists/ReliabilityBoard.d.ts +23 -0
  87. package/dist/lists/RunHistory.d.ts +11 -0
  88. package/dist/lists/ServiceDetail.d.ts +20 -0
  89. package/dist/lists/WorkflowList.d.ts +19 -0
  90. package/dist/lists/vendor-history.d.ts +40 -0
  91. package/dist/lists.d.ts +20 -0
  92. package/dist/lists.mjs +1185 -0
  93. package/dist/lists.mjs.map +1 -0
  94. package/dist/project-context-BiCjv_E3.js +25 -0
  95. package/dist/project-context-BiCjv_E3.js.map +1 -0
  96. package/dist/project-context.d.ts +15 -1
  97. package/dist/rail/CallableRail.d.ts +12 -0
  98. package/dist/rail/CallableWorkspace.d.ts +16 -0
  99. package/dist/rail/SettingsTool.d.ts +7 -1
  100. package/dist/rail/settings-sections.d.ts +2 -2
  101. package/dist/rail-settings-XYGToh00.js +111 -0
  102. package/dist/rail-settings-XYGToh00.js.map +1 -0
  103. package/dist/rail.d.ts +11 -0
  104. package/dist/rail.mjs +35 -0
  105. package/dist/rail.mjs.map +1 -0
  106. package/dist/repos/api-calls.d.ts +4 -0
  107. package/dist/repos/apps.d.ts +14 -0
  108. package/dist/repos/callables.d.ts +91 -0
  109. package/dist/repos/connections.d.ts +33 -0
  110. package/dist/repos/dashboard.d.ts +4 -0
  111. package/dist/repos/endpoints.d.ts +125 -0
  112. package/dist/repos/functions.d.ts +79 -0
  113. package/dist/repos/index.d.ts +10 -0
  114. package/dist/repos/reliability.d.ts +42 -0
  115. package/dist/repos/saved-tests.d.ts +46 -0
  116. package/dist/repos/spec-export.d.ts +23 -0
  117. package/dist/repos/workflows.d.ts +138 -0
  118. package/dist/repos.mjs +174 -88
  119. package/dist/repos.mjs.map +1 -1
  120. package/dist/settings-rail--GdRMusb.js +33 -0
  121. package/dist/settings-rail--GdRMusb.js.map +1 -0
  122. package/dist/slug-C4ktDPdy.js +315 -0
  123. package/dist/slug-C4ktDPdy.js.map +1 -0
  124. package/dist/spec-export-Cf3VQSQS.js +176 -0
  125. package/dist/spec-export-Cf3VQSQS.js.map +1 -0
  126. package/dist/spec-import-CjmxyZDR.js +465 -0
  127. package/dist/spec-import-CjmxyZDR.js.map +1 -0
  128. package/dist/step-tests-CivICmTq.js +18 -0
  129. package/dist/step-tests-CivICmTq.js.map +1 -0
  130. package/dist/trigger-preview-VPkrryDl.js +120 -0
  131. package/dist/trigger-preview-VPkrryDl.js.map +1 -0
  132. package/dist/use-callable-draft-zHLpcr-b.js +271 -0
  133. package/dist/use-callable-draft-zHLpcr-b.js.map +1 -0
  134. package/dist/{use-workflow-draft-oI02dsP-.js → use-workflow-draft-DzAyUeA6.js} +48 -46
  135. package/dist/use-workflow-draft-DzAyUeA6.js.map +1 -0
  136. package/dist/vault-BSEWhMYC.js +117 -0
  137. package/dist/vault-BSEWhMYC.js.map +1 -0
  138. package/dist/workflow-blank-DyL3_RUA.js +14 -0
  139. package/dist/workflow-blank-DyL3_RUA.js.map +1 -0
  140. package/package.json +21 -5
  141. package/src/styles.css +408 -1
  142. package/dist/project-context-Dbk0Gr1K.js +0 -16
  143. package/dist/project-context-Dbk0Gr1K.js.map +0 -1
  144. package/dist/slug-ByKQgxrf.js +0 -642
  145. package/dist/slug-ByKQgxrf.js.map +0 -1
  146. package/dist/spec-import-HgO7ZkLZ.js +0 -898
  147. package/dist/spec-import-HgO7ZkLZ.js.map +0 -1
  148. package/dist/use-workflow-draft-oI02dsP-.js.map +0 -1
@@ -0,0 +1,1313 @@
1
+ "use client";
2
+ import { E as $e, a as Ce, J as Se, H as Ee, b as Ie } from "./WorkflowEditor-DlbVv6Fs.js";
3
+ import { W as pt } from "./WorkflowEditor-DlbVv6Fs.js";
4
+ import { jsx as e, jsxs as o, Fragment as K } from "react/jsx-runtime";
5
+ import { EditButton as He, DeleteButton as _e, Copyable as Fe, CodeBlock as Ve, IconButton as ye, AppIcon as Ye, ExpressionInput as Ge, StepBuilderModal as Xe, ExpressionOptionsProvider as Pe } from "@w6w/ui";
6
+ import { useState as N, useEffect as ce, useMemo as O, useCallback as de, useRef as le } from "react";
7
+ import { C as ze, a as Ze } from "./ConfirmModal-RLbZT5_k.js";
8
+ import { D as en } from "./DocumentFormModal-BExK1V-B.js";
9
+ import { u as ve } from "./project-context-BiCjv_E3.js";
10
+ import { L as nn, J as tn, m as Be, Y as an, X as on } from "./spec-import-CjmxyZDR.js";
11
+ import { ApiError as he } from "@w6w/sdk";
12
+ import { C as sn, c as De } from "./editor-tools-RxmY5iyi.js";
13
+ import { a as ln, b as rn } from "./use-callable-draft-zHLpcr-b.js";
14
+ import { E as cn, F as dn } from "./CreateFunctionModal-DRsFx-FB.js";
15
+ import { d as Re, x as un, t as hn, r as mn, s as Ke, q as Te, y as pn } from "./endpoints-B2ynbZo-.js";
16
+ import { t as fn, a as xe, c as Ae, I as yn, b as vn, p as me, f as gn, u as we, s as je, m as Je, g as Oe, e as kn, i as wn, d as bn } from "./coerce-input-BicYr7nc.js";
17
+ import { e as ue } from "./rail-settings-XYGToh00.js";
18
+ import { useQueryClient as Le } from "@tanstack/react-query";
19
+ import { SECRET_MASK as Nn } from "@w6w/sdk/console";
20
+ import { u as Cn } from "./apps-1FNUwbGv.js";
21
+ import { h as Sn } from "./connections-CjjYeRqb.js";
22
+ import { u as En } from "./editor-apps-BdenSV1o.js";
23
+ import { s as In } from "./slug-C4ktDPdy.js";
24
+ function Fn(a) {
25
+ switch (a) {
26
+ case "yaml":
27
+ return "yaml";
28
+ case "json":
29
+ return "json";
30
+ case "markdown":
31
+ return "markdown";
32
+ case "html":
33
+ return "markup";
34
+ case "text":
35
+ return "plaintext";
36
+ }
37
+ }
38
+ function ct({
39
+ documentId: a,
40
+ project: s,
41
+ onDeleted: i,
42
+ onBack: f,
43
+ slots: u
44
+ }) {
45
+ const n = ve(s), m = nn(a, n ?? void 0, n != null), F = tn(), [S, g] = N(!1), [d, r] = N(!1);
46
+ if (m.isPending)
47
+ return /* @__PURE__ */ e("div", { className: "w6w-embed-root", children: /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" }) });
48
+ const t = m.data;
49
+ if (!t) {
50
+ const C = (u == null ? void 0 : u.empty) === void 0 ? /* @__PURE__ */ o(K, { children: [
51
+ /* @__PURE__ */ e("h3", { children: "Document not found" }),
52
+ f && /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: f, children: "Back to documents" })
53
+ ] }) : u.empty;
54
+ return /* @__PURE__ */ e("div", { className: "w6w-embed-root", children: C });
55
+ }
56
+ const y = (u == null ? void 0 : u.header) === void 0 ? /* @__PURE__ */ e("h3", { children: t.key }) : u.header, c = (u == null ? void 0 : u.actions) === void 0 ? /* @__PURE__ */ e("div", { className: "card", children: /* @__PURE__ */ o("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
57
+ /* @__PURE__ */ e(ze, { resource: { kind: "document", key: t.key } }),
58
+ !t.shared && /* @__PURE__ */ o(K, { children: [
59
+ /* @__PURE__ */ e(
60
+ He,
61
+ {
62
+ label: "Edit",
63
+ onClick: () => g(!0),
64
+ "data-testid": "document-editor-edit"
65
+ }
66
+ ),
67
+ /* @__PURE__ */ e(
68
+ _e,
69
+ {
70
+ label: "Delete",
71
+ onClick: () => r(!0),
72
+ disabled: F.isPending,
73
+ "data-testid": "document-editor-delete"
74
+ }
75
+ )
76
+ ] })
77
+ ] }) }) : u.actions;
78
+ return /* @__PURE__ */ o("div", { className: "w6w-embed-root w6w-doc-editor", children: [
79
+ y,
80
+ c,
81
+ /* @__PURE__ */ o("div", { className: "card", children: [
82
+ /* @__PURE__ */ e("h3", { children: "Key" }),
83
+ /* @__PURE__ */ e(Fe, { value: t.key, readOnly: !0, children: /* @__PURE__ */ e(
84
+ "code",
85
+ {
86
+ style: {
87
+ overflowWrap: "anywhere",
88
+ display: "block",
89
+ minWidth: 0,
90
+ overflow: "hidden",
91
+ textOverflow: "ellipsis",
92
+ flex: 1
93
+ },
94
+ children: t.key
95
+ }
96
+ ) })
97
+ ] }),
98
+ /* @__PURE__ */ o("div", { className: "card", children: [
99
+ /* @__PURE__ */ e("h3", { children: "Content" }),
100
+ /* @__PURE__ */ o("p", { className: "muted small", children: [
101
+ "Format ",
102
+ /* @__PURE__ */ e("code", { children: t.format }),
103
+ ". Stored verbatim — this is a read-only view, not a rendered preview."
104
+ ] }),
105
+ /* @__PURE__ */ e(
106
+ Ve,
107
+ {
108
+ code: t.content,
109
+ language: Fn(t.format),
110
+ showLineNumbers: !0
111
+ }
112
+ )
113
+ ] }),
114
+ S && /* @__PURE__ */ e(
115
+ en,
116
+ {
117
+ initial: t,
118
+ project: n,
119
+ onClose: () => g(!1),
120
+ onSaved: () => g(!1)
121
+ }
122
+ ),
123
+ d && /* @__PURE__ */ e(
124
+ Ze,
125
+ {
126
+ title: "Delete document",
127
+ message: `Delete the document "${t.key}"? This cannot be undone.`,
128
+ confirmLabel: "Delete",
129
+ onConfirm: () => {
130
+ r(!1), n != null && F.mutate({ id: t.id, project: n }, { onSuccess: () => i == null ? void 0 : i() });
131
+ },
132
+ onClose: () => r(!1)
133
+ }
134
+ )
135
+ ] });
136
+ }
137
+ const Pn = {
138
+ kind: "action",
139
+ uses: { app: "", action: "", connection: null }
140
+ };
141
+ function se(a) {
142
+ return { input: [], ...a, target: a.target ?? Pn };
143
+ }
144
+ function be(a) {
145
+ const { target: s, input: i, ...f } = se(a), u = {
146
+ ...f,
147
+ key: String(a.key ?? "").trim()
148
+ };
149
+ fn(s) && (u.target = s);
150
+ const n = xe(i ?? [], { emptyMeansPassthrough: !0 });
151
+ return n !== void 0 && (u.input = n), u;
152
+ }
153
+ function Me(a) {
154
+ return a && a.length > 1 ? a : void 0;
155
+ }
156
+ function Bn(a, s) {
157
+ const i = Me(a);
158
+ return i ? i.find((f) => f.domain === s) ?? i.find((f) => f.default) ?? i[0] : null;
159
+ }
160
+ function Dn(a, s, i) {
161
+ return a ?? {
162
+ url: s ?? "",
163
+ urlByKey: i,
164
+ resolves: !0
165
+ };
166
+ }
167
+ function We(a) {
168
+ const s = Re(a.kind), i = a.slots, f = (i == null ? void 0 : i.backLabel) ?? s.editor.backLabel, u = () => a.onNavigate({ type: "list" });
169
+ return a.notFound ? /* @__PURE__ */ o("div", { children: [
170
+ /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: u, children: f }),
171
+ /* @__PURE__ */ o("div", { className: "card", children: [
172
+ /* @__PURE__ */ e("h3", { children: s.editor.notFoundTitle }),
173
+ /* @__PURE__ */ e("p", { className: "error", children: a.error })
174
+ ] })
175
+ ] }) : /* @__PURE__ */ o("div", { className: "exec-profile-editor", children: [
176
+ (i == null ? void 0 : i.header) ?? /* @__PURE__ */ e(
177
+ $e,
178
+ {
179
+ onBack: u,
180
+ backLabel: f,
181
+ title: { editable: !1, value: a.title },
182
+ titleAdornment: a.incomplete && /* @__PURE__ */ e("span", { className: "badge status-failed", children: "incomplete" }),
183
+ actions: /* @__PURE__ */ o(K, { children: [
184
+ a.headerActions,
185
+ /* @__PURE__ */ e(
186
+ "button",
187
+ {
188
+ type: "button",
189
+ className: "btn",
190
+ disabled: !a.canSave,
191
+ onClick: a.onSave,
192
+ children: a.isSaving ? "Saving…" : s.editor.saveLabel
193
+ }
194
+ ),
195
+ i == null ? void 0 : i.headerActions
196
+ ] })
197
+ }
198
+ ),
199
+ /* @__PURE__ */ o("div", { className: "exec-profile-body", children: [
200
+ a.error && /* @__PURE__ */ e("div", { className: "error", children: a.error }),
201
+ a.banners,
202
+ a.children
203
+ ] })
204
+ ] });
205
+ }
206
+ const Ne = [
207
+ {
208
+ value: "platform",
209
+ label: "Platform auth (default)",
210
+ hint: "A w6w token or a partner OIDC token, exactly like the rest of the API. The call runs as the caller."
211
+ },
212
+ {
213
+ value: "none",
214
+ label: "None — public",
215
+ hint: "Anyone with the URL can invoke this. The call runs as this Endpoint's owner."
216
+ },
217
+ {
218
+ value: "basic",
219
+ label: "Basic auth",
220
+ hint: "HTTP Basic with the username and password below."
221
+ },
222
+ {
223
+ value: "header",
224
+ label: "Header auth",
225
+ hint: "The named header must carry the value below."
226
+ },
227
+ {
228
+ value: "jwt",
229
+ label: "JWT (HMAC)",
230
+ hint: "A Bearer JWT, verified HS256 against the shared secret below."
231
+ }
232
+ ];
233
+ function Rn(a) {
234
+ var g;
235
+ const { entry: s, domainOptions: i, urlDomain: f, onUrlDomain: u, urlForm: n, onUrlForm: m } = a, F = s.urlByKey !== void 0 && s.urlByKey !== "", S = n === "key" && s.urlByKey ? s.urlByKey : s.url;
236
+ return /* @__PURE__ */ o("div", { className: "card", children: [
237
+ /* @__PURE__ */ e("h3", { children: "URL" }),
238
+ i && /* @__PURE__ */ o("label", { className: "field", children: [
239
+ /* @__PURE__ */ e("span", { children: "Domain" }),
240
+ /* @__PURE__ */ e(
241
+ "select",
242
+ {
243
+ "data-testid": "url-domain",
244
+ value: f ?? ((g = i[0]) == null ? void 0 : g.domain),
245
+ onChange: (d) => u(d.target.value),
246
+ children: i.map((d) => /* @__PURE__ */ e("option", { value: d.domain, children: d.domain + (d.default ? " · default" : "") + (d.resolves ? "" : " · not routable yet") }, d.domain))
247
+ }
248
+ )
249
+ ] }),
250
+ F && /* @__PURE__ */ e("fieldset", { className: "seg", "aria-label": "URL form", children: [
251
+ ["id", "By id", "The stable, host-issued address. Never changes."],
252
+ ["key", "By key", "The readable address, built from the account and this key."]
253
+ ].map(([d, r, t]) => /* @__PURE__ */ e(
254
+ "button",
255
+ {
256
+ type: "button",
257
+ className: `seg-btn${n === d ? " active" : ""}`,
258
+ "aria-pressed": n === d,
259
+ "data-testid": `url-form-${d}`,
260
+ title: t,
261
+ onClick: () => m(d),
262
+ children: r
263
+ },
264
+ d
265
+ )) }),
266
+ /* @__PURE__ */ e("div", { className: "row", style: { alignItems: "center", gap: "var(--w6w-sp-2)" }, children: /* @__PURE__ */ e(Fe, { value: S, readOnly: !0, children: /* @__PURE__ */ o("code", { style: { overflowWrap: "anywhere" }, children: [
267
+ /* @__PURE__ */ e("strong", { children: "POST" }),
268
+ " ",
269
+ /* @__PURE__ */ e("span", { "data-testid": "invoke-url", children: S || "…" })
270
+ ] }) }) }),
271
+ !s.resolves && /* @__PURE__ */ e("p", { className: "muted small", "data-testid": "url-unroutable", children: "Not routable yet — this domain has no DNS or TLS behind it, so a call to this address will not answer." }),
272
+ /* @__PURE__ */ e("p", { className: "muted small", style: { marginTop: "var(--w6w-sp-2)" }, children: "Send the declared input as a JSON body." })
273
+ ] });
274
+ }
275
+ function Kn(a) {
276
+ var u;
277
+ const { security: s, onPatch: i } = a, f = s.auth;
278
+ return /* @__PURE__ */ o("div", { className: "card", children: [
279
+ /* @__PURE__ */ e("h3", { children: "Security" }),
280
+ /* @__PURE__ */ o("label", { className: "field", children: [
281
+ /* @__PURE__ */ e("span", { children: "Who may call it" }),
282
+ /* @__PURE__ */ e(
283
+ "select",
284
+ {
285
+ value: f,
286
+ onChange: (n) => i({ auth: n.target.value }),
287
+ children: Ne.map((n) => /* @__PURE__ */ e("option", { value: n.value, children: n.label }, n.value))
288
+ }
289
+ ),
290
+ /* @__PURE__ */ e("span", { className: "hint", children: (u = Ne.find((n) => n.value === f)) == null ? void 0 : u.hint })
291
+ ] }),
292
+ f !== "platform" && /* @__PURE__ */ o("p", { className: "muted small", children: [
293
+ /* @__PURE__ */ e("strong", { children: "Runs as this Endpoint's owner." }),
294
+ " A caller authenticated by the policy above carries no w6w identity, so the target runs with the connections and data of whoever owns this Endpoint."
295
+ ] }),
296
+ f === "basic" && /* @__PURE__ */ o(K, { children: [
297
+ /* @__PURE__ */ o("label", { className: "field", children: [
298
+ /* @__PURE__ */ e("span", { children: "Username" }),
299
+ /* @__PURE__ */ e(
300
+ "input",
301
+ {
302
+ type: "text",
303
+ value: s.basicUser ?? "",
304
+ onChange: (n) => i({ basicUser: n.target.value })
305
+ }
306
+ )
307
+ ] }),
308
+ /* @__PURE__ */ e(
309
+ pe,
310
+ {
311
+ label: "Password",
312
+ value: s.basicPassword,
313
+ onChange: (n) => i({ basicPassword: n })
314
+ }
315
+ )
316
+ ] }),
317
+ f === "header" && /* @__PURE__ */ o(K, { children: [
318
+ /* @__PURE__ */ o("label", { className: "field", children: [
319
+ /* @__PURE__ */ e("span", { children: "Header name" }),
320
+ /* @__PURE__ */ e(
321
+ "input",
322
+ {
323
+ type: "text",
324
+ placeholder: "X-API-Key",
325
+ value: s.headerName ?? "",
326
+ onChange: (n) => i({ headerName: n.target.value })
327
+ }
328
+ )
329
+ ] }),
330
+ /* @__PURE__ */ e(
331
+ pe,
332
+ {
333
+ label: "Header value",
334
+ value: s.headerValue,
335
+ onChange: (n) => i({ headerValue: n })
336
+ }
337
+ )
338
+ ] }),
339
+ f === "jwt" && /* @__PURE__ */ e(
340
+ pe,
341
+ {
342
+ label: "JWT secret (HS256)",
343
+ value: s.jwtSecret,
344
+ onChange: (n) => i({ jwtSecret: n })
345
+ }
346
+ )
347
+ ] });
348
+ }
349
+ function pe(a) {
350
+ const s = a.value === Nn;
351
+ return /* @__PURE__ */ o("label", { className: "field", children: [
352
+ /* @__PURE__ */ e("span", { children: a.label }),
353
+ /* @__PURE__ */ e(
354
+ "input",
355
+ {
356
+ type: "password",
357
+ value: s ? "" : a.value ?? "",
358
+ placeholder: s ? "•••••••• (stored — type to replace)" : "",
359
+ onChange: (i) => a.onChange(i.target.value)
360
+ }
361
+ ),
362
+ s && /* @__PURE__ */ e("span", { className: "hint", children: "A secret is stored — type to replace it." })
363
+ ] });
364
+ }
365
+ function Tn(a) {
366
+ const { id: s, inputs: i } = a, [f, u] = N({}), [n, m] = N(void 0), [F, S] = N(null), g = Le(), d = un(), r = () => {
367
+ const t = {};
368
+ for (const y of i) {
369
+ const c = Ae(y.type, f[y.key] ?? "");
370
+ c !== void 0 && (t[y.key] = c);
371
+ }
372
+ d.mutate(
373
+ { id: s, input: t },
374
+ {
375
+ onSuccess: (y) => {
376
+ S(null), m(y);
377
+ },
378
+ onError: (y) => {
379
+ m(void 0), S((y instanceof he, y.message));
380
+ },
381
+ onSettled: () => g.invalidateQueries({ queryKey: Be.root })
382
+ }
383
+ );
384
+ };
385
+ return /* @__PURE__ */ o("div", { className: "card", children: [
386
+ /* @__PURE__ */ e("h3", { children: "Test invoke" }),
387
+ /* @__PURE__ */ e("p", { className: "muted small", children: "Dispatches the saved Endpoint to its target. Save any edits first. An Action or Function target returns a value; a Workflow target returns a run id to poll." }),
388
+ i.length === 0 && /* @__PURE__ */ e("p", { className: "muted small", children: "No declared inputs — the payload is passed through." }),
389
+ i.map((t) => {
390
+ const y = `ep-invoke-${s}-${t.key || t.label}`;
391
+ return /* @__PURE__ */ o("div", { className: "field", children: [
392
+ /* @__PURE__ */ o("label", { htmlFor: y, children: [
393
+ t.label || t.key,
394
+ t.required && " *"
395
+ ] }),
396
+ t.type === "boolean" ? /* @__PURE__ */ o(
397
+ "select",
398
+ {
399
+ id: y,
400
+ value: f[t.key] ?? "",
401
+ onChange: (c) => u((C) => ({ ...C, [t.key]: c.target.value })),
402
+ children: [
403
+ /* @__PURE__ */ e("option", { value: "", children: "—" }),
404
+ /* @__PURE__ */ e("option", { value: "true", children: "true" }),
405
+ /* @__PURE__ */ e("option", { value: "false", children: "false" })
406
+ ]
407
+ }
408
+ ) : /* @__PURE__ */ e(
409
+ "input",
410
+ {
411
+ id: y,
412
+ type: t.type === "number" ? "number" : "text",
413
+ value: f[t.key] ?? "",
414
+ placeholder: t.type === "json" ? "{ }" : t.hint ?? "",
415
+ onChange: (c) => u((C) => ({ ...C, [t.key]: c.target.value }))
416
+ }
417
+ )
418
+ ] }, t.key || t.label);
419
+ }),
420
+ /* @__PURE__ */ e("div", { className: "row", children: /* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: d.isPending, onClick: r, children: d.isPending ? "Invoking…" : "Invoke" }) }),
421
+ F && /* @__PURE__ */ e("div", { className: "result error", children: F }),
422
+ n !== void 0 && /* @__PURE__ */ e("pre", { className: "result", style: { overflow: "auto" }, children: JSON.stringify(n, null, 2) })
423
+ ] });
424
+ }
425
+ function qe(a) {
426
+ const { rows: s, onChange: i, title: f, description: u, emptyMeansPassthrough: n, uncoveredKeys: m } = a;
427
+ function F() {
428
+ i([...s, { key: "", label: "", type: "string" }]);
429
+ }
430
+ function S(d, r) {
431
+ i(s.map((t, y) => y === d ? { ...t, ...r } : t));
432
+ }
433
+ function g(d) {
434
+ i(s.filter((r, t) => t !== d));
435
+ }
436
+ return /* @__PURE__ */ o("div", { className: "card", children: [
437
+ /* @__PURE__ */ o("div", { className: "row", style: { justifyContent: "space-between", alignItems: "center" }, children: [
438
+ /* @__PURE__ */ e("h3", { children: f }),
439
+ /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: F, children: "+ Add input" })
440
+ ] }),
441
+ /* @__PURE__ */ e("p", { className: "muted small", children: u }),
442
+ s.length === 0 && /* @__PURE__ */ e("p", { className: "muted small", children: n ? "No inputs — payload is passed through." : "No inputs yet." }),
443
+ /* @__PURE__ */ e("ul", { className: "list", "data-testid": "input-list", children: s.map((d, r) => (
444
+ // biome-ignore lint/suspicious/noArrayIndexKey: rows are positional and reorderable
445
+ /* @__PURE__ */ o("li", { style: { alignItems: "center", gap: 8 }, children: [
446
+ /* @__PURE__ */ e(
447
+ "input",
448
+ {
449
+ type: "text",
450
+ value: d.key,
451
+ placeholder: "key",
452
+ "aria-label": "Input key",
453
+ onChange: (t) => S(r, { key: t.target.value })
454
+ }
455
+ ),
456
+ /* @__PURE__ */ e(
457
+ "input",
458
+ {
459
+ type: "text",
460
+ value: d.label,
461
+ placeholder: "Label",
462
+ "aria-label": "Input label",
463
+ onChange: (t) => S(r, { label: t.target.value })
464
+ }
465
+ ),
466
+ /* @__PURE__ */ e(
467
+ "select",
468
+ {
469
+ value: d.type,
470
+ "aria-label": "Input type",
471
+ onChange: (t) => S(r, { type: t.target.value }),
472
+ children: yn.map((t) => /* @__PURE__ */ e("option", { value: t, children: t }, t))
473
+ }
474
+ ),
475
+ /* @__PURE__ */ o("label", { className: "row", style: { gap: 4, alignItems: "center" }, children: [
476
+ /* @__PURE__ */ e(
477
+ "input",
478
+ {
479
+ type: "checkbox",
480
+ checked: d.required ?? !1,
481
+ onChange: (t) => S(r, { required: t.target.checked })
482
+ }
483
+ ),
484
+ /* @__PURE__ */ e("span", { className: "muted small", children: "required" })
485
+ ] }),
486
+ /* @__PURE__ */ e(
487
+ ye,
488
+ {
489
+ danger: !0,
490
+ icon: "close",
491
+ label: `Remove input ${d.key || r + 1}`,
492
+ onClick: () => g(r)
493
+ }
494
+ )
495
+ ] }, r)
496
+ )) }),
497
+ m && m.length > 0 && /* @__PURE__ */ o("p", { className: "muted small", "data-testid": "input-uncovered", children: [
498
+ "Missing required field",
499
+ m.length > 1 ? "s" : "",
500
+ " for the current target:",
501
+ " ",
502
+ m.join(", ")
503
+ ] })
504
+ ] });
505
+ }
506
+ const xn = ["action", "function", "workflow", "endpoint"], An = {
507
+ action: "Action (synchronous)",
508
+ function: "Function (synchronous)",
509
+ workflow: "Workflow (asynchronous)",
510
+ endpoint: "Endpoint (dispatches to another Endpoint)"
511
+ };
512
+ function Qe(a) {
513
+ var Q, _, V;
514
+ const { allowedKinds: s, value: i, onChange: f, onResolved: u, title: n, description: m, passthroughHint: F } = a, [S, g] = N(!1), d = i, r = d.kind, t = (l) => s.includes(l);
515
+ function y(l) {
516
+ f(l);
517
+ }
518
+ const c = d.kind === "action" ? d : void 0, C = (c == null ? void 0 : c.uses.app) ?? "", D = (c == null ? void 0 : c.uses.action) ?? "", E = vn(d), B = En(C), [M, L] = N(null);
519
+ ce(() => {
520
+ let l = !1;
521
+ return import("@w6w/ui/flow").then((w) => {
522
+ l || L({ isTriggerApp: w.isTriggerApp, asFieldDefs: w.asFieldDefs });
523
+ }), () => {
524
+ l = !0;
525
+ };
526
+ }, []);
527
+ const A = Cn(C, C !== ""), Y = Sn(C, C !== ""), P = O(
528
+ () => (A.data ?? []).find((l) => l.key === D),
529
+ [A.data, D]
530
+ ), G = ["function", "workflow"].filter(t), ae = `Choose ${n.charAt(0).toLowerCase()}${n.slice(1)}`, W = hn(t("function")), X = an(void 0, t("workflow")), k = mn(t("endpoint")), p = Ke(E, r === "function" && E !== ""), R = on(E, r === "workflow" && E !== ""), z = Te(E, r === "endpoint" && E !== ""), Z = O(() => {
531
+ var l, w, v;
532
+ return r === "action" ? me((P == null ? void 0 : P.params) ?? []) : r === "function" ? me(((l = p.data) == null ? void 0 : l.inputs) ?? []) : r === "workflow" ? M ? gn(
533
+ (w = R.data) == null ? void 0 : w.workflow,
534
+ M
535
+ ) : [] : r === "endpoint" ? me(((v = z.data) == null ? void 0 : v.endpoint.input) ?? []) : [];
536
+ }, [
537
+ r,
538
+ P,
539
+ p.data,
540
+ R.data,
541
+ z.data,
542
+ M
543
+ ]);
544
+ ce(() => {
545
+ u == null || u({ meta: { kind: r, ref: r === "action" ? C : E }, kind: r, fields: Z });
546
+ }, [r, C, E, Z, u]);
547
+ function x(l) {
548
+ if (l.uses.app === sn) {
549
+ const T = l.with ?? {}, h = T.targetKind === "workflow" ? "workflow" : "function", I = typeof T.targetId == "string" ? T.targetId : "";
550
+ if (!I) return;
551
+ y(
552
+ h === "workflow" ? { kind: "workflow", workflow: I } : { kind: "function", function: I }
553
+ ), g(!1);
554
+ return;
555
+ }
556
+ if (l.uses.app.startsWith("@w6w/")) return;
557
+ const w = d.kind === "action" ? d.with ?? {} : {}, v = l.with ?? {}, j = {};
558
+ for (const T of Object.keys(v))
559
+ j[T] = T in w ? w[T] : v[T];
560
+ y({ kind: "action", uses: l.uses, with: j }), g(!1);
561
+ }
562
+ function H(l, w) {
563
+ if (d.kind !== "action") return;
564
+ const v = { ...d.with ?? {} };
565
+ w === "" || w === void 0 ? delete v[l] : v[l] = w, y({ ...d, with: v });
566
+ }
567
+ function q(l) {
568
+ y(
569
+ l === "action" ? { kind: "action", uses: { app: "", action: "", connection: null } } : l === "function" ? { kind: "function", function: "" } : l === "workflow" ? { kind: "workflow", workflow: "" } : { kind: "endpoint", endpoint: "" }
570
+ );
571
+ }
572
+ function ee(l) {
573
+ y(
574
+ r === "function" ? { kind: "function", function: l } : r === "workflow" ? { kind: "workflow", workflow: l } : { kind: "endpoint", endpoint: l }
575
+ );
576
+ }
577
+ const ie = O(() => {
578
+ var l, w;
579
+ if (E) {
580
+ if (r === "function") {
581
+ const v = (l = W.data) == null ? void 0 : l.find((j) => j.id === E);
582
+ return v ? v.displayName || v.key : void 0;
583
+ }
584
+ if (r === "workflow") {
585
+ const v = (w = X.data) == null ? void 0 : w.find((j) => j.id === E);
586
+ return v ? v.displayName || v.name : void 0;
587
+ }
588
+ }
589
+ }, [r, E, W.data, X.data]), ne = O(() => {
590
+ const l = (P == null ? void 0 : P.params) ?? [], w = (c == null ? void 0 : c.with) ?? {};
591
+ return l.filter((v) => {
592
+ if (v.showIf) {
593
+ const { field: T, equals: h, in: I, notIn: U, truthy: re } = v.showIf, te = w[T];
594
+ if (h !== void 0 && te !== h || I !== void 0 && !I.includes(te) || U != null && U.includes(te) || re !== void 0 && !!te !== re) return !1;
595
+ }
596
+ const j = v.key in w && w[v.key] !== "" && w[v.key] !== void 0;
597
+ return v.required || j;
598
+ });
599
+ }, [P, c == null ? void 0 : c.with]);
600
+ return /* @__PURE__ */ o("div", { className: "card", children: [
601
+ /* @__PURE__ */ e("h3", { children: n }),
602
+ /* @__PURE__ */ e("p", { className: "muted small", children: m }),
603
+ s.length > 1 && /* @__PURE__ */ o("label", { className: "field", children: [
604
+ /* @__PURE__ */ e("span", { children: "Kind" }),
605
+ /* @__PURE__ */ e("select", { value: r, onChange: (l) => q(l.target.value), children: xn.filter(t).map((l) => /* @__PURE__ */ e("option", { value: l, children: An[l] }, l)) })
606
+ ] }),
607
+ r === "action" && /* @__PURE__ */ o(K, { children: [
608
+ C && D ? /* @__PURE__ */ o("div", { className: "row", style: { alignItems: "center", gap: 8 }, children: [
609
+ /* @__PURE__ */ e(
610
+ Ye,
611
+ {
612
+ src: B == null ? void 0 : B.iconSvg,
613
+ srcDark: B == null ? void 0 : B.iconSvgDark,
614
+ brandColor: B == null ? void 0 : B.brandColor,
615
+ name: C
616
+ }
617
+ ),
618
+ /* @__PURE__ */ o("span", { className: "list-main", children: [
619
+ /* @__PURE__ */ e("strong", { children: (P == null ? void 0 : P.title) ?? D }),
620
+ " ",
621
+ /* @__PURE__ */ e("code", { className: "muted", children: C }),
622
+ /* @__PURE__ */ e("span", { className: "muted small block", children: c != null && c.uses.connection ? `via ${((_ = (Q = Y.data) == null ? void 0 : Q.find((l) => l.id === c.uses.connection)) == null ? void 0 : _.displayName) ?? c.uses.connection}` : "no connection" })
623
+ ] }),
624
+ /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: () => g(!0), children: "Change" })
625
+ ] }) : /* @__PURE__ */ e("button", { type: "button", className: "btn", onClick: () => g(!0), children: "+ Choose an action" }),
626
+ D && /* @__PURE__ */ o("div", { style: { marginTop: 12 }, children: [
627
+ /* @__PURE__ */ e("h4", { children: "Input mapping" }),
628
+ /* @__PURE__ */ o("p", { className: "muted small", children: [
629
+ "Map each action param from the inputs above. Reference an input with",
630
+ " ",
631
+ /* @__PURE__ */ e("code", { children: "inputs.<key>" }),
632
+ "; anything else is a literal.",
633
+ F && " Leave every cell blank to pass the inbound payload through as the action's params."
634
+ ] }),
635
+ ne.length === 0 ? /* @__PURE__ */ e("p", { className: "muted small", children: "This action declares no params." }) : /* @__PURE__ */ e("ul", { className: "list", children: ne.map((l) => {
636
+ var w;
637
+ return /* @__PURE__ */ o("li", { style: { alignItems: "center", gap: 8 }, children: [
638
+ /* @__PURE__ */ o("span", { className: "list-main", children: [
639
+ /* @__PURE__ */ e("code", { children: l.key }),
640
+ l.required && /* @__PURE__ */ e("span", { className: "muted small", children: " · required" })
641
+ ] }),
642
+ /* @__PURE__ */ e("div", { style: { flex: 1 }, children: /* @__PURE__ */ e(
643
+ Ge,
644
+ {
645
+ value: (w = c == null ? void 0 : c.with) == null ? void 0 : w[l.key],
646
+ onChange: (v) => H(l.key, v),
647
+ placeholder: `inputs.${l.key}`,
648
+ "aria-label": `Mapping for ${l.key}`
649
+ }
650
+ ) })
651
+ ] }, l.key);
652
+ }) })
653
+ ] })
654
+ ] }),
655
+ (r === "function" || r === "workflow") && /* @__PURE__ */ e("div", { className: "row", style: { alignItems: "center", gap: 8 }, children: E ? /* @__PURE__ */ o(K, { children: [
656
+ /* @__PURE__ */ o("span", { className: "list-main", children: [
657
+ /* @__PURE__ */ e("strong", { children: ie ?? E }),
658
+ " ",
659
+ /* @__PURE__ */ e("code", { className: "muted", children: E }),
660
+ /* @__PURE__ */ e("span", { className: "muted small block", children: r === "function" ? "Function (synchronous)" : "Workflow (asynchronous)" })
661
+ ] }),
662
+ /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: () => g(!0), children: "Change" })
663
+ ] }) : /* @__PURE__ */ o("button", { type: "button", className: "btn", onClick: () => g(!0), children: [
664
+ "+ Choose a ",
665
+ r
666
+ ] }) }),
667
+ S && /* No provider here. The scope this modal needs is INHERITED from
668
+ the page (which contributes its `inputs`) over the app shell
669
+ (vars/secrets/documents) — the same scope the mapping rows below
670
+ see, which is the entire point: reaching the expression editor
671
+ through "Change" and reaching it through a row's `ƒx` toggle must
672
+ offer the identical rail. Wrapping only this modal is what made
673
+ them disagree.
674
+
675
+ ONE modal for the whole card, not one per arm: it now offers every
676
+ kind this card allows, so which arm is showing decides only which
677
+ tab it OPENS on, never whether it renders. */
678
+ /* @__PURE__ */ e(
679
+ Xe,
680
+ {
681
+ appsOnly: !0,
682
+ callables: G,
683
+ initialTab: r === "function" || r === "workflow" ? `${r}s` : "connected",
684
+ title: ae,
685
+ onClose: () => g(!1),
686
+ onAdd: x,
687
+ initialApp: c && C ? B : void 0,
688
+ initialAction: c ? D : void 0,
689
+ initialConnection: (c == null ? void 0 : c.uses.connection) ?? void 0,
690
+ initialWith: c == null ? void 0 : c.with
691
+ }
692
+ ),
693
+ r === "endpoint" && /* @__PURE__ */ o("label", { className: "field", children: [
694
+ /* @__PURE__ */ e("span", { children: "Endpoint" }),
695
+ /* @__PURE__ */ o("select", { value: E, onChange: (l) => ee(l.target.value), children: [
696
+ /* @__PURE__ */ e("option", { value: "", children: "— pick an endpoint —" }),
697
+ (V = k.data) == null ? void 0 : V.map((l) => /* @__PURE__ */ o("option", { value: l.id, children: [
698
+ l.displayName || l.key,
699
+ " (",
700
+ l.id,
701
+ ")"
702
+ ] }, l.id))
703
+ ] })
704
+ ] })
705
+ ] });
706
+ }
707
+ const jn = () => {
708
+ };
709
+ function oe(a) {
710
+ return a instanceof he || a instanceof Error ? a.message : String(a);
711
+ }
712
+ function dt(a) {
713
+ const { endpointId: s, onNavigate: i = jn, slots: f, tools: u } = a, n = ve(a.project), m = de(
714
+ (F) => i(F),
715
+ [i]
716
+ );
717
+ return /* @__PURE__ */ e(
718
+ "div",
719
+ {
720
+ className: "w6w-embed-root",
721
+ style: { display: "flex", width: "100%", height: "100%", minHeight: 0 },
722
+ children: /* @__PURE__ */ e(
723
+ Ce,
724
+ {
725
+ project: n,
726
+ onNavigate: m,
727
+ rail: a.rail,
728
+ tools: u,
729
+ storageKey: n === null ? null : `w6w.rail.embed.${n}`,
730
+ children: /* @__PURE__ */ e("div", { style: { flex: 1, minWidth: 0, overflow: "auto" }, children: /* @__PURE__ */ e(
731
+ Jn,
732
+ {
733
+ id: s,
734
+ onNavigate: i,
735
+ slots: f
736
+ },
737
+ s
738
+ ) })
739
+ }
740
+ )
741
+ }
742
+ );
743
+ }
744
+ function Jn(a) {
745
+ var ge;
746
+ const { id: s, onNavigate: i, slots: f } = a, u = Re("endpoint"), n = Te(s).data, [m, F] = N([]), S = le(m);
747
+ S.current = m;
748
+ const g = le(!1), d = le(!1), [r, t] = N("id"), [y, c] = N(null), [C, D] = N(!1), [E, B] = N(!1), [M, L] = N(!1), [A, Y] = N(""), [P, G] = N({ id: s, key: "" }), [ae, W] = N(null), X = de((b) => {
749
+ const $ = se(b), J = we({
750
+ target: $.target,
751
+ rows: $.input ?? [],
752
+ fields: S.current
753
+ });
754
+ return J.length > 0 ? `The target needs: ${J.join(", ")}` : null;
755
+ }, []), k = ln({ id: s, saveGuard: X }), p = O(
756
+ () => k.definition ? se(k.definition) : null,
757
+ [k.definition]
758
+ ), R = (p == null ? void 0 : p.input) ?? [], z = ((ge = p == null ? void 0 : p.exposure) == null ? void 0 : ge.security) ?? {
759
+ auth: "platform"
760
+ }, Z = Me(n == null ? void 0 : n.invokeUrls), x = Bn(n == null ? void 0 : n.invokeUrls, y);
761
+ De({
762
+ kind: "endpoint",
763
+ id: s,
764
+ label: (p == null ? void 0 : p.displayName) || void 0,
765
+ key: (p == null ? void 0 : p.key.trim()) || void 0,
766
+ invokeUrl: x ? x.url : n == null ? void 0 : n.invokeUrl,
767
+ invokeUrlByKey: x ? x.urlByKey : n == null ? void 0 : n.invokeUrlByKey,
768
+ urlForm: r,
769
+ inputs: m.map((b) => b.key),
770
+ policy: k.policy,
771
+ onPolicyChange: k.onPolicyChange
772
+ });
773
+ const { setDefinition: H } = k, q = de(
774
+ (b) => {
775
+ B(!1), H(($) => ({
776
+ ...se($),
777
+ ...b
778
+ }));
779
+ },
780
+ [H]
781
+ ), ee = (b) => {
782
+ B(!1), H(($) => {
783
+ var ke;
784
+ const J = se($), Ue = {
785
+ ...((ke = J.exposure) == null ? void 0 : ke.security) ?? { auth: "platform" },
786
+ ...b
787
+ };
788
+ return { ...J, exposure: { ...J.exposure, security: Ue } };
789
+ });
790
+ };
791
+ function ie(b) {
792
+ g.current = !0, q({ target: b });
793
+ }
794
+ ce(() => {
795
+ if (g.current) {
796
+ if (!je({ rows: R, touched: d.current })) {
797
+ g.current = !1;
798
+ return;
799
+ }
800
+ m.length !== 0 && (q({ input: Je(R, m) }), g.current = !1);
801
+ }
802
+ }, [m]);
803
+ const ne = O(
804
+ () => ({ inputs: R.map((b) => b.key).filter(Boolean) }),
805
+ [R]
806
+ ), Q = O(
807
+ () => Oe(R, m),
808
+ [R, m]
809
+ ), _ = O(
810
+ () => p ? we({
811
+ target: p.target,
812
+ rows: R,
813
+ fields: m
814
+ }) : [],
815
+ [p, R, m]
816
+ ), V = p && _.length > 0 ? /* @__PURE__ */ o("p", { className: "error small", "data-testid": "save-blocked", children: [
817
+ "Can’t save yet — the target needs",
818
+ " ",
819
+ p.target.kind === "action" ? "these required params mapped under Input mapping" : "these required keys declared under Input",
820
+ ": ",
821
+ /* @__PURE__ */ e("strong", { children: _.join(", ") })
822
+ ] }) : null, w = !!((p == null ? void 0 : p.key.trim()) ?? "") && _.length === 0 && k.canSave;
823
+ async function v() {
824
+ if (!p) return;
825
+ const b = await k.commit(be(p));
826
+ B(b.status === "saved");
827
+ }
828
+ function j() {
829
+ if (!p) return;
830
+ const b = be(p);
831
+ Y(JSON.stringify(b, null, 2)), G({ id: String(b.id), key: String(b.key) }), W(null), L(!0);
832
+ }
833
+ async function T() {
834
+ const b = ue(A, P), $ = b.parsed;
835
+ if (!$ || b.blockedReason) return;
836
+ const J = await k.commit($);
837
+ J.status === "saved" || J.status === "clean" ? (W(null), L(!1), B(J.status === "saved")) : J.status === "failed" ? W(oe(J.error)) : W(J.reason);
838
+ }
839
+ const h = k.loadError, I = h instanceof he && h.status === 404;
840
+ if (!p) {
841
+ if (h !== null && !I)
842
+ return /* @__PURE__ */ e("div", { className: "error", role: "alert", children: oe(h) });
843
+ if (!I) return /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" });
844
+ }
845
+ const U = p && (p.displayName || p.key) || u.editor.newTitle, re = k.error !== null && !k.stale ? oe(k.error) : null, te = k.stale || k.changedElsewhere ? /* @__PURE__ */ o("div", { className: "error", role: "alert", "data-testid": "endpoint-stale", children: [
846
+ k.stale ? oe(k.error) : "This endpoint was changed elsewhere. Reload to see the new version (your edits will be discarded).",
847
+ " ",
848
+ /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: () => void k.reload(), children: "Reload" })
849
+ ] }) : null;
850
+ return /* @__PURE__ */ e(Pe, { value: ne, children: /* @__PURE__ */ e(
851
+ We,
852
+ {
853
+ kind: "endpoint",
854
+ title: U,
855
+ incomplete: !1,
856
+ canSave: w,
857
+ isSaving: k.saving,
858
+ onSave: () => void v(),
859
+ error: I ? oe(h) : re,
860
+ notFound: I,
861
+ onNavigate: i,
862
+ slots: f,
863
+ headerActions: /* @__PURE__ */ o(K, { children: [
864
+ /* @__PURE__ */ e(Ee, { kind: "endpoint", id: s }),
865
+ /* @__PURE__ */ e(Ie, { onClick: j })
866
+ ] }),
867
+ banners: /* @__PURE__ */ o(K, { children: [
868
+ te,
869
+ V,
870
+ E && /* @__PURE__ */ e("span", { className: "ok", children: "Saved." })
871
+ ] }),
872
+ children: p && /* @__PURE__ */ o(K, { children: [
873
+ /* @__PURE__ */ o("div", { className: "card", children: [
874
+ /* @__PURE__ */ o("div", { className: "section-head", children: [
875
+ /* @__PURE__ */ e("h3", { children: "Identity" }),
876
+ /* @__PURE__ */ e(
877
+ ye,
878
+ {
879
+ icon: "edit-2",
880
+ label: "Edit name, key, and description",
881
+ onClick: () => D(!0)
882
+ }
883
+ )
884
+ ] }),
885
+ /* @__PURE__ */ o("div", { className: "field", children: [
886
+ /* @__PURE__ */ e("span", { className: "muted small", children: "Display name" }),
887
+ /* @__PURE__ */ e("span", { children: p.displayName || "—" })
888
+ ] }),
889
+ /* @__PURE__ */ o("div", { className: "field", children: [
890
+ /* @__PURE__ */ e("span", { className: "muted small", children: "Key" }),
891
+ /* @__PURE__ */ e("code", { className: "muted", children: p.key || "—" })
892
+ ] }),
893
+ /* @__PURE__ */ o("div", { className: "field", children: [
894
+ /* @__PURE__ */ e("span", { className: "muted small", children: "Description" }),
895
+ /* @__PURE__ */ e("span", { children: p.description || "—" })
896
+ ] })
897
+ ] }),
898
+ /* @__PURE__ */ e(
899
+ Rn,
900
+ {
901
+ entry: Dn(x, n == null ? void 0 : n.invokeUrl, n == null ? void 0 : n.invokeUrlByKey),
902
+ domainOptions: Z,
903
+ urlDomain: (x == null ? void 0 : x.domain) ?? null,
904
+ onUrlDomain: c,
905
+ urlForm: r,
906
+ onUrlForm: t
907
+ }
908
+ ),
909
+ /* @__PURE__ */ e(
910
+ qe,
911
+ {
912
+ title: "Input",
913
+ description: "The declared inbound contract. Reuses core Param fields. Leave empty to pass the raw request payload through to the target unchanged.",
914
+ emptyMeansPassthrough: !0,
915
+ rows: R,
916
+ onChange: (b) => {
917
+ d.current = !0, q({ input: b });
918
+ },
919
+ uncoveredKeys: Q
920
+ }
921
+ ),
922
+ /* @__PURE__ */ e(
923
+ Qe,
924
+ {
925
+ allowedKinds: ["action", "function", "workflow"],
926
+ title: "Target",
927
+ description: /* @__PURE__ */ o(K, { children: [
928
+ "The single thing this Endpoint dispatches to. An ",
929
+ /* @__PURE__ */ e("strong", { children: "Action" }),
930
+ " target runs one app action directly and a ",
931
+ /* @__PURE__ */ e("strong", { children: "Function" }),
932
+ " target resolves synchronously to a value; a ",
933
+ /* @__PURE__ */ e("strong", { children: "Workflow" }),
934
+ " target enqueues an asynchronous run. Switching the target here preserves the key and the input contract below, so callers never break."
935
+ ] }),
936
+ passthroughHint: !0,
937
+ value: p.target,
938
+ onChange: ie,
939
+ onResolved: (b) => F(b.fields)
940
+ }
941
+ ),
942
+ /* @__PURE__ */ e(Kn, { security: z, onPatch: ee }),
943
+ /* @__PURE__ */ e(Tn, { id: s, inputs: R }),
944
+ /* @__PURE__ */ o(
945
+ "div",
946
+ {
947
+ className: "row",
948
+ style: {
949
+ justifyContent: "flex-end",
950
+ alignItems: "center",
951
+ gap: "var(--w6w-sp-3)",
952
+ marginTop: "var(--w6w-sp-4)"
953
+ },
954
+ children: [
955
+ V,
956
+ E && /* @__PURE__ */ e("span", { className: "ok", children: "Saved." }),
957
+ /* @__PURE__ */ e(
958
+ "button",
959
+ {
960
+ type: "button",
961
+ className: "btn",
962
+ disabled: !w,
963
+ onClick: () => void v(),
964
+ children: k.saving ? "Saving…" : "Save"
965
+ }
966
+ )
967
+ ]
968
+ }
969
+ ),
970
+ C && /* @__PURE__ */ e(
971
+ cn,
972
+ {
973
+ initial: {
974
+ key: p.key,
975
+ displayName: p.displayName ?? "",
976
+ description: p.description ?? ""
977
+ },
978
+ onClose: () => D(!1),
979
+ onSaved: (b) => {
980
+ q({
981
+ displayName: b.displayName,
982
+ description: b.description
983
+ }), D(!1);
984
+ }
985
+ }
986
+ ),
987
+ /* @__PURE__ */ e(
988
+ Se,
989
+ {
990
+ open: M,
991
+ onClose: () => L(!1),
992
+ title: `JSON — ${U}`,
993
+ mode: "disconnected",
994
+ value: A,
995
+ onChange: Y,
996
+ guard: (b) => ue(b, P).blockedReason,
997
+ onSave: () => void T(),
998
+ saving: k.saving,
999
+ error: ae,
1000
+ editorLabel: "Endpoint definition JSON"
1001
+ }
1002
+ )
1003
+ ] })
1004
+ }
1005
+ ) });
1006
+ }
1007
+ const On = () => {
1008
+ }, fe = (a) => a instanceof Error ? a.message : String(a);
1009
+ function ut(a) {
1010
+ const { functionId: s, onNavigate: i = On, slots: f, tools: u } = a, n = ve(a.project);
1011
+ return /* @__PURE__ */ e(
1012
+ "div",
1013
+ {
1014
+ className: "w6w-embed-root",
1015
+ style: { display: "flex", width: "100%", height: "100%", minHeight: 0 },
1016
+ children: /* @__PURE__ */ e(
1017
+ Ce,
1018
+ {
1019
+ project: n,
1020
+ onNavigate: i,
1021
+ rail: a.rail,
1022
+ tools: u,
1023
+ storageKey: n === null ? null : `w6w.rail.embed.${n}`,
1024
+ children: /* @__PURE__ */ e(Ln, { functionId: s, onNavigate: i, slots: f })
1025
+ }
1026
+ )
1027
+ }
1028
+ );
1029
+ }
1030
+ function Ln(a) {
1031
+ const s = rn({ id: a.functionId });
1032
+ return /* @__PURE__ */ e(Mn, { ...a, draft: s }, a.functionId);
1033
+ }
1034
+ function Mn(a) {
1035
+ var T;
1036
+ const { functionId: s, draft: i, onNavigate: f, slots: u } = a, n = i.definition, m = (n == null ? void 0 : n.inputs) ?? [], S = ((T = Ke(s).data) == null ? void 0 : T.valid) === !0, g = i.loadError, d = g instanceof he && g.status === 404, [r, t] = N(!1), [y, c] = N(null), [C, D] = N(!1), [E, B] = N(!1), M = ((n == null ? void 0 : n.key) ?? "").trim() || In((n == null ? void 0 : n.displayName) ?? "");
1037
+ De({
1038
+ kind: "function",
1039
+ id: s,
1040
+ label: (n == null ? void 0 : n.displayName) || void 0,
1041
+ key: M || void 0,
1042
+ inputs: m.filter((h) => !!h.key).map((h) => ({ key: h.key, required: h.required === !0 })),
1043
+ policy: i.policy,
1044
+ onPolicyChange: i.onPolicyChange
1045
+ });
1046
+ const L = (h) => i.setDefinition((I) => ({ ...I, ...h })), [A, Y] = N([]), P = le(!1), G = le(!1);
1047
+ ce(() => {
1048
+ if (P.current) {
1049
+ if (!je({ rows: m, touched: G.current })) {
1050
+ P.current = !1;
1051
+ return;
1052
+ }
1053
+ A.length !== 0 && (L({ inputs: Je(m, A) }), P.current = !1);
1054
+ }
1055
+ }, [A]);
1056
+ const ae = O(
1057
+ () => Oe(m, A),
1058
+ [m, A]
1059
+ ), W = O(
1060
+ () => ({ inputs: m.map((h) => h.key).filter(Boolean) }),
1061
+ [m]
1062
+ );
1063
+ function X(h) {
1064
+ var U;
1065
+ P.current = !0;
1066
+ const I = bn(h);
1067
+ L({ impl: (U = n == null ? void 0 : n.impl) != null && U.outputMap ? { ...I, outputMap: n.impl.outputMap } : I });
1068
+ }
1069
+ const k = O(
1070
+ () => kn({ impl: n == null ? void 0 : n.impl, fields: A }),
1071
+ [n == null ? void 0 : n.impl, A]
1072
+ ), p = !!M && k.length === 0 && i.canSave;
1073
+ function R() {
1074
+ return {
1075
+ ...n,
1076
+ key: M,
1077
+ inputs: xe(m, { emptyMeansPassthrough: !1 })
1078
+ };
1079
+ }
1080
+ async function z() {
1081
+ c(null), D(!1);
1082
+ const h = await i.commit(R());
1083
+ h.status === "saved" || h.status === "clean" ? D(!0) : h.status === "blocked" && c(h.reason);
1084
+ }
1085
+ const [Z, x] = N(!1), [H, q] = N(""), [ee, ie] = N({ id: s, key: "" }), [ne, Q] = N(null);
1086
+ function _() {
1087
+ const h = R();
1088
+ q(JSON.stringify(h, null, 2)), ie({ id: String(h.id), key: String(h.key) }), Q(null), x(!0);
1089
+ }
1090
+ async function V() {
1091
+ const h = ue(H, ee);
1092
+ if (!h.parsed || h.blockedReason) return;
1093
+ D(!1);
1094
+ const I = await i.commit(h.parsed);
1095
+ I.status === "saved" || I.status === "clean" ? (Q(null), x(!1), D(!0)) : I.status === "blocked" ? Q(I.reason) : I.status === "failed" && Q(fe(I.error));
1096
+ }
1097
+ const l = de(async () => {
1098
+ B(!0);
1099
+ try {
1100
+ await i.reload(), c(null), D(!1);
1101
+ } finally {
1102
+ B(!1);
1103
+ }
1104
+ }, [i.reload]), w = i.stale ? null : i.error ?? g, v = y ?? (w === null ? null : fe(w)), j = (n == null ? void 0 : n.displayName) || (n == null ? void 0 : n.key) || "New function";
1105
+ return i.loading || n === null && g === null ? /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" }) : /* @__PURE__ */ e("div", { style: { flex: 1, minWidth: 0, overflow: "auto" }, children: /* @__PURE__ */ e(Pe, { value: W, children: /* @__PURE__ */ e(
1106
+ We,
1107
+ {
1108
+ kind: "function",
1109
+ title: j,
1110
+ incomplete: n !== null && !S,
1111
+ canSave: p,
1112
+ isSaving: i.saving,
1113
+ onSave: () => void z(),
1114
+ error: v,
1115
+ notFound: d,
1116
+ onNavigate: f,
1117
+ slots: u,
1118
+ headerActions: n && /* @__PURE__ */ o(K, { children: [
1119
+ /* @__PURE__ */ e(Ee, { kind: "function", id: s }),
1120
+ /* @__PURE__ */ e(Ie, { onClick: _ })
1121
+ ] }),
1122
+ banners: /* @__PURE__ */ o(K, { children: [
1123
+ i.stale && /* @__PURE__ */ o("div", { className: "error", role: "alert", "data-testid": "save-stale", children: [
1124
+ /* @__PURE__ */ e("p", { children: "This function changed on the server after you opened it. Your save was refused, so their work is intact." }),
1125
+ /* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: E, onClick: l, children: E ? "Reloading…" : "Reload from server" })
1126
+ ] }),
1127
+ i.changedElsewhere && !i.stale && /* @__PURE__ */ o("div", { className: "muted small", "data-testid": "changed-elsewhere", children: [
1128
+ /* @__PURE__ */ e("p", { children: "This function was changed elsewhere. Reloading replaces your unsaved edits with the saved copy." }),
1129
+ /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", disabled: E, onClick: l, children: E ? "Reloading…" : "Reload from server" })
1130
+ ] }),
1131
+ k.length > 0 && /* @__PURE__ */ o("p", { className: "error small", "data-testid": "save-blocked", children: [
1132
+ "Can’t save yet — map ",
1133
+ k.length > 1 ? "these" : "this",
1134
+ " required action",
1135
+ " ",
1136
+ k.length > 1 ? "params" : "param",
1137
+ " under Input mapping above:",
1138
+ " ",
1139
+ /* @__PURE__ */ e("strong", { children: k.join(", ") })
1140
+ ] }),
1141
+ C && /* @__PURE__ */ e("span", { className: "ok", children: "Saved." })
1142
+ ] }),
1143
+ children: n && /* @__PURE__ */ o(K, { children: [
1144
+ /* @__PURE__ */ o("div", { className: "card", children: [
1145
+ /* @__PURE__ */ o("div", { className: "section-head", children: [
1146
+ /* @__PURE__ */ e("h3", { children: "Interface" }),
1147
+ /* @__PURE__ */ e(
1148
+ ye,
1149
+ {
1150
+ icon: "edit-2",
1151
+ label: "Edit name, key, and description",
1152
+ onClick: () => t(!0)
1153
+ }
1154
+ )
1155
+ ] }),
1156
+ /* @__PURE__ */ o("div", { className: "field", children: [
1157
+ /* @__PURE__ */ e("span", { className: "muted small", children: "Display name" }),
1158
+ /* @__PURE__ */ e("span", { children: n.displayName || "—" })
1159
+ ] }),
1160
+ /* @__PURE__ */ o("div", { className: "field", children: [
1161
+ /* @__PURE__ */ e("span", { className: "muted small", children: "Key" }),
1162
+ /* @__PURE__ */ e("code", { className: "muted", children: n.key || "—" })
1163
+ ] }),
1164
+ /* @__PURE__ */ o("div", { className: "field", children: [
1165
+ /* @__PURE__ */ e("span", { className: "muted small", children: "Description" }),
1166
+ /* @__PURE__ */ e("span", { children: n.description || "—" })
1167
+ ] })
1168
+ ] }),
1169
+ /* @__PURE__ */ e(
1170
+ qe,
1171
+ {
1172
+ title: "Inputs",
1173
+ description: "The canonical, vendor-stable interface a caller binds to. Reuses core Param fields.",
1174
+ emptyMeansPassthrough: !1,
1175
+ rows: m,
1176
+ onChange: (h) => {
1177
+ G.current = !0, L({ inputs: h });
1178
+ },
1179
+ uncoveredKeys: ae
1180
+ }
1181
+ ),
1182
+ /* @__PURE__ */ e(
1183
+ Qe,
1184
+ {
1185
+ allowedKinds: ["action", "function", "workflow"],
1186
+ title: "Implementation",
1187
+ description: /* @__PURE__ */ o(K, { children: [
1188
+ 'Bind the interface to one concrete app action, another Function, or a Workflow. Switching the provider here (a "re-bind") rewrites only ',
1189
+ /* @__PURE__ */ e("code", { children: "impl" }),
1190
+ "'s target fields - the interface above, and every caller, is untouched."
1191
+ ] }),
1192
+ value: wn(n.impl),
1193
+ onChange: X,
1194
+ onResolved: (h) => Y(h.fields)
1195
+ }
1196
+ ),
1197
+ /* @__PURE__ */ e(Wn, { id: s, inputs: m, disabled: !S, invalid: !S }),
1198
+ r && /* @__PURE__ */ e(
1199
+ dn,
1200
+ {
1201
+ initial: {
1202
+ key: n.key,
1203
+ displayName: n.displayName ?? "",
1204
+ description: n.description ?? ""
1205
+ },
1206
+ onClose: () => t(!1),
1207
+ onSaved: (h) => {
1208
+ L({ displayName: h.displayName, description: h.description }), t(!1);
1209
+ }
1210
+ }
1211
+ ),
1212
+ /* @__PURE__ */ e(
1213
+ Se,
1214
+ {
1215
+ open: Z,
1216
+ onClose: () => x(!1),
1217
+ title: `JSON — ${j}`,
1218
+ mode: "disconnected",
1219
+ value: H,
1220
+ onChange: q,
1221
+ guard: (h) => ue(h, ee).blockedReason,
1222
+ onSave: () => void V(),
1223
+ saving: i.saving,
1224
+ error: ne,
1225
+ editorLabel: "Function definition JSON"
1226
+ }
1227
+ )
1228
+ ] })
1229
+ }
1230
+ ) }) });
1231
+ }
1232
+ function Wn(a) {
1233
+ const { id: s, inputs: i } = a, [f, u] = N({}), [n, m] = N(void 0), [F, S] = N(null), g = Le(), d = pn();
1234
+ async function r() {
1235
+ const t = {};
1236
+ for (const y of i) {
1237
+ const c = Ae(y.type, f[y.key] ?? "");
1238
+ c !== void 0 && (t[y.key] = c);
1239
+ }
1240
+ try {
1241
+ const y = await d.mutateAsync({ id: s, inputs: t });
1242
+ S(null), m(y);
1243
+ } catch (y) {
1244
+ m(void 0), S(fe(y));
1245
+ } finally {
1246
+ g.invalidateQueries({ queryKey: Be.root });
1247
+ }
1248
+ }
1249
+ return /* @__PURE__ */ o("div", { className: "card", children: [
1250
+ /* @__PURE__ */ e("h3", { children: "Test invoke" }),
1251
+ /* @__PURE__ */ e("p", { className: "muted small", children: "Runs the saved Function through its bound action. Save any edits first." }),
1252
+ a.invalid && /* @__PURE__ */ e("p", { className: "muted small", children: "Pick an app and action to test this function — it has no implementation bound yet." }),
1253
+ i.length === 0 && /* @__PURE__ */ e("p", { className: "muted small", children: "Add inputs above to supply test values." }),
1254
+ i.map((t) => {
1255
+ const y = `fn-invoke-${t.key || t.label}`;
1256
+ return /* @__PURE__ */ o("div", { className: "field", children: [
1257
+ /* @__PURE__ */ o("label", { htmlFor: y, children: [
1258
+ t.label || t.key,
1259
+ t.required && " *"
1260
+ ] }),
1261
+ t.type === "boolean" ? /* @__PURE__ */ o(
1262
+ "select",
1263
+ {
1264
+ id: y,
1265
+ value: f[t.key] ?? "",
1266
+ onChange: (c) => u((C) => ({ ...C, [t.key]: c.target.value })),
1267
+ children: [
1268
+ /* @__PURE__ */ e("option", { value: "", children: "—" }),
1269
+ /* @__PURE__ */ e("option", { value: "true", children: "true" }),
1270
+ /* @__PURE__ */ e("option", { value: "false", children: "false" })
1271
+ ]
1272
+ }
1273
+ ) : /* @__PURE__ */ e(
1274
+ "input",
1275
+ {
1276
+ id: y,
1277
+ type: t.type === "number" ? "number" : "text",
1278
+ value: f[t.key] ?? "",
1279
+ placeholder: t.type === "json" ? "{ }" : t.hint ?? "",
1280
+ onChange: (c) => u((C) => ({ ...C, [t.key]: c.target.value }))
1281
+ }
1282
+ )
1283
+ ] }, t.key || t.label);
1284
+ }),
1285
+ /* @__PURE__ */ e("div", { className: "row", children: /* @__PURE__ */ e(
1286
+ "button",
1287
+ {
1288
+ type: "button",
1289
+ className: "btn",
1290
+ disabled: a.disabled || d.isPending,
1291
+ onClick: () => void r(),
1292
+ children: d.isPending ? "Invoking…" : "Invoke"
1293
+ }
1294
+ ) }),
1295
+ F && /* @__PURE__ */ e("div", { className: "result error", children: F }),
1296
+ n !== void 0 && /* @__PURE__ */ o(K, { children: [
1297
+ n.invocationId && /* @__PURE__ */ o("p", { className: "muted small", children: [
1298
+ n.status ?? "done",
1299
+ n.durationMs !== void 0 ? ` · ${n.durationMs} ms` : "",
1300
+ " · ",
1301
+ /* @__PURE__ */ e("code", { children: n.invocationId })
1302
+ ] }),
1303
+ /* @__PURE__ */ e("pre", { className: "result", style: { overflow: "auto" }, children: JSON.stringify(n.output, null, 2) })
1304
+ ] })
1305
+ ] });
1306
+ }
1307
+ export {
1308
+ ct as DocumentEditor,
1309
+ dt as EndpointEditor,
1310
+ ut as FunctionEditor,
1311
+ pt as WorkflowEditor
1312
+ };
1313
+ //# sourceMappingURL=editors.mjs.map