@solidxai/core-ui 0.1.13-beta.6 → 0.1.14-beta.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.
- package/dist/components/common/SolidPopupContainer.d.ts.map +1 -1
- package/dist/components/common/SolidPopupContainer.js +68 -5
- package/dist/components/common/SolidPopupContainer.js.map +1 -1
- package/dist/components/common/SolidPopupContainer.tsx +50 -4
- package/dist/components/core/card/SolidCardViewConfigure.d.ts.map +1 -1
- package/dist/components/core/card/SolidCardViewConfigure.js +1 -1
- package/dist/components/core/card/SolidCardViewConfigure.js.map +1 -1
- package/dist/components/core/card/SolidCardViewConfigure.tsx +3 -1
- package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.d.ts +2 -0
- package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.js +4 -0
- package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.js.map +1 -0
- package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.ts +3 -0
- package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.d.ts +8 -0
- package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.js +9 -0
- package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.js.map +1 -0
- package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.ts +17 -0
- package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
- package/dist/components/core/form/SolidFormView.js +52 -22
- package/dist/components/core/form/SolidFormView.js.map +1 -1
- package/dist/components/core/form/SolidFormView.tsx +49 -9
- package/dist/components/core/kanban/SolidKanbanViewConfigure.d.ts.map +1 -1
- package/dist/components/core/kanban/SolidKanbanViewConfigure.js +1 -1
- package/dist/components/core/kanban/SolidKanbanViewConfigure.js.map +1 -1
- package/dist/components/core/kanban/SolidKanbanViewConfigure.tsx +3 -1
- package/dist/components/core/list/SolidCustomListViewColumn.d.ts +2 -1
- package/dist/components/core/list/SolidCustomListViewColumn.d.ts.map +1 -1
- package/dist/components/core/list/SolidCustomListViewColumn.js +3 -2
- package/dist/components/core/list/SolidCustomListViewColumn.js.map +1 -1
- package/dist/components/core/list/SolidCustomListViewColumn.tsx +4 -1
- package/dist/components/core/list/SolidListView.d.ts.map +1 -1
- package/dist/components/core/list/SolidListView.js +75 -71
- package/dist/components/core/list/SolidListView.js.map +1 -1
- package/dist/components/core/list/SolidListView.tsx +25 -10
- package/dist/components/core/list/SolidListViewColumn.d.ts +3 -1
- package/dist/components/core/list/SolidListViewColumn.d.ts.map +1 -1
- package/dist/components/core/list/SolidListViewColumn.js +81 -42
- package/dist/components/core/list/SolidListViewColumn.js.map +1 -1
- package/dist/components/core/list/SolidListViewColumn.tsx +93 -44
- package/dist/components/core/list/SolidListViewConfigure.d.ts.map +1 -1
- package/dist/components/core/list/SolidListViewConfigure.js +2 -2
- package/dist/components/core/list/SolidListViewConfigure.js.map +1 -1
- package/dist/components/core/list/SolidListViewConfigure.tsx +4 -2
- package/dist/components/core/list/widgets/PillWidget.d.ts +3 -0
- package/dist/components/core/list/widgets/PillWidget.d.ts.map +1 -0
- package/dist/components/core/list/widgets/PillWidget.js +95 -0
- package/dist/components/core/list/widgets/PillWidget.js.map +1 -0
- package/dist/components/core/list/widgets/PillWidget.tsx +127 -0
- package/dist/components/shad-cn-ui/SolidDialog.js +1 -1
- package/dist/components/shad-cn-ui/SolidDialog.js.map +1 -1
- package/dist/components/shad-cn-ui/SolidDialog.tsx +1 -1
- package/dist/components/shad-cn-ui/SolidDropdownMenu.d.ts +3 -1
- package/dist/components/shad-cn-ui/SolidDropdownMenu.d.ts.map +1 -1
- package/dist/components/shad-cn-ui/SolidDropdownMenu.js +2 -2
- package/dist/components/shad-cn-ui/SolidDropdownMenu.js.map +1 -1
- package/dist/components/shad-cn-ui/SolidDropdownMenu.tsx +11 -5
- package/dist/components/shad-cn-ui/SolidIcon.d.ts +2 -1
- package/dist/components/shad-cn-ui/SolidIcon.d.ts.map +1 -1
- package/dist/components/shad-cn-ui/SolidIcon.js +2 -1
- package/dist/components/shad-cn-ui/SolidIcon.js.map +1 -1
- package/dist/components/shad-cn-ui/SolidIcon.tsx +2 -0
- package/dist/components/workflow/WorkflowFlowCanvas.css +454 -0
- package/dist/components/workflow/WorkflowFlowCanvas.d.ts +40 -0
- package/dist/components/workflow/WorkflowFlowCanvas.d.ts.map +1 -0
- package/dist/components/workflow/WorkflowFlowCanvas.js +861 -0
- package/dist/components/workflow/WorkflowFlowCanvas.js.map +1 -0
- package/dist/components/workflow/WorkflowFlowCanvas.tsx +1522 -0
- package/dist/components/workflow/WorkflowNodeDocsPanel.css +247 -0
- package/dist/components/workflow/WorkflowNodeDocsPanel.d.ts +22 -0
- package/dist/components/workflow/WorkflowNodeDocsPanel.d.ts.map +1 -0
- package/dist/components/workflow/WorkflowNodeDocsPanel.js +97 -0
- package/dist/components/workflow/WorkflowNodeDocsPanel.js.map +1 -0
- package/dist/components/workflow/WorkflowNodeDocsPanel.tsx +363 -0
- package/dist/components/workflow/WorkflowNodeSchemaEditor.css +802 -0
- package/dist/components/workflow/WorkflowNodeSchemaEditor.d.ts +72 -0
- package/dist/components/workflow/WorkflowNodeSchemaEditor.d.ts.map +1 -0
- package/dist/components/workflow/WorkflowNodeSchemaEditor.js +1107 -0
- package/dist/components/workflow/WorkflowNodeSchemaEditor.js.map +1 -0
- package/dist/components/workflow/WorkflowNodeSchemaEditor.tsx +2347 -0
- package/dist/helpers/registry.d.ts.map +1 -1
- package/dist/helpers/registry.js +7 -0
- package/dist/helpers/registry.js.map +1 -1
- package/dist/helpers/registry.ts +8 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/index.ts +37 -0
- package/dist/redux/api/workflowDefinitionEditorApi.d.ts +17 -0
- package/dist/redux/api/workflowDefinitionEditorApi.d.ts.map +1 -0
- package/dist/redux/api/workflowDefinitionEditorApi.js +38 -0
- package/dist/redux/api/workflowDefinitionEditorApi.js.map +1 -0
- package/dist/redux/api/workflowDefinitionEditorApi.ts +40 -0
- package/dist/redux/api/workflowNodeApi.d.ts +6 -0
- package/dist/redux/api/workflowNodeApi.d.ts.map +1 -0
- package/dist/redux/api/workflowNodeApi.js +14 -0
- package/dist/redux/api/workflowNodeApi.js.map +1 -0
- package/dist/redux/api/workflowNodeApi.ts +18 -0
- package/dist/redux/features/popupSlice.d.ts +17 -2
- package/dist/redux/features/popupSlice.d.ts.map +1 -1
- package/dist/redux/features/popupSlice.js.map +1 -1
- package/dist/redux/features/popupSlice.ts +19 -3
- package/dist/redux/store/defaultStoreConfig.d.ts +13 -0
- package/dist/redux/store/defaultStoreConfig.d.ts.map +1 -1
- package/dist/redux/store/defaultStoreConfig.js +4 -0
- package/dist/redux/store/defaultStoreConfig.js.map +1 -1
- package/dist/redux/store/defaultStoreConfig.ts +4 -0
- package/dist/redux/store/solidEntityApiPool.d.ts.map +1 -1
- package/dist/redux/store/solidEntityApiPool.js +1 -0
- package/dist/redux/store/solidEntityApiPool.js.map +1 -1
- package/dist/redux/store/solidEntityApiPool.ts +1 -0
- package/dist/resources/solid-custom.css +16 -0
- package/dist/resources/solid-tailwind-generated.css +1 -1
- package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.css +3194 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.d.ts +3 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.d.ts.map +1 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.js +3371 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.js.map +1 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.tsx +6215 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.css +217 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.d.ts +3 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.d.ts.map +1 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.js +268 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.js.map +1 -0
- package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.tsx +510 -0
- package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.d.ts +3 -0
- package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.d.ts.map +1 -0
- package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.js +618 -0
- package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.js.map +1 -0
- package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.tsx +1322 -0
- package/dist/routes/solidRoutes.d.ts.map +1 -1
- package/dist/routes/solidRoutes.js +6 -0
- package/dist/routes/solidRoutes.js.map +1 -1
- package/dist/routes/solidRoutes.tsx +6 -0
- package/dist/types/extension-registry.d.ts +4 -0
- package/dist/types/extension-registry.d.ts.map +1 -1
- package/dist/types/extension-registry.js +5 -1
- package/dist/types/extension-registry.js.map +1 -1
- package/dist/types/extension-registry.ts +5 -1
- package/dist/types/solid-core.d.ts +32 -0
- package/dist/types/workflow-node.d.ts +142 -0
- package/dist/types/workflow-node.d.ts.map +1 -0
- package/dist/types/workflow-node.js +2 -0
- package/dist/types/workflow-node.js.map +1 -0
- package/dist/types/workflow-node.ts +179 -0
- package/package.json +3 -1
|
@@ -0,0 +1,3371 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
57
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
58
|
+
import { Activity, ArrowLeft, Braces, ChevronRight, Copy, Workflow, Layers3, Play, Search, Save, ShieldCheck, Trash2, X, } from "lucide-react";
|
|
59
|
+
import React from "react";
|
|
60
|
+
import { useNavigate, useParams } from "react-router-dom";
|
|
61
|
+
import { useDispatch } from "react-redux";
|
|
62
|
+
import qs from "qs";
|
|
63
|
+
import YAML from "yaml";
|
|
64
|
+
import { createSolidEntityApi } from "../../../../redux/api/solidEntityApi";
|
|
65
|
+
import { useGetmodulesQuery } from "../../../../redux/api/moduleApi";
|
|
66
|
+
import { useGetWorkflowNodeTypesQuery } from "../../../../redux/api/workflowNodeApi";
|
|
67
|
+
import { useExecuteWorkflowDefinitionMutation, useValidateWorkflowDefinitionMutation, } from "../../../../redux/api/workflowDefinitionEditorApi";
|
|
68
|
+
import { showToast } from "../../../../redux/features/toastSlice";
|
|
69
|
+
import { WorkflowNodeDocsPanel, } from "../../../../components/workflow/WorkflowNodeDocsPanel";
|
|
70
|
+
import { WorkflowFlowCanvas, } from "../../../../components/workflow/WorkflowFlowCanvas";
|
|
71
|
+
import { WorkflowAddNodeDialog, WorkflowExpressionAutocompleteField, WorkflowNodeEditorDialog, } from "../../../../components/workflow/WorkflowNodeSchemaEditor";
|
|
72
|
+
import { SolidAutocomplete, SolidButton, SolidCheckbox, SolidCodeEditor, SolidDatePicker, SolidDialog, SolidDialogBody, SolidInput, SolidPanel, SolidSelect, SolidSpinner, SolidTabGroup, SolidTag, SolidTextarea, } from "../../../../components/shad-cn-ui";
|
|
73
|
+
import { SolidJsonEditor } from "../../../../components/core/json/SolidJsonEditor";
|
|
74
|
+
import "./WorkflowDefinitionEditorPage.css";
|
|
75
|
+
var RESERVED_WORKFLOW_MODULE_NAMES = new Set(["solid-core"]);
|
|
76
|
+
function isWorkflowModuleSelectable(module) {
|
|
77
|
+
var _a;
|
|
78
|
+
var moduleName = String((_a = module === null || module === void 0 ? void 0 : module.name) !== null && _a !== void 0 ? _a : "").trim();
|
|
79
|
+
return Boolean(moduleName) && !RESERVED_WORKFLOW_MODULE_NAMES.has(moduleName);
|
|
80
|
+
}
|
|
81
|
+
var createEmptyWorkflowDefinition = function () { return ({
|
|
82
|
+
version: "1.0.0",
|
|
83
|
+
description: "",
|
|
84
|
+
inputs: {},
|
|
85
|
+
variables: {},
|
|
86
|
+
nodes: [],
|
|
87
|
+
triggers: [],
|
|
88
|
+
metadata: {},
|
|
89
|
+
}); };
|
|
90
|
+
var TOPOLOGY_SPLIT_STORAGE_KEY = "solid.workflow.editor.topologySplitPercent";
|
|
91
|
+
var WORKFLOW_STATUS_OPTIONS = [
|
|
92
|
+
{ label: "Draft", value: "draft" },
|
|
93
|
+
{ label: "Active", value: "active" },
|
|
94
|
+
{ label: "Inactive", value: "inactive" },
|
|
95
|
+
];
|
|
96
|
+
var WORKFLOW_INPUT_TYPE_OPTIONS = [
|
|
97
|
+
{ label: "String", value: "string" },
|
|
98
|
+
{ label: "Number", value: "number" },
|
|
99
|
+
{ label: "Boolean", value: "boolean" },
|
|
100
|
+
{ label: "Date", value: "date" },
|
|
101
|
+
{ label: "Object", value: "object" },
|
|
102
|
+
{ label: "Array", value: "array" },
|
|
103
|
+
];
|
|
104
|
+
var WORKFLOW_TRIGGER_GUIDE_OPTIONS = [
|
|
105
|
+
{
|
|
106
|
+
label: "CURL",
|
|
107
|
+
value: "curl",
|
|
108
|
+
description: "Run this workflow through the authenticated execution endpoint.",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: "API",
|
|
112
|
+
value: "api",
|
|
113
|
+
description: "Call this workflow from a SolidX service, subscriber, or job.",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: "Scheduled",
|
|
117
|
+
value: "scheduled",
|
|
118
|
+
description: "Persist CRON metadata so the scheduler can run this workflow.",
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
var WORKFLOW_EXECUTION_STATUS_OPTIONS = [
|
|
122
|
+
{ label: "All statuses", value: "all" },
|
|
123
|
+
{ label: "Success", value: "success" },
|
|
124
|
+
{ label: "Failed", value: "failed" },
|
|
125
|
+
{ label: "Running", value: "running" },
|
|
126
|
+
{ label: "Pending", value: "pending" },
|
|
127
|
+
];
|
|
128
|
+
var WORKFLOW_EXECUTION_PAGE_SIZE = 25;
|
|
129
|
+
var WORKFLOW_LOG_LEVEL_OPTIONS = [
|
|
130
|
+
{ label: "All levels", value: "all" },
|
|
131
|
+
{ label: "Debug", value: "debug" },
|
|
132
|
+
{ label: "Info", value: "info" },
|
|
133
|
+
{ label: "Warn", value: "warn" },
|
|
134
|
+
{ label: "Error", value: "error" },
|
|
135
|
+
];
|
|
136
|
+
var WORKFLOW_CRON_EXAMPLES = [
|
|
137
|
+
{ label: "Every hour", value: "0 * * * *" },
|
|
138
|
+
{ label: "Weekdays at 9 AM", value: "0 9 * * 1-5" },
|
|
139
|
+
{ label: "Mondays at 2 AM", value: "0 2 * * 1" },
|
|
140
|
+
{ label: "Daily midnight", value: "0 0 * * *" },
|
|
141
|
+
];
|
|
142
|
+
var WORKFLOW_CRON_FIELD_HELP = [
|
|
143
|
+
{ key: "minute", label: "Minute", placeholder: "0", help: "0-59, * or */5" },
|
|
144
|
+
{ key: "hour", label: "Hour", placeholder: "9", help: "0-23, * or */2" },
|
|
145
|
+
{ key: "dayOfMonth", label: "Day", placeholder: "*", help: "1-31 or *" },
|
|
146
|
+
{ key: "month", label: "Month", placeholder: "*", help: "1-12 or *" },
|
|
147
|
+
{ key: "dayOfWeek", label: "Weekday", placeholder: "*", help: "0-7, 1-5 or *" },
|
|
148
|
+
];
|
|
149
|
+
function readStoredTopologySplitPercent() {
|
|
150
|
+
if (typeof window === "undefined") {
|
|
151
|
+
return 62;
|
|
152
|
+
}
|
|
153
|
+
var storedValue = Number(window.localStorage.getItem(TOPOLOGY_SPLIT_STORAGE_KEY));
|
|
154
|
+
return Number.isFinite(storedValue) ? Math.min(78, Math.max(22, storedValue)) : 62;
|
|
155
|
+
}
|
|
156
|
+
function splitCronExpression(expression) {
|
|
157
|
+
var _a, _b, _c, _d, _e;
|
|
158
|
+
var parts = String(expression !== null && expression !== void 0 ? expression : "").trim().split(/\s+/).filter(Boolean);
|
|
159
|
+
var normalized = parts.length === 5 ? parts : ["0", "9", "*", "*", "*"];
|
|
160
|
+
return {
|
|
161
|
+
minute: (_a = normalized[0]) !== null && _a !== void 0 ? _a : "0",
|
|
162
|
+
hour: (_b = normalized[1]) !== null && _b !== void 0 ? _b : "9",
|
|
163
|
+
dayOfMonth: (_c = normalized[2]) !== null && _c !== void 0 ? _c : "*",
|
|
164
|
+
month: (_d = normalized[3]) !== null && _d !== void 0 ? _d : "*",
|
|
165
|
+
dayOfWeek: (_e = normalized[4]) !== null && _e !== void 0 ? _e : "*",
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function joinCronExpression(parts) {
|
|
169
|
+
return [
|
|
170
|
+
parts.minute || "*",
|
|
171
|
+
parts.hour || "*",
|
|
172
|
+
parts.dayOfMonth || "*",
|
|
173
|
+
parts.month || "*",
|
|
174
|
+
parts.dayOfWeek || "*",
|
|
175
|
+
].join(" ");
|
|
176
|
+
}
|
|
177
|
+
function isValidSimpleCronExpression(expression) {
|
|
178
|
+
return String(expression !== null && expression !== void 0 ? expression : "").trim().split(/\s+/).filter(Boolean).length === 5;
|
|
179
|
+
}
|
|
180
|
+
function isNumericCronPart(value) {
|
|
181
|
+
return /^\d+$/.test(String(value !== null && value !== void 0 ? value : ""));
|
|
182
|
+
}
|
|
183
|
+
function getCronMinuteStep(value) {
|
|
184
|
+
var _a;
|
|
185
|
+
var match = String(value !== null && value !== void 0 ? value : "").match(/^\*\/(\d+)$/);
|
|
186
|
+
return (_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : null;
|
|
187
|
+
}
|
|
188
|
+
function formatCronNumber(value) {
|
|
189
|
+
return String(Number(value)).padStart(2, "0");
|
|
190
|
+
}
|
|
191
|
+
function describeCronList(value) {
|
|
192
|
+
var items = String(value !== null && value !== void 0 ? value : "")
|
|
193
|
+
.split(",")
|
|
194
|
+
.map(function (item) { return item.trim(); })
|
|
195
|
+
.filter(Boolean);
|
|
196
|
+
if (items.length <= 1) {
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
if (items.length === 2) {
|
|
200
|
+
return items.join(" and ");
|
|
201
|
+
}
|
|
202
|
+
return "".concat(items.slice(0, -1).join(", "), " and ").concat(items[items.length - 1]);
|
|
203
|
+
}
|
|
204
|
+
function describeCronMonthScope(month) {
|
|
205
|
+
if (month === "*") {
|
|
206
|
+
return "";
|
|
207
|
+
}
|
|
208
|
+
if (/^\d+(,\d+)*$/.test(month)) {
|
|
209
|
+
return " in months ".concat(describeCronList(month));
|
|
210
|
+
}
|
|
211
|
+
return " in month ".concat(month);
|
|
212
|
+
}
|
|
213
|
+
function describeCronDateScope(dayOfMonth) {
|
|
214
|
+
if (dayOfMonth === "*") {
|
|
215
|
+
return "";
|
|
216
|
+
}
|
|
217
|
+
if (/^\d+(,\d+)*$/.test(dayOfMonth)) {
|
|
218
|
+
return " on dates ".concat(describeCronList(dayOfMonth));
|
|
219
|
+
}
|
|
220
|
+
return " on day ".concat(dayOfMonth);
|
|
221
|
+
}
|
|
222
|
+
function describeCronWeekdayScope(dayOfWeek) {
|
|
223
|
+
if (dayOfWeek === "*") {
|
|
224
|
+
return "";
|
|
225
|
+
}
|
|
226
|
+
if (dayOfWeek === "1") {
|
|
227
|
+
return " on Mondays";
|
|
228
|
+
}
|
|
229
|
+
if (dayOfWeek === "1-5") {
|
|
230
|
+
return " on weekdays";
|
|
231
|
+
}
|
|
232
|
+
if (dayOfWeek === "0" || dayOfWeek === "7") {
|
|
233
|
+
return " on Sundays";
|
|
234
|
+
}
|
|
235
|
+
return " on weekday ".concat(dayOfWeek);
|
|
236
|
+
}
|
|
237
|
+
function describeCronCalendarScope(dayOfMonth, month, dayOfWeek) {
|
|
238
|
+
return [
|
|
239
|
+
describeCronDateScope(dayOfMonth),
|
|
240
|
+
describeCronWeekdayScope(dayOfWeek),
|
|
241
|
+
describeCronMonthScope(month),
|
|
242
|
+
].join("");
|
|
243
|
+
}
|
|
244
|
+
function describeWorkflowCronExpression(expression, timezone) {
|
|
245
|
+
if (timezone === void 0) { timezone = "UTC"; }
|
|
246
|
+
var cron = String(expression !== null && expression !== void 0 ? expression : "").trim();
|
|
247
|
+
if (!isValidSimpleCronExpression(cron)) {
|
|
248
|
+
return "Enter exactly five CRON fields: minute hour day month weekday.";
|
|
249
|
+
}
|
|
250
|
+
var parts = splitCronExpression(cron);
|
|
251
|
+
var numericHour = isNumericCronPart(parts.hour) ? formatCronNumber(parts.hour) : null;
|
|
252
|
+
var numericMinute = isNumericCronPart(parts.minute) ? formatCronNumber(parts.minute) : null;
|
|
253
|
+
var minuteStep = getCronMinuteStep(parts.minute);
|
|
254
|
+
var time = numericHour && numericMinute ? "".concat(numericHour, ":").concat(numericMinute) : null;
|
|
255
|
+
var timezoneSuffix = timezone ? " (".concat(timezone, ")") : "";
|
|
256
|
+
var calendarScope = describeCronCalendarScope(parts.dayOfMonth, parts.month, parts.dayOfWeek);
|
|
257
|
+
if (cron === "* * * * *") {
|
|
258
|
+
return "Runs every minute".concat(timezoneSuffix, ".");
|
|
259
|
+
}
|
|
260
|
+
if (/^\*\/\d+$/.test(parts.minute) &&
|
|
261
|
+
parts.hour === "*" &&
|
|
262
|
+
parts.dayOfMonth === "*" &&
|
|
263
|
+
parts.month === "*" &&
|
|
264
|
+
parts.dayOfWeek === "*") {
|
|
265
|
+
return "Runs every ".concat(parts.minute.replace("*/", ""), " minutes").concat(timezoneSuffix, ".");
|
|
266
|
+
}
|
|
267
|
+
if (minuteStep && numericHour) {
|
|
268
|
+
return "Runs every ".concat(minuteStep, " minutes between ").concat(numericHour, ":00 and ").concat(numericHour, ":59").concat(calendarScope).concat(timezoneSuffix, ".");
|
|
269
|
+
}
|
|
270
|
+
if (time && parts.dayOfMonth === "*" && parts.month === "*" && parts.dayOfWeek === "*") {
|
|
271
|
+
return "Runs every day at ".concat(time).concat(timezoneSuffix, ".");
|
|
272
|
+
}
|
|
273
|
+
if (time && parts.dayOfMonth === "*" && parts.month === "*" && parts.dayOfWeek === "1") {
|
|
274
|
+
return "Runs every Monday at ".concat(time).concat(timezoneSuffix, ".");
|
|
275
|
+
}
|
|
276
|
+
if (time && parts.dayOfMonth === "*" && parts.month === "*" && parts.dayOfWeek === "1-5") {
|
|
277
|
+
return "Runs every weekday at ".concat(time).concat(timezoneSuffix, ".");
|
|
278
|
+
}
|
|
279
|
+
if (time) {
|
|
280
|
+
return "Runs at ".concat(time).concat(calendarScope).concat(timezoneSuffix, ".");
|
|
281
|
+
}
|
|
282
|
+
return "Runs on the schedule ".concat(cron).concat(timezoneSuffix, ".");
|
|
283
|
+
}
|
|
284
|
+
function workflowInputHasDefault(value) {
|
|
285
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
286
|
+
return (Object.prototype.hasOwnProperty.call(value, "default") &&
|
|
287
|
+
value.default !== undefined &&
|
|
288
|
+
value.default !== null);
|
|
289
|
+
}
|
|
290
|
+
return value !== undefined && value !== null;
|
|
291
|
+
}
|
|
292
|
+
function isWorkflowExpressionString(value) {
|
|
293
|
+
return typeof value === "string" && /^\s*\{\{\s*.+?\s*\}\}\s*$/.test(value);
|
|
294
|
+
}
|
|
295
|
+
function serializeWorkflowDefinitionYaml(definition) {
|
|
296
|
+
return YAML.stringify(definition);
|
|
297
|
+
}
|
|
298
|
+
function serializeJsonDtoValue(value, fallback) {
|
|
299
|
+
if (fallback === void 0) { fallback = null; }
|
|
300
|
+
if (typeof value === "string") {
|
|
301
|
+
return value;
|
|
302
|
+
}
|
|
303
|
+
return JSON.stringify(value !== null && value !== void 0 ? value : fallback);
|
|
304
|
+
}
|
|
305
|
+
function formatReadonlyJson(value, emptyValue) {
|
|
306
|
+
if (emptyValue === void 0) { emptyValue = "{}"; }
|
|
307
|
+
if (value === undefined || value === null || value === "") {
|
|
308
|
+
return emptyValue;
|
|
309
|
+
}
|
|
310
|
+
if (typeof value === "string") {
|
|
311
|
+
try {
|
|
312
|
+
return JSON.stringify(JSON.parse(value), null, 2);
|
|
313
|
+
}
|
|
314
|
+
catch (_a) {
|
|
315
|
+
return value;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return JSON.stringify(value, null, 2);
|
|
319
|
+
}
|
|
320
|
+
function formatReadonlyYaml(value) {
|
|
321
|
+
if (value === undefined || value === null || value === "") {
|
|
322
|
+
return "";
|
|
323
|
+
}
|
|
324
|
+
if (typeof value === "string") {
|
|
325
|
+
return value;
|
|
326
|
+
}
|
|
327
|
+
return YAML.stringify(value);
|
|
328
|
+
}
|
|
329
|
+
function normalizeJsonDisplayValue(value) {
|
|
330
|
+
if (value === undefined || value === null || value === "") {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
if (typeof value === "string") {
|
|
334
|
+
try {
|
|
335
|
+
return JSON.parse(value);
|
|
336
|
+
}
|
|
337
|
+
catch (_a) {
|
|
338
|
+
return value;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return value;
|
|
342
|
+
}
|
|
343
|
+
function isPlainObjectValue(value) {
|
|
344
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
345
|
+
}
|
|
346
|
+
function formatOutputVisualValue(value) {
|
|
347
|
+
if (value === null || value === undefined) {
|
|
348
|
+
return "null";
|
|
349
|
+
}
|
|
350
|
+
if (typeof value === "boolean") {
|
|
351
|
+
return value ? "true" : "false";
|
|
352
|
+
}
|
|
353
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
354
|
+
return String(value);
|
|
355
|
+
}
|
|
356
|
+
return JSON.stringify(value);
|
|
357
|
+
}
|
|
358
|
+
function isUrlLike(value) {
|
|
359
|
+
return /^https?:\/\//i.test(value);
|
|
360
|
+
}
|
|
361
|
+
function summarizeOutputValue(value) {
|
|
362
|
+
var normalizedValue = normalizeJsonDisplayValue(value);
|
|
363
|
+
if (normalizedValue === null || normalizedValue === undefined) {
|
|
364
|
+
return "No output";
|
|
365
|
+
}
|
|
366
|
+
if (Array.isArray(normalizedValue)) {
|
|
367
|
+
return "".concat(normalizedValue.length, " item").concat(normalizedValue.length === 1 ? "" : "s");
|
|
368
|
+
}
|
|
369
|
+
if (isPlainObjectValue(normalizedValue)) {
|
|
370
|
+
var count = Object.keys(normalizedValue).length;
|
|
371
|
+
return "".concat(count, " field").concat(count === 1 ? "" : "s");
|
|
372
|
+
}
|
|
373
|
+
return String(formatOutputVisualValue(normalizedValue));
|
|
374
|
+
}
|
|
375
|
+
function slugifyWorkflowKey(value) {
|
|
376
|
+
return value
|
|
377
|
+
.trim()
|
|
378
|
+
.toLowerCase()
|
|
379
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
380
|
+
.replace(/^-+|-+$/g, "");
|
|
381
|
+
}
|
|
382
|
+
function camelizeWorkflowInputKey(value) {
|
|
383
|
+
var words = String(value !== null && value !== void 0 ? value : "")
|
|
384
|
+
.trim()
|
|
385
|
+
.replace(/['’]/g, "")
|
|
386
|
+
.split(/[^a-zA-Z0-9]+/)
|
|
387
|
+
.filter(Boolean);
|
|
388
|
+
if (!words.length) {
|
|
389
|
+
return "";
|
|
390
|
+
}
|
|
391
|
+
return words
|
|
392
|
+
.map(function (word, index) {
|
|
393
|
+
var hasLowercase = /[a-z]/.test(word);
|
|
394
|
+
var hasUppercase = /[A-Z]/.test(word);
|
|
395
|
+
var normalizedWord = hasLowercase && hasUppercase ? word : word.toLowerCase();
|
|
396
|
+
return index === 0
|
|
397
|
+
? normalizedWord.charAt(0).toLowerCase() + normalizedWord.slice(1)
|
|
398
|
+
: normalizedWord.charAt(0).toUpperCase() + normalizedWord.slice(1);
|
|
399
|
+
})
|
|
400
|
+
.join("");
|
|
401
|
+
}
|
|
402
|
+
function buildUniqueWorkflowInputKey(baseKey, existingKeys) {
|
|
403
|
+
var fallbackKey = camelizeWorkflowInputKey(baseKey) || "input";
|
|
404
|
+
var existing = new Set(existingKeys);
|
|
405
|
+
if (!existing.has(fallbackKey)) {
|
|
406
|
+
return fallbackKey;
|
|
407
|
+
}
|
|
408
|
+
var index = 2;
|
|
409
|
+
while (existing.has("".concat(fallbackKey).concat(index))) {
|
|
410
|
+
index += 1;
|
|
411
|
+
}
|
|
412
|
+
return "".concat(fallbackKey).concat(index);
|
|
413
|
+
}
|
|
414
|
+
function buildUniqueWorkflowVariableKey(baseKey, existingKeys) {
|
|
415
|
+
var fallbackKey = camelizeWorkflowInputKey(baseKey) || "variable";
|
|
416
|
+
var existing = new Set(existingKeys);
|
|
417
|
+
if (!existing.has(fallbackKey)) {
|
|
418
|
+
return fallbackKey;
|
|
419
|
+
}
|
|
420
|
+
var index = 2;
|
|
421
|
+
while (existing.has("".concat(fallbackKey).concat(index))) {
|
|
422
|
+
index += 1;
|
|
423
|
+
}
|
|
424
|
+
return "".concat(fallbackKey).concat(index);
|
|
425
|
+
}
|
|
426
|
+
function normalizeWorkflowTag(value) {
|
|
427
|
+
return value.trim();
|
|
428
|
+
}
|
|
429
|
+
function parseWorkflowTagInput(value) {
|
|
430
|
+
return value
|
|
431
|
+
.split(",")
|
|
432
|
+
.map(normalizeWorkflowTag)
|
|
433
|
+
.filter(Boolean);
|
|
434
|
+
}
|
|
435
|
+
function formatWorkflowTags(value) {
|
|
436
|
+
if (Array.isArray(value)) {
|
|
437
|
+
return value.map(function (tag) { return String(tag).trim(); }).filter(Boolean);
|
|
438
|
+
}
|
|
439
|
+
if (typeof value === "string") {
|
|
440
|
+
try {
|
|
441
|
+
var parsed = JSON.parse(value);
|
|
442
|
+
if (Array.isArray(parsed)) {
|
|
443
|
+
return parsed.map(function (tag) { return String(tag).trim(); }).filter(Boolean);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
catch (_a) {
|
|
447
|
+
return parseWorkflowTagInput(value);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return [];
|
|
451
|
+
}
|
|
452
|
+
function buildUniqueWorkflowKey(baseKey, existingKeys) {
|
|
453
|
+
var fallbackKey = slugifyWorkflowKey(baseKey) || "item";
|
|
454
|
+
var existing = new Set(existingKeys);
|
|
455
|
+
if (!existing.has(fallbackKey)) {
|
|
456
|
+
return fallbackKey;
|
|
457
|
+
}
|
|
458
|
+
var index = 2;
|
|
459
|
+
while (existing.has("".concat(fallbackKey, "-").concat(index))) {
|
|
460
|
+
index += 1;
|
|
461
|
+
}
|
|
462
|
+
return "".concat(fallbackKey, "-").concat(index);
|
|
463
|
+
}
|
|
464
|
+
function normalizeWorkflowInputDefinition(value) {
|
|
465
|
+
var _a, _b, _c, _d;
|
|
466
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
467
|
+
return {
|
|
468
|
+
type: (_a = value.type) !== null && _a !== void 0 ? _a : "string",
|
|
469
|
+
label: (_b = value.label) !== null && _b !== void 0 ? _b : "",
|
|
470
|
+
required: Boolean(value.required),
|
|
471
|
+
default: (_c = value.default) !== null && _c !== void 0 ? _c : "",
|
|
472
|
+
description: (_d = value.description) !== null && _d !== void 0 ? _d : "",
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
return {
|
|
476
|
+
type: "string",
|
|
477
|
+
label: "",
|
|
478
|
+
required: false,
|
|
479
|
+
default: value !== null && value !== void 0 ? value : "",
|
|
480
|
+
description: "",
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
function getWorkflowInputEntries(inputs) {
|
|
484
|
+
return Object.entries(inputs !== null && inputs !== void 0 ? inputs : {}).map(function (_a) {
|
|
485
|
+
var key = _a[0], value = _a[1];
|
|
486
|
+
return ({
|
|
487
|
+
key: key,
|
|
488
|
+
definition: normalizeWorkflowInputDefinition(value),
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
function getWorkflowVariableMetadata(metadata) {
|
|
493
|
+
var variableDefinitions = metadata === null || metadata === void 0 ? void 0 : metadata.variableDefinitions;
|
|
494
|
+
return variableDefinitions && typeof variableDefinitions === "object" && !Array.isArray(variableDefinitions)
|
|
495
|
+
? variableDefinitions
|
|
496
|
+
: {};
|
|
497
|
+
}
|
|
498
|
+
function inferWorkflowVariableType(value, metadataType) {
|
|
499
|
+
if (metadataType &&
|
|
500
|
+
WORKFLOW_INPUT_TYPE_OPTIONS.some(function (option) { return option.value === metadataType; })) {
|
|
501
|
+
return metadataType;
|
|
502
|
+
}
|
|
503
|
+
if (Array.isArray(value)) {
|
|
504
|
+
return "array";
|
|
505
|
+
}
|
|
506
|
+
if (value && typeof value === "object") {
|
|
507
|
+
return "object";
|
|
508
|
+
}
|
|
509
|
+
if (typeof value === "number") {
|
|
510
|
+
return "number";
|
|
511
|
+
}
|
|
512
|
+
if (typeof value === "boolean") {
|
|
513
|
+
return "boolean";
|
|
514
|
+
}
|
|
515
|
+
return "string";
|
|
516
|
+
}
|
|
517
|
+
function getWorkflowVariableEntries(variables, metadata) {
|
|
518
|
+
var variableMetadata = getWorkflowVariableMetadata(metadata);
|
|
519
|
+
return Object.entries(variables !== null && variables !== void 0 ? variables : {}).map(function (_a) {
|
|
520
|
+
var _b;
|
|
521
|
+
var key = _a[0], value = _a[1];
|
|
522
|
+
var meta = (_b = variableMetadata[key]) !== null && _b !== void 0 ? _b : {};
|
|
523
|
+
var label = typeof meta.label === "string" ? meta.label : key;
|
|
524
|
+
return {
|
|
525
|
+
key: key,
|
|
526
|
+
definition: {
|
|
527
|
+
type: inferWorkflowVariableType(value, meta.type),
|
|
528
|
+
label: label,
|
|
529
|
+
value: value,
|
|
530
|
+
description: typeof meta.description === "string" ? meta.description : "",
|
|
531
|
+
},
|
|
532
|
+
};
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
function stringifyWorkflowRunInputDefault(value, type) {
|
|
536
|
+
if (value === undefined || value === null) {
|
|
537
|
+
return type === "boolean" ? false : "";
|
|
538
|
+
}
|
|
539
|
+
if (type === "object" || type === "array") {
|
|
540
|
+
return typeof value === "string" ? value : JSON.stringify(value, null, 2);
|
|
541
|
+
}
|
|
542
|
+
if (type === "boolean") {
|
|
543
|
+
return Boolean(value);
|
|
544
|
+
}
|
|
545
|
+
return String(value);
|
|
546
|
+
}
|
|
547
|
+
function buildWorkflowRunInputDefaults(entries) {
|
|
548
|
+
return entries.reduce(function (values, entry) {
|
|
549
|
+
values[entry.key] = stringifyWorkflowRunInputDefault(entry.definition.default, entry.definition.type);
|
|
550
|
+
return values;
|
|
551
|
+
}, {});
|
|
552
|
+
}
|
|
553
|
+
function hasWorkflowInputDefaultValue(value) {
|
|
554
|
+
return value !== undefined && value !== null && value !== "";
|
|
555
|
+
}
|
|
556
|
+
function formatWorkflowInputDefaultSummary(value) {
|
|
557
|
+
if (!hasWorkflowInputDefaultValue(value)) {
|
|
558
|
+
return "No default value set";
|
|
559
|
+
}
|
|
560
|
+
if (typeof value === "object") {
|
|
561
|
+
var serialized_1 = JSON.stringify(value);
|
|
562
|
+
return "Default - ".concat(serialized_1.length > 58 ? "".concat(serialized_1.slice(0, 58), "...") : serialized_1);
|
|
563
|
+
}
|
|
564
|
+
var serialized = String(value);
|
|
565
|
+
return "Default - ".concat(serialized.length > 58 ? "".concat(serialized.slice(0, 58), "...") : serialized);
|
|
566
|
+
}
|
|
567
|
+
function formatWorkflowVariableValueSummary(value) {
|
|
568
|
+
if (typeof value === "object" && value !== null) {
|
|
569
|
+
var serialized_2 = JSON.stringify(value);
|
|
570
|
+
return "Value - ".concat(serialized_2.length > 58 ? "".concat(serialized_2.slice(0, 58), "...") : serialized_2);
|
|
571
|
+
}
|
|
572
|
+
if (value === "") {
|
|
573
|
+
return 'Value - ""';
|
|
574
|
+
}
|
|
575
|
+
var serialized = String(value !== null && value !== void 0 ? value : "");
|
|
576
|
+
return "Value - ".concat(serialized.length > 58 ? "".concat(serialized.slice(0, 58), "...") : serialized);
|
|
577
|
+
}
|
|
578
|
+
function getWorkflowInputDefaultEditorValue(value, type) {
|
|
579
|
+
if (!hasWorkflowInputDefaultValue(value)) {
|
|
580
|
+
if (type === "array") {
|
|
581
|
+
return [];
|
|
582
|
+
}
|
|
583
|
+
if (type === "object") {
|
|
584
|
+
return {};
|
|
585
|
+
}
|
|
586
|
+
if (type === "boolean") {
|
|
587
|
+
return false;
|
|
588
|
+
}
|
|
589
|
+
return "";
|
|
590
|
+
}
|
|
591
|
+
if (type === "object" || type === "array") {
|
|
592
|
+
if (typeof value === "string") {
|
|
593
|
+
try {
|
|
594
|
+
return JSON.parse(value);
|
|
595
|
+
}
|
|
596
|
+
catch (_a) {
|
|
597
|
+
return type === "array" ? [] : {};
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return value;
|
|
601
|
+
}
|
|
602
|
+
if (type === "boolean") {
|
|
603
|
+
return Boolean(value);
|
|
604
|
+
}
|
|
605
|
+
return String(value);
|
|
606
|
+
}
|
|
607
|
+
function getWorkflowVariableInitialValue(type) {
|
|
608
|
+
if (type === "array") {
|
|
609
|
+
return [];
|
|
610
|
+
}
|
|
611
|
+
if (type === "object") {
|
|
612
|
+
return {};
|
|
613
|
+
}
|
|
614
|
+
if (type === "boolean") {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
if (type === "number") {
|
|
618
|
+
return 0;
|
|
619
|
+
}
|
|
620
|
+
return "";
|
|
621
|
+
}
|
|
622
|
+
function getWorkflowVariableEditorValue(value, type) {
|
|
623
|
+
if (value === undefined || value === null) {
|
|
624
|
+
return getWorkflowVariableInitialValue(type);
|
|
625
|
+
}
|
|
626
|
+
if (type === "object" || type === "array") {
|
|
627
|
+
if (typeof value === "string") {
|
|
628
|
+
try {
|
|
629
|
+
return JSON.parse(value);
|
|
630
|
+
}
|
|
631
|
+
catch (_a) {
|
|
632
|
+
return getWorkflowVariableInitialValue(type);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return value;
|
|
636
|
+
}
|
|
637
|
+
if (type === "boolean") {
|
|
638
|
+
return Boolean(value);
|
|
639
|
+
}
|
|
640
|
+
return String(value);
|
|
641
|
+
}
|
|
642
|
+
function parseWorkflowRunInputValue(value, type) {
|
|
643
|
+
if (type === "boolean") {
|
|
644
|
+
return Boolean(value);
|
|
645
|
+
}
|
|
646
|
+
if (type === "number") {
|
|
647
|
+
if (value === "" || value === null || value === undefined) {
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
var numericValue = Number(value);
|
|
651
|
+
if (!Number.isFinite(numericValue)) {
|
|
652
|
+
throw new Error("Enter a valid number.");
|
|
653
|
+
}
|
|
654
|
+
return numericValue;
|
|
655
|
+
}
|
|
656
|
+
if (type === "object" || type === "array") {
|
|
657
|
+
var trimmedValue = String(value !== null && value !== void 0 ? value : "").trim();
|
|
658
|
+
if (!trimmedValue) {
|
|
659
|
+
return type === "array" ? [] : {};
|
|
660
|
+
}
|
|
661
|
+
var parsed = JSON.parse(trimmedValue);
|
|
662
|
+
if (type === "array" && !Array.isArray(parsed)) {
|
|
663
|
+
throw new Error("Enter a valid JSON array.");
|
|
664
|
+
}
|
|
665
|
+
if (type === "object" && !isPlainObjectValue(parsed)) {
|
|
666
|
+
throw new Error("Enter a valid JSON object.");
|
|
667
|
+
}
|
|
668
|
+
return parsed;
|
|
669
|
+
}
|
|
670
|
+
return value !== null && value !== void 0 ? value : "";
|
|
671
|
+
}
|
|
672
|
+
function normalizeWorkflowTriggerDefinition(value) {
|
|
673
|
+
var configuration = (value === null || value === void 0 ? void 0 : value.configuration) && typeof value.configuration === "object" && !Array.isArray(value.configuration)
|
|
674
|
+
? value.configuration
|
|
675
|
+
: {};
|
|
676
|
+
return {
|
|
677
|
+
id: (value === null || value === void 0 ? void 0 : value.id) ? String(value.id) : "",
|
|
678
|
+
name: (value === null || value === void 0 ? void 0 : value.name) ? String(value.name) : "",
|
|
679
|
+
type: (value === null || value === void 0 ? void 0 : value.type) ? String(value.type) : "schedule",
|
|
680
|
+
disabled: Boolean(value === null || value === void 0 ? void 0 : value.disabled),
|
|
681
|
+
configuration: configuration,
|
|
682
|
+
metadata: (value === null || value === void 0 ? void 0 : value.metadata) && typeof value.metadata === "object" && !Array.isArray(value.metadata)
|
|
683
|
+
? value.metadata
|
|
684
|
+
: undefined,
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
function getWorkflowTriggerCronExpression(trigger) {
|
|
688
|
+
var _a, _b;
|
|
689
|
+
return String((_b = (_a = trigger.configuration.cronExpression) !== null && _a !== void 0 ? _a : trigger.configuration.cron) !== null && _b !== void 0 ? _b : "0 9 * * *");
|
|
690
|
+
}
|
|
691
|
+
function normalizeWorkflowDefinition(parsed) {
|
|
692
|
+
var _a;
|
|
693
|
+
return __assign(__assign(__assign({}, createEmptyWorkflowDefinition()), (parsed !== null && parsed !== void 0 ? parsed : {})), { nodes: parsed.nodes, triggers: (_a = parsed.triggers) !== null && _a !== void 0 ? _a : [] });
|
|
694
|
+
}
|
|
695
|
+
function validateWorkflowDefinitionSchema(value, nodeTypes, options) {
|
|
696
|
+
var _a, _b;
|
|
697
|
+
if (options === void 0) { options = {}; }
|
|
698
|
+
var errors = [];
|
|
699
|
+
var nodeTypeMap = new Map(nodeTypes.map(function (item) { return [item.type, item]; }));
|
|
700
|
+
var seenNodeIds = new Set();
|
|
701
|
+
var validNodeKinds = new Set(["task", "control", "subflow"]);
|
|
702
|
+
var canonicalChildKeys = ["tasks", "then", "else", "defaults"];
|
|
703
|
+
var unsupportedChildKeys = ["children", "branches", "nodes"];
|
|
704
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
705
|
+
return ["Workflow definition YAML must resolve to an object."];
|
|
706
|
+
}
|
|
707
|
+
var definition = value;
|
|
708
|
+
if (options.requireWorkflowKey && !String((_a = options.workflowKey) !== null && _a !== void 0 ? _a : "").trim()) {
|
|
709
|
+
errors.push("Workflow key is required.");
|
|
710
|
+
}
|
|
711
|
+
if (!Array.isArray(definition.nodes)) {
|
|
712
|
+
errors.push("Workflow definition YAML must include a nodes array.");
|
|
713
|
+
}
|
|
714
|
+
else if (options.requireRootNode && !definition.nodes.length) {
|
|
715
|
+
errors.push("Workflow definition must contain at least one root node.");
|
|
716
|
+
}
|
|
717
|
+
if (definition.triggers !== undefined &&
|
|
718
|
+
definition.triggers !== null &&
|
|
719
|
+
!Array.isArray(definition.triggers)) {
|
|
720
|
+
errors.push("Workflow definition triggers must be an array when provided.");
|
|
721
|
+
}
|
|
722
|
+
var validateNodeSequence = function (nodes, scopeLabel) {
|
|
723
|
+
if (!Array.isArray(nodes)) {
|
|
724
|
+
errors.push("".concat(scopeLabel, " must be an array."));
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
nodes.forEach(function (nodeValue, index) {
|
|
728
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
729
|
+
var prefix = "".concat(scopeLabel, " node ").concat(index + 1);
|
|
730
|
+
if (!nodeValue || typeof nodeValue !== "object" || Array.isArray(nodeValue)) {
|
|
731
|
+
errors.push("".concat(prefix, " must be an object."));
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
var node = nodeValue;
|
|
735
|
+
unsupportedChildKeys.forEach(function (key) {
|
|
736
|
+
if (Object.prototype.hasOwnProperty.call(node, key)) {
|
|
737
|
+
errors.push("".concat(prefix, " uses unsupported child key \"").concat(key, "\". Use \"tasks\", \"then\", \"else\", \"defaults\", or \"cases\" instead."));
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
canonicalChildKeys.forEach(function (key) {
|
|
741
|
+
if (node[key] !== undefined &&
|
|
742
|
+
node[key] !== null &&
|
|
743
|
+
!Array.isArray(node[key])) {
|
|
744
|
+
errors.push("".concat(prefix, " field \"").concat(key, "\" must be an array when provided."));
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
if (node.cases !== undefined &&
|
|
748
|
+
node.cases !== null &&
|
|
749
|
+
(typeof node.cases !== "object" || Array.isArray(node.cases))) {
|
|
750
|
+
errors.push("".concat(prefix, " field \"cases\" must be an object of arrays when provided."));
|
|
751
|
+
}
|
|
752
|
+
else if (node.cases && typeof node.cases === "object") {
|
|
753
|
+
Object.entries(node.cases).forEach(function (_a) {
|
|
754
|
+
var caseKey = _a[0], caseNodes = _a[1];
|
|
755
|
+
if (!Array.isArray(caseNodes)) {
|
|
756
|
+
errors.push("".concat(prefix, " case \"").concat(caseKey, "\" must be an array."));
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
if (!node.id) {
|
|
761
|
+
errors.push("".concat(prefix, " is missing an id."));
|
|
762
|
+
}
|
|
763
|
+
else if (seenNodeIds.has(String(node.id))) {
|
|
764
|
+
errors.push("Duplicate workflow node id \"".concat(node.id, "\"."));
|
|
765
|
+
}
|
|
766
|
+
else {
|
|
767
|
+
seenNodeIds.add(String(node.id));
|
|
768
|
+
}
|
|
769
|
+
if (!node.kind) {
|
|
770
|
+
errors.push("".concat(prefix, " is missing a kind."));
|
|
771
|
+
}
|
|
772
|
+
else if (!validNodeKinds.has(String(node.kind))) {
|
|
773
|
+
errors.push("".concat(prefix, " has unsupported kind \"").concat(node.kind, "\". Expected task, control, or subflow."));
|
|
774
|
+
}
|
|
775
|
+
if (!node.type) {
|
|
776
|
+
errors.push("".concat(prefix, " is missing a type."));
|
|
777
|
+
}
|
|
778
|
+
var nodeType = node.type ? nodeTypeMap.get(String(node.type)) : undefined;
|
|
779
|
+
if (node.type && nodeTypes.length && !nodeType) {
|
|
780
|
+
errors.push("Node \"".concat((_a = node.id) !== null && _a !== void 0 ? _a : prefix, "\" uses unregistered type \"").concat(node.type, "\"."));
|
|
781
|
+
}
|
|
782
|
+
if (node.kind && nodeType && node.kind !== nodeType.kind) {
|
|
783
|
+
errors.push("Node \"".concat(node.id, "\" kind \"").concat(node.kind, "\" does not match registered type \"").concat(node.type, "\" kind \"").concat(nodeType.kind, "\"."));
|
|
784
|
+
}
|
|
785
|
+
var configuration = (_b = node.configuration) !== null && _b !== void 0 ? _b : {};
|
|
786
|
+
if (node.configuration !== undefined &&
|
|
787
|
+
node.configuration !== null &&
|
|
788
|
+
(typeof node.configuration !== "object" || Array.isArray(node.configuration))) {
|
|
789
|
+
errors.push("Node \"".concat((_c = node.id) !== null && _c !== void 0 ? _c : prefix, "\" configuration must be an object."));
|
|
790
|
+
}
|
|
791
|
+
((_e = (_d = nodeType === null || nodeType === void 0 ? void 0 : nodeType.authoring) === null || _d === void 0 ? void 0 : _d.configurationFields) !== null && _e !== void 0 ? _e : []).forEach(function (field) {
|
|
792
|
+
var _a, _b;
|
|
793
|
+
if (!field.required) {
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
if (configuration &&
|
|
797
|
+
typeof configuration === "object" &&
|
|
798
|
+
!isConfigurationFieldVisibleForValidation(field, configuration)) {
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
var valueForField = configuration && typeof configuration === "object"
|
|
802
|
+
? getFieldValue(configuration, (_a = field.path) !== null && _a !== void 0 ? _a : field.key)
|
|
803
|
+
: undefined;
|
|
804
|
+
var isEmptyArray = Array.isArray(valueForField) && valueForField.length === 0;
|
|
805
|
+
var isMissing = valueForField === undefined ||
|
|
806
|
+
valueForField === null ||
|
|
807
|
+
valueForField === "" ||
|
|
808
|
+
isEmptyArray;
|
|
809
|
+
if (isMissing) {
|
|
810
|
+
errors.push("Node \"".concat(node.id, "\" is missing required field \"").concat((_b = field.label) !== null && _b !== void 0 ? _b : field.key, "\"."));
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
((_g = (_f = nodeType === null || nodeType === void 0 ? void 0 : nodeType.authoring) === null || _f === void 0 ? void 0 : _f.childSlots) !== null && _g !== void 0 ? _g : []).forEach(function (slot) {
|
|
814
|
+
var _a, _b, _c, _d;
|
|
815
|
+
var slotNodes = slot.kind === "case-collection"
|
|
816
|
+
? Object.values((_a = node.cases) !== null && _a !== void 0 ? _a : {}).flat()
|
|
817
|
+
: Array.isArray(node[slot.key])
|
|
818
|
+
? node[slot.key]
|
|
819
|
+
: [];
|
|
820
|
+
var slotCount = slot.kind === "case-collection"
|
|
821
|
+
? Object.keys((_b = node.cases) !== null && _b !== void 0 ? _b : {}).length
|
|
822
|
+
: slotNodes.length;
|
|
823
|
+
if (slot.required && slotCount === 0) {
|
|
824
|
+
errors.push("Node \"".concat(node.id, "\" requires at least one child node in \"").concat((_c = slot.label) !== null && _c !== void 0 ? _c : slot.key, "\"."));
|
|
825
|
+
}
|
|
826
|
+
if (slot.minItems && slotCount < slot.minItems) {
|
|
827
|
+
errors.push("Node \"".concat(node.id, "\" requires at least ").concat(slot.minItems, " nodes in \"").concat((_d = slot.label) !== null && _d !== void 0 ? _d : slot.key, "\"."));
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
validateNodeSequence((_h = node.tasks) !== null && _h !== void 0 ? _h : [], "".concat((_j = node.id) !== null && _j !== void 0 ? _j : prefix, " tasks"));
|
|
831
|
+
validateNodeSequence((_k = node.then) !== null && _k !== void 0 ? _k : [], "".concat((_l = node.id) !== null && _l !== void 0 ? _l : prefix, " then"));
|
|
832
|
+
validateNodeSequence((_m = node.else) !== null && _m !== void 0 ? _m : [], "".concat((_o = node.id) !== null && _o !== void 0 ? _o : prefix, " else"));
|
|
833
|
+
validateNodeSequence((_p = node.defaults) !== null && _p !== void 0 ? _p : [], "".concat((_q = node.id) !== null && _q !== void 0 ? _q : prefix, " defaults"));
|
|
834
|
+
Object.entries((_r = node.cases) !== null && _r !== void 0 ? _r : {}).forEach(function (_a) {
|
|
835
|
+
var _b;
|
|
836
|
+
var caseKey = _a[0], caseNodes = _a[1];
|
|
837
|
+
validateNodeSequence(caseNodes, "".concat((_b = node.id) !== null && _b !== void 0 ? _b : prefix, " case \"").concat(caseKey, "\""));
|
|
838
|
+
});
|
|
839
|
+
});
|
|
840
|
+
};
|
|
841
|
+
if (Array.isArray(definition.nodes)) {
|
|
842
|
+
validateNodeSequence(definition.nodes, "root");
|
|
843
|
+
}
|
|
844
|
+
if (Array.isArray(definition.triggers)) {
|
|
845
|
+
var triggerIds_1 = new Set();
|
|
846
|
+
var activeScheduleTriggers = definition.triggers.filter(function (trigger) { return (trigger === null || trigger === void 0 ? void 0 : trigger.type) === "schedule" && !trigger.disabled; });
|
|
847
|
+
definition.triggers.forEach(function (trigger, index) {
|
|
848
|
+
var _a, _b, _c;
|
|
849
|
+
var prefix = "Trigger ".concat(index + 1);
|
|
850
|
+
if (!trigger || typeof trigger !== "object" || Array.isArray(trigger)) {
|
|
851
|
+
errors.push("".concat(prefix, " must be an object."));
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
if (!trigger.id) {
|
|
855
|
+
errors.push("".concat(prefix, " is missing an id."));
|
|
856
|
+
}
|
|
857
|
+
else if (triggerIds_1.has(String(trigger.id))) {
|
|
858
|
+
errors.push("Duplicate workflow trigger id \"".concat(trigger.id, "\"."));
|
|
859
|
+
}
|
|
860
|
+
else {
|
|
861
|
+
triggerIds_1.add(String(trigger.id));
|
|
862
|
+
}
|
|
863
|
+
if (!["schedule", "webhook"].includes(String(trigger.type))) {
|
|
864
|
+
errors.push("".concat(prefix, " has unsupported type \"").concat(trigger.type, "\"."));
|
|
865
|
+
}
|
|
866
|
+
if (trigger.type === "schedule") {
|
|
867
|
+
var cronExpression = (_b = (_a = trigger.configuration) === null || _a === void 0 ? void 0 : _a.cronExpression) !== null && _b !== void 0 ? _b : (_c = trigger.configuration) === null || _c === void 0 ? void 0 : _c.cron;
|
|
868
|
+
if (!cronExpression || !isValidSimpleCronExpression(String(cronExpression))) {
|
|
869
|
+
errors.push("".concat(prefix, " requires a five-field CRON expression."));
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
if (activeScheduleTriggers.length) {
|
|
874
|
+
Object.entries((_b = definition.inputs) !== null && _b !== void 0 ? _b : {}).forEach(function (_a) {
|
|
875
|
+
var inputKey = _a[0], inputDefinition = _a[1];
|
|
876
|
+
if (!workflowInputHasDefault(inputDefinition)) {
|
|
877
|
+
errors.push("Input \"".concat(inputKey, "\" requires a default value before enabling a scheduled trigger."));
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return errors;
|
|
883
|
+
}
|
|
884
|
+
function parseWorkflowDefinitionYaml(definitionYaml, nodeTypes) {
|
|
885
|
+
var _a;
|
|
886
|
+
if (!definitionYaml) {
|
|
887
|
+
var definition = createEmptyWorkflowDefinition();
|
|
888
|
+
return {
|
|
889
|
+
ok: true,
|
|
890
|
+
definition: definition,
|
|
891
|
+
yaml: serializeWorkflowDefinitionYaml(definition),
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
var parsed = definitionYaml;
|
|
895
|
+
var yaml = typeof definitionYaml === "string"
|
|
896
|
+
? definitionYaml
|
|
897
|
+
: serializeWorkflowDefinitionYaml(definitionYaml);
|
|
898
|
+
if (typeof definitionYaml === "string") {
|
|
899
|
+
try {
|
|
900
|
+
parsed = YAML.parse(definitionYaml);
|
|
901
|
+
}
|
|
902
|
+
catch (error) {
|
|
903
|
+
return {
|
|
904
|
+
ok: false,
|
|
905
|
+
errors: ["Invalid workflow YAML: ".concat((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : "Unable to parse YAML.")],
|
|
906
|
+
yaml: yaml,
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
var errors = validateWorkflowDefinitionSchema(parsed, nodeTypes);
|
|
911
|
+
if (errors.length) {
|
|
912
|
+
return {
|
|
913
|
+
ok: false,
|
|
914
|
+
errors: errors,
|
|
915
|
+
yaml: yaml,
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
return {
|
|
919
|
+
ok: true,
|
|
920
|
+
definition: normalizeWorkflowDefinition(parsed),
|
|
921
|
+
yaml: yaml,
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
function flattenWorkflowNodeIds(nodes) {
|
|
925
|
+
return nodes.flatMap(function (node) {
|
|
926
|
+
var _a, _b, _c, _d, _e;
|
|
927
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
928
|
+
String(node.id)
|
|
929
|
+
], flattenWorkflowNodeIds((_a = node.tasks) !== null && _a !== void 0 ? _a : []), true), flattenWorkflowNodeIds((_b = node.then) !== null && _b !== void 0 ? _b : []), true), flattenWorkflowNodeIds((_c = node.else) !== null && _c !== void 0 ? _c : []), true), flattenWorkflowNodeIds((_d = node.defaults) !== null && _d !== void 0 ? _d : []), true), Object.values((_e = node.cases) !== null && _e !== void 0 ? _e : {}).flatMap(function (caseNodes) {
|
|
930
|
+
return flattenWorkflowNodeIds(caseNodes);
|
|
931
|
+
}), true);
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
function flattenWorkflowNodes(nodes) {
|
|
935
|
+
return nodes.flatMap(function (node) {
|
|
936
|
+
var _a, _b, _c, _d, _e;
|
|
937
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
938
|
+
node
|
|
939
|
+
], flattenWorkflowNodes((_a = node.tasks) !== null && _a !== void 0 ? _a : []), true), flattenWorkflowNodes((_b = node.then) !== null && _b !== void 0 ? _b : []), true), flattenWorkflowNodes((_c = node.else) !== null && _c !== void 0 ? _c : []), true), flattenWorkflowNodes((_d = node.defaults) !== null && _d !== void 0 ? _d : []), true), Object.values((_e = node.cases) !== null && _e !== void 0 ? _e : {}).flatMap(function (caseNodes) {
|
|
940
|
+
return flattenWorkflowNodes(caseNodes);
|
|
941
|
+
}), true);
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
function buildExecutionOutputEntries(outputPayload, nodes) {
|
|
945
|
+
var normalizedValue = normalizeJsonDisplayValue(outputPayload);
|
|
946
|
+
if (normalizedValue === null || normalizedValue === undefined) {
|
|
947
|
+
return [];
|
|
948
|
+
}
|
|
949
|
+
var nodeMap = new Map(flattenWorkflowNodes(nodes).map(function (node) { return [String(node.id), node]; }));
|
|
950
|
+
if (isPlainObjectValue(normalizedValue)) {
|
|
951
|
+
return Object.entries(normalizedValue).map(function (_a) {
|
|
952
|
+
var _b;
|
|
953
|
+
var key = _a[0], value = _a[1];
|
|
954
|
+
var node = nodeMap.get(key);
|
|
955
|
+
return {
|
|
956
|
+
key: key,
|
|
957
|
+
label: (_b = node === null || node === void 0 ? void 0 : node.name) !== null && _b !== void 0 ? _b : key,
|
|
958
|
+
nodeId: key,
|
|
959
|
+
nodeType: node === null || node === void 0 ? void 0 : node.type,
|
|
960
|
+
value: value,
|
|
961
|
+
};
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
return [
|
|
965
|
+
{
|
|
966
|
+
key: "execution-output",
|
|
967
|
+
label: "Execution Output",
|
|
968
|
+
value: normalizedValue,
|
|
969
|
+
},
|
|
970
|
+
];
|
|
971
|
+
}
|
|
972
|
+
function buildNodeId(type, definition) {
|
|
973
|
+
var _a;
|
|
974
|
+
var suffix = (_a = type.split(".").pop()) !== null && _a !== void 0 ? _a : "node";
|
|
975
|
+
var base = suffix.replace(/[^a-zA-Z0-9]+/g, "");
|
|
976
|
+
var attempt = base.charAt(0).toLowerCase() + base.slice(1);
|
|
977
|
+
var counter = 1;
|
|
978
|
+
var nodeIds = new Set(flattenWorkflowNodeIds(definition.nodes));
|
|
979
|
+
while (nodeIds.has(attempt)) {
|
|
980
|
+
counter += 1;
|
|
981
|
+
attempt = "".concat(base.charAt(0).toLowerCase() + base.slice(1)).concat(counter);
|
|
982
|
+
}
|
|
983
|
+
return attempt;
|
|
984
|
+
}
|
|
985
|
+
function countNodes(nodes) {
|
|
986
|
+
return nodes.reduce(function (sum, node) {
|
|
987
|
+
var _a, _b, _c, _d, _e;
|
|
988
|
+
return sum +
|
|
989
|
+
1 +
|
|
990
|
+
countNodes((_a = node.tasks) !== null && _a !== void 0 ? _a : []) +
|
|
991
|
+
countNodes((_b = node.then) !== null && _b !== void 0 ? _b : []) +
|
|
992
|
+
countNodes((_c = node.else) !== null && _c !== void 0 ? _c : []) +
|
|
993
|
+
countNodes((_d = node.defaults) !== null && _d !== void 0 ? _d : []) +
|
|
994
|
+
Object.values((_e = node.cases) !== null && _e !== void 0 ? _e : {}).reduce(function (caseSum, caseNodes) { return caseSum + countNodes(caseNodes); }, 0);
|
|
995
|
+
}, 0);
|
|
996
|
+
}
|
|
997
|
+
function countTriggers(triggers) {
|
|
998
|
+
return Array.isArray(triggers) ? triggers.length : 0;
|
|
999
|
+
}
|
|
1000
|
+
function buildWorkflowInputExample(inputs) {
|
|
1001
|
+
return Object.entries(inputs !== null && inputs !== void 0 ? inputs : {}).reduce(function (acc, _a) {
|
|
1002
|
+
var key = _a[0], inputDefinition = _a[1];
|
|
1003
|
+
var normalized = normalizeWorkflowInputDefinition(inputDefinition);
|
|
1004
|
+
if (workflowInputHasDefault(normalized.default)) {
|
|
1005
|
+
acc[key] = normalized.default;
|
|
1006
|
+
return acc;
|
|
1007
|
+
}
|
|
1008
|
+
if (normalized.type === "number") {
|
|
1009
|
+
acc[key] = 123;
|
|
1010
|
+
}
|
|
1011
|
+
else if (normalized.type === "boolean") {
|
|
1012
|
+
acc[key] = true;
|
|
1013
|
+
}
|
|
1014
|
+
else if (normalized.type === "date") {
|
|
1015
|
+
acc[key] = "2026-07-21";
|
|
1016
|
+
}
|
|
1017
|
+
else if (normalized.type === "object") {
|
|
1018
|
+
acc[key] = { example: true };
|
|
1019
|
+
}
|
|
1020
|
+
else if (normalized.type === "array") {
|
|
1021
|
+
acc[key] = ["example"];
|
|
1022
|
+
}
|
|
1023
|
+
else {
|
|
1024
|
+
acc[key] = "<".concat(key, ">");
|
|
1025
|
+
}
|
|
1026
|
+
return acc;
|
|
1027
|
+
}, {});
|
|
1028
|
+
}
|
|
1029
|
+
function formatExecutionDate(value) {
|
|
1030
|
+
if (!value) {
|
|
1031
|
+
return "Not available";
|
|
1032
|
+
}
|
|
1033
|
+
var parsed = new Date(value);
|
|
1034
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
1035
|
+
return "Not available";
|
|
1036
|
+
}
|
|
1037
|
+
return parsed.toLocaleString(undefined, {
|
|
1038
|
+
year: "numeric",
|
|
1039
|
+
month: "short",
|
|
1040
|
+
day: "numeric",
|
|
1041
|
+
hour: "numeric",
|
|
1042
|
+
minute: "2-digit",
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
function formatExecutionLogTime(value) {
|
|
1046
|
+
if (!value) {
|
|
1047
|
+
return "-";
|
|
1048
|
+
}
|
|
1049
|
+
var parsed = new Date(value);
|
|
1050
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
1051
|
+
return "-";
|
|
1052
|
+
}
|
|
1053
|
+
return parsed.toLocaleTimeString(undefined, {
|
|
1054
|
+
hour: "2-digit",
|
|
1055
|
+
minute: "2-digit",
|
|
1056
|
+
second: "2-digit",
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
function parseExecutionTimestamp(value) {
|
|
1060
|
+
if (!value) {
|
|
1061
|
+
return null;
|
|
1062
|
+
}
|
|
1063
|
+
var parsed = new Date(value).getTime();
|
|
1064
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
1065
|
+
}
|
|
1066
|
+
function getNumericDurationMs(value) {
|
|
1067
|
+
var numericValue = typeof value === "string" ? Number(value) : typeof value === "number" ? value : null;
|
|
1068
|
+
return typeof numericValue === "number" && Number.isFinite(numericValue)
|
|
1069
|
+
? numericValue
|
|
1070
|
+
: null;
|
|
1071
|
+
}
|
|
1072
|
+
function formatDurationMs(value) {
|
|
1073
|
+
var numericValue = getNumericDurationMs(value);
|
|
1074
|
+
if (numericValue == null || Number.isNaN(numericValue) || numericValue <= 0) {
|
|
1075
|
+
return "Not available";
|
|
1076
|
+
}
|
|
1077
|
+
if (numericValue < 1000) {
|
|
1078
|
+
return "".concat(numericValue, " ms");
|
|
1079
|
+
}
|
|
1080
|
+
var seconds = numericValue / 1000;
|
|
1081
|
+
if (seconds < 60) {
|
|
1082
|
+
return "".concat(seconds.toFixed(seconds >= 10 ? 0 : 1), " s");
|
|
1083
|
+
}
|
|
1084
|
+
var minutes = Math.floor(seconds / 60);
|
|
1085
|
+
var remainingSeconds = Math.round(seconds % 60);
|
|
1086
|
+
return "".concat(minutes, "m ").concat(remainingSeconds, "s");
|
|
1087
|
+
}
|
|
1088
|
+
function getExecutionStatusCategory(status) {
|
|
1089
|
+
var normalized = (status !== null && status !== void 0 ? status : "").trim().toLowerCase();
|
|
1090
|
+
if (["success", "succeeded", "completed", "complete"].includes(normalized)) {
|
|
1091
|
+
return "success";
|
|
1092
|
+
}
|
|
1093
|
+
if (["failed", "error", "errored", "cancelled", "canceled"].includes(normalized)) {
|
|
1094
|
+
return "failed";
|
|
1095
|
+
}
|
|
1096
|
+
if (["running", "in_progress", "in-progress", "started", "processing"].includes(normalized)) {
|
|
1097
|
+
return "inProgress";
|
|
1098
|
+
}
|
|
1099
|
+
if (["created", "pending", "queued", "scheduled"].includes(normalized)) {
|
|
1100
|
+
return "pending";
|
|
1101
|
+
}
|
|
1102
|
+
return "other";
|
|
1103
|
+
}
|
|
1104
|
+
function workflowLogLevelTone(level) {
|
|
1105
|
+
var value = (level !== null && level !== void 0 ? level : "").toLowerCase();
|
|
1106
|
+
if (value === "error" || value === "fatal") {
|
|
1107
|
+
return "danger";
|
|
1108
|
+
}
|
|
1109
|
+
if (value === "warn" || value === "warning") {
|
|
1110
|
+
return "warn";
|
|
1111
|
+
}
|
|
1112
|
+
if (value === "info") {
|
|
1113
|
+
return "success";
|
|
1114
|
+
}
|
|
1115
|
+
return undefined;
|
|
1116
|
+
}
|
|
1117
|
+
function buildWorkflowExecutionQueryString(options) {
|
|
1118
|
+
var _a, _b, _c;
|
|
1119
|
+
var queryData = {
|
|
1120
|
+
limit: (_a = options.limit) !== null && _a !== void 0 ? _a : WORKFLOW_EXECUTION_PAGE_SIZE,
|
|
1121
|
+
offset: (_b = options.offset) !== null && _b !== void 0 ? _b : 0,
|
|
1122
|
+
sort: ["startedAt:desc", "id:desc"],
|
|
1123
|
+
filters: {
|
|
1124
|
+
workflowDefinition: {
|
|
1125
|
+
id: {
|
|
1126
|
+
$eq: options.workflowDefinitionId,
|
|
1127
|
+
},
|
|
1128
|
+
},
|
|
1129
|
+
},
|
|
1130
|
+
};
|
|
1131
|
+
if (options.status && options.status !== "all") {
|
|
1132
|
+
queryData.filters.status = {
|
|
1133
|
+
$eqi: options.status,
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
if ((_c = options.search) === null || _c === void 0 ? void 0 : _c.trim()) {
|
|
1137
|
+
queryData.filters.executionIdentifier = {
|
|
1138
|
+
$containsi: options.search.trim(),
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
if (options.startDate || options.endDate) {
|
|
1142
|
+
queryData.filters.startedAt = {};
|
|
1143
|
+
if (options.startDate) {
|
|
1144
|
+
var startDate = new Date(options.startDate);
|
|
1145
|
+
startDate.setHours(0, 0, 0, 0);
|
|
1146
|
+
queryData.filters.startedAt.$gte = startDate.toISOString();
|
|
1147
|
+
}
|
|
1148
|
+
if (options.endDate) {
|
|
1149
|
+
var endDate = new Date(options.endDate);
|
|
1150
|
+
endDate.setHours(23, 59, 59, 999);
|
|
1151
|
+
queryData.filters.startedAt.$lte = endDate.toISOString();
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
return qs.stringify(queryData, { encodeValuesOnly: true });
|
|
1155
|
+
}
|
|
1156
|
+
function buildWorkflowExecutionLogQueryString(options) {
|
|
1157
|
+
var _a;
|
|
1158
|
+
var queryData = {
|
|
1159
|
+
limit: 200,
|
|
1160
|
+
offset: 0,
|
|
1161
|
+
populate: ["workflowStepExecution"],
|
|
1162
|
+
sort: ["sequenceNumber:asc", "occurredAt:asc", "id:asc"],
|
|
1163
|
+
filters: {
|
|
1164
|
+
workflowExecution: {
|
|
1165
|
+
id: {
|
|
1166
|
+
$eq: options.workflowExecutionId,
|
|
1167
|
+
},
|
|
1168
|
+
},
|
|
1169
|
+
},
|
|
1170
|
+
};
|
|
1171
|
+
if (options.level && options.level !== "all") {
|
|
1172
|
+
queryData.filters.level = {
|
|
1173
|
+
$eqi: options.level,
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
var trimmedSearch = (_a = options.search) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1177
|
+
if (trimmedSearch) {
|
|
1178
|
+
queryData.filters.$or = [
|
|
1179
|
+
{ message: { $containsi: trimmedSearch } },
|
|
1180
|
+
{ nodeId: { $containsi: trimmedSearch } },
|
|
1181
|
+
{ nodeType: { $containsi: trimmedSearch } },
|
|
1182
|
+
{ source: { $containsi: trimmedSearch } },
|
|
1183
|
+
{ eventType: { $containsi: trimmedSearch } },
|
|
1184
|
+
];
|
|
1185
|
+
}
|
|
1186
|
+
return qs.stringify(queryData, { encodeValuesOnly: true });
|
|
1187
|
+
}
|
|
1188
|
+
function buildWorkflowStepExecutionQueryString(options) {
|
|
1189
|
+
var queryData = {
|
|
1190
|
+
limit: 500,
|
|
1191
|
+
offset: 0,
|
|
1192
|
+
sort: ["startedAt:asc", "sequenceNumber:asc", "id:asc"],
|
|
1193
|
+
filters: {
|
|
1194
|
+
workflowExecution: {
|
|
1195
|
+
id: {
|
|
1196
|
+
$eq: options.workflowExecutionId,
|
|
1197
|
+
},
|
|
1198
|
+
},
|
|
1199
|
+
},
|
|
1200
|
+
};
|
|
1201
|
+
return qs.stringify(queryData, { encodeValuesOnly: true });
|
|
1202
|
+
}
|
|
1203
|
+
function buildTriggerDocsModel(trigger) {
|
|
1204
|
+
var _a, _b, _c, _d, _e;
|
|
1205
|
+
var triggerEntries = Object.entries(trigger !== null && trigger !== void 0 ? trigger : {}).filter(function (_a) {
|
|
1206
|
+
var key = _a[0];
|
|
1207
|
+
return !["id", "type", "description", "disabled", "name", "label"].includes(key);
|
|
1208
|
+
});
|
|
1209
|
+
return {
|
|
1210
|
+
title: (_c = (_b = (_a = trigger.label) !== null && _a !== void 0 ? _a : trigger.name) !== null && _b !== void 0 ? _b : trigger.id) !== null && _c !== void 0 ? _c : "Trigger",
|
|
1211
|
+
subtitle: (_d = trigger.type) !== null && _d !== void 0 ? _d : "Trigger",
|
|
1212
|
+
summary: (_e = trigger.description) !== null && _e !== void 0 ? _e : "Workflow trigger that can launch the workflow on a schedule or external event.",
|
|
1213
|
+
badges: ["trigger", trigger.disabled ? "disabled" : "enabled"].filter(Boolean),
|
|
1214
|
+
definitions: [
|
|
1215
|
+
{
|
|
1216
|
+
key: "behavior",
|
|
1217
|
+
label: "Behavior",
|
|
1218
|
+
content: trigger.disabled
|
|
1219
|
+
? "This trigger is currently disabled and will not launch workflow executions until it is enabled."
|
|
1220
|
+
: "This trigger is currently enabled and may launch workflow executions based on its configuration.",
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
key: "configuration",
|
|
1224
|
+
label: "Configuration",
|
|
1225
|
+
content: "```yaml\n".concat(YAML.stringify(trigger), "```"),
|
|
1226
|
+
},
|
|
1227
|
+
],
|
|
1228
|
+
outputs: triggerEntries.map(function (_a) {
|
|
1229
|
+
var key = _a[0], value = _a[1];
|
|
1230
|
+
return ({
|
|
1231
|
+
key: key,
|
|
1232
|
+
label: key,
|
|
1233
|
+
description: typeof value === "object"
|
|
1234
|
+
? "Structured trigger configuration value."
|
|
1235
|
+
: "Current value: ".concat(String(value)),
|
|
1236
|
+
valueType: Array.isArray(value)
|
|
1237
|
+
? "array"
|
|
1238
|
+
: typeof value === "boolean"
|
|
1239
|
+
? "boolean"
|
|
1240
|
+
: typeof value === "number"
|
|
1241
|
+
? "number"
|
|
1242
|
+
: typeof value === "object"
|
|
1243
|
+
? "object"
|
|
1244
|
+
: "string",
|
|
1245
|
+
});
|
|
1246
|
+
}),
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
function findNodeById(nodes, nodeId) {
|
|
1250
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1251
|
+
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
|
|
1252
|
+
var node = nodes_1[_i];
|
|
1253
|
+
if (String(node.id) === nodeId) {
|
|
1254
|
+
return node;
|
|
1255
|
+
}
|
|
1256
|
+
var fromChildren = (_h = (_f = (_d = (_b = findNodeById((_a = node.tasks) !== null && _a !== void 0 ? _a : [], nodeId)) !== null && _b !== void 0 ? _b : findNodeById((_c = node.then) !== null && _c !== void 0 ? _c : [], nodeId)) !== null && _d !== void 0 ? _d : findNodeById((_e = node.else) !== null && _e !== void 0 ? _e : [], nodeId)) !== null && _f !== void 0 ? _f : findNodeById((_g = node.defaults) !== null && _g !== void 0 ? _g : [], nodeId)) !== null && _h !== void 0 ? _h : Object.values((_j = node.cases) !== null && _j !== void 0 ? _j : {})
|
|
1257
|
+
.map(function (caseNodes) { return findNodeById(caseNodes, nodeId); })
|
|
1258
|
+
.find(Boolean);
|
|
1259
|
+
if (fromChildren) {
|
|
1260
|
+
return fromChildren;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
return undefined;
|
|
1264
|
+
}
|
|
1265
|
+
function createExpressionSuggestion(group, label, path, detail, description) {
|
|
1266
|
+
return {
|
|
1267
|
+
group: group,
|
|
1268
|
+
label: label,
|
|
1269
|
+
insertText: "{{ ".concat(path, " }}"),
|
|
1270
|
+
detail: detail,
|
|
1271
|
+
description: description,
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
function inferWorkflowValueType(value) {
|
|
1275
|
+
if (Array.isArray(value)) {
|
|
1276
|
+
return "array";
|
|
1277
|
+
}
|
|
1278
|
+
if (value === null || value === undefined) {
|
|
1279
|
+
return undefined;
|
|
1280
|
+
}
|
|
1281
|
+
return typeof value === "object" ? "object" : typeof value;
|
|
1282
|
+
}
|
|
1283
|
+
function getNodeOutputSuggestions(node, nodeTypesByType, options) {
|
|
1284
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1285
|
+
if (options === void 0) { options = {}; }
|
|
1286
|
+
var nodeId = String((_a = node.id) !== null && _a !== void 0 ? _a : "").trim();
|
|
1287
|
+
if (!nodeId) {
|
|
1288
|
+
return [];
|
|
1289
|
+
}
|
|
1290
|
+
var nodeType = nodeTypesByType.get(String((_b = node.type) !== null && _b !== void 0 ? _b : ""));
|
|
1291
|
+
var outputDefinitions = (_d = (_c = nodeType === null || nodeType === void 0 ? void 0 : nodeType.authoring) === null || _c === void 0 ? void 0 : _c.outputs) !== null && _d !== void 0 ? _d : [];
|
|
1292
|
+
var prefix = (_e = options.prefix) !== null && _e !== void 0 ? _e : "outputs.".concat(nodeId);
|
|
1293
|
+
var labelPrefix = (_f = options.labelPrefix) !== null && _f !== void 0 ? _f : nodeId;
|
|
1294
|
+
var suggestions = outputDefinitions.map(function (output) {
|
|
1295
|
+
var _a;
|
|
1296
|
+
var outputPath = (_a = output.path) !== null && _a !== void 0 ? _a : output.key;
|
|
1297
|
+
return createExpressionSuggestion("Outputs", "".concat(labelPrefix, ".").concat(outputPath), "".concat(prefix, ".").concat(outputPath), output.valueType, output.description);
|
|
1298
|
+
});
|
|
1299
|
+
if (node.type === "parallel" && options.includeParallelTaskOutputs) {
|
|
1300
|
+
((_g = node.tasks) !== null && _g !== void 0 ? _g : []).forEach(function (task, index) {
|
|
1301
|
+
suggestions.push.apply(suggestions, getNodeOutputSuggestions(task, nodeTypesByType, {
|
|
1302
|
+
prefix: "".concat(prefix, ".tasks.").concat(index, ".outputs.").concat(task.id),
|
|
1303
|
+
labelPrefix: "".concat(labelPrefix, ".tasks.").concat(index, ".").concat(task.id),
|
|
1304
|
+
}));
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
return suggestions;
|
|
1308
|
+
}
|
|
1309
|
+
function buildWorkflowExpressionSuggestions(definition, nodeTypes, currentNodeId, workflowSecrets) {
|
|
1310
|
+
var _a, _b, _c, _d;
|
|
1311
|
+
if (workflowSecrets === void 0) { workflowSecrets = []; }
|
|
1312
|
+
var nodeTypesByType = new Map(nodeTypes.map(function (nodeType) { return [nodeType.type, nodeType]; }));
|
|
1313
|
+
var suggestions = [];
|
|
1314
|
+
var seenInsertText = new Set();
|
|
1315
|
+
var addSuggestion = function (suggestion) {
|
|
1316
|
+
if (seenInsertText.has(suggestion.insertText)) {
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
seenInsertText.add(suggestion.insertText);
|
|
1320
|
+
suggestions.push(suggestion);
|
|
1321
|
+
};
|
|
1322
|
+
Object.entries((_a = definition.inputs) !== null && _a !== void 0 ? _a : {}).forEach(function (_a) {
|
|
1323
|
+
var _b;
|
|
1324
|
+
var inputKey = _a[0], inputDefinition = _a[1];
|
|
1325
|
+
var definitionObject = inputDefinition && typeof inputDefinition === "object" && !Array.isArray(inputDefinition)
|
|
1326
|
+
? inputDefinition
|
|
1327
|
+
: {};
|
|
1328
|
+
addSuggestion(createExpressionSuggestion("Inputs", inputKey, "inputs.".concat(inputKey), (_b = definitionObject.type) !== null && _b !== void 0 ? _b : inferWorkflowValueType(inputDefinition), definitionObject.description));
|
|
1329
|
+
});
|
|
1330
|
+
var variableDefinitions = ((_b = definition.metadata) === null || _b === void 0 ? void 0 : _b.variableDefinitions) &&
|
|
1331
|
+
typeof definition.metadata.variableDefinitions === "object" &&
|
|
1332
|
+
!Array.isArray(definition.metadata.variableDefinitions)
|
|
1333
|
+
? definition.metadata.variableDefinitions
|
|
1334
|
+
: {};
|
|
1335
|
+
Object.entries((_c = definition.variables) !== null && _c !== void 0 ? _c : {}).forEach(function (_a) {
|
|
1336
|
+
var _b, _c, _d;
|
|
1337
|
+
var variableKey = _a[0], variableValue = _a[1];
|
|
1338
|
+
var variableDefinition = (_b = variableDefinitions[variableKey]) !== null && _b !== void 0 ? _b : {};
|
|
1339
|
+
addSuggestion(createExpressionSuggestion("Variables", (_c = variableDefinition.label) !== null && _c !== void 0 ? _c : variableKey, "variables.".concat(variableKey), (_d = variableDefinition.type) !== null && _d !== void 0 ? _d : inferWorkflowValueType(variableValue), variableDefinition.description));
|
|
1340
|
+
});
|
|
1341
|
+
workflowSecrets
|
|
1342
|
+
.filter(function (secret) { var _a; return String((_a = secret.status) !== null && _a !== void 0 ? _a : "active") === "active"; })
|
|
1343
|
+
.forEach(function (secret) {
|
|
1344
|
+
var _a, _b;
|
|
1345
|
+
var key = String((_a = secret.key) !== null && _a !== void 0 ? _a : "").trim();
|
|
1346
|
+
if (!key) {
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
addSuggestion(createExpressionSuggestion("Secrets", secret.displayName ? "".concat(secret.displayName, " (").concat(key, ")") : key, "secrets.".concat(key), (_b = secret.valueType) !== null && _b !== void 0 ? _b : "secret", secret.description));
|
|
1350
|
+
});
|
|
1351
|
+
var addNodeOutputs = function (node) {
|
|
1352
|
+
getNodeOutputSuggestions(node, nodeTypesByType, {
|
|
1353
|
+
includeParallelTaskOutputs: true,
|
|
1354
|
+
}).forEach(addSuggestion);
|
|
1355
|
+
};
|
|
1356
|
+
var visitSequence = function (nodes) {
|
|
1357
|
+
var _a;
|
|
1358
|
+
for (var _i = 0, _b = nodes !== null && nodes !== void 0 ? nodes : []; _i < _b.length; _i++) {
|
|
1359
|
+
var node = _b[_i];
|
|
1360
|
+
if (String(node.id) === currentNodeId) {
|
|
1361
|
+
return true;
|
|
1362
|
+
}
|
|
1363
|
+
if (node.type === "parallel" && Array.isArray(node.tasks)) {
|
|
1364
|
+
var foundInParallelBranch = node.tasks.some(function (task) { return visitSequence([task]); });
|
|
1365
|
+
if (foundInParallelBranch) {
|
|
1366
|
+
return true;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
else {
|
|
1370
|
+
var childSequences = __spreadArray([
|
|
1371
|
+
node.tasks,
|
|
1372
|
+
node.then,
|
|
1373
|
+
node.else,
|
|
1374
|
+
node.defaults
|
|
1375
|
+
], Object.values((_a = node.cases) !== null && _a !== void 0 ? _a : {}), true).filter(Array.isArray);
|
|
1376
|
+
for (var _c = 0, childSequences_1 = childSequences; _c < childSequences_1.length; _c++) {
|
|
1377
|
+
var childSequence = childSequences_1[_c];
|
|
1378
|
+
if (visitSequence(childSequence)) {
|
|
1379
|
+
return true;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
addNodeOutputs(node);
|
|
1384
|
+
}
|
|
1385
|
+
return false;
|
|
1386
|
+
};
|
|
1387
|
+
visitSequence((_d = definition.nodes) !== null && _d !== void 0 ? _d : []);
|
|
1388
|
+
return suggestions;
|
|
1389
|
+
}
|
|
1390
|
+
function getFirstNodeId(nodes) {
|
|
1391
|
+
var _a, _b;
|
|
1392
|
+
return (_b = (_a = nodes[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : "";
|
|
1393
|
+
}
|
|
1394
|
+
function updateNodeById(nodes, nodeId, updater) {
|
|
1395
|
+
return nodes.map(function (node) {
|
|
1396
|
+
if (String(node.id) === nodeId) {
|
|
1397
|
+
return updater(node);
|
|
1398
|
+
}
|
|
1399
|
+
return __assign(__assign({}, node), { tasks: node.tasks ? updateNodeById(node.tasks, nodeId, updater) : node.tasks, then: node.then ? updateNodeById(node.then, nodeId, updater) : node.then, else: node.else ? updateNodeById(node.else, nodeId, updater) : node.else, defaults: node.defaults
|
|
1400
|
+
? updateNodeById(node.defaults, nodeId, updater)
|
|
1401
|
+
: node.defaults, cases: node.cases
|
|
1402
|
+
? Object.fromEntries(Object.entries(node.cases).map(function (_a) {
|
|
1403
|
+
var caseKey = _a[0], caseNodes = _a[1];
|
|
1404
|
+
return [
|
|
1405
|
+
caseKey,
|
|
1406
|
+
updateNodeById(caseNodes, nodeId, updater),
|
|
1407
|
+
];
|
|
1408
|
+
}))
|
|
1409
|
+
: node.cases });
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
function removeNodeById(nodes, nodeId) {
|
|
1413
|
+
return nodes
|
|
1414
|
+
.filter(function (node) { return String(node.id) !== nodeId; })
|
|
1415
|
+
.map(function (node) { return (__assign(__assign({}, node), { tasks: node.tasks ? removeNodeById(node.tasks, nodeId) : node.tasks, then: node.then ? removeNodeById(node.then, nodeId) : node.then, else: node.else ? removeNodeById(node.else, nodeId) : node.else, defaults: node.defaults
|
|
1416
|
+
? removeNodeById(node.defaults, nodeId)
|
|
1417
|
+
: node.defaults, cases: node.cases
|
|
1418
|
+
? Object.fromEntries(Object.entries(node.cases).map(function (_a) {
|
|
1419
|
+
var caseKey = _a[0], caseNodes = _a[1];
|
|
1420
|
+
return [
|
|
1421
|
+
caseKey,
|
|
1422
|
+
removeNodeById(caseNodes, nodeId),
|
|
1423
|
+
];
|
|
1424
|
+
}))
|
|
1425
|
+
: node.cases })); });
|
|
1426
|
+
}
|
|
1427
|
+
function insertAt(items, index, item) {
|
|
1428
|
+
var safeIndex = Math.max(0, Math.min(index, items.length));
|
|
1429
|
+
return __spreadArray(__spreadArray(__spreadArray([], items.slice(0, safeIndex), true), [item], false), items.slice(safeIndex), true);
|
|
1430
|
+
}
|
|
1431
|
+
function insertNodeIntoDefinition(definition, target, nodeToInsert) {
|
|
1432
|
+
if (target.scope === "root") {
|
|
1433
|
+
return __assign(__assign({}, definition), { nodes: insertAt(definition.nodes, target.index, nodeToInsert) });
|
|
1434
|
+
}
|
|
1435
|
+
return __assign(__assign({}, definition), { nodes: updateNodeById(definition.nodes, target.parentNodeId, function (node) {
|
|
1436
|
+
var _a, _b;
|
|
1437
|
+
var _c;
|
|
1438
|
+
if (target.scope === "case") {
|
|
1439
|
+
var cases = (_c = node.cases) !== null && _c !== void 0 ? _c : {};
|
|
1440
|
+
var caseNodes = Array.isArray(cases[target.caseKey])
|
|
1441
|
+
? cases[target.caseKey]
|
|
1442
|
+
: [];
|
|
1443
|
+
return __assign(__assign({}, node), { cases: __assign(__assign({}, cases), (_a = {}, _a[target.caseKey] = insertAt(caseNodes, target.index, nodeToInsert), _a)) });
|
|
1444
|
+
}
|
|
1445
|
+
var slotNodes = Array.isArray(node[target.slotKey])
|
|
1446
|
+
? node[target.slotKey]
|
|
1447
|
+
: [];
|
|
1448
|
+
return __assign(__assign({}, node), (_b = {}, _b[target.slotKey] = insertAt(slotNodes, target.index, nodeToInsert), _b));
|
|
1449
|
+
}) });
|
|
1450
|
+
}
|
|
1451
|
+
function getFieldValue(value, pathOrKey) {
|
|
1452
|
+
var parts = pathOrKey.split(".");
|
|
1453
|
+
var current = value;
|
|
1454
|
+
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
|
1455
|
+
var part = parts_1[_i];
|
|
1456
|
+
current = current === null || current === void 0 ? void 0 : current[part];
|
|
1457
|
+
if (current === undefined) {
|
|
1458
|
+
return undefined;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
return current;
|
|
1462
|
+
}
|
|
1463
|
+
function isConfigurationFieldVisibleForValidation(field, configuration) {
|
|
1464
|
+
var _a, _b;
|
|
1465
|
+
var visibleWhen = (_a = field.uiSchema) === null || _a === void 0 ? void 0 : _a.visibleWhen;
|
|
1466
|
+
if (!visibleWhen) {
|
|
1467
|
+
return true;
|
|
1468
|
+
}
|
|
1469
|
+
var dependencyPath = (_b = visibleWhen.path) !== null && _b !== void 0 ? _b : visibleWhen.field;
|
|
1470
|
+
if (!dependencyPath) {
|
|
1471
|
+
return true;
|
|
1472
|
+
}
|
|
1473
|
+
var dependencyValue = getFieldValue(configuration, dependencyPath);
|
|
1474
|
+
if ("equals" in visibleWhen) {
|
|
1475
|
+
return dependencyValue === visibleWhen.equals;
|
|
1476
|
+
}
|
|
1477
|
+
if ("notEquals" in visibleWhen) {
|
|
1478
|
+
return dependencyValue !== visibleWhen.notEquals;
|
|
1479
|
+
}
|
|
1480
|
+
if (Array.isArray(visibleWhen.includes)) {
|
|
1481
|
+
return visibleWhen.includes.includes(dependencyValue);
|
|
1482
|
+
}
|
|
1483
|
+
return true;
|
|
1484
|
+
}
|
|
1485
|
+
function validateWorkflowDefinitionClient(definition, nodeTypes, workflowKey) {
|
|
1486
|
+
return validateWorkflowDefinitionSchema(definition, nodeTypes, {
|
|
1487
|
+
workflowKey: workflowKey,
|
|
1488
|
+
requireWorkflowKey: true,
|
|
1489
|
+
requireRootNode: true,
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
export function WorkflowDefinitionEditorPage() {
|
|
1493
|
+
var _this = this;
|
|
1494
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
1495
|
+
var params = useParams();
|
|
1496
|
+
var navigate = useNavigate();
|
|
1497
|
+
var dispatch = useDispatch();
|
|
1498
|
+
var entityApi = React.useMemo(function () { return createSolidEntityApi("workflowDefinition"); }, []);
|
|
1499
|
+
var workflowExecutionApi = React.useMemo(function () { return createSolidEntityApi("workflowExecution"); }, []);
|
|
1500
|
+
var workflowExecutionLogApi = React.useMemo(function () { return createSolidEntityApi("workflowExecutionLog"); }, []);
|
|
1501
|
+
var workflowStepExecutionApi = React.useMemo(function () { return createSolidEntityApi("workflowStepExecution"); }, []);
|
|
1502
|
+
var workflowSecretApi = React.useMemo(function () { return createSolidEntityApi("workflowSecret"); }, []);
|
|
1503
|
+
var useCreateSolidEntityMutation = entityApi.useCreateSolidEntityMutation, useGetSolidEntityByIdQuery = entityApi.useGetSolidEntityByIdQuery, useUpdateSolidEntityMutation = entityApi.useUpdateSolidEntityMutation;
|
|
1504
|
+
var useLazyGetWorkflowExecutionsQuery = workflowExecutionApi.useLazyGetSolidEntitiesQuery;
|
|
1505
|
+
var useLazyGetWorkflowExecutionLogsQuery = workflowExecutionLogApi.useLazyGetSolidEntitiesQuery;
|
|
1506
|
+
var useLazyGetWorkflowStepExecutionsQuery = workflowStepExecutionApi.useLazyGetSolidEntitiesQuery;
|
|
1507
|
+
var useGetWorkflowSecretsQuery = workflowSecretApi.useGetSolidEntitiesQuery;
|
|
1508
|
+
var workflowDefinitionId = (_a = params.id) !== null && _a !== void 0 ? _a : "";
|
|
1509
|
+
var _w = useGetSolidEntityByIdQuery({ id: workflowDefinitionId, qs: "populate[0]=moduleMetadata" }, { skip: !workflowDefinitionId || workflowDefinitionId === "new" }), workflowDefinitionResponse = _w.data, isWorkflowDefinitionLoading = _w.isLoading, refetch = _w.refetch;
|
|
1510
|
+
var _x = useCreateSolidEntityMutation(), createWorkflowDefinition = _x[0], isCreating = _x[1].isLoading;
|
|
1511
|
+
var _y = useUpdateSolidEntityMutation(), updateWorkflowDefinition = _y[0], isSaving = _y[1].isLoading;
|
|
1512
|
+
var _z = useValidateWorkflowDefinitionMutation(), validateWorkflowDefinition = _z[0], isServerValidating = _z[1].isLoading;
|
|
1513
|
+
var _0 = useExecuteWorkflowDefinitionMutation(), executeWorkflowDefinition = _0[0], isExecuting = _0[1].isLoading;
|
|
1514
|
+
var _1 = useLazyGetWorkflowExecutionsQuery(), triggerGetWorkflowExecutions = _1[0], workflowExecutionsQuery = _1[1];
|
|
1515
|
+
var _2 = useLazyGetWorkflowExecutionsQuery(), triggerGetWorkflowExecutionPresence = _2[0], workflowExecutionPresenceQuery = _2[1];
|
|
1516
|
+
var _3 = useLazyGetWorkflowExecutionLogsQuery(), triggerGetWorkflowExecutionLogs = _3[0], workflowExecutionLogsQuery = _3[1];
|
|
1517
|
+
var _4 = useLazyGetWorkflowStepExecutionsQuery(), triggerGetWorkflowStepExecutions = _4[0], workflowStepExecutionsQuery = _4[1];
|
|
1518
|
+
var moduleMetadataResponse = useGetmodulesQuery("offset=0&limit=100&sort[0]=displayName%3Aasc").data;
|
|
1519
|
+
var workflowSecretsResponse = useGetWorkflowSecretsQuery("offset=0&limit=1000&fields[0]=id&fields[1]=key&fields[2]=displayName&fields[3]=description&fields[4]=valueType&fields[5]=status&filters[status][$eq]=active&sort[0]=key%3Aasc").data;
|
|
1520
|
+
var _5 = useGetWorkflowNodeTypesQuery(), _6 = _5.data, nodeTypes = _6 === void 0 ? [] : _6, isNodeTypesLoading = _5.isLoading, isNodeTypesError = _5.isError;
|
|
1521
|
+
var record = workflowDefinitionResponse === null || workflowDefinitionResponse === void 0 ? void 0 : workflowDefinitionResponse.data;
|
|
1522
|
+
var moduleRecords = React.useMemo(function () { var _a; return ((_a = moduleMetadataResponse === null || moduleMetadataResponse === void 0 ? void 0 : moduleMetadataResponse.records) !== null && _a !== void 0 ? _a : []); }, [moduleMetadataResponse === null || moduleMetadataResponse === void 0 ? void 0 : moduleMetadataResponse.records]);
|
|
1523
|
+
var selectableModuleRecords = React.useMemo(function () { return moduleRecords.filter(isWorkflowModuleSelectable); }, [moduleRecords]);
|
|
1524
|
+
var workflowSecretRecords = React.useMemo(function () { var _a; return ((_a = workflowSecretsResponse === null || workflowSecretsResponse === void 0 ? void 0 : workflowSecretsResponse.records) !== null && _a !== void 0 ? _a : []); }, [workflowSecretsResponse === null || workflowSecretsResponse === void 0 ? void 0 : workflowSecretsResponse.records]);
|
|
1525
|
+
var _7 = React.useState(""), workflowKey = _7[0], setWorkflowKey = _7[1];
|
|
1526
|
+
var _8 = React.useState(""), workflowDisplayName = _8[0], setWorkflowDisplayName = _8[1];
|
|
1527
|
+
var _9 = React.useState(null), workflowModule = _9[0], setWorkflowModule = _9[1];
|
|
1528
|
+
var _10 = React.useState([]), workflowModuleSuggestions = _10[0], setWorkflowModuleSuggestions = _10[1];
|
|
1529
|
+
var _11 = React.useState(""), workflowNamespace = _11[0], setWorkflowNamespace = _11[1];
|
|
1530
|
+
var _12 = React.useState(""), workflowDescription = _12[0], setWorkflowDescription = _12[1];
|
|
1531
|
+
var _13 = React.useState("draft"), workflowStatus = _13[0], setWorkflowStatus = _13[1];
|
|
1532
|
+
var _14 = React.useState([]), workflowTags = _14[0], setWorkflowTags = _14[1];
|
|
1533
|
+
var _15 = React.useState(""), workflowTagDraft = _15[0], setWorkflowTagDraft = _15[1];
|
|
1534
|
+
var _16 = React.useState({}), workflowIdentityErrors = _16[0], setWorkflowIdentityErrors = _16[1];
|
|
1535
|
+
var _17 = React.useState("curl"), triggerGuideMode = _17[0], setTriggerGuideMode = _17[1];
|
|
1536
|
+
var _18 = React.useState(false), runInputsOpen = _18[0], setRunInputsOpen = _18[1];
|
|
1537
|
+
var _19 = React.useState({}), runInputValues = _19[0], setRunInputValues = _19[1];
|
|
1538
|
+
var _20 = React.useState({}), runInputErrors = _20[0], setRunInputErrors = _20[1];
|
|
1539
|
+
var _21 = React.useState(null), defaultValueEditorInputKey = _21[0], setDefaultValueEditorInputKey = _21[1];
|
|
1540
|
+
var _22 = React.useState(""), defaultValueEditorDraft = _22[0], setDefaultValueEditorDraft = _22[1];
|
|
1541
|
+
var _23 = React.useState(""), defaultValueEditorJsonText = _23[0], setDefaultValueEditorJsonText = _23[1];
|
|
1542
|
+
var _24 = React.useState(""), defaultValueEditorError = _24[0], setDefaultValueEditorError = _24[1];
|
|
1543
|
+
var _25 = React.useState("default-value-editor"), defaultValueEditorResetToken = _25[0], setDefaultValueEditorResetToken = _25[1];
|
|
1544
|
+
var _26 = React.useState(null), variableValueEditorKey = _26[0], setVariableValueEditorKey = _26[1];
|
|
1545
|
+
var _27 = React.useState(""), variableValueEditorDraft = _27[0], setVariableValueEditorDraft = _27[1];
|
|
1546
|
+
var _28 = React.useState(""), variableValueEditorJsonText = _28[0], setVariableValueEditorJsonText = _28[1];
|
|
1547
|
+
var _29 = React.useState(""), variableValueEditorError = _29[0], setVariableValueEditorError = _29[1];
|
|
1548
|
+
var _30 = React.useState("variable-value-editor"), variableValueEditorResetToken = _30[0], setVariableValueEditorResetToken = _30[1];
|
|
1549
|
+
var _31 = React.useState(createEmptyWorkflowDefinition()), definitionDraft = _31[0], setDefinitionDraft = _31[1];
|
|
1550
|
+
var _32 = React.useState(serializeWorkflowDefinitionYaml(createEmptyWorkflowDefinition())), codeValue = _32[0], setCodeValue = _32[1];
|
|
1551
|
+
var _33 = React.useState(null), codeError = _33[0], setCodeError = _33[1];
|
|
1552
|
+
var _34 = React.useState(""), selectedNodeId = _34[0], setSelectedNodeId = _34[1];
|
|
1553
|
+
var _35 = React.useState(""), selectedTriggerId = _35[0], setSelectedTriggerId = _35[1];
|
|
1554
|
+
var _36 = React.useState(false), editorOpen = _36[0], setEditorOpen = _36[1];
|
|
1555
|
+
var _37 = React.useState(null), pendingInsertTarget = _37[0], setPendingInsertTarget = _37[1];
|
|
1556
|
+
var _38 = React.useState(false), topologyDocsOpen = _38[0], setTopologyDocsOpen = _38[1];
|
|
1557
|
+
var _39 = React.useState(""), topologyDocsNodeTypeKey = _39[0], setTopologyDocsNodeTypeKey = _39[1];
|
|
1558
|
+
var _40 = React.useState(), topologyDocsModel = _40[0], setTopologyDocsModel = _40[1];
|
|
1559
|
+
var _41 = React.useState("overview"), detailTab = _41[0], setDetailTab = _41[1];
|
|
1560
|
+
var _42 = React.useState(true), topologyViewOpen = _42[0], setTopologyViewOpen = _42[1];
|
|
1561
|
+
var _43 = React.useState(false), topologyYamlViewOpen = _43[0], setTopologyYamlViewOpen = _43[1];
|
|
1562
|
+
var _44 = React.useState(readStoredTopologySplitPercent), topologySplitPercent = _44[0], setTopologySplitPercent = _44[1];
|
|
1563
|
+
var topologySplitRef = React.useRef(null);
|
|
1564
|
+
var _45 = React.useState(null), overviewStartDate = _45[0], setOverviewStartDate = _45[1];
|
|
1565
|
+
var _46 = React.useState(null), overviewEndDate = _46[0], setOverviewEndDate = _46[1];
|
|
1566
|
+
var _47 = React.useState(1), executionPage = _47[0], setExecutionPage = _47[1];
|
|
1567
|
+
var _48 = React.useState("all"), executionStatusFilter = _48[0], setExecutionStatusFilter = _48[1];
|
|
1568
|
+
var _49 = React.useState(""), executionSearchFilter = _49[0], setExecutionSearchFilter = _49[1];
|
|
1569
|
+
var _50 = React.useState("summary"), executionWorkspaceTab = _50[0], setExecutionWorkspaceTab = _50[1];
|
|
1570
|
+
var _51 = React.useState(null), selectedExecution = _51[0], setSelectedExecution = _51[1];
|
|
1571
|
+
var _52 = React.useState("summary"), selectedExecutionTab = _52[0], setSelectedExecutionTab = _52[1];
|
|
1572
|
+
var _53 = React.useState("visual"), selectedExecutionOutputMode = _53[0], setSelectedExecutionOutputMode = _53[1];
|
|
1573
|
+
var _54 = React.useState(null), expandedExecutionOutputKey = _54[0], setExpandedExecutionOutputKey = _54[1];
|
|
1574
|
+
var _55 = React.useState("all"), executionLogLevelFilter = _55[0], setExecutionLogLevelFilter = _55[1];
|
|
1575
|
+
var _56 = React.useState(""), executionLogSearch = _56[0], setExecutionLogSearch = _56[1];
|
|
1576
|
+
var _57 = React.useState(null), expandedExecutionLogId = _57[0], setExpandedExecutionLogId = _57[1];
|
|
1577
|
+
var _58 = React.useState(null), expandedTimelineStepId = _58[0], setExpandedTimelineStepId = _58[1];
|
|
1578
|
+
var _59 = React.useState({
|
|
1579
|
+
status: "idle",
|
|
1580
|
+
errors: [],
|
|
1581
|
+
}), validationState = _59[0], setValidationState = _59[1];
|
|
1582
|
+
React.useEffect(function () {
|
|
1583
|
+
setDetailTab("overview");
|
|
1584
|
+
}, [workflowDefinitionId]);
|
|
1585
|
+
React.useEffect(function () {
|
|
1586
|
+
setOverviewStartDate(null);
|
|
1587
|
+
setOverviewEndDate(null);
|
|
1588
|
+
setExecutionPage(1);
|
|
1589
|
+
setExecutionStatusFilter("all");
|
|
1590
|
+
setExecutionSearchFilter("");
|
|
1591
|
+
setExecutionWorkspaceTab("summary");
|
|
1592
|
+
setSelectedExecution(null);
|
|
1593
|
+
setSelectedExecutionTab("summary");
|
|
1594
|
+
setSelectedExecutionOutputMode("visual");
|
|
1595
|
+
setExecutionLogLevelFilter("all");
|
|
1596
|
+
setExecutionLogSearch("");
|
|
1597
|
+
setExpandedExecutionLogId(null);
|
|
1598
|
+
setExpandedTimelineStepId(null);
|
|
1599
|
+
}, [workflowDefinitionId]);
|
|
1600
|
+
React.useEffect(function () {
|
|
1601
|
+
var _a, _b;
|
|
1602
|
+
if (workflowDefinitionId === "new") {
|
|
1603
|
+
if (!selectableModuleRecords.length) {
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
setWorkflowModule(function (current) {
|
|
1607
|
+
var _a, _b;
|
|
1608
|
+
return (_b = (_a = (current && isWorkflowModuleSelectable(current) ? current : null)) !== null && _a !== void 0 ? _a : selectableModuleRecords[0]) !== null && _b !== void 0 ? _b : null;
|
|
1609
|
+
});
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
if (!record) {
|
|
1613
|
+
return;
|
|
1614
|
+
}
|
|
1615
|
+
var selectedModule = (_b = (_a = record.moduleMetadata) !== null && _a !== void 0 ? _a : moduleRecords.find(function (module) {
|
|
1616
|
+
return module.id === record.moduleMetadataId ||
|
|
1617
|
+
module.name === record.moduleMetadataUserKey;
|
|
1618
|
+
})) !== null && _b !== void 0 ? _b : null;
|
|
1619
|
+
if (selectedModule && isWorkflowModuleSelectable(selectedModule)) {
|
|
1620
|
+
setWorkflowModule(selectedModule);
|
|
1621
|
+
}
|
|
1622
|
+
else if (selectedModule) {
|
|
1623
|
+
setWorkflowModule(null);
|
|
1624
|
+
setWorkflowIdentityErrors(function (current) { return (__assign(__assign({}, current), { moduleMetadata: "Workflows cannot be saved to Solid Core. Select an application module." })); });
|
|
1625
|
+
}
|
|
1626
|
+
}, [moduleRecords, record, selectableModuleRecords, workflowDefinitionId]);
|
|
1627
|
+
React.useEffect(function () {
|
|
1628
|
+
if (workflowDefinitionId === "new") {
|
|
1629
|
+
var emptyDefinition = createEmptyWorkflowDefinition();
|
|
1630
|
+
setWorkflowKey("");
|
|
1631
|
+
setWorkflowDisplayName("");
|
|
1632
|
+
setWorkflowNamespace("");
|
|
1633
|
+
setWorkflowDescription("");
|
|
1634
|
+
setWorkflowStatus("draft");
|
|
1635
|
+
setWorkflowTags([]);
|
|
1636
|
+
setWorkflowTagDraft("");
|
|
1637
|
+
setWorkflowIdentityErrors({});
|
|
1638
|
+
setDefinitionDraft(emptyDefinition);
|
|
1639
|
+
setCodeValue(serializeWorkflowDefinitionYaml(emptyDefinition));
|
|
1640
|
+
setCodeError(null);
|
|
1641
|
+
setSelectedNodeId("");
|
|
1642
|
+
setSelectedTriggerId("");
|
|
1643
|
+
setValidationState({ status: "idle", errors: [] });
|
|
1644
|
+
}
|
|
1645
|
+
}, [workflowDefinitionId]);
|
|
1646
|
+
React.useEffect(function () {
|
|
1647
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1648
|
+
if (workflowDefinitionId === "new") {
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
if (!record || (isNodeTypesLoading && !nodeTypes.length)) {
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
var parsed = parseWorkflowDefinitionYaml(record.definitionYaml, nodeTypes);
|
|
1655
|
+
setWorkflowKey((_a = record.key) !== null && _a !== void 0 ? _a : "");
|
|
1656
|
+
setWorkflowDisplayName((_b = record.displayName) !== null && _b !== void 0 ? _b : "");
|
|
1657
|
+
setWorkflowNamespace((_c = record.namespace) !== null && _c !== void 0 ? _c : "");
|
|
1658
|
+
setWorkflowStatus((_d = record.status) !== null && _d !== void 0 ? _d : "draft");
|
|
1659
|
+
setWorkflowTags(formatWorkflowTags(record.tags));
|
|
1660
|
+
setWorkflowTagDraft("");
|
|
1661
|
+
setWorkflowIdentityErrors({});
|
|
1662
|
+
setSelectedNodeId("");
|
|
1663
|
+
setSelectedTriggerId("");
|
|
1664
|
+
setCodeValue(parsed.yaml);
|
|
1665
|
+
if (!parsed.ok) {
|
|
1666
|
+
var nextError = parsed.errors.join("\n");
|
|
1667
|
+
setWorkflowDescription((_e = record.description) !== null && _e !== void 0 ? _e : "");
|
|
1668
|
+
setDefinitionDraft(createEmptyWorkflowDefinition());
|
|
1669
|
+
setCodeError(nextError);
|
|
1670
|
+
setValidationState({
|
|
1671
|
+
status: "invalid",
|
|
1672
|
+
source: "client",
|
|
1673
|
+
message: "Workflow definition YAML is invalid.",
|
|
1674
|
+
errors: parsed.errors,
|
|
1675
|
+
});
|
|
1676
|
+
setDetailTab("topology");
|
|
1677
|
+
setTopologyYamlViewOpen(true);
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
setWorkflowDescription((_g = (_f = record.description) !== null && _f !== void 0 ? _f : parsed.definition.description) !== null && _g !== void 0 ? _g : "");
|
|
1681
|
+
setDefinitionDraft(parsed.definition);
|
|
1682
|
+
setCodeError(null);
|
|
1683
|
+
setSelectedNodeId(getFirstNodeId(parsed.definition.nodes));
|
|
1684
|
+
setValidationState({ status: "idle", errors: [] });
|
|
1685
|
+
}, [isNodeTypesLoading, nodeTypes, record, workflowDefinitionId]);
|
|
1686
|
+
React.useEffect(function () {
|
|
1687
|
+
if (!selectedNodeId) {
|
|
1688
|
+
return;
|
|
1689
|
+
}
|
|
1690
|
+
if (!findNodeById(definitionDraft.nodes, selectedNodeId)) {
|
|
1691
|
+
setSelectedNodeId(getFirstNodeId(definitionDraft.nodes));
|
|
1692
|
+
}
|
|
1693
|
+
}, [definitionDraft.nodes, selectedNodeId]);
|
|
1694
|
+
React.useEffect(function () {
|
|
1695
|
+
var _a;
|
|
1696
|
+
if (!selectedTriggerId) {
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
var exists = ((_a = definitionDraft.triggers) !== null && _a !== void 0 ? _a : []).some(function (trigger) { return String(trigger.id) === selectedTriggerId; });
|
|
1700
|
+
if (!exists) {
|
|
1701
|
+
setSelectedTriggerId("");
|
|
1702
|
+
}
|
|
1703
|
+
}, [definitionDraft.triggers, selectedTriggerId]);
|
|
1704
|
+
React.useEffect(function () {
|
|
1705
|
+
if (typeof window === "undefined") {
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
window.localStorage.setItem(TOPOLOGY_SPLIT_STORAGE_KEY, String(Math.round(topologySplitPercent)));
|
|
1709
|
+
}, [topologySplitPercent]);
|
|
1710
|
+
var selectedNode = React.useMemo(function () { return findNodeById(definitionDraft.nodes, selectedNodeId); }, [definitionDraft.nodes, selectedNodeId]);
|
|
1711
|
+
var selectedNodeType = React.useMemo(function () {
|
|
1712
|
+
if (!(selectedNode === null || selectedNode === void 0 ? void 0 : selectedNode.type)) {
|
|
1713
|
+
return undefined;
|
|
1714
|
+
}
|
|
1715
|
+
return nodeTypes.find(function (nodeType) { return nodeType.type === selectedNode.type; });
|
|
1716
|
+
}, [nodeTypes, selectedNode]);
|
|
1717
|
+
var selectedNodeExpressionSuggestions = React.useMemo(function () {
|
|
1718
|
+
return selectedNodeId
|
|
1719
|
+
? buildWorkflowExpressionSuggestions(definitionDraft, nodeTypes, selectedNodeId, workflowSecretRecords)
|
|
1720
|
+
: [];
|
|
1721
|
+
}, [definitionDraft, nodeTypes, selectedNodeId, workflowSecretRecords]);
|
|
1722
|
+
var validateWorkflowIdentity = React.useCallback(function () {
|
|
1723
|
+
var errors = {};
|
|
1724
|
+
var displayName = workflowDisplayName.trim();
|
|
1725
|
+
var key = workflowKey.trim();
|
|
1726
|
+
var namespace = workflowNamespace.trim();
|
|
1727
|
+
var pendingTags = parseWorkflowTagInput(workflowTagDraft);
|
|
1728
|
+
var tags = __spreadArray(__spreadArray([], workflowTags, true), pendingTags, true);
|
|
1729
|
+
if (!displayName) {
|
|
1730
|
+
errors.displayName = "Workflow name is required.";
|
|
1731
|
+
}
|
|
1732
|
+
if (!(workflowModule === null || workflowModule === void 0 ? void 0 : workflowModule.id) && !(workflowModule === null || workflowModule === void 0 ? void 0 : workflowModule.name)) {
|
|
1733
|
+
errors.moduleMetadata = "Module is required.";
|
|
1734
|
+
}
|
|
1735
|
+
else if (!isWorkflowModuleSelectable(workflowModule)) {
|
|
1736
|
+
errors.moduleMetadata = "Workflows cannot be saved to Solid Core. Select an application module.";
|
|
1737
|
+
}
|
|
1738
|
+
if (!key) {
|
|
1739
|
+
errors.key = "Key is required.";
|
|
1740
|
+
}
|
|
1741
|
+
else if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(key)) {
|
|
1742
|
+
errors.key = "Key can only contain lowercase letters, numbers, and hyphens.";
|
|
1743
|
+
}
|
|
1744
|
+
if (namespace && !/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/.test(namespace)) {
|
|
1745
|
+
errors.namespace =
|
|
1746
|
+
"Namespace can only contain lowercase letters, numbers, dots, and hyphens.";
|
|
1747
|
+
}
|
|
1748
|
+
if (tags.some(function (tag) { return !/^[\w.-]+$/.test(tag); })) {
|
|
1749
|
+
errors.tags = "Tags can only contain letters, numbers, underscores, dots, and hyphens.";
|
|
1750
|
+
}
|
|
1751
|
+
setWorkflowIdentityErrors(errors);
|
|
1752
|
+
return errors;
|
|
1753
|
+
}, [
|
|
1754
|
+
workflowDisplayName,
|
|
1755
|
+
workflowKey,
|
|
1756
|
+
workflowModule,
|
|
1757
|
+
workflowNamespace,
|
|
1758
|
+
workflowTagDraft,
|
|
1759
|
+
workflowTags,
|
|
1760
|
+
]);
|
|
1761
|
+
var hasWorkflowIdentityErrors = function (errors) {
|
|
1762
|
+
return Object.keys(errors).length > 0;
|
|
1763
|
+
};
|
|
1764
|
+
var handleWorkflowDisplayNameChange = function (nextDisplayName) {
|
|
1765
|
+
setWorkflowDisplayName(nextDisplayName);
|
|
1766
|
+
if (workflowDefinitionId === "new") {
|
|
1767
|
+
setWorkflowKey(slugifyWorkflowKey(nextDisplayName));
|
|
1768
|
+
}
|
|
1769
|
+
setWorkflowIdentityErrors(function (current) { return (__assign(__assign({}, current), { displayName: undefined, key: undefined })); });
|
|
1770
|
+
};
|
|
1771
|
+
var handleWorkflowNamespaceChange = function (nextNamespace) {
|
|
1772
|
+
setWorkflowNamespace(nextNamespace);
|
|
1773
|
+
setWorkflowIdentityErrors(function (current) { return (__assign(__assign({}, current), { namespace: undefined })); });
|
|
1774
|
+
};
|
|
1775
|
+
var searchWorkflowModules = React.useCallback(function (_a) {
|
|
1776
|
+
var query = _a.query;
|
|
1777
|
+
var normalizedQuery = query.trim().toLowerCase();
|
|
1778
|
+
var nextSuggestions = normalizedQuery
|
|
1779
|
+
? selectableModuleRecords.filter(function (module) {
|
|
1780
|
+
return [module.displayName, module.name]
|
|
1781
|
+
.filter(Boolean)
|
|
1782
|
+
.some(function (value) { return String(value).toLowerCase().includes(normalizedQuery); });
|
|
1783
|
+
})
|
|
1784
|
+
: selectableModuleRecords;
|
|
1785
|
+
setWorkflowModuleSuggestions(nextSuggestions);
|
|
1786
|
+
}, [selectableModuleRecords]);
|
|
1787
|
+
var handleWorkflowModuleChange = function (_a) {
|
|
1788
|
+
var value = _a.value;
|
|
1789
|
+
if (value && !isWorkflowModuleSelectable(value)) {
|
|
1790
|
+
setWorkflowModule(null);
|
|
1791
|
+
setWorkflowIdentityErrors(function (current) { return (__assign(__assign({}, current), { moduleMetadata: "Workflows cannot be saved to Solid Core. Select an application module." })); });
|
|
1792
|
+
return;
|
|
1793
|
+
}
|
|
1794
|
+
setWorkflowModule(value !== null && value !== void 0 ? value : null);
|
|
1795
|
+
setWorkflowIdentityErrors(function (current) { return (__assign(__assign({}, current), { moduleMetadata: undefined })); });
|
|
1796
|
+
};
|
|
1797
|
+
var commitWorkflowTags = React.useCallback(function (value) {
|
|
1798
|
+
if (value === void 0) { value = workflowTagDraft; }
|
|
1799
|
+
var nextTags = parseWorkflowTagInput(value);
|
|
1800
|
+
if (!nextTags.length) {
|
|
1801
|
+
setWorkflowTagDraft("");
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
setWorkflowTags(function (current) {
|
|
1805
|
+
var seen = new Set(current.map(function (tag) { return tag.toLowerCase(); }));
|
|
1806
|
+
var merged = __spreadArray([], current, true);
|
|
1807
|
+
nextTags.forEach(function (tag) {
|
|
1808
|
+
var normalizedKey = tag.toLowerCase();
|
|
1809
|
+
if (!seen.has(normalizedKey)) {
|
|
1810
|
+
seen.add(normalizedKey);
|
|
1811
|
+
merged.push(tag);
|
|
1812
|
+
}
|
|
1813
|
+
});
|
|
1814
|
+
return merged;
|
|
1815
|
+
});
|
|
1816
|
+
setWorkflowTagDraft("");
|
|
1817
|
+
setWorkflowIdentityErrors(function (current) { return (__assign(__assign({}, current), { tags: undefined })); });
|
|
1818
|
+
}, [workflowTagDraft]);
|
|
1819
|
+
var removeWorkflowTag = function (tagToRemove) {
|
|
1820
|
+
setWorkflowTags(function (current) { return current.filter(function (tag) { return tag !== tagToRemove; }); });
|
|
1821
|
+
setWorkflowIdentityErrors(function (current) { return (__assign(__assign({}, current), { tags: undefined })); });
|
|
1822
|
+
};
|
|
1823
|
+
var handleWorkflowTagKeyDown = function (event) {
|
|
1824
|
+
if (event.key === "Enter" || event.key === ",") {
|
|
1825
|
+
event.preventDefault();
|
|
1826
|
+
commitWorkflowTags();
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
if (event.key === "Backspace" && !workflowTagDraft && workflowTags.length) {
|
|
1830
|
+
event.preventDefault();
|
|
1831
|
+
setWorkflowTags(function (current) { return current.slice(0, -1); });
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
var topologyDocsNodeType = React.useMemo(function () {
|
|
1835
|
+
if (!topologyDocsNodeTypeKey) {
|
|
1836
|
+
return undefined;
|
|
1837
|
+
}
|
|
1838
|
+
return nodeTypes.find(function (nodeType) { return nodeType.type === topologyDocsNodeTypeKey; });
|
|
1839
|
+
}, [nodeTypes, topologyDocsNodeTypeKey]);
|
|
1840
|
+
var workflowStats = React.useMemo(function () { return ({
|
|
1841
|
+
nodeCount: countNodes(definitionDraft.nodes),
|
|
1842
|
+
triggerCount: countTriggers(definitionDraft.triggers),
|
|
1843
|
+
inputCount: definitionDraft.inputs && typeof definitionDraft.inputs === "object"
|
|
1844
|
+
? Array.isArray(definitionDraft.inputs)
|
|
1845
|
+
? definitionDraft.inputs.length
|
|
1846
|
+
: Object.keys(definitionDraft.inputs).length
|
|
1847
|
+
: 0,
|
|
1848
|
+
}); }, [definitionDraft]);
|
|
1849
|
+
var numericWorkflowDefinitionId = React.useMemo(function () {
|
|
1850
|
+
var _a;
|
|
1851
|
+
var candidate = (_a = record === null || record === void 0 ? void 0 : record.id) !== null && _a !== void 0 ? _a : Number(workflowDefinitionId);
|
|
1852
|
+
var parsedCandidate = typeof candidate === "number" ? candidate : Number(candidate);
|
|
1853
|
+
return Number.isFinite(parsedCandidate) ? parsedCandidate : null;
|
|
1854
|
+
}, [record === null || record === void 0 ? void 0 : record.id, workflowDefinitionId]);
|
|
1855
|
+
var validationTag = React.useMemo(function () {
|
|
1856
|
+
if (validationState.status === "valid") {
|
|
1857
|
+
return { tone: "success", label: "Validated" };
|
|
1858
|
+
}
|
|
1859
|
+
if (validationState.status === "invalid") {
|
|
1860
|
+
return { tone: "danger", label: "Needs fixes" };
|
|
1861
|
+
}
|
|
1862
|
+
if (validationState.status === "validating") {
|
|
1863
|
+
return { tone: undefined, label: "Validating" };
|
|
1864
|
+
}
|
|
1865
|
+
return { tone: undefined, label: "Not validated" };
|
|
1866
|
+
}, [validationState.status]);
|
|
1867
|
+
var loadWorkflowExecutions = React.useCallback(function (page) {
|
|
1868
|
+
if (page === void 0) { page = executionPage; }
|
|
1869
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1870
|
+
return __generator(this, function (_a) {
|
|
1871
|
+
switch (_a.label) {
|
|
1872
|
+
case 0:
|
|
1873
|
+
if (!numericWorkflowDefinitionId) {
|
|
1874
|
+
return [2 /*return*/];
|
|
1875
|
+
}
|
|
1876
|
+
return [4 /*yield*/, triggerGetWorkflowExecutions(buildWorkflowExecutionQueryString({
|
|
1877
|
+
workflowDefinitionId: numericWorkflowDefinitionId,
|
|
1878
|
+
startDate: overviewStartDate,
|
|
1879
|
+
endDate: overviewEndDate,
|
|
1880
|
+
status: executionStatusFilter,
|
|
1881
|
+
search: executionSearchFilter,
|
|
1882
|
+
limit: WORKFLOW_EXECUTION_PAGE_SIZE,
|
|
1883
|
+
offset: (page - 1) * WORKFLOW_EXECUTION_PAGE_SIZE,
|
|
1884
|
+
}))];
|
|
1885
|
+
case 1:
|
|
1886
|
+
_a.sent();
|
|
1887
|
+
return [2 /*return*/];
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
});
|
|
1891
|
+
}, [
|
|
1892
|
+
executionPage,
|
|
1893
|
+
executionSearchFilter,
|
|
1894
|
+
executionStatusFilter,
|
|
1895
|
+
numericWorkflowDefinitionId,
|
|
1896
|
+
overviewEndDate,
|
|
1897
|
+
overviewStartDate,
|
|
1898
|
+
triggerGetWorkflowExecutions,
|
|
1899
|
+
]);
|
|
1900
|
+
var loadWorkflowExecutionPresence = React.useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1901
|
+
return __generator(this, function (_a) {
|
|
1902
|
+
switch (_a.label) {
|
|
1903
|
+
case 0:
|
|
1904
|
+
if (!numericWorkflowDefinitionId || workflowDefinitionId === "new") {
|
|
1905
|
+
return [2 /*return*/];
|
|
1906
|
+
}
|
|
1907
|
+
return [4 /*yield*/, triggerGetWorkflowExecutionPresence(buildWorkflowExecutionQueryString({
|
|
1908
|
+
workflowDefinitionId: numericWorkflowDefinitionId,
|
|
1909
|
+
limit: 1,
|
|
1910
|
+
}))];
|
|
1911
|
+
case 1:
|
|
1912
|
+
_a.sent();
|
|
1913
|
+
return [2 /*return*/];
|
|
1914
|
+
}
|
|
1915
|
+
});
|
|
1916
|
+
}); }, [
|
|
1917
|
+
numericWorkflowDefinitionId,
|
|
1918
|
+
triggerGetWorkflowExecutionPresence,
|
|
1919
|
+
workflowDefinitionId,
|
|
1920
|
+
]);
|
|
1921
|
+
React.useEffect(function () {
|
|
1922
|
+
void loadWorkflowExecutionPresence();
|
|
1923
|
+
}, [loadWorkflowExecutionPresence]);
|
|
1924
|
+
React.useEffect(function () {
|
|
1925
|
+
if (detailTab !== "executions" ||
|
|
1926
|
+
!numericWorkflowDefinitionId ||
|
|
1927
|
+
workflowDefinitionId === "new") {
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
void loadWorkflowExecutions();
|
|
1931
|
+
}, [
|
|
1932
|
+
detailTab,
|
|
1933
|
+
loadWorkflowExecutions,
|
|
1934
|
+
numericWorkflowDefinitionId,
|
|
1935
|
+
workflowDefinitionId,
|
|
1936
|
+
]);
|
|
1937
|
+
var refreshWorkflowExecutionData = React.useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1938
|
+
return __generator(this, function (_a) {
|
|
1939
|
+
switch (_a.label) {
|
|
1940
|
+
case 0:
|
|
1941
|
+
if (!numericWorkflowDefinitionId || workflowDefinitionId === "new") {
|
|
1942
|
+
return [2 /*return*/];
|
|
1943
|
+
}
|
|
1944
|
+
setExecutionPage(1);
|
|
1945
|
+
return [4 /*yield*/, Promise.all([loadWorkflowExecutionPresence(), loadWorkflowExecutions(1)])];
|
|
1946
|
+
case 1:
|
|
1947
|
+
_a.sent();
|
|
1948
|
+
return [2 /*return*/];
|
|
1949
|
+
}
|
|
1950
|
+
});
|
|
1951
|
+
}); }, [
|
|
1952
|
+
loadWorkflowExecutionPresence,
|
|
1953
|
+
loadWorkflowExecutions,
|
|
1954
|
+
numericWorkflowDefinitionId,
|
|
1955
|
+
workflowDefinitionId,
|
|
1956
|
+
]);
|
|
1957
|
+
var executionRecords = React.useMemo(function () { var _a, _b; return ((_b = (_a = workflowExecutionsQuery.data) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : []); }, [(_b = workflowExecutionsQuery.data) === null || _b === void 0 ? void 0 : _b.records]);
|
|
1958
|
+
var executionTotalRecords = (_e = (_d = (_c = workflowExecutionsQuery.data) === null || _c === void 0 ? void 0 : _c.meta) === null || _d === void 0 ? void 0 : _d.totalRecords) !== null && _e !== void 0 ? _e : 0;
|
|
1959
|
+
var executionTotalPages = Math.max(1, Math.ceil(executionTotalRecords / WORKFLOW_EXECUTION_PAGE_SIZE));
|
|
1960
|
+
var executionPageStart = executionTotalRecords
|
|
1961
|
+
? (executionPage - 1) * WORKFLOW_EXECUTION_PAGE_SIZE + 1
|
|
1962
|
+
: 0;
|
|
1963
|
+
var executionPageEnd = Math.min(executionPage * WORKFLOW_EXECUTION_PAGE_SIZE, executionTotalRecords);
|
|
1964
|
+
var openExecutionDetails = React.useCallback(function (execution) {
|
|
1965
|
+
navigate("/admin/core/solid-core/workflow-execution/detail/".concat(execution.id));
|
|
1966
|
+
}, [navigate]);
|
|
1967
|
+
var loadSelectedExecutionLogs = React.useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1968
|
+
return __generator(this, function (_a) {
|
|
1969
|
+
switch (_a.label) {
|
|
1970
|
+
case 0:
|
|
1971
|
+
if (!(selectedExecution === null || selectedExecution === void 0 ? void 0 : selectedExecution.id)) {
|
|
1972
|
+
return [2 /*return*/];
|
|
1973
|
+
}
|
|
1974
|
+
return [4 /*yield*/, triggerGetWorkflowExecutionLogs(buildWorkflowExecutionLogQueryString({
|
|
1975
|
+
workflowExecutionId: selectedExecution.id,
|
|
1976
|
+
level: executionLogLevelFilter,
|
|
1977
|
+
search: executionLogSearch,
|
|
1978
|
+
}))];
|
|
1979
|
+
case 1:
|
|
1980
|
+
_a.sent();
|
|
1981
|
+
return [2 /*return*/];
|
|
1982
|
+
}
|
|
1983
|
+
});
|
|
1984
|
+
}); }, [
|
|
1985
|
+
executionLogLevelFilter,
|
|
1986
|
+
executionLogSearch,
|
|
1987
|
+
selectedExecution === null || selectedExecution === void 0 ? void 0 : selectedExecution.id,
|
|
1988
|
+
triggerGetWorkflowExecutionLogs,
|
|
1989
|
+
]);
|
|
1990
|
+
React.useEffect(function () {
|
|
1991
|
+
if (!(selectedExecution === null || selectedExecution === void 0 ? void 0 : selectedExecution.id)) {
|
|
1992
|
+
return;
|
|
1993
|
+
}
|
|
1994
|
+
void loadSelectedExecutionLogs();
|
|
1995
|
+
}, [loadSelectedExecutionLogs, selectedExecution === null || selectedExecution === void 0 ? void 0 : selectedExecution.id]);
|
|
1996
|
+
var loadSelectedExecutionSteps = React.useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1997
|
+
return __generator(this, function (_a) {
|
|
1998
|
+
switch (_a.label) {
|
|
1999
|
+
case 0:
|
|
2000
|
+
if (!(selectedExecution === null || selectedExecution === void 0 ? void 0 : selectedExecution.id)) {
|
|
2001
|
+
return [2 /*return*/];
|
|
2002
|
+
}
|
|
2003
|
+
return [4 /*yield*/, triggerGetWorkflowStepExecutions(buildWorkflowStepExecutionQueryString({
|
|
2004
|
+
workflowExecutionId: selectedExecution.id,
|
|
2005
|
+
}))];
|
|
2006
|
+
case 1:
|
|
2007
|
+
_a.sent();
|
|
2008
|
+
return [2 /*return*/];
|
|
2009
|
+
}
|
|
2010
|
+
});
|
|
2011
|
+
}); }, [selectedExecution === null || selectedExecution === void 0 ? void 0 : selectedExecution.id, triggerGetWorkflowStepExecutions]);
|
|
2012
|
+
React.useEffect(function () {
|
|
2013
|
+
if (!(selectedExecution === null || selectedExecution === void 0 ? void 0 : selectedExecution.id)) {
|
|
2014
|
+
return;
|
|
2015
|
+
}
|
|
2016
|
+
void loadSelectedExecutionSteps();
|
|
2017
|
+
}, [loadSelectedExecutionSteps, selectedExecution === null || selectedExecution === void 0 ? void 0 : selectedExecution.id]);
|
|
2018
|
+
var executionLogRecords = React.useMemo(function () { var _a, _b; return ((_b = (_a = workflowExecutionLogsQuery.data) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : []); }, [(_f = workflowExecutionLogsQuery.data) === null || _f === void 0 ? void 0 : _f.records]);
|
|
2019
|
+
var executionStepRecords = React.useMemo(function () { var _a, _b; return ((_b = (_a = workflowStepExecutionsQuery.data) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : []); }, [(_g = workflowStepExecutionsQuery.data) === null || _g === void 0 ? void 0 : _g.records]);
|
|
2020
|
+
var executionTimeline = React.useMemo(function () {
|
|
2021
|
+
var _a, _b, _c, _d;
|
|
2022
|
+
if (!selectedExecution) {
|
|
2023
|
+
return {
|
|
2024
|
+
rows: [],
|
|
2025
|
+
totalDurationMs: 0,
|
|
2026
|
+
startLabel: "-",
|
|
2027
|
+
endLabel: "-",
|
|
2028
|
+
slowestStep: null,
|
|
2029
|
+
statusCounts: {},
|
|
2030
|
+
};
|
|
2031
|
+
}
|
|
2032
|
+
var executionStart = (_b = (_a = parseExecutionTimestamp(selectedExecution.startedAt)) !== null && _a !== void 0 ? _a : parseExecutionTimestamp(selectedExecution.createdAt)) !== null && _b !== void 0 ? _b : Date.now();
|
|
2033
|
+
var executionFinish = (_c = parseExecutionTimestamp(selectedExecution.finishedAt)) !== null && _c !== void 0 ? _c : (getNumericDurationMs(selectedExecution.durationMs) != null
|
|
2034
|
+
? executionStart + ((_d = getNumericDurationMs(selectedExecution.durationMs)) !== null && _d !== void 0 ? _d : 0)
|
|
2035
|
+
: executionStart);
|
|
2036
|
+
var sortedSteps = __spreadArray([], executionStepRecords, true).sort(function (first, second) {
|
|
2037
|
+
var _a, _b, _c, _d;
|
|
2038
|
+
var firstSequence = (_a = first.sequenceNumber) !== null && _a !== void 0 ? _a : first.id;
|
|
2039
|
+
var secondSequence = (_b = second.sequenceNumber) !== null && _b !== void 0 ? _b : second.id;
|
|
2040
|
+
var firstStart = (_c = parseExecutionTimestamp(first.startedAt)) !== null && _c !== void 0 ? _c : executionStart;
|
|
2041
|
+
var secondStart = (_d = parseExecutionTimestamp(second.startedAt)) !== null && _d !== void 0 ? _d : executionStart;
|
|
2042
|
+
return firstStart - secondStart || firstSequence - secondSequence;
|
|
2043
|
+
});
|
|
2044
|
+
var normalizedSteps = sortedSteps.map(function (step) {
|
|
2045
|
+
var _a, _b, _c, _d;
|
|
2046
|
+
var durationMs = (_a = getNumericDurationMs(step.durationMs)) !== null && _a !== void 0 ? _a : 0;
|
|
2047
|
+
var startedAt = (_c = (_b = parseExecutionTimestamp(step.startedAt)) !== null && _b !== void 0 ? _b : parseExecutionTimestamp(step.createdAt)) !== null && _c !== void 0 ? _c : executionStart;
|
|
2048
|
+
var finishedAt = (_d = parseExecutionTimestamp(step.finishedAt)) !== null && _d !== void 0 ? _d : (durationMs > 0 ? startedAt + durationMs : startedAt);
|
|
2049
|
+
return {
|
|
2050
|
+
step: step,
|
|
2051
|
+
startedAt: startedAt,
|
|
2052
|
+
finishedAt: Math.max(finishedAt, startedAt),
|
|
2053
|
+
durationMs: Math.max(durationMs, Math.max(finishedAt - startedAt, 0)),
|
|
2054
|
+
};
|
|
2055
|
+
});
|
|
2056
|
+
var startMs = Math.min.apply(Math, __spreadArray([executionStart], normalizedSteps.map(function (item) { return item.startedAt; }), false));
|
|
2057
|
+
var endMs = Math.max.apply(Math, __spreadArray(__spreadArray([executionFinish], normalizedSteps.map(function (item) { return item.finishedAt; }), false), [startMs + 1], false));
|
|
2058
|
+
var spanMs = Math.max(endMs - startMs, 1);
|
|
2059
|
+
var statusCounts = {};
|
|
2060
|
+
var slowestStep = null;
|
|
2061
|
+
var slowestDuration = -1;
|
|
2062
|
+
var rows = normalizedSteps.map(function (item, index) {
|
|
2063
|
+
var _a, _b;
|
|
2064
|
+
var status = ((_a = item.step.status) !== null && _a !== void 0 ? _a : "unknown").toLowerCase();
|
|
2065
|
+
statusCounts[status] = ((_b = statusCounts[status]) !== null && _b !== void 0 ? _b : 0) + 1;
|
|
2066
|
+
if (item.durationMs > slowestDuration) {
|
|
2067
|
+
slowestDuration = item.durationMs;
|
|
2068
|
+
slowestStep = item.step;
|
|
2069
|
+
}
|
|
2070
|
+
var width = Math.max((item.durationMs / spanMs) * 100, item.durationMs > 0 ? 1.2 : 0.55);
|
|
2071
|
+
return __assign(__assign({}, item), { index: index, label: item.step.nodeName || item.step.nodeId || item.step.stepExecutionKey || "Step ".concat(index + 1), startOffsetPercent: Math.min(Math.max(((item.startedAt - startMs) / spanMs) * 100, 0), 100), widthPercent: Math.min(width, 100), depth: item.step.parentStepExecutionKey || item.step.parentNodeId ? 1 : 0, status: status });
|
|
2072
|
+
});
|
|
2073
|
+
return {
|
|
2074
|
+
rows: rows,
|
|
2075
|
+
totalDurationMs: spanMs,
|
|
2076
|
+
startLabel: formatExecutionLogTime(new Date(startMs).toISOString()),
|
|
2077
|
+
endLabel: formatExecutionLogTime(new Date(endMs).toISOString()),
|
|
2078
|
+
slowestStep: slowestStep,
|
|
2079
|
+
statusCounts: statusCounts,
|
|
2080
|
+
};
|
|
2081
|
+
}, [executionStepRecords, selectedExecution]);
|
|
2082
|
+
var renderOutputPrimitive = React.useCallback(function (value) {
|
|
2083
|
+
if (typeof value === "string" && isUrlLike(value)) {
|
|
2084
|
+
return (_jsx("a", { href: value, target: "_blank", rel: "noreferrer", children: value }));
|
|
2085
|
+
}
|
|
2086
|
+
return formatOutputVisualValue(value);
|
|
2087
|
+
}, []);
|
|
2088
|
+
var renderOutputVisual = React.useCallback(function (value, options) {
|
|
2089
|
+
if (options === void 0) { options = {}; }
|
|
2090
|
+
var normalizedValue = normalizeJsonDisplayValue(value);
|
|
2091
|
+
if (normalizedValue === null || normalizedValue === undefined) {
|
|
2092
|
+
return (_jsxs("div", { className: "workflow-editor-output-empty", children: [_jsx("h4", { children: "No output produced" }), _jsx("p", { children: "This execution completed without returning an output payload." })] }));
|
|
2093
|
+
}
|
|
2094
|
+
if (!isPlainObjectValue(normalizedValue) && !Array.isArray(normalizedValue)) {
|
|
2095
|
+
return (_jsxs("div", { className: "workflow-editor-output-primitive", children: [_jsx("span", { children: "Result" }), _jsx("strong", { children: renderOutputPrimitive(normalizedValue) })] }));
|
|
2096
|
+
}
|
|
2097
|
+
if (Array.isArray(normalizedValue)) {
|
|
2098
|
+
if (!normalizedValue.length) {
|
|
2099
|
+
return (_jsxs("div", { className: "workflow-editor-output-empty", children: [_jsx("h4", { children: "Empty array" }), _jsx("p", { children: "The execution returned an empty collection." })] }));
|
|
2100
|
+
}
|
|
2101
|
+
var objectRows_1 = normalizedValue.filter(isPlainObjectValue);
|
|
2102
|
+
var tableKeys_1 = Array.from(new Set(objectRows_1
|
|
2103
|
+
.flatMap(function (item) { return Object.keys(item); })
|
|
2104
|
+
.filter(function (key) {
|
|
2105
|
+
return objectRows_1.some(function (item) {
|
|
2106
|
+
var cell = item[key];
|
|
2107
|
+
return !isPlainObjectValue(cell) && !Array.isArray(cell);
|
|
2108
|
+
});
|
|
2109
|
+
}))).slice(0, 6);
|
|
2110
|
+
if (objectRows_1.length === normalizedValue.length && tableKeys_1.length) {
|
|
2111
|
+
return (_jsxs("div", { className: "workflow-editor-output-visual", children: [options.hideSummary ? null : (_jsxs("div", { className: "workflow-editor-output-visual__summary", children: [_jsx("strong", { children: normalizedValue.length }), _jsx("span", { children: "items returned" })] })), _jsx("div", { className: "workflow-editor-output-table-wrap", children: _jsxs("table", { className: "workflow-editor-output-table", children: [_jsx("thead", { children: _jsx("tr", { children: tableKeys_1.map(function (key) { return (_jsx("th", { children: key }, key)); }) }) }), _jsx("tbody", { children: objectRows_1.slice(0, 25).map(function (item, index) { return (_jsx("tr", { children: tableKeys_1.map(function (key) { return (_jsx("td", { children: renderOutputPrimitive(item[key]) }, key)); }) }, index)); }) })] }) }), normalizedValue.length > 25 ? (_jsx("p", { className: "workflow-editor-output-note", children: "Showing the first 25 rows. Switch to JSON to inspect the full payload." })) : null] }));
|
|
2112
|
+
}
|
|
2113
|
+
return (_jsx("div", { className: "workflow-editor-output-list", children: normalizedValue.slice(0, 25).map(function (item, index) { return (_jsxs("div", { className: "workflow-editor-output-list-item", children: [_jsxs("span", { children: ["Item ", index + 1] }), _jsx("strong", { children: renderOutputPrimitive(item) })] }, index)); }) }));
|
|
2114
|
+
}
|
|
2115
|
+
var entries = Object.entries(normalizedValue);
|
|
2116
|
+
return (_jsxs("div", { className: "workflow-editor-output-object", children: [options.hideSummary ? null : (_jsxs("div", { className: "workflow-editor-output-visual__summary", children: [_jsx("strong", { children: entries.length }), _jsx("span", { children: "top-level fields" })] })), _jsx("div", { className: "workflow-editor-output-object-grid", children: entries.map(function (_a) {
|
|
2117
|
+
var key = _a[0], item = _a[1];
|
|
2118
|
+
var isNested = isPlainObjectValue(item) || Array.isArray(item);
|
|
2119
|
+
return (_jsxs("div", { className: "workflow-editor-output-field ".concat(isNested ? "is-nested" : ""), children: [_jsx("span", { children: key }), isNested ? (_jsx("pre", { children: formatReadonlyJson(item) })) : (_jsx("strong", { children: renderOutputPrimitive(item) }))] }, key));
|
|
2120
|
+
}) })] }));
|
|
2121
|
+
}, [renderOutputPrimitive]);
|
|
2122
|
+
var selectedExecutionModalTabs = React.useMemo(function () {
|
|
2123
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
2124
|
+
if (!selectedExecution) {
|
|
2125
|
+
return [];
|
|
2126
|
+
}
|
|
2127
|
+
var summaryContent = (_jsxs("div", { className: "workflow-editor-execution-detail-summary", children: [_jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Status" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: (_a = selectedExecution.status) !== null && _a !== void 0 ? _a : "Unknown" })] }), _jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Execution Identifier" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: (_b = selectedExecution.executionIdentifier) !== null && _b !== void 0 ? _b : "-" })] }), _jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Workflow" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: (_e = (_d = (_c = selectedExecution.workflowDisplayName) !== null && _c !== void 0 ? _c : workflowDisplayName) !== null && _d !== void 0 ? _d : record === null || record === void 0 ? void 0 : record.displayName) !== null && _e !== void 0 ? _e : "-" })] }), _jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Workflow Key" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: (_g = (_f = selectedExecution.workflowKey) !== null && _f !== void 0 ? _f : workflowKey) !== null && _g !== void 0 ? _g : "-" })] }), _jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Trigger Type" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: (_h = selectedExecution.triggerType) !== null && _h !== void 0 ? _h : "manual" })] }), _jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Started" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: formatExecutionDate(selectedExecution.startedAt || selectedExecution.createdAt) })] }), _jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Finished" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: formatExecutionDate(selectedExecution.finishedAt) })] }), _jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Duration" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: formatDurationMs(selectedExecution.durationMs) })] }), _jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Definition Version" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: (_j = selectedExecution.definitionVersion) !== null && _j !== void 0 ? _j : "-" })] }), _jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Definition Checksum" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: (_k = selectedExecution.definitionChecksum) !== null && _k !== void 0 ? _k : "-" })] }), _jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Requested By" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: (_l = selectedExecution.requestedByUserId) !== null && _l !== void 0 ? _l : "-" })] })] }));
|
|
2128
|
+
var timelineContent = (_jsxs("div", { className: "workflow-editor-execution-timeline", children: [_jsxs("div", { className: "workflow-editor-execution-timeline__hero", children: [_jsxs("div", { children: [_jsx("h4", { children: "Execution Timeline" }), _jsx("p", { children: "Step-level timing across this execution. Parallel work appears as overlapping bars; sequential work appears left-to-right." })] }), _jsxs("div", { className: "workflow-editor-execution-timeline__stats", children: [_jsxs("div", { children: [_jsx("span", { children: "Total span" }), _jsx("strong", { children: formatDurationMs(executionTimeline.totalDurationMs) })] }), _jsxs("div", { children: [_jsx("span", { children: "Steps" }), _jsx("strong", { children: executionTimeline.rows.length })] }), _jsxs("div", { children: [_jsx("span", { children: "Slowest" }), _jsx("strong", { children: (_q = (_o = (_m = executionTimeline.slowestStep) === null || _m === void 0 ? void 0 : _m.nodeName) !== null && _o !== void 0 ? _o : (_p = executionTimeline.slowestStep) === null || _p === void 0 ? void 0 : _p.nodeId) !== null && _q !== void 0 ? _q : "-" })] })] })] }), workflowStepExecutionsQuery.isFetching && !executionTimeline.rows.length ? (_jsxs("div", { className: "workflow-editor-execution-timeline__loading", children: [_jsx(SolidSpinner, {}), _jsx("span", { children: "Loading step timeline..." })] })) : executionTimeline.rows.length ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "workflow-editor-execution-timeline__legend", children: Object.entries(executionTimeline.statusCounts).map(function (_a) {
|
|
2129
|
+
var status = _a[0], count = _a[1];
|
|
2130
|
+
return (_jsxs(SolidTag, { tone: workflowLogLevelTone(status), children: [status, ": ", count] }, status));
|
|
2131
|
+
}) }), _jsxs("div", { className: "workflow-editor-execution-gantt", children: [_jsxs("div", { className: "workflow-editor-execution-gantt__ruler", children: [_jsx("span", { children: executionTimeline.startLabel }), _jsx("span", { children: formatDurationMs(executionTimeline.totalDurationMs) }), _jsx("span", { children: executionTimeline.endLabel })] }), _jsx("div", { className: "workflow-editor-execution-gantt__rows", children: executionTimeline.rows.map(function (row) {
|
|
2132
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2133
|
+
var isExpanded = expandedTimelineStepId === row.step.id;
|
|
2134
|
+
return (_jsxs("div", { className: "workflow-editor-execution-gantt-row workflow-editor-execution-gantt-row--".concat(row.status, " ").concat(isExpanded ? "is-expanded" : ""), children: [_jsxs("button", { type: "button", className: "workflow-editor-execution-gantt-row__main", "aria-expanded": isExpanded, onClick: function () {
|
|
2135
|
+
return setExpandedTimelineStepId(function (current) {
|
|
2136
|
+
return current === row.step.id ? null : row.step.id;
|
|
2137
|
+
});
|
|
2138
|
+
}, children: [_jsx("span", { className: "workflow-editor-execution-gantt-row__toggle", children: _jsx(ChevronRight, { size: 14 }) }), _jsxs("span", { className: "workflow-editor-execution-gantt-row__identity", style: { "--workflow-step-depth": row.depth }, children: [_jsx("strong", { children: row.label }), _jsx("span", { children: (_b = (_a = row.step.nodeType) !== null && _a !== void 0 ? _a : row.step.nodeKind) !== null && _b !== void 0 ? _b : "step" })] }), _jsx("span", { className: "workflow-editor-execution-gantt-row__track", children: _jsx("span", { className: "workflow-editor-execution-gantt-row__bar", style: {
|
|
2139
|
+
left: "".concat(row.startOffsetPercent, "%"),
|
|
2140
|
+
width: "".concat(row.widthPercent, "%"),
|
|
2141
|
+
} }) }), _jsx(SolidTag, { tone: workflowLogLevelTone(row.status), children: (_c = row.step.status) !== null && _c !== void 0 ? _c : "unknown" }), _jsx("span", { className: "workflow-editor-execution-gantt-row__duration", children: formatDurationMs(row.durationMs) })] }), isExpanded ? (_jsx("div", { className: "workflow-editor-execution-gantt-row__details", children: _jsxs("div", { className: "workflow-editor-execution-step-inspector", children: [_jsxs("div", { className: "workflow-editor-execution-step-inspector__header", children: [_jsxs("div", { children: [_jsx("span", { children: "Step Detail" }), _jsx("h4", { children: row.label })] }), _jsx("button", { type: "button", "aria-label": "Collapse step detail", onClick: function () { return setExpandedTimelineStepId(null); }, children: _jsx(X, { size: 14 }) })] }), _jsxs("div", { className: "workflow-editor-execution-step-inspector__meta", children: [_jsxs("div", { children: [_jsx("span", { children: "Status" }), _jsx("strong", { children: (_d = row.step.status) !== null && _d !== void 0 ? _d : "unknown" })] }), _jsxs("div", { children: [_jsx("span", { children: "Node Id" }), _jsx("strong", { children: (_e = row.step.nodeId) !== null && _e !== void 0 ? _e : "-" })] }), _jsxs("div", { children: [_jsx("span", { children: "Node Type" }), _jsx("strong", { children: (_f = row.step.nodeType) !== null && _f !== void 0 ? _f : "-" })] }), _jsxs("div", { children: [_jsx("span", { children: "Attempt" }), _jsx("strong", { children: (_g = row.step.attemptNumber) !== null && _g !== void 0 ? _g : 1 })] }), _jsxs("div", { children: [_jsx("span", { children: "Started" }), _jsx("strong", { children: formatExecutionDate(row.step.startedAt) })] }), _jsxs("div", { children: [_jsx("span", { children: "Finished" }), _jsx("strong", { children: formatExecutionDate(row.step.finishedAt) })] }), _jsxs("div", { children: [_jsx("span", { children: "Duration" }), _jsx("strong", { children: formatDurationMs(row.durationMs) })] }), _jsxs("div", { children: [_jsx("span", { children: "Step Key" }), _jsx("strong", { children: (_h = row.step.stepExecutionKey) !== null && _h !== void 0 ? _h : "-" })] })] }), row.step.errorSummary ? (_jsx("div", { className: "workflow-editor-execution-step-inspector__error", children: row.step.errorSummary })) : null] }) })) : null] }, row.step.id));
|
|
2142
|
+
}) })] })] })) : (_jsxs("div", { className: "workflow-editor-execution-timeline__empty", children: [_jsx("h4", { children: "No step timing captured" }), _jsx("p", { children: "This execution does not have persisted step execution records yet. Once step lifecycle records are present, this tab renders a proportional Gantt-style timeline automatically." })] }))] }));
|
|
2143
|
+
var logLevelCounts = executionLogRecords.reduce(function (counts, log) {
|
|
2144
|
+
var _a, _b;
|
|
2145
|
+
var key = ((_a = log.level) !== null && _a !== void 0 ? _a : "unknown").toLowerCase();
|
|
2146
|
+
counts[key] = ((_b = counts[key]) !== null && _b !== void 0 ? _b : 0) + 1;
|
|
2147
|
+
return counts;
|
|
2148
|
+
}, {});
|
|
2149
|
+
var logsContent = (_jsxs("div", { className: "workflow-editor-execution-logs", children: [_jsxs("div", { className: "workflow-editor-execution-logs__hero", children: [_jsxs("div", { children: [_jsx("h4", { children: "Execution Log Stream" }), _jsx("p", { children: "Runtime messages emitted while this execution was processed, ordered by sequence and occurrence time." })] }), _jsxs("div", { className: "workflow-editor-execution-logs__stats", children: [_jsx("span", { children: workflowExecutionLogsQuery.isFetching ? "Loading" : "".concat(executionLogRecords.length, " logs") }), Object.entries(logLevelCounts).map(function (_a) {
|
|
2150
|
+
var level = _a[0], count = _a[1];
|
|
2151
|
+
return (_jsxs(SolidTag, { tone: workflowLogLevelTone(level), children: [level, ": ", count] }, level));
|
|
2152
|
+
})] })] }), _jsxs("div", { className: "workflow-editor-execution-logs__filters", children: [_jsxs("div", { className: "workflow-editor-execution-logs__search", children: [_jsx(Search, { size: 14 }), _jsx(SolidInput, { value: executionLogSearch, placeholder: "Search message, node, source", onChange: function (event) {
|
|
2153
|
+
setExecutionLogSearch(event.target.value);
|
|
2154
|
+
setExpandedExecutionLogId(null);
|
|
2155
|
+
} })] }), _jsx(SolidSelect, { value: executionLogLevelFilter, options: WORKFLOW_LOG_LEVEL_OPTIONS, onChange: function (event) {
|
|
2156
|
+
var _a;
|
|
2157
|
+
setExecutionLogLevelFilter((_a = event.value) !== null && _a !== void 0 ? _a : "all");
|
|
2158
|
+
setExpandedExecutionLogId(null);
|
|
2159
|
+
} })] }), workflowExecutionLogsQuery.isFetching && !executionLogRecords.length ? (_jsxs("div", { className: "workflow-editor-execution-logs__loading", children: [_jsx(SolidSpinner, {}), _jsx("span", { children: "Loading execution logs..." })] })) : executionLogRecords.length ? (_jsx("div", { className: "workflow-editor-execution-log-list", children: executionLogRecords.map(function (log) {
|
|
2160
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
2161
|
+
var isSelected = expandedExecutionLogId === log.id;
|
|
2162
|
+
return (_jsxs("div", { className: "workflow-editor-execution-log-row workflow-editor-execution-log-row--".concat(((_a = log.level) !== null && _a !== void 0 ? _a : "info").toLowerCase(), " ").concat(isSelected ? "is-selected" : ""), children: [_jsxs("button", { type: "button", className: "workflow-editor-execution-log-row__main", "aria-expanded": isSelected, onClick: function () {
|
|
2163
|
+
return setExpandedExecutionLogId(function (current) {
|
|
2164
|
+
return current === log.id ? null : log.id;
|
|
2165
|
+
});
|
|
2166
|
+
}, children: [_jsx("span", { className: "workflow-editor-execution-log-row__toggle", children: _jsx(ChevronRight, { size: 14 }) }), _jsx("span", { className: "workflow-editor-execution-log-row__sequence", children: (_b = log.sequenceNumber) !== null && _b !== void 0 ? _b : log.id }), _jsx("span", { className: "workflow-editor-execution-log-row__time", children: formatExecutionLogTime(log.occurredAt || log.createdAt) }), _jsx(SolidTag, { tone: workflowLogLevelTone(log.level), children: (_c = log.level) !== null && _c !== void 0 ? _c : "info" }), _jsx("span", { className: "workflow-editor-execution-log-row__node", children: (_e = (_d = log.nodeId) !== null && _d !== void 0 ? _d : log.source) !== null && _e !== void 0 ? _e : "runtime" }), _jsx("span", { className: "workflow-editor-execution-log-row__message", children: (_f = log.message) !== null && _f !== void 0 ? _f : "No message" }), log.eventType ? (_jsx("span", { className: "workflow-editor-execution-log-row__event", children: log.eventType })) : null] }), isSelected ? (_jsx("div", { className: "workflow-editor-execution-log-row__details", children: _jsxs("div", { className: "workflow-editor-execution-log-inspector", children: [_jsxs("div", { className: "workflow-editor-execution-log-inspector__header", children: [_jsxs("div", { children: [_jsx("span", { children: "Log Detail" }), _jsx("h4", { children: (_g = log.message) !== null && _g !== void 0 ? _g : "No message" })] }), _jsx("button", { type: "button", "aria-label": "Collapse log detail", onClick: function () { return setExpandedExecutionLogId(null); }, children: _jsx(X, { size: 14 }) })] }), _jsxs("div", { className: "workflow-editor-execution-log-inspector__meta", children: [_jsxs("div", { children: [_jsx("span", { children: "Level" }), _jsx("strong", { children: (_h = log.level) !== null && _h !== void 0 ? _h : "info" })] }), _jsxs("div", { children: [_jsx("span", { children: "Sequence" }), _jsx("strong", { children: (_j = log.sequenceNumber) !== null && _j !== void 0 ? _j : log.id })] }), _jsxs("div", { children: [_jsx("span", { children: "Occurred" }), _jsx("strong", { children: formatExecutionDate(log.occurredAt || log.createdAt) })] }), _jsxs("div", { children: [_jsx("span", { children: "Node" }), _jsx("strong", { children: (_k = log.nodeId) !== null && _k !== void 0 ? _k : "-" })] }), _jsxs("div", { children: [_jsx("span", { children: "Node Type" }), _jsx("strong", { children: (_l = log.nodeType) !== null && _l !== void 0 ? _l : "-" })] }), _jsxs("div", { children: [_jsx("span", { children: "Source" }), _jsx("strong", { children: (_m = log.source) !== null && _m !== void 0 ? _m : "-" })] }), _jsxs("div", { children: [_jsx("span", { children: "Event Type" }), _jsx("strong", { children: (_o = log.eventType) !== null && _o !== void 0 ? _o : "-" })] }), _jsxs("div", { children: [_jsx("span", { children: "Log Key" }), _jsx("strong", { children: (_p = log.logKey) !== null && _p !== void 0 ? _p : "-" })] })] }), log.context || log.metadata ? (_jsxs("div", { className: "workflow-editor-execution-log-inspector__payloads", children: [_jsxs("div", { children: [_jsx("h5", { children: "Context" }), _jsx(SolidCodeEditor, { language: "json", height: "180px", fontSize: 12, readOnly: true, value: formatReadonlyJson(log.context) })] }), _jsxs("div", { children: [_jsx("h5", { children: "Metadata" }), _jsx(SolidCodeEditor, { language: "json", height: "180px", fontSize: 12, readOnly: true, value: formatReadonlyJson(log.metadata) })] })] })) : (_jsx("div", { className: "workflow-editor-execution-log-inspector__empty", children: "No structured context or metadata was captured for this log." }))] }) })) : null] }, log.id));
|
|
2167
|
+
}) })) : (_jsxs("div", { className: "workflow-editor-execution-logs__empty", children: [_jsx("h4", { children: "No logs found" }), _jsx("p", { children: "This execution has no log entries matching the current filters. Try another level or clear the search text." })] }))] }));
|
|
2168
|
+
var selectedExecutionOutputEntries = buildExecutionOutputEntries(selectedExecution.outputPayload, definitionDraft.nodes);
|
|
2169
|
+
var outputContent = (_jsxs("div", { className: "workflow-editor-output-viewer", children: [_jsxs("div", { className: "workflow-editor-output-viewer__toolbar", children: [_jsxs("div", { children: [_jsx("h4", { children: "Execution Output" }), _jsx("p", { children: "Inspect node outputs visually or switch to the raw JSON payload." })] }), _jsxs("div", { className: "workflow-editor-view-toggle", "aria-label": "Output view", children: [_jsx("button", { type: "button", className: "workflow-editor-view-toggle__button ".concat(selectedExecutionOutputMode === "visual" ? "is-active" : ""), "aria-label": "Show visual output", title: "Visual output", onClick: function () { return setSelectedExecutionOutputMode("visual"); }, children: _jsx(Layers3, { size: 14 }) }), _jsx("button", { type: "button", className: "workflow-editor-view-toggle__button ".concat(selectedExecutionOutputMode === "json" ? "is-active" : ""), "aria-label": "Show JSON output", title: "JSON output", onClick: function () { return setSelectedExecutionOutputMode("json"); }, children: _jsx(Braces, { size: 14 }) })] })] }), selectedExecutionOutputMode === "json" ? (_jsx("div", { className: "workflow-editor-output-json-editor", children: _jsx(SolidJsonEditor, { value: normalizeJsonDisplayValue(selectedExecution.outputPayload), resetToken: "execution-output-".concat(selectedExecution.id, "-").concat(selectedExecutionOutputMode), readOnly: true, className: "sdix-json-editor workflow-editor-output-json-host" }) })) : selectedExecutionOutputEntries.length ? (_jsx("div", { className: "workflow-editor-output-node-list", children: selectedExecutionOutputEntries.map(function (entry, index) {
|
|
2170
|
+
var _a;
|
|
2171
|
+
var isExpanded = expandedExecutionOutputKey === entry.key;
|
|
2172
|
+
return (_jsxs("div", { className: "workflow-editor-output-node-row ".concat(isExpanded ? "is-expanded" : ""), children: [_jsxs("button", { type: "button", className: "workflow-editor-output-node-row__header", "aria-expanded": isExpanded, onClick: function () {
|
|
2173
|
+
return setExpandedExecutionOutputKey(function (current) {
|
|
2174
|
+
return current === entry.key ? null : entry.key;
|
|
2175
|
+
});
|
|
2176
|
+
}, children: [_jsx("span", { className: "workflow-editor-output-node-row__toggle", children: _jsx(ChevronRight, { size: 15 }) }), _jsx("span", { className: "workflow-editor-output-node-row__sequence", children: index + 1 }), _jsx("span", { className: "workflow-editor-output-node-row__identity", children: _jsx("strong", { children: entry.label }) }), _jsx("span", { className: "workflow-editor-output-node-row__node-key", children: (_a = entry.nodeId) !== null && _a !== void 0 ? _a : entry.key }), entry.nodeType ? _jsx(SolidTag, { children: entry.nodeType }) : null, _jsx("span", { className: "workflow-editor-output-node-row__summary", children: summarizeOutputValue(entry.value) })] }), isExpanded ? (_jsx("div", { className: "workflow-editor-output-node-row__body", children: _jsxs("div", { className: "workflow-editor-output-node-detail", children: [_jsxs("div", { className: "workflow-editor-output-node-detail__header", children: [_jsxs("div", { children: [_jsx("span", { children: "Output Detail" }), _jsx("h4", { children: entry.label })] }), _jsx("button", { type: "button", "aria-label": "Collapse output detail", onClick: function () { return setExpandedExecutionOutputKey(null); }, children: _jsx(X, { size: 14 }) })] }), renderOutputVisual(entry.value, { hideSummary: true })] }) })) : null] }, entry.key));
|
|
2177
|
+
}) })) : (_jsxs("div", { className: "workflow-editor-output-empty", children: [_jsx("h4", { children: "No output produced" }), _jsx("p", { children: "This execution completed without returning an output payload." })] }))] }));
|
|
2178
|
+
return [
|
|
2179
|
+
{
|
|
2180
|
+
value: "summary",
|
|
2181
|
+
label: "Summary",
|
|
2182
|
+
content: summaryContent,
|
|
2183
|
+
},
|
|
2184
|
+
{
|
|
2185
|
+
value: "timeline",
|
|
2186
|
+
label: "Timeline",
|
|
2187
|
+
content: timelineContent,
|
|
2188
|
+
},
|
|
2189
|
+
{
|
|
2190
|
+
value: "logs",
|
|
2191
|
+
label: "Logs",
|
|
2192
|
+
content: logsContent,
|
|
2193
|
+
},
|
|
2194
|
+
{
|
|
2195
|
+
value: "input",
|
|
2196
|
+
label: "Input",
|
|
2197
|
+
content: (_jsx(SolidCodeEditor, { language: "json", height: "calc(100vh - 260px)", fontSize: 12, readOnly: true, value: formatReadonlyJson(selectedExecution.inputPayload) })),
|
|
2198
|
+
},
|
|
2199
|
+
{
|
|
2200
|
+
value: "output",
|
|
2201
|
+
label: "Output",
|
|
2202
|
+
content: outputContent,
|
|
2203
|
+
},
|
|
2204
|
+
{
|
|
2205
|
+
value: "error",
|
|
2206
|
+
label: "Error",
|
|
2207
|
+
content: (_jsxs("div", { className: "workflow-editor-execution-detail-error", children: [_jsxs("div", { className: "workflow-editor-execution-detail-kv", children: [_jsx("div", { className: "workflow-editor-execution-detail-kv__label", children: "Error Summary" }), _jsx("div", { className: "workflow-editor-execution-detail-kv__value", children: (_r = selectedExecution.errorSummary) !== null && _r !== void 0 ? _r : "-" })] }), _jsx(SolidCodeEditor, { language: "json", height: "calc(100vh - 320px)", fontSize: 12, readOnly: true, value: formatReadonlyJson(selectedExecution.errorDetails) })] })),
|
|
2208
|
+
},
|
|
2209
|
+
{
|
|
2210
|
+
value: "definition",
|
|
2211
|
+
label: "Definition",
|
|
2212
|
+
content: (_jsx(SolidCodeEditor, { language: "yaml", height: "calc(100vh - 260px)", fontSize: 12, readOnly: true, value: formatReadonlyYaml(selectedExecution.definitionSnapshot) })),
|
|
2213
|
+
},
|
|
2214
|
+
];
|
|
2215
|
+
}, [
|
|
2216
|
+
executionLogLevelFilter,
|
|
2217
|
+
executionLogRecords,
|
|
2218
|
+
executionLogSearch,
|
|
2219
|
+
executionTimeline,
|
|
2220
|
+
expandedExecutionOutputKey,
|
|
2221
|
+
expandedExecutionLogId,
|
|
2222
|
+
expandedTimelineStepId,
|
|
2223
|
+
definitionDraft.nodes,
|
|
2224
|
+
record === null || record === void 0 ? void 0 : record.displayName,
|
|
2225
|
+
renderOutputVisual,
|
|
2226
|
+
selectedExecution,
|
|
2227
|
+
selectedExecutionOutputMode,
|
|
2228
|
+
workflowDisplayName,
|
|
2229
|
+
workflowExecutionLogsQuery.isFetching,
|
|
2230
|
+
workflowStepExecutionsQuery.isFetching,
|
|
2231
|
+
workflowKey,
|
|
2232
|
+
]);
|
|
2233
|
+
var hasExecutions = React.useMemo(function () { var _a, _b, _c; return ((_c = (_b = (_a = workflowExecutionPresenceQuery.data) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.totalRecords) !== null && _c !== void 0 ? _c : 0) > 0; }, [(_j = (_h = workflowExecutionPresenceQuery.data) === null || _h === void 0 ? void 0 : _h.meta) === null || _j === void 0 ? void 0 : _j.totalRecords]);
|
|
2234
|
+
var executionOverview = React.useMemo(function () {
|
|
2235
|
+
var totals = {
|
|
2236
|
+
total: executionRecords.length,
|
|
2237
|
+
success: 0,
|
|
2238
|
+
failed: 0,
|
|
2239
|
+
inProgress: 0,
|
|
2240
|
+
pending: 0,
|
|
2241
|
+
other: 0,
|
|
2242
|
+
totalDurationMs: 0,
|
|
2243
|
+
durationCount: 0,
|
|
2244
|
+
};
|
|
2245
|
+
for (var _i = 0, executionRecords_1 = executionRecords; _i < executionRecords_1.length; _i++) {
|
|
2246
|
+
var execution = executionRecords_1[_i];
|
|
2247
|
+
var category = getExecutionStatusCategory(execution.status);
|
|
2248
|
+
totals[category] += 1;
|
|
2249
|
+
var durationValue = typeof execution.durationMs === "string"
|
|
2250
|
+
? Number(execution.durationMs)
|
|
2251
|
+
: execution.durationMs;
|
|
2252
|
+
if (typeof durationValue === "number" &&
|
|
2253
|
+
Number.isFinite(durationValue) &&
|
|
2254
|
+
durationValue > 0) {
|
|
2255
|
+
totals.totalDurationMs += durationValue;
|
|
2256
|
+
totals.durationCount += 1;
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
var terminalCount = totals.success + totals.failed;
|
|
2260
|
+
var successRatio = terminalCount ? Math.round((totals.success / terminalCount) * 100) : 0;
|
|
2261
|
+
var failedRatio = terminalCount ? Math.round((totals.failed / terminalCount) * 100) : 0;
|
|
2262
|
+
return __assign(__assign({}, totals), { successRatio: successRatio, failedRatio: failedRatio, averageDurationMs: totals.durationCount
|
|
2263
|
+
? Math.round(totals.totalDurationMs / totals.durationCount)
|
|
2264
|
+
: null, latestExecution: executionRecords[0] });
|
|
2265
|
+
}, [executionRecords]);
|
|
2266
|
+
var syncDraftToCode = React.useCallback(function (nextDraft) {
|
|
2267
|
+
setDefinitionDraft(nextDraft);
|
|
2268
|
+
setCodeValue(serializeWorkflowDefinitionYaml(nextDraft));
|
|
2269
|
+
setCodeError(null);
|
|
2270
|
+
setValidationState({ status: "idle", errors: [] });
|
|
2271
|
+
}, []);
|
|
2272
|
+
var handleCodeChange = function (nextValue) {
|
|
2273
|
+
var safeValue = nextValue !== null && nextValue !== void 0 ? nextValue : "";
|
|
2274
|
+
setCodeValue(safeValue);
|
|
2275
|
+
var parsed = parseWorkflowDefinitionYaml(safeValue, nodeTypes);
|
|
2276
|
+
if (!parsed.ok) {
|
|
2277
|
+
var nextError = parsed.errors.join("\n");
|
|
2278
|
+
setCodeError(nextError);
|
|
2279
|
+
setValidationState({
|
|
2280
|
+
status: "invalid",
|
|
2281
|
+
source: "client",
|
|
2282
|
+
message: "Definition YAML is invalid.",
|
|
2283
|
+
errors: parsed.errors,
|
|
2284
|
+
});
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
setDefinitionDraft(parsed.definition);
|
|
2288
|
+
setCodeError(null);
|
|
2289
|
+
setValidationState({ status: "idle", errors: [] });
|
|
2290
|
+
};
|
|
2291
|
+
var startTopologySplitResize = React.useCallback(function (event) {
|
|
2292
|
+
event.preventDefault();
|
|
2293
|
+
var container = topologySplitRef.current;
|
|
2294
|
+
if (!container) {
|
|
2295
|
+
return;
|
|
2296
|
+
}
|
|
2297
|
+
var handleMouseMove = function (moveEvent) {
|
|
2298
|
+
var rect = container.getBoundingClientRect();
|
|
2299
|
+
if (!rect.width) {
|
|
2300
|
+
return;
|
|
2301
|
+
}
|
|
2302
|
+
var nextPercent = ((moveEvent.clientX - rect.left) / rect.width) * 100;
|
|
2303
|
+
setTopologySplitPercent(Math.min(78, Math.max(22, nextPercent)));
|
|
2304
|
+
};
|
|
2305
|
+
var handleMouseUp = function () {
|
|
2306
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
2307
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
2308
|
+
};
|
|
2309
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
2310
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
2311
|
+
}, []);
|
|
2312
|
+
var createNodeFromType = function (nodeType) {
|
|
2313
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2314
|
+
var nextNode = {
|
|
2315
|
+
id: buildNodeId(nodeType.type, definitionDraft),
|
|
2316
|
+
kind: nodeType.kind,
|
|
2317
|
+
type: nodeType.type,
|
|
2318
|
+
name: (_a = nodeType.label) !== null && _a !== void 0 ? _a : nodeType.type,
|
|
2319
|
+
description: (_b = nodeType.description) !== null && _b !== void 0 ? _b : "",
|
|
2320
|
+
configuration: (_d = (_c = nodeType.authoring) === null || _c === void 0 ? void 0 : _c.defaultConfiguration) !== null && _d !== void 0 ? _d : {},
|
|
2321
|
+
};
|
|
2322
|
+
((_f = (_e = nodeType.authoring) === null || _e === void 0 ? void 0 : _e.childSlots) !== null && _f !== void 0 ? _f : []).forEach(function (slot) {
|
|
2323
|
+
var _a, _b;
|
|
2324
|
+
if (slot.kind === "case-collection") {
|
|
2325
|
+
nextNode[slot.key] = (_a = nextNode[slot.key]) !== null && _a !== void 0 ? _a : {
|
|
2326
|
+
true: [],
|
|
2327
|
+
false: [],
|
|
2328
|
+
};
|
|
2329
|
+
return;
|
|
2330
|
+
}
|
|
2331
|
+
nextNode[slot.key] = (_b = nextNode[slot.key]) !== null && _b !== void 0 ? _b : [];
|
|
2332
|
+
});
|
|
2333
|
+
return nextNode;
|
|
2334
|
+
};
|
|
2335
|
+
var validateCurrentDefinition = React.useCallback(function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
2336
|
+
var identityErrors, nextState, clientErrors, nextState, response, nextState, error_1, detail, nextState;
|
|
2337
|
+
var _a, _b, _c, _d;
|
|
2338
|
+
return __generator(this, function (_e) {
|
|
2339
|
+
switch (_e.label) {
|
|
2340
|
+
case 0:
|
|
2341
|
+
identityErrors = validateWorkflowIdentity();
|
|
2342
|
+
if (hasWorkflowIdentityErrors(identityErrors)) {
|
|
2343
|
+
setDetailTab("overview");
|
|
2344
|
+
return [2 /*return*/, {
|
|
2345
|
+
valid: false,
|
|
2346
|
+
errors: Object.values(identityErrors).filter(Boolean),
|
|
2347
|
+
fieldErrors: true,
|
|
2348
|
+
}];
|
|
2349
|
+
}
|
|
2350
|
+
if (codeError) {
|
|
2351
|
+
nextState = {
|
|
2352
|
+
status: "invalid",
|
|
2353
|
+
source: "client",
|
|
2354
|
+
message: "Definition YAML is invalid.",
|
|
2355
|
+
errors: [codeError],
|
|
2356
|
+
};
|
|
2357
|
+
setValidationState(nextState);
|
|
2358
|
+
setDetailTab("topology");
|
|
2359
|
+
return [2 /*return*/, { valid: false, errors: nextState.errors }];
|
|
2360
|
+
}
|
|
2361
|
+
setValidationState({
|
|
2362
|
+
status: "validating",
|
|
2363
|
+
errors: [],
|
|
2364
|
+
message: "Validating workflow definition...",
|
|
2365
|
+
});
|
|
2366
|
+
clientErrors = validateWorkflowDefinitionClient(__assign(__assign({}, definitionDraft), { description: workflowDescription }), nodeTypes, workflowKey);
|
|
2367
|
+
if (clientErrors.length) {
|
|
2368
|
+
nextState = {
|
|
2369
|
+
status: "invalid",
|
|
2370
|
+
source: "client",
|
|
2371
|
+
message: "Client-side validation failed.",
|
|
2372
|
+
errors: clientErrors,
|
|
2373
|
+
};
|
|
2374
|
+
setValidationState(nextState);
|
|
2375
|
+
setDetailTab("topology");
|
|
2376
|
+
return [2 /*return*/, { valid: false, errors: clientErrors }];
|
|
2377
|
+
}
|
|
2378
|
+
_e.label = 1;
|
|
2379
|
+
case 1:
|
|
2380
|
+
_e.trys.push([1, 3, , 4]);
|
|
2381
|
+
return [4 /*yield*/, validateWorkflowDefinition({
|
|
2382
|
+
definitionYaml: serializeWorkflowDefinitionYaml(__assign(__assign({}, definitionDraft), { description: workflowDescription })),
|
|
2383
|
+
}).unwrap()];
|
|
2384
|
+
case 2:
|
|
2385
|
+
response = _e.sent();
|
|
2386
|
+
nextState = {
|
|
2387
|
+
status: "valid",
|
|
2388
|
+
source: "server",
|
|
2389
|
+
message: (_a = response === null || response === void 0 ? void 0 : response.message) !== null && _a !== void 0 ? _a : "Workflow definition is valid.",
|
|
2390
|
+
errors: [],
|
|
2391
|
+
};
|
|
2392
|
+
setValidationState(nextState);
|
|
2393
|
+
if (options === null || options === void 0 ? void 0 : options.showSuccessToast) {
|
|
2394
|
+
dispatch(showToast({
|
|
2395
|
+
severity: "success",
|
|
2396
|
+
summary: "Validation passed",
|
|
2397
|
+
detail: nextState.message,
|
|
2398
|
+
}));
|
|
2399
|
+
}
|
|
2400
|
+
return [2 /*return*/, { valid: true, errors: [] }];
|
|
2401
|
+
case 3:
|
|
2402
|
+
error_1 = _e.sent();
|
|
2403
|
+
detail = (_d = (_c = (_b = error_1 === null || error_1 === void 0 ? void 0 : error_1.data) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : error_1 === null || error_1 === void 0 ? void 0 : error_1.message) !== null && _d !== void 0 ? _d : "Workflow validation failed on the server.";
|
|
2404
|
+
nextState = {
|
|
2405
|
+
status: "invalid",
|
|
2406
|
+
source: "server",
|
|
2407
|
+
message: detail,
|
|
2408
|
+
errors: [detail],
|
|
2409
|
+
};
|
|
2410
|
+
setValidationState(nextState);
|
|
2411
|
+
setDetailTab("topology");
|
|
2412
|
+
return [2 /*return*/, { valid: false, errors: [detail] }];
|
|
2413
|
+
case 4: return [2 /*return*/];
|
|
2414
|
+
}
|
|
2415
|
+
});
|
|
2416
|
+
}); }, [
|
|
2417
|
+
codeError,
|
|
2418
|
+
definitionDraft,
|
|
2419
|
+
dispatch,
|
|
2420
|
+
nodeTypes,
|
|
2421
|
+
validateWorkflowDefinition,
|
|
2422
|
+
validateWorkflowIdentity,
|
|
2423
|
+
workflowDescription,
|
|
2424
|
+
workflowKey,
|
|
2425
|
+
workflowModule,
|
|
2426
|
+
workflowNamespace,
|
|
2427
|
+
workflowStatus,
|
|
2428
|
+
workflowTagDraft,
|
|
2429
|
+
workflowTags,
|
|
2430
|
+
]);
|
|
2431
|
+
var handleInsertNode = function (target) {
|
|
2432
|
+
setPendingInsertTarget(target);
|
|
2433
|
+
setDetailTab("topology");
|
|
2434
|
+
};
|
|
2435
|
+
var handleAddNodeSubmit = function (nextNode) {
|
|
2436
|
+
if (!pendingInsertTarget) {
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2439
|
+
var nextDraft = insertNodeIntoDefinition(definitionDraft, pendingInsertTarget, nextNode);
|
|
2440
|
+
syncDraftToCode(nextDraft);
|
|
2441
|
+
setSelectedNodeId(nextNode.id);
|
|
2442
|
+
setSelectedTriggerId("");
|
|
2443
|
+
setPendingInsertTarget(null);
|
|
2444
|
+
setDetailTab("topology");
|
|
2445
|
+
};
|
|
2446
|
+
var handleUpdateSelectedNode = function (nextNode) {
|
|
2447
|
+
if (!selectedNode) {
|
|
2448
|
+
return;
|
|
2449
|
+
}
|
|
2450
|
+
var nextDraft = __assign(__assign({}, definitionDraft), { nodes: updateNodeById(definitionDraft.nodes, selectedNode.id, function () { return nextNode; }) });
|
|
2451
|
+
syncDraftToCode(nextDraft);
|
|
2452
|
+
setSelectedNodeId(nextNode.id);
|
|
2453
|
+
};
|
|
2454
|
+
var handleRemoveNode = function (nodeId) {
|
|
2455
|
+
var nextDraft = __assign(__assign({}, definitionDraft), { nodes: removeNodeById(definitionDraft.nodes, nodeId) });
|
|
2456
|
+
syncDraftToCode(nextDraft);
|
|
2457
|
+
if (selectedNodeId === nodeId) {
|
|
2458
|
+
setSelectedNodeId(getFirstNodeId(nextDraft.nodes));
|
|
2459
|
+
}
|
|
2460
|
+
};
|
|
2461
|
+
var handleSave = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2462
|
+
var validation, payload, result, createdId, error_2;
|
|
2463
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2464
|
+
return __generator(this, function (_g) {
|
|
2465
|
+
switch (_g.label) {
|
|
2466
|
+
case 0: return [4 /*yield*/, validateCurrentDefinition()];
|
|
2467
|
+
case 1:
|
|
2468
|
+
validation = _g.sent();
|
|
2469
|
+
if (!validation.valid) {
|
|
2470
|
+
if (!validation.fieldErrors) {
|
|
2471
|
+
dispatch(showToast({
|
|
2472
|
+
severity: "error",
|
|
2473
|
+
summary: "Validation failed",
|
|
2474
|
+
detail: (_a = validation.errors[0]) !== null && _a !== void 0 ? _a : "Fix validation errors before saving.",
|
|
2475
|
+
}));
|
|
2476
|
+
}
|
|
2477
|
+
return [2 /*return*/];
|
|
2478
|
+
}
|
|
2479
|
+
payload = {
|
|
2480
|
+
key: workflowKey,
|
|
2481
|
+
displayName: workflowDisplayName,
|
|
2482
|
+
moduleMetadataId: workflowModule === null || workflowModule === void 0 ? void 0 : workflowModule.id,
|
|
2483
|
+
moduleMetadataUserKey: workflowModule === null || workflowModule === void 0 ? void 0 : workflowModule.name,
|
|
2484
|
+
namespace: workflowNamespace || null,
|
|
2485
|
+
description: workflowDescription,
|
|
2486
|
+
status: workflowStatus,
|
|
2487
|
+
definitionYaml: serializeWorkflowDefinitionYaml(__assign(__assign({}, definitionDraft), { description: workflowDescription })),
|
|
2488
|
+
tags: serializeJsonDtoValue(__spreadArray(__spreadArray([], workflowTags, true), parseWorkflowTagInput(workflowTagDraft), true), []),
|
|
2489
|
+
};
|
|
2490
|
+
_g.label = 2;
|
|
2491
|
+
case 2:
|
|
2492
|
+
_g.trys.push([2, 7, , 8]);
|
|
2493
|
+
if (!(record === null || record === void 0 ? void 0 : record.id)) return [3 /*break*/, 4];
|
|
2494
|
+
return [4 /*yield*/, updateWorkflowDefinition({
|
|
2495
|
+
id: record.id,
|
|
2496
|
+
data: payload,
|
|
2497
|
+
}).unwrap()];
|
|
2498
|
+
case 3:
|
|
2499
|
+
_g.sent();
|
|
2500
|
+
dispatch(showToast({
|
|
2501
|
+
severity: "success",
|
|
2502
|
+
summary: "Saved",
|
|
2503
|
+
detail: "Workflow definition updated successfully.",
|
|
2504
|
+
}));
|
|
2505
|
+
refetch();
|
|
2506
|
+
return [3 /*break*/, 6];
|
|
2507
|
+
case 4: return [4 /*yield*/, createWorkflowDefinition(payload).unwrap()];
|
|
2508
|
+
case 5:
|
|
2509
|
+
result = _g.sent();
|
|
2510
|
+
createdId = (_c = (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : result === null || result === void 0 ? void 0 : result.id;
|
|
2511
|
+
dispatch(showToast({
|
|
2512
|
+
severity: "success",
|
|
2513
|
+
summary: "Created",
|
|
2514
|
+
detail: "Workflow definition created successfully.",
|
|
2515
|
+
}));
|
|
2516
|
+
if (createdId) {
|
|
2517
|
+
navigate("/admin/core/solid-core/workflow-definition/editor/".concat(createdId), { replace: true });
|
|
2518
|
+
}
|
|
2519
|
+
_g.label = 6;
|
|
2520
|
+
case 6: return [3 /*break*/, 8];
|
|
2521
|
+
case 7:
|
|
2522
|
+
error_2 = _g.sent();
|
|
2523
|
+
dispatch(showToast({
|
|
2524
|
+
severity: "error",
|
|
2525
|
+
summary: "Save failed",
|
|
2526
|
+
detail: (_f = (_e = (_d = error_2 === null || error_2 === void 0 ? void 0 : error_2.data) === null || _d === void 0 ? void 0 : _d.message) !== null && _e !== void 0 ? _e : error_2 === null || error_2 === void 0 ? void 0 : error_2.message) !== null && _f !== void 0 ? _f : "Failed to save workflow definition.",
|
|
2527
|
+
}));
|
|
2528
|
+
return [3 /*break*/, 8];
|
|
2529
|
+
case 8: return [2 /*return*/];
|
|
2530
|
+
}
|
|
2531
|
+
});
|
|
2532
|
+
}); };
|
|
2533
|
+
var workflowInputEntries = React.useMemo(function () { return getWorkflowInputEntries(definitionDraft.inputs); }, [definitionDraft.inputs]);
|
|
2534
|
+
var workflowVariableEntries = React.useMemo(function () { return getWorkflowVariableEntries(definitionDraft.variables, definitionDraft.metadata); }, [definitionDraft.metadata, definitionDraft.variables]);
|
|
2535
|
+
var workflowExecutionReference = workflowDefinitionId && workflowDefinitionId !== "new"
|
|
2536
|
+
? workflowDefinitionId
|
|
2537
|
+
: "{workflowDefinitionId}";
|
|
2538
|
+
var workflowExecutionKeyReference = workflowKey || "{workflowKey}";
|
|
2539
|
+
var workflowExecutionInputExample = React.useMemo(function () { return buildWorkflowInputExample(definitionDraft.inputs); }, [definitionDraft.inputs]);
|
|
2540
|
+
var workflowExecutionRequestBody = React.useMemo(function () { return ({
|
|
2541
|
+
input: workflowExecutionInputExample,
|
|
2542
|
+
triggerType: "api",
|
|
2543
|
+
}); }, [workflowExecutionInputExample]);
|
|
2544
|
+
var workflowCurlExample = React.useMemo(function () {
|
|
2545
|
+
return [
|
|
2546
|
+
"curl -X POST \"http://localhost:3000/api/workflow-definition/".concat(workflowExecutionReference, "/execute\" \\"),
|
|
2547
|
+
" -H \"Authorization: Bearer <access-token>\" \\",
|
|
2548
|
+
" -H \"Content-Type: application/json\" \\",
|
|
2549
|
+
" -d '".concat(JSON.stringify(workflowExecutionRequestBody, null, 2), "'"),
|
|
2550
|
+
].join("\n");
|
|
2551
|
+
}, [workflowExecutionReference, workflowExecutionRequestBody]);
|
|
2552
|
+
var workflowApiExample = React.useMemo(function () {
|
|
2553
|
+
return [
|
|
2554
|
+
"import { Injectable } from \"@nestjs/common\";",
|
|
2555
|
+
"import { WorkflowInvocationService } from \"@solidxai/core\";",
|
|
2556
|
+
"",
|
|
2557
|
+
"@Injectable()",
|
|
2558
|
+
"export class CustomerWorkflowSubscriber {",
|
|
2559
|
+
" constructor(private readonly workflows: WorkflowInvocationService) {}",
|
|
2560
|
+
"",
|
|
2561
|
+
" async handleCustomerEvent() {",
|
|
2562
|
+
" return this.workflows.executeByKey(",
|
|
2563
|
+
" \"".concat(workflowExecutionKeyReference, "\","),
|
|
2564
|
+
" ".concat(JSON.stringify(workflowExecutionRequestBody, null, 6).replace(/\n/g, "\n "), ","),
|
|
2565
|
+
" );",
|
|
2566
|
+
" }",
|
|
2567
|
+
"}",
|
|
2568
|
+
].join("\n");
|
|
2569
|
+
}, [workflowExecutionKeyReference, workflowExecutionRequestBody]);
|
|
2570
|
+
var defaultValueEditorEntry = React.useMemo(function () {
|
|
2571
|
+
var _a;
|
|
2572
|
+
return (_a = workflowInputEntries.find(function (entry) { return entry.key === defaultValueEditorInputKey; })) !== null && _a !== void 0 ? _a : null;
|
|
2573
|
+
}, [defaultValueEditorInputKey, workflowInputEntries]);
|
|
2574
|
+
var variableValueEditorEntry = React.useMemo(function () {
|
|
2575
|
+
var _a;
|
|
2576
|
+
return (_a = workflowVariableEntries.find(function (entry) { return entry.key === variableValueEditorKey; })) !== null && _a !== void 0 ? _a : null;
|
|
2577
|
+
}, [variableValueEditorKey, workflowVariableEntries]);
|
|
2578
|
+
var copyWorkflowTriggerExample = function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|
2579
|
+
var _a;
|
|
2580
|
+
return __generator(this, function (_b) {
|
|
2581
|
+
switch (_b.label) {
|
|
2582
|
+
case 0:
|
|
2583
|
+
_b.trys.push([0, 2, , 3]);
|
|
2584
|
+
return [4 /*yield*/, navigator.clipboard.writeText(value)];
|
|
2585
|
+
case 1:
|
|
2586
|
+
_b.sent();
|
|
2587
|
+
dispatch(showToast({
|
|
2588
|
+
severity: "success",
|
|
2589
|
+
summary: "Copied",
|
|
2590
|
+
detail: "Workflow trigger example copied to clipboard.",
|
|
2591
|
+
}));
|
|
2592
|
+
return [3 /*break*/, 3];
|
|
2593
|
+
case 2:
|
|
2594
|
+
_a = _b.sent();
|
|
2595
|
+
dispatch(showToast({
|
|
2596
|
+
severity: "error",
|
|
2597
|
+
summary: "Copy failed",
|
|
2598
|
+
detail: "Unable to copy the workflow trigger example.",
|
|
2599
|
+
}));
|
|
2600
|
+
return [3 /*break*/, 3];
|
|
2601
|
+
case 3: return [2 /*return*/];
|
|
2602
|
+
}
|
|
2603
|
+
});
|
|
2604
|
+
}); };
|
|
2605
|
+
var executeWorkflowWithInput = function (input) { return __awaiter(_this, void 0, void 0, function () {
|
|
2606
|
+
var validation, response, error_3;
|
|
2607
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2608
|
+
return __generator(this, function (_g) {
|
|
2609
|
+
switch (_g.label) {
|
|
2610
|
+
case 0:
|
|
2611
|
+
if (!(record === null || record === void 0 ? void 0 : record.id)) {
|
|
2612
|
+
dispatch(showToast({
|
|
2613
|
+
severity: "warn",
|
|
2614
|
+
summary: "Save first",
|
|
2615
|
+
detail: "Create the workflow definition before launching execution.",
|
|
2616
|
+
}));
|
|
2617
|
+
return [2 /*return*/];
|
|
2618
|
+
}
|
|
2619
|
+
return [4 /*yield*/, validateCurrentDefinition()];
|
|
2620
|
+
case 1:
|
|
2621
|
+
validation = _g.sent();
|
|
2622
|
+
if (!validation.valid) {
|
|
2623
|
+
dispatch(showToast({
|
|
2624
|
+
severity: "error",
|
|
2625
|
+
summary: "Execution blocked",
|
|
2626
|
+
detail: (_a = validation.errors[0]) !== null && _a !== void 0 ? _a : "Workflow validation failed.",
|
|
2627
|
+
}));
|
|
2628
|
+
return [2 /*return*/];
|
|
2629
|
+
}
|
|
2630
|
+
_g.label = 2;
|
|
2631
|
+
case 2:
|
|
2632
|
+
_g.trys.push([2, 4, , 5]);
|
|
2633
|
+
return [4 /*yield*/, executeWorkflowDefinition(__assign({ id: record.id }, (input ? { input: input } : {}))).unwrap()];
|
|
2634
|
+
case 3:
|
|
2635
|
+
response = _g.sent();
|
|
2636
|
+
dispatch(showToast({
|
|
2637
|
+
severity: (response === null || response === void 0 ? void 0 : response.status) === "failed" ? "error" : "success",
|
|
2638
|
+
summary: (response === null || response === void 0 ? void 0 : response.status) === "failed"
|
|
2639
|
+
? "Execution failed"
|
|
2640
|
+
: "Execution started",
|
|
2641
|
+
detail: (_c = (_b = response === null || response === void 0 ? void 0 : response.executionIdentifier) !== null && _b !== void 0 ? _b : response === null || response === void 0 ? void 0 : response.errorSummary) !== null && _c !== void 0 ? _c : "Workflow execution request completed.",
|
|
2642
|
+
}));
|
|
2643
|
+
void refreshWorkflowExecutionData();
|
|
2644
|
+
return [3 /*break*/, 5];
|
|
2645
|
+
case 4:
|
|
2646
|
+
error_3 = _g.sent();
|
|
2647
|
+
dispatch(showToast({
|
|
2648
|
+
severity: "error",
|
|
2649
|
+
summary: "Execution failed",
|
|
2650
|
+
detail: (_f = (_e = (_d = error_3 === null || error_3 === void 0 ? void 0 : error_3.data) === null || _d === void 0 ? void 0 : _d.message) !== null && _e !== void 0 ? _e : error_3 === null || error_3 === void 0 ? void 0 : error_3.message) !== null && _f !== void 0 ? _f : "Failed to execute workflow definition.",
|
|
2651
|
+
}));
|
|
2652
|
+
return [3 /*break*/, 5];
|
|
2653
|
+
case 5: return [2 /*return*/];
|
|
2654
|
+
}
|
|
2655
|
+
});
|
|
2656
|
+
}); };
|
|
2657
|
+
var handleExecute = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2658
|
+
var validation;
|
|
2659
|
+
var _a;
|
|
2660
|
+
return __generator(this, function (_b) {
|
|
2661
|
+
switch (_b.label) {
|
|
2662
|
+
case 0:
|
|
2663
|
+
if (!(record === null || record === void 0 ? void 0 : record.id)) {
|
|
2664
|
+
dispatch(showToast({
|
|
2665
|
+
severity: "warn",
|
|
2666
|
+
summary: "Save first",
|
|
2667
|
+
detail: "Create the workflow definition before launching execution.",
|
|
2668
|
+
}));
|
|
2669
|
+
return [2 /*return*/];
|
|
2670
|
+
}
|
|
2671
|
+
return [4 /*yield*/, validateCurrentDefinition()];
|
|
2672
|
+
case 1:
|
|
2673
|
+
validation = _b.sent();
|
|
2674
|
+
if (!validation.valid) {
|
|
2675
|
+
dispatch(showToast({
|
|
2676
|
+
severity: "error",
|
|
2677
|
+
summary: "Execution blocked",
|
|
2678
|
+
detail: (_a = validation.errors[0]) !== null && _a !== void 0 ? _a : "Workflow validation failed.",
|
|
2679
|
+
}));
|
|
2680
|
+
return [2 /*return*/];
|
|
2681
|
+
}
|
|
2682
|
+
if (workflowInputEntries.length) {
|
|
2683
|
+
setRunInputValues(buildWorkflowRunInputDefaults(workflowInputEntries));
|
|
2684
|
+
setRunInputErrors({});
|
|
2685
|
+
setRunInputsOpen(true);
|
|
2686
|
+
return [2 /*return*/];
|
|
2687
|
+
}
|
|
2688
|
+
return [4 /*yield*/, executeWorkflowWithInput()];
|
|
2689
|
+
case 2:
|
|
2690
|
+
_b.sent();
|
|
2691
|
+
return [2 /*return*/];
|
|
2692
|
+
}
|
|
2693
|
+
});
|
|
2694
|
+
}); };
|
|
2695
|
+
var handleRunInputsSubmit = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2696
|
+
var errors, input, _i, workflowInputEntries_1, entry, rawValue, isEmpty;
|
|
2697
|
+
var _a;
|
|
2698
|
+
return __generator(this, function (_b) {
|
|
2699
|
+
switch (_b.label) {
|
|
2700
|
+
case 0:
|
|
2701
|
+
errors = {};
|
|
2702
|
+
input = {};
|
|
2703
|
+
for (_i = 0, workflowInputEntries_1 = workflowInputEntries; _i < workflowInputEntries_1.length; _i++) {
|
|
2704
|
+
entry = workflowInputEntries_1[_i];
|
|
2705
|
+
rawValue = runInputValues[entry.key];
|
|
2706
|
+
isEmpty = entry.definition.type === "boolean"
|
|
2707
|
+
? false
|
|
2708
|
+
: rawValue === undefined || rawValue === null || String(rawValue).trim() === "";
|
|
2709
|
+
if (entry.definition.required && isEmpty) {
|
|
2710
|
+
errors[entry.key] = "This input is required.";
|
|
2711
|
+
continue;
|
|
2712
|
+
}
|
|
2713
|
+
if (!entry.definition.required && isEmpty) {
|
|
2714
|
+
continue;
|
|
2715
|
+
}
|
|
2716
|
+
try {
|
|
2717
|
+
input[entry.key] = parseWorkflowRunInputValue(rawValue, entry.definition.type);
|
|
2718
|
+
}
|
|
2719
|
+
catch (error) {
|
|
2720
|
+
errors[entry.key] = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : "Enter a valid value.";
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
setRunInputErrors(errors);
|
|
2724
|
+
if (Object.keys(errors).length) {
|
|
2725
|
+
return [2 /*return*/];
|
|
2726
|
+
}
|
|
2727
|
+
setRunInputsOpen(false);
|
|
2728
|
+
return [4 /*yield*/, executeWorkflowWithInput(input)];
|
|
2729
|
+
case 1:
|
|
2730
|
+
_b.sent();
|
|
2731
|
+
return [2 /*return*/];
|
|
2732
|
+
}
|
|
2733
|
+
});
|
|
2734
|
+
}); };
|
|
2735
|
+
var identityFieldClass = function (field) {
|
|
2736
|
+
return "workflow-editor-field ".concat(workflowIdentityErrors[field] ? "is-invalid" : "");
|
|
2737
|
+
};
|
|
2738
|
+
var renderWorkflowTagsInput = function () { return (_jsxs("div", { className: "workflow-editor-tag-input ".concat(workflowIdentityErrors.tags ? "is-invalid" : ""), children: [workflowTags.map(function (tag) { return (_jsxs("span", { className: "workflow-editor-tag-pill", children: [_jsx("span", { children: tag }), _jsx("button", { type: "button", "aria-label": "Remove ".concat(tag), onClick: function () { return removeWorkflowTag(tag); }, children: _jsx(X, { size: 12 }) })] }, tag)); }), _jsx(SolidInput, { value: workflowTagDraft, placeholder: workflowTags.length ? "Add tag" : "Type tag and press Enter", onChange: function (event) {
|
|
2739
|
+
setWorkflowTagDraft(event.target.value);
|
|
2740
|
+
setWorkflowIdentityErrors(function (current) { return (__assign(__assign({}, current), { tags: undefined })); });
|
|
2741
|
+
}, onKeyDown: handleWorkflowTagKeyDown, onBlur: function () { return commitWorkflowTags(); } })] })); };
|
|
2742
|
+
var renderWorkflowIdentityForm = function () { return (_jsx(SolidPanel, { header: "Workflow Identity", children: _jsxs("div", { className: "workflow-editor-create-form", children: [_jsxs("div", { className: identityFieldClass("moduleMetadata"), children: [_jsx("label", { children: "Module" }), _jsx(SolidAutocomplete, { value: workflowModule, suggestions: workflowModuleSuggestions, completeMethod: searchWorkflowModules, onChange: handleWorkflowModuleChange, dropdown: true, forceSelection: true, field: "displayName", placeholder: "Select module", className: "workflow-editor-autocomplete", inputClassName: workflowIdentityErrors.moduleMetadata ? "is-invalid" : undefined }), workflowIdentityErrors.moduleMetadata ? (_jsx("div", { className: "workflow-editor-field-error", children: workflowIdentityErrors.moduleMetadata })) : null] }), _jsxs("div", { className: identityFieldClass("displayName"), children: [_jsx("label", { children: "Workflow Name" }), _jsx(SolidInput, { value: workflowDisplayName, placeholder: "Send Welcome Email", className: workflowIdentityErrors.displayName ? "is-invalid" : undefined, onChange: function (event) { return handleWorkflowDisplayNameChange(event.target.value); } }), workflowIdentityErrors.displayName ? (_jsx("div", { className: "workflow-editor-field-error", children: workflowIdentityErrors.displayName })) : null] }), _jsxs("div", { className: identityFieldClass("key"), children: [_jsx("label", { children: "Key" }), _jsx(SolidInput, { value: workflowKey, readOnly: true, placeholder: "generated-from-workflow-name", className: workflowIdentityErrors.key ? "is-invalid" : undefined }), workflowIdentityErrors.key ? (_jsx("div", { className: "workflow-editor-field-error", children: workflowIdentityErrors.key })) : null] }), _jsxs("div", { className: identityFieldClass("namespace"), children: [_jsx("label", { children: "Namespace" }), _jsx(SolidInput, { value: workflowNamespace, placeholder: "customer.onboarding", className: workflowIdentityErrors.namespace ? "is-invalid" : undefined, onChange: function (event) { return handleWorkflowNamespaceChange(event.target.value); } }), workflowIdentityErrors.namespace ? (_jsx("div", { className: "workflow-editor-field-error", children: workflowIdentityErrors.namespace })) : null] }), _jsxs("div", { className: "workflow-editor-field", children: [_jsx("label", { children: "Status" }), _jsx(SolidSelect, { value: workflowStatus, options: WORKFLOW_STATUS_OPTIONS, onChange: function (event) { var _a; return setWorkflowStatus((_a = event.value) !== null && _a !== void 0 ? _a : "draft"); } })] }), _jsxs("div", { className: identityFieldClass("tags"), children: [_jsx("label", { children: "Tags" }), renderWorkflowTagsInput(), workflowIdentityErrors.tags ? (_jsx("div", { className: "workflow-editor-field-error", children: workflowIdentityErrors.tags })) : null] }), _jsxs("div", { className: "workflow-editor-field workflow-editor-field--wide", children: [_jsx("label", { children: "Description" }), _jsx(SolidTextarea, { value: workflowDescription, placeholder: "Describe what this workflow does and when it should run.", onChange: function (event) { return setWorkflowDescription(event.target.value); } })] })] }) })); };
|
|
2743
|
+
var overviewContent = (_jsx("div", { className: "workflow-editor-overview workflow-editor-overview--create", children: renderWorkflowIdentityForm() }));
|
|
2744
|
+
var renderOptionalAuthoringEmptyState = function (_a) {
|
|
2745
|
+
var icon = _a.icon, title = _a.title, body = _a.body, examples = _a.examples, primaryLabel = _a.primaryLabel, onPrimaryClick = _a.onPrimaryClick;
|
|
2746
|
+
return (_jsxs("div", { className: "workflow-editor-optional-state", children: [_jsx("div", { className: "workflow-editor-placeholder__icon", children: icon }), _jsxs("div", { className: "workflow-editor-optional-state__copy", children: [_jsx("h3", { children: title }), _jsx("p", { children: body })] }), _jsx("div", { className: "workflow-editor-optional-state__examples", children: examples.map(function (example) { return (_jsx(SolidTag, { children: example }, example)); }) }), _jsxs("div", { className: "workflow-editor-optional-state__actions", children: [_jsx(SolidButton, { onClick: onPrimaryClick, children: primaryLabel }), _jsx(SolidButton, { variant: "outline", onClick: function () { return setDetailTab("topology"); }, children: "Configure Flow" })] })] }));
|
|
2747
|
+
};
|
|
2748
|
+
var triggerEntries = ((_k = definitionDraft.triggers) !== null && _k !== void 0 ? _k : []).map(function (trigger, index) { return ({
|
|
2749
|
+
index: index,
|
|
2750
|
+
trigger: normalizeWorkflowTriggerDefinition(trigger),
|
|
2751
|
+
}); });
|
|
2752
|
+
var scheduledTriggerEntries = triggerEntries.filter(function (_a) {
|
|
2753
|
+
var trigger = _a.trigger;
|
|
2754
|
+
return trigger.type === "schedule";
|
|
2755
|
+
});
|
|
2756
|
+
var updateWorkflowInputs = function (nextInputs) {
|
|
2757
|
+
syncDraftToCode(__assign(__assign({}, definitionDraft), { inputs: nextInputs }));
|
|
2758
|
+
};
|
|
2759
|
+
var addWorkflowInput = function () {
|
|
2760
|
+
var _a;
|
|
2761
|
+
var _b, _c;
|
|
2762
|
+
var nextKey = buildUniqueWorkflowInputKey("Input", Object.keys((_b = definitionDraft.inputs) !== null && _b !== void 0 ? _b : {}));
|
|
2763
|
+
updateWorkflowInputs(__assign(__assign({}, ((_c = definitionDraft.inputs) !== null && _c !== void 0 ? _c : {})), (_a = {}, _a[nextKey] = {
|
|
2764
|
+
type: "string",
|
|
2765
|
+
label: "Input",
|
|
2766
|
+
required: false,
|
|
2767
|
+
default: "",
|
|
2768
|
+
description: "",
|
|
2769
|
+
}, _a)));
|
|
2770
|
+
};
|
|
2771
|
+
var updateWorkflowInputLabel = function (currentKey, nextLabel) {
|
|
2772
|
+
var _a;
|
|
2773
|
+
var currentInputs = (_a = definitionDraft.inputs) !== null && _a !== void 0 ? _a : {};
|
|
2774
|
+
var nextKey = buildUniqueWorkflowInputKey(nextLabel || currentKey, Object.keys(currentInputs).filter(function (key) { return key !== currentKey; }));
|
|
2775
|
+
if (!nextKey) {
|
|
2776
|
+
return;
|
|
2777
|
+
}
|
|
2778
|
+
var nextInputs = {};
|
|
2779
|
+
Object.entries(currentInputs).forEach(function (_a) {
|
|
2780
|
+
var key = _a[0], value = _a[1];
|
|
2781
|
+
nextInputs[key === currentKey
|
|
2782
|
+
? nextKey
|
|
2783
|
+
: key] = key === currentKey
|
|
2784
|
+
? __assign(__assign({}, normalizeWorkflowInputDefinition(value)), { label: nextLabel }) : value;
|
|
2785
|
+
});
|
|
2786
|
+
updateWorkflowInputs(nextInputs);
|
|
2787
|
+
};
|
|
2788
|
+
var updateWorkflowInput = function (key, patch) {
|
|
2789
|
+
var _a;
|
|
2790
|
+
var _b;
|
|
2791
|
+
var currentInputs = (_b = definitionDraft.inputs) !== null && _b !== void 0 ? _b : {};
|
|
2792
|
+
updateWorkflowInputs(__assign(__assign({}, currentInputs), (_a = {}, _a[key] = __assign(__assign({}, normalizeWorkflowInputDefinition(currentInputs[key])), patch), _a)));
|
|
2793
|
+
};
|
|
2794
|
+
var closeDefaultValueEditor = function () {
|
|
2795
|
+
setDefaultValueEditorInputKey(null);
|
|
2796
|
+
setDefaultValueEditorDraft("");
|
|
2797
|
+
setDefaultValueEditorJsonText("");
|
|
2798
|
+
setDefaultValueEditorError("");
|
|
2799
|
+
};
|
|
2800
|
+
var openDefaultValueEditor = function (key) {
|
|
2801
|
+
var _a;
|
|
2802
|
+
var definition = normalizeWorkflowInputDefinition(((_a = definitionDraft.inputs) !== null && _a !== void 0 ? _a : {})[key]);
|
|
2803
|
+
var editorValue = getWorkflowInputDefaultEditorValue(definition.default, definition.type);
|
|
2804
|
+
setDefaultValueEditorInputKey(key);
|
|
2805
|
+
setDefaultValueEditorDraft(editorValue);
|
|
2806
|
+
setDefaultValueEditorJsonText(definition.type === "object" || definition.type === "array"
|
|
2807
|
+
? JSON.stringify(editorValue, null, 2)
|
|
2808
|
+
: "");
|
|
2809
|
+
setDefaultValueEditorError("");
|
|
2810
|
+
setDefaultValueEditorResetToken("default-value-editor-".concat(key, "-").concat(Date.now()));
|
|
2811
|
+
};
|
|
2812
|
+
var saveDefaultValueEditor = function () {
|
|
2813
|
+
if (!defaultValueEditorEntry) {
|
|
2814
|
+
return;
|
|
2815
|
+
}
|
|
2816
|
+
var type = defaultValueEditorEntry.definition.type;
|
|
2817
|
+
var nextDefaultValue = defaultValueEditorDraft;
|
|
2818
|
+
try {
|
|
2819
|
+
if (type === "object" || type === "array") {
|
|
2820
|
+
var trimmedText = defaultValueEditorJsonText.trim();
|
|
2821
|
+
nextDefaultValue = trimmedText
|
|
2822
|
+
? JSON.parse(trimmedText)
|
|
2823
|
+
: type === "array"
|
|
2824
|
+
? []
|
|
2825
|
+
: {};
|
|
2826
|
+
if (type === "array" && !Array.isArray(nextDefaultValue)) {
|
|
2827
|
+
throw new Error("Default value must be a JSON array.");
|
|
2828
|
+
}
|
|
2829
|
+
if (type === "object" && !isPlainObjectValue(nextDefaultValue)) {
|
|
2830
|
+
throw new Error("Default value must be a JSON object.");
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
else if (isWorkflowExpressionString(nextDefaultValue)) {
|
|
2834
|
+
nextDefaultValue = String(nextDefaultValue).trim();
|
|
2835
|
+
}
|
|
2836
|
+
else if (type === "number") {
|
|
2837
|
+
if (nextDefaultValue === "" || nextDefaultValue === null || nextDefaultValue === undefined) {
|
|
2838
|
+
nextDefaultValue = "";
|
|
2839
|
+
}
|
|
2840
|
+
else {
|
|
2841
|
+
var numericValue = Number(nextDefaultValue);
|
|
2842
|
+
if (!Number.isFinite(numericValue)) {
|
|
2843
|
+
throw new Error("Default value must be a valid number.");
|
|
2844
|
+
}
|
|
2845
|
+
nextDefaultValue = numericValue;
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
else if (type === "boolean") {
|
|
2849
|
+
nextDefaultValue = Boolean(nextDefaultValue);
|
|
2850
|
+
}
|
|
2851
|
+
else {
|
|
2852
|
+
nextDefaultValue = nextDefaultValue !== null && nextDefaultValue !== void 0 ? nextDefaultValue : "";
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
catch (error) {
|
|
2856
|
+
setDefaultValueEditorError((error === null || error === void 0 ? void 0 : error.message) ? String(error.message) : "Default value is invalid.");
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
updateWorkflowInput(defaultValueEditorEntry.key, { default: nextDefaultValue });
|
|
2860
|
+
closeDefaultValueEditor();
|
|
2861
|
+
};
|
|
2862
|
+
var clearDefaultValueEditor = function () {
|
|
2863
|
+
if (!defaultValueEditorEntry) {
|
|
2864
|
+
return;
|
|
2865
|
+
}
|
|
2866
|
+
updateWorkflowInput(defaultValueEditorEntry.key, { default: "" });
|
|
2867
|
+
closeDefaultValueEditor();
|
|
2868
|
+
};
|
|
2869
|
+
var removeWorkflowInput = function (keyToRemove) {
|
|
2870
|
+
var _a;
|
|
2871
|
+
var nextInputs = __assign({}, ((_a = definitionDraft.inputs) !== null && _a !== void 0 ? _a : {}));
|
|
2872
|
+
delete nextInputs[keyToRemove];
|
|
2873
|
+
updateWorkflowInputs(nextInputs);
|
|
2874
|
+
};
|
|
2875
|
+
var updateWorkflowVariables = function (nextVariables, nextVariableMetadata) {
|
|
2876
|
+
var _a;
|
|
2877
|
+
var currentMetadata = (_a = definitionDraft.metadata) !== null && _a !== void 0 ? _a : {};
|
|
2878
|
+
var variableDefinitions = nextVariableMetadata !== null && nextVariableMetadata !== void 0 ? nextVariableMetadata : getWorkflowVariableMetadata(currentMetadata);
|
|
2879
|
+
syncDraftToCode(__assign(__assign({}, definitionDraft), { variables: nextVariables, metadata: __assign(__assign({}, currentMetadata), { variableDefinitions: variableDefinitions }) }));
|
|
2880
|
+
};
|
|
2881
|
+
var addWorkflowVariable = function () {
|
|
2882
|
+
var _a, _b;
|
|
2883
|
+
var _c, _d;
|
|
2884
|
+
var nextKey = buildUniqueWorkflowVariableKey("Variable", Object.keys((_c = definitionDraft.variables) !== null && _c !== void 0 ? _c : {}));
|
|
2885
|
+
updateWorkflowVariables(__assign(__assign({}, ((_d = definitionDraft.variables) !== null && _d !== void 0 ? _d : {})), (_a = {}, _a[nextKey] = "", _a)), __assign(__assign({}, getWorkflowVariableMetadata(definitionDraft.metadata)), (_b = {}, _b[nextKey] = {
|
|
2886
|
+
label: "Variable",
|
|
2887
|
+
type: "string",
|
|
2888
|
+
description: "",
|
|
2889
|
+
}, _b)));
|
|
2890
|
+
};
|
|
2891
|
+
var updateWorkflowVariableLabel = function (currentKey, nextLabel) {
|
|
2892
|
+
var _a;
|
|
2893
|
+
var currentVariables = (_a = definitionDraft.variables) !== null && _a !== void 0 ? _a : {};
|
|
2894
|
+
var currentVariableMetadata = getWorkflowVariableMetadata(definitionDraft.metadata);
|
|
2895
|
+
var existingKeys = Object.keys(currentVariables).filter(function (key) { return key !== currentKey; });
|
|
2896
|
+
var nextKey = camelizeWorkflowInputKey(nextLabel)
|
|
2897
|
+
? buildUniqueWorkflowVariableKey(nextLabel, existingKeys)
|
|
2898
|
+
: currentKey;
|
|
2899
|
+
if (!nextKey) {
|
|
2900
|
+
return;
|
|
2901
|
+
}
|
|
2902
|
+
var nextVariables = {};
|
|
2903
|
+
var nextVariableMetadata = {};
|
|
2904
|
+
Object.entries(currentVariables).forEach(function (_a) {
|
|
2905
|
+
var _b, _c;
|
|
2906
|
+
var key = _a[0], value = _a[1];
|
|
2907
|
+
var outputKey = key === currentKey ? nextKey : key;
|
|
2908
|
+
nextVariables[outputKey] = value;
|
|
2909
|
+
nextVariableMetadata[outputKey] = __assign(__assign({}, ((_b = currentVariableMetadata[key]) !== null && _b !== void 0 ? _b : {})), { label: key === currentKey ? nextLabel : (_c = currentVariableMetadata[key]) === null || _c === void 0 ? void 0 : _c.label });
|
|
2910
|
+
});
|
|
2911
|
+
updateWorkflowVariables(nextVariables, nextVariableMetadata);
|
|
2912
|
+
};
|
|
2913
|
+
var updateWorkflowVariable = function (key, patch) {
|
|
2914
|
+
var _a, _b;
|
|
2915
|
+
var _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2916
|
+
var currentVariables = (_c = definitionDraft.variables) !== null && _c !== void 0 ? _c : {};
|
|
2917
|
+
var currentVariableMetadata = getWorkflowVariableMetadata(definitionDraft.metadata);
|
|
2918
|
+
var currentEntry = (_e = (_d = workflowVariableEntries.find(function (entry) { return entry.key === key; })) === null || _d === void 0 ? void 0 : _d.definition) !== null && _e !== void 0 ? _e : {
|
|
2919
|
+
type: inferWorkflowVariableType(currentVariables[key], (_f = currentVariableMetadata[key]) === null || _f === void 0 ? void 0 : _f.type),
|
|
2920
|
+
label: key,
|
|
2921
|
+
description: "",
|
|
2922
|
+
};
|
|
2923
|
+
var nextType = (_g = patch.type) !== null && _g !== void 0 ? _g : currentEntry.type;
|
|
2924
|
+
var nextValue = patch.value !== undefined
|
|
2925
|
+
? patch.value
|
|
2926
|
+
: patch.type && patch.type !== currentEntry.type
|
|
2927
|
+
? getWorkflowVariableInitialValue(nextType)
|
|
2928
|
+
: currentVariables[key];
|
|
2929
|
+
updateWorkflowVariables(__assign(__assign({}, currentVariables), (_a = {}, _a[key] = nextValue, _a)), __assign(__assign({}, currentVariableMetadata), (_b = {}, _b[key] = __assign(__assign({}, ((_h = currentVariableMetadata[key]) !== null && _h !== void 0 ? _h : {})), { label: (_j = patch.label) !== null && _j !== void 0 ? _j : currentEntry.label, type: nextType, description: (_k = patch.description) !== null && _k !== void 0 ? _k : currentEntry.description }), _b)));
|
|
2930
|
+
};
|
|
2931
|
+
var removeWorkflowVariable = function (keyToRemove) {
|
|
2932
|
+
var _a;
|
|
2933
|
+
var nextVariables = __assign({}, ((_a = definitionDraft.variables) !== null && _a !== void 0 ? _a : {}));
|
|
2934
|
+
var nextVariableMetadata = __assign({}, getWorkflowVariableMetadata(definitionDraft.metadata));
|
|
2935
|
+
delete nextVariables[keyToRemove];
|
|
2936
|
+
delete nextVariableMetadata[keyToRemove];
|
|
2937
|
+
updateWorkflowVariables(nextVariables, nextVariableMetadata);
|
|
2938
|
+
};
|
|
2939
|
+
var closeVariableValueEditor = function () {
|
|
2940
|
+
setVariableValueEditorKey(null);
|
|
2941
|
+
setVariableValueEditorDraft("");
|
|
2942
|
+
setVariableValueEditorJsonText("");
|
|
2943
|
+
setVariableValueEditorError("");
|
|
2944
|
+
};
|
|
2945
|
+
var openVariableValueEditor = function (key) {
|
|
2946
|
+
var entry = workflowVariableEntries.find(function (variableEntry) { return variableEntry.key === key; });
|
|
2947
|
+
if (!entry) {
|
|
2948
|
+
return;
|
|
2949
|
+
}
|
|
2950
|
+
var editorValue = getWorkflowVariableEditorValue(entry.definition.value, entry.definition.type);
|
|
2951
|
+
setVariableValueEditorKey(key);
|
|
2952
|
+
setVariableValueEditorDraft(editorValue);
|
|
2953
|
+
setVariableValueEditorJsonText(entry.definition.type === "object" || entry.definition.type === "array"
|
|
2954
|
+
? JSON.stringify(editorValue, null, 2)
|
|
2955
|
+
: "");
|
|
2956
|
+
setVariableValueEditorError("");
|
|
2957
|
+
setVariableValueEditorResetToken("variable-value-editor-".concat(key, "-").concat(Date.now()));
|
|
2958
|
+
};
|
|
2959
|
+
var saveVariableValueEditor = function () {
|
|
2960
|
+
if (!variableValueEditorEntry) {
|
|
2961
|
+
return;
|
|
2962
|
+
}
|
|
2963
|
+
var type = variableValueEditorEntry.definition.type;
|
|
2964
|
+
var nextValue = variableValueEditorDraft;
|
|
2965
|
+
try {
|
|
2966
|
+
if (type === "object" || type === "array") {
|
|
2967
|
+
var trimmedText = variableValueEditorJsonText.trim();
|
|
2968
|
+
nextValue = trimmedText
|
|
2969
|
+
? JSON.parse(trimmedText)
|
|
2970
|
+
: getWorkflowVariableInitialValue(type);
|
|
2971
|
+
if (type === "array" && !Array.isArray(nextValue)) {
|
|
2972
|
+
throw new Error("Variable value must be a JSON array.");
|
|
2973
|
+
}
|
|
2974
|
+
if (type === "object" && !isPlainObjectValue(nextValue)) {
|
|
2975
|
+
throw new Error("Variable value must be a JSON object.");
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
else if (isWorkflowExpressionString(nextValue)) {
|
|
2979
|
+
nextValue = String(nextValue).trim();
|
|
2980
|
+
}
|
|
2981
|
+
else if (type === "number") {
|
|
2982
|
+
var numericValue = Number(nextValue);
|
|
2983
|
+
if (!Number.isFinite(numericValue)) {
|
|
2984
|
+
throw new Error("Variable value must be a valid number.");
|
|
2985
|
+
}
|
|
2986
|
+
nextValue = numericValue;
|
|
2987
|
+
}
|
|
2988
|
+
else if (type === "boolean") {
|
|
2989
|
+
nextValue = Boolean(nextValue);
|
|
2990
|
+
}
|
|
2991
|
+
else {
|
|
2992
|
+
nextValue = nextValue !== null && nextValue !== void 0 ? nextValue : "";
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
catch (error) {
|
|
2996
|
+
setVariableValueEditorError((error === null || error === void 0 ? void 0 : error.message) ? String(error.message) : "Variable value is invalid.");
|
|
2997
|
+
return;
|
|
2998
|
+
}
|
|
2999
|
+
updateWorkflowVariable(variableValueEditorEntry.key, { value: nextValue });
|
|
3000
|
+
closeVariableValueEditor();
|
|
3001
|
+
};
|
|
3002
|
+
var renderDefaultValueEditorField = function () {
|
|
3003
|
+
if (!defaultValueEditorEntry) {
|
|
3004
|
+
return null;
|
|
3005
|
+
}
|
|
3006
|
+
var type = defaultValueEditorEntry.definition.type;
|
|
3007
|
+
if (type === "object" || type === "array") {
|
|
3008
|
+
return (_jsx(SolidJsonEditor, { value: defaultValueEditorDraft, resetToken: defaultValueEditorResetToken, className: "workflow-editor-default-dialog__json-editor", onValueChange: function (value) {
|
|
3009
|
+
setDefaultValueEditorDraft(value);
|
|
3010
|
+
setDefaultValueEditorError("");
|
|
3011
|
+
}, onTextChange: function (text) { return setDefaultValueEditorJsonText(text); }, onErrorChange: function (message) { return setDefaultValueEditorError(message !== null && message !== void 0 ? message : ""); } }));
|
|
3012
|
+
}
|
|
3013
|
+
if (type === "boolean") {
|
|
3014
|
+
return (_jsx(SolidCheckbox, { checked: Boolean(defaultValueEditorDraft), label: "Use true as the default value", onChange: function (event) {
|
|
3015
|
+
setDefaultValueEditorDraft(event.currentTarget.checked);
|
|
3016
|
+
setDefaultValueEditorError("");
|
|
3017
|
+
} }));
|
|
3018
|
+
}
|
|
3019
|
+
return (_jsx(WorkflowExpressionAutocompleteField, { value: String(defaultValueEditorDraft !== null && defaultValueEditorDraft !== void 0 ? defaultValueEditorDraft : ""), placeholder: type === "date" ? "Select date" : "Enter default value", suggestions: selectedNodeExpressionSuggestions, onChange: function (value) {
|
|
3020
|
+
setDefaultValueEditorDraft(value);
|
|
3021
|
+
setDefaultValueEditorError("");
|
|
3022
|
+
} }));
|
|
3023
|
+
};
|
|
3024
|
+
var renderVariableValueEditorField = function () {
|
|
3025
|
+
if (!variableValueEditorEntry) {
|
|
3026
|
+
return null;
|
|
3027
|
+
}
|
|
3028
|
+
var type = variableValueEditorEntry.definition.type;
|
|
3029
|
+
if (type === "object" || type === "array") {
|
|
3030
|
+
return (_jsx(SolidJsonEditor, { value: variableValueEditorDraft, resetToken: variableValueEditorResetToken, className: "workflow-editor-default-dialog__json-editor", onValueChange: function (value) {
|
|
3031
|
+
setVariableValueEditorDraft(value);
|
|
3032
|
+
setVariableValueEditorError("");
|
|
3033
|
+
}, onTextChange: function (text) { return setVariableValueEditorJsonText(text); }, onErrorChange: function (message) { return setVariableValueEditorError(message !== null && message !== void 0 ? message : ""); } }));
|
|
3034
|
+
}
|
|
3035
|
+
if (type === "boolean") {
|
|
3036
|
+
return (_jsx(SolidCheckbox, { checked: Boolean(variableValueEditorDraft), label: "Use true as the variable value", onChange: function (event) {
|
|
3037
|
+
setVariableValueEditorDraft(event.currentTarget.checked);
|
|
3038
|
+
setVariableValueEditorError("");
|
|
3039
|
+
} }));
|
|
3040
|
+
}
|
|
3041
|
+
return (_jsx(WorkflowExpressionAutocompleteField, { value: String(variableValueEditorDraft !== null && variableValueEditorDraft !== void 0 ? variableValueEditorDraft : ""), placeholder: type === "date" ? "Select date" : "Enter variable value", suggestions: selectedNodeExpressionSuggestions, onChange: function (value) {
|
|
3042
|
+
setVariableValueEditorDraft(value);
|
|
3043
|
+
setVariableValueEditorError("");
|
|
3044
|
+
} }));
|
|
3045
|
+
};
|
|
3046
|
+
var updateWorkflowTriggers = function (nextTriggers) {
|
|
3047
|
+
syncDraftToCode(__assign(__assign({}, definitionDraft), { triggers: nextTriggers }));
|
|
3048
|
+
};
|
|
3049
|
+
var addWorkflowTrigger = function () {
|
|
3050
|
+
var _a, _b;
|
|
3051
|
+
var nextId = buildUniqueWorkflowKey("trigger", ((_a = definitionDraft.triggers) !== null && _a !== void 0 ? _a : []).map(function (trigger) { var _a; return String((_a = trigger.id) !== null && _a !== void 0 ? _a : ""); }));
|
|
3052
|
+
updateWorkflowTriggers(__spreadArray(__spreadArray([], ((_b = definitionDraft.triggers) !== null && _b !== void 0 ? _b : []), true), [
|
|
3053
|
+
{
|
|
3054
|
+
id: nextId,
|
|
3055
|
+
name: "Trigger",
|
|
3056
|
+
type: "schedule",
|
|
3057
|
+
disabled: false,
|
|
3058
|
+
configuration: {
|
|
3059
|
+
cronExpression: "0 9 * * *",
|
|
3060
|
+
timezone: "UTC",
|
|
3061
|
+
},
|
|
3062
|
+
},
|
|
3063
|
+
], false));
|
|
3064
|
+
};
|
|
3065
|
+
var updateWorkflowTrigger = function (index, patch) {
|
|
3066
|
+
var _a;
|
|
3067
|
+
var nextTriggers = ((_a = definitionDraft.triggers) !== null && _a !== void 0 ? _a : []).map(function (trigger, triggerIndex) {
|
|
3068
|
+
if (triggerIndex !== index) {
|
|
3069
|
+
return trigger;
|
|
3070
|
+
}
|
|
3071
|
+
var currentTrigger = normalizeWorkflowTriggerDefinition(trigger);
|
|
3072
|
+
var nextTrigger = __assign(__assign({}, currentTrigger), patch);
|
|
3073
|
+
if (patch.type && patch.type !== currentTrigger.type) {
|
|
3074
|
+
nextTrigger.configuration =
|
|
3075
|
+
patch.type === "schedule"
|
|
3076
|
+
? { cronExpression: "0 9 * * *", timezone: "UTC" }
|
|
3077
|
+
: { method: "POST", path: "/".concat(currentTrigger.id || "trigger") };
|
|
3078
|
+
}
|
|
3079
|
+
return nextTrigger;
|
|
3080
|
+
});
|
|
3081
|
+
updateWorkflowTriggers(nextTriggers);
|
|
3082
|
+
};
|
|
3083
|
+
var updateWorkflowTriggerConfiguration = function (index, patch) {
|
|
3084
|
+
var _a;
|
|
3085
|
+
var currentTrigger = normalizeWorkflowTriggerDefinition(((_a = definitionDraft.triggers) !== null && _a !== void 0 ? _a : [])[index]);
|
|
3086
|
+
var nextConfiguration = __assign(__assign({}, currentTrigger.configuration), patch);
|
|
3087
|
+
if (patch.cronExpression !== undefined) {
|
|
3088
|
+
delete nextConfiguration.cron;
|
|
3089
|
+
}
|
|
3090
|
+
updateWorkflowTrigger(index, {
|
|
3091
|
+
configuration: nextConfiguration,
|
|
3092
|
+
});
|
|
3093
|
+
};
|
|
3094
|
+
var removeWorkflowTrigger = function (indexToRemove) {
|
|
3095
|
+
var _a;
|
|
3096
|
+
updateWorkflowTriggers(((_a = definitionDraft.triggers) !== null && _a !== void 0 ? _a : []).filter(function (_, index) { return index !== indexToRemove; }));
|
|
3097
|
+
};
|
|
3098
|
+
var renderTriggerConfigurationFields = function (trigger, index) {
|
|
3099
|
+
var _a, _b;
|
|
3100
|
+
var cronExpression = getWorkflowTriggerCronExpression(trigger);
|
|
3101
|
+
var cronParts = splitCronExpression(cronExpression);
|
|
3102
|
+
var timezone = String((_a = trigger.configuration.timezone) !== null && _a !== void 0 ? _a : "UTC");
|
|
3103
|
+
var setCronPart = function (key, value) {
|
|
3104
|
+
var _a;
|
|
3105
|
+
updateWorkflowTriggerConfiguration(index, {
|
|
3106
|
+
timezone: "UTC",
|
|
3107
|
+
cronExpression: joinCronExpression(__assign(__assign({}, cronParts), (_a = {}, _a[key] = value.trim() || "*", _a))),
|
|
3108
|
+
});
|
|
3109
|
+
};
|
|
3110
|
+
var inputsMissingDefaults = Object.entries((_b = definitionDraft.inputs) !== null && _b !== void 0 ? _b : {})
|
|
3111
|
+
.filter(function (_a) {
|
|
3112
|
+
var inputDefinition = _a[1];
|
|
3113
|
+
return !workflowInputHasDefault(inputDefinition);
|
|
3114
|
+
})
|
|
3115
|
+
.map(function (_a) {
|
|
3116
|
+
var inputKey = _a[0];
|
|
3117
|
+
return inputKey;
|
|
3118
|
+
});
|
|
3119
|
+
return (_jsxs("div", { className: "workflow-editor-cron-builder workflow-editor-field--wide", children: [_jsxs("div", { className: "workflow-editor-cron-builder__header", children: [_jsxs("div", { children: [_jsx("label", { children: "Schedule" }), _jsx("p", { children: "Define when this workflow should run. Times are evaluated in UTC." })] }), _jsxs("div", { className: "workflow-editor-cron-builder__header-meta", children: [_jsx("span", { children: "Generated expression" }), _jsx("code", { children: cronExpression }), _jsx("span", { children: "Timezone" }), _jsx("code", { children: timezone })] })] }), _jsx("div", { className: "workflow-editor-cron-builder__grid", children: WORKFLOW_CRON_FIELD_HELP.map(function (field) { return (_jsxs("div", { className: "workflow-editor-cron-builder__part", children: [_jsx("label", { children: field.label }), _jsx(SolidInput, { value: cronParts[field.key], placeholder: field.placeholder, onChange: function (event) { return setCronPart(field.key, event.target.value); } }), _jsx("span", { children: field.help })] }, field.key)); }) }), _jsx("div", { className: "workflow-editor-cron-builder__examples", children: WORKFLOW_CRON_EXAMPLES.map(function (example) { return (_jsx(SolidButton, { variant: "outline", size: "small", onClick: function () {
|
|
3120
|
+
return updateWorkflowTriggerConfiguration(index, {
|
|
3121
|
+
cronExpression: example.value,
|
|
3122
|
+
timezone: "UTC",
|
|
3123
|
+
});
|
|
3124
|
+
}, children: example.label }, example.value)); }) }), _jsx("div", { className: "workflow-editor-cron-builder__explanation".concat(isValidSimpleCronExpression(cronExpression) ? "" : " is-invalid"), children: describeWorkflowCronExpression(cronExpression, timezone) }), inputsMissingDefaults.length ? (_jsxs("div", { className: "workflow-editor-cron-builder__warning", children: ["Scheduled workflows run without a user present. Add default values for:", " ", inputsMissingDefaults.join(", "), "."] })) : null] }));
|
|
3125
|
+
};
|
|
3126
|
+
var inputsContent = workflowInputEntries.length ? (_jsxs("div", { className: "workflow-editor-authoring-tab", children: [_jsxs("div", { className: "workflow-editor-authoring-header", children: [_jsxs("div", { children: [_jsx("h3", { children: "Inputs" }), _jsx("p", { children: "Define values that callers can provide when this workflow runs." })] }), _jsx(SolidButton, { onClick: addWorkflowInput, children: "Add Input" })] }), _jsxs("div", { className: "workflow-editor-input-table", children: [_jsxs("div", { className: "workflow-editor-input-table__header", role: "row", children: [_jsx("span", { children: "Label" }), _jsx("span", { children: "Type" }), _jsx("span", { children: "Required" }), _jsx("span", { children: "Description" }), _jsx("span", { className: "workflow-editor-input-table__actions-header", children: "Actions" })] }), workflowInputEntries.map(function (_a, index) {
|
|
3127
|
+
var key = _a.key, definition = _a.definition;
|
|
3128
|
+
return (_jsxs("div", { className: "workflow-editor-input-table__row", role: "row", children: [_jsxs("div", { className: "workflow-editor-input-table__label-cell", children: [_jsx(SolidInput, { value: definition.label, placeholder: "Customer ID", onChange: function (event) { return updateWorkflowInputLabel(key, event.target.value); } }), _jsxs("span", { children: ["We will use input field with name ", _jsx("strong", { children: key }), "."] })] }), _jsxs("div", { className: "workflow-editor-input-table__type-cell", children: [_jsxs("div", { className: "workflow-editor-input-table__type-row", children: [_jsx(SolidSelect, { value: definition.type, options: WORKFLOW_INPUT_TYPE_OPTIONS, onChange: function (event) { var _a; return updateWorkflowInput(key, { type: (_a = event.value) !== null && _a !== void 0 ? _a : "string" }); } }), _jsx("button", { type: "button", className: "workflow-editor-input-table__default-button", "aria-label": "Configure default value for ".concat(key), title: "Configure default value", onClick: function () { return openDefaultValueEditor(key); }, children: _jsx(Braces, { size: 14 }) })] }), _jsx("span", { className: "workflow-editor-input-table__default-summary".concat(hasWorkflowInputDefaultValue(definition.default) ? "" : " is-empty"), children: formatWorkflowInputDefaultSummary(definition.default) })] }), _jsx("div", { className: "workflow-editor-input-table__required", children: _jsx(SolidCheckbox, { checked: definition.required, label: "", onChange: function (event) {
|
|
3129
|
+
return updateWorkflowInput(key, { required: event.currentTarget.checked });
|
|
3130
|
+
} }) }), _jsx(SolidInput, { value: definition.description, placeholder: "Describe this input", onChange: function (event) {
|
|
3131
|
+
return updateWorkflowInput(key, { description: event.target.value });
|
|
3132
|
+
} }), _jsx("button", { type: "button", className: "workflow-editor-input-table__delete", "aria-label": "Remove ".concat(key), title: "Remove input", onClick: function () { return removeWorkflowInput(key); }, children: _jsx(Trash2, { size: 14 }) })] }, "input-row-".concat(index)));
|
|
3133
|
+
})] })] })) : (renderOptionalAuthoringEmptyState({
|
|
3134
|
+
icon: _jsx(Braces, { size: 20 }),
|
|
3135
|
+
title: "No inputs defined",
|
|
3136
|
+
body: "Inputs are optional. Add them when this workflow needs values at run time, such as a customer id, email, date range, or amount. If this workflow can run with fixed configuration or values produced inside the flow, you can skip inputs and configure the flow directly.",
|
|
3137
|
+
examples: ["customerId", "email", "startDate", "approvalAmount"],
|
|
3138
|
+
primaryLabel: "Add Input",
|
|
3139
|
+
onPrimaryClick: addWorkflowInput,
|
|
3140
|
+
}));
|
|
3141
|
+
var variablesContent = workflowVariableEntries.length ? (_jsxs("div", { className: "workflow-editor-authoring-tab", children: [_jsxs("div", { className: "workflow-editor-authoring-header", children: [_jsxs("div", { children: [_jsx("h3", { children: "Variables" }), _jsx("p", { children: "Define reusable values owned by this workflow." })] }), _jsx(SolidButton, { onClick: addWorkflowVariable, children: "Add Variable" })] }), _jsxs("div", { className: "workflow-editor-input-table workflow-editor-variable-table", children: [_jsxs("div", { className: "workflow-editor-input-table__header", role: "row", children: [_jsx("span", { children: "Name" }), _jsx("span", { children: "Type & value" }), _jsx("span", { children: "Description" }), _jsx("span", { className: "workflow-editor-input-table__actions-header", children: "Actions" })] }), workflowVariableEntries.map(function (_a, index) {
|
|
3142
|
+
var key = _a.key, definition = _a.definition;
|
|
3143
|
+
return (_jsxs("div", { className: "workflow-editor-input-table__row", role: "row", children: [_jsxs("div", { className: "workflow-editor-input-table__label-cell", children: [_jsx(SolidInput, { value: definition.label, placeholder: "API Base URL", onChange: function (event) { return updateWorkflowVariableLabel(key, event.target.value); } }), _jsxs("span", { children: ["We will use variable ", _jsx("strong", { children: key }), "."] })] }), _jsxs("div", { className: "workflow-editor-input-table__type-cell", children: [_jsxs("div", { className: "workflow-editor-input-table__type-row", children: [_jsx(SolidSelect, { value: definition.type, options: WORKFLOW_INPUT_TYPE_OPTIONS, onChange: function (event) { var _a; return updateWorkflowVariable(key, { type: (_a = event.value) !== null && _a !== void 0 ? _a : "string" }); } }), _jsx("button", { type: "button", className: "workflow-editor-input-table__default-button", "aria-label": "Configure value for ".concat(key), title: "Configure value", onClick: function () { return openVariableValueEditor(key); }, children: _jsx(Braces, { size: 14 }) })] }), _jsx("span", { className: "workflow-editor-input-table__default-summary", children: formatWorkflowVariableValueSummary(definition.value) })] }), _jsx(SolidInput, { value: definition.description, placeholder: "Describe this variable", onChange: function (event) {
|
|
3144
|
+
return updateWorkflowVariable(key, { description: event.target.value });
|
|
3145
|
+
} }), _jsx("button", { type: "button", className: "workflow-editor-input-table__delete", "aria-label": "Remove ".concat(key), title: "Remove variable", onClick: function () { return removeWorkflowVariable(key); }, children: _jsx(Trash2, { size: 14 }) })] }, "variable-row-".concat(index)));
|
|
3146
|
+
})] })] })) : (renderOptionalAuthoringEmptyState({
|
|
3147
|
+
icon: _jsx(Braces, { size: 20 }),
|
|
3148
|
+
title: "No variables defined",
|
|
3149
|
+
body: "Variables are optional workflow-owned values. Use them for constants shared across nodes, such as base URLs, thresholds, labels, or feature flags. Callers do not provide variables when executing the workflow.",
|
|
3150
|
+
examples: ["apiBaseUrl", "retryDelayMs", "notificationChannel", "featureEnabled"],
|
|
3151
|
+
primaryLabel: "Add Variable",
|
|
3152
|
+
onPrimaryClick: addWorkflowVariable,
|
|
3153
|
+
}));
|
|
3154
|
+
var renderWorkflowTriggerCodeExample = function (value) { return (_jsxs("div", { className: "workflow-editor-trigger-guide-code", children: [_jsx("pre", { children: _jsx("code", { children: value }) }), _jsxs(SolidButton, { variant: "outline", size: "small", onClick: function () { return void copyWorkflowTriggerExample(value); }, children: [_jsx(Copy, { size: 14 }), "Copy"] })] })); };
|
|
3155
|
+
var scheduledTriggersContent = scheduledTriggerEntries.length ? (_jsx("div", { className: "workflow-editor-authoring-list", children: scheduledTriggerEntries.map(function (_a) {
|
|
3156
|
+
var trigger = _a.trigger, index = _a.index;
|
|
3157
|
+
return (_jsxs(SolidPanel, { header: trigger.name || trigger.id, children: [_jsxs("div", { className: "workflow-editor-form-grid", children: [_jsxs("div", { className: "workflow-editor-field", children: [_jsx("label", { children: "Id" }), _jsx(SolidInput, { value: trigger.id, onChange: function (event) {
|
|
3158
|
+
return updateWorkflowTrigger(index, {
|
|
3159
|
+
id: slugifyWorkflowKey(event.target.value) || trigger.id,
|
|
3160
|
+
});
|
|
3161
|
+
} })] }), _jsxs("div", { className: "workflow-editor-field", children: [_jsx("label", { children: "Name" }), _jsx(SolidInput, { value: trigger.name, onChange: function (event) {
|
|
3162
|
+
return updateWorkflowTrigger(index, { name: event.target.value });
|
|
3163
|
+
} })] }), _jsx("div", { className: "workflow-editor-field", children: _jsx(SolidCheckbox, { checked: trigger.disabled, label: "Disabled", onChange: function (event) {
|
|
3164
|
+
return updateWorkflowTrigger(index, {
|
|
3165
|
+
disabled: event.currentTarget.checked,
|
|
3166
|
+
});
|
|
3167
|
+
} }) }), renderTriggerConfigurationFields(trigger, index)] }), _jsx("div", { className: "workflow-editor-authoring-card-actions", children: _jsx(SolidButton, { variant: "ghost", size: "small", onClick: function () { return removeWorkflowTrigger(index); }, children: "Remove Trigger" }) })] }, "".concat(trigger.id, "-").concat(index)));
|
|
3168
|
+
}) })) : (renderOptionalAuthoringEmptyState({
|
|
3169
|
+
icon: _jsx(Activity, { size: 20 }),
|
|
3170
|
+
title: "No scheduled triggers configured",
|
|
3171
|
+
body: "Scheduled triggers are optional. Add one when this workflow should run automatically on a CRON cadence. Scheduled workflows run without a user present, so every required input must have a default value.",
|
|
3172
|
+
examples: ["Every weekday at 09:00", "Every 15 minutes", "Every Monday at 02:00"],
|
|
3173
|
+
primaryLabel: "Add Scheduled Trigger",
|
|
3174
|
+
onPrimaryClick: addWorkflowTrigger,
|
|
3175
|
+
}));
|
|
3176
|
+
var triggersContent = (_jsxs("div", { className: "workflow-editor-authoring-tab workflow-editor-trigger-guide", children: [_jsxs("div", { className: "workflow-editor-authoring-header", children: [_jsxs("div", { children: [_jsx("h3", { children: "Triggers" }), _jsx("p", { children: "Choose how this workflow should be started. Only scheduled triggers are saved into YAML; CURL and API are authenticated execution examples." })] }), triggerGuideMode === "scheduled" && scheduledTriggerEntries.length ? (_jsx(SolidButton, { onClick: addWorkflowTrigger, children: "Add Scheduled Trigger" })) : null] }), _jsx("div", { className: "workflow-editor-trigger-guide-mode", role: "radiogroup", "aria-label": "Trigger type", children: WORKFLOW_TRIGGER_GUIDE_OPTIONS.map(function (option) { return (_jsxs("button", { type: "button", role: "radio", "aria-checked": triggerGuideMode === option.value, className: "workflow-editor-trigger-guide-mode__button".concat(triggerGuideMode === option.value ? " is-active" : ""), onClick: function () { return setTriggerGuideMode(option.value); }, children: [_jsx("span", { children: option.label }), _jsx("small", { children: option.description })] }, option.value)); }) }), triggerGuideMode === "curl" ? (_jsxs("div", { className: "workflow-editor-trigger-guide-card", children: [_jsxs("div", { children: [_jsx("h4", { children: "Run With CURL" }), _jsxs("p", { children: ["Use this from scripts, Postman, or external systems that can call private SolidX APIs with a bearer token. The request creates a normal workflow execution with ", _jsx("code", { children: "triggerType" }), " set to ", _jsx("code", { children: "api" }), "."] })] }), renderWorkflowTriggerCodeExample(workflowCurlExample)] })) : null, triggerGuideMode === "api" ? (_jsxs("div", { className: "workflow-editor-trigger-guide-card", children: [_jsxs("div", { children: [_jsx("h4", { children: "Run From SolidX Code" }), _jsx("p", { children: "Inject the workflow invocation service inside a SolidX subscriber, service, scheduled job, or controller when workflow execution is part of application logic." })] }), renderWorkflowTriggerCodeExample(workflowApiExample)] })) : null, triggerGuideMode === "scheduled" ? scheduledTriggersContent : null] }));
|
|
3177
|
+
var executionsContent = workflowDefinitionId === "new" || !hasExecutions ? (_jsx("div", { className: "workflow-editor-overview workflow-editor-overview--empty", children: _jsxs("div", { className: "workflow-editor-overview-cta", children: [_jsx("div", { className: "workflow-editor-overview-cta__art", children: _jsx(Workflow, { size: 28 }) }), _jsxs("div", { className: "workflow-editor-overview-cta__copy", children: [_jsx("h2", { children: workflowDisplayName || (record === null || record === void 0 ? void 0 : record.displayName) || workflowKey || "Workflow" }), _jsx("p", { children: "Run the workflow once to unlock execution history, operational KPIs, and workflow activity for this definition." })] }), _jsxs("div", { className: "workflow-editor-overview-cta__actions", children: [_jsx(SolidButton, { leftIcon: _jsx(Play, { size: 16 }), loading: isExecuting, onClick: function () { return void handleExecute(); }, children: "Execute Workflow" }), _jsx(SolidButton, { variant: "outline", onClick: function () { return setDetailTab("topology"); }, children: "Open Topology" })] })] }) })) : (_jsxs("div", { className: "workflow-editor-executions", children: [_jsxs("div", { className: "workflow-editor-execution-subtabs", role: "tablist", "aria-label": "Execution workspace views", children: [_jsx("button", { type: "button", className: "workflow-editor-execution-subtabs__button".concat(executionWorkspaceTab === "summary" ? " is-active" : ""), role: "tab", "aria-selected": executionWorkspaceTab === "summary", onClick: function () { return setExecutionWorkspaceTab("summary"); }, children: "Summary" }), _jsx("button", { type: "button", className: "workflow-editor-execution-subtabs__button".concat(executionWorkspaceTab === "list" ? " is-active" : ""), role: "tab", "aria-selected": executionWorkspaceTab === "list", onClick: function () { return setExecutionWorkspaceTab("list"); }, children: "List" })] }), executionWorkspaceTab === "list" ? (_jsx("div", { className: "workflow-editor-overview-filterbar", children: _jsxs("div", { className: "workflow-editor-overview-filterbar__left", children: [_jsxs("div", { className: "workflow-editor-overview-filter", children: [_jsx("label", { children: "Date From" }), _jsx(SolidDatePicker, { selected: overviewStartDate, onChange: function (date) {
|
|
3178
|
+
setOverviewStartDate(date);
|
|
3179
|
+
setExecutionPage(1);
|
|
3180
|
+
}, placeholderText: "Start date" })] }), _jsxs("div", { className: "workflow-editor-overview-filter", children: [_jsx("label", { children: "Date To" }), _jsx(SolidDatePicker, { selected: overviewEndDate, onChange: function (date) {
|
|
3181
|
+
setOverviewEndDate(date);
|
|
3182
|
+
setExecutionPage(1);
|
|
3183
|
+
}, placeholderText: "End date" })] }), _jsxs("div", { className: "workflow-editor-overview-filter", children: [_jsx("label", { children: "Status" }), _jsx(SolidSelect, { value: executionStatusFilter, options: WORKFLOW_EXECUTION_STATUS_OPTIONS, onChange: function (event) {
|
|
3184
|
+
var _a;
|
|
3185
|
+
setExecutionStatusFilter((_a = event.value) !== null && _a !== void 0 ? _a : "all");
|
|
3186
|
+
setExecutionPage(1);
|
|
3187
|
+
} })] }), _jsxs("div", { className: "workflow-editor-overview-filter workflow-editor-overview-filter--search", children: [_jsx("label", { children: "Execution" }), _jsx(SolidInput, { value: executionSearchFilter, placeholder: "Search identifier", onChange: function (event) {
|
|
3188
|
+
setExecutionSearchFilter(event.target.value);
|
|
3189
|
+
setExecutionPage(1);
|
|
3190
|
+
} })] }), (overviewStartDate ||
|
|
3191
|
+
overviewEndDate ||
|
|
3192
|
+
executionStatusFilter !== "all" ||
|
|
3193
|
+
executionSearchFilter) && (_jsx(SolidButton, { size: "small", variant: "ghost", onClick: function () {
|
|
3194
|
+
setOverviewStartDate(null);
|
|
3195
|
+
setOverviewEndDate(null);
|
|
3196
|
+
setExecutionStatusFilter("all");
|
|
3197
|
+
setExecutionSearchFilter("");
|
|
3198
|
+
setExecutionPage(1);
|
|
3199
|
+
}, children: "Clear" }))] }) })) : null, executionWorkspaceTab === "summary" ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "workflow-editor-overview-stats", children: [_jsxs("div", { className: "workflow-editor-overview-stat", children: [_jsx("span", { className: "workflow-editor-overview-stat-label", children: "Success Ratio" }), _jsxs("strong", { className: "workflow-editor-overview-stat-value", children: [executionOverview.successRatio, "%"] }), _jsxs("span", { className: "workflow-editor-overview-stat-meta", children: [executionOverview.success, " successful runs"] })] }), _jsxs("div", { className: "workflow-editor-overview-stat", children: [_jsx("span", { className: "workflow-editor-overview-stat-label", children: "Failed Ratio" }), _jsxs("strong", { className: "workflow-editor-overview-stat-value", children: [executionOverview.failedRatio, "%"] }), _jsxs("span", { className: "workflow-editor-overview-stat-meta", children: [executionOverview.failed, " failed runs"] })] }), _jsxs("div", { className: "workflow-editor-overview-stat", children: [_jsx("span", { className: "workflow-editor-overview-stat-label", children: "In Progress" }), _jsx("strong", { className: "workflow-editor-overview-stat-value", children: executionOverview.inProgress }), _jsx("span", { className: "workflow-editor-overview-stat-meta", children: "Currently running executions" })] }), _jsxs("div", { className: "workflow-editor-overview-stat", children: [_jsx("span", { className: "workflow-editor-overview-stat-label", children: "Pending" }), _jsx("strong", { className: "workflow-editor-overview-stat-value", children: executionOverview.pending }), _jsx("span", { className: "workflow-editor-overview-stat-meta", children: "Created or queued executions" })] })] }), _jsxs("div", { className: "workflow-editor-overview-grid", children: [_jsx(SolidPanel, { header: "Workflow Summary", children: _jsxs("div", { className: "workflow-editor-overview-section", children: [_jsxs("div", { className: "workflow-editor-overview-kv", children: [_jsx("span", { children: "Workflow" }), _jsx("strong", { children: workflowDisplayName || (record === null || record === void 0 ? void 0 : record.displayName) || workflowKey })] }), _jsxs("div", { className: "workflow-editor-overview-kv", children: [_jsx("span", { children: "Total Executions" }), _jsx("strong", { children: (_o = (_m = (_l = workflowExecutionPresenceQuery.data) === null || _l === void 0 ? void 0 : _l.meta) === null || _m === void 0 ? void 0 : _m.totalRecords) !== null && _o !== void 0 ? _o : 0 })] }), _jsxs("div", { className: "workflow-editor-overview-kv", children: [_jsx("span", { children: "Executions In Range" }), _jsx("strong", { children: (_r = (_q = (_p = workflowExecutionsQuery.data) === null || _p === void 0 ? void 0 : _p.meta) === null || _q === void 0 ? void 0 : _q.totalRecords) !== null && _r !== void 0 ? _r : 0 })] }), _jsxs("div", { className: "workflow-editor-overview-kv", children: [_jsx("span", { children: "Average Duration" }), _jsx("strong", { children: formatDurationMs(executionOverview.averageDurationMs) })] }), _jsx("div", { className: "workflow-editor-overview-description", children: workflowDescription ||
|
|
3200
|
+
(record === null || record === void 0 ? void 0 : record.description) ||
|
|
3201
|
+
definitionDraft.description ||
|
|
3202
|
+
"No workflow description has been added yet." })] }) }), _jsx(SolidPanel, { header: "Latest Execution", children: executionOverview.latestExecution ? (_jsxs("div", { className: "workflow-editor-overview-section", children: [_jsxs("div", { className: "workflow-editor-overview-kv", children: [_jsx("span", { children: "Status" }), _jsx("strong", { children: (_s = executionOverview.latestExecution.status) !== null && _s !== void 0 ? _s : "Unknown" })] }), _jsxs("div", { className: "workflow-editor-overview-kv", children: [_jsx("span", { children: "Started" }), _jsx("strong", { children: formatExecutionDate(executionOverview.latestExecution.startedAt) })] }), _jsxs("div", { className: "workflow-editor-overview-kv", children: [_jsx("span", { children: "Finished" }), _jsx("strong", { children: formatExecutionDate(executionOverview.latestExecution.finishedAt) })] }), _jsxs("div", { className: "workflow-editor-overview-kv", children: [_jsx("span", { children: "Trigger Type" }), _jsx("strong", { children: (_t = executionOverview.latestExecution.triggerType) !== null && _t !== void 0 ? _t : "manual" })] })] })) : (_jsx("div", { className: "workflow-editor-empty-state workflow-editor-empty-state--compact", children: "No executions match the current date filter." })) })] })] })) : null, executionWorkspaceTab === "list" ? (_jsx(SolidPanel, { header: "Executions", children: workflowExecutionsQuery.isFetching && !executionRecords.length ? (_jsx("div", { className: "workflow-editor-loading", children: _jsx(SolidSpinner, {}) })) : executionRecords.length ? (_jsxs("div", { className: "workflow-editor-execution-table-wrap", children: [_jsxs("table", { className: "workflow-editor-execution-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Id" }), _jsx("th", { children: "Execution Identifier" }), _jsx("th", { children: "Status" }), _jsx("th", { children: "Trigger" }), _jsx("th", { children: "Started" }), _jsx("th", { children: "Finished" }), _jsx("th", { children: "Duration" }), _jsx("th", { children: "Error" }), _jsx("th", { children: "Details" })] }) }), _jsx("tbody", { children: executionRecords.map(function (execution) {
|
|
3203
|
+
var _a, _b, _c, _d;
|
|
3204
|
+
var statusCategory = getExecutionStatusCategory(execution.status);
|
|
3205
|
+
return (_jsxs("tr", { className: "workflow-editor-execution-table__row", tabIndex: 0, role: "button", onClick: function () { return openExecutionDetails(execution); }, onKeyDown: function (event) {
|
|
3206
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
3207
|
+
event.preventDefault();
|
|
3208
|
+
openExecutionDetails(execution);
|
|
3209
|
+
}
|
|
3210
|
+
}, children: [_jsx("td", { children: execution.id }), _jsx("td", { className: "workflow-editor-execution-table__identifier", children: (_a = execution.executionIdentifier) !== null && _a !== void 0 ? _a : "-" }), _jsx("td", { children: _jsx(SolidTag, { className: "workflow-editor-execution-status-pill workflow-editor-execution-status-pill--".concat(statusCategory), children: (_b = execution.status) !== null && _b !== void 0 ? _b : "Unknown" }) }), _jsx("td", { children: (_c = execution.triggerType) !== null && _c !== void 0 ? _c : "manual" }), _jsx("td", { children: formatExecutionDate(execution.startedAt || execution.createdAt) }), _jsx("td", { children: formatExecutionDate(execution.finishedAt) }), _jsx("td", { children: formatDurationMs(execution.durationMs) }), _jsx("td", { className: "workflow-editor-execution-table__error", children: (_d = execution.errorSummary) !== null && _d !== void 0 ? _d : "-" }), _jsx("td", { children: _jsx(SolidButton, { size: "small", variant: "outline", onClick: function (event) {
|
|
3211
|
+
event.stopPropagation();
|
|
3212
|
+
openExecutionDetails(execution);
|
|
3213
|
+
}, children: "View" }) })] }, execution.id));
|
|
3214
|
+
}) })] }), _jsxs("div", { className: "workflow-editor-execution-pagination", children: [_jsxs("span", { children: ["Showing ", executionPageStart, "-", executionPageEnd, " of ", executionTotalRecords] }), _jsxs("div", { className: "workflow-editor-execution-pagination__actions", children: [_jsx(SolidButton, { size: "small", variant: "outline", disabled: executionPage <= 1, onClick: function () { return setExecutionPage(function (current) { return Math.max(1, current - 1); }); }, children: "Previous" }), _jsxs(SolidTag, { children: ["Page ", executionPage, " of ", executionTotalPages] }), _jsx(SolidButton, { size: "small", variant: "outline", disabled: executionPage >= executionTotalPages, onClick: function () {
|
|
3215
|
+
return setExecutionPage(function (current) {
|
|
3216
|
+
return Math.min(executionTotalPages, current + 1);
|
|
3217
|
+
});
|
|
3218
|
+
}, children: "Next" })] })] })] })) : (_jsx("div", { className: "workflow-editor-empty-state workflow-editor-empty-state--compact", children: "No executions match the current filters." })) })) : null] }));
|
|
3219
|
+
var topologyCanvasView = (_jsx("div", { className: "workflow-editor-canvas-shell", children: codeError ? (_jsxs("div", { className: "workflow-editor-definition-error", children: [_jsx("div", { className: "workflow-editor-definition-error__icon", children: _jsx(Braces, { size: 20 }) }), _jsxs("div", { className: "workflow-editor-definition-error__content", children: [_jsx("h3", { children: "Workflow definition YAML is invalid" }), _jsx("p", { children: "The topology cannot be rendered until the saved YAML parses and matches the current workflow schema." }), _jsx("pre", { children: codeError }), !topologyYamlViewOpen ? (_jsx(SolidButton, { size: "small", variant: "outline", onClick: function () { return setTopologyYamlViewOpen(true); }, children: "Show YAML" })) : null] })] })) : (_jsx(WorkflowFlowCanvas, { definition: definitionDraft, nodeTypes: nodeTypes, selectedNodeId: selectedNodeId, selectedTriggerId: selectedTriggerId, activePaletteNodeType: undefined, onSelectNode: function (nodeId) {
|
|
3220
|
+
setSelectedNodeId(nodeId);
|
|
3221
|
+
setSelectedTriggerId("");
|
|
3222
|
+
}, onSelectTrigger: function (triggerId) {
|
|
3223
|
+
setSelectedTriggerId(triggerId);
|
|
3224
|
+
setSelectedNodeId("");
|
|
3225
|
+
}, onEditNode: function (nodeId) {
|
|
3226
|
+
setSelectedNodeId(nodeId);
|
|
3227
|
+
setSelectedTriggerId("");
|
|
3228
|
+
setEditorOpen(true);
|
|
3229
|
+
}, onDeleteNode: handleRemoveNode, onViewDocs: function (nodeId) {
|
|
3230
|
+
var node = findNodeById(definitionDraft.nodes, nodeId);
|
|
3231
|
+
if (node === null || node === void 0 ? void 0 : node.type) {
|
|
3232
|
+
setSelectedNodeId(nodeId);
|
|
3233
|
+
setSelectedTriggerId("");
|
|
3234
|
+
setTopologyDocsNodeTypeKey(node.type);
|
|
3235
|
+
setTopologyDocsModel(undefined);
|
|
3236
|
+
setTopologyDocsOpen(true);
|
|
3237
|
+
}
|
|
3238
|
+
}, onViewTriggerDocs: function (triggerId) {
|
|
3239
|
+
var _a;
|
|
3240
|
+
var trigger = ((_a = definitionDraft.triggers) !== null && _a !== void 0 ? _a : []).find(function (item) { return String(item.id) === triggerId; });
|
|
3241
|
+
setSelectedTriggerId(triggerId);
|
|
3242
|
+
setSelectedNodeId("");
|
|
3243
|
+
setTopologyDocsNodeTypeKey("");
|
|
3244
|
+
setTopologyDocsModel(trigger ? buildTriggerDocsModel(trigger) : undefined);
|
|
3245
|
+
setTopologyDocsOpen(true);
|
|
3246
|
+
}, onInsertNode: handleInsertNode })) }));
|
|
3247
|
+
var topologyYamlEditorView = (_jsxs("div", { className: "workflow-editor-topology-code", children: [_jsxs("div", { className: "workflow-editor-topology-code__header", children: [_jsx("span", { children: "Definition YAML" }), codeError ? (_jsx(SolidTag, { tone: "danger", children: "Invalid" })) : (_jsx(SolidTag, { tone: "success", children: "Synced" }))] }), _jsx(SolidCodeEditor, { language: "yaml", height: "100%", fontSize: 12, value: codeValue, onChange: handleCodeChange }), codeError ? (_jsx("pre", { className: "workflow-editor-error workflow-editor-error--block", children: codeError })) : null] }));
|
|
3248
|
+
var topologyContent = (_jsxs("div", { className: "workflow-editor-topology-tab", children: [_jsxs("div", { className: "workflow-editor-topology-actionbar", children: [_jsx("div", { className: "workflow-editor-topology-actionbar__left" }), _jsxs("div", { className: "workflow-editor-view-toggle", "aria-label": "Topology views", children: [_jsx("button", { type: "button", className: "workflow-editor-view-toggle__button ".concat(topologyViewOpen ? "is-active" : ""), "aria-label": topologyViewOpen ? "Hide topology view" : "Show topology view", title: topologyViewOpen ? "Hide topology view" : "Show topology view", onClick: function () { return setTopologyViewOpen(function (current) { return !current; }); }, children: _jsx(Layers3, { size: 14 }) }), _jsx("button", { type: "button", className: "workflow-editor-view-toggle__button ".concat(topologyYamlViewOpen ? "is-active" : ""), "aria-label": topologyYamlViewOpen ? "Hide YAML editor" : "Show YAML editor", title: topologyYamlViewOpen ? "Hide YAML editor" : "Show YAML editor", onClick: function () { return setTopologyYamlViewOpen(function (current) { return !current; }); }, children: _jsx(Braces, { size: 14 }) })] })] }), topologyViewOpen && topologyYamlViewOpen ? (_jsxs("div", { ref: topologySplitRef, className: "workflow-editor-topology-split", style: {
|
|
3249
|
+
gridTemplateColumns: "".concat(topologySplitPercent, "% 0.45rem minmax(0, 1fr)"),
|
|
3250
|
+
}, children: [_jsx("div", { className: "workflow-editor-topology-pane", children: topologyCanvasView }), _jsx("div", { className: "workflow-editor-topology-resizer", role: "separator", "aria-orientation": "vertical", "aria-label": "Resize topology and YAML views", onMouseDown: startTopologySplitResize }), _jsx("div", { className: "workflow-editor-topology-pane", children: topologyYamlEditorView })] })) : topologyViewOpen ? (_jsx("div", { className: "workflow-editor-topology-single", children: topologyCanvasView })) : topologyYamlViewOpen ? (_jsx("div", { className: "workflow-editor-topology-single", children: topologyYamlEditorView })) : (_jsxs("div", { className: "workflow-editor-placeholder", children: [_jsx("div", { className: "workflow-editor-placeholder__icon", children: _jsx(Layers3, { size: 20 }) }), _jsxs("div", { className: "workflow-editor-placeholder__copy", children: [_jsx("h3", { children: "No topology view selected" }), _jsx("p", { children: "Use the view toggles above to show the topology canvas or YAML editor." })] })] }))] }));
|
|
3251
|
+
var detailTabs = [
|
|
3252
|
+
{ value: "overview", label: "Overview", content: overviewContent },
|
|
3253
|
+
{
|
|
3254
|
+
value: "inputs",
|
|
3255
|
+
label: "Inputs",
|
|
3256
|
+
content: inputsContent,
|
|
3257
|
+
},
|
|
3258
|
+
{
|
|
3259
|
+
value: "variables",
|
|
3260
|
+
label: "Variables",
|
|
3261
|
+
content: variablesContent,
|
|
3262
|
+
},
|
|
3263
|
+
{
|
|
3264
|
+
value: "topology",
|
|
3265
|
+
label: "Topology",
|
|
3266
|
+
content: topologyContent,
|
|
3267
|
+
},
|
|
3268
|
+
{
|
|
3269
|
+
value: "executions",
|
|
3270
|
+
label: "Executions",
|
|
3271
|
+
content: executionsContent,
|
|
3272
|
+
},
|
|
3273
|
+
{
|
|
3274
|
+
value: "triggers",
|
|
3275
|
+
label: "Triggers",
|
|
3276
|
+
content: triggersContent,
|
|
3277
|
+
},
|
|
3278
|
+
];
|
|
3279
|
+
var handleDetailTabChange = function (value) {
|
|
3280
|
+
var nextTab = value;
|
|
3281
|
+
if (workflowDefinitionId === "new" && nextTab !== "overview") {
|
|
3282
|
+
var errors = validateWorkflowIdentity();
|
|
3283
|
+
if (hasWorkflowIdentityErrors(errors)) {
|
|
3284
|
+
setDetailTab("overview");
|
|
3285
|
+
return;
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
setDetailTab(nextTab);
|
|
3289
|
+
};
|
|
3290
|
+
if (isWorkflowDefinitionLoading || isNodeTypesLoading) {
|
|
3291
|
+
return (_jsx("div", { className: "workflow-editor-page workflow-editor-page--loading", children: _jsx(SolidSpinner, {}) }));
|
|
3292
|
+
}
|
|
3293
|
+
if (isNodeTypesError) {
|
|
3294
|
+
return (_jsx("div", { className: "workflow-editor-page", children: _jsx("div", { className: "workflow-editor-empty-state", children: "Failed to load workflow node types." }) }));
|
|
3295
|
+
}
|
|
3296
|
+
return (_jsxs("div", { className: "workflow-editor-page", children: [_jsxs("div", { className: "workflow-editor-header", children: [_jsx("div", { className: "workflow-editor-header-main", children: _jsx(SolidButton, { size: "small", variant: "ghost", leftIcon: _jsx(ArrowLeft, { size: 16 }), onClick: function () {
|
|
3297
|
+
return navigate("/admin/core/solid-core/workflow-definition/list");
|
|
3298
|
+
}, children: "Back" }) }), _jsxs("div", { className: "workflow-editor-header-actions", children: [_jsx(SolidButton, { size: "small", variant: "outline", leftIcon: _jsx(ShieldCheck, { size: 16 }), loading: isServerValidating, onClick: function () { return void validateCurrentDefinition({ showSuccessToast: true }); }, children: "Validate" }), _jsx(SolidButton, { size: "small", variant: "outline", leftIcon: _jsx(Play, { size: 16 }), loading: isExecuting, onClick: function () { return void handleExecute(); }, children: "Run" }), _jsx(SolidButton, { size: "small", leftIcon: _jsx(Save, { size: 16 }), loading: isSaving || isCreating, onClick: handleSave, children: "Save" })] })] }), _jsx("div", { className: "workflow-editor-detail-tabs", children: _jsx(SolidTabGroup, { tabs: detailTabs.map(function (tab) { return ({
|
|
3299
|
+
value: tab.value,
|
|
3300
|
+
label: tab.label,
|
|
3301
|
+
content: tab.content,
|
|
3302
|
+
}); }), value: detailTab, onValueChange: handleDetailTabChange, listClassName: "workflow-editor-detail-tabs__list", panelClassName: "workflow-editor-detail-tabs__panel" }) }), _jsx(SolidDialog, { open: Boolean(defaultValueEditorEntry), onOpenChange: function (open) {
|
|
3303
|
+
if (!open) {
|
|
3304
|
+
closeDefaultValueEditor();
|
|
3305
|
+
}
|
|
3306
|
+
}, header: defaultValueEditorEntry
|
|
3307
|
+
? "Default Value - ".concat(defaultValueEditorEntry.definition.label || defaultValueEditorEntry.key)
|
|
3308
|
+
: "Default Value", className: "workflow-editor-default-dialog", style: { width: "min(560px, 94vw)" }, footer: _jsxs("div", { className: "workflow-editor-default-dialog__footer", children: [_jsx(SolidButton, { type: "button", variant: "secondary", onClick: clearDefaultValueEditor, children: "Clear Default" }), _jsxs("div", { children: [_jsx(SolidButton, { type: "button", variant: "secondary", onClick: closeDefaultValueEditor, children: "Cancel" }), _jsx(SolidButton, { type: "button", onClick: saveDefaultValueEditor, children: "Save Default" })] })] }), children: _jsx(SolidDialogBody, { children: defaultValueEditorEntry ? (_jsxs("div", { className: "workflow-editor-default-dialog__body", children: [_jsxs("p", { children: ["This value is used when callers do not provide", " ", _jsx("code", { children: defaultValueEditorEntry.key }), "."] }), renderDefaultValueEditorField(), defaultValueEditorError ? (_jsx("div", { className: "workflow-editor-field-error", children: defaultValueEditorError })) : null] })) : null }) }), _jsx(SolidDialog, { open: Boolean(variableValueEditorEntry), onOpenChange: function (open) {
|
|
3309
|
+
if (!open) {
|
|
3310
|
+
closeVariableValueEditor();
|
|
3311
|
+
}
|
|
3312
|
+
}, header: variableValueEditorEntry
|
|
3313
|
+
? "Variable Value - ".concat(variableValueEditorEntry.definition.label || variableValueEditorEntry.key)
|
|
3314
|
+
: "Variable Value", className: "workflow-editor-default-dialog", style: { width: "min(520px, 92vw)" }, footer: _jsxs("div", { className: "workflow-editor-default-dialog__footer", children: [_jsx(SolidButton, { type: "button", variant: "secondary", onClick: closeVariableValueEditor, children: "Cancel" }), _jsx(SolidButton, { type: "button", onClick: saveVariableValueEditor, children: "Save Value" })] }), children: _jsx(SolidDialogBody, { children: variableValueEditorEntry ? (_jsxs("div", { className: "workflow-editor-default-dialog__body", children: [_jsxs("p", { children: ["Nodes can reference this value as", " ", _jsx("code", { children: "{{ variables.".concat(variableValueEditorEntry.key, " }}") }), "."] }), renderVariableValueEditorField(), variableValueEditorError ? (_jsx("div", { className: "workflow-editor-field-error", children: variableValueEditorError })) : null] })) : null }) }), _jsx(SolidDialog, { open: runInputsOpen, onOpenChange: function (open) {
|
|
3315
|
+
if (!isExecuting) {
|
|
3316
|
+
setRunInputsOpen(open);
|
|
3317
|
+
}
|
|
3318
|
+
}, header: "Run Workflow", className: "workflow-editor-run-input-dialog", style: { width: "min(620px, 94vw)" }, footer: _jsxs("div", { className: "workflow-editor-run-input-dialog__footer", children: [_jsx(SolidButton, { type: "button", variant: "secondary", disabled: isExecuting, onClick: function () { return setRunInputsOpen(false); }, children: "Cancel" }), _jsx(SolidButton, { type: "button", loading: isExecuting, onClick: function () { return void handleRunInputsSubmit(); }, children: "Run Workflow" })] }), children: _jsx(SolidDialogBody, { children: _jsxs("form", { className: "workflow-editor-run-input-dialog__form", onSubmit: function (event) {
|
|
3319
|
+
event.preventDefault();
|
|
3320
|
+
void handleRunInputsSubmit();
|
|
3321
|
+
}, children: [_jsxs("div", { className: "workflow-editor-run-input-dialog__intro", children: [_jsx("h3", { children: workflowDisplayName || (record === null || record === void 0 ? void 0 : record.displayName) || workflowKey || "Workflow" }), _jsx("p", { children: "Provide the runtime inputs required for this execution." })] }), workflowInputEntries.map(function (_a) {
|
|
3322
|
+
var _b, _c;
|
|
3323
|
+
var key = _a.key, definition = _a.definition;
|
|
3324
|
+
var fieldId = "workflow-run-input-".concat(key);
|
|
3325
|
+
var fieldError = runInputErrors[key];
|
|
3326
|
+
var label = definition.label || key;
|
|
3327
|
+
var type = definition.type || "string";
|
|
3328
|
+
return (_jsxs("div", { className: "workflow-editor-run-input-field ".concat(fieldError ? "is-invalid" : ""), children: [type === "boolean" ? (_jsx(SolidCheckbox, { checked: Boolean(runInputValues[key]), label: "".concat(label).concat(definition.required ? " *" : ""), onChange: function (event) {
|
|
3329
|
+
setRunInputValues(function (current) {
|
|
3330
|
+
var _a;
|
|
3331
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = event.currentTarget.checked, _a)));
|
|
3332
|
+
});
|
|
3333
|
+
setRunInputErrors(function (current) {
|
|
3334
|
+
var _a;
|
|
3335
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = "", _a)));
|
|
3336
|
+
});
|
|
3337
|
+
} })) : (_jsxs(_Fragment, { children: [_jsxs("label", { htmlFor: fieldId, children: [label, definition.required ? _jsx("span", { children: " *" }) : null] }), type === "object" || type === "array" ? (_jsx(SolidTextarea, { id: fieldId, value: (_b = runInputValues[key]) !== null && _b !== void 0 ? _b : "", placeholder: type === "array" ? "[]" : "{}", rows: 5, onChange: function (event) {
|
|
3338
|
+
setRunInputValues(function (current) {
|
|
3339
|
+
var _a;
|
|
3340
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = event.target.value, _a)));
|
|
3341
|
+
});
|
|
3342
|
+
setRunInputErrors(function (current) {
|
|
3343
|
+
var _a;
|
|
3344
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = "", _a)));
|
|
3345
|
+
});
|
|
3346
|
+
} })) : (_jsx(SolidInput, { id: fieldId, type: type === "number" ? "number" : type === "date" ? "date" : "text", value: (_c = runInputValues[key]) !== null && _c !== void 0 ? _c : "", onChange: function (event) {
|
|
3347
|
+
setRunInputValues(function (current) {
|
|
3348
|
+
var _a;
|
|
3349
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = event.target.value, _a)));
|
|
3350
|
+
});
|
|
3351
|
+
setRunInputErrors(function (current) {
|
|
3352
|
+
var _a;
|
|
3353
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = "", _a)));
|
|
3354
|
+
});
|
|
3355
|
+
} }))] })), definition.description ? (_jsx("p", { className: "workflow-editor-run-input-field__help", children: definition.description })) : null, fieldError ? (_jsx("div", { className: "workflow-editor-field-error", children: fieldError })) : null] }, key));
|
|
3356
|
+
})] }) }) }), selectedNode && selectedNodeType ? (_jsx(WorkflowNodeEditorDialog, { open: editorOpen, onOpenChange: setEditorOpen, nodeType: selectedNodeType, nodeValue: selectedNode, expressionSuggestions: selectedNodeExpressionSuggestions, onNodeSubmit: function (nextValue) {
|
|
3357
|
+
handleUpdateSelectedNode(nextValue);
|
|
3358
|
+
setEditorOpen(false);
|
|
3359
|
+
}, title: "".concat((_u = selectedNode.name) !== null && _u !== void 0 ? _u : selectedNode.id, " \u00B7 ").concat((_v = selectedNodeType.label) !== null && _v !== void 0 ? _v : selectedNodeType.type) })) : null, _jsx(WorkflowAddNodeDialog, { open: !!pendingInsertTarget, nodeTypes: nodeTypes, onOpenChange: function (open) {
|
|
3360
|
+
if (!open) {
|
|
3361
|
+
setPendingInsertTarget(null);
|
|
3362
|
+
}
|
|
3363
|
+
}, createNodeValue: createNodeFromType, onSubmit: handleAddNodeSubmit }), _jsx(SolidDialog, { open: topologyDocsOpen, onOpenChange: function (open) {
|
|
3364
|
+
setTopologyDocsOpen(open);
|
|
3365
|
+
if (!open) {
|
|
3366
|
+
setTopologyDocsNodeTypeKey("");
|
|
3367
|
+
setTopologyDocsModel(undefined);
|
|
3368
|
+
}
|
|
3369
|
+
}, header: "Node Documentation", className: "workflow-editor-topology-docs-dialog", style: { width: "min(920px, 94vw)", maxWidth: "96vw" }, children: _jsx(SolidDialogBody, { children: _jsx("div", { className: "workflow-editor-topology-docs-dialog__body", children: topologyDocsNodeType || topologyDocsModel ? (_jsx(WorkflowNodeDocsPanel, { nodeType: topologyDocsNodeType, docsModel: topologyDocsModel })) : (_jsx("div", { className: "workflow-editor-empty-state workflow-editor-empty-state--compact", children: "Documentation is not available for this topology item yet." })) }) }) })] }));
|
|
3370
|
+
}
|
|
3371
|
+
//# sourceMappingURL=WorkflowDefinitionEditorPage.js.map
|