@w6w/embed 0.2.0 → 0.2.11

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