@w6w/embed 0.2.29 → 0.2.31

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 (76) hide show
  1. package/dist/{CreateFunctionModal-CCYi9deY.js → CreateFunctionModal-glk2zg1r.js} +28 -27
  2. package/dist/{CreateFunctionModal-CCYi9deY.js.map → CreateFunctionModal-glk2zg1r.js.map} +1 -1
  3. package/dist/{DocumentFormModal-CCIgA7pR.js → DocumentFormModal-Cw85R4wk.js} +2 -2
  4. package/dist/{DocumentFormModal-CCIgA7pR.js.map → DocumentFormModal-Cw85R4wk.js.map} +1 -1
  5. package/dist/{ImportSpecModal-DoxsVxru.js → ImportSpecModal-fU5RsVTa.js} +2 -2
  6. package/dist/{ImportSpecModal-DoxsVxru.js.map → ImportSpecModal-fU5RsVTa.js.map} +1 -1
  7. package/dist/WorkflowEditor-B-Wc_r4X.js +1140 -0
  8. package/dist/WorkflowEditor-B-Wc_r4X.js.map +1 -0
  9. package/dist/callable-record-Bhxim8C1.js +14 -0
  10. package/dist/callable-record-Bhxim8C1.js.map +1 -0
  11. package/dist/callables-B49tS2vv.js +297 -0
  12. package/dist/callables-B49tS2vv.js.map +1 -0
  13. package/dist/{document-sources-DNmBojx6.js → document-sources-Khcw2zB5.js} +16 -16
  14. package/dist/document-sources-Khcw2zB5.js.map +1 -0
  15. package/dist/draft.mjs +1 -1
  16. package/dist/editor/WorkflowInputsModal.d.ts +12 -0
  17. package/dist/editor/WorkflowVariablesEditor.d.ts +1 -1
  18. package/dist/{editor-tools--Y3wlBZE.js → editor-tools-Ch1cAE4F.js} +434 -377
  19. package/dist/editor-tools-Ch1cAE4F.js.map +1 -0
  20. package/dist/editor.mjs +1 -1
  21. package/dist/editors.mjs +85 -85
  22. package/dist/endpoints-zOuwci2U.js +136 -0
  23. package/dist/endpoints-zOuwci2U.js.map +1 -0
  24. package/dist/fields-CXHRR5eK.js +28 -0
  25. package/dist/fields-CXHRR5eK.js.map +1 -0
  26. package/dist/forms.mjs +1 -1
  27. package/dist/index.mjs +91 -91
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/lib/callable-duplicate.d.ts +26 -0
  30. package/dist/lib/recent-activity.d.ts +2 -2
  31. package/dist/lib/variable-preview.d.ts +6 -0
  32. package/dist/lib/workflow-version.d.ts +19 -2
  33. package/dist/lib.mjs +41 -40
  34. package/dist/lib.mjs.map +1 -1
  35. package/dist/lists/AiKeyCreate.d.ts +20 -0
  36. package/dist/lists/CallableKindList.d.ts +21 -2
  37. package/dist/lists/CallableRowParts.d.ts +38 -0
  38. package/dist/lists/CredentialCreate.d.ts +17 -17
  39. package/dist/lists/CredentialDetail.d.ts +2 -0
  40. package/dist/lists/CredentialFields.d.ts +18 -0
  41. package/dist/lists/CredentialList.d.ts +35 -3
  42. package/dist/lists/EndpointList.d.ts +2 -1
  43. package/dist/lists/WorkflowList.d.ts +2 -1
  44. package/dist/lists.d.ts +2 -0
  45. package/dist/lists.mjs +2185 -1615
  46. package/dist/lists.mjs.map +1 -1
  47. package/dist/rail.mjs +1 -1
  48. package/dist/repos/callables.d.ts +23 -0
  49. package/dist/repos/fields.d.ts +4 -1
  50. package/dist/repos.mjs +287 -284
  51. package/dist/settings-rail-BjsTjg2u.js +22 -0
  52. package/dist/settings-rail-BjsTjg2u.js.map +1 -0
  53. package/dist/spec-export-BtnoV0ex.js +33 -0
  54. package/dist/spec-export-BtnoV0ex.js.map +1 -0
  55. package/dist/spec-import-CGPqUUjN.js +272 -0
  56. package/dist/spec-import-CGPqUUjN.js.map +1 -0
  57. package/dist/{use-callable-draft-DCauHt5o.js → use-callable-draft-DjW7_9qb.js} +8 -7
  58. package/dist/{use-callable-draft-DCauHt5o.js.map → use-callable-draft-DjW7_9qb.js.map} +1 -1
  59. package/package.json +5 -5
  60. package/src/styles.css +221 -10
  61. package/dist/WorkflowEditor-CBUwh85L.js +0 -1117
  62. package/dist/WorkflowEditor-CBUwh85L.js.map +0 -1
  63. package/dist/callables-tOlflvbl.js +0 -151
  64. package/dist/callables-tOlflvbl.js.map +0 -1
  65. package/dist/document-sources-DNmBojx6.js.map +0 -1
  66. package/dist/editor-tools--Y3wlBZE.js.map +0 -1
  67. package/dist/endpoints-DArAqoLT.js +0 -233
  68. package/dist/endpoints-DArAqoLT.js.map +0 -1
  69. package/dist/fields-DvS8XZFc.js +0 -21
  70. package/dist/fields-DvS8XZFc.js.map +0 -1
  71. package/dist/settings-rail--GdRMusb.js +0 -33
  72. package/dist/settings-rail--GdRMusb.js.map +0 -1
  73. package/dist/spec-export-DMMET5VM.js +0 -189
  74. package/dist/spec-export-DMMET5VM.js.map +0 -1
  75. package/dist/spec-import-0B6oUewa.js +0 -116
  76. package/dist/spec-import-0B6oUewa.js.map +0 -1
@@ -1,1117 +0,0 @@
1
- import { jsxs as g, jsx as a, Fragment as le } from "react/jsx-runtime";
2
- import { useQueryClient as Ot, useQueries as Re } from "@tanstack/react-query";
3
- import { ApiError as Ce } from "@w6w/sdk";
4
- import { Modal as fn, IconButton as ce, JsonEditor as pn, useExpressionOptions as hn, ExpressionEditorModal as mn, useW6WApi as It, W6WUIProvider as bn, isTestRequired as Ct, requiredParamsFilled as gn, ExecutionLogPanel as yn, testInputSavesSettled as vn } from "@w6w/ui";
5
- import { useState as v, useMemo as w, createElement as J, useId as wn, useCallback as E, useContext as Sn, useRef as S, useEffect as T, Suspense as kn, lazy as Nn } from "react";
6
- import { E as En, $ as Rn, W as Cn, Q as Pn, V as An, q as Tn, X as jn, v as On, B as In, A as Fn, N as Ln, a as Mn, z as Jn, n as Dn, y as Bn, t as Wn, b as $n } from "./workflows-Dz8LMjnt.js";
7
- import { H as xn, a as Kn } from "./editor-apps-HEOclsxL.js";
8
- import { M as ue } from "./ConfirmModal-WqBfWftD.js";
9
- import { d as Qn, W as _n, e as qn, R as Hn, P as Vn, b as zn, c as Gn } from "./editor-tools--Y3wlBZE.js";
10
- import { u as Yn } from "./client-context-CX61Bgw-.js";
11
- import { u as Un } from "./use-workflow-draft-l3P5KZzw.js";
12
- import { r as Xn, h as Zn, e as es, f as ts, a as ns, d as ss, b as os, p as is, i as rs, g as as } from "./setup-incomplete-BHs3Lpfy.js";
13
- import { g as Pt, r as ls, c as cs, v as us } from "./document-sources-DNmBojx6.js";
14
- import { n as At } from "./import-bindings-EUtxZ9Ti.js";
15
- import { p as ds, d as fs } from "./settings-rail--GdRMusb.js";
16
- import { u as ps, b as hs } from "./project-context-Tvp-La7A.js";
17
- import { i as ms, d as Tt } from "./connections-CzsCyIxY.js";
18
- import { h as bs, b as gs, g as ys, d as vs, u as ws, e as Ss } from "./spec-export-DMMET5VM.js";
19
- import { l as jt, a as Pe, w as ks } from "./step-tests-B4E4W3ly.js";
20
- import { i as Ns, f as Es } from "./vault-BSEWhMYC.js";
21
- import { i as Rs } from "./data-stores-UeQvwVCa.js";
22
- import { e as Cs } from "./apps-FMcQfyL2.js";
23
- import { E as Ps } from "./theme-context-E2ZhlXDX.js";
24
- import { validateInitialState as As } from "@w6w/expr";
25
- function Ts({ title: n }) {
26
- const { value: e, placeholder: r, maxLength: i, ariaLabel: s, onChange: l, onBlur: u } = n;
27
- return /* @__PURE__ */ a(
28
- "input",
29
- {
30
- className: "wf-title-input",
31
- value: e,
32
- placeholder: r,
33
- maxLength: i,
34
- size: Math.min(Math.max(e.length, r.length), 80),
35
- "aria-label": s,
36
- onChange: (d) => l(d.target.value),
37
- onBlur: u
38
- }
39
- );
40
- }
41
- function js({
42
- onBack: n,
43
- backLabel: e,
44
- title: r,
45
- titleAdornment: i,
46
- actions: s
47
- }) {
48
- return /* @__PURE__ */ g("div", { className: "wf-fullbleed-head", children: [
49
- e !== null && /* @__PURE__ */ a(
50
- "button",
51
- {
52
- type: "button",
53
- className: "muted wf-back-btn",
54
- "data-testid": "wf-editor-back",
55
- onClick: n,
56
- children: e
57
- }
58
- ),
59
- r.editable ? /* @__PURE__ */ a(Ts, { title: r }) : /* @__PURE__ */ g("h2", { className: "exec-profile-title", children: [
60
- r.value,
61
- " ",
62
- i
63
- ] }),
64
- /* @__PURE__ */ g("div", { className: "wf-head-actions", style: { marginLeft: "auto" }, children: [
65
- r.editable && i,
66
- s
67
- ] })
68
- ] });
69
- }
70
- function Os(n, e, r) {
71
- if (!(n !== "workflow" || e === void 0))
72
- return (i) => {
73
- r(), e(i.id);
74
- };
75
- }
76
- function Is(n) {
77
- const { kind: e, id: r, onClose: i, onOpenRun: s } = n, [l, u] = v(En), d = Os(e, s, i);
78
- return /* @__PURE__ */ a(
79
- fn,
80
- {
81
- size: "full",
82
- title: "History",
83
- subtitle: r,
84
- onClose: i,
85
- headerRight: /* @__PURE__ */ a(ce, { icon: "close", label: "Close", onClick: i }),
86
- children: /* @__PURE__ */ a("div", { className: "w6w-modal-body", children: /* @__PURE__ */ a(
87
- xn,
88
- {
89
- scope: { callable: r },
90
- showKind: !1,
91
- filters: l,
92
- onFiltersChange: u,
93
- onOpenInEditor: d
94
- }
95
- ) })
96
- }
97
- );
98
- }
99
- function Fs(n) {
100
- return /* @__PURE__ */ a(ce, { icon: "json", onClick: n.onClick, label: "Edit raw JSON definition" });
101
- }
102
- function Ls(n) {
103
- return n.open ? n.mode === "apply" ? /* @__PURE__ */ a(Ms, { ...n }) : /* @__PURE__ */ a(Js, { ...n }) : null;
104
- }
105
- function Ft(n) {
106
- return /* @__PURE__ */ a("div", { className: "json-toggle-editor", children: /* @__PURE__ */ a(
107
- pn,
108
- {
109
- value: n.value,
110
- onChange: n.onChange,
111
- minHeight: "120px",
112
- "aria-label": n.label
113
- }
114
- ) });
115
- }
116
- function Ms(n) {
117
- const { onClose: e, title: r, value: i, prepareApply: s, onApply: l, editorLabel: u } = n, [d, y] = v(i), [h, m] = v(i), [j, z] = v([]), [de, I] = v(!1), C = w(
118
- () => (s == null ? void 0 : s(d)) ?? { ok: !0, text: d, restored: [] },
119
- [s, d]
120
- ), D = d !== h, G = () => D ? I(!0) : e(), Y = () => {
121
- !C.ok || !D || (l == null || l(C.text), y(C.text), m(C.text), z(C.restored), I(!1));
122
- };
123
- return /* @__PURE__ */ g(ue, { title: r, onClose: G, wide: !0, className: "modal-json", children: [
124
- /* @__PURE__ */ g("div", { className: "modal-body", children: [
125
- /* @__PURE__ */ g("p", { className: "muted small", children: [
126
- "Edit the raw definition (",
127
- /* @__PURE__ */ a("code", { children: 'manifestVersion: "2"' }),
128
- "). Apply updates the visual editor; Save stores it."
129
- ] }),
130
- /* @__PURE__ */ a(
131
- Ft,
132
- {
133
- value: d,
134
- onChange: (U) => {
135
- y(U), I(!1);
136
- },
137
- label: u
138
- }
139
- ),
140
- !C.ok && /* @__PURE__ */ a("p", { className: "error small", role: "alert", "data-testid": "json-toggle-error", children: C.error }),
141
- j.length > 0 && /* @__PURE__ */ g("p", { className: "muted small", "data-testid": "json-toggle-restored", children: [
142
- "Restored ",
143
- j.join(", "),
144
- ": ",
145
- j.length > 1 ? "these fields" : "this field",
146
- " ",
147
- "can't be changed in JSON."
148
- ] })
149
- ] }),
150
- /* @__PURE__ */ a("div", { className: "modal-actions", children: de ? /* @__PURE__ */ g(le, { children: [
151
- /* @__PURE__ */ a("span", { className: "muted small json-toggle-confirm", children: "Discard unapplied changes?" }),
152
- /* @__PURE__ */ a("button", { type: "button", className: "btn ghost", onClick: () => I(!1), children: "Keep editing" }),
153
- /* @__PURE__ */ a(
154
- "button",
155
- {
156
- type: "button",
157
- className: "btn danger",
158
- "data-testid": "json-toggle-discard",
159
- onClick: e,
160
- children: "Discard"
161
- }
162
- )
163
- ] }) : /* @__PURE__ */ g(le, { children: [
164
- /* @__PURE__ */ a(
165
- "button",
166
- {
167
- type: "button",
168
- className: "btn ghost",
169
- "data-testid": "json-toggle-close",
170
- onClick: G,
171
- children: "Close"
172
- }
173
- ),
174
- /* @__PURE__ */ a(
175
- "button",
176
- {
177
- type: "button",
178
- className: "btn",
179
- "data-testid": "json-toggle-apply",
180
- disabled: !C.ok || !D,
181
- onClick: Y,
182
- children: "Apply"
183
- }
184
- )
185
- ] }) })
186
- ] });
187
- }
188
- function Js(n) {
189
- const { onClose: e, title: r, value: i, onChange: s, guard: l, onSave: u, saving: d, error: y, editorLabel: h } = n, m = (l == null ? void 0 : l(i)) ?? null;
190
- return /* @__PURE__ */ g(ue, { title: r, onClose: e, wide: !0, className: "modal-json", children: [
191
- /* @__PURE__ */ g("div", { className: "modal-body", children: [
192
- /* @__PURE__ */ a("p", { className: "muted small", children: "Save replaces the stored definition." }),
193
- /* @__PURE__ */ a(Ft, { value: i, onChange: (j) => s == null ? void 0 : s(j), label: h }),
194
- m && /* @__PURE__ */ a("p", { className: "muted small", "data-testid": "json-toggle-reason", children: m }),
195
- y && /* @__PURE__ */ a("div", { className: "error", children: y })
196
- ] }),
197
- /* @__PURE__ */ g("div", { className: "modal-actions", children: [
198
- /* @__PURE__ */ a("button", { type: "button", className: "btn ghost", onClick: e, children: "Cancel" }),
199
- /* @__PURE__ */ a(
200
- "button",
201
- {
202
- type: "button",
203
- className: "btn",
204
- "data-testid": "json-toggle-save",
205
- disabled: m != null || !!d,
206
- onClick: u,
207
- children: d ? "Saving…" : "Save"
208
- }
209
- )
210
- ] })
211
- ] });
212
- }
213
- function Ds(n, e) {
214
- const r = (s) => Array.isArray(s) ? s.map(r) : s !== null && typeof s == "object" ? Object.fromEntries(
215
- Object.entries(s).sort(([l], [u]) => l.localeCompare(u)).map(([l, u]) => [l, r(u)])
216
- ) : s, i = (s) => {
217
- if (s === null || typeof s != "object" || Array.isArray(s)) return s;
218
- const { status: l, ...u } = s;
219
- return { ...u, key: u.key ?? null, tags: u.tags ?? [] };
220
- };
221
- return JSON.stringify(r(i(n))) === JSON.stringify(r(i(e)));
222
- }
223
- function Bs(n) {
224
- const { kind: e, problemCount: r, canEnable: i, onEnable: s, pending: l } = n, u = r > 0 ? `This ${e} is disabled and ${r} ${r === 1 ? "step uses" : "steps use"} a connection that no longer exists. Choose another connection, save, then Enable.` : "Connections fixed. Enable to run again.";
225
- return J(
226
- "div",
227
- { role: "alert", className: "error", "data-testid": "binding-disabled-banner" },
228
- J("span", null, u),
229
- " ",
230
- J(
231
- "button",
232
- {
233
- type: "button",
234
- "data-testid": "binding-enable",
235
- disabled: !i || l === !0,
236
- onClick: s
237
- },
238
- "Enable"
239
- )
240
- );
241
- }
242
- function Ws({
243
- project: n,
244
- onNavigate: e,
245
- rail: r = !0,
246
- storageKey: i,
247
- tools: s = qn,
248
- children: l
249
- }) {
250
- const u = Qn(), d = /* @__PURE__ */ a(Hn, { project: n, onNavigate: e, children: /* @__PURE__ */ g(Vn, { project: n, children: [
251
- l,
252
- r && /* @__PURE__ */ a(zn, { tools: s, storageKey: i })
253
- ] }) });
254
- return r || !u ? /* @__PURE__ */ a(_n, { children: d }) : d;
255
- }
256
- function $s({
257
- message: n,
258
- disabled: e = !1,
259
- children: r
260
- }) {
261
- const i = wn(), [s, l] = v(!1);
262
- return /* @__PURE__ */ g(
263
- "fieldset",
264
- {
265
- className: "wf-publish-tooltip",
266
- "aria-label": "Publish workflow",
267
- "aria-describedby": i,
268
- tabIndex: e ? 0 : void 0,
269
- onMouseEnter: () => l(!0),
270
- onMouseLeave: () => l(!1),
271
- onFocus: () => l(!0),
272
- onBlur: (u) => {
273
- u.currentTarget.contains(u.relatedTarget) || l(!1);
274
- },
275
- onKeyDown: (u) => {
276
- u.key === "Escape" && l(!1);
277
- },
278
- children: [
279
- r(i),
280
- s && /* @__PURE__ */ a("span", { id: i, role: "tooltip", className: "wf-publish-hint", children: n })
281
- ]
282
- }
283
- );
284
- }
285
- function xs(n) {
286
- const { problems: e, nodeLabel: r } = n, i = Object.entries(e).filter(([, l]) => l.length > 0);
287
- if (i.length === 0) return null;
288
- const s = i.length;
289
- return J(
290
- "div",
291
- { role: "status", className: "error", "data-testid": "setup-incomplete-banner" },
292
- J(
293
- "span",
294
- null,
295
- `Setup incomplete: ${s} ${s === 1 ? "step needs" : "steps need"} attention. The workflow can still run.`
296
- ),
297
- J(
298
- "ul",
299
- { "data-testid": "setup-incomplete-list" },
300
- ...i.map(
301
- ([l, u]) => J("li", { key: l }, `${r ? r(l) : l}: ${u.join(", ")}`)
302
- )
303
- )
304
- );
305
- }
306
- const Ks = {
307
- invalid_json: "This isn't valid JSON yet, so it isn't saved. Fix it to save.",
308
- not_object: 'Starting state must be a JSON object, like {"region": "us"}. Not saved.',
309
- too_large: "Starting state is over the 64 KiB limit. Not saved."
310
- };
311
- function Qs(n) {
312
- const e = hn();
313
- return /* @__PURE__ */ a(
314
- mn,
315
- {
316
- mode: "json-binding",
317
- startingState: !0,
318
- title: "Starting state",
319
- fieldLabel: "initialState",
320
- value: void 0,
321
- options: e,
322
- jsonValue: n.initialState,
323
- jsonProblem: (r) => {
324
- const i = Pt(r);
325
- if (!i.ok) return Ks[i.reason];
326
- const s = i.value === void 0 ? void 0 : As(i.value)[0];
327
- return s ? `${s.message} Not saved.` : null;
328
- },
329
- onSaveJson: (r) => {
330
- const i = Pt(r === void 0 ? "" : JSON.stringify(r));
331
- i.ok && n.onChange(i.value);
332
- },
333
- onClose: n.onClose
334
- }
335
- );
336
- }
337
- const Lt = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/, _s = "Untitled workflow", qs = ["id", "key", "manifestVersion"];
338
- function Hs(n) {
339
- let e = 0;
340
- const r = () => {
341
- for (; e < n.length && `
342
- \r`.includes(n[e]); ) e++;
343
- }, i = () => {
344
- throw e;
345
- }, s = (h) => {
346
- for (const m of h)
347
- n[e] !== m && i(), e++;
348
- }, l = () => {
349
- for (e++; n[e] !== '"'; ) {
350
- const h = n[e];
351
- if ((h === void 0 || h < " ") && i(), h === "\\")
352
- if (e++, n[e] === "u")
353
- for (let m = 0; m < 4; m++)
354
- e++, /[0-9a-fA-F]/.test(n[e] ?? "") || i();
355
- else '"\\/bfnrt'.includes(n[e] ?? "x") || i();
356
- e++;
357
- }
358
- e++;
359
- }, u = /-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?/y, d = () => {
360
- u.lastIndex = e, u.test(n) || i(), e = u.lastIndex;
361
- }, y = () => {
362
- r();
363
- const h = n[e];
364
- if (h === "{" || h === "[") {
365
- const m = h === "{" ? "}" : "]";
366
- if (e++, r(), n[e] === m) {
367
- e++;
368
- return;
369
- }
370
- for (; ; )
371
- if (m === "}" && (r(), n[e] !== '"' && i(), l(), r(), n[e] !== ":" && i(), e++), y(), r(), n[e] === ",") e++;
372
- else if (n[e] === m) {
373
- e++;
374
- return;
375
- } else i();
376
- }
377
- h === '"' ? l() : h === "t" ? s("true") : h === "f" ? s("false") : h === "n" ? s("null") : d();
378
- };
379
- try {
380
- return y(), r(), e < n.length ? e : null;
381
- } catch (h) {
382
- return typeof h == "number" ? Math.min(h, n.length) : 0;
383
- }
384
- }
385
- function Vs(n, e) {
386
- const r = e instanceof Error ? e.message : String(e), i = Hs(n);
387
- if (i === null) return r;
388
- const s = n.slice(0, i), l = s.split(`
389
- `).length, u = i - s.lastIndexOf(`
390
- `);
391
- return `Line ${l}, column ${u}: ${r}`;
392
- }
393
- const ae = (n) => typeof n == "object" && n !== null && !Array.isArray(n);
394
- function zs(n) {
395
- if (typeof n.name != "string" || n.name.length === 0) return "`name` is required.";
396
- const e = n.nodes ?? n.steps;
397
- if (!Array.isArray(e)) return "`nodes` must be an array.";
398
- const r = /* @__PURE__ */ new Set();
399
- for (let i = 0; i < e.length; i++) {
400
- const s = e[i];
401
- if (!ae(s)) return `\`nodes[${i}]\` must be an object.`;
402
- if (typeof s.id != "string" || s.id.length === 0)
403
- return `\`nodes[${i}].id\` must be a non-empty string.`;
404
- if (s.id.includes(".")) return `Node id "${s.id}" may not contain ".".`;
405
- if (r.has(s.id)) return `Node id "${s.id}" is used twice.`;
406
- r.add(s.id);
407
- const l = s.position;
408
- if (l !== void 0 && (!ae(l) || !Number.isFinite(l.x) || !Number.isFinite(l.y)))
409
- return `\`nodes[${i}].position\` must be { "x": number, "y": number }.`;
410
- }
411
- if (n.edges !== void 0) {
412
- if (!Array.isArray(n.edges)) return "`edges` must be an array.";
413
- for (let i = 0; i < n.edges.length; i++) {
414
- const s = n.edges[i];
415
- if (!ae(s)) return `\`edges[${i}]\` must be an object.`;
416
- for (const l of ["from", "to"])
417
- if (typeof s[l] != "string" || !r.has(s[l]))
418
- return `\`edges[${i}].${l}\` does not name an existing node.`;
419
- }
420
- }
421
- return null;
422
- }
423
- function Gs(n, e) {
424
- let r;
425
- try {
426
- r = JSON.parse(n);
427
- } catch (d) {
428
- return { ok: !1, error: Vs(n, d) };
429
- }
430
- if (!ae(r)) return { ok: !1, error: "The definition must be a JSON object." };
431
- const i = [];
432
- let s = r;
433
- const l = {};
434
- if (e) {
435
- for (const d of qs) {
436
- const y = Object.hasOwn(e, d), h = Object.hasOwn(s, d);
437
- if (!(y === h && JSON.stringify(e[d]) === JSON.stringify(s[d])))
438
- if (i.push(d), y)
439
- h ? s = { ...s, [d]: e[d] } : l[d] = e[d];
440
- else {
441
- const { [d]: m, ...j } = s;
442
- s = j;
443
- }
444
- }
445
- s = { ...l, ...s };
446
- }
447
- if (typeof s.id == "string" && !Lt.test(s.id))
448
- return { ok: !1, error: "Invalid workflow id." };
449
- const u = zs(s);
450
- return u !== null ? { ok: !1, error: u } : { ok: !0, text: i.length > 0 ? JSON.stringify(s, null, 2) : n, restored: i };
451
- }
452
- function Ys(n, e, r, i) {
453
- const s = {};
454
- for (const l of n) {
455
- const u = { code: l.code, connection: l.connection };
456
- s[l.siteId] = [...Object.hasOwn(s, l.siteId) ? s[l.siteId] : [], u];
457
- }
458
- for (const l of [e, r, i])
459
- for (const [u, d] of Object.entries(l ?? {}))
460
- d.length > 0 && (s[u] = [...Object.hasOwn(s, u) ? s[u] : [], ...d]);
461
- return s;
462
- }
463
- const Us = Nn(
464
- () => import("@w6w/ui/flow").then((n) => ({ default: n.WorkflowFlowEditor }))
465
- );
466
- function Xs(n) {
467
- var wt, St, kt, Nt, Et;
468
- const { workflowId: e, project: r, projectPending: i, initialRunId: s, onNavigate: l, slots: u } = n, d = Yn(), y = It(), [h, m] = v(null), [j, z] = v(!1), [de, I] = v(0), [C, D] = v(!1), [G, Y] = v(!1), [U, Ae] = v(!1), [X, Te] = v(void 0), je = S(!0), Oe = S(() => null), Mt = E(
469
- (t) => {
470
- const o = t;
471
- return Lt.test(typeof o.id == "string" ? o.id : "") ? At(X, o.key).reason : "Invalid workflow id.";
472
- },
473
- [X]
474
- ), f = Un({
475
- workflowId: e,
476
- project: r,
477
- autoSave: je.current,
478
- // The expression editor holds uncommitted parts in its own local state until its Save
479
- // button, so saving from under it would persist a workflow without the expression the user
480
- // is looking at. Read at fire time (opening it changes neither the buffer nor `canSave`).
481
- canAutoSave: () => !document.querySelector(".w6w-exprmodal"),
482
- saveGuard: Mt,
483
- publishBlockedReason: (t) => Oe.current(t)
484
- }), Ie = f.json, c = f.parsed, B = f.canSave, Jt = f.dirty;
485
- T(() => {
486
- if (f.loading || f.loadError !== null) {
487
- Te(void 0);
488
- return;
489
- }
490
- !f.dirty && c && Te(c.key ?? null);
491
- }, [f.loading, f.loadError, f.dirty, c]);
492
- const [Dt, fe] = v(!1);
493
- T(() => {
494
- f.stale || fe(!1);
495
- }, [f.stale]);
496
- const [Bt, Fe] = v(!1), Le = S(!1);
497
- T(() => {
498
- f.saving ? Fe(!1) : Le.current && f.error === null && Fe(!0), Le.current = f.saving;
499
- }, [f.saving, f.error]);
500
- const [O, N] = v(null), Me = Rn(), Je = Cn(), De = Pn(), P = An(O), K = (wt = P.data) == null ? void 0 : wt.status, Be = P.isError, Z = Tn(K, Be), Wt = jn(O, K), We = On(
501
- In(P.data),
502
- (St = Wt.data) == null ? void 0 : St.writes
503
- ), $e = Fn(P.data, We), pe = S(!1), [$t, xe] = v(!1);
504
- T(() => {
505
- N(null);
506
- }, [e]), T(() => {
507
- s && N(s);
508
- }, [e, s]), T(() => {
509
- P.data && P.data.workflowId !== e && N(null);
510
- }, [P.data, e]);
511
- async function Ke(t) {
512
- try {
513
- const o = await f.flushThen(t);
514
- !o.ok && o.outcome.status === "blocked" && m(o.outcome.reason);
515
- } catch (o) {
516
- m(o instanceof Ce ? o.message : String(o));
517
- }
518
- }
519
- async function xt() {
520
- if (!(!e || Z || pe.current)) {
521
- m(null), pe.current = !0, xe(!0);
522
- try {
523
- const t = b ? Dn(R, b.isManualTrigger, b.isEntryTrigger) : (Q == null ? void 0 : Q[0]) && { id: Q[0].id, manual: !0 };
524
- await vn();
525
- const o = await Bn(
526
- t == null ? void 0 : t.id,
527
- (p) => jt(d, e, p),
528
- () => Wn(d, e)
529
- );
530
- await Ke(
531
- () => t && !t.manual ? (
532
- // A webhook / schedule / app trigger entry runs FROM that trigger: the server takes
533
- // the payload as the event that fired it (its output and `trigger.event`), which a
534
- // plain run's `input` — the Manual trigger's slot — never reaches.
535
- Je.mutateAsync({
536
- id: e,
537
- nodeId: t.id,
538
- body: { stopAt: [], ...o ? { input: o } : {} }
539
- }).then((p) => N(p.runId))
540
- ) : Me.mutateAsync({
541
- id: e,
542
- variables: {},
543
- ...o ? { input: o } : {}
544
- }).then((p) => N(p.runId))
545
- );
546
- } finally {
547
- pe.current = !1, xe(!1);
548
- }
549
- }
550
- }
551
- async function Kt(t, o) {
552
- if (!e) return;
553
- m(null);
554
- const p = await f.flushThen(
555
- () => {
556
- var k;
557
- return Je.mutateAsync({
558
- id: e,
559
- nodeId: t,
560
- body: {
561
- stopAt: o.stopAt,
562
- ...(k = o.state) != null && k.steps ? { nodes: o.state.steps } : {},
563
- ...o.input ? { input: o.input } : {}
564
- }
565
- });
566
- }
567
- );
568
- if (!p.ok)
569
- throw new Error(
570
- p.outcome.status === "blocked" ? p.outcome.reason : "The workflow could not be saved, so it was not run."
571
- );
572
- N(p.value.runId);
573
- }
574
- function Qt() {
575
- O && (De.mutate(O, {
576
- onError: (t) => {
577
- const o = t instanceof Ce ? t.code : "";
578
- $n(o) === "surface" && m(t instanceof Ce ? t.message : String(t));
579
- }
580
- }), N(null));
581
- }
582
- async function _t() {
583
- Ae(!0);
584
- try {
585
- await f.reload(), I((t) => t + 1), m(null);
586
- } finally {
587
- Ae(!1);
588
- }
589
- }
590
- const ee = f.stale ? null : f.error ?? f.loadError, Qe = h ?? (ee === null ? null : ee instanceof Error ? ee.message : String(ee)), qt = c !== null && (Array.isArray(c.nodes) || Array.isArray(c.steps)), _e = (c == null ? void 0 : c.displayName) ?? "", he = Xn(c == null ? void 0 : c.settings), te = ls(c == null ? void 0 : c.initialState), Ht = w(() => cs(c == null ? void 0 : c.variables), [c == null ? void 0 : c.variables]), qe = At(X, c == null ? void 0 : c.key), He = c !== null && X !== void 0 && !qe.allowed ? qe.reason : null, R = w(
591
- () => Zn(c),
592
- [c]
593
- ), [b, Vt] = v(null);
594
- T(() => {
595
- let t = !1;
596
- return import("@w6w/ui/flow").then((o) => {
597
- t || Vt({
598
- internalNodes: o.INTERNAL_NODES,
599
- isInternalApp: o.isInternalApp,
600
- internalNodeParams: o.internalNodeParams,
601
- isManualTrigger: (p) => p === o.TRIGGER_APP,
602
- isEntryTrigger: o.isTriggerStep,
603
- asFieldDefs: o.asFieldDefs,
604
- findLoopProblems: o.findLoopProblems,
605
- findStateWriteProblems: o.findStateWriteProblems
606
- });
607
- }), () => {
608
- t = !0;
609
- };
610
- }, []);
611
- const Q = w(() => {
612
- if (b)
613
- return es(
614
- { steps: R },
615
- {
616
- isManualTrigger: b.isManualTrigger,
617
- asFieldDefs: b.asFieldDefs
618
- }
619
- );
620
- }, [b, R]), F = w(() => {
621
- if (!b) return [];
622
- const t = /* @__PURE__ */ new Set();
623
- for (const o of R) {
624
- const { app: p, action: k } = o.uses ?? {};
625
- p && k && !b.isInternalApp(p) && t.add(p);
626
- }
627
- return [...t];
628
- }, [b, R]), { byId: ne } = Kn(F), zt = w(() => [...ne.values()], [ne]), Ve = Re({
629
- queries: F.map((t) => ({
630
- queryKey: Cs(t),
631
- queryFn: () => y.getAppActions(t)
632
- }))
633
- }), ze = w(() => {
634
- var o, p;
635
- const t = {};
636
- if (!b) return t;
637
- for (const k of R) {
638
- const { app: A, action: x } = k.uses ?? {};
639
- if (!A || !x) continue;
640
- const Ne = `${A}::${x}`;
641
- if (!(Ne in t))
642
- if (b.isInternalApp(A))
643
- t[Ne] = b.internalNodeParams(A, x);
644
- else {
645
- const Rt = F.indexOf(A), Ee = Rt >= 0 ? (o = Ve[Rt]) == null ? void 0 : o.data : void 0;
646
- t[Ne] = ((p = Ee == null ? void 0 : Ee.find((dn) => dn.key === x)) == null ? void 0 : p.params) ?? [];
647
- }
648
- }
649
- return t;
650
- }, [b, R, F, Ve]), _ = w(() => {
651
- const t = {};
652
- for (const [o, p] of ne) t[o] = p;
653
- return t;
654
- }, [ne]), me = w(
655
- () => R.filter((t) => {
656
- var p;
657
- const o = (p = t.uses) == null ? void 0 : p.app;
658
- return !!o && o in _ && Ct(_[o]);
659
- }),
660
- [R, _]
661
- ), Ge = Re({
662
- queries: me.map((t) => ({
663
- queryKey: Pe(e, t.id),
664
- queryFn: () => jt(d, e, t.id),
665
- enabled: !!e
666
- }))
667
- }), Ye = w(() => {
668
- const t = {};
669
- return me.forEach((o, p) => {
670
- var k, A;
671
- t[o.id] = !!((A = (k = Ge[p]) == null ? void 0 : k.data) != null && A.some((x) => x.lastRunStatus === "succeeded"));
672
- }), t;
673
- }, [me, Ge]), q = bs("workflow", e, !!e), be = gs("workflow"), L = ((kt = q.data) == null ? void 0 : kt.currentPublishedVersion) ?? null, H = ys("workflow", e, L, !!e), Ue = H.data !== void 0 && c !== null && Ds(c, H.data.definition), M = q.data === void 0 ? void 0 : L === null ? "unpublished" : H.data === void 0 || f.loading ? void 0 : Ue ? "published" : "draft", [Gt, Xe] = v(!1), Yt = vs("workflow");
674
- async function Ze(t) {
675
- Xe(!0), m(null);
676
- try {
677
- await f.discardThen(() => Yt.mutateAsync({ id: e, versionNumber: t })), I((o) => o + 1), N(null);
678
- } finally {
679
- Xe(!1);
680
- }
681
- }
682
- const se = Ot(), et = S(null);
683
- T(() => {
684
- var t;
685
- if (!(!e || !O || et.current === O) && Ln(K, (t = P.data) == null ? void 0 : t.workflowId, e)) {
686
- et.current = O;
687
- for (const o of Mn)
688
- setTimeout(
689
- () => void se.invalidateQueries({ queryKey: ks(e) }),
690
- o
691
- );
692
- }
693
- }, [e, O, K, (Nt = P.data) == null ? void 0 : Nt.workflowId, se]);
694
- const tt = Re({
695
- queries: F.map((t) => ({
696
- queryKey: Tt(t),
697
- queryFn: () => ms(d, t)
698
- }))
699
- }), nt = w(() => {
700
- const t = /* @__PURE__ */ new Map();
701
- return F.forEach((o, p) => {
702
- const k = tt[p];
703
- k && (k.isError ? t.set(o, { state: "error" }) : k.isSuccess && !k.isFetching ? t.set(o, { state: "ready", ids: new Set((k.data ?? []).map((A) => A.id)) }) : t.set(o, { state: "loading" }));
704
- }), t;
705
- }, [F, tt]), W = w(
706
- () => ts(R, (t) => nt.get(t), c == null ? void 0 : c.connections),
707
- [R, nt, c == null ? void 0 : c.connections]
708
- ), st = Ns(r ?? void 0, r !== null), ot = Es(), it = ws(), rt = Rs(r ?? void 0), ge = w(() => {
709
- if (!c) return {};
710
- const t = (o) => ({
711
- names: (o.data ?? []).map((p) => p.name),
712
- ready: o.isSuccess
713
- });
714
- return ns({
715
- workflow: c,
716
- lists: {
717
- vars: t(st),
718
- secrets: t(ot),
719
- constants: t(it),
720
- stores: t(rt)
721
- }
722
- });
723
- }, [c, st, ot, it, rt]), at = w(() => {
724
- const t = {};
725
- for (const [o, p] of Object.entries(ge))
726
- t[o] = [{ code: "setup_incomplete", items: p }];
727
- return t;
728
- }, [ge]), Ut = w(
729
- () => Ys(
730
- W,
731
- b == null ? void 0 : b.findLoopProblems(c),
732
- c ? b == null ? void 0 : b.findStateWriteProblems(c) : void 0,
733
- at
734
- ),
735
- [W, b, c, at]
736
- ), lt = S(/* @__PURE__ */ new Set());
737
- T(() => {
738
- for (const t of W) {
739
- const o = `${t.app}|${t.connection}`;
740
- lt.current.has(o) || (lt.current.add(o), se.invalidateQueries({ queryKey: Tt(t.app) }));
741
- }
742
- }, [W, se]);
743
- const oe = S({ id: e, had: !1 });
744
- oe.current.id !== e && (oe.current = { id: e, had: !1 }), W.length > 0 && (oe.current.had = !0);
745
- const ct = Ss("workflow"), ye = ss({
746
- enabled: (Et = q.data) == null ? void 0 : Et.enabled,
747
- problemCount: W.length,
748
- dirty: f.dirty,
749
- hadProblems: oe.current.had
750
- }), ve = w(
751
- () => ({
752
- actionParamsByKey: ze,
753
- appsById: _,
754
- testStatus: Ye,
755
- requiredParamsFilled: gn,
756
- isTestRequired: Ct
757
- }),
758
- [ze, _, Ye]
759
- ), Xt = w(
760
- () => c !== null && b !== null ? os(c, ve) : [],
761
- [c, b, ve]
762
- ), [ut, dt] = v(!1), we = S(!1), V = is({
763
- projectMissing: r === null,
764
- loading: !B,
765
- saveBlockedReason: f.saveBlockedReason ?? (B && c === null ? "the workflow JSON does not parse." : null),
766
- catalogLoading: c !== null && b === null,
767
- problems: Xt,
768
- publishing: ut || be.isPending
769
- }) ?? (q.isPending || L !== null && H.isPending ? "Checking the published version…" : q.isError || L !== null && H.isError ? "Can't check the published version. Reload to try again." : Ue ? "Already published. Make a change before publishing again." : null);
770
- async function Se() {
771
- if (!(!e || V !== null || we.current)) {
772
- we.current = !0, dt(!0), m(null);
773
- try {
774
- await Ke(() => be.mutateAsync(e));
775
- } finally {
776
- we.current = !1, dt(!1);
777
- }
778
- }
779
- }
780
- Oe.current = (t) => t !== null && typeof t == "object" ? rs(t, ve) : null, je.current = he.autoSave;
781
- const Zt = E(
782
- (t) => Gs(t, re.current),
783
- []
784
- );
785
- function ie(t) {
786
- if (!c) return;
787
- const o = { ...c, ...t };
788
- f.setJson(JSON.stringify(o, null, 2));
789
- }
790
- function ft(t) {
791
- if (!c) return;
792
- const o = { ...c, ...t };
793
- m(null), f.commit(JSON.stringify(o, null, 2));
794
- }
795
- const re = S(c);
796
- re.current = c;
797
- const pt = S(f.commit);
798
- pt.current = f.commit;
799
- const ht = S(f.saveNow);
800
- ht.current = f.saveNow, T(() => {
801
- const t = (o) => {
802
- o.altKey || !(o.metaKey || o.ctrlKey) || o.key.toLowerCase() !== "s" || (o.preventDefault(), !document.querySelector(".w6w-exprmodal") && B && ht.current());
803
- };
804
- return document.addEventListener("keydown", t), () => {
805
- document.removeEventListener("keydown", t);
806
- };
807
- }, [B]);
808
- const en = w(
809
- () => c ? ds(c) : {},
810
- [c]
811
- ), tn = E((t) => {
812
- const o = re.current;
813
- if (!o) return;
814
- const p = fs(o, t);
815
- m(null), pt.current(JSON.stringify(p, null, 2));
816
- }, []), nn = E(() => Y(!0), []), mt = S(() => {
817
- });
818
- mt.current = (t) => {
819
- N(t), l({ type: "run", id: e, runId: t });
820
- };
821
- const bt = E((t) => mt.current(t), []), gt = S(Ze);
822
- gt.current = Ze;
823
- const sn = E((t) => gt.current(t), []), yt = S(Se);
824
- yt.current = Se;
825
- const on = E(() => yt.current(), []), ke = S({ saveMeta: ft, patchMeta: ie });
826
- ke.current = { saveMeta: ft, patchMeta: ie };
827
- const rn = E(
828
- (t, o) => {
829
- var p;
830
- ke.current.saveMeta({
831
- settings: as((p = re.current) == null ? void 0 : p.settings, t, o)
832
- });
833
- },
834
- []
835
- ), an = E((t) => {
836
- ke.current.patchMeta({ variables: us(t) });
837
- }, []), [$, ln] = v(null), vt = S($);
838
- vt.current = $;
839
- const cn = E(
840
- (t) => {
841
- var o;
842
- (o = vt.current) == null || o.edit(t);
843
- },
844
- []
845
- ), un = E(() => D(!0), []);
846
- return Gn({
847
- kind: "workflow",
848
- id: e,
849
- connectionResources: ($ == null ? void 0 : $.workflowId) === e ? { ...$, edit: cn } : void 0,
850
- label: _e,
851
- key: (c == null ? void 0 : c.key) ?? void 0,
852
- triggers: Q,
853
- onRestoreVersion: sn,
854
- definitionStatus: M,
855
- onPublish: on,
856
- publishDisabled: V !== null,
857
- policy: en,
858
- onPolicyChange: tn,
859
- hasStartingState: te !== void 0 && Object.keys(te).length > 0,
860
- startingState: te,
861
- onOpenStartingState: nn,
862
- onOpenRun: bt,
863
- authoringSettings: { autoSave: he.autoSave, savePosition: he.savePosition },
864
- onAuthoringSettingChange: rn,
865
- variables: Ht,
866
- onVariablesChange: an,
867
- onOpenHistory: un
868
- }), /* @__PURE__ */ g("div", { className: "wf-fullbleed", style: { height: "100%", minWidth: 0, flex: 1 }, children: [
869
- (u == null ? void 0 : u.header) ?? /* @__PURE__ */ a(
870
- js,
871
- {
872
- onBack: () => l({ type: "list" }),
873
- backLabel: (u == null ? void 0 : u.backLabel) === null ? null : (u == null ? void 0 : u.backLabel) ?? "← Workflows",
874
- title: {
875
- editable: !0,
876
- value: _e,
877
- placeholder: _s,
878
- maxLength: 80,
879
- ariaLabel: "Workflow name",
880
- onChange: (t) => ie({ displayName: t }),
881
- onBlur: () => {
882
- B && f.saveNow();
883
- }
884
- },
885
- titleAdornment: M && /* @__PURE__ */ a(
886
- "span",
887
- {
888
- className: `badge wf-definition-status ${M}`,
889
- "data-testid": "wf-definition-status",
890
- "aria-live": "polite",
891
- title: M === "published" ? "This workflow matches the published version. Edits create a separate draft." : M === "draft" ? "You are editing a draft. The published version stays unchanged until you publish." : "You are editing a draft. This workflow has not been published.",
892
- children: M === "published" ? "Live" : "Draft"
893
- }
894
- ),
895
- actions: /* @__PURE__ */ g(le, { children: [
896
- /* @__PURE__ */ a(
897
- ce,
898
- {
899
- icon: "play",
900
- label: Jn(K, Be),
901
- "data-testid": "wf-run-start",
902
- onClick: xt,
903
- disabled: !e || Z || $t || Me.isPending
904
- }
905
- ),
906
- Z && /* @__PURE__ */ a(
907
- ce,
908
- {
909
- icon: "stop",
910
- label: "Stop this run",
911
- "data-testid": "wf-run-stop",
912
- onClick: Qt,
913
- disabled: De.isPending
914
- }
915
- ),
916
- /* @__PURE__ */ a(
917
- $s,
918
- {
919
- disabled: V !== null,
920
- message: V ?? (L !== null ? "Republish this draft as a new live version" : "Publish this draft as a new live version"),
921
- children: (t) => /* @__PURE__ */ a(le, { children: /* @__PURE__ */ a(
922
- "button",
923
- {
924
- type: "button",
925
- className: "btn ghost wf-publish",
926
- "data-testid": "wf-publish",
927
- onClick: () => void Se(),
928
- disabled: V !== null,
929
- "aria-describedby": t,
930
- children: ut || be.isPending ? L !== null ? "Republishing…" : "Publishing…" : L !== null ? M === "draft" ? "Republish" : "Published" : "Publish"
931
- }
932
- ) })
933
- }
934
- ),
935
- /* @__PURE__ */ a(Fs, { onClick: () => z(!0) }),
936
- u == null ? void 0 : u.headerActions
937
- ] })
938
- }
939
- ),
940
- /* @__PURE__ */ a(xs, { problems: ge }),
941
- ye.show && /* @__PURE__ */ a(
942
- Bs,
943
- {
944
- kind: "workflow",
945
- problemCount: ye.problemCount,
946
- canEnable: ye.canEnable,
947
- pending: ct.isPending,
948
- onEnable: () => ct.mutate({ id: e, enabled: !0 })
949
- }
950
- ),
951
- /* @__PURE__ */ a("div", { className: "wf-fullbleed-canvas", children: /* @__PURE__ */ g("div", { className: "wf-run-area", children: [
952
- /* @__PURE__ */ a("div", { className: "wf-run-canvas", children: /* @__PURE__ */ a(kn, { fallback: /* @__PURE__ */ a("p", { className: "muted", children: "Loading visual editor…" }), children: qt && c ? /* @__PURE__ */ a(
953
- Us,
954
- {
955
- onConnectionResourcesChange: ln,
956
- value: c,
957
- onChange: (t, o) => {
958
- f.setJson(JSON.stringify(t, null, 2)), o != null && o.viewportOnly || N(null);
959
- },
960
- apps: zt,
961
- project: r ?? void 0,
962
- height: "100%",
963
- readOnly: Z,
964
- stepProblems: Ut,
965
- runState: P.data,
966
- onTestRun: () => N(null),
967
- onRunFromNode: Kt
968
- },
969
- de
970
- ) : Ie === "" ? /* @__PURE__ */ a("p", { className: "muted", children: "Loading…" }) : /* @__PURE__ */ a("p", { className: "muted", children: "Fix the JSON to render the visual editor." }) }) }),
971
- O && /* @__PURE__ */ a("div", { className: "wf-run-log", "data-testid": "wf-run-log", children: /* @__PURE__ */ a(
972
- yn,
973
- {
974
- steps: We,
975
- runError: $e.runError,
976
- stepErrors: $e.stepErrors,
977
- onDismiss: () => N(null)
978
- }
979
- ) })
980
- ] }) }),
981
- r === null && !i && /* @__PURE__ */ g("div", { role: "alert", className: "error", "data-testid": "wf-project-required", children: [
982
- "No project selected — pass a ",
983
- /* @__PURE__ */ a("code", { children: "project" }),
984
- " prop (or set the provider's project) to edit and save this workflow."
985
- ] }),
986
- /* @__PURE__ */ g("div", { className: "wf-fullbleed-foot", children: [
987
- /* @__PURE__ */ g("div", { className: "row", style: { flexWrap: "wrap", alignItems: "center" }, children: [
988
- /* @__PURE__ */ a(
989
- "button",
990
- {
991
- type: "button",
992
- className: "btn",
993
- disabled: r === null || !B || !Jt,
994
- onClick: f.saveNow,
995
- children: f.saving ? "Saving…" : "Save"
996
- }
997
- ),
998
- Bt && /* @__PURE__ */ a("span", { className: "ok", children: "Saved." })
999
- ] }),
1000
- Qe && /* @__PURE__ */ a("div", { className: "error", children: Qe }),
1001
- He && /* @__PURE__ */ a("div", { className: "error", "data-testid": "wf-key-guard", children: He })
1002
- ] }),
1003
- Gt && /* @__PURE__ */ a(ue, { title: "Restoring version…", onClose: () => {
1004
- }, children: /* @__PURE__ */ a("div", { className: "modal-body", children: "Replacing the draft…" }) }),
1005
- /* @__PURE__ */ a(
1006
- Ls,
1007
- {
1008
- open: j,
1009
- onClose: () => z(!1),
1010
- title: `JSON — ${(c == null ? void 0 : c.displayName) || "workflow"}`,
1011
- mode: "apply",
1012
- value: Ie,
1013
- prepareApply: Zt,
1014
- onApply: (t) => {
1015
- f.setJson(t), I((o) => o + 1), N(null);
1016
- },
1017
- editorLabel: "Workflow definition JSON"
1018
- }
1019
- ),
1020
- f.stale && !Dt && /* @__PURE__ */ g(ue, { title: "This workflow changed on the server", onClose: () => fe(!0), children: [
1021
- /* @__PURE__ */ g("div", { className: "modal-body", children: [
1022
- /* @__PURE__ */ a("p", { className: "muted small", children: "Someone else — another tab, another session — saved this workflow after you opened it. Your save was refused rather than applied, so their work is still intact." }),
1023
- /* @__PURE__ */ g("p", { className: "muted small", children: [
1024
- /* @__PURE__ */ a("strong", { children: "Reload from server" }),
1025
- " replaces what is on this canvas with the saved copy; anything you changed here and have not saved is lost.",
1026
- " ",
1027
- /* @__PURE__ */ a("strong", { children: "Keep editing" }),
1028
- " leaves your version exactly as it is — but every save will be refused the same way until you reload, so copy out anything you need first."
1029
- ] })
1030
- ] }),
1031
- /* @__PURE__ */ g("div", { className: "modal-actions", children: [
1032
- /* @__PURE__ */ a("button", { type: "button", className: "btn ghost", onClick: () => fe(!0), children: "Keep editing" }),
1033
- /* @__PURE__ */ a("button", { type: "button", className: "btn", disabled: U, onClick: _t, children: U ? "Reloading…" : "Reload from server" })
1034
- ] })
1035
- ] }),
1036
- C && /* @__PURE__ */ a(
1037
- Is,
1038
- {
1039
- kind: "workflow",
1040
- id: e,
1041
- onClose: () => D(!1),
1042
- onOpenRun: bt
1043
- }
1044
- ),
1045
- G && /* @__PURE__ */ a(
1046
- Qs,
1047
- {
1048
- initialState: te,
1049
- onChange: (t) => ie({ initialState: t }),
1050
- onClose: () => Y(!1)
1051
- }
1052
- )
1053
- ] });
1054
- }
1055
- function Zs({
1056
- children: n,
1057
- callableHref: e
1058
- }) {
1059
- const r = It(), i = Ot(), s = Sn(Ps), l = w(() => ({
1060
- ...r,
1061
- saveStepTest: (...y) => r.saveStepTest(...y).finally(() => {
1062
- i.invalidateQueries({ queryKey: Pe(y[0], y[1]) });
1063
- }),
1064
- recordStepTestRun: (...y) => r.recordStepTestRun(...y).finally(() => {
1065
- i.invalidateQueries({ queryKey: Pe(y[0], y[1]) });
1066
- }),
1067
- callableHref: e ?? r.callableHref
1068
- }), [r, i, e]);
1069
- return /* @__PURE__ */ a(bn, { api: l, theme: s, children: n });
1070
- }
1071
- const eo = () => {
1072
- };
1073
- function Po(n) {
1074
- const { workflowId: e, initialRunId: r, onNavigate: i = eo, slots: s } = n, l = ps(n.project), u = hs().status, d = n.project === void 0 && u === "resolving", y = E(
1075
- (h) => {
1076
- h.type === "list" ? i({ type: "list" }) : h.kind === "workflow" && i({ type: "workflow", id: h.id });
1077
- },
1078
- [i]
1079
- );
1080
- return /* @__PURE__ */ a(
1081
- "div",
1082
- {
1083
- className: "w6w-embed-root",
1084
- style: { display: "flex", width: "100%", height: "100%", minHeight: 0 },
1085
- children: /* @__PURE__ */ a(
1086
- Ws,
1087
- {
1088
- project: l,
1089
- onNavigate: y,
1090
- rail: n.rail,
1091
- storageKey: l === null ? null : `w6w.rail.embed.${l}`,
1092
- children: /* @__PURE__ */ a(Zs, { callableHref: n.callableHref, children: /* @__PURE__ */ a(
1093
- Xs,
1094
- {
1095
- workflowId: e,
1096
- project: l,
1097
- projectPending: d,
1098
- initialRunId: r,
1099
- onNavigate: i,
1100
- slots: s
1101
- }
1102
- ) })
1103
- }
1104
- )
1105
- }
1106
- );
1107
- }
1108
- export {
1109
- Bs as B,
1110
- js as E,
1111
- Is as H,
1112
- Ls as J,
1113
- Po as W,
1114
- Ws as a,
1115
- Fs as b
1116
- };
1117
- //# sourceMappingURL=WorkflowEditor-CBUwh85L.js.map