@w6w/embed 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +231 -4
  2. package/dist/ConfirmModal-RLbZT5_k.js +181 -0
  3. package/dist/ConfirmModal-RLbZT5_k.js.map +1 -0
  4. package/dist/CreateFunctionModal-DRsFx-FB.js +221 -0
  5. package/dist/CreateFunctionModal-DRsFx-FB.js.map +1 -0
  6. package/dist/DocumentFormModal-BExK1V-B.js +89 -0
  7. package/dist/DocumentFormModal-BExK1V-B.js.map +1 -0
  8. package/dist/ImportSpecModal-BDQIf6rg.js +136 -0
  9. package/dist/ImportSpecModal-BDQIf6rg.js.map +1 -0
  10. package/dist/W6WEmbedProvider.d.ts +22 -4
  11. package/dist/WorkflowEditor-DlbVv6Fs.js +854 -0
  12. package/dist/WorkflowEditor-DlbVv6Fs.js.map +1 -0
  13. package/dist/api-calls--JHyif6a.js +107 -0
  14. package/dist/api-calls--JHyif6a.js.map +1 -0
  15. package/dist/apps-1FNUwbGv.js +77 -0
  16. package/dist/apps-1FNUwbGv.js.map +1 -0
  17. package/dist/callables-3mFrMVG_.js +151 -0
  18. package/dist/callables-3mFrMVG_.js.map +1 -0
  19. package/dist/chrome/index.d.ts +6 -0
  20. package/dist/chrome/workspace.d.ts +29 -1
  21. package/dist/coerce-input-BicYr7nc.js +139 -0
  22. package/dist/coerce-input-BicYr7nc.js.map +1 -0
  23. package/dist/connections-CjjYeRqb.js +78 -0
  24. package/dist/connections-CjjYeRqb.js.map +1 -0
  25. package/dist/document-sources-C0grrtdq.js +86 -0
  26. package/dist/document-sources-C0grrtdq.js.map +1 -0
  27. package/dist/draft/index.d.ts +3 -1
  28. package/dist/draft/use-callable-draft.d.ts +65 -0
  29. package/dist/draft/workflow-save.d.ts +3 -0
  30. package/dist/draft.mjs +9 -5
  31. package/dist/draft.mjs.map +1 -1
  32. package/dist/editor/CallableEditorFrame.d.ts +33 -0
  33. package/dist/editor/EditorShell.d.ts +16 -0
  34. package/dist/editor/EndpointCards.d.ts +56 -0
  35. package/dist/editor/EndpointEditor.d.ts +26 -0
  36. package/dist/editor/FunctionEditor.d.ts +21 -0
  37. package/dist/editor/InputListEditor.d.ts +29 -0
  38. package/dist/editor/TargetSelector.d.ts +30 -0
  39. package/dist/editor/TargetSelector.types.d.ts +62 -0
  40. package/dist/editor/editor-apps.d.ts +8 -2
  41. package/dist/editor/types.d.ts +57 -0
  42. package/dist/editor-apps-BdenSV1o.js +95 -0
  43. package/dist/editor-apps-BdenSV1o.js.map +1 -0
  44. package/dist/editor-tools-RxmY5iyi.js +1279 -0
  45. package/dist/editor-tools-RxmY5iyi.js.map +1 -0
  46. package/dist/editor.mjs +2 -2166
  47. package/dist/editor.mjs.map +1 -1
  48. package/dist/editors/DocumentEditor.d.ts +20 -0
  49. package/dist/editors/doc-format.d.ts +3 -0
  50. package/dist/editors.d.ts +12 -0
  51. package/dist/editors.mjs +1313 -0
  52. package/dist/editors.mjs.map +1 -0
  53. package/dist/embed-status.d.ts +20 -0
  54. package/dist/endpoints-B2ynbZo-.js +227 -0
  55. package/dist/endpoints-B2ynbZo-.js.map +1 -0
  56. package/dist/forms/CreateEndpointModal.d.ts +54 -0
  57. package/dist/forms/CreateFunctionModal.d.ts +55 -0
  58. package/dist/forms/DocumentFormModal.d.ts +8 -0
  59. package/dist/forms/SecretsManager.d.ts +12 -0
  60. package/dist/forms/VarsManager.d.ts +29 -0
  61. package/dist/forms.d.ts +6 -0
  62. package/dist/forms.mjs +407 -0
  63. package/dist/forms.mjs.map +1 -0
  64. package/dist/index.d.ts +3 -1
  65. package/dist/index.mjs +153 -50
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/lib/callable-record.d.ts +21 -0
  68. package/dist/lib/coerce-input.d.ts +6 -0
  69. package/dist/lib/endpoint-editor.d.ts +23 -0
  70. package/dist/lib/index.d.ts +7 -0
  71. package/dist/lib/input-coverage.d.ts +28 -0
  72. package/dist/lib/input-seeding.d.ts +67 -0
  73. package/dist/lib/rail-settings.d.ts +3 -3
  74. package/dist/lib/recent-activity.d.ts +128 -0
  75. package/dist/lib/target-fields.d.ts +168 -0
  76. package/dist/lib/workflow-blank.d.ts +2 -0
  77. package/dist/lib.mjs +70 -48
  78. package/dist/lib.mjs.map +1 -1
  79. package/dist/lists/ActivitySummary.d.ts +29 -0
  80. package/dist/lists/CallableKindList.d.ts +34 -0
  81. package/dist/lists/ConnectionDetail.d.ts +17 -0
  82. package/dist/lists/ConnectionList.d.ts +16 -0
  83. package/dist/lists/DocumentList.d.ts +29 -0
  84. package/dist/lists/EndpointList.d.ts +19 -0
  85. package/dist/lists/FunctionList.d.ts +18 -0
  86. package/dist/lists/ReliabilityBoard.d.ts +23 -0
  87. package/dist/lists/RunHistory.d.ts +11 -0
  88. package/dist/lists/ServiceDetail.d.ts +20 -0
  89. package/dist/lists/WorkflowList.d.ts +19 -0
  90. package/dist/lists/vendor-history.d.ts +40 -0
  91. package/dist/lists.d.ts +20 -0
  92. package/dist/lists.mjs +1185 -0
  93. package/dist/lists.mjs.map +1 -0
  94. package/dist/project-context-BiCjv_E3.js +25 -0
  95. package/dist/project-context-BiCjv_E3.js.map +1 -0
  96. package/dist/project-context.d.ts +15 -1
  97. package/dist/rail/CallableRail.d.ts +12 -0
  98. package/dist/rail/CallableWorkspace.d.ts +16 -0
  99. package/dist/rail/SettingsTool.d.ts +7 -1
  100. package/dist/rail/settings-sections.d.ts +2 -2
  101. package/dist/rail-settings-XYGToh00.js +111 -0
  102. package/dist/rail-settings-XYGToh00.js.map +1 -0
  103. package/dist/rail.d.ts +11 -0
  104. package/dist/rail.mjs +35 -0
  105. package/dist/rail.mjs.map +1 -0
  106. package/dist/repos/api-calls.d.ts +4 -0
  107. package/dist/repos/apps.d.ts +14 -0
  108. package/dist/repos/callables.d.ts +91 -0
  109. package/dist/repos/connections.d.ts +33 -0
  110. package/dist/repos/dashboard.d.ts +4 -0
  111. package/dist/repos/endpoints.d.ts +125 -0
  112. package/dist/repos/functions.d.ts +79 -0
  113. package/dist/repos/index.d.ts +10 -0
  114. package/dist/repos/reliability.d.ts +42 -0
  115. package/dist/repos/saved-tests.d.ts +46 -0
  116. package/dist/repos/spec-export.d.ts +23 -0
  117. package/dist/repos/workflows.d.ts +138 -0
  118. package/dist/repos.mjs +174 -88
  119. package/dist/repos.mjs.map +1 -1
  120. package/dist/settings-rail--GdRMusb.js +33 -0
  121. package/dist/settings-rail--GdRMusb.js.map +1 -0
  122. package/dist/slug-C4ktDPdy.js +315 -0
  123. package/dist/slug-C4ktDPdy.js.map +1 -0
  124. package/dist/spec-export-Cf3VQSQS.js +176 -0
  125. package/dist/spec-export-Cf3VQSQS.js.map +1 -0
  126. package/dist/spec-import-CjmxyZDR.js +465 -0
  127. package/dist/spec-import-CjmxyZDR.js.map +1 -0
  128. package/dist/step-tests-CivICmTq.js +18 -0
  129. package/dist/step-tests-CivICmTq.js.map +1 -0
  130. package/dist/trigger-preview-VPkrryDl.js +120 -0
  131. package/dist/trigger-preview-VPkrryDl.js.map +1 -0
  132. package/dist/use-callable-draft-zHLpcr-b.js +271 -0
  133. package/dist/use-callable-draft-zHLpcr-b.js.map +1 -0
  134. package/dist/{use-workflow-draft-oI02dsP-.js → use-workflow-draft-DzAyUeA6.js} +48 -46
  135. package/dist/use-workflow-draft-DzAyUeA6.js.map +1 -0
  136. package/dist/vault-BSEWhMYC.js +117 -0
  137. package/dist/vault-BSEWhMYC.js.map +1 -0
  138. package/dist/workflow-blank-DyL3_RUA.js +14 -0
  139. package/dist/workflow-blank-DyL3_RUA.js.map +1 -0
  140. package/package.json +21 -5
  141. package/src/styles.css +408 -1
  142. package/dist/project-context-Dbk0Gr1K.js +0 -16
  143. package/dist/project-context-Dbk0Gr1K.js.map +0 -1
  144. package/dist/slug-ByKQgxrf.js +0 -642
  145. package/dist/slug-ByKQgxrf.js.map +0 -1
  146. package/dist/spec-import-HgO7ZkLZ.js +0 -898
  147. package/dist/spec-import-HgO7ZkLZ.js.map +0 -1
  148. package/dist/use-workflow-draft-oI02dsP-.js.map +0 -1
@@ -0,0 +1,854 @@
1
+ var ut = Object.defineProperty;
2
+ var ht = (r, a, o) => a in r ? ut(r, a, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[a] = o;
3
+ var He = (r, a, o) => ht(r, typeof a != "symbol" ? a + "" : a, o);
4
+ import { jsxs as c, jsx as e, Fragment as W } from "react/jsx-runtime";
5
+ import { useQueries as Be } from "@tanstack/react-query";
6
+ import { ApiError as ne } from "@w6w/sdk";
7
+ import { Modal as ft, IconButton as F, JsonEditor as pt, useExpressionOptions as mt, ExpressionOptionsProvider as vt, ExpressionInput as yt, useW6WApi as gt, isTestRequired as Je, requiredParamsFilled as bt, ExecutionLogPanel as wt } from "@w6w/ui";
8
+ import { useState as g, Component as kt, useRef as I, useEffect as x, useCallback as ae, useMemo as k, Suspense as Nt, lazy as St } from "react";
9
+ import { f as Ct, a as Et } from "./apps-1FNUwbGv.js";
10
+ import { E as Rt, U as Pt, F as xt, O as It, o as At, r as Lt, v as Ft, u as Tt, t as Ot, a as Vt } from "./spec-import-CjmxyZDR.js";
11
+ import { H as Wt, a as Dt } from "./editor-apps-BdenSV1o.js";
12
+ import { M as se } from "./ConfirmModal-RLbZT5_k.js";
13
+ import { d as Mt, W as Kt, e as jt, R as Ht, P as Bt, b as Jt, c as $t } from "./editor-tools-RxmY5iyi.js";
14
+ import { u as qt } from "./client-context-CX61Bgw-.js";
15
+ import { u as _t } from "./use-workflow-draft-DzAyUeA6.js";
16
+ import { d as Qt, g as Gt, r as zt, b as Yt, f as Ut, w as Zt, i as $e, v as Xt, h as en } from "./trigger-preview-VPkrryDl.js";
17
+ import { w as qe } from "./rail-settings-XYGToh00.js";
18
+ import { p as tn, d as nn } from "./settings-rail--GdRMusb.js";
19
+ import { u as an } from "./project-context-BiCjv_E3.js";
20
+ import { f as sn, a as on } from "./spec-export-Cf3VQSQS.js";
21
+ import { l as _e, a as rn } from "./step-tests-CivICmTq.js";
22
+ function ln({ title: r }) {
23
+ const { value: a, placeholder: o, maxLength: l, ariaLabel: u, onChange: d, onBlur: m } = r;
24
+ return /* @__PURE__ */ e(
25
+ "input",
26
+ {
27
+ className: "wf-title-input",
28
+ value: a,
29
+ placeholder: o,
30
+ maxLength: l,
31
+ size: Math.min(Math.max(a.length, o.length), 80),
32
+ "aria-label": u,
33
+ onChange: (f) => d(f.target.value),
34
+ onBlur: m
35
+ }
36
+ );
37
+ }
38
+ function cn({
39
+ onBack: r,
40
+ backLabel: a,
41
+ title: o,
42
+ titleAdornment: l,
43
+ actions: u
44
+ }) {
45
+ return /* @__PURE__ */ c("div", { className: "wf-fullbleed-head", children: [
46
+ /* @__PURE__ */ e(
47
+ "button",
48
+ {
49
+ type: "button",
50
+ className: "muted wf-back-btn",
51
+ "data-testid": "wf-editor-back",
52
+ onClick: r,
53
+ children: a
54
+ }
55
+ ),
56
+ o.editable ? /* @__PURE__ */ e(ln, { title: o }) : /* @__PURE__ */ c("h2", { className: "exec-profile-title", children: [
57
+ o.value,
58
+ " ",
59
+ l
60
+ ] }),
61
+ /* @__PURE__ */ e("div", { className: "wf-head-actions", style: { marginLeft: "auto" }, children: u })
62
+ ] });
63
+ }
64
+ function dn(r, a, o) {
65
+ if (!(r !== "workflow" || a === void 0))
66
+ return (l) => {
67
+ o(), a(l.id);
68
+ };
69
+ }
70
+ function un(r) {
71
+ const { kind: a, id: o, onClose: l, onOpenRun: u } = r, [d, m] = g(Rt), f = dn(a, u, l);
72
+ return /* @__PURE__ */ e(
73
+ ft,
74
+ {
75
+ size: "full",
76
+ title: "History",
77
+ subtitle: o,
78
+ onClose: l,
79
+ headerRight: /* @__PURE__ */ e(F, { icon: "close", label: "Close", onClick: l }),
80
+ children: /* @__PURE__ */ e("div", { className: "w6w-modal-body", children: /* @__PURE__ */ e(
81
+ Wt,
82
+ {
83
+ scope: { callable: o },
84
+ showKind: !1,
85
+ filters: d,
86
+ onFiltersChange: m,
87
+ onOpenInEditor: f
88
+ }
89
+ ) })
90
+ }
91
+ );
92
+ }
93
+ function Qe({
94
+ hasExecuted: r,
95
+ onClick: a,
96
+ buttonRef: o
97
+ }) {
98
+ return /* @__PURE__ */ e(
99
+ F,
100
+ {
101
+ ref: o,
102
+ icon: "history",
103
+ "data-testid": "history-button",
104
+ label: "Execution history",
105
+ title: r ? "Execution history" : "No executions yet",
106
+ disabled: !r,
107
+ onClick: a
108
+ }
109
+ );
110
+ }
111
+ function hn({ kind: r, id: a, onOpenRun: o }) {
112
+ const { hasExecuted: l } = Ct(a), [u, d] = g(!1), m = I(null), f = I(!1);
113
+ return x(() => {
114
+ var N;
115
+ f.current && !u && ((N = m.current) == null || N.focus()), f.current = u;
116
+ }, [u]), /* @__PURE__ */ c(W, { children: [
117
+ /* @__PURE__ */ e(
118
+ Qe,
119
+ {
120
+ hasExecuted: l,
121
+ buttonRef: m,
122
+ onClick: () => d(!0)
123
+ }
124
+ ),
125
+ u && /* @__PURE__ */ e(un, { kind: r, id: a, onClose: () => d(!1), onOpenRun: o })
126
+ ] });
127
+ }
128
+ class fn extends kt {
129
+ constructor() {
130
+ super(...arguments);
131
+ He(this, "state", { failed: !1 });
132
+ }
133
+ static getDerivedStateFromError() {
134
+ return { failed: !0 };
135
+ }
136
+ componentDidCatch(o) {
137
+ console.error("history probe answer was unreadable; disabling the button", o);
138
+ }
139
+ render() {
140
+ return this.state.failed ? /* @__PURE__ */ e(Qe, { hasExecuted: !1, onClick: () => {
141
+ } }) : this.props.children;
142
+ }
143
+ }
144
+ function pn(r) {
145
+ return /* @__PURE__ */ e(fn, { children: /* @__PURE__ */ e(hn, { ...r }) });
146
+ }
147
+ function mn(r) {
148
+ return /* @__PURE__ */ e(F, { icon: "json", onClick: r.onClick, label: "Edit raw JSON definition" });
149
+ }
150
+ function vn(r) {
151
+ const {
152
+ open: a,
153
+ onClose: o,
154
+ title: l,
155
+ mode: u,
156
+ value: d,
157
+ onChange: m,
158
+ onValidityChange: f,
159
+ invalidReason: N,
160
+ guard: C,
161
+ onSave: D,
162
+ saving: S,
163
+ error: T,
164
+ editorLabel: w
165
+ } = r;
166
+ if (!a) return null;
167
+ const v = (C == null ? void 0 : C(d)) ?? null;
168
+ return /* @__PURE__ */ c(se, { title: l, onClose: o, wide: !0, children: [
169
+ /* @__PURE__ */ c("div", { className: "modal-body", children: [
170
+ /* @__PURE__ */ e("p", { className: "muted small", children: u === "synced" ? /* @__PURE__ */ c(W, { children: [
171
+ "Edit the raw definition (",
172
+ /* @__PURE__ */ e("code", { children: 'manifestVersion: "2"' }),
173
+ "). Changes sync live to the visual editor."
174
+ ] }) : "Save replaces the stored definition." }),
175
+ /* @__PURE__ */ e(
176
+ pt,
177
+ {
178
+ value: d,
179
+ onChange: m,
180
+ onValidityChange: ({ valid: y, error: p }) => f == null ? void 0 : f({ valid: y, error: p ?? null }),
181
+ minHeight: "420px",
182
+ "aria-label": w
183
+ }
184
+ ),
185
+ v && /* @__PURE__ */ e("p", { className: "muted small", "data-testid": "json-toggle-reason", children: v }),
186
+ N && /* @__PURE__ */ c("div", { className: "muted small", children: [
187
+ "Invalid JSON — ",
188
+ N
189
+ ] }),
190
+ T && /* @__PURE__ */ e("div", { className: "error", children: T })
191
+ ] }),
192
+ /* @__PURE__ */ e("div", { className: "modal-actions", children: u === "synced" ? /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: o, children: "Done" }) : /* @__PURE__ */ c(W, { children: [
193
+ /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: o, children: "Cancel" }),
194
+ /* @__PURE__ */ e(
195
+ "button",
196
+ {
197
+ type: "button",
198
+ className: "btn",
199
+ "data-testid": "json-toggle-save",
200
+ disabled: v != null || !!S,
201
+ onClick: D,
202
+ children: S ? "Saving…" : "Save"
203
+ }
204
+ )
205
+ ] }) })
206
+ ] });
207
+ }
208
+ function yn({
209
+ project: r,
210
+ onNavigate: a,
211
+ rail: o = !0,
212
+ storageKey: l,
213
+ tools: u = jt,
214
+ children: d
215
+ }) {
216
+ const m = Mt(), f = /* @__PURE__ */ e(Ht, { project: r, onNavigate: a, children: /* @__PURE__ */ c(Bt, { project: r, children: [
217
+ d,
218
+ o && /* @__PURE__ */ e(Jt, { tools: u, storageKey: l })
219
+ ] }) });
220
+ return o || !m ? /* @__PURE__ */ e(Kt, { children: f }) : f;
221
+ }
222
+ const gn = ["string", "number", "boolean", "object", "array"];
223
+ function bn(r) {
224
+ const { autoSave: a, savePosition: o, variables: l, onClose: u, onChange: d, onVariablesChange: m } = r, f = mt().vars ?? [], [N, C] = g("general");
225
+ function D() {
226
+ m([...l, { key: "" }]);
227
+ }
228
+ function S(v, y) {
229
+ m(l.map((p, j) => j === v ? { ...p, ...y } : p));
230
+ }
231
+ function T(v) {
232
+ m(l.filter((y, p) => p !== v));
233
+ }
234
+ const w = Qt(l);
235
+ return /* @__PURE__ */ c(se, { title: "Workflow settings", onClose: u, wide: !0, children: [
236
+ /* @__PURE__ */ c("div", { className: "w6w-subtabs", children: [
237
+ /* @__PURE__ */ e(
238
+ "button",
239
+ {
240
+ type: "button",
241
+ className: `w6w-subtab${N === "general" ? " active" : ""}`,
242
+ onClick: () => C("general"),
243
+ children: "General"
244
+ }
245
+ ),
246
+ /* @__PURE__ */ e(
247
+ "button",
248
+ {
249
+ type: "button",
250
+ className: `w6w-subtab${N === "variables" ? " active" : ""}`,
251
+ onClick: () => C("variables"),
252
+ children: "Variables"
253
+ }
254
+ )
255
+ ] }),
256
+ N === "general" ? /* @__PURE__ */ c(W, { children: [
257
+ /* @__PURE__ */ c("div", { className: "modal-body", children: [
258
+ /* @__PURE__ */ e("p", { className: "muted small", children: "These settings belong to the workflow, so everyone who opens it gets the same behaviour. Both are on unless you turn them off; each change saves straight away." }),
259
+ /* @__PURE__ */ c(
260
+ "label",
261
+ {
262
+ style: {
263
+ display: "flex",
264
+ alignItems: "center",
265
+ gap: "var(--w6w-sp-2)",
266
+ cursor: "pointer"
267
+ },
268
+ title: "Save edits as you make them, without pressing Save.",
269
+ children: [
270
+ /* @__PURE__ */ e(
271
+ "input",
272
+ {
273
+ type: "checkbox",
274
+ checked: a,
275
+ onChange: (v) => d("autoSave", v.target.checked)
276
+ }
277
+ ),
278
+ /* @__PURE__ */ e("span", { className: "muted small", children: "Auto-save edits" })
279
+ ]
280
+ }
281
+ ),
282
+ /* @__PURE__ */ c(
283
+ "label",
284
+ {
285
+ style: {
286
+ display: "flex",
287
+ alignItems: "center",
288
+ gap: "var(--w6w-sp-2)",
289
+ cursor: "pointer"
290
+ },
291
+ title: "Keep the arrangement of the canvas — where each step sits, and the view you left it at.",
292
+ children: [
293
+ /* @__PURE__ */ e(
294
+ "input",
295
+ {
296
+ type: "checkbox",
297
+ checked: o,
298
+ onChange: (v) => d("savePosition", v.target.checked)
299
+ }
300
+ ),
301
+ /* @__PURE__ */ e("span", { className: "muted small", children: "Save step positions and canvas view" })
302
+ ]
303
+ }
304
+ )
305
+ ] }),
306
+ /* @__PURE__ */ e("div", { className: "modal-actions", children: /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: u, children: "Done" }) })
307
+ ] }) : /* @__PURE__ */ c(W, { children: [
308
+ /* @__PURE__ */ c("div", { className: "modal-body", children: [
309
+ /* @__PURE__ */ c("p", { className: "muted small", children: [
310
+ "Declaring variables here defines this workflow's ",
311
+ /* @__PURE__ */ e("strong", { children: "public input schema" }),
312
+ ": API and AI (MCP) callers then see exactly these inputs. With none declared, they may send anything."
313
+ ] }),
314
+ /* @__PURE__ */ c("div", { className: "row", style: { justifyContent: "space-between", alignItems: "center" }, children: [
315
+ /* @__PURE__ */ e("span", { className: "muted small", children: l.length === 0 ? "No variables declared." : `${l.length} variable${l.length === 1 ? "" : "s"} declared.` }),
316
+ /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: D, children: "+ Add variable" })
317
+ ] }),
318
+ l.length > 0 && /* @__PURE__ */ e("ul", { className: "list", "data-testid": "workflow-variables-list", children: l.map((v, y) => /* @__PURE__ */ c(
319
+ "li",
320
+ {
321
+ style: {
322
+ flexDirection: "column",
323
+ alignItems: "stretch",
324
+ gap: "var(--w6w-sp-1)"
325
+ },
326
+ children: [
327
+ /* @__PURE__ */ c("div", { className: "row", style: { alignItems: "center", gap: "var(--w6w-sp-2)" }, children: [
328
+ /* @__PURE__ */ e(
329
+ "input",
330
+ {
331
+ type: "text",
332
+ value: v.key,
333
+ placeholder: "key",
334
+ "aria-label": "Variable key",
335
+ onChange: (p) => S(y, { key: p.target.value })
336
+ }
337
+ ),
338
+ /* @__PURE__ */ c(
339
+ "select",
340
+ {
341
+ value: v.type ?? "",
342
+ "aria-label": "Variable type",
343
+ onChange: (p) => S(y, {
344
+ type: p.target.value || void 0
345
+ }),
346
+ children: [
347
+ /* @__PURE__ */ e("option", { value: "", children: "(unset)" }),
348
+ gn.map((p) => /* @__PURE__ */ e("option", { value: p, children: p }, p))
349
+ ]
350
+ }
351
+ ),
352
+ /* @__PURE__ */ c(
353
+ "label",
354
+ {
355
+ className: "row",
356
+ style: { gap: "var(--w6w-sp-1)", alignItems: "center" },
357
+ children: [
358
+ /* @__PURE__ */ e(
359
+ "input",
360
+ {
361
+ type: "checkbox",
362
+ checked: v.required ?? !1,
363
+ onChange: (p) => S(y, { required: p.target.checked })
364
+ }
365
+ ),
366
+ /* @__PURE__ */ e("span", { className: "muted small", children: "required" })
367
+ ]
368
+ }
369
+ ),
370
+ /* @__PURE__ */ e(
371
+ vt,
372
+ {
373
+ value: { vars: Gt(l, y, f) },
374
+ children: /* @__PURE__ */ e(
375
+ yt,
376
+ {
377
+ value: v.default,
378
+ onChange: (p) => S(y, { default: p }),
379
+ placeholder: "default",
380
+ "aria-label": "Variable default"
381
+ },
382
+ `${l.length}:${y}`
383
+ )
384
+ }
385
+ ),
386
+ /* @__PURE__ */ e(
387
+ F,
388
+ {
389
+ danger: !0,
390
+ icon: "close",
391
+ label: `Remove variable ${v.key || y + 1}`,
392
+ onClick: () => T(y)
393
+ }
394
+ )
395
+ ] }),
396
+ w.includes(y) && /* @__PURE__ */ e("span", { className: "muted small", "data-testid": "variable-duplicate", children: "Duplicate key — a later row with the same name wins." })
397
+ ]
398
+ },
399
+ y
400
+ )) })
401
+ ] }),
402
+ /* @__PURE__ */ e("div", { className: "modal-actions", children: /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: u, children: "Done" }) })
403
+ ] })
404
+ ] });
405
+ }
406
+ const wn = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/, kn = "Untitled workflow", Nn = St(
407
+ () => import("@w6w/ui/flow").then((r) => ({ default: r.WorkflowFlowEditor }))
408
+ );
409
+ function Sn(r) {
410
+ var Ve, We, De, Me, Ke;
411
+ const { workflowId: a, project: o, initialRunId: l, onNavigate: u, slots: d } = r, m = qt(), f = gt(), [N, C] = g(!0), [D, S] = g(null), [T, w] = g(null), [v, y] = g(!1), [p, j] = g(!1), [oe, re] = g(!1), [H, le] = g(void 0), ie = I(!0), ce = I(() => null), Ge = ae(
412
+ (t) => {
413
+ const n = t;
414
+ return wn.test(typeof n.id == "string" ? n.id : "") ? qe(H, n.key).reason : "Invalid workflow id.";
415
+ },
416
+ [H]
417
+ ), i = _t({
418
+ workflowId: a,
419
+ project: o,
420
+ autoSave: ie.current,
421
+ // The expression editor holds uncommitted parts in its own local state until its Save
422
+ // button, so saving from under it would persist a workflow without the expression the user
423
+ // is looking at. Read at fire time (opening it changes neither the buffer nor `canSave`).
424
+ canAutoSave: () => !document.querySelector(".w6w-exprmodal"),
425
+ saveGuard: Ge,
426
+ publishBlockedReason: (t) => ce.current(t)
427
+ }), de = i.json, s = i.parsed, O = i.canSave, ze = i.dirty;
428
+ x(() => {
429
+ if (i.loading || i.loadError !== null) {
430
+ le(void 0);
431
+ return;
432
+ }
433
+ !i.dirty && s && le(s.key ?? null);
434
+ }, [i.loading, i.loadError, i.dirty, s]);
435
+ const [Ye, Q] = g(!1);
436
+ x(() => {
437
+ i.stale || Q(!1);
438
+ }, [i.stale]);
439
+ const [Ue, ue] = g(!1), he = I(!1);
440
+ x(() => {
441
+ i.saving ? ue(!1) : he.current && i.error === null && ue(!0), he.current = i.saving;
442
+ }, [i.saving, i.error]);
443
+ const [M, E] = g(null), fe = Pt(), pe = xt(), A = It(M), me = (Ve = A.data) == null ? void 0 : Ve.status, ve = A.isError, B = At(me, ve), ye = Lt(
444
+ (We = A.data) == null ? void 0 : We.steps
445
+ ), ge = Ft(A.data, ye), G = I(!1), [Ze, be] = g(!1);
446
+ x(() => {
447
+ E(null);
448
+ }, [a]), x(() => {
449
+ l && E(l);
450
+ }, [a, l]), x(() => {
451
+ A.data && A.data.workflowId !== a && E(null);
452
+ }, [A.data, a]);
453
+ async function we(t) {
454
+ try {
455
+ const n = await i.flushThen(t);
456
+ !n.ok && n.outcome.status === "blocked" && w(n.outcome.reason);
457
+ } catch (n) {
458
+ w(n instanceof ne ? n.message : String(n));
459
+ }
460
+ }
461
+ async function Xe() {
462
+ var t;
463
+ if (!(!a || B || G.current)) {
464
+ w(null), G.current = !0, be(!0);
465
+ try {
466
+ const n = await Ot(
467
+ (t = $ == null ? void 0 : $[0]) == null ? void 0 : t.id,
468
+ (h) => _e(m, a, h)
469
+ );
470
+ await we(
471
+ () => fe.mutateAsync({
472
+ id: a,
473
+ variables: {},
474
+ ...n ? { input: n } : {}
475
+ }).then((h) => E(h.runId))
476
+ );
477
+ } finally {
478
+ G.current = !1, be(!1);
479
+ }
480
+ }
481
+ }
482
+ function et() {
483
+ M && (pe.mutate(M, {
484
+ onError: (t) => {
485
+ const n = t instanceof ne ? t.code : "";
486
+ Vt(n) === "surface" && w(t instanceof ne ? t.message : String(t));
487
+ }
488
+ }), E(null));
489
+ }
490
+ async function tt() {
491
+ re(!0);
492
+ try {
493
+ await i.reload(), C(!0), S(null), w(null);
494
+ } finally {
495
+ re(!1);
496
+ }
497
+ }
498
+ const J = i.stale ? null : i.error ?? i.loadError, ke = T ?? (J === null ? null : J instanceof Error ? J.message : String(J)), nt = s !== null && Array.isArray(s.steps), Ne = (s == null ? void 0 : s.displayName) ?? "", z = zt(s == null ? void 0 : s.settings), at = k(() => Yt(s == null ? void 0 : s.variables), [s == null ? void 0 : s.variables]), Se = qe(H, s == null ? void 0 : s.key), Ce = s !== null && H !== void 0 && !Se.allowed ? Se.reason : null, R = k(
499
+ () => Array.isArray(s == null ? void 0 : s.steps) ? s.steps : [],
500
+ [s]
501
+ ), [b, st] = g(null);
502
+ x(() => {
503
+ let t = !1;
504
+ return import("@w6w/ui/flow").then((n) => {
505
+ t || st({
506
+ internalNodes: n.INTERNAL_NODES,
507
+ isInternalApp: n.isInternalApp,
508
+ internalNodeParams: n.internalNodeParams,
509
+ isManualTrigger: (h) => h === n.TRIGGER_APP,
510
+ asFieldDefs: n.asFieldDefs
511
+ });
512
+ }), () => {
513
+ t = !0;
514
+ };
515
+ }, []);
516
+ const $ = k(() => {
517
+ if (b)
518
+ return Ut(
519
+ { steps: R },
520
+ {
521
+ isManualTrigger: b.isManualTrigger,
522
+ asFieldDefs: b.asFieldDefs
523
+ }
524
+ );
525
+ }, [b, R]), Ee = k(() => {
526
+ if (!b) return !1;
527
+ const t = new Set(
528
+ b.internalNodes.filter((n) => n.group === "trigger").map((n) => `${n.app}::${n.action}`)
529
+ );
530
+ return R.some((n) => {
531
+ const { app: h, action: P } = n.uses ?? {};
532
+ return !!h && !!P && t.has(`${h}::${P}`);
533
+ });
534
+ }, [b, R]), q = k(() => {
535
+ if (!b) return [];
536
+ const t = /* @__PURE__ */ new Set();
537
+ for (const n of R) {
538
+ const { app: h, action: P } = n.uses ?? {};
539
+ h && P && !b.isInternalApp(h) && t.add(h);
540
+ }
541
+ return [...t];
542
+ }, [b, R]), { byId: _ } = Dt(q), ot = k(() => [..._.values()], [_]), Re = Be({
543
+ queries: q.map((t) => ({
544
+ queryKey: Et(t),
545
+ queryFn: () => f.getAppActions(t)
546
+ }))
547
+ }), Pe = k(() => {
548
+ var n, h;
549
+ const t = {};
550
+ if (!b) return t;
551
+ for (const P of R) {
552
+ const { app: L, action: V } = P.uses ?? {};
553
+ if (!L || !V) continue;
554
+ const ee = `${L}::${V}`;
555
+ if (!(ee in t))
556
+ if (b.isInternalApp(L))
557
+ t[ee] = b.internalNodeParams(L, V);
558
+ else {
559
+ const je = q.indexOf(L), te = je >= 0 ? (n = Re[je]) == null ? void 0 : n.data : void 0;
560
+ t[ee] = ((h = te == null ? void 0 : te.find((dt) => dt.key === V)) == null ? void 0 : h.params) ?? [];
561
+ }
562
+ }
563
+ return t;
564
+ }, [b, R, q, Re]), K = k(() => {
565
+ const t = {};
566
+ for (const [n, h] of _) t[n] = h;
567
+ return t;
568
+ }, [_]), Y = k(
569
+ () => R.filter((t) => {
570
+ var h;
571
+ const n = (h = t.uses) == null ? void 0 : h.app;
572
+ return !!n && n in K && Je(K[n]);
573
+ }),
574
+ [R, K]
575
+ ), xe = Be({
576
+ queries: Y.map((t) => ({
577
+ queryKey: rn(a, t.id),
578
+ queryFn: () => _e(m, a, t.id),
579
+ enabled: !!a
580
+ }))
581
+ }), Ie = k(() => {
582
+ const t = {};
583
+ return Y.forEach((n, h) => {
584
+ var P, L;
585
+ t[n.id] = !!((L = (P = xe[h]) == null ? void 0 : P.data) != null && L.some((V) => V.lastRunStatus === "succeeded"));
586
+ }), t;
587
+ }, [Y, xe]), U = sn("workflow", a, !!a), Z = on("workflow"), X = k(
588
+ () => ({
589
+ hasTrigger: Ee,
590
+ actionParamsByKey: Pe,
591
+ appsById: K,
592
+ testStatus: Ie,
593
+ requiredParamsFilled: bt,
594
+ isTestRequired: Je
595
+ }),
596
+ [Ee, Pe, K, Ie]
597
+ ), Ae = s !== null && Zt(s, X), rt = s !== null ? $e(s, X) : null;
598
+ ce.current = (t) => t !== null && typeof t == "object" ? $e(t, X) : null, ie.current = z.autoSave;
599
+ function Le(t) {
600
+ if (!s) return;
601
+ const n = { ...s, ...t };
602
+ i.setJson(JSON.stringify(n, null, 2));
603
+ }
604
+ function lt(t) {
605
+ if (!s) return;
606
+ const n = { ...s, ...t };
607
+ w(null), i.commit(JSON.stringify(n, null, 2));
608
+ }
609
+ const Fe = I(s);
610
+ Fe.current = s;
611
+ const Te = I(i.commit);
612
+ Te.current = i.commit;
613
+ const Oe = I(i.saveNow);
614
+ Oe.current = i.saveNow, x(() => {
615
+ const t = (n) => {
616
+ n.altKey || !(n.metaKey || n.ctrlKey) || n.key.toLowerCase() !== "s" || (n.preventDefault(), !document.querySelector(".w6w-exprmodal") && O && Oe.current());
617
+ };
618
+ return document.addEventListener("keydown", t), () => {
619
+ document.removeEventListener("keydown", t);
620
+ };
621
+ }, [O]);
622
+ const it = k(
623
+ () => s ? tn(s) : {},
624
+ [s]
625
+ ), ct = ae((t) => {
626
+ const n = Fe.current;
627
+ if (!n) return;
628
+ const h = nn(n, t);
629
+ w(null), Te.current(JSON.stringify(h, null, 2));
630
+ }, []);
631
+ return $t({
632
+ kind: "workflow",
633
+ id: a,
634
+ label: Ne,
635
+ key: (s == null ? void 0 : s.key) ?? void 0,
636
+ triggers: $,
637
+ policy: it,
638
+ onPolicyChange: ct
639
+ }), /* @__PURE__ */ c("div", { className: "wf-fullbleed", style: { height: "100%", minWidth: 0, flex: 1 }, children: [
640
+ (d == null ? void 0 : d.header) ?? /* @__PURE__ */ e(
641
+ cn,
642
+ {
643
+ onBack: () => u({ type: "list" }),
644
+ backLabel: (d == null ? void 0 : d.backLabel) ?? "← Workflows",
645
+ title: {
646
+ editable: !0,
647
+ value: Ne,
648
+ placeholder: kn,
649
+ maxLength: 80,
650
+ ariaLabel: "Workflow name",
651
+ onChange: (t) => Le({ displayName: t }),
652
+ onBlur: () => {
653
+ O && i.saveNow();
654
+ }
655
+ },
656
+ actions: /* @__PURE__ */ c(W, { children: [
657
+ /* @__PURE__ */ e(
658
+ F,
659
+ {
660
+ icon: "play",
661
+ label: Tt(me, ve),
662
+ "data-testid": "wf-run-start",
663
+ onClick: Xe,
664
+ disabled: !a || B || Ze || fe.isPending
665
+ }
666
+ ),
667
+ B && /* @__PURE__ */ e(
668
+ F,
669
+ {
670
+ icon: "stop",
671
+ label: "Stop this run",
672
+ "data-testid": "wf-run-stop",
673
+ onClick: et,
674
+ disabled: pe.isPending
675
+ }
676
+ ),
677
+ /* @__PURE__ */ e(
678
+ "button",
679
+ {
680
+ type: "button",
681
+ className: `btn ghost wf-publish${((De = U.data) == null ? void 0 : De.currentPublishedVersion) != null ? " active" : ""}`,
682
+ "data-testid": "wf-publish",
683
+ onClick: () => {
684
+ a && (w(null), we(() => Z.mutateAsync(a)));
685
+ },
686
+ disabled: o === null || !O || !Ae || Z.isPending,
687
+ title: O && !Ae ? rt ?? "Workflow is not valid" : ((Me = U.data) == null ? void 0 : Me.currentPublishedVersion) != null ? "Published — click to publish a new version" : "Never published — click to publish",
688
+ children: Z.isPending ? "Publishing…" : ((Ke = U.data) == null ? void 0 : Ke.currentPublishedVersion) != null ? "● Published" : "Publish"
689
+ }
690
+ ),
691
+ /* @__PURE__ */ e(
692
+ pn,
693
+ {
694
+ kind: "workflow",
695
+ id: a,
696
+ onOpenRun: (t) => {
697
+ E(t), u({ type: "run", id: a, runId: t });
698
+ }
699
+ }
700
+ ),
701
+ /* @__PURE__ */ e(mn, { onClick: () => y(!0) }),
702
+ /* @__PURE__ */ e(
703
+ F,
704
+ {
705
+ icon: "settings",
706
+ label: "Workflow settings",
707
+ onClick: () => j(!0)
708
+ }
709
+ ),
710
+ d == null ? void 0 : d.headerActions
711
+ ] })
712
+ }
713
+ ),
714
+ /* @__PURE__ */ e("div", { className: "wf-fullbleed-canvas", children: /* @__PURE__ */ c("div", { className: "wf-run-area", children: [
715
+ /* @__PURE__ */ e("div", { className: "wf-run-canvas", children: /* @__PURE__ */ e(Nt, { fallback: /* @__PURE__ */ e("p", { className: "muted", children: "Loading visual editor…" }), children: nt && s ? /* @__PURE__ */ e(
716
+ Nn,
717
+ {
718
+ value: s,
719
+ onChange: (t) => {
720
+ i.setJson(JSON.stringify(t, null, 2)), C(!0), S(null), E(null);
721
+ },
722
+ apps: ot,
723
+ project: o ?? void 0,
724
+ height: "100%",
725
+ readOnly: B,
726
+ fitViewKey: M !== null,
727
+ runState: A.data,
728
+ onTestRun: () => E(null)
729
+ }
730
+ ) : de === "" ? /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" }) : /* @__PURE__ */ e("p", { className: "muted", children: "Fix the JSON to render the visual editor." }) }) }),
731
+ M && /* @__PURE__ */ e("div", { className: "wf-run-log", "data-testid": "wf-run-log", children: /* @__PURE__ */ e(
732
+ wt,
733
+ {
734
+ steps: ye,
735
+ runError: ge.runError,
736
+ stepErrors: ge.stepErrors,
737
+ onDismiss: () => E(null)
738
+ }
739
+ ) })
740
+ ] }) }),
741
+ o === null && /* @__PURE__ */ c("div", { role: "alert", className: "error", "data-testid": "wf-project-required", children: [
742
+ "No project selected — pass a ",
743
+ /* @__PURE__ */ e("code", { children: "project" }),
744
+ " prop (or set the provider's project) to edit and save this workflow."
745
+ ] }),
746
+ /* @__PURE__ */ c("div", { className: "wf-fullbleed-foot", children: [
747
+ /* @__PURE__ */ c("div", { className: "row", style: { flexWrap: "wrap", alignItems: "center" }, children: [
748
+ /* @__PURE__ */ e(
749
+ "button",
750
+ {
751
+ type: "button",
752
+ className: "btn",
753
+ disabled: o === null || !O || !ze,
754
+ onClick: i.saveNow,
755
+ children: i.saving ? "Saving…" : "Save"
756
+ }
757
+ ),
758
+ Ue && /* @__PURE__ */ e("span", { className: "ok", children: "Saved." })
759
+ ] }),
760
+ ke && /* @__PURE__ */ e("div", { className: "error", children: ke }),
761
+ Ce && /* @__PURE__ */ e("div", { className: "error", "data-testid": "wf-key-guard", children: Ce })
762
+ ] }),
763
+ /* @__PURE__ */ e(
764
+ vn,
765
+ {
766
+ open: v,
767
+ onClose: () => y(!1),
768
+ title: `JSON — ${(s == null ? void 0 : s.displayName) || "workflow"}`,
769
+ mode: "synced",
770
+ value: de,
771
+ onChange: (t) => {
772
+ i.setJson(t), E(null);
773
+ },
774
+ onValidityChange: ({ valid: t, error: n }) => {
775
+ C(t), S(n);
776
+ },
777
+ invalidReason: N ? null : D,
778
+ editorLabel: "Workflow definition JSON"
779
+ }
780
+ ),
781
+ i.stale && !Ye && /* @__PURE__ */ c(se, { title: "This workflow changed on the server", onClose: () => Q(!0), children: [
782
+ /* @__PURE__ */ c("div", { className: "modal-body", children: [
783
+ /* @__PURE__ */ e("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." }),
784
+ /* @__PURE__ */ c("p", { className: "muted small", children: [
785
+ /* @__PURE__ */ e("strong", { children: "Reload from server" }),
786
+ " replaces what is on this canvas with the saved copy; anything you changed here and have not saved is lost.",
787
+ " ",
788
+ /* @__PURE__ */ e("strong", { children: "Keep editing" }),
789
+ " 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."
790
+ ] })
791
+ ] }),
792
+ /* @__PURE__ */ c("div", { className: "modal-actions", children: [
793
+ /* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: () => Q(!0), children: "Keep editing" }),
794
+ /* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: oe, onClick: tt, children: oe ? "Reloading…" : "Reload from server" })
795
+ ] })
796
+ ] }),
797
+ p && /* @__PURE__ */ e(
798
+ bn,
799
+ {
800
+ autoSave: z.autoSave,
801
+ savePosition: z.savePosition,
802
+ variables: at,
803
+ onClose: () => j(!1),
804
+ onChange: (t, n) => lt({ settings: en(s == null ? void 0 : s.settings, t, n) }),
805
+ onVariablesChange: (t) => Le({ variables: Xt(t) })
806
+ }
807
+ )
808
+ ] });
809
+ }
810
+ const Cn = () => {
811
+ };
812
+ function $n(r) {
813
+ const { workflowId: a, initialRunId: o, onNavigate: l = Cn, slots: u } = r, d = an(r.project), m = ae(
814
+ (f) => {
815
+ f.type === "list" ? l({ type: "list" }) : f.kind === "workflow" && l({ type: "workflow", id: f.id });
816
+ },
817
+ [l]
818
+ );
819
+ return /* @__PURE__ */ e(
820
+ "div",
821
+ {
822
+ className: "w6w-embed-root",
823
+ style: { display: "flex", width: "100%", height: "100%", minHeight: 0 },
824
+ children: /* @__PURE__ */ e(
825
+ yn,
826
+ {
827
+ project: d,
828
+ onNavigate: m,
829
+ rail: r.rail,
830
+ storageKey: d === null ? null : `w6w.rail.embed.${d}`,
831
+ children: /* @__PURE__ */ e(
832
+ Sn,
833
+ {
834
+ workflowId: a,
835
+ project: d,
836
+ initialRunId: o,
837
+ onNavigate: l,
838
+ slots: u
839
+ }
840
+ )
841
+ }
842
+ )
843
+ }
844
+ );
845
+ }
846
+ export {
847
+ cn as E,
848
+ pn as H,
849
+ vn as J,
850
+ $n as W,
851
+ yn as a,
852
+ mn as b
853
+ };
854
+ //# sourceMappingURL=WorkflowEditor-DlbVv6Fs.js.map