@antelopejs/dms-automation 0.7.0 → 0.8.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/README.md +19 -5
- package/dist/cluster/bus.js +8 -6
- package/dist/cluster/bus.js.map +1 -1
- package/dist/cluster/leader.js.map +1 -1
- package/dist/data/procedures-query.d.ts +19 -0
- package/dist/data/procedures-query.js +105 -0
- package/dist/data/procedures-query.js.map +1 -0
- package/dist/data/procedures-table.d.ts +4 -20
- package/dist/data/procedures-table.js +10 -106
- package/dist/data/procedures-table.js.map +1 -1
- package/dist/data/runs-table.js.map +1 -1
- package/dist/db/models/automation_template.model.d.ts +2 -4
- package/dist/db/models/automation_template.model.js +13 -14
- package/dist/db/models/automation_template.model.js.map +1 -1
- package/dist/db/models/procedure_run.model.js.map +1 -1
- package/dist/db/models/stats.model.js.map +1 -1
- package/dist/db/tables/procedure_run.table.d.ts +2 -1
- package/dist/db/tables/procedure_run.table.js.map +1 -1
- package/dist/implementations/dms-automation/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pages/category.js.map +1 -1
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/procedures.js.map +1 -1
- package/dist/pages/runs.js.map +1 -1
- package/dist/pages/shared.js +1 -1
- package/dist/pages/shared.js.map +1 -1
- package/dist/realtime.d.ts +2 -1
- package/dist/realtime.js.map +1 -1
- package/dist/routes/action-types.d.ts +2 -1
- package/dist/routes/action-types.js.map +1 -1
- package/dist/routes/deleteConfirm.js +4 -3
- package/dist/routes/deleteConfirm.js.map +1 -1
- package/dist/routes/graphSchema.d.ts +2 -1
- package/dist/routes/graphSchema.js +8 -7
- package/dist/routes/graphSchema.js.map +1 -1
- package/dist/routes/procedureChecks.js +5 -5
- package/dist/routes/procedureChecks.js.map +1 -1
- package/dist/routes/procedureRuns.d.ts +2 -2
- package/dist/routes/procedureRuns.js +1 -1
- package/dist/routes/procedureRuns.js.map +1 -1
- package/dist/routes/procedures.d.ts +14 -13
- package/dist/routes/procedures.js +2 -1
- package/dist/routes/procedures.js.map +1 -1
- package/dist/routes/requests.d.ts +11 -5
- package/dist/routes/requests.js.map +1 -1
- package/dist/routes/runs.d.ts +7 -7
- package/dist/routes/runs.js +5 -3
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/stats.js.map +1 -1
- package/dist/routes/templates.d.ts +3 -2
- package/dist/routes/templates.js +2 -1
- package/dist/routes/templates.js.map +1 -1
- package/dist/routes/trigger-types.d.ts +2 -1
- package/dist/routes/trigger-types.js.map +1 -1
- package/dist/routes/typeConfigShared.d.ts +2 -1
- package/dist/routes/typeConfigShared.js.map +1 -1
- package/dist/runtime/armErrors.d.ts +0 -1
- package/dist/runtime/armErrors.js +0 -7
- package/dist/runtime/armErrors.js.map +1 -1
- package/dist/runtime/boundRunLog.d.ts +1 -0
- package/dist/runtime/boundRunLog.js +11 -11
- package/dist/runtime/boundRunLog.js.map +1 -1
- package/dist/runtime/builtins/actions/http.js +16 -9
- package/dist/runtime/builtins/actions/http.js.map +1 -1
- package/dist/runtime/builtins/actions/log.js.map +1 -1
- package/dist/runtime/builtins/data/boolean.js +4 -5
- package/dist/runtime/builtins/data/boolean.js.map +1 -1
- package/dist/runtime/builtins/data/compare.js +8 -10
- package/dist/runtime/builtins/data/compare.js.map +1 -1
- package/dist/runtime/builtins/data/constant.js +1 -1
- package/dist/runtime/builtins/data/constant.js.map +1 -1
- package/dist/runtime/builtins/data/json.js +4 -5
- package/dist/runtime/builtins/data/json.js.map +1 -1
- package/dist/runtime/builtins/data/math.js +4 -4
- package/dist/runtime/builtins/data/math.js.map +1 -1
- package/dist/runtime/builtins/data/object.js +12 -17
- package/dist/runtime/builtins/data/object.js.map +1 -1
- package/dist/runtime/builtins/data/string.js +13 -18
- package/dist/runtime/builtins/data/string.js.map +1 -1
- package/dist/runtime/builtins/nodes/action.js +5 -2
- package/dist/runtime/builtins/nodes/action.js.map +1 -1
- package/dist/runtime/builtins/nodes/data.js +2 -2
- package/dist/runtime/builtins/nodes/data.js.map +1 -1
- package/dist/runtime/builtins/nodes/delay.js +2 -2
- package/dist/runtime/builtins/nodes/delay.js.map +1 -1
- package/dist/runtime/builtins/nodes/forRange.js +2 -2
- package/dist/runtime/builtins/nodes/forRange.js.map +1 -1
- package/dist/runtime/builtins/nodes/foreach.js +2 -2
- package/dist/runtime/builtins/nodes/foreach.js.map +1 -1
- package/dist/runtime/builtins/nodes/groupInput.js +2 -2
- package/dist/runtime/builtins/nodes/groupInput.js.map +1 -1
- package/dist/runtime/builtins/nodes/groupOutput.js +2 -2
- package/dist/runtime/builtins/nodes/groupOutput.js.map +1 -1
- package/dist/runtime/builtins/nodes/if.js +2 -2
- package/dist/runtime/builtins/nodes/if.js.map +1 -1
- package/dist/runtime/builtins/nodes/parallel.js +2 -2
- package/dist/runtime/builtins/nodes/parallel.js.map +1 -1
- package/dist/runtime/builtins/nodes/retry.js +5 -4
- package/dist/runtime/builtins/nodes/retry.js.map +1 -1
- package/dist/runtime/builtins/nodes/setVariable.js +2 -2
- package/dist/runtime/builtins/nodes/setVariable.js.map +1 -1
- package/dist/runtime/builtins/nodes/switch.js +2 -2
- package/dist/runtime/builtins/nodes/switch.js.map +1 -1
- package/dist/runtime/builtins/nodes/trigger.js +2 -2
- package/dist/runtime/builtins/nodes/trigger.js.map +1 -1
- package/dist/runtime/builtins/nodes/tryCatch.js +2 -2
- package/dist/runtime/builtins/nodes/tryCatch.js.map +1 -1
- package/dist/runtime/builtins/triggers/cron.d.ts +2 -1
- package/dist/runtime/builtins/triggers/cron.js +5 -7
- package/dist/runtime/builtins/triggers/cron.js.map +1 -1
- package/dist/runtime/builtins/triggers/webhook.d.ts +6 -5
- package/dist/runtime/builtins/triggers/webhook.js +9 -6
- package/dist/runtime/builtins/triggers/webhook.js.map +1 -1
- package/dist/runtime/declaredProcedures.d.ts +2 -2
- package/dist/runtime/declaredProcedures.js +3 -2
- package/dist/runtime/declaredProcedures.js.map +1 -1
- package/dist/runtime/describe.js +11 -10
- package/dist/runtime/describe.js.map +1 -1
- package/dist/runtime/executor.js +10 -7
- package/dist/runtime/executor.js.map +1 -1
- package/dist/runtime/flatten.d.ts +1 -1
- package/dist/runtime/flatten.js +1 -1
- package/dist/runtime/flatten.js.map +1 -1
- package/dist/runtime/graphIssues.js +24 -22
- package/dist/runtime/graphIssues.js.map +1 -1
- package/dist/runtime/graphVersion.d.ts +1 -1
- package/dist/runtime/graphVersion.js +2 -1
- package/dist/runtime/graphVersion.js.map +1 -1
- package/dist/runtime/nodeKinds.d.ts +3 -2
- package/dist/runtime/nodeKinds.js.map +1 -1
- package/dist/runtime/reconcile.d.ts +3 -0
- package/dist/runtime/reconcile.js +178 -0
- package/dist/runtime/reconcile.js.map +1 -0
- package/dist/runtime/resolveInputs.d.ts +4 -2
- package/dist/runtime/resolveInputs.js +13 -12
- package/dist/runtime/resolveInputs.js.map +1 -1
- package/dist/runtime/resolveSubgraph.js +4 -5
- package/dist/runtime/resolveSubgraph.js.map +1 -1
- package/dist/runtime/retention.js.map +1 -1
- package/dist/runtime/runProcedure.d.ts +1 -1
- package/dist/runtime/runProcedure.js +2 -1
- package/dist/runtime/runProcedure.js.map +1 -1
- package/dist/runtime/schedule.js +3 -0
- package/dist/runtime/schedule.js.map +1 -1
- package/dist/runtime/schemaProperties.d.ts +11 -0
- package/dist/runtime/schemaProperties.js +7 -0
- package/dist/runtime/schemaProperties.js.map +1 -0
- package/dist/runtime/serialQueue.d.ts +1 -1
- package/dist/runtime/serialQueue.js +4 -4
- package/dist/runtime/serialQueue.js.map +1 -1
- package/dist/runtime/subscriptions.js +21 -180
- package/dist/runtime/subscriptions.js.map +1 -1
- package/dist/runtime/subwalk.js.map +1 -1
- package/dist/runtime/templateCacheState.d.ts +6 -0
- package/dist/runtime/templateCacheState.js +10 -0
- package/dist/runtime/templateCacheState.js.map +1 -0
- package/dist/runtime/templateUsages.js +4 -5
- package/dist/runtime/templateUsages.js.map +1 -1
- package/dist/runtime/topo.js +2 -4
- package/dist/runtime/topo.js.map +1 -1
- package/dist/runtime/trace.js +12 -9
- package/dist/runtime/trace.js.map +1 -1
- package/dist/runtime/triggerHandles.d.ts +3 -0
- package/dist/runtime/triggerHandles.js +8 -0
- package/dist/runtime/triggerHandles.js.map +1 -1
- package/dist/runtime/typeOrigin.js +12 -1
- package/dist/runtime/typeOrigin.js.map +1 -1
- package/dist/runtime/validate.js.map +1 -1
- package/dist/runtime/validateTemplate.js.map +1 -1
- package/dist/runtime/withTimeout.js.map +1 -1
- package/dist/runtime/wording.js +12 -8
- package/dist/runtime/wording.js.map +1 -1
- package/dist/stats/health-banner.js.map +1 -1
- package/dist/stats/health.js.map +1 -1
- package/dist/stats/kpi.js +1 -1
- package/dist/stats/kpi.js.map +1 -1
- package/dist/stats/overview.js +2 -1
- package/dist/stats/overview.js.map +1 -1
- package/dist/types/dataValue.d.ts +8 -0
- package/dist/types/dataValue.js +36 -0
- package/dist/types/dataValue.js.map +1 -0
- package/dist/types/graph.d.ts +8 -1
- package/dist/types/graph.js +8 -0
- package/dist/types/graph.js.map +1 -1
- package/dist/types/guards.d.ts +8 -0
- package/dist/types/guards.js +35 -0
- package/dist/types/guards.js.map +1 -0
- package/frontend-vue/app/build/components/editor/EditorBanners.vue +120 -0
- package/frontend-vue/app/build/components/editor/EditorChoiceModal.vue +44 -0
- package/frontend-vue/app/build/components/editor/EditorForkModal.vue +51 -0
- package/frontend-vue/app/build/components/editor/EditorHeader.vue +146 -0
- package/frontend-vue/app/build/components/editor/EditorSaveTemplateModal.vue +105 -0
- package/frontend-vue/app/build/components/editor/NodeInspectorDocs.vue +28 -0
- package/frontend-vue/app/build/components/editor/NodeInspectorRun.vue +48 -0
- package/frontend-vue/app/build/composables/editor/useBuilderMount.ts +129 -0
- package/frontend-vue/app/build/composables/editor/useBuilderSave.ts +256 -0
- package/frontend-vue/app/build/composables/editor/useBuilderShortcuts.ts +270 -0
- package/frontend-vue/app/build/composables/editor/useDraftProblems.ts +288 -0
- package/frontend-vue/app/build/composables/editor/useEditorContext.ts +388 -0
- package/frontend-vue/app/build/composables/editor/useEditorLoad.ts +158 -0
- package/frontend-vue/app/build/composables/editor/useForkToLocal.ts +193 -0
- package/frontend-vue/app/build/composables/editor/useGraphHistory.ts +113 -0
- package/frontend-vue/app/build/composables/editor/useGroupEditing.ts +445 -0
- package/frontend-vue/app/build/composables/editor/usePalette.ts +41 -0
- package/frontend-vue/app/build/composables/editor/useProcedureActions.ts +96 -0
- package/frontend-vue/app/build/composables/editor/useRunOverlay.ts +466 -0
- package/frontend-vue/app/build/composables/editor/useSaveAsTemplate.ts +172 -0
- package/frontend-vue/app/build/composables/editor/useSavedTriggers.ts +100 -0
- package/frontend-vue/app/build/composables/editor/useSubgraphNavigation.ts +270 -0
- package/frontend-vue/app/build/composables/editor/useUnsavedGuards.ts +233 -0
- package/frontend-vue/app/build/composables/graphCanvas/connect.ts +273 -0
- package/frontend-vue/app/build/composables/graphCanvas/edgeEvents.ts +172 -0
- package/frontend-vue/app/build/composables/graphCanvas/edges.ts +55 -0
- package/frontend-vue/app/build/composables/graphCanvas/handles.ts +181 -0
- package/frontend-vue/app/build/composables/graphCanvas/linkMenu.ts +123 -0
- package/frontend-vue/app/build/composables/graphCanvas/nodeData.ts +222 -0
- package/frontend-vue/app/build/composables/graphCanvas/placement.ts +248 -0
- package/frontend-vue/app/build/composables/graphCanvas/selection.ts +150 -0
- package/frontend-vue/app/build/composables/graphCanvas/types.ts +188 -0
- package/frontend-vue/app/build/composables/graphCanvas/view.ts +230 -0
- package/frontend-vue/app/build/types/editor.ts +94 -0
- package/frontend-vue/app/build/utils/editor/apiErrors.ts +74 -0
- package/frontend-vue/app/build/utils/editor/graphShape.ts +68 -0
- package/frontend-vue/app/build/utils/editor/groupPlan.ts +322 -0
- package/frontend-vue/app/build/utils/editor/groupPorts.ts +210 -0
- package/frontend-vue/app/build/utils/editor/keyboard.ts +22 -0
- package/frontend-vue/app/build/utils/inspectorFields.ts +117 -0
- package/frontend-vue/app/build/utils/templates.ts +88 -0
- package/frontend-vue/app/components/AttentionList.vue +2 -6
- package/frontend-vue/app/components/Catalog.vue +2 -1
- package/frontend-vue/app/components/Editor/GraphCanvas.vue +78 -1337
- package/frontend-vue/app/components/Editor/NodeInspector.vue +31 -123
- package/frontend-vue/app/components/Editor.vue +134 -3484
- package/frontend-vue/app/components/Templates.vue +14 -84
- package/frontend-vue/build/backend-boundary.ts +122 -0
- package/frontend-vue/dms.frontend.build.ts +2 -0
- package/frontend-vue/eslint-rules/index.mjs +103 -0
- package/frontend-vue/eslint.config.mjs +15 -0
- package/frontend-vue/package.json +7 -4
- package/frontend-vue/pnpm-lock.yaml +73 -59
- package/frontend-vue/tests/api-error-presentation.test.cjs +257 -0
- package/frontend-vue/tests/helpers/setup.cjs +44 -0
- package/package.json +4 -4
- package/skills/dms-automation/SKILL.md +2 -2
- package/skills/dms-automation/cases.json +58 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import type { Connection } from "@vue-flow/core";
|
|
2
|
+
import { computed, ref, type Ref } from "vue";
|
|
3
|
+
import { newId } from "../../../utils/automation";
|
|
4
|
+
import {
|
|
5
|
+
canConnect,
|
|
6
|
+
connectionKind,
|
|
7
|
+
parseDataField,
|
|
8
|
+
parseDataPort,
|
|
9
|
+
parseSourceBranch,
|
|
10
|
+
parseTargetBranch,
|
|
11
|
+
} from "../../../composables/useGraphConnect";
|
|
12
|
+
import type {
|
|
13
|
+
ConnectResult,
|
|
14
|
+
DataEdge,
|
|
15
|
+
GraphNode as AppGraphNode,
|
|
16
|
+
ProcedureGraph,
|
|
17
|
+
TriggerEdge,
|
|
18
|
+
} from "../../../composables/useGraphConnect";
|
|
19
|
+
import type {
|
|
20
|
+
CanvasProps,
|
|
21
|
+
CanvasText,
|
|
22
|
+
FlowController,
|
|
23
|
+
NodeHandles,
|
|
24
|
+
} from "./types";
|
|
25
|
+
|
|
26
|
+
/** Whether a connection may be drawn in a graph, and why not. */
|
|
27
|
+
export type ConnectionCheck = (
|
|
28
|
+
graph: ProcedureGraph,
|
|
29
|
+
conn: Connection,
|
|
30
|
+
) => ConnectResult;
|
|
31
|
+
|
|
32
|
+
export function connectionCheck(props: Readonly<CanvasProps>): ConnectionCheck {
|
|
33
|
+
return (graph, conn) =>
|
|
34
|
+
canConnect(
|
|
35
|
+
graph,
|
|
36
|
+
props.nodeKinds,
|
|
37
|
+
props.triggerTypes,
|
|
38
|
+
props.actionTypes,
|
|
39
|
+
props.dataNodeTypes,
|
|
40
|
+
conn,
|
|
41
|
+
{ parentGroupPorts: props.parentGroupPorts },
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// The link from `from`'s main output to `to`, when that output is free and
|
|
46
|
+
// `to` has an input that accepts it.
|
|
47
|
+
export function nextStepConnection(
|
|
48
|
+
graph: ProcedureGraph,
|
|
49
|
+
from: AppGraphNode,
|
|
50
|
+
to: AppGraphNode,
|
|
51
|
+
handlesOf: (node: AppGraphNode) => NodeHandles,
|
|
52
|
+
check: ConnectionCheck,
|
|
53
|
+
): Connection | null {
|
|
54
|
+
const out = handlesOf(from).triggerOuts.find((p) => p.name === "main");
|
|
55
|
+
const ins = handlesOf(to).triggerIns;
|
|
56
|
+
const into = ins.find((p) => p.name === "main" || p.name === "") ?? ins[0];
|
|
57
|
+
if (!out || !into) return null;
|
|
58
|
+
if (
|
|
59
|
+
graph.triggerEdges.some(
|
|
60
|
+
(e) => e.from.node === from.id && (e.from.branch ?? "main") === "main",
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
return null;
|
|
64
|
+
const conn: Connection = {
|
|
65
|
+
source: from.id,
|
|
66
|
+
sourceHandle: out.id,
|
|
67
|
+
target: to.id,
|
|
68
|
+
targetHandle: into.id,
|
|
69
|
+
};
|
|
70
|
+
return check(graph, conn).ok ? conn : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The graph once `conn` is drawn, and the link it took the place of.
|
|
74
|
+
export function withConnection(
|
|
75
|
+
graph: ProcedureGraph,
|
|
76
|
+
conn: Connection,
|
|
77
|
+
): {
|
|
78
|
+
graph: ProcedureGraph;
|
|
79
|
+
added: TriggerEdge | DataEdge;
|
|
80
|
+
replaced?: TriggerEdge | DataEdge;
|
|
81
|
+
} | null {
|
|
82
|
+
const kind = connectionKind(conn.sourceHandle);
|
|
83
|
+
if (kind === "trigger") {
|
|
84
|
+
const branch = parseSourceBranch(conn.sourceHandle);
|
|
85
|
+
const toBranch = parseTargetBranch(conn.targetHandle);
|
|
86
|
+
const newEdge: TriggerEdge = {
|
|
87
|
+
id: newId(),
|
|
88
|
+
from: { node: conn.source, branch },
|
|
89
|
+
to:
|
|
90
|
+
toBranch !== undefined
|
|
91
|
+
? { node: conn.target, branch: toBranch }
|
|
92
|
+
: { node: conn.target },
|
|
93
|
+
};
|
|
94
|
+
// Each source/branch carries exactly one outgoing trigger edge.
|
|
95
|
+
// Connecting again replaces any existing edge from that source/branch.
|
|
96
|
+
// (Branching across if/switch named branches still works because each
|
|
97
|
+
// branch has its own `from.branch` and only conflicts with itself.)
|
|
98
|
+
const replaced = graph.triggerEdges.find(
|
|
99
|
+
(e) =>
|
|
100
|
+
e.from.node === conn.source && (e.from.branch ?? "main") === branch,
|
|
101
|
+
);
|
|
102
|
+
return {
|
|
103
|
+
graph: {
|
|
104
|
+
...graph,
|
|
105
|
+
triggerEdges: [
|
|
106
|
+
...graph.triggerEdges.filter((e) => e !== replaced),
|
|
107
|
+
newEdge,
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
added: newEdge,
|
|
111
|
+
replaced,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (kind !== "data") return null;
|
|
115
|
+
const port = parseDataPort(conn.sourceHandle);
|
|
116
|
+
const field = parseDataField(conn.targetHandle);
|
|
117
|
+
if (!port || !field) return null;
|
|
118
|
+
const newEdge: DataEdge = {
|
|
119
|
+
id: newId(),
|
|
120
|
+
from: { node: conn.source, port },
|
|
121
|
+
to: { node: conn.target, field },
|
|
122
|
+
};
|
|
123
|
+
// Overwrite: a field reads from one output only.
|
|
124
|
+
const replaced = graph.dataEdges.find(
|
|
125
|
+
(e) => e.to.node === conn.target && e.to.field === field,
|
|
126
|
+
);
|
|
127
|
+
return {
|
|
128
|
+
graph: {
|
|
129
|
+
...graph,
|
|
130
|
+
dataEdges: [...graph.dataEdges.filter((e) => e !== replaced), newEdge],
|
|
131
|
+
},
|
|
132
|
+
added: newEdge,
|
|
133
|
+
replaced,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function useConnections({
|
|
138
|
+
props,
|
|
139
|
+
t,
|
|
140
|
+
toast,
|
|
141
|
+
emitGraph,
|
|
142
|
+
menuName,
|
|
143
|
+
check,
|
|
144
|
+
flowRef,
|
|
145
|
+
}: {
|
|
146
|
+
props: Readonly<CanvasProps>;
|
|
147
|
+
t: CanvasText["t"];
|
|
148
|
+
toast: ReturnType<typeof useToast>;
|
|
149
|
+
emitGraph: (graph: ProcedureGraph) => void;
|
|
150
|
+
menuName: (id: string) => string;
|
|
151
|
+
check: ConnectionCheck;
|
|
152
|
+
flowRef: Ref<FlowController | null>;
|
|
153
|
+
}) {
|
|
154
|
+
function refusalText(result: ConnectResult): string {
|
|
155
|
+
return result.ok
|
|
156
|
+
? ""
|
|
157
|
+
: t(
|
|
158
|
+
`dms_automation.editor.canvas.connect.${result.code}`,
|
|
159
|
+
result.params ?? {},
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Undo of a replacement: the new link goes, the old one comes back — unless
|
|
164
|
+
// the new link is gone already, or an end of the old one was deleted since.
|
|
165
|
+
function restoreLink(
|
|
166
|
+
added: TriggerEdge | DataEdge,
|
|
167
|
+
old: TriggerEdge | DataEdge,
|
|
168
|
+
) {
|
|
169
|
+
const graph = props.graph;
|
|
170
|
+
const ids = new Set(graph.nodes.map((n) => n.id));
|
|
171
|
+
const back = ids.has(old.from.node) && ids.has(old.to.node);
|
|
172
|
+
if ("port" in added.from) {
|
|
173
|
+
if (!graph.dataEdges.some((e) => e.id === added.id)) return;
|
|
174
|
+
const edges = graph.dataEdges.filter((e) => e.id !== added.id);
|
|
175
|
+
emitGraph({
|
|
176
|
+
...graph,
|
|
177
|
+
dataEdges: back ? [...edges, old as DataEdge] : edges,
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
if (!graph.triggerEdges.some((e) => e.id === added.id)) return;
|
|
181
|
+
const edges = graph.triggerEdges.filter((e) => e.id !== added.id);
|
|
182
|
+
emitGraph({
|
|
183
|
+
...graph,
|
|
184
|
+
triggerEdges: back ? [...edges, old as TriggerEdge] : edges,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Drawing over an existing link replaces it: say which one, with an undo of
|
|
190
|
+
// that replacement only.
|
|
191
|
+
function notifyReplaced(
|
|
192
|
+
added: TriggerEdge | DataEdge,
|
|
193
|
+
old: TriggerEdge | DataEdge,
|
|
194
|
+
conn: Connection,
|
|
195
|
+
) {
|
|
196
|
+
let description: string;
|
|
197
|
+
if ("port" in old.from) {
|
|
198
|
+
const port = parseDataPort(conn.sourceHandle);
|
|
199
|
+
if (old.from.node === conn.source && old.from.port === port) return;
|
|
200
|
+
description = t("dms_automation.editor.canvas.replaced.data", {
|
|
201
|
+
field: (old as DataEdge).to.field,
|
|
202
|
+
step: menuName(conn.target),
|
|
203
|
+
source: `${menuName(conn.source)} · ${port}`,
|
|
204
|
+
previous: `${menuName(old.from.node)} · ${old.from.port}`,
|
|
205
|
+
});
|
|
206
|
+
} else {
|
|
207
|
+
if (old.to.node === conn.target) return;
|
|
208
|
+
description = t("dms_automation.editor.canvas.replaced.trigger", {
|
|
209
|
+
source: menuName(conn.source),
|
|
210
|
+
target: menuName(conn.target),
|
|
211
|
+
previous: menuName(old.to.node),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
toast.add({
|
|
215
|
+
title: t("dms_automation.editor.canvas.replaced.title"),
|
|
216
|
+
description,
|
|
217
|
+
color: "info",
|
|
218
|
+
icon: "i-ph-arrows-left-right",
|
|
219
|
+
actions: [
|
|
220
|
+
{
|
|
221
|
+
label: t("dms_automation.editor.canvas.undo"),
|
|
222
|
+
onClick: () => restoreLink(added, old),
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function onConnect(conn: Connection) {
|
|
229
|
+
if (props.readOnly) return;
|
|
230
|
+
const result = check(props.graph, conn);
|
|
231
|
+
if (!result.ok) {
|
|
232
|
+
toast.add({
|
|
233
|
+
title: t("dms_automation.editor.canvas.connect.title"),
|
|
234
|
+
description: refusalText(result),
|
|
235
|
+
color: "warning",
|
|
236
|
+
icon: "i-ph-warning",
|
|
237
|
+
});
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const next = withConnection(props.graph, conn);
|
|
241
|
+
if (!next) return;
|
|
242
|
+
emitGraph(next.graph);
|
|
243
|
+
if (next.replaced) notifyReplaced(next.added, next.replaced, conn);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Why the port under a link being drawn refuses it, shown while it hovers.
|
|
247
|
+
const refusal = ref("");
|
|
248
|
+
|
|
249
|
+
const refusalShown = computed(
|
|
250
|
+
() => flowRef.value?.connectionStatus === "invalid" && refusal.value !== "",
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
function isValidConnection(conn: Connection): boolean {
|
|
254
|
+
const result = check(props.graph, conn);
|
|
255
|
+
refusal.value = refusalText(result);
|
|
256
|
+
return result.ok;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Released over a port that refuses the link: keep the reason on screen.
|
|
260
|
+
function onConnectEnd() {
|
|
261
|
+
if (refusalShown.value) {
|
|
262
|
+
toast.add({
|
|
263
|
+
title: t("dms_automation.editor.canvas.connect.title"),
|
|
264
|
+
description: refusal.value,
|
|
265
|
+
color: "warning",
|
|
266
|
+
icon: "i-ph-warning",
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
refusal.value = "";
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return { onConnect, refusal, refusalShown, isValidConnection, onConnectEnd };
|
|
273
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { Connection, EdgeChange, Edge as VfEdge } from "@vue-flow/core";
|
|
2
|
+
import type { Ref } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
parseDataField,
|
|
5
|
+
parseDataPort,
|
|
6
|
+
parseSourceBranch,
|
|
7
|
+
parseTargetBranch,
|
|
8
|
+
} from "../../../composables/useGraphConnect";
|
|
9
|
+
import type { ProcedureGraph } from "../../../composables/useGraphConnect";
|
|
10
|
+
import type { CanvasEmits, CanvasProps, FlowController } from "./types";
|
|
11
|
+
|
|
12
|
+
export function useEdgeEvents({
|
|
13
|
+
props,
|
|
14
|
+
emit,
|
|
15
|
+
flowRef,
|
|
16
|
+
emitGraph,
|
|
17
|
+
}: {
|
|
18
|
+
props: Readonly<CanvasProps>;
|
|
19
|
+
emit: CanvasEmits;
|
|
20
|
+
flowRef: Ref<FlowController | null>;
|
|
21
|
+
emitGraph: (graph: ProcedureGraph) => void;
|
|
22
|
+
}) {
|
|
23
|
+
function onEdgesChange(changes: EdgeChange[]) {
|
|
24
|
+
if (props.readOnly) return;
|
|
25
|
+
let nextTrigger = props.graph.triggerEdges;
|
|
26
|
+
let nextData = props.graph.dataEdges;
|
|
27
|
+
let changed = false;
|
|
28
|
+
|
|
29
|
+
for (const c of changes) {
|
|
30
|
+
if (c.type === "remove") {
|
|
31
|
+
const beforeT = nextTrigger.length;
|
|
32
|
+
nextTrigger = nextTrigger.filter((e) => e.id !== c.id);
|
|
33
|
+
if (nextTrigger.length !== beforeT) {
|
|
34
|
+
changed = true;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const beforeD = nextData.length;
|
|
38
|
+
nextData = nextData.filter((e) => e.id !== c.id);
|
|
39
|
+
if (nextData.length !== beforeD) changed = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (changed) {
|
|
44
|
+
emitGraph({
|
|
45
|
+
...props.graph,
|
|
46
|
+
triggerEdges: nextTrigger,
|
|
47
|
+
dataEdges: nextData,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The DMS canvas deletes the selected nodes on Delete / Backspace, not the
|
|
53
|
+
// selected links: remove those here (a deleted node takes its links along).
|
|
54
|
+
function onKeydown(event: KeyboardEvent) {
|
|
55
|
+
if (props.readOnly || (event.key !== "Delete" && event.key !== "Backspace"))
|
|
56
|
+
return;
|
|
57
|
+
const target = event.target;
|
|
58
|
+
if (
|
|
59
|
+
target instanceof HTMLElement &&
|
|
60
|
+
(target.isContentEditable ||
|
|
61
|
+
["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName))
|
|
62
|
+
)
|
|
63
|
+
return;
|
|
64
|
+
const flow = flowRef.value;
|
|
65
|
+
if (
|
|
66
|
+
!flow ||
|
|
67
|
+
flow.getSelectedNodes.length > 0 ||
|
|
68
|
+
flow.getSelectedEdges.length === 0
|
|
69
|
+
)
|
|
70
|
+
return;
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
onEdgesChange(
|
|
73
|
+
flow.getSelectedEdges.map(
|
|
74
|
+
(e) => ({ type: "remove", id: e.id }) as EdgeChange,
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Edge-update flow (drag an existing edge's endpoint to reattach or delete):
|
|
80
|
+
// 1. @edge-update-start clears the success flag.
|
|
81
|
+
// 2. @edge-update fires only if the user drops on a valid target — mark
|
|
82
|
+
// successful and rewrite the edge with the new connection.
|
|
83
|
+
// 3. @edge-update-end fires unconditionally; if no successful update
|
|
84
|
+
// happened, the user dropped in empty space → delete the edge.
|
|
85
|
+
let edgeUpdateSuccessful = false;
|
|
86
|
+
function onEdgeUpdateStart() {
|
|
87
|
+
edgeUpdateSuccessful = false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function onEdgeUpdate(payload: {
|
|
91
|
+
event: MouseEvent;
|
|
92
|
+
edge: VfEdge;
|
|
93
|
+
connection: Connection;
|
|
94
|
+
}) {
|
|
95
|
+
edgeUpdateSuccessful = true;
|
|
96
|
+
const { edge, connection } = payload;
|
|
97
|
+
const kind = (edge.data as { kind?: "trigger" | "data" } | undefined)?.kind;
|
|
98
|
+
if (kind === "trigger") {
|
|
99
|
+
const branch = parseSourceBranch(connection.sourceHandle);
|
|
100
|
+
const toBranch = parseTargetBranch(connection.targetHandle);
|
|
101
|
+
const nextTrigger = props.graph.triggerEdges.map((e) =>
|
|
102
|
+
e.id === edge.id
|
|
103
|
+
? {
|
|
104
|
+
...e,
|
|
105
|
+
from: { node: connection.source, branch },
|
|
106
|
+
to:
|
|
107
|
+
toBranch !== undefined
|
|
108
|
+
? { node: connection.target, branch: toBranch }
|
|
109
|
+
: { node: connection.target },
|
|
110
|
+
}
|
|
111
|
+
: e,
|
|
112
|
+
);
|
|
113
|
+
emitGraph({ ...props.graph, triggerEdges: nextTrigger });
|
|
114
|
+
} else if (kind === "data") {
|
|
115
|
+
const port = parseDataPort(connection.sourceHandle);
|
|
116
|
+
const field = parseDataField(connection.targetHandle);
|
|
117
|
+
if (!port || !field) return;
|
|
118
|
+
const nextData = props.graph.dataEdges.map((e) =>
|
|
119
|
+
e.id === edge.id
|
|
120
|
+
? {
|
|
121
|
+
...e,
|
|
122
|
+
from: { node: connection.source, port },
|
|
123
|
+
to: { node: connection.target, field },
|
|
124
|
+
}
|
|
125
|
+
: e,
|
|
126
|
+
);
|
|
127
|
+
emitGraph({ ...props.graph, dataEdges: nextData });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Vue Flow fires @node-double-click with a single `{ event, node }` payload.
|
|
132
|
+
// Filter to group nodes so Editor.vue receives a clean group:enter signal —
|
|
133
|
+
// double-clicking any other node kind is reserved for future inline edit
|
|
134
|
+
// affordances.
|
|
135
|
+
function onNodeDoubleClick(payload: {
|
|
136
|
+
event: MouseEvent;
|
|
137
|
+
node: { id: string; type?: string };
|
|
138
|
+
}) {
|
|
139
|
+
if (payload.node?.type !== "group") return;
|
|
140
|
+
emit("group:enter", { id: payload.node.id });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
|
|
144
|
+
if (edgeUpdateSuccessful) return;
|
|
145
|
+
const { edge } = payload;
|
|
146
|
+
if (!edge) return;
|
|
147
|
+
const nextTrigger = props.graph.triggerEdges.filter(
|
|
148
|
+
(e) => e.id !== edge.id,
|
|
149
|
+
);
|
|
150
|
+
const nextData = props.graph.dataEdges.filter((e) => e.id !== edge.id);
|
|
151
|
+
if (
|
|
152
|
+
nextTrigger.length === props.graph.triggerEdges.length &&
|
|
153
|
+
nextData.length === props.graph.dataEdges.length
|
|
154
|
+
) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
emitGraph({
|
|
158
|
+
...props.graph,
|
|
159
|
+
triggerEdges: nextTrigger,
|
|
160
|
+
dataEdges: nextData,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
onEdgesChange,
|
|
166
|
+
onKeydown,
|
|
167
|
+
onEdgeUpdateStart,
|
|
168
|
+
onEdgeUpdate,
|
|
169
|
+
onNodeDoubleClick,
|
|
170
|
+
onEdgeUpdateEnd,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import type { NodeKind } from "../../../composables/useGraphConnect";
|
|
3
|
+
import {
|
|
4
|
+
dataSourceHandle,
|
|
5
|
+
dataTargetHandle,
|
|
6
|
+
edgeClass,
|
|
7
|
+
triggerSourceHandle,
|
|
8
|
+
triggerTargetHandle,
|
|
9
|
+
} from "./handles";
|
|
10
|
+
import type { CanvasProps } from "./types";
|
|
11
|
+
|
|
12
|
+
export function useCanvasEdges(
|
|
13
|
+
props: Readonly<CanvasProps>,
|
|
14
|
+
menuName: (id: string) => string,
|
|
15
|
+
) {
|
|
16
|
+
// Look up the kind of an edge endpoint by node id — needed for the group
|
|
17
|
+
// handle-id derivation below. Sentinels and groups have richer handle
|
|
18
|
+
// naming than regular nodes (`group-trigger-in-<port>` vs `trigger-in`),
|
|
19
|
+
// so the edge mapping needs to know which target/source it's wiring to.
|
|
20
|
+
const nodeKindById = computed<Map<string, NodeKind>>(() => {
|
|
21
|
+
const m = new Map<string, NodeKind>();
|
|
22
|
+
for (const n of props.graph.nodes) m.set(n.id, n.kind);
|
|
23
|
+
return m;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Edge styling lives in <style> (.edge-trigger / .edge-data) so the
|
|
27
|
+
// `.selected` highlight can win without `!important`. Inline `style`
|
|
28
|
+
// on a vue-flow edge defeats the .selected rule — documented gotcha.
|
|
29
|
+
const vfEdges = computed(() => {
|
|
30
|
+
const kinds = nodeKindById.value;
|
|
31
|
+
const triggerEdges = props.graph.triggerEdges.map((e) => ({
|
|
32
|
+
id: e.id,
|
|
33
|
+
source: e.from.node,
|
|
34
|
+
target: e.to.node,
|
|
35
|
+
sourceHandle: triggerSourceHandle(e, kinds.get(e.from.node)),
|
|
36
|
+
targetHandle: triggerTargetHandle(e, kinds.get(e.to.node)),
|
|
37
|
+
data: { kind: "trigger" as const },
|
|
38
|
+
ariaLabel: `${menuName(e.from.node)} → ${menuName(e.to.node)}`,
|
|
39
|
+
class: edgeClass(props.runStates, e.from.node, e.to.node),
|
|
40
|
+
}));
|
|
41
|
+
const dataEdges = props.graph.dataEdges.map((e) => ({
|
|
42
|
+
id: e.id,
|
|
43
|
+
source: e.from.node,
|
|
44
|
+
target: e.to.node,
|
|
45
|
+
sourceHandle: dataSourceHandle(e, kinds.get(e.from.node)),
|
|
46
|
+
targetHandle: dataTargetHandle(e, kinds.get(e.to.node)),
|
|
47
|
+
data: { kind: "data" as const },
|
|
48
|
+
ariaLabel: `${menuName(e.from.node)} · ${e.from.port} → ${menuName(e.to.node)} · ${e.to.field}`,
|
|
49
|
+
class: "edge-data",
|
|
50
|
+
}));
|
|
51
|
+
return [...triggerEdges, ...dataEdges];
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return vfEdges;
|
|
55
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GraphNode as AppGraphNode,
|
|
3
|
+
GroupPort,
|
|
4
|
+
JsonSchema,
|
|
5
|
+
NodeKind,
|
|
6
|
+
DataEdge,
|
|
7
|
+
TriggerEdge,
|
|
8
|
+
} from "../../../composables/useGraphConnect";
|
|
9
|
+
import type { CanvasProps, NodeHandles } from "./types";
|
|
10
|
+
import { SENTINEL_KINDS } from "./types";
|
|
11
|
+
|
|
12
|
+
export function vfTypeFor(kind: NodeKind): string {
|
|
13
|
+
if (kind === "group") return "group";
|
|
14
|
+
if (kind === "groupInput") return "groupInput";
|
|
15
|
+
if (kind === "groupOutput") return "groupOutput";
|
|
16
|
+
return "genericNode";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function propsOf(schema: JsonSchema | undefined) {
|
|
20
|
+
if (!schema?.properties) return [];
|
|
21
|
+
return Object.entries(schema.properties).map(([name, p]) => ({
|
|
22
|
+
name,
|
|
23
|
+
type: Array.isArray(p?.type) ? p?.type[0] : p?.type,
|
|
24
|
+
title: p?.title,
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// What a screen reader announces for a node: its type when the node has a
|
|
29
|
+
// name of its own, its name, and what it does.
|
|
30
|
+
export function ariaLabelOf(data: {
|
|
31
|
+
label?: string;
|
|
32
|
+
typeName?: string;
|
|
33
|
+
summary?: string;
|
|
34
|
+
}) {
|
|
35
|
+
if (!data.label) return undefined;
|
|
36
|
+
const type =
|
|
37
|
+
data.typeName && data.typeName !== data.label ? `${data.typeName}: ` : "";
|
|
38
|
+
return `${type}${data.label}${data.summary ? `, ${data.summary}` : ""}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Trigger edges into a group node or groupOutput sentinel target a specific
|
|
42
|
+
// trigger-in port — the port name lives on `e.to.branch`. Ordinary target
|
|
43
|
+
// nodes have a single fixed `trigger-in` handle.
|
|
44
|
+
export function triggerTargetHandle(
|
|
45
|
+
e: TriggerEdge,
|
|
46
|
+
targetKind: NodeKind | undefined,
|
|
47
|
+
): string {
|
|
48
|
+
if (targetKind === "group") {
|
|
49
|
+
return `group-trigger-in-${e.to.branch}`;
|
|
50
|
+
}
|
|
51
|
+
if (targetKind === "groupOutput") {
|
|
52
|
+
// Trigger edge from an inner node into the groupOutput sentinel —
|
|
53
|
+
// the sentinel exposes a `groupOutput-trigger-in-<port>` handle per
|
|
54
|
+
// declared trigger-OUT port (since trigger-OUT on the OUTER group is
|
|
55
|
+
// trigger-IN on the sentinel side).
|
|
56
|
+
return `groupOutput-trigger-in-${e.to.branch}`;
|
|
57
|
+
}
|
|
58
|
+
return "trigger-in";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function triggerSourceHandle(
|
|
62
|
+
e: TriggerEdge,
|
|
63
|
+
sourceKind: NodeKind | undefined,
|
|
64
|
+
): string {
|
|
65
|
+
if (sourceKind === "group") {
|
|
66
|
+
// Source is the OUTER group node firing into an outer downstream
|
|
67
|
+
// node — the branch name IS the port name (see planNewGroup's
|
|
68
|
+
// outerTriggerEdges where `from.branch = portName`).
|
|
69
|
+
return `group-trigger-out-${e.from.branch ?? "main"}`;
|
|
70
|
+
}
|
|
71
|
+
if (sourceKind === "groupInput") {
|
|
72
|
+
// Inner edge out of groupInput into an inner node — handle id is
|
|
73
|
+
// `groupInput-trigger-out-<port>` and the port name lives on
|
|
74
|
+
// `from.branch` (per planNewGroup's innerTriggerEdges).
|
|
75
|
+
return `groupInput-trigger-out-${e.from.branch ?? "main"}`;
|
|
76
|
+
}
|
|
77
|
+
return `trigger-out-${e.from.branch ?? "main"}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function dataSourceHandle(
|
|
81
|
+
e: DataEdge,
|
|
82
|
+
sourceKind: NodeKind | undefined,
|
|
83
|
+
): string {
|
|
84
|
+
if (sourceKind === "group") return `group-data-out-${e.from.port}`;
|
|
85
|
+
if (sourceKind === "groupInput") return `groupInput-data-out-${e.from.port}`;
|
|
86
|
+
return `data-out-${e.from.port}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function dataTargetHandle(
|
|
90
|
+
e: DataEdge,
|
|
91
|
+
targetKind: NodeKind | undefined,
|
|
92
|
+
): string {
|
|
93
|
+
if (targetKind === "group") return `group-data-in-${e.to.field}`;
|
|
94
|
+
if (targetKind === "groupOutput") return `groupOutput-data-in-${e.to.field}`;
|
|
95
|
+
return `data-in-${e.to.field}`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// After a run, the edges it took are drawn solid and the one into the failing
|
|
99
|
+
// step red; the others fade.
|
|
100
|
+
export function edgeClass(
|
|
101
|
+
runs: CanvasProps["runStates"],
|
|
102
|
+
from: string,
|
|
103
|
+
to: string,
|
|
104
|
+
): string {
|
|
105
|
+
if (!runs) return "edge-trigger";
|
|
106
|
+
const target = runs[to]?.status;
|
|
107
|
+
const taken = runs[from] && target && target !== "skipped";
|
|
108
|
+
if (taken && target === "failed") return "edge-trigger edge-failed";
|
|
109
|
+
return taken ? "edge-trigger edge-taken" : "edge-trigger edge-idle";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// The handles a node draws, named as its renderer names them (see the
|
|
113
|
+
// handle prefix table in useGraphConnect).
|
|
114
|
+
export function handlesOf(
|
|
115
|
+
node: AppGraphNode,
|
|
116
|
+
parentGroupPorts: GroupPort[] | undefined,
|
|
117
|
+
dataFor: (node: AppGraphNode) => object,
|
|
118
|
+
): NodeHandles {
|
|
119
|
+
if (node.kind === "group" || SENTINEL_KINDS.has(node.kind)) {
|
|
120
|
+
const ports =
|
|
121
|
+
node.kind === "group"
|
|
122
|
+
? ((node as AppGraphNode & { ports?: GroupPort[] }).ports ?? [])
|
|
123
|
+
: (parentGroupPorts ?? []);
|
|
124
|
+
const pick = (
|
|
125
|
+
kind: GroupPort["kind"],
|
|
126
|
+
direction: GroupPort["direction"],
|
|
127
|
+
prefix: string,
|
|
128
|
+
) =>
|
|
129
|
+
ports
|
|
130
|
+
.filter((p) => p.kind === kind && p.direction === direction)
|
|
131
|
+
.map((p) => ({ id: `${prefix}${p.name}`, name: p.name }));
|
|
132
|
+
if (node.kind === "group") {
|
|
133
|
+
return {
|
|
134
|
+
triggerIns: pick("trigger", "in", "group-trigger-in-"),
|
|
135
|
+
triggerOuts: pick("trigger", "out", "group-trigger-out-"),
|
|
136
|
+
dataIns: pick("data", "in", "group-data-in-"),
|
|
137
|
+
dataOuts: pick("data", "out", "group-data-out-"),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// The sentinels face inwards: the group's inputs leave groupInput, its
|
|
141
|
+
// outputs enter groupOutput.
|
|
142
|
+
if (node.kind === "groupInput") {
|
|
143
|
+
return {
|
|
144
|
+
triggerIns: [],
|
|
145
|
+
triggerOuts: pick("trigger", "in", "groupInput-trigger-out-"),
|
|
146
|
+
dataIns: [],
|
|
147
|
+
dataOuts: pick("data", "in", "groupInput-data-out-"),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
triggerIns: pick("trigger", "out", "groupOutput-trigger-in-"),
|
|
152
|
+
triggerOuts: [],
|
|
153
|
+
dataIns: pick("data", "out", "groupOutput-data-in-"),
|
|
154
|
+
dataOuts: [],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const data = dataFor(node) as {
|
|
158
|
+
hasTriggerIn?: boolean;
|
|
159
|
+
hasMainTriggerOut?: boolean;
|
|
160
|
+
triggerOuts?: string[];
|
|
161
|
+
dataIns?: Array<{ name: string }>;
|
|
162
|
+
dataOuts?: Array<{ name: string }>;
|
|
163
|
+
};
|
|
164
|
+
const branches = [
|
|
165
|
+
...(data.hasMainTriggerOut === false ? [] : ["main"]),
|
|
166
|
+
...(data.triggerOuts ?? []),
|
|
167
|
+
];
|
|
168
|
+
return {
|
|
169
|
+
triggerIns:
|
|
170
|
+
data.hasTriggerIn === false ? [] : [{ id: "trigger-in", name: "" }],
|
|
171
|
+
triggerOuts: branches.map((name) => ({ id: `trigger-out-${name}`, name })),
|
|
172
|
+
dataIns: (data.dataIns ?? []).map((p) => ({
|
|
173
|
+
id: `data-in-${p.name}`,
|
|
174
|
+
name: p.name,
|
|
175
|
+
})),
|
|
176
|
+
dataOuts: (data.dataOuts ?? []).map((p) => ({
|
|
177
|
+
id: `data-out-${p.name}`,
|
|
178
|
+
name: p.name,
|
|
179
|
+
})),
|
|
180
|
+
};
|
|
181
|
+
}
|