@w6w/embed 0.2.11 → 0.2.19

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 (132) hide show
  1. package/README.md +22 -5
  2. package/dist/ConfirmModal-Pv2-A_3U.js +186 -0
  3. package/dist/ConfirmModal-Pv2-A_3U.js.map +1 -0
  4. package/dist/{CreateFunctionModal-D6CQLpa_.js → CreateFunctionModal-DScxp_LN.js} +2 -2
  5. package/dist/{CreateFunctionModal-D6CQLpa_.js.map → CreateFunctionModal-DScxp_LN.js.map} +1 -1
  6. package/dist/{DocumentFormModal-YauVdolr.js → DocumentFormModal-Br4s8wmi.js} +3 -3
  7. package/dist/{DocumentFormModal-YauVdolr.js.map → DocumentFormModal-Br4s8wmi.js.map} +1 -1
  8. package/dist/ImportSpecModal-Cpzp8ndt.js +251 -0
  9. package/dist/ImportSpecModal-Cpzp8ndt.js.map +1 -0
  10. package/dist/{ModelRoutesManager-BGESQahw.js → ModelRoutesManager-1Ac5wcas.js} +3 -3
  11. package/dist/{ModelRoutesManager-BGESQahw.js.map → ModelRoutesManager-1Ac5wcas.js.map} +1 -1
  12. package/dist/WorkflowEditor-CmhXHRxi.js +1109 -0
  13. package/dist/WorkflowEditor-CmhXHRxi.js.map +1 -0
  14. package/dist/apps-ItBvnWX3.js +92 -0
  15. package/dist/apps-ItBvnWX3.js.map +1 -0
  16. package/dist/chrome/DangerZone.d.ts +4 -3
  17. package/dist/chrome/ExecutionProfileHeader.d.ts +3 -3
  18. package/dist/chrome/JsonToggle.d.ts +29 -20
  19. package/dist/chrome/Modal.d.ts +3 -1
  20. package/dist/chrome/RightRail.d.ts +6 -1
  21. package/dist/chrome/VersionHistoryModal.d.ts +2 -0
  22. package/dist/chrome/index.d.ts +1 -0
  23. package/dist/chrome/workspace.d.ts +32 -1
  24. package/dist/{coerce-input-DttlcSdO.js → coerce-input-DFJ4n_wc.js} +68 -69
  25. package/dist/coerce-input-DFJ4n_wc.js.map +1 -0
  26. package/dist/{connections-D7cgXhDS.js → connections-CzsCyIxY.js} +10 -10
  27. package/dist/{connections-D7cgXhDS.js.map → connections-CzsCyIxY.js.map} +1 -1
  28. package/dist/{credentials-DaQU3Ca_.js → credentials-Cn92LGhJ.js} +4 -4
  29. package/dist/{credentials-DaQU3Ca_.js.map → credentials-Cn92LGhJ.js.map} +1 -1
  30. package/dist/data-stores-UeQvwVCa.js +170 -0
  31. package/dist/data-stores-UeQvwVCa.js.map +1 -0
  32. package/dist/document-sources-DNmBojx6.js +169 -0
  33. package/dist/document-sources-DNmBojx6.js.map +1 -0
  34. package/dist/draft/use-workflow-draft.d.ts +2 -0
  35. package/dist/draft.mjs +2 -2
  36. package/dist/editor/PublishTooltip.d.ts +7 -0
  37. package/dist/editor/SetupIncompleteBanner.d.ts +12 -0
  38. package/dist/editor/StartingStateModal.d.ts +14 -0
  39. package/dist/editor/WorkflowSettingsModal.d.ts +6 -1
  40. package/dist/editor/WorkflowVariablesEditor.d.ts +6 -0
  41. package/dist/editor/definition.d.ts +4 -0
  42. package/dist/editor/json-apply.d.ts +29 -0
  43. package/dist/editor/step-problems-feed.d.ts +5 -0
  44. package/dist/editor/types.d.ts +2 -2
  45. package/dist/editor-apps-DkkC7wOQ.js +152 -0
  46. package/dist/editor-apps-DkkC7wOQ.js.map +1 -0
  47. package/dist/editor-tools-BR27RGto.js +1683 -0
  48. package/dist/editor-tools-BR27RGto.js.map +1 -0
  49. package/dist/editor.mjs +1 -1
  50. package/dist/editors.mjs +536 -478
  51. package/dist/editors.mjs.map +1 -1
  52. package/dist/forms.mjs +3 -3
  53. package/dist/{rail-settings-XYGToh00.js → import-bindings-EUtxZ9Ti.js} +90 -24
  54. package/dist/import-bindings-EUtxZ9Ti.js.map +1 -0
  55. package/dist/index.mjs +138 -108
  56. package/dist/index.mjs.map +1 -1
  57. package/dist/lib/binding-problems.d.ts +5 -1
  58. package/dist/lib/history-query.d.ts +45 -0
  59. package/dist/lib/import-bindings.d.ts +89 -0
  60. package/dist/lib/index.d.ts +3 -0
  61. package/dist/lib/rail-settings.d.ts +1 -1
  62. package/dist/lib/setup-incomplete.d.ts +22 -0
  63. package/dist/lib/starting-data.d.ts +31 -0
  64. package/dist/lib/state-panel.d.ts +29 -0
  65. package/dist/lib/target-fields.d.ts +3 -15
  66. package/dist/lib/workflow-live-run.d.ts +84 -6
  67. package/dist/lib/workflow-validity.d.ts +64 -16
  68. package/dist/lib/workflow-variables.d.ts +1 -1
  69. package/dist/lib/workflow-version.d.ts +2 -0
  70. package/dist/lib.mjs +87 -72
  71. package/dist/lists/DataStoreList.d.ts +17 -0
  72. package/dist/lists/DataStoreView.d.ts +19 -0
  73. package/dist/lists/Logs.d.ts +19 -0
  74. package/dist/lists.d.ts +6 -0
  75. package/dist/lists.mjs +1255 -816
  76. package/dist/lists.mjs.map +1 -1
  77. package/dist/rail/ConnectionsTool.d.ts +2 -0
  78. package/dist/rail/HistoryTool.d.ts +2 -0
  79. package/dist/rail/StartingStateTool.d.ts +2 -0
  80. package/dist/rail/settings-sections.d.ts +4 -1
  81. package/dist/rail.mjs +1 -1
  82. package/dist/repos/constants.d.ts +12 -0
  83. package/dist/repos/data-stores.d.ts +84 -0
  84. package/dist/repos/history.d.ts +9 -0
  85. package/dist/repos/index.d.ts +2 -0
  86. package/dist/repos/spec-export.d.ts +3 -3
  87. package/dist/repos/spec-import.d.ts +30 -1
  88. package/dist/repos/step-tests.d.ts +2 -0
  89. package/dist/repos/webhook-listen.d.ts +35 -0
  90. package/dist/repos/workflows.d.ts +105 -2
  91. package/dist/repos.mjs +370 -328
  92. package/dist/repos.mjs.map +1 -1
  93. package/dist/setup-incomplete-BHs3Lpfy.js +199 -0
  94. package/dist/setup-incomplete-BHs3Lpfy.js.map +1 -0
  95. package/dist/{spec-export-CBbloO_n.js → spec-export-DGy5ijps.js} +72 -59
  96. package/dist/spec-export-DGy5ijps.js.map +1 -0
  97. package/dist/spec-import-SWOonsNr.js +116 -0
  98. package/dist/spec-import-SWOonsNr.js.map +1 -0
  99. package/dist/{step-tests-CivICmTq.js → step-tests-B4E4W3ly.js} +8 -7
  100. package/dist/step-tests-B4E4W3ly.js.map +1 -0
  101. package/dist/{use-callable-draft-DsALnSfF.js → use-callable-draft-DCauHt5o.js} +2 -2
  102. package/dist/{use-callable-draft-DsALnSfF.js.map → use-callable-draft-DCauHt5o.js.map} +1 -1
  103. package/dist/use-workflow-draft-l3P5KZzw.js +338 -0
  104. package/dist/use-workflow-draft-l3P5KZzw.js.map +1 -0
  105. package/dist/workflows-BZN4Hyz1.js +623 -0
  106. package/dist/workflows-BZN4Hyz1.js.map +1 -0
  107. package/package.json +3 -2
  108. package/src/styles.css +153 -1
  109. package/dist/ConfirmModal-BE-SdX-O.js +0 -185
  110. package/dist/ConfirmModal-BE-SdX-O.js.map +0 -1
  111. package/dist/ImportSpecModal-B7qd1Km2.js +0 -136
  112. package/dist/ImportSpecModal-B7qd1Km2.js.map +0 -1
  113. package/dist/WorkflowEditor-CwvmAGp2.js +0 -925
  114. package/dist/WorkflowEditor-CwvmAGp2.js.map +0 -1
  115. package/dist/apps-CboASBKr.js +0 -77
  116. package/dist/apps-CboASBKr.js.map +0 -1
  117. package/dist/coerce-input-DttlcSdO.js.map +0 -1
  118. package/dist/document-sources-UCwe8x77.js +0 -91
  119. package/dist/document-sources-UCwe8x77.js.map +0 -1
  120. package/dist/editor-apps-BUZWld-m.js +0 -95
  121. package/dist/editor-apps-BUZWld-m.js.map +0 -1
  122. package/dist/editor-tools-B_Lfx3kw.js +0 -1279
  123. package/dist/editor-tools-B_Lfx3kw.js.map +0 -1
  124. package/dist/rail-settings-XYGToh00.js.map +0 -1
  125. package/dist/spec-export-CBbloO_n.js.map +0 -1
  126. package/dist/spec-import-CW6R_Wk1.js +0 -469
  127. package/dist/spec-import-CW6R_Wk1.js.map +0 -1
  128. package/dist/step-tests-CivICmTq.js.map +0 -1
  129. package/dist/trigger-preview-DKxfjzUY.js +0 -145
  130. package/dist/trigger-preview-DKxfjzUY.js.map +0 -1
  131. package/dist/use-workflow-draft-DzAyUeA6.js +0 -316
  132. package/dist/use-workflow-draft-DzAyUeA6.js.map +0 -1
@@ -1,1279 +0,0 @@
1
- import { jsx as n, jsxs as a, Fragment as B } from "react/jsx-runtime";
2
- import { r as yn, m as Oe, s as kn, b as Ae, e as wn, h as Pe, a as Nn } from "./rail-settings-XYGToh00.js";
3
- import { useContext as de, useState as d, useMemo as Re, useEffect as ge, createContext as Le } from "react";
4
- import { ExpressionOptionsProvider as Cn, Icon as x, RetryPolicyFields as En, StepBuilderModal as Sn, IconButton as Qe, useEnterSubmit as Tn, CodeBlock as ve, DeleteButton as An, EditButton as Pn, ConfirmModal as Me, JsonEditor as Mn } from "@w6w/ui";
5
- import { d as Dn, p as In, i as On, t as Rn, e as De } from "./document-sources-UCwe8x77.js";
6
- import { i as Ln, f as Qn, e as jn, b as Vn, u as Wn } from "./vault-BSEWhMYC.js";
7
- import { P as Fn, Z as je, Y as Hn, V as Bn, J as Jn, N as $n, $ as Kn } from "./spec-import-CW6R_Wk1.js";
8
- import { s as qn, M as K, b as Un, C as zn } from "./ConfirmModal-BE-SdX-O.js";
9
- import { u as _n, i as Gn, f as Yn } from "./slug-BVdgiP_L.js";
10
- import { ApiError as A } from "@w6w/sdk";
11
- import { i as Zn, p as Ve, c as We, d as Xn } from "./settings-rail--GdRMusb.js";
12
- import { w as Fe, v as He, y as Be, x as Je, b as $e, d as xn, f as et, h as nt, u as tt, t as it, s as ot, r as st, q as rt } from "./endpoints-DSRo1Lc5.js";
13
- import { I as Ke } from "./ImportSpecModal-B7qd1Km2.js";
14
- import { e as at, b as lt, u as dt, f as qe, a as Ue, c as ze, d as ct } from "./spec-export-CBbloO_n.js";
15
- const ce = Le(null);
16
- function Zt({
17
- children: e,
18
- base: i = null
19
- }) {
20
- const [t, r] = d(null), o = t ?? i, s = Re(() => ({ resource: o, setCallable: r }), [o]);
21
- return /* @__PURE__ */ n(ce.Provider, { value: s, children: e });
22
- }
23
- function Xt() {
24
- return de(ce) !== null;
25
- }
26
- function xt(e) {
27
- const i = de(ce);
28
- if (!i) throw new Error("useWorkspace must be used within <WorkspaceProvider>");
29
- const { setCallable: t } = i, r = e ? JSON.stringify(e) : "";
30
- ge(() => (t(e), () => t(null)), [r, t]);
31
- }
32
- function ut() {
33
- const e = de(ce);
34
- if (!e) throw new Error("useWorkspaceCallable must be used within <WorkspaceProvider>");
35
- return e.resource;
36
- }
37
- const _e = { open: !1, activeTool: null };
38
- function ht(e) {
39
- if (typeof localStorage > "u") return _e;
40
- const i = localStorage.getItem(e), { activeTool: t } = yn(i);
41
- return { open: !1, activeTool: t };
42
- }
43
- function Ge({
44
- tools: e,
45
- ctx: i,
46
- state: t,
47
- onToggle: r
48
- }) {
49
- const o = t.open ? e.find((s) => s.id === t.activeTool) ?? null : null;
50
- return /* @__PURE__ */ a("aside", { className: "right-rail", children: [
51
- /* @__PURE__ */ n("div", { className: "right-rail-strip", children: e.map((s) => /* @__PURE__ */ n(
52
- "button",
53
- {
54
- type: "button",
55
- "data-testid": `rail-tool-${s.id}`,
56
- className: `right-rail-tool-btn${(o == null ? void 0 : o.id) === s.id ? " active" : ""}`,
57
- title: s.title,
58
- "aria-label": s.title,
59
- "aria-pressed": (o == null ? void 0 : o.id) === s.id,
60
- onClick: () => r(s.id),
61
- children: /* @__PURE__ */ n(s.Icon, {})
62
- },
63
- s.id
64
- )) }),
65
- o && /* @__PURE__ */ a("div", { className: "right-rail-panel", "data-testid": `rail-panel-${o.id}`, children: [
66
- !o.rendersHeading && /* @__PURE__ */ n("div", { className: "right-rail-panel-head", children: /* @__PURE__ */ n("h3", { children: o.title }) }),
67
- /* @__PURE__ */ n(o.Panel, { ctx: i })
68
- ] })
69
- ] });
70
- }
71
- function ft({
72
- storageKey: e,
73
- tools: i,
74
- ctx: t
75
- }) {
76
- const [r, o] = d(() => ht(e));
77
- ge(() => {
78
- typeof localStorage > "u" || localStorage.setItem(e, JSON.stringify({ activeTool: r.activeTool }));
79
- }, [e, r.activeTool]);
80
- function s(l) {
81
- o(
82
- (c) => c.open && c.activeTool === l ? { open: !1, activeTool: l } : { open: !0, activeTool: l }
83
- );
84
- }
85
- return /* @__PURE__ */ n(Ge, { tools: i, ctx: t, state: r, onToggle: s });
86
- }
87
- function ei({
88
- tools: e,
89
- storageKey: i
90
- }) {
91
- const t = ut(), r = e.filter((o) => o.isAvailable(t));
92
- return r.length === 0 ? null : i === null ? /* @__PURE__ */ n(Ge, { tools: r, ctx: t, state: _e, onToggle: () => {
93
- } }) : /* @__PURE__ */ n(ft, { storageKey: i, tools: r, ctx: t }, i);
94
- }
95
- function mt(e) {
96
- const i = e, t = Ln(i ?? void 0, i != null), r = Qn(), o = Fn(i ?? void 0, i != null), s = jn(), l = Vn(), c = Wn();
97
- return Re(
98
- () => ({
99
- vars: (t.data ?? []).map((u) => u.name),
100
- secrets: (r.data ?? []).map((u) => u.name),
101
- // `document-sources.ts` owns the `format === "json"` gate and the raw
102
- // field enumeration — no parsing, no gate logic, and no filtering here
103
- // (A5c); `isRefSafeKey` filtering happens once, downstream, at the
104
- // modal's render site.
105
- documents: In(o.data ?? []),
106
- // Real project values so the ƒx Result preview substitutes them for
107
- // `vars.<name>` / `documents.<key>` / `documents.<key>.<field>` refs
108
- // instead of the raw template.
109
- sampleValues: {
110
- ...Object.fromEntries((t.data ?? []).map((u) => [`vars.${u.name}`, u.value])),
111
- ...Dn(o.data ?? [])
112
- },
113
- sealSecret: s,
114
- // A created var carries the SAME project the read above carried (B3) —
115
- // it must land in the project whose rail asked for it. `type: "string"`
116
- // is pinned (a string type's `raw` passes through untouched) — the modal
117
- // has no type field.
118
- createVar: (u) => l.mutateAsync({
119
- input: {
120
- name: u.name,
121
- type: "string",
122
- value: u.value,
123
- description: u.description
124
- },
125
- project: i ?? void 0
126
- }).then(() => {
127
- }),
128
- // Secrets carry NO project (B4) — `vault_secrets` has no `project`
129
- // column and the routes read no `?project=`. Plaintext in, the server
130
- // encrypts; the resolved value is referenced nowhere (B5).
131
- createSecret: (u) => c.mutateAsync({ name: u.name, value: u.value, description: u.description }).then(() => {
132
- })
133
- }),
134
- [
135
- t.data,
136
- r.data,
137
- o.data,
138
- s,
139
- l.mutateAsync,
140
- c.mutateAsync,
141
- i
142
- ]
143
- );
144
- }
145
- function ni({
146
- project: e,
147
- children: i
148
- }) {
149
- const t = mt(e);
150
- return /* @__PURE__ */ n(Cn, { value: t, children: i });
151
- }
152
- function pt({ ctx: e }) {
153
- const [i, t] = d(null), r = Rn(e);
154
- if (!r) return null;
155
- const o = (e == null ? void 0 : e.kind) === "workflow" ? e.triggers : void 0, s = qn(r);
156
- return s.length === 0 ? /* @__PURE__ */ n("p", { className: "muted", children: _n(r) }) : /* @__PURE__ */ a("div", { children: [
157
- /* @__PURE__ */ n("p", { className: "muted small", style: { marginTop: 0 }, children: "Call this from:" }),
158
- /* @__PURE__ */ n("div", { className: "rail-code-langs", children: s.map(({ id: l, label: c, icon: u }) => /* @__PURE__ */ a(
159
- "button",
160
- {
161
- type: "button",
162
- className: "rail-code-lang",
163
- "data-testid": `rail-code-lang-${l}`,
164
- title: `Show the ${c} snippet`,
165
- "aria-label": `Show the ${c} snippet`,
166
- onClick: () => t(l),
167
- children: [
168
- /* @__PURE__ */ n(x, { name: u, size: 20 }),
169
- /* @__PURE__ */ n("span", { children: c })
170
- ]
171
- },
172
- l
173
- )) }),
174
- i !== null && /* @__PURE__ */ n(K, { title: "Call from code", wide: !0, onClose: () => t(null), children: /* @__PURE__ */ n("div", { style: { height: 450 }, children: /* @__PURE__ */ n(Un, { resource: r, triggers: o, initialTab: i }) }) })
175
- ] });
176
- }
177
- function vt() {
178
- return /* @__PURE__ */ n(x, { name: "code" });
179
- }
180
- const gt = {
181
- id: "code",
182
- title: "Code",
183
- Icon: vt,
184
- isAvailable: (e) => On(e),
185
- Panel: pt
186
- }, bt = { project: null, onNavigate: () => {
187
- } }, Ye = Le(bt);
188
- function ti({
189
- project: e,
190
- onNavigate: i,
191
- children: t
192
- }) {
193
- return /* @__PURE__ */ n(Ye.Provider, { value: { project: e, onNavigate: i }, children: t });
194
- }
195
- function Ze() {
196
- return de(Ye);
197
- }
198
- const yt = "@w6w/call";
199
- function Ie(e) {
200
- return e ? e.kind === "workflow" ? e.workflow : e.kind === "function" ? e.function : `${e.uses.app}/${e.uses.action}` : "";
201
- }
202
- function kt(e) {
203
- return (e == null ? void 0 : e.kind) === "workflow" ? "Workflow (asynchronous)" : (e == null ? void 0 : e.kind) === "function" ? "Function (synchronous)" : "App action (synchronous)";
204
- }
205
- function Xe({
206
- kind: e,
207
- id: i,
208
- policy: t,
209
- ready: r,
210
- saving: o,
211
- onPersist: s
212
- }) {
213
- var O, R, Q, v;
214
- const l = $e(!0), { project: c } = Ze(), u = je(c ?? void 0, !0), [b, N] = d(!1), [T, m] = d(null), E = (O = t.reroute) == null ? void 0 : O.target, k = Ie(E), W = E ? De({
215
- resource: { kind: e, id: i },
216
- target: { kind: E.kind, id: k },
217
- hasAdapter: ((R = t.reroute) == null ? void 0 : R.with) !== void 0
218
- }) : "allow", F = (E == null ? void 0 : E.kind) === "workflow" ? ((v = (Q = u.data) == null ? void 0 : Q.find((p) => p.id === k)) == null ? void 0 : v.displayName) ?? void 0 : (() => {
219
- var w;
220
- const p = (w = l.data) == null ? void 0 : w.find((q) => q.id === k);
221
- return p ? p.displayName || p.key : void 0;
222
- })();
223
- ge(() => {
224
- i && e && m(null);
225
- }, [i, e]);
226
- function P(p) {
227
- m(null), s(p, m);
228
- }
229
- function M(p) {
230
- var H;
231
- let w;
232
- if (p.uses.app === yt) {
233
- const J = p.with ?? {}, D = typeof J.targetId == "string" ? J.targetId : "";
234
- if (!D) return;
235
- w = J.targetKind === "workflow" ? { kind: "workflow", workflow: D } : { kind: "function", function: D };
236
- } else if (!p.uses.app.startsWith("@w6w/"))
237
- w = {
238
- kind: "action",
239
- uses: {
240
- app: p.uses.app,
241
- action: p.uses.action,
242
- connection: p.uses.connection ?? void 0
243
- },
244
- ...p.with ? { with: p.with } : {}
245
- };
246
- else
247
- return;
248
- if (De({
249
- resource: { kind: e, id: i },
250
- target: { kind: w.kind, id: Ie(w) },
251
- hasAdapter: ((H = t.reroute) == null ? void 0 : H.with) !== void 0
252
- }) === "block") {
253
- m(
254
- "This handler would call itself with the same inputs and can loop forever. Choose another handler or keep a differing imported adapter."
255
- ), N(!1);
256
- return;
257
- }
258
- P({ ...t, reroute: { ...t.reroute, target: w } }), N(!1);
259
- }
260
- return !r && !o ? /* @__PURE__ */ n("p", { className: "muted small", children: "Loading…" }) : /* @__PURE__ */ a("div", { className: "w6w-stack", "data-testid": "rail-errorhandling-body", children: [
261
- /* @__PURE__ */ a("section", { "data-testid": "rail-retry-section", children: [
262
- /* @__PURE__ */ n(
263
- En,
264
- {
265
- value: t.retry,
266
- onChange: (p) => P({ ...t, retry: p }),
267
- readOnly: o,
268
- target: e
269
- }
270
- ),
271
- e === "workflow" && /* @__PURE__ */ n("p", { className: "muted small", "data-testid": "rail-retry-run-warning", children: "Retrying re-runs the whole workflow from its first step, so steps that already succeeded run again. For a step that must not repeat (a send or a charge), set retry on that step instead." })
272
- ] }),
273
- /* @__PURE__ */ n("p", { className: "muted small", children: e === "workflow" ? "What runs when this workflow's run fails, after every node's own retry is spent." : "What runs when this call fails, after retry (if any) is exhausted." }),
274
- k ? /* @__PURE__ */ a("div", { className: "row", style: { alignItems: "center", gap: 8 }, children: [
275
- /* @__PURE__ */ a("span", { className: "list-main", children: [
276
- /* @__PURE__ */ n("strong", { children: F ?? k }),
277
- " ",
278
- /* @__PURE__ */ n("code", { className: "muted", children: k }),
279
- /* @__PURE__ */ n("span", { className: "muted small block", children: kt(E) })
280
- ] }),
281
- /* @__PURE__ */ n(
282
- "button",
283
- {
284
- type: "button",
285
- className: "btn ghost",
286
- "data-testid": "rail-errorhandling-change",
287
- disabled: o,
288
- onClick: () => N(!0),
289
- children: "Change"
290
- }
291
- )
292
- ] }) : /* @__PURE__ */ n(
293
- "button",
294
- {
295
- type: "button",
296
- className: "btn",
297
- "data-testid": "rail-errorhandling-choose",
298
- disabled: o,
299
- onClick: () => N(!0),
300
- children: "+ Choose what runs on failure"
301
- }
302
- ),
303
- k && /* @__PURE__ */ n(
304
- "button",
305
- {
306
- type: "button",
307
- className: "btn ghost",
308
- "data-testid": "rail-errorhandling-clear",
309
- disabled: o,
310
- onClick: () => P({ ...t, reroute: void 0 }),
311
- children: "Remove handler"
312
- }
313
- ),
314
- W === "warn" && /* @__PURE__ */ n("div", { className: "result error", "data-testid": "rail-errorhandling-self-caution", children: "This handler targets itself. Its imported input adapter is preserved; the server will refuse it if it resolves to the failed call's same inputs." }),
315
- T && /* @__PURE__ */ n("div", { className: "error", "data-testid": "rail-errorhandling-error", children: T }),
316
- b && /* @__PURE__ */ n(
317
- Sn,
318
- {
319
- appsOnly: !0,
320
- callables: ["function", "workflow"],
321
- title: "Choose what runs on failure",
322
- onClose: () => N(!1),
323
- onAdd: M
324
- }
325
- )
326
- ] });
327
- }
328
- function wt({ ctx: e }) {
329
- const i = "policy" in e ? e.policy : void 0, t = "onPolicyChange" in e ? e.onPolicyChange : void 0;
330
- return /* @__PURE__ */ n(
331
- Xe,
332
- {
333
- kind: e.kind,
334
- id: e.id,
335
- policy: i ? Ve(i) : {},
336
- ready: !!t,
337
- saving: !1,
338
- onPersist: (r) => t == null ? void 0 : t(r)
339
- }
340
- );
341
- }
342
- function Nt({ id: e, kind: i }) {
343
- const t = Fe(e, i === "function"), r = He(e, i === "endpoint"), o = Be(), s = Je(), l = We(i, i === "function" ? t.data : r.data), c = i === "function" ? o.isPending : s.isPending;
344
- return /* @__PURE__ */ n(
345
- Xe,
346
- {
347
- kind: i,
348
- id: e,
349
- policy: l ? Ve(l.definition) : {},
350
- ready: !!l,
351
- saving: c,
352
- onPersist: (u, b) => {
353
- if (!l) return;
354
- const N = {
355
- definition: Xn(l.definition, u),
356
- ifUnmodifiedSince: l.updatedAt
357
- }, T = {
358
- onError: (m) => b(m instanceof A ? m.message : String(m))
359
- };
360
- i === "function" ? o.mutate(N, T) : s.mutate(N, T);
361
- }
362
- }
363
- );
364
- }
365
- function Ct({ ctx: e }) {
366
- return (e == null ? void 0 : e.kind) !== "workflow" && (e == null ? void 0 : e.kind) !== "function" && (e == null ? void 0 : e.kind) !== "endpoint" ? null : e.kind === "workflow" || typeof e.onPolicyChange == "function" ? /* @__PURE__ */ n(wt, { ctx: e }) : /* @__PURE__ */ n(Nt, { id: e.id, kind: e.kind });
367
- }
368
- function Et() {
369
- return /* @__PURE__ */ n(x, { name: "warning" });
370
- }
371
- const St = {
372
- id: "error-handling",
373
- title: "Error handling",
374
- Icon: Et,
375
- isAvailable: (e) => Zn(e),
376
- Panel: Ct
377
- };
378
- function Tt(e, i) {
379
- if (!i.includes(",")) return { tags: e, typed: i };
380
- let t = e;
381
- for (const r of i.split(",")) {
382
- const o = r.trim();
383
- o && !t.includes(o) && (t = [...t, o]);
384
- }
385
- return { tags: t, typed: "" };
386
- }
387
- function At(e, i) {
388
- return e.filter((t) => t !== i);
389
- }
390
- function Pt({ tags: e, onChange: i }) {
391
- const [t, r] = d("");
392
- function o(s) {
393
- const l = Tt(e, s);
394
- r(l.typed), l.tags !== e && i(l.tags);
395
- }
396
- return /* @__PURE__ */ a("div", { className: "tag-list", "data-testid": "tag-editor", children: [
397
- e.map((s) => /* @__PURE__ */ a("span", { className: "tag removable", children: [
398
- s,
399
- /* @__PURE__ */ n(
400
- Qe,
401
- {
402
- danger: !0,
403
- icon: "close",
404
- label: `Remove tag ${s}`,
405
- title: `Remove ${s}`,
406
- onClick: () => i(At(e, s))
407
- }
408
- )
409
- ] }, s)),
410
- /* @__PURE__ */ n(
411
- "input",
412
- {
413
- type: "text",
414
- value: t,
415
- placeholder: "Add a tag…",
416
- "aria-label": "New tag",
417
- onChange: (s) => o(s.target.value)
418
- }
419
- )
420
- ] });
421
- }
422
- function xe(e) {
423
- const i = xn(e.kind).settings, { initial: t } = e, [r, o] = d(t.displayName), [s, l] = d(t.key ?? ""), [c, u] = d(t.tags ?? []), [b, N] = d(!1), [T, m] = d(null), E = r !== t.displayName, k = s !== (t.key ?? ""), W = i.hasTags && JSON.stringify(c) !== JSON.stringify(t.tags ?? []), F = E || k || W, P = i.canEditKey, M = s === "" || Gn(s), O = F && M && !b;
424
- async function R() {
425
- if (O) {
426
- m(null), N(!0);
427
- try {
428
- await e.onSave({
429
- displayName: r.trim(),
430
- key: P && k ? s : t.key,
431
- tags: i.hasTags ? c : void 0
432
- }), e.onClose();
433
- } catch (v) {
434
- m(v instanceof A ? v.message : String(v));
435
- } finally {
436
- N(!1);
437
- }
438
- }
439
- }
440
- const Q = Tn(R, { enabled: O });
441
- return /* @__PURE__ */ a(K, { title: "Edit settings", onClose: e.onClose, children: [
442
- /* @__PURE__ */ a("div", { className: "modal-body", children: [
443
- /* @__PURE__ */ a("label", { className: "field", children: [
444
- /* @__PURE__ */ n("span", { children: "Name" }),
445
- /* @__PURE__ */ n(
446
- "input",
447
- {
448
- type: "text",
449
- value: r,
450
- onChange: (v) => o(v.target.value),
451
- placeholder: i.namePlaceholder,
452
- autoFocus: !0,
453
- ...Q
454
- }
455
- )
456
- ] }),
457
- P && /* @__PURE__ */ a("label", { className: "field", children: [
458
- /* @__PURE__ */ n("span", { children: "Key" }),
459
- /* @__PURE__ */ n(
460
- "input",
461
- {
462
- type: "text",
463
- value: s,
464
- onChange: (v) => l(Yn(v.target.value)),
465
- placeholder: i.keyPlaceholder,
466
- ...Q
467
- }
468
- ),
469
- /* @__PURE__ */ a("span", { className: "muted small", children: [
470
- "Lowercase, kebab-case, 3–39 characters.",
471
- i.keyHintSuffix
472
- ] })
473
- ] }),
474
- i.hasTags && /* @__PURE__ */ a("div", { children: [
475
- /* @__PURE__ */ n("p", { className: "muted small", style: { marginBottom: "8px" }, children: "Tags" }),
476
- /* @__PURE__ */ n(Pt, { tags: c, onChange: u })
477
- ] }),
478
- T && /* @__PURE__ */ n("div", { className: "error", children: T })
479
- ] }),
480
- /* @__PURE__ */ a("div", { className: "modal-actions", children: [
481
- /* @__PURE__ */ n("button", { type: "button", className: "btn ghost", onClick: e.onClose, children: "Cancel" }),
482
- /* @__PURE__ */ n("button", { type: "button", className: "btn", disabled: !O, onClick: R, children: b ? "Saving…" : "Save" })
483
- ] })
484
- ] });
485
- }
486
- const Mt = {
487
- function: {
488
- json: "functions-version-json",
489
- error: "functions-version-error",
490
- revertButton: "functions-version-revert",
491
- invokeButton: "functions-version-invoke",
492
- invokeJson: "functions-version-invoke-json",
493
- invokeError: "functions-version-invoke-error"
494
- },
495
- workflow: {
496
- json: "workflows-version-json",
497
- error: "workflows-version-error",
498
- revertButton: "workflows-version-revert",
499
- invokeButton: "workflows-version-invoke",
500
- invokeJson: "workflows-version-invoke-json",
501
- invokeError: "workflows-version-invoke-error"
502
- },
503
- endpoint: {
504
- json: "endpoints-version-json",
505
- error: "endpoints-version-error",
506
- revertButton: "endpoints-version-revert",
507
- invokeButton: "endpoints-version-invoke",
508
- invokeJson: "endpoints-version-invoke-json",
509
- invokeError: "endpoints-version-invoke-error"
510
- }
511
- };
512
- function en(e) {
513
- const { kind: i, id: t, versionNumber: r } = e, o = Mt[i], s = at(i, t, r, !0), l = lt(i), c = dt(i), [u, b] = d(!1);
514
- return /* @__PURE__ */ a(B, { children: [
515
- /* @__PURE__ */ a(K, { title: `Version ${r}`, onClose: e.onClose, wide: !0, children: [
516
- /* @__PURE__ */ a("div", { className: "modal-body", children: [
517
- s.isLoading ? /* @__PURE__ */ n("p", { className: "muted small", children: "Loading…" }) : s.isError ? /* @__PURE__ */ n("div", { className: "error", "data-testid": o.error, children: s.error instanceof Error ? s.error.message : String(s.error) }) : s.data ? /* @__PURE__ */ n("div", { "data-testid": o.json, children: /* @__PURE__ */ n(
518
- ve,
519
- {
520
- code: JSON.stringify(s.data.definition, null, 2),
521
- language: "json",
522
- maxHeight: "420px",
523
- copyable: !0
524
- }
525
- ) }) : null,
526
- c.data !== void 0 && /* @__PURE__ */ n("div", { "data-testid": o.invokeJson, children: /* @__PURE__ */ n(
527
- ve,
528
- {
529
- code: JSON.stringify(c.data, null, 2),
530
- language: "json",
531
- maxHeight: "240px",
532
- copyable: !0
533
- }
534
- ) }),
535
- c.isError && /* @__PURE__ */ n("div", { className: "error", "data-testid": o.invokeError, children: c.error instanceof A ? c.error.message : String(c.error) })
536
- ] }),
537
- /* @__PURE__ */ a("div", { className: "modal-actions", children: [
538
- /* @__PURE__ */ n(
539
- "button",
540
- {
541
- type: "button",
542
- className: "btn ghost",
543
- "data-testid": o.invokeButton,
544
- disabled: c.isPending,
545
- onClick: () => c.mutate({ id: t, versionNumber: r }),
546
- children: c.isPending ? "Invoking…" : "Invoke this version"
547
- }
548
- ),
549
- /* @__PURE__ */ n(
550
- "button",
551
- {
552
- type: "button",
553
- className: "btn danger",
554
- "data-testid": o.revertButton,
555
- disabled: l.isPending,
556
- onClick: () => b(!0),
557
- children: l.isPending ? "Reverting…" : "Revert to this version"
558
- }
559
- ),
560
- /* @__PURE__ */ n("button", { type: "button", className: "btn ghost", onClick: e.onClose, children: "Close" })
561
- ] })
562
- ] }),
563
- u && /* @__PURE__ */ n(
564
- zn,
565
- {
566
- title: "Revert to this version",
567
- message: `Revert to version ${r}? This restores its content onto the resource's current draft; the resource's key and address stay unchanged.`,
568
- confirmLabel: "Revert",
569
- destructive: !0,
570
- onConfirm: () => {
571
- b(!1), l.mutate({ id: t, versionNumber: r });
572
- },
573
- onClose: () => b(!1)
574
- }
575
- )
576
- ] });
577
- }
578
- function Dt(e) {
579
- const {
580
- archived: i,
581
- deleteLabel: t,
582
- deleteTestId: r,
583
- archiveTestId: o,
584
- onRequestDelete: s,
585
- onRequestArchive: l,
586
- deleteError: c,
587
- archiveError: u
588
- } = e;
589
- return /* @__PURE__ */ a("div", { className: "rail-danger-zone rail-danger-zone--panel", "data-testid": "rail-danger-zone-panel", children: [
590
- i ? /* @__PURE__ */ a("span", { className: "rail-danger-zone-delete", children: [
591
- /* @__PURE__ */ n(An, { label: t, "data-testid": r, onClick: s }),
592
- /* @__PURE__ */ n("span", { children: "Delete" })
593
- ] }) : /* @__PURE__ */ n(
594
- "button",
595
- {
596
- type: "button",
597
- className: "btn danger",
598
- "data-testid": o,
599
- onClick: l,
600
- children: "Archive"
601
- }
602
- ),
603
- c && /* @__PURE__ */ n("div", { className: "error", "data-testid": "rail-delete-error", children: c }),
604
- u && /* @__PURE__ */ n("div", { className: "error", "data-testid": "rail-archive-error", children: u })
605
- ] });
606
- }
607
- function nn(e) {
608
- return /* @__PURE__ */ a("div", { className: "right-rail-panel-head rail-settings-head", children: [
609
- /* @__PURE__ */ n("h3", { children: "Settings" }),
610
- /* @__PURE__ */ n(Pn, { label: "Edit settings", "data-testid": "rail-settings-edit", onClick: e.onEdit })
611
- ] });
612
- }
613
- function tn(e) {
614
- const { id: i, displayName: t, fields: r, row: o, tags: s } = e;
615
- return /* @__PURE__ */ n("div", { className: "rail-meta", children: /* @__PURE__ */ n(
616
- "div",
617
- {
618
- style: {
619
- display: "flex",
620
- justifyContent: "space-between",
621
- alignItems: "flex-start",
622
- gap: "8px"
623
- },
624
- children: /* @__PURE__ */ a("dl", { className: "rail-meta-list", children: [
625
- t && /* @__PURE__ */ a(B, { children: [
626
- /* @__PURE__ */ n("dt", { children: "Name" }),
627
- /* @__PURE__ */ n("dd", { "data-testid": "rail-meta-name", children: /* @__PURE__ */ n("code", { children: t }) })
628
- ] }),
629
- /* @__PURE__ */ n("dt", { children: "ID" }),
630
- /* @__PURE__ */ n("dd", { "data-testid": "rail-meta-id", children: /* @__PURE__ */ n("code", { children: i }) }),
631
- r.includes("key") && o && /* @__PURE__ */ a(B, { children: [
632
- /* @__PURE__ */ n("dt", { children: "Key" }),
633
- /* @__PURE__ */ n("dd", { "data-testid": "rail-meta-key", children: /* @__PURE__ */ n("code", { children: o.key || "unset" }) })
634
- ] }),
635
- r.includes("updatedAt") && o && /* @__PURE__ */ a(B, { children: [
636
- /* @__PURE__ */ n("dt", { children: "Updated" }),
637
- /* @__PURE__ */ n("dd", { "data-testid": "rail-meta-updated", "data-value": o.updatedAt, children: new Date(o.updatedAt).toLocaleString() })
638
- ] }),
639
- s !== void 0 && o && /* @__PURE__ */ a(B, { children: [
640
- /* @__PURE__ */ n("dt", { children: "Tags" }),
641
- /* @__PURE__ */ n("dd", { "data-testid": "rail-meta-tags", children: s.length > 0 ? s.map((l) => /* @__PURE__ */ n("span", { className: "tag", children: l }, l)) : "No tags" })
642
- ] })
643
- ] })
644
- }
645
- ) });
646
- }
647
- function on(e) {
648
- return /* @__PURE__ */ n("div", { className: "rail-spec-actions", children: /* @__PURE__ */ n(
649
- Qe,
650
- {
651
- icon: "file-text",
652
- label: "Export, edit, or import",
653
- "data-testid": "rail-spec-actions-open",
654
- onClick: e.onOpen
655
- }
656
- ) });
657
- }
658
- function sn(e) {
659
- const { kind: i, children: t, onImport: r, onClose: o } = e;
660
- return /* @__PURE__ */ a(K, { title: "Definition", onClose: o, children: [
661
- /* @__PURE__ */ a("div", { className: "modal-body", children: [
662
- t,
663
- /* @__PURE__ */ a("p", { className: "muted small", children: [
664
- "Import a spec document to create a NEW ",
665
- i,
666
- " and navigate to it — this does not replace the ",
667
- i,
668
- " you have open."
669
- ] }),
670
- /* @__PURE__ */ n("div", { className: "rail-spec-menu-row", children: /* @__PURE__ */ n(
671
- "button",
672
- {
673
- type: "button",
674
- className: "btn ghost",
675
- "data-testid": "rail-spec-import",
676
- onClick: r,
677
- children: "Import"
678
- }
679
- ) })
680
- ] }),
681
- /* @__PURE__ */ n("div", { className: "modal-actions", children: /* @__PURE__ */ n("button", { type: "button", className: "btn ghost", onClick: o, children: "Close" }) })
682
- ] });
683
- }
684
- function rn(e) {
685
- const { open: i, versions: t } = e;
686
- return /* @__PURE__ */ a("div", { className: "rail-version-section", children: [
687
- /* @__PURE__ */ a(
688
- "button",
689
- {
690
- type: "button",
691
- className: "rail-link-icon",
692
- "data-testid": "rail-history-show",
693
- "aria-label": "Version history",
694
- title: "Version history",
695
- onClick: e.onShow,
696
- children: [
697
- /* @__PURE__ */ n(x, { name: "clock", size: 14 }),
698
- /* @__PURE__ */ n("span", { children: "Version history" })
699
- ]
700
- }
701
- ),
702
- i && /* @__PURE__ */ a(B, { children: [
703
- /* @__PURE__ */ n("p", { className: "muted small", "data-testid": "rail-version-published", children: (t == null ? void 0 : t.currentPublishedVersion) != null ? `Published: v${t.currentPublishedVersion}` : "Never published" }),
704
- /* @__PURE__ */ a("div", { className: "rail-version-actions", children: [
705
- /* @__PURE__ */ n(
706
- "button",
707
- {
708
- type: "button",
709
- className: "btn ghost",
710
- "data-testid": "rail-publish",
711
- disabled: e.publishing,
712
- onClick: e.onPublish,
713
- children: e.publishing ? "Publishing…" : "Publish"
714
- }
715
- ),
716
- " ",
717
- /* @__PURE__ */ n(
718
- "button",
719
- {
720
- type: "button",
721
- className: "btn ghost",
722
- "data-testid": "rail-enable-toggle",
723
- disabled: e.togglingEnabled || t === void 0,
724
- onClick: e.onToggleEnabled,
725
- children: e.togglingEnabled ? "Saving…" : t != null && t.enabled ? "Disable" : "Enable"
726
- }
727
- )
728
- ] }),
729
- e.publishError && /* @__PURE__ */ n("div", { className: "error", "data-testid": "rail-publish-error", children: e.publishError }),
730
- e.enableError && /* @__PURE__ */ n("div", { className: "error", "data-testid": "rail-enable-error", children: e.enableError })
731
- ] })
732
- ] });
733
- }
734
- function an(e) {
735
- const { loading: i, versions: t } = e;
736
- return /* @__PURE__ */ a(K, { title: "All versions", onClose: e.onClose, wide: !0, children: [
737
- /* @__PURE__ */ a("div", { className: "modal-body", children: [
738
- i && /* @__PURE__ */ n("p", { className: "muted small", children: "Loading…" }),
739
- (t == null ? void 0 : t.length) === 0 && /* @__PURE__ */ n("p", { className: "muted small", children: "No versions yet." }),
740
- t && t.length > 0 && /* @__PURE__ */ n("ul", { className: "list", children: t.map((r) => /* @__PURE__ */ n("li", { className: "selectable", children: /* @__PURE__ */ n(
741
- "button",
742
- {
743
- type: "button",
744
- className: "row-select",
745
- "data-testid": "rail-version-row",
746
- onClick: () => e.onSelect(r.versionNumber),
747
- children: /* @__PURE__ */ a("div", { className: "list-main", children: [
748
- /* @__PURE__ */ a("code", { children: [
749
- "v",
750
- r.versionNumber
751
- ] }),
752
- " ",
753
- r.isCurrentPublished && /* @__PURE__ */ n("span", { className: "badge", "data-testid": "rail-version-current", children: "Published" }),
754
- /* @__PURE__ */ n("div", { className: "muted small", children: new Date(r.createdAt).toLocaleString() })
755
- ] })
756
- }
757
- ) }, r.versionNumber)) })
758
- ] }),
759
- /* @__PURE__ */ n("div", { className: "modal-actions", children: /* @__PURE__ */ n("button", { type: "button", className: "btn ghost", onClick: e.onClose, children: "Done" }) })
760
- ] });
761
- }
762
- const It = {
763
- function: {
764
- deleteTitle: "Delete function",
765
- deleteMessage: "Delete this function permanently? Any endpoint, workflow, or call pointing to it will start failing with a not-found error the next time it runs, and this cannot be undone.",
766
- archiveTitle: "Archive function",
767
- archiveMessage: "Archive this function? It stops being invocable and can no longer be edited. Archiving is one-way — there is no unarchive — and only an archived function can be deleted.",
768
- deleteLabel: "Delete this function",
769
- deleteTestId: "delete-function",
770
- archiveTestId: "archive-function"
771
- },
772
- endpoint: {
773
- deleteTitle: "Delete endpoint",
774
- deleteMessage: "Delete this endpoint permanently? Any alias, workflow, or call pointing to it will start failing with a not-found error the next time it runs, and this cannot be undone.",
775
- archiveTitle: "Archive endpoint",
776
- archiveMessage: "Archive this endpoint? It stops being invocable and can no longer be edited. Archiving is one-way — there is no unarchive — and only an archived endpoint can be deleted.",
777
- deleteLabel: "Delete this endpoint",
778
- deleteTestId: "delete-endpoint",
779
- archiveTestId: "archive-endpoint"
780
- },
781
- workflow: {
782
- deleteTitle: "Delete workflow",
783
- deleteMessage: "Delete this workflow permanently? Its run history is discarded immediately via cascading deletes and cannot be recovered.",
784
- archiveTitle: "Archive workflow",
785
- archiveMessage: "Archive this workflow? It stops running and can no longer be published. Archiving is one-way — there is no unarchive — and only an archived workflow can be deleted.",
786
- deleteLabel: "Delete this workflow",
787
- deleteTestId: "wf-settings-delete",
788
- archiveTestId: "wf-settings-archive"
789
- }
790
- };
791
- function ln(e) {
792
- const i = It[e.kind];
793
- return /* @__PURE__ */ a(B, { children: [
794
- /* @__PURE__ */ n(
795
- Dt,
796
- {
797
- archived: e.archived,
798
- deleteLabel: i.deleteLabel,
799
- deleteTestId: i.deleteTestId,
800
- archiveTestId: i.archiveTestId,
801
- onRequestDelete: e.onRequestDelete,
802
- onRequestArchive: e.onRequestArchive,
803
- deleteError: e.deleteError,
804
- archiveError: e.archiveError
805
- }
806
- ),
807
- e.deleteConfirming && /* @__PURE__ */ n(
808
- Me,
809
- {
810
- title: i.deleteTitle,
811
- message: i.deleteMessage,
812
- confirmLabel: "Delete",
813
- onConfirm: e.onConfirmDelete,
814
- onClose: e.onCloseDelete
815
- }
816
- ),
817
- e.archiveConfirming && /* @__PURE__ */ n(
818
- Me,
819
- {
820
- title: i.archiveTitle,
821
- message: i.archiveMessage,
822
- confirmLabel: "Archive",
823
- onConfirm: e.onConfirmArchive,
824
- onClose: e.onCloseArchive
825
- }
826
- )
827
- ] });
828
- }
829
- const dn = { functionsKey: nt, endpointsKey: et, workflowsKey: Kn };
830
- function Ot({
831
- ctx: e,
832
- project: i,
833
- onNavigate: t,
834
- open: r
835
- }) {
836
- var L, _;
837
- const {
838
- editingSettings: o,
839
- setEditingSettings: s,
840
- historyOpen: l,
841
- setHistoryOpen: c,
842
- versionListOpen: u,
843
- setVersionListOpen: b
844
- } = r, N = je(i ?? void 0), T = (e == null ? void 0 : e.kind) === "workflow", m = (e == null ? void 0 : e.id) ?? "", E = Hn(m, T), k = Bn(i ?? void 0), W = Jn(), F = $n(), [P, M] = d(!1), [O, R] = d(!1), [Q, v] = d(!1), [p, w] = d(!1), [q, H] = d(null), [J, D] = d(null), U = qe("workflow", m, l && T), $ = Ue("workflow"), ee = ze("workflow"), [ne, te] = d(null), [ie, oe] = d(null), [X, z] = d(
845
- null
846
- );
847
- if (!e || e.kind !== "workflow")
848
- return /* @__PURE__ */ n("p", { className: "muted small", children: "Open a workflow to see its settings." });
849
- const C = (L = N.data) == null ? void 0 : L.find((h) => h.id === e.id), se = C && typeof C.displayName == "string" ? C.displayName : "", re = (C == null ? void 0 : C.tags) ?? [], ue = (C == null ? void 0 : C.status) === "archived";
850
- function he() {
851
- H(null), F.mutate(m, {
852
- onSuccess: () => {
853
- v(!1), t({ type: "list" });
854
- },
855
- onError: (h) => {
856
- v(!1), H(h instanceof A ? h.message : String(h));
857
- }
858
- });
859
- }
860
- function fe() {
861
- D(null), W.mutate(m, {
862
- onSuccess: () => {
863
- w(!1), t({ type: "list" });
864
- },
865
- onError: (h) => {
866
- w(!1), D(h instanceof A ? h.message : String(h));
867
- }
868
- });
869
- }
870
- return /* @__PURE__ */ a("div", { className: "rail-settings-panel", children: [
871
- /* @__PURE__ */ n(nn, { onEdit: () => s(!0) }),
872
- /* @__PURE__ */ n(
873
- tn,
874
- {
875
- id: e.id,
876
- displayName: se,
877
- fields: Oe("workflow"),
878
- row: C,
879
- tags: re
880
- }
881
- ),
882
- /* @__PURE__ */ n(on, { onOpen: () => M(!0) }),
883
- /* @__PURE__ */ n(
884
- rn,
885
- {
886
- open: l,
887
- versions: U.data,
888
- publishing: $.isPending,
889
- togglingEnabled: ee.isPending,
890
- publishError: ne,
891
- enableError: ie,
892
- onShow: () => {
893
- c(!0), b(!0);
894
- },
895
- onPublish: () => {
896
- te(null), $.mutate(m, {
897
- onError: (h) => te(h instanceof A ? h.message : String(h))
898
- });
899
- },
900
- onToggleEnabled: () => {
901
- var h;
902
- oe(null), ee.mutate(
903
- { id: m, enabled: !((h = U.data) != null && h.enabled) },
904
- { onError: (I) => oe(I instanceof A ? I.message : String(I)) }
905
- );
906
- }
907
- }
908
- ),
909
- u && /* @__PURE__ */ n(
910
- an,
911
- {
912
- loading: U.isLoading,
913
- versions: (_ = U.data) == null ? void 0 : _.versions,
914
- onSelect: (h) => z({ id: m, versionNumber: h }),
915
- onClose: () => b(!1)
916
- }
917
- ),
918
- X && X.id === m && /* @__PURE__ */ n(
919
- en,
920
- {
921
- kind: "workflow",
922
- id: m,
923
- versionNumber: X.versionNumber,
924
- onClose: () => z(null)
925
- }
926
- ),
927
- P && /* @__PURE__ */ n(
928
- sn,
929
- {
930
- kind: "workflow",
931
- onClose: () => M(!1),
932
- onImport: () => {
933
- M(!1), R(!0);
934
- }
935
- }
936
- ),
937
- o && C && /* @__PURE__ */ n(
938
- xe,
939
- {
940
- kind: "workflow",
941
- id: m,
942
- initial: {
943
- displayName: se,
944
- key: C.key ?? null,
945
- tags: re
946
- },
947
- onSave: async (h) => {
948
- if (!E.data) throw new Error("Unable to save settings");
949
- const I = E.data;
950
- return new Promise((ae, me) => {
951
- const G = {
952
- ...I.workflow,
953
- displayName: h.displayName
954
- };
955
- h.key !== void 0 && (G.key = h.key), h.tags !== void 0 && (G.tags = h.tags), k.mutate(
956
- { definition: G, ifUnmodifiedSince: I.updatedAt },
957
- { onSuccess: () => ae(), onError: me }
958
- );
959
- });
960
- },
961
- onClose: () => s(!1)
962
- },
963
- m
964
- ),
965
- /* @__PURE__ */ n(
966
- ln,
967
- {
968
- kind: "workflow",
969
- archived: ue,
970
- deleteConfirming: Q,
971
- archiveConfirming: p,
972
- deleteError: q,
973
- archiveError: J,
974
- onRequestDelete: () => v(!0),
975
- onRequestArchive: () => w(!0),
976
- onConfirmDelete: he,
977
- onConfirmArchive: fe,
978
- onCloseDelete: () => v(!1),
979
- onCloseArchive: () => w(!1)
980
- }
981
- ),
982
- O && /* @__PURE__ */ n(
983
- Ke,
984
- {
985
- kind: "workflow",
986
- project: i ?? void 0,
987
- listKeys: dn,
988
- onOpenImported: (h, I) => t({ type: "imported", kind: h, id: I }),
989
- onClose: () => R(!1)
990
- }
991
- )
992
- ] });
993
- }
994
- function Rt({ ctx: e }) {
995
- const { project: i, onNavigate: t } = Ze(), [r, o] = d(!1), [s, l] = d(!1), [c, u] = d(!1), b = {
996
- editingSettings: r,
997
- setEditingSettings: o,
998
- historyOpen: s,
999
- setHistoryOpen: l,
1000
- versionListOpen: c,
1001
- setVersionListOpen: u
1002
- };
1003
- return (e == null ? void 0 : e.kind) === "workflow" ? /* @__PURE__ */ n(Ot, { ctx: e, project: i, onNavigate: t, open: b }) : /* @__PURE__ */ n(Lt, { ctx: e, project: i, onNavigate: t, open: b });
1004
- }
1005
- function Lt({
1006
- ctx: e,
1007
- project: i,
1008
- onNavigate: t,
1009
- open: r
1010
- }) {
1011
- var Ne, Ce, Ee;
1012
- const {
1013
- editingSettings: o,
1014
- setEditingSettings: s,
1015
- historyOpen: l,
1016
- setHistoryOpen: c,
1017
- versionListOpen: u,
1018
- setVersionListOpen: b
1019
- } = r, N = e == null ? void 0 : e.kind, T = tt(N === "endpoint"), m = $e(N === "function"), [E, k] = d(!1), [W, F] = d(""), [P, M] = d(null), [O, R] = d(null), [Q, v] = d(!1), [p, w] = d(!1), [q, H] = d(!1), [J, D] = d(!1), [U, $] = d(!1), [ee, ne] = d(null), [te, ie] = d(null), oe = Fe((e == null ? void 0 : e.id) ?? "", (e == null ? void 0 : e.kind) === "function"), X = He((e == null ? void 0 : e.id) ?? "", (e == null ? void 0 : e.kind) === "endpoint"), z = Be(), C = Je(), se = it(), re = ot(), ue = st(), he = rt(), fe = e ? kn(e.kind) : null, L = ct(fe, (e == null ? void 0 : e.id) ?? "", p), _ = e && Ae(e.kind) ? e.kind : null, h = qe(_, (e == null ? void 0 : e.id) ?? "", l), I = Ue(_ ?? "function"), ae = ze(_ ?? "function"), [me, G] = d(null), [cn, be] = d(null), [pe, ye] = d(
1020
- null
1021
- );
1022
- if (!e || e.kind !== "function" && e.kind !== "endpoint")
1023
- return /* @__PURE__ */ n("p", { className: "muted small", children: "Open a workflow, function, or endpoint to see its settings." });
1024
- const y = e.kind, S = e.id, j = y === "function" ? (Ne = m.data) == null ? void 0 : Ne.find((f) => f.id === S) : (Ce = T.data) == null ? void 0 : Ce.find((f) => f.id === S), V = We(y, y === "function" ? oe.data : X.data), Y = (V == null ? void 0 : V.definition) ?? null, ke = j && typeof j.displayName == "string" ? j.displayName : "", un = Y ? JSON.stringify(Y, null, 2) : "";
1025
- function hn() {
1026
- M(null), F(un), R((V == null ? void 0 : V.updatedAt) ?? null), k(!0);
1027
- }
1028
- const Z = Y ? wn(W, { id: String(Y.id), key: String(Y.key) }) : { parsed: null, blockedReason: "No definition loaded yet." }, we = y === "function" ? z.isPending : C.isPending;
1029
- function fn() {
1030
- if (!Z.parsed || Z.blockedReason) return;
1031
- M(null);
1032
- const f = {
1033
- onSuccess: () => k(!1),
1034
- onError: (le) => M(le instanceof A ? le.message : String(le))
1035
- }, g = { definition: Z.parsed, ifUnmodifiedSince: O };
1036
- y === "function" ? z.mutate(g, f) : C.mutate(g, f);
1037
- }
1038
- const mn = (j == null ? void 0 : j.archivedAt) != null;
1039
- function pn() {
1040
- ne(null);
1041
- const f = {
1042
- onSuccess: () => {
1043
- D(!1), t({ type: "list" });
1044
- },
1045
- onError: (g) => {
1046
- D(!1), ne(g instanceof A ? g.message : String(g));
1047
- }
1048
- };
1049
- y === "function" ? se.mutate(S, f) : re.mutate(S, f);
1050
- }
1051
- function vn() {
1052
- ie(null);
1053
- const f = {
1054
- onSuccess: () => {
1055
- $(!1), t({ type: "list" });
1056
- },
1057
- onError: (g) => {
1058
- $(!1), ie(g instanceof A ? g.message : String(g));
1059
- }
1060
- };
1061
- y === "function" ? ue.mutate(S, f) : he.mutate(S, f);
1062
- }
1063
- return /* @__PURE__ */ a("div", { className: "rail-settings-panel", children: [
1064
- /* @__PURE__ */ n(nn, { onEdit: () => s(!0) }),
1065
- /* @__PURE__ */ n(
1066
- tn,
1067
- {
1068
- id: S,
1069
- displayName: ke,
1070
- fields: Oe(y),
1071
- row: j
1072
- }
1073
- ),
1074
- Pe(y) && /* @__PURE__ */ n(on, { onOpen: () => v(!0) }),
1075
- Ae(y) && /* @__PURE__ */ n(
1076
- rn,
1077
- {
1078
- open: l,
1079
- versions: h.data,
1080
- publishing: I.isPending,
1081
- togglingEnabled: ae.isPending,
1082
- publishError: me,
1083
- enableError: cn,
1084
- onShow: () => {
1085
- c(!0), b(!0);
1086
- },
1087
- onPublish: () => {
1088
- G(null), I.mutate(S, {
1089
- onError: (f) => G(f instanceof A ? f.message : String(f))
1090
- });
1091
- },
1092
- onToggleEnabled: () => {
1093
- var f;
1094
- be(null), ae.mutate(
1095
- { id: S, enabled: !((f = h.data) != null && f.enabled) },
1096
- { onError: (g) => be(g instanceof A ? g.message : String(g)) }
1097
- );
1098
- }
1099
- }
1100
- ),
1101
- u && /* @__PURE__ */ n(
1102
- an,
1103
- {
1104
- loading: h.isLoading,
1105
- versions: (Ee = h.data) == null ? void 0 : Ee.versions,
1106
- onSelect: (f) => ye({ id: S, versionNumber: f }),
1107
- onClose: () => b(!1)
1108
- }
1109
- ),
1110
- pe && pe.id === S && /* @__PURE__ */ n(
1111
- en,
1112
- {
1113
- kind: y,
1114
- id: S,
1115
- versionNumber: pe.versionNumber,
1116
- onClose: () => ye(null)
1117
- }
1118
- ),
1119
- Q && /* @__PURE__ */ n(
1120
- sn,
1121
- {
1122
- kind: y,
1123
- onClose: () => v(!1),
1124
- onImport: () => {
1125
- v(!1), H(!0);
1126
- },
1127
- children: Pe(y) && /* @__PURE__ */ a(B, { children: [
1128
- /* @__PURE__ */ n("p", { className: "muted small", children: "Export a portable definition — the same shape Import accepts — or Edit JSON to change what's stored directly." }),
1129
- /* @__PURE__ */ a("div", { className: "rail-spec-menu-row", children: [
1130
- /* @__PURE__ */ n(
1131
- "button",
1132
- {
1133
- type: "button",
1134
- className: "btn ghost",
1135
- "data-testid": "rail-spec-export",
1136
- onClick: () => {
1137
- v(!1), w(!0);
1138
- },
1139
- children: "Export"
1140
- }
1141
- ),
1142
- " ",
1143
- /* @__PURE__ */ n(
1144
- "button",
1145
- {
1146
- type: "button",
1147
- className: "btn ghost",
1148
- disabled: !Y,
1149
- "data-testid": "rail-json-edit",
1150
- onClick: () => {
1151
- v(!1), hn();
1152
- },
1153
- children: "Edit JSON"
1154
- }
1155
- )
1156
- ] })
1157
- ] })
1158
- }
1159
- ),
1160
- p && /* @__PURE__ */ a(K, { title: "Export spec document", onClose: () => w(!1), wide: !0, children: [
1161
- /* @__PURE__ */ n("div", { className: "modal-body", children: L.isLoading ? /* @__PURE__ */ n("p", { className: "muted small", children: "Loading…" }) : L.isError ? /* @__PURE__ */ n("div", { className: "error", "data-testid": "rail-spec-error", children: L.error instanceof Error ? L.error.message : String(L.error) }) : L.data ? /* @__PURE__ */ n("div", { "data-testid": "rail-spec-json", children: /* @__PURE__ */ n(
1162
- ve,
1163
- {
1164
- code: JSON.stringify(L.data, null, 2),
1165
- language: "json",
1166
- maxHeight: "420px",
1167
- copyable: !0
1168
- }
1169
- ) }) : null }),
1170
- /* @__PURE__ */ n("div", { className: "modal-actions", children: /* @__PURE__ */ n("button", { type: "button", className: "btn ghost", onClick: () => w(!1), children: "Close" }) })
1171
- ] }),
1172
- E && /* @__PURE__ */ a(K, { title: "Edit definition", onClose: () => k(!1), wide: !0, children: [
1173
- /* @__PURE__ */ a("div", { className: "modal-body", children: [
1174
- /* @__PURE__ */ n(
1175
- Mn,
1176
- {
1177
- value: W,
1178
- onChange: F,
1179
- minHeight: "320px",
1180
- "aria-label": "Edit definition JSON"
1181
- }
1182
- ),
1183
- Z.blockedReason && /* @__PURE__ */ n("p", { className: "muted small", "data-testid": "rail-edit-reason", children: Z.blockedReason }),
1184
- P && /* @__PURE__ */ n("div", { className: "error", children: P })
1185
- ] }),
1186
- /* @__PURE__ */ a("div", { className: "modal-actions", children: [
1187
- /* @__PURE__ */ n("button", { type: "button", className: "btn ghost", onClick: () => k(!1), children: "Cancel" }),
1188
- /* @__PURE__ */ n(
1189
- "button",
1190
- {
1191
- type: "button",
1192
- className: "btn",
1193
- disabled: Z.blockedReason !== null || we,
1194
- "data-testid": "rail-json-save",
1195
- onClick: fn,
1196
- children: we ? "Saving…" : "Save"
1197
- }
1198
- )
1199
- ] })
1200
- ] }),
1201
- o && j && /* @__PURE__ */ n(
1202
- xe,
1203
- {
1204
- kind: y,
1205
- id: S,
1206
- initial: {
1207
- displayName: ke,
1208
- key: j.key ?? null,
1209
- tags: []
1210
- },
1211
- onSave: async (f) => {
1212
- if (!V) throw new Error("Unable to save settings");
1213
- const g = V.definition, Se = { definition: y === "function" ? (
1214
- // `canEditKey: true` for function (`callable-descriptors.ts`): `data.key` must
1215
- // reach the server (the modal falls back to `initial.key` when unchanged).
1216
- { ...g, displayName: f.displayName, key: f.key ?? g.key }
1217
- ) : { ...g, displayName: f.displayName }, ifUnmodifiedSince: V.updatedAt };
1218
- return new Promise((gn, bn) => {
1219
- const Te = { onSuccess: () => gn(), onError: bn };
1220
- y === "function" ? z.mutate(Se, Te) : C.mutate(Se, Te);
1221
- });
1222
- },
1223
- onClose: () => s(!1)
1224
- },
1225
- S
1226
- ),
1227
- Nn(y) && /* @__PURE__ */ n(
1228
- ln,
1229
- {
1230
- kind: y,
1231
- archived: mn,
1232
- deleteConfirming: J,
1233
- archiveConfirming: U,
1234
- deleteError: ee,
1235
- archiveError: te,
1236
- onRequestDelete: () => D(!0),
1237
- onRequestArchive: () => $(!0),
1238
- onConfirmDelete: pn,
1239
- onConfirmArchive: vn,
1240
- onCloseDelete: () => D(!1),
1241
- onCloseArchive: () => $(!1)
1242
- }
1243
- ),
1244
- q && /* @__PURE__ */ n(
1245
- Ke,
1246
- {
1247
- kind: y,
1248
- project: i ?? void 0,
1249
- listKeys: dn,
1250
- onOpenImported: (f, g) => t({ type: "imported", kind: f, id: g }),
1251
- onClose: () => H(!1)
1252
- }
1253
- )
1254
- ] });
1255
- }
1256
- function Qt() {
1257
- return /* @__PURE__ */ n(x, { name: "settings" });
1258
- }
1259
- const jt = {
1260
- id: "settings",
1261
- title: "Settings",
1262
- rendersHeading: !0,
1263
- Icon: Qt,
1264
- isAvailable: (e) => (e == null ? void 0 : e.kind) === "workflow" || (e == null ? void 0 : e.kind) === "function" || (e == null ? void 0 : e.kind) === "endpoint",
1265
- Panel: Rt
1266
- }, ii = [jt, gt, St];
1267
- export {
1268
- yt as C,
1269
- ni as P,
1270
- ti as R,
1271
- Zt as W,
1272
- Ze as a,
1273
- ei as b,
1274
- Xt as c,
1275
- xt as d,
1276
- ii as e,
1277
- ut as u
1278
- };
1279
- //# sourceMappingURL=editor-tools-B_Lfx3kw.js.map