@powerhousedao/workflow 6.2.3-dev.84 → 6.2.3-dev.86
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.
- package/dist/browser/{BlockSelector-CtoMNZ9A.js → BlockSelector-BKAJwJ4Y.js} +74 -6
- package/dist/browser/BlockSelector-BKAJwJ4Y.js.map +1 -0
- package/dist/browser/{PieceMarkdown-U6OUTwRi.js → PieceMarkdown-DSdZd-Jc.js} +34 -8
- package/dist/browser/PieceMarkdown-DSdZd-Jc.js.map +1 -0
- package/dist/browser/{connection-form-_H-tP2Vk.js → connection-form-DltdMa8F.js} +3 -3
- package/dist/browser/{connection-form-_H-tP2Vk.js.map → connection-form-DltdMa8F.js.map} +1 -1
- package/dist/browser/{data-tree-CjWQllC7.js → data-tree-DAw8e0j8.js} +25 -12
- package/dist/browser/data-tree-DAw8e0j8.js.map +1 -0
- package/dist/browser/document-models/index.js +2 -2
- package/dist/browser/document-models/workflow/index.js +2 -2
- package/dist/browser/{document-models-DSK5cn8B.js → document-models-C2SAP1SX.js} +2 -2
- package/dist/browser/{document-models-DSK5cn8B.js.map → document-models-C2SAP1SX.js.map} +1 -1
- package/dist/browser/{editor-B1AzXxaF.js → editor--J61vLSC.js} +435 -51
- package/dist/browser/editor--J61vLSC.js.map +1 -0
- package/dist/browser/{editor-DgdTF2up.js → editor-CZLe6CAF.js} +5 -5
- package/dist/browser/{editor-DgdTF2up.js.map → editor-CZLe6CAF.js.map} +1 -1
- package/dist/browser/{editor-B9069RYZ.js → editor-Dl6lzxkM.js} +26 -18
- package/dist/browser/{editor-B9069RYZ.js.map → editor-Dl6lzxkM.js.map} +1 -1
- package/dist/browser/editors/connection-editor/module.js +1 -1
- package/dist/browser/editors/runtime/index.js +1 -1
- package/dist/browser/editors/workflow-editor/module.js +1 -1
- package/dist/browser/editors/workflow-studio/module.js +1 -1
- package/dist/browser/index.js +3 -3
- package/dist/browser/{module-eOpxJVIl.js → module-mFCt9WHJ.js} +2 -2
- package/dist/browser/module-mFCt9WHJ.js.map +1 -0
- package/dist/browser/reactor/index.js +2 -2
- package/dist/browser/{runtime-queries-LAcyniYz.js → runtime-queries-D81Ghpok.js} +105 -4
- package/dist/browser/runtime-queries-D81Ghpok.js.map +1 -0
- package/dist/browser/{trigger-text-BgpPIXEJ.js → trigger-text-BSVi5oGZ.js} +392 -387
- package/dist/browser/trigger-text-BSVi5oGZ.js.map +1 -0
- package/dist/browser/{upgrade-manifests-CLYUPqBs.js → upgrade-manifests-C2Qa6myy.js} +2 -2
- package/dist/browser/{upgrade-manifests-CLYUPqBs.js.map → upgrade-manifests-C2Qa6myy.js.map} +1 -1
- package/dist/browser/{workflow-Cn1UP-eJ.js → workflow-BFdnSGRD.js} +2 -2
- package/dist/browser/{workflow-Cn1UP-eJ.js.map → workflow-BFdnSGRD.js.map} +1 -1
- package/dist/node/{BlockSelector-CbdgYJfp.mjs → BlockSelector-DTfZEEW9.mjs} +75 -7
- package/dist/node/BlockSelector-DTfZEEW9.mjs.map +1 -0
- package/dist/node/{PieceMarkdown-DwpCBISY.mjs → PieceMarkdown-CUSdTMH4.mjs} +34 -8
- package/dist/node/{PieceMarkdown-DwpCBISY.mjs.map → PieceMarkdown-CUSdTMH4.mjs.map} +1 -1
- package/dist/node/{connection-form-DPbyrUIm.mjs → connection-form-Dc7akS2K.mjs} +3 -3
- package/dist/node/{connection-form-DPbyrUIm.mjs.map → connection-form-Dc7akS2K.mjs.map} +1 -1
- package/dist/node/{data-tree-CXa2kEuD.mjs → data-tree-9EdqJVwJ.mjs} +25 -12
- package/dist/node/{data-tree-CXa2kEuD.mjs.map → data-tree-9EdqJVwJ.mjs.map} +1 -1
- package/dist/node/document-models/index.mjs +2 -2
- package/dist/node/document-models/workflow/index.mjs +2 -2
- package/dist/node/{editor-BGz1Ljdk.mjs → editor-CdIYZSrv.mjs} +26 -18
- package/dist/node/{editor-BGz1Ljdk.mjs.map → editor-CdIYZSrv.mjs.map} +1 -1
- package/dist/node/{editor-DzxyNgYk.mjs → editor-GSV1jiWZ.mjs} +5 -5
- package/dist/node/{editor-DzxyNgYk.mjs.map → editor-GSV1jiWZ.mjs.map} +1 -1
- package/dist/node/{editor-D3MlbYBN.mjs → editor-rbgFzhV5.mjs} +435 -51
- package/dist/node/editor-rbgFzhV5.mjs.map +1 -0
- package/dist/node/editors/connection-editor/module.mjs +1 -1
- package/dist/node/editors/runtime/index.mjs +1 -1
- package/dist/node/editors/workflow-editor/module.mjs +1 -1
- package/dist/node/editors/workflow-studio/module.mjs +1 -1
- package/dist/node/index.mjs +3 -3
- package/dist/node/{module-D9Zx5Zow.mjs → module-CuTg45ct.mjs} +2 -2
- package/dist/{browser/module-eOpxJVIl.js.map → node/module-CuTg45ct.mjs.map} +1 -1
- package/dist/node/pieces/ai/descriptor.json +1 -1
- package/dist/node/pieces/ai/package.json +1 -1
- package/dist/node/pieces/reactor/descriptor.json +1 -1
- package/dist/node/pieces/reactor/package.json +1 -1
- package/dist/node/{runtime-queries-CatdoDey.mjs → runtime-queries-VXJsWno5.mjs} +110 -5
- package/dist/node/runtime-queries-VXJsWno5.mjs.map +1 -0
- package/dist/node/{trigger-text-yNCaB6pd.mjs → trigger-text-DeWNwuoF.mjs} +392 -387
- package/dist/node/trigger-text-DeWNwuoF.mjs.map +1 -0
- package/dist/node/{upgrade-manifests-C4akaA_X.mjs → upgrade-manifests-BA5OaR4H.mjs} +2 -2
- package/dist/node/{upgrade-manifests-C4akaA_X.mjs.map → upgrade-manifests-BA5OaR4H.mjs.map} +1 -1
- package/dist/node/{workflow-DqF9VsBQ.mjs → workflow-BgURVzdc.mjs} +2 -2
- package/dist/node/{workflow-DqF9VsBQ.mjs.map → workflow-BgURVzdc.mjs.map} +1 -1
- package/dist/powerhouse.manifest.json +2 -2
- package/dist/style.css +1 -1
- package/dist/types/document-models/workflow/v1/gen/schema/types.d.ts +1 -1
- package/dist/types/document-models/workflow/v1/gen/schema/types.d.ts.map +1 -1
- package/dist/types/editors/shared/controls.d.ts.map +1 -1
- package/dist/types/editors/shared/data-tree.d.ts.map +1 -1
- package/dist/types/editors/shared/icons.d.ts +1 -0
- package/dist/types/editors/shared/icons.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-client.d.ts +39 -0
- package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-context.d.ts +10 -1
- package/dist/types/editors/workflow-editor/runtime-context.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-queries.d.ts +21 -1
- package/dist/types/editors/workflow-editor/runtime-queries.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/PieceMarkdown.d.ts +2 -1
- package/dist/types/editors/workflow-editor/ui/PieceMarkdown.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts +4 -0
- package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/block-meta.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/blocks.d.ts +4 -0
- package/dist/types/editors/workflow-editor/ui/blocks.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/query-keys.d.ts +9 -0
- package/dist/types/editors/workflow-editor/ui/query-keys.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/RunsTable.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/Sidebar.d.ts +3 -0
- package/dist/types/editors/workflow-studio/components/Sidebar.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts +49 -0
- package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts.map +1 -0
- package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts +3 -0
- package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/WorkflowStudio.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/run-format.d.ts +2 -1
- package/dist/types/editors/workflow-studio/components/run-format.d.ts.map +1 -1
- package/dist/types/editors/workflow-studio/components/waitpoints-view.test.d.ts +2 -0
- package/dist/types/editors/workflow-studio/components/waitpoints-view.test.d.ts.map +1 -0
- package/dist/types/editors/workflow-studio/components/waitpoints.test.d.ts +2 -0
- package/dist/types/editors/workflow-studio/components/waitpoints.test.d.ts.map +1 -0
- package/dist/types/test/waitpoint-record.d.ts +3 -0
- package/dist/types/test/waitpoint-record.d.ts.map +1 -0
- package/dist/workflow.css +2 -0
- package/package.json +9 -9
- package/dist/browser/BlockSelector-CtoMNZ9A.js.map +0 -1
- package/dist/browser/PieceMarkdown-U6OUTwRi.js.map +0 -1
- package/dist/browser/data-tree-CjWQllC7.js.map +0 -1
- package/dist/browser/editor-B1AzXxaF.js.map +0 -1
- package/dist/browser/runtime-queries-LAcyniYz.js.map +0 -1
- package/dist/browser/trigger-text-BgpPIXEJ.js.map +0 -1
- package/dist/node/BlockSelector-CbdgYJfp.mjs.map +0 -1
- package/dist/node/editor-D3MlbYBN.mjs.map +0 -1
- package/dist/node/module-D9Zx5Zow.mjs.map +0 -1
- package/dist/node/runtime-queries-CatdoDey.mjs.map +0 -1
- package/dist/node/trigger-text-yNCaB6pd.mjs.map +0 -1
|
@@ -1,42 +1,140 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { B as WEBHOOK_TRIGGER, F as SCHEDULE_TRIGGER, K as triggerBlock, N as MANUAL_TRIGGER, W as stepBlock } from "./runtime-queries-D81Ghpok.js";
|
|
2
|
+
import { Bt as textAreaClass, Ft as Switch, Ht as Icon, It as Tabs, Lt as Toggle, Mt as IconButton, Nt as Segmented, Ot as Button, Pt as Select, Q as useResolvedProp, Rt as Tooltip, Ut as isIconName, Vt as textInputClass, Z as useOptionSearch, at as isPropVisible, ct as settingFor, f as blockMeta, ft as withSetting, it as isEmptyValue, jt as Hint, kt as FieldError, ot as parsePropList, q as useDynamicCache, st as resolverInputFor, t as BlockLogo, ut as stripOptions, zt as invalidClass } from "./BlockSelector-BKAJwJ4Y.js";
|
|
3
3
|
import { useSetSelectedNode } from "@powerhousedao/reactor-browser";
|
|
4
4
|
import { blockKey } from "@powerhousedao/pieces-framework/block-type";
|
|
5
5
|
import { DOCUMENT_REF_KEY, NEXT_PORT, documentRefsIn, expandDocumentRefs, isDocumentRefMarker, parseScheduleConfig } from "@powerhousedao/pieces-framework/workflow";
|
|
6
6
|
import { Fragment, Suspense, createContext, lazy, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
9
|
-
//#region editors/
|
|
10
|
-
function
|
|
11
|
-
return value
|
|
9
|
+
//#region editors/shared/pending-echo.ts
|
|
10
|
+
function keyOf(value) {
|
|
11
|
+
return JSON.stringify(value, (_, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))) : entry);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
function usePendingEcho(saved, onChange) {
|
|
14
|
+
const savedKey = keyOf(saved);
|
|
15
|
+
const [sent, setSent] = useState([]);
|
|
16
|
+
const [seen, setSeen] = useState(savedKey);
|
|
17
|
+
let pending = sent;
|
|
18
|
+
if (seen !== savedKey) {
|
|
19
|
+
const echo = sent.findIndex((value) => keyOf(value) === savedKey);
|
|
20
|
+
pending = echo === -1 ? [] : sent.slice(echo + 1);
|
|
21
|
+
setSeen(savedKey);
|
|
22
|
+
setSent(pending);
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
const value = pending.length > 0 ? pending[pending.length - 1] : saved;
|
|
25
|
+
return {
|
|
26
|
+
value,
|
|
27
|
+
commit: (next) => {
|
|
28
|
+
if (keyOf(next) === keyOf(value)) return;
|
|
29
|
+
setSent([...pending, next]);
|
|
30
|
+
onChange(next, value);
|
|
31
|
+
},
|
|
32
|
+
onBlur: (event) => {
|
|
33
|
+
const inside = event.currentTarget.contains(event.relatedTarget);
|
|
34
|
+
if (pending.length > 0 && !inside && keyOf(value) === savedKey) setSent([]);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
24
37
|
}
|
|
25
38
|
//#endregion
|
|
26
|
-
//#region editors/workflow-editor/ui/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
return !model.published || model.published.version !== model.version;
|
|
39
|
+
//#region editors/workflow-editor/ui/canvas-menu.ts
|
|
40
|
+
function hasNextPort(model, id, portsOf) {
|
|
41
|
+
if (model.trigger?.id === id) return true;
|
|
42
|
+
const step = model.steps.find((entry) => entry.id === id);
|
|
43
|
+
return step ? portsOf(stepBlock(step))?.includes(NEXT_PORT) ?? false : false;
|
|
32
44
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
function contextMenuItems(target, model, portsOf) {
|
|
46
|
+
switch (target.kind) {
|
|
47
|
+
case "step": {
|
|
48
|
+
const skipped = model.steps.find((entry) => entry.id === target.id)?.skip === true;
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
id: "open",
|
|
52
|
+
label: "Open settings"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "addBelow",
|
|
56
|
+
label: "Add step below",
|
|
57
|
+
disabled: !hasNextPort(model, target.id, portsOf)
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "duplicate",
|
|
61
|
+
label: "Duplicate step"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: "toggleSkip",
|
|
65
|
+
label: skipped ? "Stop skipping this step" : "Skip this step"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "removeStep",
|
|
69
|
+
label: "Remove step"
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
case "trigger": return [
|
|
74
|
+
{
|
|
75
|
+
id: "open",
|
|
76
|
+
label: "Open settings"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: "addBelow",
|
|
80
|
+
label: "Add step below",
|
|
81
|
+
disabled: !model.trigger
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "changeTrigger",
|
|
85
|
+
label: "Change trigger"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: "removeTrigger",
|
|
89
|
+
label: "Remove trigger"
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
case "edge": return [{
|
|
93
|
+
id: "insertStep",
|
|
94
|
+
label: "Insert step here"
|
|
95
|
+
}, {
|
|
96
|
+
id: "removeEdge",
|
|
97
|
+
label: "Remove edge"
|
|
98
|
+
}];
|
|
99
|
+
case "pane": return [
|
|
100
|
+
{
|
|
101
|
+
id: "addStep",
|
|
102
|
+
label: "Add step here"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "selectAll",
|
|
106
|
+
label: "Select all steps",
|
|
107
|
+
disabled: model.steps.length === 0
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "fitView",
|
|
111
|
+
label: "Fit view"
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const MENU_ITEM_HEIGHT = 28;
|
|
117
|
+
const VIEWPORT_MARGIN = 8;
|
|
118
|
+
function menuHeight(items) {
|
|
119
|
+
return items * MENU_ITEM_HEIGHT + 8;
|
|
120
|
+
}
|
|
121
|
+
function clampToViewport(at, extent, available) {
|
|
122
|
+
return Math.max(VIEWPORT_MARGIN, Math.min(at, available - extent - VIEWPORT_MARGIN));
|
|
123
|
+
}
|
|
124
|
+
function menuPosition(point, size, viewport) {
|
|
125
|
+
const place = (at, extent, available) => clampToViewport(at + extent > available - VIEWPORT_MARGIN ? at - extent : at, extent, available);
|
|
126
|
+
return {
|
|
127
|
+
x: place(point.x, size.width, viewport.width),
|
|
128
|
+
y: place(point.y, size.height, viewport.height)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const ANCHOR_GAP = 8;
|
|
132
|
+
function anchorLeftPosition(anchor, size, viewport) {
|
|
133
|
+
const left = anchor.left - ANCHOR_GAP - size.width;
|
|
134
|
+
return {
|
|
135
|
+
x: clampToViewport(left >= VIEWPORT_MARGIN ? left : anchor.right + ANCHOR_GAP, size.width, viewport.width),
|
|
136
|
+
y: clampToViewport(anchor.top, size.height, viewport.height)
|
|
137
|
+
};
|
|
40
138
|
}
|
|
41
139
|
//#endregion
|
|
42
140
|
//#region editors/workflow-editor/ui/document-shape.ts
|
|
@@ -298,107 +396,6 @@ function childPath(parent, key, parentIsArray) {
|
|
|
298
396
|
return IDENTIFIER.test(key) ? `${parent}.${key}` : `${parent}[${JSON.stringify(key)}]`;
|
|
299
397
|
}
|
|
300
398
|
//#endregion
|
|
301
|
-
//#region editors/workflow-editor/ui/canvas-menu.ts
|
|
302
|
-
function hasNextPort(model, id, portsOf) {
|
|
303
|
-
if (model.trigger?.id === id) return true;
|
|
304
|
-
const step = model.steps.find((entry) => entry.id === id);
|
|
305
|
-
return step ? portsOf(stepBlock(step))?.includes(NEXT_PORT) ?? false : false;
|
|
306
|
-
}
|
|
307
|
-
function contextMenuItems(target, model, portsOf) {
|
|
308
|
-
switch (target.kind) {
|
|
309
|
-
case "step": {
|
|
310
|
-
const skipped = model.steps.find((entry) => entry.id === target.id)?.skip === true;
|
|
311
|
-
return [
|
|
312
|
-
{
|
|
313
|
-
id: "open",
|
|
314
|
-
label: "Open settings"
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
id: "addBelow",
|
|
318
|
-
label: "Add step below",
|
|
319
|
-
disabled: !hasNextPort(model, target.id, portsOf)
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
id: "duplicate",
|
|
323
|
-
label: "Duplicate step"
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
id: "toggleSkip",
|
|
327
|
-
label: skipped ? "Stop skipping this step" : "Skip this step"
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
id: "removeStep",
|
|
331
|
-
label: "Remove step"
|
|
332
|
-
}
|
|
333
|
-
];
|
|
334
|
-
}
|
|
335
|
-
case "trigger": return [
|
|
336
|
-
{
|
|
337
|
-
id: "open",
|
|
338
|
-
label: "Open settings"
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
id: "addBelow",
|
|
342
|
-
label: "Add step below",
|
|
343
|
-
disabled: !model.trigger
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
id: "changeTrigger",
|
|
347
|
-
label: "Change trigger"
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
id: "removeTrigger",
|
|
351
|
-
label: "Remove trigger"
|
|
352
|
-
}
|
|
353
|
-
];
|
|
354
|
-
case "edge": return [{
|
|
355
|
-
id: "insertStep",
|
|
356
|
-
label: "Insert step here"
|
|
357
|
-
}, {
|
|
358
|
-
id: "removeEdge",
|
|
359
|
-
label: "Remove edge"
|
|
360
|
-
}];
|
|
361
|
-
case "pane": return [
|
|
362
|
-
{
|
|
363
|
-
id: "addStep",
|
|
364
|
-
label: "Add step here"
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
id: "selectAll",
|
|
368
|
-
label: "Select all steps",
|
|
369
|
-
disabled: model.steps.length === 0
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
id: "fitView",
|
|
373
|
-
label: "Fit view"
|
|
374
|
-
}
|
|
375
|
-
];
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
const MENU_ITEM_HEIGHT = 28;
|
|
379
|
-
const VIEWPORT_MARGIN = 8;
|
|
380
|
-
function menuHeight(items) {
|
|
381
|
-
return items * MENU_ITEM_HEIGHT + 8;
|
|
382
|
-
}
|
|
383
|
-
function clampToViewport(at, extent, available) {
|
|
384
|
-
return Math.max(VIEWPORT_MARGIN, Math.min(at, available - extent - VIEWPORT_MARGIN));
|
|
385
|
-
}
|
|
386
|
-
function menuPosition(point, size, viewport) {
|
|
387
|
-
const place = (at, extent, available) => clampToViewport(at + extent > available - VIEWPORT_MARGIN ? at - extent : at, extent, available);
|
|
388
|
-
return {
|
|
389
|
-
x: place(point.x, size.width, viewport.width),
|
|
390
|
-
y: place(point.y, size.height, viewport.height)
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
const ANCHOR_GAP = 8;
|
|
394
|
-
function anchorLeftPosition(anchor, size, viewport) {
|
|
395
|
-
const left = anchor.left - ANCHOR_GAP - size.width;
|
|
396
|
-
return {
|
|
397
|
-
x: clampToViewport(left >= VIEWPORT_MARGIN ? left : anchor.right + ANCHOR_GAP, size.width, viewport.width),
|
|
398
|
-
y: clampToViewport(anchor.top, size.height, viewport.height)
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
//#endregion
|
|
402
399
|
//#region editors/workflow-editor/ui/expression-tokens.ts
|
|
403
400
|
const EMBEDDED_EXPRESSION = /(?<!\\)\{\{\s*([^{}]+?)\s*\}\}/g;
|
|
404
401
|
function splitExpressionTokens(value) {
|
|
@@ -806,258 +803,26 @@ function Chip(props) {
|
|
|
806
803
|
children: ref.root === "other" ? ref.rest : ref.rest || "*"
|
|
807
804
|
}),
|
|
808
805
|
ref.hasFallback ? /* @__PURE__ */ jsx("span", {
|
|
809
|
-
className: "text-wf-run",
|
|
810
|
-
children: "||…"
|
|
811
|
-
}) : null
|
|
812
|
-
]
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
function ExpressionTokenLine(props) {
|
|
816
|
-
const context = useExpressionTarget();
|
|
817
|
-
const tokens = splitExpressionTokens(props.value);
|
|
818
|
-
if (!tokens.some((token) => token.kind === "expression")) return null;
|
|
819
|
-
return /* @__PURE__ */ jsx("div", {
|
|
820
|
-
className: "mt-1.5 flex flex-wrap items-center gap-1 text-xs text-muted-foreground",
|
|
821
|
-
children: tokens.map((token, index) => token.kind === "text" ? /* @__PURE__ */ jsx("span", {
|
|
822
|
-
className: "max-w-40 truncate whitespace-pre",
|
|
823
|
-
children: token.text
|
|
824
|
-
}, index) : /* @__PURE__ */ jsx(Chip, {
|
|
825
|
-
expression: token.expression,
|
|
826
|
-
stepBlocks: context?.stepBlocks ?? {}
|
|
827
|
-
}, index))
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
//#endregion
|
|
831
|
-
//#region editors/workflow-editor/ui/PublishControls.tsx
|
|
832
|
-
function blockedReason(readiness) {
|
|
833
|
-
if (!readiness.hasTrigger) return "Add a trigger first";
|
|
834
|
-
if (readiness.firstIncomplete) return "You have incomplete steps";
|
|
835
|
-
return "Checking the steps…";
|
|
836
|
-
}
|
|
837
|
-
function usePublish(callbacks) {
|
|
838
|
-
const [publishing, setPublishing] = useState(false);
|
|
839
|
-
const [error, setError] = useState(null);
|
|
840
|
-
const publish = () => {
|
|
841
|
-
if (publishing) return;
|
|
842
|
-
setPublishing(true);
|
|
843
|
-
setError(null);
|
|
844
|
-
callbacks.publish().catch((cause) => setError(cause instanceof Error ? cause.message : String(cause))).finally(() => setPublishing(false));
|
|
845
|
-
};
|
|
846
|
-
return {
|
|
847
|
-
publishing,
|
|
848
|
-
error,
|
|
849
|
-
publish
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
function PublishButton(props) {
|
|
853
|
-
const { model, readiness } = props;
|
|
854
|
-
if (props.signIn?.required) return /* @__PURE__ */ jsx(Tooltip, {
|
|
855
|
-
content: "This Switchboard enforces document permissions, so a publish must be signed",
|
|
856
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
857
|
-
size: props.size ?? "sm",
|
|
858
|
-
variant: "primary",
|
|
859
|
-
disabled: props.signIn.pending,
|
|
860
|
-
onClick: props.signIn.login,
|
|
861
|
-
children: "Sign in to publish"
|
|
862
|
-
})
|
|
863
|
-
});
|
|
864
|
-
const incomplete = !readiness.ready;
|
|
865
|
-
const changes = hasDraftChanges(model);
|
|
866
|
-
const target = readiness.firstIncomplete;
|
|
867
|
-
const select = () => {
|
|
868
|
-
if (target) props.onSelect(target);
|
|
869
|
-
};
|
|
870
|
-
return /* @__PURE__ */ jsx(Tooltip, {
|
|
871
|
-
enabled: incomplete,
|
|
872
|
-
content: /* @__PURE__ */ jsx("button", {
|
|
873
|
-
type: "button",
|
|
874
|
-
className: "font-medium text-wf-warn hover:underline",
|
|
875
|
-
onClick: select,
|
|
876
|
-
children: blockedReason(readiness)
|
|
877
|
-
}),
|
|
878
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
879
|
-
className: "inline-flex",
|
|
880
|
-
onClick: incomplete ? select : void 0,
|
|
881
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
882
|
-
size: props.size ?? "sm",
|
|
883
|
-
variant: "primary",
|
|
884
|
-
disabled: incomplete || !changes || props.publishing,
|
|
885
|
-
title: !changes && !incomplete ? "No unpublished changes" : void 0,
|
|
886
|
-
onClick: props.onPublish,
|
|
887
|
-
children: props.publishing ? "Publishing…" : "Publish"
|
|
888
|
-
})
|
|
889
|
-
})
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
function PublishState(props) {
|
|
893
|
-
const draft = hasDraftChanges(props.model);
|
|
894
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
895
|
-
className: "flex shrink-0 items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground",
|
|
896
|
-
title: props.model.published ? `Published ${new Date(props.model.published.publishedAt).toLocaleString()}` : "Never published",
|
|
897
|
-
children: [
|
|
898
|
-
/* @__PURE__ */ jsx("span", {
|
|
899
|
-
"aria-hidden": true,
|
|
900
|
-
className: `h-2 w-2 rounded-full ${draft ? "bg-wf-warn" : "bg-wf-ok"}`
|
|
901
|
-
}),
|
|
902
|
-
/* @__PURE__ */ jsx("span", { children: !props.model.published ? "Draft" : draft ? "Unpublished changes" : "Published" }),
|
|
903
|
-
props.model.published && draft ? /* @__PURE__ */ jsxs("span", {
|
|
904
|
-
className: "text-muted-foreground/80",
|
|
905
|
-
children: [
|
|
906
|
-
"· v",
|
|
907
|
-
props.model.published.version,
|
|
908
|
-
" live"
|
|
909
|
-
]
|
|
910
|
-
}) : null
|
|
911
|
-
]
|
|
912
|
-
});
|
|
913
|
-
}
|
|
914
|
-
function StatusToggle(props) {
|
|
915
|
-
const allowed = props.published;
|
|
916
|
-
const on = props.status === "ENABLED";
|
|
917
|
-
return /* @__PURE__ */ jsx(Tooltip, {
|
|
918
|
-
enabled: !allowed,
|
|
919
|
-
content: "Publish the workflow first",
|
|
920
|
-
align: "end",
|
|
921
|
-
side: props.tooltipSide,
|
|
922
|
-
children: /* @__PURE__ */ jsxs("span", {
|
|
923
|
-
className: "flex items-center gap-2 text-xs text-muted-foreground",
|
|
924
|
-
children: [/* @__PURE__ */ jsx(Toggle, {
|
|
925
|
-
checked: on,
|
|
926
|
-
disabled: !allowed,
|
|
927
|
-
label: on ? "Turn the workflow off" : "Turn the workflow on",
|
|
928
|
-
onChange: (checked) => props.onChange(checked ? "ENABLED" : "DISABLED")
|
|
929
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
930
|
-
className: "w-6",
|
|
931
|
-
children: on ? "On" : "Off"
|
|
932
|
-
})]
|
|
933
|
-
})
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
function PublishedMissingNote(props) {
|
|
937
|
-
if (props.missing.length === 0) return null;
|
|
938
|
-
return /* @__PURE__ */ jsx("span", {
|
|
939
|
-
role: "alert",
|
|
940
|
-
"aria-label": "Published version incomplete",
|
|
941
|
-
className: "shrink-0 whitespace-nowrap rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs text-wf-warn",
|
|
942
|
-
title: `The published version is missing a reactor connection on: ${props.missing.join(", ")}`,
|
|
943
|
-
children: "Live version incomplete"
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
function ReactorDenialNote(props) {
|
|
947
|
-
if (!props.denial) return null;
|
|
948
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
949
|
-
role: "alert",
|
|
950
|
-
"aria-label": "Reactor access denied",
|
|
951
|
-
className: "max-w-80 truncate rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs text-wf-warn",
|
|
952
|
-
title: props.denial,
|
|
953
|
-
children: ["No reactor access: ", props.denial]
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
/** Instead of the draft banner on a managed workflow: who keeps it, and that edits here are not saved. */
|
|
957
|
-
function ManagedBanner(props) {
|
|
958
|
-
const manager = props.model.managedBy;
|
|
959
|
-
if (!manager) return null;
|
|
960
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
961
|
-
role: "status",
|
|
962
|
-
className: "pointer-events-auto flex max-w-xl items-center gap-3 rounded-lg border border-solid border-foreground/10 bg-card px-3 py-1.5 text-[13px] shadow-sm",
|
|
963
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
964
|
-
className: "h-2 w-2 shrink-0 rounded-full bg-muted-foreground",
|
|
965
|
-
"aria-hidden": true
|
|
966
|
-
}), /* @__PURE__ */ jsxs("span", {
|
|
967
|
-
className: "text-foreground",
|
|
968
|
-
children: [
|
|
969
|
-
"Managed by ",
|
|
970
|
-
/* @__PURE__ */ jsx("strong", { children: manager.label || manager.documentType }),
|
|
971
|
-
". Change it there: edits here are not saved."
|
|
972
|
-
]
|
|
973
|
-
})]
|
|
974
|
-
});
|
|
975
|
-
}
|
|
976
|
-
function DraftBanner(props) {
|
|
977
|
-
if (!hasDraftChanges(props.model)) return null;
|
|
978
|
-
const { readiness } = props;
|
|
979
|
-
const target = readiness.firstIncomplete;
|
|
980
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
981
|
-
role: "status",
|
|
982
|
-
className: "pointer-events-auto flex items-center gap-3 rounded-lg border border-solid border-foreground/10 bg-card py-1.5 pl-3 pr-1.5 text-[13px] shadow-sm",
|
|
983
|
-
children: [
|
|
984
|
-
/* @__PURE__ */ jsx("span", {
|
|
985
|
-
className: "h-2 w-2 shrink-0 rounded-full bg-wf-warn",
|
|
986
|
-
"aria-hidden": true
|
|
987
|
-
}),
|
|
988
|
-
/* @__PURE__ */ jsx("span", {
|
|
989
|
-
className: "text-foreground",
|
|
990
|
-
children: "You have unpublished changes"
|
|
991
|
-
}),
|
|
992
|
-
props.error ? /* @__PURE__ */ jsx("span", {
|
|
993
|
-
className: "text-xs text-wf-fail",
|
|
994
|
-
children: props.error
|
|
995
|
-
}) : null,
|
|
996
|
-
!readiness.hasTrigger || target ? /* @__PURE__ */ jsxs("span", {
|
|
997
|
-
className: "flex items-center gap-1.5 text-xs text-wf-warn",
|
|
998
|
-
children: [/* @__PURE__ */ jsx("span", { children: target ? "Incomplete steps" : "No trigger yet" }), target ? /* @__PURE__ */ jsx("button", {
|
|
999
|
-
type: "button",
|
|
1000
|
-
className: "font-medium underline underline-offset-2 hover:no-underline",
|
|
1001
|
-
onClick: () => props.onSelect(target),
|
|
1002
|
-
children: "Show"
|
|
1003
|
-
}) : null]
|
|
1004
|
-
}) : null,
|
|
1005
|
-
/* @__PURE__ */ jsxs("span", {
|
|
1006
|
-
className: "flex items-center gap-1",
|
|
1007
|
-
children: [props.model.published ? /* @__PURE__ */ jsx(Button, {
|
|
1008
|
-
size: "sm",
|
|
1009
|
-
variant: "ghost",
|
|
1010
|
-
onClick: props.onDiscard,
|
|
1011
|
-
children: "Discard changes"
|
|
1012
|
-
}) : null, /* @__PURE__ */ jsx(PublishButton, {
|
|
1013
|
-
model: props.model,
|
|
1014
|
-
readiness,
|
|
1015
|
-
publishing: props.publishing,
|
|
1016
|
-
onPublish: props.onPublish,
|
|
1017
|
-
onSelect: props.onSelect,
|
|
1018
|
-
signIn: props.signIn
|
|
1019
|
-
})]
|
|
1020
|
-
})
|
|
1021
|
-
]
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
//#endregion
|
|
1025
|
-
//#region editors/workflow-editor/ui/StepError.tsx
|
|
1026
|
-
function StepError(props) {
|
|
1027
|
-
return /* @__PURE__ */ jsx("pre", {
|
|
1028
|
-
className: "overflow-auto whitespace-pre-wrap rounded-md bg-wf-fail/10 p-2.5 text-xs text-wf-fail",
|
|
1029
|
-
children: props.error
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
//#endregion
|
|
1033
|
-
//#region editors/shared/pending-echo.ts
|
|
1034
|
-
function keyOf(value) {
|
|
1035
|
-
return JSON.stringify(value, (_, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))) : entry);
|
|
1036
|
-
}
|
|
1037
|
-
function usePendingEcho(saved, onChange) {
|
|
1038
|
-
const savedKey = keyOf(saved);
|
|
1039
|
-
const [sent, setSent] = useState([]);
|
|
1040
|
-
const [seen, setSeen] = useState(savedKey);
|
|
1041
|
-
let pending = sent;
|
|
1042
|
-
if (seen !== savedKey) {
|
|
1043
|
-
const echo = sent.findIndex((value) => keyOf(value) === savedKey);
|
|
1044
|
-
pending = echo === -1 ? [] : sent.slice(echo + 1);
|
|
1045
|
-
setSeen(savedKey);
|
|
1046
|
-
setSent(pending);
|
|
1047
|
-
}
|
|
1048
|
-
const value = pending.length > 0 ? pending[pending.length - 1] : saved;
|
|
1049
|
-
return {
|
|
1050
|
-
value,
|
|
1051
|
-
commit: (next) => {
|
|
1052
|
-
if (keyOf(next) === keyOf(value)) return;
|
|
1053
|
-
setSent([...pending, next]);
|
|
1054
|
-
onChange(next, value);
|
|
1055
|
-
},
|
|
1056
|
-
onBlur: (event) => {
|
|
1057
|
-
const inside = event.currentTarget.contains(event.relatedTarget);
|
|
1058
|
-
if (pending.length > 0 && !inside && keyOf(value) === savedKey) setSent([]);
|
|
1059
|
-
}
|
|
1060
|
-
};
|
|
806
|
+
className: "text-wf-run",
|
|
807
|
+
children: "||…"
|
|
808
|
+
}) : null
|
|
809
|
+
]
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
function ExpressionTokenLine(props) {
|
|
813
|
+
const context = useExpressionTarget();
|
|
814
|
+
const tokens = splitExpressionTokens(props.value);
|
|
815
|
+
if (!tokens.some((token) => token.kind === "expression")) return null;
|
|
816
|
+
return /* @__PURE__ */ jsx("div", {
|
|
817
|
+
className: "mt-1.5 flex flex-wrap items-center gap-1 text-xs text-muted-foreground",
|
|
818
|
+
children: tokens.map((token, index) => token.kind === "text" ? /* @__PURE__ */ jsx("span", {
|
|
819
|
+
className: "max-w-40 truncate whitespace-pre",
|
|
820
|
+
children: token.text
|
|
821
|
+
}, index) : /* @__PURE__ */ jsx(Chip, {
|
|
822
|
+
expression: token.expression,
|
|
823
|
+
stepBlocks: context?.stepBlocks ?? {}
|
|
824
|
+
}, index))
|
|
825
|
+
});
|
|
1061
826
|
}
|
|
1062
827
|
//#endregion
|
|
1063
828
|
//#region editors/workflow-editor/ui/secret-ref.ts
|
|
@@ -1113,6 +878,23 @@ function useSecretRef(options) {
|
|
|
1113
878
|
};
|
|
1114
879
|
}
|
|
1115
880
|
//#endregion
|
|
881
|
+
//#region editors/workflow-editor/ui/prop-defaults.ts
|
|
882
|
+
function asRecord(value) {
|
|
883
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
884
|
+
}
|
|
885
|
+
function withPropDefaults(props, config) {
|
|
886
|
+
const next = { ...asRecord(config) };
|
|
887
|
+
for (const prop of props) {
|
|
888
|
+
if (prop.type === "MARKDOWN" || prop.defaultValue === void 0) continue;
|
|
889
|
+
if (next[prop.name] === void 0) next[prop.name] = prop.defaultValue;
|
|
890
|
+
}
|
|
891
|
+
return next;
|
|
892
|
+
}
|
|
893
|
+
function lacksDefaults(props, config) {
|
|
894
|
+
const record = asRecord(config);
|
|
895
|
+
return props.some((prop) => prop.type !== "MARKDOWN" && prop.defaultValue !== void 0 && record[prop.name] === void 0);
|
|
896
|
+
}
|
|
897
|
+
//#endregion
|
|
1116
898
|
//#region editors/workflow-editor/ui/prop-controls.tsx
|
|
1117
899
|
const CALLOUT = {
|
|
1118
900
|
INFO: { box: "rounded bg-muted px-2 py-1.5" },
|
|
@@ -1651,11 +1433,12 @@ function parseDropdownResult(result) {
|
|
|
1651
1433
|
};
|
|
1652
1434
|
}
|
|
1653
1435
|
const RELOAD_DEBOUNCE_MS = 400;
|
|
1654
|
-
const PieceMarkdown = lazy(() => import("./PieceMarkdown-
|
|
1436
|
+
const PieceMarkdown = lazy(() => import("./PieceMarkdown-DSdZd-Jc.js"));
|
|
1655
1437
|
const NO_ENDPOINT = "[no endpoint yet — see Endpoint URL above]";
|
|
1656
1438
|
function fillPiecePlaceholders(text, values) {
|
|
1657
|
-
return text.replace(/\{\{\s*webhookUrl\s*\}\}/g, values.webhookUrl ?? NO_ENDPOINT).replace(/\{\{\s*webhookTimeoutSeconds\s*\}\}/g, values.webhookTimeoutSeconds === void 0 ? "{{webhookTimeoutSeconds}}" : String(values.webhookTimeoutSeconds));
|
|
1439
|
+
return text.replace(/\{\{\s*webhookUrl\s*\}\}/g, values.webhookUrl ?? NO_ENDPOINT).replace(/\{\{\s*webhookTimeoutSeconds\s*\}\}/g, values.webhookTimeoutSeconds === void 0 ? "{{webhookTimeoutSeconds}}" : String(values.webhookTimeoutSeconds)).replace(/\{\{\s*pausedFlowTimeoutDays\s*\}\}/g, values.pausedFlowTimeoutDays === void 0 ? "the workflow's maximum suspension" : String(values.pausedFlowTimeoutDays));
|
|
1658
1440
|
}
|
|
1441
|
+
const PiecePlaceholderContext = createContext({});
|
|
1659
1442
|
function AvailableSoon(props) {
|
|
1660
1443
|
return /* @__PURE__ */ jsxs("span", {
|
|
1661
1444
|
className: "inline-flex items-center gap-1 rounded-full bg-wf-warn/10 px-2 py-0.5 text-[11px] font-medium normal-case tracking-normal text-wf-warn",
|
|
@@ -1999,6 +1782,7 @@ function ModeButton(props) {
|
|
|
1999
1782
|
}
|
|
2000
1783
|
function PropField(props) {
|
|
2001
1784
|
const { prop, value } = props;
|
|
1785
|
+
const placeholders = useContext(PiecePlaceholderContext);
|
|
2002
1786
|
const fieldId = useId();
|
|
2003
1787
|
const optionsUnavailable = Boolean(props.nested && prop.hasDynamicResolver && !props.loadOptions);
|
|
2004
1788
|
const fieldRef = useRef(null);
|
|
@@ -2109,7 +1893,10 @@ function PropField(props) {
|
|
|
2109
1893
|
secrets: props.secrets
|
|
2110
1894
|
});
|
|
2111
1895
|
case "MARKDOWN": {
|
|
2112
|
-
const markdown = fillPiecePlaceholders(stringifyValue(prop.description ?? prop.defaultValue ?? prop.displayName), {
|
|
1896
|
+
const markdown = fillPiecePlaceholders(stringifyValue(prop.description ?? prop.defaultValue ?? prop.displayName), {
|
|
1897
|
+
...placeholders,
|
|
1898
|
+
webhookUrl: props.webhookUrl
|
|
1899
|
+
});
|
|
2113
1900
|
return /* @__PURE__ */ jsx(MarkdownCallout, {
|
|
2114
1901
|
variant: prop.variant,
|
|
2115
1902
|
children: /* @__PURE__ */ jsx(Suspense, {
|
|
@@ -2750,6 +2537,224 @@ function PropertyForm(props) {
|
|
|
2750
2537
|
});
|
|
2751
2538
|
}
|
|
2752
2539
|
//#endregion
|
|
2540
|
+
//#region editors/workflow-editor/ui/model.ts
|
|
2541
|
+
const VARIABLES_VIEW = "__variables";
|
|
2542
|
+
/** Query params of the editor's view: the open panel and its tab. */
|
|
2543
|
+
const STEP_PARAM = "step";
|
|
2544
|
+
function hasDraftChanges(model) {
|
|
2545
|
+
return !model.published || model.published.version !== model.version;
|
|
2546
|
+
}
|
|
2547
|
+
function uniqueStepKey(taken, label) {
|
|
2548
|
+
const base = label.toLowerCase().replaceAll(/[^a-z0-9]+/g, "_").replaceAll(/^_+|_+$/g, "") || "step";
|
|
2549
|
+
const keys = new Set(taken);
|
|
2550
|
+
let key = base;
|
|
2551
|
+
let suffix = 2;
|
|
2552
|
+
while (keys.has(key)) key = `${base}_${suffix++}`;
|
|
2553
|
+
return key;
|
|
2554
|
+
}
|
|
2555
|
+
//#endregion
|
|
2556
|
+
//#region editors/workflow-editor/ui/PublishControls.tsx
|
|
2557
|
+
function blockedReason(readiness) {
|
|
2558
|
+
if (!readiness.hasTrigger) return "Add a trigger first";
|
|
2559
|
+
if (readiness.firstIncomplete) return "You have incomplete steps";
|
|
2560
|
+
return "Checking the steps…";
|
|
2561
|
+
}
|
|
2562
|
+
function usePublish(callbacks) {
|
|
2563
|
+
const [publishing, setPublishing] = useState(false);
|
|
2564
|
+
const [error, setError] = useState(null);
|
|
2565
|
+
const publish = () => {
|
|
2566
|
+
if (publishing) return;
|
|
2567
|
+
setPublishing(true);
|
|
2568
|
+
setError(null);
|
|
2569
|
+
callbacks.publish().catch((cause) => setError(cause instanceof Error ? cause.message : String(cause))).finally(() => setPublishing(false));
|
|
2570
|
+
};
|
|
2571
|
+
return {
|
|
2572
|
+
publishing,
|
|
2573
|
+
error,
|
|
2574
|
+
publish
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2577
|
+
function PublishButton(props) {
|
|
2578
|
+
const { model, readiness } = props;
|
|
2579
|
+
if (props.signIn?.required) return /* @__PURE__ */ jsx(Tooltip, {
|
|
2580
|
+
content: "This Switchboard enforces document permissions, so a publish must be signed",
|
|
2581
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
2582
|
+
size: props.size ?? "sm",
|
|
2583
|
+
variant: "primary",
|
|
2584
|
+
disabled: props.signIn.pending,
|
|
2585
|
+
onClick: props.signIn.login,
|
|
2586
|
+
children: "Sign in to publish"
|
|
2587
|
+
})
|
|
2588
|
+
});
|
|
2589
|
+
const incomplete = !readiness.ready;
|
|
2590
|
+
const changes = hasDraftChanges(model);
|
|
2591
|
+
const target = readiness.firstIncomplete;
|
|
2592
|
+
const select = () => {
|
|
2593
|
+
if (target) props.onSelect(target);
|
|
2594
|
+
};
|
|
2595
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
2596
|
+
enabled: incomplete,
|
|
2597
|
+
content: /* @__PURE__ */ jsx("button", {
|
|
2598
|
+
type: "button",
|
|
2599
|
+
className: "font-medium text-wf-warn hover:underline",
|
|
2600
|
+
onClick: select,
|
|
2601
|
+
children: blockedReason(readiness)
|
|
2602
|
+
}),
|
|
2603
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
2604
|
+
className: "inline-flex",
|
|
2605
|
+
onClick: incomplete ? select : void 0,
|
|
2606
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
2607
|
+
size: props.size ?? "sm",
|
|
2608
|
+
variant: "primary",
|
|
2609
|
+
disabled: incomplete || !changes || props.publishing,
|
|
2610
|
+
title: !changes && !incomplete ? "No unpublished changes" : void 0,
|
|
2611
|
+
onClick: props.onPublish,
|
|
2612
|
+
children: props.publishing ? "Publishing…" : "Publish"
|
|
2613
|
+
})
|
|
2614
|
+
})
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
function PublishState(props) {
|
|
2618
|
+
const draft = hasDraftChanges(props.model);
|
|
2619
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
2620
|
+
className: "flex shrink-0 items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground",
|
|
2621
|
+
title: props.model.published ? `Published ${new Date(props.model.published.publishedAt).toLocaleString()}` : "Never published",
|
|
2622
|
+
children: [
|
|
2623
|
+
/* @__PURE__ */ jsx("span", {
|
|
2624
|
+
"aria-hidden": true,
|
|
2625
|
+
className: `h-2 w-2 rounded-full ${draft ? "bg-wf-warn" : "bg-wf-ok"}`
|
|
2626
|
+
}),
|
|
2627
|
+
/* @__PURE__ */ jsx("span", { children: !props.model.published ? "Draft" : draft ? "Unpublished changes" : "Published" }),
|
|
2628
|
+
props.model.published && draft ? /* @__PURE__ */ jsxs("span", {
|
|
2629
|
+
className: "text-muted-foreground/80",
|
|
2630
|
+
children: [
|
|
2631
|
+
"· v",
|
|
2632
|
+
props.model.published.version,
|
|
2633
|
+
" live"
|
|
2634
|
+
]
|
|
2635
|
+
}) : null
|
|
2636
|
+
]
|
|
2637
|
+
});
|
|
2638
|
+
}
|
|
2639
|
+
function StatusToggle(props) {
|
|
2640
|
+
const allowed = props.published;
|
|
2641
|
+
const on = props.status === "ENABLED";
|
|
2642
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
2643
|
+
enabled: !allowed,
|
|
2644
|
+
content: "Publish the workflow first",
|
|
2645
|
+
align: "end",
|
|
2646
|
+
side: props.tooltipSide,
|
|
2647
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
2648
|
+
className: "flex items-center gap-2 text-xs text-muted-foreground",
|
|
2649
|
+
children: [/* @__PURE__ */ jsx(Toggle, {
|
|
2650
|
+
checked: on,
|
|
2651
|
+
disabled: !allowed,
|
|
2652
|
+
label: on ? "Turn the workflow off" : "Turn the workflow on",
|
|
2653
|
+
onChange: (checked) => props.onChange(checked ? "ENABLED" : "DISABLED")
|
|
2654
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2655
|
+
className: "w-6",
|
|
2656
|
+
children: on ? "On" : "Off"
|
|
2657
|
+
})]
|
|
2658
|
+
})
|
|
2659
|
+
});
|
|
2660
|
+
}
|
|
2661
|
+
function PublishedMissingNote(props) {
|
|
2662
|
+
if (props.missing.length === 0) return null;
|
|
2663
|
+
return /* @__PURE__ */ jsx("span", {
|
|
2664
|
+
role: "alert",
|
|
2665
|
+
"aria-label": "Published version incomplete",
|
|
2666
|
+
className: "shrink-0 whitespace-nowrap rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs text-wf-warn",
|
|
2667
|
+
title: `The published version is missing a reactor connection on: ${props.missing.join(", ")}`,
|
|
2668
|
+
children: "Live version incomplete"
|
|
2669
|
+
});
|
|
2670
|
+
}
|
|
2671
|
+
function ReactorDenialNote(props) {
|
|
2672
|
+
if (!props.denial) return null;
|
|
2673
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
2674
|
+
role: "alert",
|
|
2675
|
+
"aria-label": "Reactor access denied",
|
|
2676
|
+
className: "max-w-80 truncate rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs text-wf-warn",
|
|
2677
|
+
title: props.denial,
|
|
2678
|
+
children: ["No reactor access: ", props.denial]
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2681
|
+
/** Instead of the draft banner on a managed workflow: who keeps it, and that edits here are not saved. */
|
|
2682
|
+
function ManagedBanner(props) {
|
|
2683
|
+
const manager = props.model.managedBy;
|
|
2684
|
+
if (!manager) return null;
|
|
2685
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2686
|
+
role: "status",
|
|
2687
|
+
className: "pointer-events-auto flex max-w-xl items-center gap-3 rounded-lg border border-solid border-foreground/10 bg-card px-3 py-1.5 text-[13px] shadow-sm",
|
|
2688
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2689
|
+
className: "h-2 w-2 shrink-0 rounded-full bg-muted-foreground",
|
|
2690
|
+
"aria-hidden": true
|
|
2691
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
2692
|
+
className: "text-foreground",
|
|
2693
|
+
children: [
|
|
2694
|
+
"Managed by ",
|
|
2695
|
+
/* @__PURE__ */ jsx("strong", { children: manager.label || manager.documentType }),
|
|
2696
|
+
". Change it there: edits here are not saved."
|
|
2697
|
+
]
|
|
2698
|
+
})]
|
|
2699
|
+
});
|
|
2700
|
+
}
|
|
2701
|
+
function DraftBanner(props) {
|
|
2702
|
+
if (!hasDraftChanges(props.model)) return null;
|
|
2703
|
+
const { readiness } = props;
|
|
2704
|
+
const target = readiness.firstIncomplete;
|
|
2705
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2706
|
+
role: "status",
|
|
2707
|
+
className: "pointer-events-auto flex items-center gap-3 rounded-lg border border-solid border-foreground/10 bg-card py-1.5 pl-3 pr-1.5 text-[13px] shadow-sm",
|
|
2708
|
+
children: [
|
|
2709
|
+
/* @__PURE__ */ jsx("span", {
|
|
2710
|
+
className: "h-2 w-2 shrink-0 rounded-full bg-wf-warn",
|
|
2711
|
+
"aria-hidden": true
|
|
2712
|
+
}),
|
|
2713
|
+
/* @__PURE__ */ jsx("span", {
|
|
2714
|
+
className: "text-foreground",
|
|
2715
|
+
children: "You have unpublished changes"
|
|
2716
|
+
}),
|
|
2717
|
+
props.error ? /* @__PURE__ */ jsx("span", {
|
|
2718
|
+
className: "text-xs text-wf-fail",
|
|
2719
|
+
children: props.error
|
|
2720
|
+
}) : null,
|
|
2721
|
+
!readiness.hasTrigger || target ? /* @__PURE__ */ jsxs("span", {
|
|
2722
|
+
className: "flex items-center gap-1.5 text-xs text-wf-warn",
|
|
2723
|
+
children: [/* @__PURE__ */ jsx("span", { children: target ? "Incomplete steps" : "No trigger yet" }), target ? /* @__PURE__ */ jsx("button", {
|
|
2724
|
+
type: "button",
|
|
2725
|
+
className: "font-medium underline underline-offset-2 hover:no-underline",
|
|
2726
|
+
onClick: () => props.onSelect(target),
|
|
2727
|
+
children: "Show"
|
|
2728
|
+
}) : null]
|
|
2729
|
+
}) : null,
|
|
2730
|
+
/* @__PURE__ */ jsxs("span", {
|
|
2731
|
+
className: "flex items-center gap-1",
|
|
2732
|
+
children: [props.model.published ? /* @__PURE__ */ jsx(Button, {
|
|
2733
|
+
size: "sm",
|
|
2734
|
+
variant: "ghost",
|
|
2735
|
+
onClick: props.onDiscard,
|
|
2736
|
+
children: "Discard changes"
|
|
2737
|
+
}) : null, /* @__PURE__ */ jsx(PublishButton, {
|
|
2738
|
+
model: props.model,
|
|
2739
|
+
readiness,
|
|
2740
|
+
publishing: props.publishing,
|
|
2741
|
+
onPublish: props.onPublish,
|
|
2742
|
+
onSelect: props.onSelect,
|
|
2743
|
+
signIn: props.signIn
|
|
2744
|
+
})]
|
|
2745
|
+
})
|
|
2746
|
+
]
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
//#endregion
|
|
2750
|
+
//#region editors/workflow-editor/ui/StepError.tsx
|
|
2751
|
+
function StepError(props) {
|
|
2752
|
+
return /* @__PURE__ */ jsx("pre", {
|
|
2753
|
+
className: "overflow-auto whitespace-pre-wrap rounded-md bg-wf-fail/10 p-2.5 text-xs text-wf-fail",
|
|
2754
|
+
children: props.error
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
//#endregion
|
|
2753
2758
|
//#region editors/shared/document-ref.tsx
|
|
2754
2759
|
const SHOWN = 3;
|
|
2755
2760
|
function shortId(id) {
|
|
@@ -2818,7 +2823,7 @@ function DocumentRefs(props) {
|
|
|
2818
2823
|
}
|
|
2819
2824
|
//#endregion
|
|
2820
2825
|
//#region editors/shared/data-viewer.tsx
|
|
2821
|
-
const DataTree = lazy(() => import("./data-tree-
|
|
2826
|
+
const DataTree = lazy(() => import("./data-tree-DAw8e0j8.js"));
|
|
2822
2827
|
function stringify(value) {
|
|
2823
2828
|
try {
|
|
2824
2829
|
return JSON.stringify(value, null, 2) ?? "";
|
|
@@ -3035,6 +3040,6 @@ function describeTrigger(trigger) {
|
|
|
3035
3040
|
}
|
|
3036
3041
|
}
|
|
3037
3042
|
//#endregion
|
|
3038
|
-
export {
|
|
3043
|
+
export { EMPTY_SCOPE as A, menuHeight as B, useSecretRef as C, ExpressionTargetProvider as D, ExpressionScopeSourceProvider as E, parseTypedValue as F, usePendingEcho as H, valueMismatch as I, documentShape as L, VARIABLE_TYPES as M, VARIABLE_TYPE_LABEL as N, ExpressionTokenLine as O, convertVariableValue as P, stateFieldsFromSdl as R, withPropDefaults as S, ExpressionPickerPopup as T, menuPosition as V, uniqueStepKey as _, StepError as a, PropertyForm as b, PublishButton as c, ReactorDenialNote as d, StatusToggle as f, hasDraftChanges as g, VARIABLES_VIEW as h, DataViewer as i, buildExpressionScope as j, useExpressionField as k, PublishState as l, STEP_PARAM as m, describeSchedule as n, DraftBanner as o, usePublish as p, describeTrigger as r, ManagedBanner as s, describeCron as t, PublishedMissingNote as u, AvailableSoon as v, ExpressionPickerButton as w, lacksDefaults as x, PiecePlaceholderContext as y, contextMenuItems as z };
|
|
3039
3044
|
|
|
3040
|
-
//# sourceMappingURL=trigger-text-
|
|
3045
|
+
//# sourceMappingURL=trigger-text-BSVi5oGZ.js.map
|