@loopstack/loopstack-studio 0.23.1 → 0.25.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/api/config.js +3 -3
- package/dist/api/index.js +10 -12
- package/dist/api/processor.js +1 -1
- package/dist/api/secrets.js +16 -0
- package/dist/api/workflows.js +7 -1
- package/dist/components/dynamic-form/ArrayController.js +68 -64
- package/dist/components/dynamic-form/CodeContent.js +3 -3
- package/dist/components/dynamic-form/Form.js +46 -40
- package/dist/components/dynamic-form/FormElement.js +1 -1
- package/dist/components/dynamic-form/FormElementHeader.js +2 -2
- package/dist/components/dynamic-form/ObjectController.js +24 -21
- package/dist/components/dynamic-form/fields/BaseFieldWrapper.js +1 -1
- package/dist/components/dynamic-form/fields/CodeViewField.js +36 -36
- package/dist/components/dynamic-form/fields/InputField.js +20 -19
- package/dist/components/dynamic-form/fields/RadioField.js +18 -18
- package/dist/components/dynamic-form/fields/SelectField.js +19 -19
- package/dist/components/dynamic-form/fields/TextareaField.js +17 -17
- package/dist/components/feedback/LoadingCentered.js +1 -1
- package/dist/components/layout/MainLayout.js +18 -31
- package/dist/components/layout/StudioSidebar.js +169 -109
- package/dist/components/loopstack-elements/link.js +77 -76
- package/dist/components/loopstack-elements/tool.js +171 -0
- package/dist/components/page/PageBreadcrumbs.js +79 -32
- package/dist/components/ui-widgets/UiActions.js +10 -4
- package/dist/components/ui-widgets/widgets/ButtonFullWidth.js +8 -6
- package/dist/components/ui-widgets/widgets/SubmitButton.js +8 -6
- package/dist/features/code-explorer/components/FileContentViewer.js +92 -100
- package/dist/features/dashboard/RunItem.js +1 -1
- package/dist/features/debug/components/ConfigFlowViewer.js +2 -2
- package/dist/features/debug/components/{PipelineDebugHeader.js → WorkflowDebugHeader.js} +5 -5
- package/dist/features/debug/components/{PipelineDebugLegend.js → WorkflowDebugLegend.js} +2 -2
- package/dist/features/debug/components/{PipelineFlowViewer.js → WorkflowFlowViewer.js} +9 -9
- package/dist/features/debug/components/workflow-flow/WorkflowGraph.js +46 -0
- package/dist/features/debug/index.js +2 -2
- package/dist/features/debug/lib/flow-utils.js +142 -150
- package/dist/features/documents/DocumentRenderer.js +66 -30
- package/dist/features/documents/components/DocumentItem.js +2 -2
- package/dist/features/documents/components/DocumentList.js +18 -11
- package/dist/features/documents/document-details/DocumentDetails.js +4 -4
- package/dist/features/documents/renderers/AiMessage.js +12 -12
- package/dist/features/documents/renderers/ChoicesRenderer.js +92 -0
- package/dist/features/documents/renderers/ClaudeMessage.js +1 -1
- package/dist/features/documents/renderers/ConfirmPromptRenderer.js +56 -0
- package/dist/features/documents/renderers/DocumentFormRenderer.js +95 -65
- package/dist/features/documents/renderers/LinkMessageRenderer.js +8 -10
- package/dist/features/documents/renderers/SecretInputRenderer.js +87 -0
- package/dist/features/documents/renderers/TextPromptRenderer.js +57 -0
- package/dist/features/documents/renderers/useDocumentTransition.js +30 -0
- package/dist/features/oauth/OAuthPromptRenderer.js +20 -20
- package/dist/features/runs/Runs.js +8 -8
- package/dist/features/workbench/Workbench.js +35 -35
- package/dist/features/workbench/WorkflowItem.js +10 -9
- package/dist/features/workbench/WorkflowList.js +56 -73
- package/dist/features/workbench/components/NewRunDialog.js +18 -18
- package/dist/features/workbench/components/WorkbenchFilesPanel.js +33 -26
- package/dist/features/workbench/components/WorkbenchFloatingPanel.js +13 -44
- package/dist/features/workbench/components/WorkbenchFlowPanel.js +27 -29
- package/dist/features/workbench/components/WorkbenchIconSidebar.js +17 -17
- package/dist/features/workbench/components/WorkbenchPreviewPanel.js +2 -2
- package/dist/features/workbench/components/WorkbenchSecretsPanel.js +182 -0
- package/dist/features/workbench/components/WorkbenchSettingsModal.js +16 -41
- package/dist/features/workbench/components/WorkflowForms.js +14 -13
- package/dist/features/workbench/components/WorkflowHistoryItem.js +60 -81
- package/dist/features/workbench/components/{PipelineHistoryList.js → WorkflowHistoryList.js} +5 -5
- package/dist/features/workbench/components/buttons/WorkflowButtons.js +56 -54
- package/dist/features/workbench/hooks/useWorkflowData.js +10 -10
- package/dist/features/workbench/hooks/useWorkflowListState.js +8 -45
- package/dist/features/workbench/index.js +2 -3
- package/dist/features/workbench/providers/RemoteFileExplorerProvider.js +132 -117
- package/dist/features/workbench/providers/ScrollProvider.js +2 -2
- package/dist/features/workbench/providers/WorkbenchLayoutProvider.js +4 -4
- package/dist/features/workspaces/Workspaces.js +1 -1
- package/dist/features/workspaces/components/CreateWorkspace.js +12 -12
- package/dist/features/workspaces/components/ExecutionTimeline.js +22 -21
- package/dist/features/workspaces/components/{NewPipelineRunDialog.js → NewWorkflowRunDialog.js} +6 -6
- package/dist/features/workspaces/components/{PipelineForm.js → WorkflowRunForm.js} +31 -31
- package/dist/features/workspaces/components/WorkspaceHomePage.js +11 -11
- package/dist/features/workspaces/components/{pipeline-form → workflow-form}/ArgumentsView.js +1 -1
- package/dist/features/workspaces/components/{pipeline-form → workflow-form}/SelectionView.js +16 -16
- package/dist/hooks/index.js +3 -3
- package/dist/hooks/query-keys.js +34 -68
- package/dist/hooks/useConfig.js +5 -5
- package/dist/hooks/useProcessor.js +5 -5
- package/dist/hooks/useSecrets.js +69 -0
- package/dist/hooks/useWorkflows.js +155 -68
- package/dist/index.d.ts +158 -116
- package/dist/index.js +5 -5
- package/dist/packages/contracts/dist/enums/index.js +11 -12
- package/dist/packages/contracts/dist/enums/workflow-state.enum.js +1 -1
- package/dist/pages/DashboardPage.js +87 -35
- package/dist/pages/DebugWorkflowDetailsPage.js +8 -8
- package/dist/pages/DebugWorkflowsPage.js +10 -10
- package/dist/pages/EmbedWorkbenchPage.js +39 -45
- package/dist/pages/PreviewWorkbenchPage.js +130 -255
- package/dist/pages/RunsListPage.js +1 -1
- package/dist/pages/StudioLandingPage.js +13 -13
- package/dist/pages/WorkbenchPage.js +6 -6
- package/dist/pages/WorkflowDebugPage.js +114 -0
- package/dist/pages/WorkspacePage.js +4 -2
- package/dist/providers/InvalidationEventsProvider.js +19 -19
- package/dist/providers/SseProvider.js +0 -1
- package/dist/routing/LocalRouter.js +14 -17
- package/dist/types/ai.types.js +13 -0
- package/package.json +2 -3
- package/dist/api/namespaces.js +0 -7
- package/dist/api/pipelines.js +0 -13
- package/dist/components/ai-elements/tool.js +0 -158
- package/dist/features/debug/components/pipeline-flow/WorkflowGraph.js +0 -41
- package/dist/features/workbench/NavigationItems.js +0 -52
- package/dist/features/workbench/WorkbenchNavigation.js +0 -38
- package/dist/features/workbench/components/NavigationItem.js +0 -68
- package/dist/features/workbench/hooks/useIntersectionObserver.js +0 -44
- package/dist/hooks/useNamespaceTree.js +0 -27
- package/dist/hooks/useNamespaces.js +0 -25
- package/dist/hooks/usePipelines.js +0 -161
- package/dist/node_modules/@ai-sdk/provider/dist/index.js +0 -65
- package/dist/node_modules/@ai-sdk/provider-utils/dist/index.js +0 -1008
- package/dist/node_modules/ai/dist/index.js +0 -1083
- package/dist/node_modules/zod/v3/ZodError.js +0 -79
- package/dist/node_modules/zod/v3/errors.js +0 -6
- package/dist/node_modules/zod/v3/helpers/errorUtil.js +0 -5
- package/dist/node_modules/zod/v3/helpers/parseUtil.js +0 -90
- package/dist/node_modules/zod/v3/helpers/util.js +0 -72
- package/dist/node_modules/zod/v3/locales/en.js +0 -58
- package/dist/node_modules/zod/v3/types.js +0 -2425
- package/dist/node_modules/zod/v4/classic/errors.js +0 -21
- package/dist/node_modules/zod/v4/classic/iso.js +0 -29
- package/dist/node_modules/zod/v4/classic/parse.js +0 -4
- package/dist/node_modules/zod/v4/classic/schemas.js +0 -392
- package/dist/node_modules/zod/v4/core/api.js +0 -532
- package/dist/node_modules/zod/v4/core/checks.js +0 -283
- package/dist/node_modules/zod/v4/core/core.js +0 -44
- package/dist/node_modules/zod/v4/core/doc.js +0 -21
- package/dist/node_modules/zod/v4/core/errors.js +0 -40
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +0 -305
- package/dist/node_modules/zod/v4/core/parse.js +0 -66
- package/dist/node_modules/zod/v4/core/regexes.js +0 -28
- package/dist/node_modules/zod/v4/core/registries.js +0 -38
- package/dist/node_modules/zod/v4/core/schemas.js +0 -863
- package/dist/node_modules/zod/v4/core/to-json-schema.js +0 -220
- package/dist/node_modules/zod/v4/core/util.js +0 -267
- package/dist/node_modules/zod/v4/core/versions.js +0 -6
- package/dist/packages/contracts/dist/enums/pipeline-state.js +0 -10
- package/dist/pages/PipelineDebugPage.js +0 -115
- /package/dist/features/debug/components/{pipeline-flow → workflow-flow}/StateNode.js +0 -0
- /package/dist/features/debug/components/{pipeline-flow → workflow-flow}/WorkflowTransitionEdge.js +0 -0
- /package/dist/features/workspaces/components/{pipeline-form → workflow-form}/HeaderSection.js +0 -0
|
@@ -11,7 +11,7 @@ function RunItem(a) {
|
|
|
11
11
|
paused: "bg-yellow-50 text-yellow-900 border-yellow-200",
|
|
12
12
|
pending: "bg-muted text-muted-foreground border-border"
|
|
13
13
|
}[s.status] || "bg-muted text-muted-foreground border-border", d;
|
|
14
|
-
o[0] !== l || o[1] !== s.id ? (d = l.
|
|
14
|
+
o[0] !== l || o[1] !== s.id ? (d = l.getWorkflow(s.id), o[0] = l, o[1] = s.id, o[2] = d) : d = o[2];
|
|
15
15
|
let f = s.id, p = s.run ?? s.index ?? "?", m = s.title ? `(${s.title})` : "", h;
|
|
16
16
|
o[3] !== p || o[4] !== m ? (h = /* @__PURE__ */ jsxs("h3", {
|
|
17
17
|
className: "text-foreground group-hover:text-primary truncate font-semibold transition-colors",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Background, BackgroundVariant, Controls, index, useEdgesState, useNodesState, useReactFlow } from "../../../node_modules/@xyflow/react/dist/esm/index.js";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import StateNode_default from "./
|
|
3
|
+
import StateNode_default from "./workflow-flow/StateNode.js";
|
|
4
4
|
import { buildWorkflowGraph } from "../lib/flow-utils.js";
|
|
5
|
-
import WorkflowTransitionEdge_default from "./
|
|
5
|
+
import WorkflowTransitionEdge_default from "./workflow-flow/WorkflowTransitionEdge.js";
|
|
6
6
|
import { c } from "react/compiler-runtime";
|
|
7
7
|
import React, { useEffect, useRef } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Button } from "../../../components/ui/button.js";
|
|
2
|
-
import
|
|
2
|
+
import WorkflowDebugLegend_default from "./WorkflowDebugLegend.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { ArrowLeft } from "lucide-react";
|
|
6
|
-
var
|
|
6
|
+
var WorkflowDebugHeader_default = (o) => {
|
|
7
7
|
let s = c(16), { title: l, runNumber: u, onBack: d } = o, f;
|
|
8
8
|
s[0] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ jsx(ArrowLeft, { className: "h-4 w-4" }), s[0] = f) : f = s[0];
|
|
9
9
|
let p;
|
|
@@ -22,7 +22,7 @@ var PipelineDebugHeader_default = (o) => {
|
|
|
22
22
|
let h = u && `· Run #${u}`, g;
|
|
23
23
|
s[5] === h ? g = s[6] : (g = /* @__PURE__ */ jsxs("p", {
|
|
24
24
|
className: "text-muted-foreground text-xs font-medium tracking-wider uppercase",
|
|
25
|
-
children: ["
|
|
25
|
+
children: ["Workflow Flow Visualization ", h]
|
|
26
26
|
}), s[5] = h, s[6] = g);
|
|
27
27
|
let _;
|
|
28
28
|
s[7] !== m || s[8] !== g ? (_ = /* @__PURE__ */ jsxs("div", {
|
|
@@ -37,7 +37,7 @@ var PipelineDebugHeader_default = (o) => {
|
|
|
37
37
|
let y;
|
|
38
38
|
s[13] === Symbol.for("react.memo_cache_sentinel") ? (y = /* @__PURE__ */ jsx("div", {
|
|
39
39
|
className: "hidden items-center gap-6 sm:flex",
|
|
40
|
-
children: /* @__PURE__ */ jsx(
|
|
40
|
+
children: /* @__PURE__ */ jsx(WorkflowDebugLegend_default, {})
|
|
41
41
|
}), s[13] = y) : y = s[13];
|
|
42
42
|
let b;
|
|
43
43
|
return s[14] === v ? b = s[15] : (b = /* @__PURE__ */ jsxs("div", {
|
|
@@ -45,4 +45,4 @@ var PipelineDebugHeader_default = (o) => {
|
|
|
45
45
|
children: [v, y]
|
|
46
46
|
}), s[14] = v, s[15] = b), b;
|
|
47
47
|
};
|
|
48
|
-
export {
|
|
48
|
+
export { WorkflowDebugHeader_default as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c } from "react/compiler-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
var
|
|
4
|
+
var WorkflowDebugLegend_default = () => {
|
|
5
5
|
let r = c(7), i;
|
|
6
6
|
r[0] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ jsxs("div", {
|
|
7
7
|
className: "flex items-center gap-2",
|
|
@@ -65,4 +65,4 @@ var PipelineDebugLegend_default = () => {
|
|
|
65
65
|
]
|
|
66
66
|
}), r[6] = d) : d = r[6], d;
|
|
67
67
|
};
|
|
68
|
-
export {
|
|
68
|
+
export { WorkflowDebugLegend_default as default };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useWorkflow } from "../../../hooks/useWorkflows.js";
|
|
2
2
|
import { Background, BackgroundVariant, Controls, index, useEdgesState, useNodesState, useReactFlow } from "../../../node_modules/@xyflow/react/dist/esm/index.js";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import StateNode_default from "./
|
|
5
|
-
import WorkflowGraph_default from "./
|
|
6
|
-
import WorkflowTransitionEdge_default from "./
|
|
4
|
+
import StateNode_default from "./workflow-flow/StateNode.js";
|
|
5
|
+
import WorkflowGraph_default from "./workflow-flow/WorkflowGraph.js";
|
|
6
|
+
import WorkflowTransitionEdge_default from "./workflow-flow/WorkflowTransitionEdge.js";
|
|
7
7
|
import { c } from "react/compiler-runtime";
|
|
8
8
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { Loader2 } from "lucide-react";
|
|
11
|
-
var nodeTypes = { stateNode: StateNode_default }, edgeTypes = { workflowTransition: WorkflowTransitionEdge_default },
|
|
12
|
-
let x = c(29), {
|
|
11
|
+
var nodeTypes = { stateNode: StateNode_default }, edgeTypes = { workflowTransition: WorkflowTransitionEdge_default }, WorkflowFlowViewer_default = (b) => {
|
|
12
|
+
let x = c(29), { workflowId: S, workflows: C, workflowConfig: w, direction: T } = b, E = T === void 0 ? "LR" : T, { data: D } = useWorkflow(S), O;
|
|
13
13
|
x[0] === Symbol.for("react.memo_cache_sentinel") ? (O = [], x[0] = O) : O = x[0];
|
|
14
14
|
let [k, A, j] = useNodesState(O), M;
|
|
15
15
|
x[1] === Symbol.for("react.memo_cache_sentinel") ? (M = [], x[1] = M) : M = x[1];
|
|
@@ -65,9 +65,9 @@ var nodeTypes = { stateNode: StateNode_default }, edgeTypes = { workflowTransiti
|
|
|
65
65
|
}
|
|
66
66
|
let X;
|
|
67
67
|
x[15] !== E || x[16] !== q || x[17] !== D || x[18] !== w || x[19] !== C ? (X = D && C.map((e) => /* @__PURE__ */ jsx(WorkflowGraph_default, {
|
|
68
|
-
|
|
68
|
+
parentWorkflow: D,
|
|
69
69
|
workflow: e,
|
|
70
|
-
|
|
70
|
+
workflowConfig: w,
|
|
71
71
|
onGraphReady: q,
|
|
72
72
|
onLoadingChange: G,
|
|
73
73
|
direction: E
|
|
@@ -107,4 +107,4 @@ var nodeTypes = { stateNode: StateNode_default }, edgeTypes = { workflowTransiti
|
|
|
107
107
|
function _temp(e) {
|
|
108
108
|
return e;
|
|
109
109
|
}
|
|
110
|
-
export {
|
|
110
|
+
export { WorkflowFlowViewer_default as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useWorkflow, useWorkflowCheckpoints } from "../../../../hooks/useWorkflows.js";
|
|
2
|
+
import { buildWorkflowGraph, getTransitions } from "../../lib/flow-utils.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import React, { useEffect, useRef } from "react";
|
|
5
|
+
function countTransitions(e) {
|
|
6
|
+
return e ? getTransitions(e).length : 0;
|
|
7
|
+
}
|
|
8
|
+
var WorkflowGraph_default = (l) => {
|
|
9
|
+
let u = c(24), { parentWorkflow: d, workflow: f, workflowConfig: p, onGraphReady: m, onLoadingChange: h, direction: g } = l, _ = g === void 0 ? "LR" : g, v = useWorkflow(f.id), y = v.data, b = useWorkflowCheckpoints(f.id), x;
|
|
10
|
+
u[0] === b.data ? x = u[1] : (x = b.data ?? [], u[0] = b.data, u[1] = x);
|
|
11
|
+
let S = x, C = useRef(null), w = v.isLoading || b.isLoading, T, E;
|
|
12
|
+
u[2] !== w || u[3] !== h || u[4] !== f.id ? (T = () => {
|
|
13
|
+
h(f.id, w);
|
|
14
|
+
}, E = [
|
|
15
|
+
f.id,
|
|
16
|
+
w,
|
|
17
|
+
h
|
|
18
|
+
], u[2] = w, u[3] = h, u[4] = f.id, u[5] = T, u[6] = E) : (T = u[5], E = u[6]), useEffect(T, E);
|
|
19
|
+
let D;
|
|
20
|
+
u[7] !== S || u[8] !== _ || u[9] !== w || u[10] !== m || u[11] !== d || u[12] !== f.id || u[13] !== p || u[14] !== y ? (D = () => {
|
|
21
|
+
if (w) return;
|
|
22
|
+
let e = p ? getTransitions(p) : [], a = JSON.stringify({
|
|
23
|
+
p: countTransitions(d),
|
|
24
|
+
w: countTransitions(y),
|
|
25
|
+
c: e.length,
|
|
26
|
+
checkpoints: S.length,
|
|
27
|
+
place: y?.place
|
|
28
|
+
});
|
|
29
|
+
if (a !== C.current) {
|
|
30
|
+
C.current = a;
|
|
31
|
+
let { nodes: o, edges: s } = buildWorkflowGraph(d, y, f.id, e, _, !1, S);
|
|
32
|
+
m(f.id, o, s);
|
|
33
|
+
}
|
|
34
|
+
}, u[7] = S, u[8] = _, u[9] = w, u[10] = m, u[11] = d, u[12] = f.id, u[13] = p, u[14] = y, u[15] = D) : D = u[15];
|
|
35
|
+
let O;
|
|
36
|
+
return u[16] !== S || u[17] !== w || u[18] !== m || u[19] !== d || u[20] !== f || u[21] !== p || u[22] !== y ? (O = [
|
|
37
|
+
d,
|
|
38
|
+
f,
|
|
39
|
+
y,
|
|
40
|
+
S,
|
|
41
|
+
p,
|
|
42
|
+
m,
|
|
43
|
+
w
|
|
44
|
+
], u[16] = S, u[17] = w, u[18] = m, u[19] = d, u[20] = f, u[21] = p, u[22] = y, u[23] = O) : O = u[23], useEffect(D, O), null;
|
|
45
|
+
};
|
|
46
|
+
export { WorkflowGraph_default as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import WorkflowFlowViewer_default from "./components/WorkflowFlowViewer.js";
|
|
2
|
+
import WorkflowDebugHeader_default from "./components/WorkflowDebugHeader.js";
|
|
3
3
|
import ConfigFlowViewer_default from "./components/ConfigFlowViewer.js";
|
|
@@ -8,59 +8,59 @@ var NODE_WIDTH = 130, NODE_HEIGHT = 70, CONDITION_OPERATORS = {
|
|
|
8
8
|
ge: ">=",
|
|
9
9
|
le: "<="
|
|
10
10
|
};
|
|
11
|
-
function getLayoutedElements(e,
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
rankdir:
|
|
11
|
+
function getLayoutedElements(e, u, d = "LR") {
|
|
12
|
+
let f = new dagre_esm_default.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
|
|
13
|
+
f.setGraph({
|
|
14
|
+
rankdir: d,
|
|
15
15
|
nodesep: 100,
|
|
16
16
|
ranksep: 200
|
|
17
17
|
});
|
|
18
|
-
for (let
|
|
18
|
+
for (let o of e) f.setNode(o.id, {
|
|
19
19
|
width: NODE_WIDTH,
|
|
20
20
|
height: NODE_HEIGHT
|
|
21
21
|
});
|
|
22
|
-
for (let e of
|
|
23
|
-
return dagre_esm_default.layout(
|
|
22
|
+
for (let e of u) f.setEdge(e.source, e.target);
|
|
23
|
+
return dagre_esm_default.layout(f), {
|
|
24
24
|
nodes: e.map((e) => {
|
|
25
|
-
let
|
|
25
|
+
let s = f.node(e.id);
|
|
26
26
|
return {
|
|
27
27
|
...e,
|
|
28
|
-
targetPosition:
|
|
29
|
-
sourcePosition:
|
|
28
|
+
targetPosition: d === "LR" ? Position.Left : Position.Top,
|
|
29
|
+
sourcePosition: d === "LR" ? Position.Right : Position.Bottom,
|
|
30
30
|
position: {
|
|
31
|
-
x:
|
|
32
|
-
y:
|
|
31
|
+
x: s.x - NODE_WIDTH / 2,
|
|
32
|
+
y: s.y - NODE_HEIGHT / 2
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
}),
|
|
36
|
-
edges:
|
|
36
|
+
edges: u
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function getTransitions(e,
|
|
40
|
-
if (!e || typeof e != "object" ||
|
|
39
|
+
function getTransitions(e, o = /* @__PURE__ */ new Set()) {
|
|
40
|
+
if (!e || typeof e != "object" || o.has(e)) return [];
|
|
41
41
|
try {
|
|
42
|
-
|
|
42
|
+
o.add(e);
|
|
43
43
|
} catch {
|
|
44
44
|
return [];
|
|
45
45
|
}
|
|
46
|
-
let
|
|
47
|
-
if (Array.isArray(
|
|
48
|
-
if (
|
|
49
|
-
let e = getTransitions(
|
|
46
|
+
let s = e;
|
|
47
|
+
if (Array.isArray(s.transitions)) return s.transitions;
|
|
48
|
+
if (s.definition) {
|
|
49
|
+
let e = getTransitions(s.definition, o);
|
|
50
50
|
if (e.length > 0) return e;
|
|
51
51
|
}
|
|
52
|
-
if (
|
|
53
|
-
let e = getTransitions(
|
|
52
|
+
if (s.specification) {
|
|
53
|
+
let e = getTransitions(s.specification, o);
|
|
54
54
|
if (e.length > 0) return e;
|
|
55
55
|
}
|
|
56
|
-
for (let e in
|
|
56
|
+
for (let e in s) {
|
|
57
57
|
if (e === "history" || e === "data") continue;
|
|
58
|
-
let
|
|
59
|
-
if (
|
|
60
|
-
let e = getTransitions(
|
|
58
|
+
let c = s[e];
|
|
59
|
+
if (c && typeof c == "object") {
|
|
60
|
+
let e = getTransitions(c, o);
|
|
61
61
|
if (e.length > 0) return e;
|
|
62
|
-
} else if (typeof
|
|
63
|
-
let e = getTransitions(JSON.parse(
|
|
62
|
+
} else if (typeof c == "string" && c.includes("\"transitions\":")) try {
|
|
63
|
+
let e = getTransitions(JSON.parse(c), o);
|
|
64
64
|
if (e.length > 0) return e;
|
|
65
65
|
} catch {}
|
|
66
66
|
}
|
|
@@ -68,125 +68,117 @@ function getTransitions(e, s = /* @__PURE__ */ new Set()) {
|
|
|
68
68
|
}
|
|
69
69
|
function formatCondition(e) {
|
|
70
70
|
if (!e) return "";
|
|
71
|
-
let
|
|
72
|
-
if (
|
|
73
|
-
let [e,
|
|
74
|
-
if (
|
|
71
|
+
let o = e.replace(/\{\{|\}\}/g, "").trim(), s = o.split(/\s+/);
|
|
72
|
+
if (s.length === 3) {
|
|
73
|
+
let [e, o, c] = s, l = CONDITION_OPERATORS[e];
|
|
74
|
+
if (l) return `${o} ${l} ${c}`;
|
|
75
75
|
}
|
|
76
|
-
return
|
|
76
|
+
return o;
|
|
77
77
|
}
|
|
78
|
-
function buildWorkflowGraph(e, s, c
|
|
79
|
-
let p = collectTransitions(e,
|
|
80
|
-
workflowId:
|
|
81
|
-
currentPlace:
|
|
82
|
-
endStates:
|
|
83
|
-
visitedStates:
|
|
84
|
-
visitCounts: buildVisitCounts(
|
|
85
|
-
direction:
|
|
86
|
-
forceVisible:
|
|
87
|
-
}),
|
|
88
|
-
workflowId:
|
|
89
|
-
executedMap:
|
|
90
|
-
stateRanks:
|
|
91
|
-
forceVisible:
|
|
78
|
+
function buildWorkflowGraph(e, o, s, c = [], l, u = !1, f = []) {
|
|
79
|
+
let p = collectTransitions(e, o, c), m = collectStates(p, f), b = buildExecutedMap(f), x = resolveTransitions(p, f), S = findEndStates(m, x), C = findVisitedStates(f), w = computeStateRanks(x), T = buildNodes(m, {
|
|
80
|
+
workflowId: s,
|
|
81
|
+
currentPlace: o?.place,
|
|
82
|
+
endStates: S,
|
|
83
|
+
visitedStates: C,
|
|
84
|
+
visitCounts: buildVisitCounts(f),
|
|
85
|
+
direction: l,
|
|
86
|
+
forceVisible: u
|
|
87
|
+
}), E = buildEdges(x, {
|
|
88
|
+
workflowId: s,
|
|
89
|
+
executedMap: b,
|
|
90
|
+
stateRanks: w,
|
|
91
|
+
forceVisible: u
|
|
92
92
|
});
|
|
93
|
-
return
|
|
94
|
-
nodes:
|
|
95
|
-
edges:
|
|
93
|
+
return T.length > 1 ? getLayoutedElements(T, E, l) : {
|
|
94
|
+
nodes: T,
|
|
95
|
+
edges: E
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
function collectTransitions(e,
|
|
99
|
-
let
|
|
100
|
-
e &&
|
|
101
|
-
let
|
|
102
|
-
return
|
|
103
|
-
let
|
|
104
|
-
return
|
|
98
|
+
function collectTransitions(e, o, s) {
|
|
99
|
+
let c = [...s];
|
|
100
|
+
e && c.push(...getTransitions(e)), o && c.push(...getTransitions(o));
|
|
101
|
+
let l = /* @__PURE__ */ new Set();
|
|
102
|
+
return c.filter((e) => {
|
|
103
|
+
let o = Array.isArray(e.from) ? e.from.join(",") : e.from, s = `${e.id}-${o}-${e.to}`;
|
|
104
|
+
return l.has(s) ? !1 : (l.add(s), !0);
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
let e = Array.isArray(s.from) ? s.from : [s.from];
|
|
114
|
-
for (let s of e) c.add(s ?? "start");
|
|
115
|
-
c.add(s.to);
|
|
107
|
+
function collectStates(e, o) {
|
|
108
|
+
let s = new Set(["start"]);
|
|
109
|
+
for (let o of e) {
|
|
110
|
+
let e = Array.isArray(o.from) ? o.from : [o.from];
|
|
111
|
+
for (let o of e) s.add(o ?? "start");
|
|
112
|
+
s.add(o.to);
|
|
116
113
|
}
|
|
117
|
-
for (let e of
|
|
118
|
-
return
|
|
114
|
+
for (let e of o) e.place && s.add(e.place), e.transitionFrom && s.add(e.transitionFrom);
|
|
115
|
+
return s;
|
|
119
116
|
}
|
|
120
117
|
function buildVisitCounts(e) {
|
|
121
|
-
let
|
|
122
|
-
for (let
|
|
123
|
-
|
|
124
|
-
e && s.set(e, (s.get(e) ?? 0) + 1);
|
|
125
|
-
}
|
|
126
|
-
return s;
|
|
118
|
+
let o = new Map([["start", 1]]);
|
|
119
|
+
for (let s of e) s.place && o.set(s.place, (o.get(s.place) ?? 0) + 1);
|
|
120
|
+
return o;
|
|
127
121
|
}
|
|
128
122
|
function buildExecutedMap(e) {
|
|
129
|
-
let
|
|
130
|
-
for (let
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
s.set(l, (s.get(l) ?? 0) + 1);
|
|
123
|
+
let o = /* @__PURE__ */ new Map();
|
|
124
|
+
for (let s of e) {
|
|
125
|
+
if (!s.transitionId) continue;
|
|
126
|
+
let e = `${s.transitionFrom ?? "start"}->${s.place}:${s.transitionId}`;
|
|
127
|
+
o.set(e, (o.get(e) ?? 0) + 1);
|
|
135
128
|
}
|
|
136
|
-
return
|
|
129
|
+
return o;
|
|
137
130
|
}
|
|
138
|
-
function resolveTransitions(e,
|
|
139
|
-
let
|
|
140
|
-
for (let
|
|
141
|
-
let e = Array.isArray(
|
|
142
|
-
for (let
|
|
143
|
-
id:
|
|
144
|
-
from:
|
|
145
|
-
to:
|
|
146
|
-
condition:
|
|
147
|
-
trigger:
|
|
148
|
-
call:
|
|
131
|
+
function resolveTransitions(e, o) {
|
|
132
|
+
let s = [];
|
|
133
|
+
for (let o of e) {
|
|
134
|
+
let e = Array.isArray(o.from) ? o.from : [o.from], c = o;
|
|
135
|
+
for (let l of e) s.push({
|
|
136
|
+
id: o.id,
|
|
137
|
+
from: l ?? "start",
|
|
138
|
+
to: o.to,
|
|
139
|
+
condition: c.if ?? c.condition,
|
|
140
|
+
trigger: o.trigger,
|
|
141
|
+
call: o.call
|
|
149
142
|
});
|
|
150
143
|
}
|
|
151
|
-
for (let e of
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
to: s.to
|
|
144
|
+
for (let e of o) {
|
|
145
|
+
if (!e.transitionId) continue;
|
|
146
|
+
let o = e.transitionFrom ?? "start";
|
|
147
|
+
s.some((s) => s.from === o && s.to === e.place && s.id === e.transitionId) || s.push({
|
|
148
|
+
id: e.transitionId,
|
|
149
|
+
from: o,
|
|
150
|
+
to: e.place
|
|
159
151
|
});
|
|
160
152
|
}
|
|
161
|
-
return
|
|
153
|
+
return s;
|
|
162
154
|
}
|
|
163
|
-
function findEndStates(e,
|
|
164
|
-
let
|
|
165
|
-
for (let
|
|
166
|
-
return
|
|
155
|
+
function findEndStates(e, o) {
|
|
156
|
+
let s = new Set(o.map((e) => e.from)), c = /* @__PURE__ */ new Set();
|
|
157
|
+
for (let o of e) !s.has(o) && o !== "start" && c.add(o);
|
|
158
|
+
return c;
|
|
167
159
|
}
|
|
168
160
|
function findVisitedStates(e) {
|
|
169
|
-
let
|
|
170
|
-
for (let
|
|
171
|
-
return
|
|
161
|
+
let o = new Set(["start"]);
|
|
162
|
+
for (let s of e) s.place && o.add(s.place);
|
|
163
|
+
return o;
|
|
172
164
|
}
|
|
173
165
|
function computeStateRanks(e) {
|
|
174
|
-
let
|
|
175
|
-
for (let
|
|
176
|
-
if (
|
|
177
|
-
let e =
|
|
178
|
-
e.push(
|
|
166
|
+
let o = /* @__PURE__ */ new Map();
|
|
167
|
+
for (let s of e) {
|
|
168
|
+
if (s.from === s.to) continue;
|
|
169
|
+
let e = o.get(s.from) ?? [];
|
|
170
|
+
e.push(s.to), o.set(s.from, e);
|
|
179
171
|
}
|
|
180
|
-
let
|
|
181
|
-
for (;
|
|
182
|
-
let e =
|
|
183
|
-
for (let
|
|
172
|
+
let s = new Map([["start", 0]]), c = ["start"];
|
|
173
|
+
for (; c.length > 0;) {
|
|
174
|
+
let e = c.shift(), l = s.get(e);
|
|
175
|
+
for (let u of o.get(e) ?? []) s.has(u) || (s.set(u, l + 1), c.push(u));
|
|
184
176
|
}
|
|
185
|
-
return
|
|
177
|
+
return s;
|
|
186
178
|
}
|
|
187
|
-
function buildNodes(e,
|
|
179
|
+
function buildNodes(e, o) {
|
|
188
180
|
return Array.from(e).map((e) => ({
|
|
189
|
-
id: `${
|
|
181
|
+
id: `${o.workflowId}-${e}`,
|
|
190
182
|
type: "stateNode",
|
|
191
183
|
position: {
|
|
192
184
|
x: 0,
|
|
@@ -195,53 +187,53 @@ function buildNodes(e, s) {
|
|
|
195
187
|
data: {
|
|
196
188
|
label: e,
|
|
197
189
|
isStart: e === "start",
|
|
198
|
-
isEnd:
|
|
199
|
-
isCurrent: e ===
|
|
200
|
-
isVisited:
|
|
201
|
-
visitCount:
|
|
202
|
-
direction:
|
|
203
|
-
forceVisible:
|
|
190
|
+
isEnd: o.endStates.has(e),
|
|
191
|
+
isCurrent: e === o.currentPlace,
|
|
192
|
+
isVisited: o.visitedStates.has(e),
|
|
193
|
+
visitCount: o.visitCounts.get(e) ?? 0,
|
|
194
|
+
direction: o.direction,
|
|
195
|
+
forceVisible: o.forceVisible
|
|
204
196
|
}
|
|
205
197
|
}));
|
|
206
198
|
}
|
|
207
|
-
function buildEdges(
|
|
208
|
-
let
|
|
209
|
-
for (let
|
|
210
|
-
let
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
let
|
|
214
|
-
...
|
|
215
|
-
isExecuted:
|
|
216
|
-
isSelfLoop:
|
|
217
|
-
isBackEdge:
|
|
218
|
-
forceVisible:
|
|
199
|
+
function buildEdges(o, s) {
|
|
200
|
+
let c = /* @__PURE__ */ new Set(), l = [], u = 0;
|
|
201
|
+
for (let d of o) {
|
|
202
|
+
let o = `${d.from}->${d.to}:${d.id}`;
|
|
203
|
+
if (c.has(o)) continue;
|
|
204
|
+
c.add(o);
|
|
205
|
+
let f = s.executedMap.has(o), p = d.trigger === "onEntry", m = d.from === d.to, h = s.stateRanks.get(d.from) ?? 0, g = s.stateRanks.get(d.to) ?? 0, _ = !m && g <= h, v = f ? "var(--primary)" : "var(--muted-foreground)", y = {
|
|
206
|
+
...d,
|
|
207
|
+
isExecuted: f,
|
|
208
|
+
isSelfLoop: m,
|
|
209
|
+
isBackEdge: _,
|
|
210
|
+
forceVisible: s.forceVisible
|
|
219
211
|
};
|
|
220
|
-
|
|
221
|
-
id: `edge-${
|
|
222
|
-
source: `${
|
|
223
|
-
target: `${
|
|
224
|
-
...
|
|
212
|
+
l.push({
|
|
213
|
+
id: `edge-${s.workflowId}-${u++}`,
|
|
214
|
+
source: `${s.workflowId}-${d.from}`,
|
|
215
|
+
target: `${s.workflowId}-${d.to}`,
|
|
216
|
+
..._ && {
|
|
225
217
|
sourceHandle: "bottom-source",
|
|
226
218
|
targetHandle: "bottom-target"
|
|
227
219
|
},
|
|
228
220
|
type: "workflowTransition",
|
|
229
221
|
animated: !1,
|
|
230
222
|
style: {
|
|
231
|
-
strokeWidth:
|
|
232
|
-
stroke:
|
|
233
|
-
strokeDasharray:
|
|
234
|
-
opacity:
|
|
223
|
+
strokeWidth: f ? 2.5 : 1.5,
|
|
224
|
+
stroke: v,
|
|
225
|
+
strokeDasharray: p ? "4,4" : f ? void 0 : "5,5",
|
|
226
|
+
opacity: f || s.forceVisible ? 1 : .3
|
|
235
227
|
},
|
|
236
228
|
markerEnd: {
|
|
237
229
|
type: MarkerType.ArrowClosed,
|
|
238
230
|
width: 18,
|
|
239
231
|
height: 18,
|
|
240
|
-
color:
|
|
232
|
+
color: v
|
|
241
233
|
},
|
|
242
|
-
data:
|
|
234
|
+
data: y
|
|
243
235
|
});
|
|
244
236
|
}
|
|
245
|
-
return
|
|
237
|
+
return l;
|
|
246
238
|
}
|
|
247
239
|
export { buildWorkflowGraph, formatCondition, getTransitions };
|