@antelopejs/dms-automation 0.7.0 → 0.9.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 +33 -22
- 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 +5 -20
- package/dist/data/procedures-table.js +10 -106
- package/dist/data/procedures-table.js.map +1 -1
- package/dist/data/runs-table.d.ts +3 -3
- package/dist/data/runs-table.js.map +1 -1
- package/dist/db/models/automation_template.model.d.ts +13 -13
- 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.model.d.ts +7 -5
- package/dist/db/models/procedure_run.model.d.ts +9 -6
- package/dist/db/models/procedure_run.model.js +8 -8
- package/dist/db/models/procedure_run.model.js.map +1 -1
- package/dist/db/models/stats.model.js.map +1 -1
- package/dist/db/models/type_switch.model.d.ts +7 -5
- 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.d.ts +2 -2
- 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 +3 -2
- package/dist/routes/action-types.js.map +1 -1
- package/dist/routes/data-node-types.d.ts +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 +13 -10
- package/dist/routes/graphSchema.js.map +1 -1
- package/dist/routes/library.d.ts +12 -1
- package/dist/routes/library.js +38 -34
- package/dist/routes/library.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 +3 -3
- package/dist/routes/procedureRuns.js +1 -1
- package/dist/routes/procedureRuns.js.map +1 -1
- package/dist/routes/procedureSchemas.d.ts +7 -6
- package/dist/routes/procedureSchemas.js +4 -2
- package/dist/routes/procedureSchemas.js.map +1 -1
- package/dist/routes/procedures.d.ts +15 -14
- package/dist/routes/procedures.js +2 -1
- package/dist/routes/procedures.js.map +1 -1
- package/dist/routes/requests.d.ts +12 -6
- package/dist/routes/requests.js +2 -1
- package/dist/routes/requests.js.map +1 -1
- package/dist/routes/runs.d.ts +9 -8
- 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 +5 -4
- package/dist/routes/templates.js +2 -1
- package/dist/routes/templates.js.map +1 -1
- package/dist/routes/trigger-types.d.ts +3 -2
- 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/routes/zodJson.d.ts +3 -0
- package/dist/routes/zodJson.js +21 -0
- package/dist/routes/zodJson.js.map +1 -0
- package/dist/runtime/armErrors.d.ts +0 -1
- package/dist/runtime/armErrors.js +5 -12
- package/dist/runtime/armErrors.js.map +1 -1
- package/dist/runtime/boundRunLog.d.ts +7 -5
- package/dist/runtime/boundRunLog.js +24 -20
- package/dist/runtime/boundRunLog.js.map +1 -1
- package/dist/runtime/builtins/actions/http.d.ts +7 -3
- package/dist/runtime/builtins/actions/http.js +33 -22
- package/dist/runtime/builtins/actions/http.js.map +1 -1
- package/dist/runtime/builtins/actions/log.d.ts +5 -4
- package/dist/runtime/builtins/actions/log.js.map +1 -1
- package/dist/runtime/builtins/data/boolean.d.ts +2 -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 +27 -27
- 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 +16 -5
- 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 +13 -5
- 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 +8 -3
- 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 +4 -3
- 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 +11 -7
- package/dist/runtime/builtins/triggers/webhook.js +15 -12
- 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.d.ts +3 -1
- package/dist/runtime/describe.js +14 -13
- package/dist/runtime/describe.js.map +1 -1
- package/dist/runtime/executor.d.ts +2 -1
- package/dist/runtime/executor.js +18 -13
- 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.d.ts +2 -2
- package/dist/runtime/graphIssues.js +39 -32
- package/dist/runtime/graphIssues.js.map +1 -1
- package/dist/runtime/graphVersion.d.ts +1 -1
- package/dist/runtime/graphVersion.js +4 -3
- package/dist/runtime/graphVersion.js.map +1 -1
- package/dist/runtime/nodeKinds.d.ts +6 -5
- 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/registry.d.ts +3 -3
- package/dist/runtime/resolveInputs.d.ts +13 -8
- package/dist/runtime/resolveInputs.js +18 -18
- 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 +3 -2
- 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 +3 -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/sideEffects.d.ts +2 -2
- package/dist/runtime/subscriptions.d.ts +6 -4
- 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.d.ts +5 -2
- package/dist/runtime/trace.js +27 -17
- package/dist/runtime/trace.js.map +1 -1
- package/dist/runtime/triggerHandles.d.ts +4 -3
- package/dist/runtime/triggerHandles.js +9 -1
- 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 +7 -0
- package/dist/types/dataValue.js +56 -0
- package/dist/types/dataValue.js.map +1 -0
- package/dist/types/graph.d.ts +19 -13
- 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/dist/types/runLog.d.ts +8 -7
- package/dist/types/runLog.js.map +1 -1
- 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 +8 -5
- package/frontend-vue/pnpm-lock.yaml +168 -139
- package/frontend-vue/tests/api-error-presentation.test.cjs +254 -0
- package/frontend-vue/tests/helpers/setup.cjs +44 -0
- package/package.json +18 -15
- package/skills/dms-automation/SKILL.md +2 -2
- package/skills/dms-automation/cases.json +58 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { NodeChange } from "@vue-flow/core";
|
|
2
|
+
import { watch, type Ref } from "vue";
|
|
3
|
+
import type { ProcedureGraph } from "../../../composables/useGraphConnect";
|
|
4
|
+
import { SENTINEL_KINDS } from "./types";
|
|
5
|
+
import type { CanvasEmits, CanvasProps } from "./types";
|
|
6
|
+
|
|
7
|
+
export function useCanvasSelection({
|
|
8
|
+
props,
|
|
9
|
+
emit,
|
|
10
|
+
canvasSelection,
|
|
11
|
+
emitGraph,
|
|
12
|
+
}: {
|
|
13
|
+
props: Readonly<CanvasProps>;
|
|
14
|
+
emit: CanvasEmits;
|
|
15
|
+
canvasSelection: Ref<string[]>;
|
|
16
|
+
emitGraph: (graph: ProcedureGraph) => void;
|
|
17
|
+
}) {
|
|
18
|
+
// Multi-selection tracking — Vue Flow emits one NodeSelectionChange per
|
|
19
|
+
// affected node when the user box-selects or shift-clicks. We accumulate
|
|
20
|
+
// the current set here and emit a single `selection-change` event with
|
|
21
|
+
// the full list (sentinels filtered out — the user shouldn't be able to
|
|
22
|
+
// fold a sentinel into a new group). The single-node `select:node` event
|
|
23
|
+
// is preserved for the inspector (it expects exactly one node id).
|
|
24
|
+
const selectedNodeIds = new Set<string>();
|
|
25
|
+
|
|
26
|
+
// Drop any tracked ids that no longer exist in the current graph (e.g.
|
|
27
|
+
// after navigating to a different procedure / subgraph, or after the
|
|
28
|
+
// "Group selection" action removes the selected nodes). Re-emit if the
|
|
29
|
+
// set shrank. We can't `watch(() => props.graph, ...)` because that
|
|
30
|
+
// fires on every node drag (each emitGraph returns a fresh object).
|
|
31
|
+
watch(
|
|
32
|
+
() => props.graph.nodes,
|
|
33
|
+
(nodes) => {
|
|
34
|
+
if (selectedNodeIds.size === 0) return;
|
|
35
|
+
const valid = new Set(nodes.map((n) => n.id));
|
|
36
|
+
let pruned = false;
|
|
37
|
+
for (const id of [...selectedNodeIds]) {
|
|
38
|
+
if (!valid.has(id)) {
|
|
39
|
+
selectedNodeIds.delete(id);
|
|
40
|
+
pruned = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (pruned) {
|
|
44
|
+
const ids = [...selectedNodeIds].filter((id) => {
|
|
45
|
+
const n = nodes.find((nn) => nn.id === id);
|
|
46
|
+
return n ? !SENTINEL_KINDS.has(n.kind) : false;
|
|
47
|
+
});
|
|
48
|
+
canvasSelection.value = [...selectedNodeIds];
|
|
49
|
+
emit("selection-change", { ids });
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
function onNodesChange(changes: NodeChange[]) {
|
|
55
|
+
let nextNodes = props.graph.nodes;
|
|
56
|
+
let nextTrigger = props.graph.triggerEdges;
|
|
57
|
+
let nextData = props.graph.dataEdges;
|
|
58
|
+
let changed = false;
|
|
59
|
+
let selectionChanged = false;
|
|
60
|
+
|
|
61
|
+
for (const c of changes) {
|
|
62
|
+
// In read-only mode, still surface selection so the inspector
|
|
63
|
+
// can show node details; suppress position drag and delete.
|
|
64
|
+
if (props.readOnly && c.type !== "select") continue;
|
|
65
|
+
if (c.type === "position" && c.position) {
|
|
66
|
+
// Positions are stored as whole pixels, and a click that moves a
|
|
67
|
+
// node by less than one (a select, not a drag) changes nothing:
|
|
68
|
+
// otherwise selecting a node would count as an unsaved change.
|
|
69
|
+
const pos = {
|
|
70
|
+
x: Math.round(c.position.x),
|
|
71
|
+
y: Math.round(c.position.y),
|
|
72
|
+
};
|
|
73
|
+
const current = nextNodes.find((n) => n.id === c.id);
|
|
74
|
+
if (
|
|
75
|
+
current &&
|
|
76
|
+
current.position.x === pos.x &&
|
|
77
|
+
current.position.y === pos.y
|
|
78
|
+
)
|
|
79
|
+
continue;
|
|
80
|
+
nextNodes = nextNodes.map((n) =>
|
|
81
|
+
n.id === c.id ? { ...n, position: pos } : n,
|
|
82
|
+
);
|
|
83
|
+
changed = true;
|
|
84
|
+
} else if (c.type === "remove") {
|
|
85
|
+
// Sentinel nodes (groupInput / groupOutput) are auto-managed by
|
|
86
|
+
// the editor and never user-deletable. Drop the change silently
|
|
87
|
+
// so keyboard delete + right-click delete both no-op on them.
|
|
88
|
+
const victim = nextNodes.find((n) => n.id === c.id);
|
|
89
|
+
if (victim && SENTINEL_KINDS.has(victim.kind)) continue;
|
|
90
|
+
nextNodes = nextNodes.filter((n) => n.id !== c.id);
|
|
91
|
+
nextTrigger = nextTrigger.filter(
|
|
92
|
+
(e) => e.from.node !== c.id && e.to.node !== c.id,
|
|
93
|
+
);
|
|
94
|
+
nextData = nextData.filter(
|
|
95
|
+
(e) => e.from.node !== c.id && e.to.node !== c.id,
|
|
96
|
+
);
|
|
97
|
+
if (selectedNodeIds.delete(c.id)) selectionChanged = true;
|
|
98
|
+
changed = true;
|
|
99
|
+
} else if (c.type === "select") {
|
|
100
|
+
if (c.selected) {
|
|
101
|
+
if (!selectedNodeIds.has(c.id)) {
|
|
102
|
+
selectedNodeIds.add(c.id);
|
|
103
|
+
selectionChanged = true;
|
|
104
|
+
}
|
|
105
|
+
emit("select:node", c.id);
|
|
106
|
+
} else {
|
|
107
|
+
if (selectedNodeIds.delete(c.id)) selectionChanged = true;
|
|
108
|
+
// Re-point the single-node inspector on deselect: fall back to a
|
|
109
|
+
// still-selected node (most-recent), or clear it once the
|
|
110
|
+
// selection is empty. A click-swap fires `select: true` above in
|
|
111
|
+
// the same batch, which then overrides this.
|
|
112
|
+
const remaining = [...selectedNodeIds];
|
|
113
|
+
emit("select:node", remaining[remaining.length - 1] ?? null);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (selectionChanged) {
|
|
119
|
+
// Filter out sentinels — folding them into a new group makes no
|
|
120
|
+
// sense and the toolbar gating depends on a clean set.
|
|
121
|
+
const ids = [...selectedNodeIds].filter((id) => {
|
|
122
|
+
const n = props.graph.nodes.find((nn) => nn.id === id);
|
|
123
|
+
return n ? !SENTINEL_KINDS.has(n.kind) : false;
|
|
124
|
+
});
|
|
125
|
+
canvasSelection.value = [...selectedNodeIds];
|
|
126
|
+
emit("selection-change", { ids });
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (changed) {
|
|
130
|
+
emitGraph({
|
|
131
|
+
...props.graph,
|
|
132
|
+
nodes: nextNodes,
|
|
133
|
+
triggerEdges: nextTrigger,
|
|
134
|
+
dataEdges: nextData,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// DmsFlowCanvas's delete affordance (trash badge on the selected node + the
|
|
140
|
+
// Delete/Backspace key path it now owns) is emit-only: it hands us the ids and
|
|
141
|
+
// we perform the mutation. Route them through onNodesChange's `remove` path so
|
|
142
|
+
// sentinel filtering, edge cleanup, selection sync and emitGraph stay in one
|
|
143
|
+
// place.
|
|
144
|
+
function onDeleteNodes(ids: string[]) {
|
|
145
|
+
if (props.readOnly) return;
|
|
146
|
+
onNodesChange(ids.map((id) => ({ type: "remove", id }) as NodeChange));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return { onNodesChange, onDeleteNodes };
|
|
150
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { Connection } from "@vue-flow/core";
|
|
2
|
+
import type { NodeRunState } from "../../../components/Editor/nodes/GenericNode.vue";
|
|
3
|
+
import type { NodeKindEntry } from "../../../composables/useAutomationNodeKinds";
|
|
4
|
+
import type {
|
|
5
|
+
ActionType,
|
|
6
|
+
DataNodeType,
|
|
7
|
+
GroupPort,
|
|
8
|
+
NodeKind,
|
|
9
|
+
ProcedureGraph,
|
|
10
|
+
TriggerType,
|
|
11
|
+
} from "../../../composables/useGraphConnect";
|
|
12
|
+
import type { WordedTrigger } from "../../../utils/describe";
|
|
13
|
+
|
|
14
|
+
/** The props of the graph canvas. */
|
|
15
|
+
export interface CanvasProps {
|
|
16
|
+
graph: ProcedureGraph;
|
|
17
|
+
triggerTypes: TriggerType[];
|
|
18
|
+
actionTypes: ActionType[];
|
|
19
|
+
dataNodeTypes: DataNodeType[];
|
|
20
|
+
/**
|
|
21
|
+
* Per-NodeKind metadata served by `/api/automation/node-kinds`. The
|
|
22
|
+
* `ui` block on each entry tells `dataFor` how to render the node —
|
|
23
|
+
* label, icon, port lists, type-registry / dynamic-config hooks. The
|
|
24
|
+
* frontend has zero kind-specific code beyond group + sentinels.
|
|
25
|
+
*/
|
|
26
|
+
nodeKinds: NodeKindEntry[];
|
|
27
|
+
canUndo?: boolean;
|
|
28
|
+
canRedo?: boolean;
|
|
29
|
+
// When the canvas is showing a group's inner subgraph, these are the
|
|
30
|
+
// parent group's declared ports — the sentinel nodes (groupInput /
|
|
31
|
+
// groupOutput) render handles derived from this list rather than
|
|
32
|
+
// reading from their own node data. (Sentinel nodes themselves don't
|
|
33
|
+
// carry ports; their parent group does.) Undefined at the procedure
|
|
34
|
+
// root.
|
|
35
|
+
parentGroupPorts?: GroupPort[];
|
|
36
|
+
// When true, the canvas suppresses graph mutations from user input —
|
|
37
|
+
// used for the read-only view of template-instance inner subgraphs.
|
|
38
|
+
// User can still pan / zoom / select / inspect, just not connect,
|
|
39
|
+
// move, delete, or edit. The "Apply / Cancel" buttons are hidden too.
|
|
40
|
+
readOnly?: boolean;
|
|
41
|
+
/** Outcome of each node in the run shown over the canvas (a test run, a debugged run). */
|
|
42
|
+
runStates?: Record<string, NodeRunState>;
|
|
43
|
+
/** The problem of each node the validator named. */
|
|
44
|
+
issues?: Record<string, NodeIssue>;
|
|
45
|
+
/**
|
|
46
|
+
* The node the editor has selected (inspector, dock "Select node", a
|
|
47
|
+
* `?node=` link): the canvas selects it too and brings it into view.
|
|
48
|
+
*/
|
|
49
|
+
selectedNodeId?: string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Names the graph shown (the procedure, the group entered): a new key
|
|
52
|
+
* fits the new graph into view.
|
|
53
|
+
*/
|
|
54
|
+
viewKey?: string;
|
|
55
|
+
/**
|
|
56
|
+
* An element drawn over the canvas's right edge (the inspector on narrow
|
|
57
|
+
* screens): fitting and centring keep the nodes out from under it.
|
|
58
|
+
*/
|
|
59
|
+
coveredBy?: HTMLElement | null;
|
|
60
|
+
/** The draft's triggers, worded by the server: a schedule reads in words. */
|
|
61
|
+
triggers?: WordedTrigger[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface NodeIssue {
|
|
65
|
+
severity: "error" | "warning";
|
|
66
|
+
message: string;
|
|
67
|
+
/** Problem code, translated as `dms_automation.editor.problems.codes.<code>`. */
|
|
68
|
+
code?: string;
|
|
69
|
+
params?: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The events of the graph canvas. */
|
|
73
|
+
export interface CanvasEmits {
|
|
74
|
+
(e: "update:graph", g: ProcedureGraph): void;
|
|
75
|
+
(e: "select:node", id: string | null): void;
|
|
76
|
+
// Fires whenever the selection set changes (single or multi). `ids` is
|
|
77
|
+
// the full set of currently selected node ids in this canvas — used by
|
|
78
|
+
// Editor.vue to drive the "Group selection" toolbar action. Sentinel
|
|
79
|
+
// nodes (groupInput / groupOutput) are filtered out before emitting.
|
|
80
|
+
(e: "selection-change", payload: { ids: string[] }): void;
|
|
81
|
+
(e: "undo"): void;
|
|
82
|
+
(e: "redo"): void;
|
|
83
|
+
// Bubbles up GroupNode's @dblclick — Editor.vue uses this to push the
|
|
84
|
+
// group onto the subgraph navigation path. Filtered by kind here so
|
|
85
|
+
// the parent doesn't need to look the node up itself.
|
|
86
|
+
(e: "group:enter", payload: { id: string }): void;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The translators the canvas gets from the host, handed to its helpers. */
|
|
90
|
+
export interface CanvasText {
|
|
91
|
+
t: ReturnType<typeof useI18n>["t"];
|
|
92
|
+
te: ReturnType<typeof useI18n>["te"];
|
|
93
|
+
processI18n: ReturnType<typeof useTranslation>["processI18n"];
|
|
94
|
+
processText: ReturnType<typeof useComposedText>["processText"];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// The node to select and bring into view once drawn: one just added, or one
|
|
98
|
+
// the editor points at (`readable`).
|
|
99
|
+
export interface Reveal {
|
|
100
|
+
pending: { id: string; readable: boolean } | null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Fit view never zooms past 100% (a lone trigger would fill the canvas) and
|
|
104
|
+
// may go down to 10% so a large graph fits whole.
|
|
105
|
+
export const FIT_PADDING = 0.15;
|
|
106
|
+
export const FIT_MAX_ZOOM = 1;
|
|
107
|
+
export const MIN_ZOOM = 0.1;
|
|
108
|
+
export const MAX_ZOOM = 1.5;
|
|
109
|
+
// Room left around a new node, and the size assumed for a node not drawn
|
|
110
|
+
// yet (GenericNode's width, a typical height).
|
|
111
|
+
export const NODE_GAP = 60;
|
|
112
|
+
export const NEW_NODE_SIZE = { width: 230, height: 90 };
|
|
113
|
+
|
|
114
|
+
// Sentinel node kinds — only valid inside a group's subgraph and never
|
|
115
|
+
// user-deletable. We filter them out of keyboard/right-click delete in
|
|
116
|
+
// onNodesChange below.
|
|
117
|
+
export const SENTINEL_KINDS: ReadonlySet<NodeKind> = new Set<NodeKind>([
|
|
118
|
+
"groupInput",
|
|
119
|
+
"groupOutput",
|
|
120
|
+
]);
|
|
121
|
+
|
|
122
|
+
export interface XY {
|
|
123
|
+
x: number;
|
|
124
|
+
y: number;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface Rect extends XY {
|
|
128
|
+
width: number;
|
|
129
|
+
height: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface Port {
|
|
133
|
+
/** Vue Flow handle id. */
|
|
134
|
+
id: string;
|
|
135
|
+
/** Port name ('' for the single trigger input of a step). */
|
|
136
|
+
name: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface NodeHandles {
|
|
140
|
+
triggerIns: Port[];
|
|
141
|
+
triggerOuts: Port[];
|
|
142
|
+
dataIns: Port[];
|
|
143
|
+
dataOuts: Port[];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface LinkItem {
|
|
147
|
+
label: string;
|
|
148
|
+
connection: Connection;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// DmsFlowCanvas owns the VueFlow store (it calls `useVueFlow(flowId)` with a
|
|
152
|
+
// private id and `defineExpose`s the resulting controller). We grab that
|
|
153
|
+
// controller through a template ref instead of calling `useVueFlow()` here —
|
|
154
|
+
// a bare `useVueFlow()` would resolve to the DEFAULT store, which is NOT the
|
|
155
|
+
// one DmsFlowCanvas drives, so zoom/fit/updateNodeInternals would silently
|
|
156
|
+
// no-op. Only the handful of imperative methods we actually use are typed.
|
|
157
|
+
export interface FlowNodeState {
|
|
158
|
+
id: string;
|
|
159
|
+
selected?: boolean;
|
|
160
|
+
computedPosition: XY;
|
|
161
|
+
dimensions: { width: number; height: number };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface FlowController {
|
|
165
|
+
zoomIn: () => void;
|
|
166
|
+
zoomOut: () => void;
|
|
167
|
+
zoomTo: (zoom: number) => void;
|
|
168
|
+
setViewport: (
|
|
169
|
+
viewport: XY & { zoom: number },
|
|
170
|
+
options?: { duration?: number },
|
|
171
|
+
) => Promise<boolean>;
|
|
172
|
+
screenToFlowCoordinate: (position: XY) => XY;
|
|
173
|
+
findNode: (id: string) => FlowNodeState | undefined;
|
|
174
|
+
addSelectedNodes: (nodes: FlowNodeState[]) => void;
|
|
175
|
+
removeSelectedNodes: (nodes: FlowNodeState[]) => void;
|
|
176
|
+
updateNodeInternals: (ids?: string | string[]) => void;
|
|
177
|
+
// DmsFlowCanvas `defineExpose`s the VueFlow controller; Vue's expose proxy
|
|
178
|
+
// unwraps the `viewport` ref, so consumers read `.viewport.zoom` directly
|
|
179
|
+
// (NOT `.viewport.value.zoom` — that extra `.value` is undefined and pinned
|
|
180
|
+
// the zoom readout at 100%). Same for the refs below.
|
|
181
|
+
viewport: XY & { zoom: number };
|
|
182
|
+
/** Size of the canvas on screen. */
|
|
183
|
+
dimensions: { width: number; height: number };
|
|
184
|
+
getSelectedNodes: FlowNodeState[];
|
|
185
|
+
getSelectedEdges: Array<{ id: string }>;
|
|
186
|
+
/** 'invalid' while the link being drawn hovers a port that refuses it. */
|
|
187
|
+
connectionStatus: "valid" | "invalid" | null;
|
|
188
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { computed, nextTick, watch, type Ref } from "vue";
|
|
2
|
+
import type { GraphNode as AppGraphNode } from "../../../composables/useGraphConnect";
|
|
3
|
+
import { FIT_MAX_ZOOM, FIT_PADDING, MIN_ZOOM } from "./types";
|
|
4
|
+
import type {
|
|
5
|
+
CanvasProps,
|
|
6
|
+
FlowController,
|
|
7
|
+
FlowNodeState,
|
|
8
|
+
Reveal,
|
|
9
|
+
} from "./types";
|
|
10
|
+
|
|
11
|
+
export function useCanvasView({
|
|
12
|
+
props,
|
|
13
|
+
flowRef,
|
|
14
|
+
wrapRef,
|
|
15
|
+
reveal,
|
|
16
|
+
}: {
|
|
17
|
+
props: Readonly<CanvasProps>;
|
|
18
|
+
flowRef: Ref<FlowController | null>;
|
|
19
|
+
wrapRef: Ref<HTMLElement | null>;
|
|
20
|
+
reveal: Reveal;
|
|
21
|
+
}) {
|
|
22
|
+
// The width of the canvas the inspector covers when it is drawn over it.
|
|
23
|
+
function coveredRight(): number {
|
|
24
|
+
const cover = props.coveredBy?.getBoundingClientRect();
|
|
25
|
+
const own = wrapRef.value?.getBoundingClientRect();
|
|
26
|
+
if (!cover?.width || !own) return 0;
|
|
27
|
+
return Math.max(
|
|
28
|
+
0,
|
|
29
|
+
Math.min(own.right, cover.right) - Math.max(own.left, cover.left),
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Fit every node into the part of the canvas left visible.
|
|
34
|
+
function fitView() {
|
|
35
|
+
const flow = flowRef.value;
|
|
36
|
+
if (!flow) return;
|
|
37
|
+
const nodes = props.graph.nodes
|
|
38
|
+
.map((n) => flow.findNode(n.id))
|
|
39
|
+
.filter((n): n is FlowNodeState => !!n?.dimensions.width);
|
|
40
|
+
if (nodes.length === 0) return;
|
|
41
|
+
const left = Math.min(...nodes.map((n) => n.computedPosition.x));
|
|
42
|
+
const top = Math.min(...nodes.map((n) => n.computedPosition.y));
|
|
43
|
+
const width =
|
|
44
|
+
Math.max(...nodes.map((n) => n.computedPosition.x + n.dimensions.width)) -
|
|
45
|
+
left;
|
|
46
|
+
const height =
|
|
47
|
+
Math.max(
|
|
48
|
+
...nodes.map((n) => n.computedPosition.y + n.dimensions.height),
|
|
49
|
+
) - top;
|
|
50
|
+
const visible = flow.dimensions.width - coveredRight();
|
|
51
|
+
const room = 1 + FIT_PADDING;
|
|
52
|
+
const fit = Math.min(
|
|
53
|
+
visible / (width * room),
|
|
54
|
+
flow.dimensions.height / (height * room),
|
|
55
|
+
);
|
|
56
|
+
const zoom = Math.min(Math.max(fit, MIN_ZOOM), FIT_MAX_ZOOM);
|
|
57
|
+
flow.setViewport({
|
|
58
|
+
x: (visible - width * zoom) / 2 - left * zoom,
|
|
59
|
+
y: (flow.dimensions.height - height * zoom) / 2 - top * zoom,
|
|
60
|
+
zoom,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Select a node and bring it into the visible part of the canvas. A node the
|
|
65
|
+
// editor points at (a link, a problem) is also shown at a readable zoom; a
|
|
66
|
+
// new node keeps the zoom.
|
|
67
|
+
function focusNode(id: string, readable = false) {
|
|
68
|
+
const flow = flowRef.value;
|
|
69
|
+
const node = flow?.findNode(id);
|
|
70
|
+
if (!flow || !node) return;
|
|
71
|
+
if (!node.selected) flow.addSelectedNodes([node]);
|
|
72
|
+
// Selecting opens the inspector, which narrows or covers the canvas:
|
|
73
|
+
// look once it is drawn (two frames).
|
|
74
|
+
requestAnimationFrame(() =>
|
|
75
|
+
requestAnimationFrame(() => panTo(id, readable)),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function panTo(id: string, readable: boolean) {
|
|
80
|
+
const flow = flowRef.value;
|
|
81
|
+
const node = flow?.findNode(id);
|
|
82
|
+
if (!flow || !node) return;
|
|
83
|
+
const visible = flow.dimensions.width - coveredRight();
|
|
84
|
+
const zoom = readable
|
|
85
|
+
? Math.max(flow.viewport.zoom, 1)
|
|
86
|
+
: flow.viewport.zoom;
|
|
87
|
+
const left = node.computedPosition.x * zoom + flow.viewport.x;
|
|
88
|
+
const top = node.computedPosition.y * zoom + flow.viewport.y;
|
|
89
|
+
const inSight =
|
|
90
|
+
left >= 0 &&
|
|
91
|
+
top >= 0 &&
|
|
92
|
+
left + node.dimensions.width * zoom <= visible &&
|
|
93
|
+
top + node.dimensions.height * zoom <= flow.dimensions.height;
|
|
94
|
+
if (inSight && zoom === flow.viewport.zoom) return;
|
|
95
|
+
flow.setViewport(
|
|
96
|
+
{
|
|
97
|
+
x:
|
|
98
|
+
visible / 2 -
|
|
99
|
+
(node.computedPosition.x + node.dimensions.width / 2) * zoom,
|
|
100
|
+
y:
|
|
101
|
+
flow.dimensions.height / 2 -
|
|
102
|
+
(node.computedPosition.y + node.dimensions.height / 2) * zoom,
|
|
103
|
+
zoom,
|
|
104
|
+
},
|
|
105
|
+
// A node pointed at is shown at once; a new one slides into view.
|
|
106
|
+
{ duration: readable ? 0 : 200 },
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// A new graph on the canvas (first load, another procedure, a group entered
|
|
111
|
+
// or left) is fitted into view; a node just added or pointed at is shown.
|
|
112
|
+
// Both wait until every node is measured and the panels around the canvas
|
|
113
|
+
// have settled (two frames): Vue Flow keeps the measures of nodes whose id
|
|
114
|
+
// the previous graph shared, so it does not always report them again.
|
|
115
|
+
let fitPending = true;
|
|
116
|
+
let settleQueued = false;
|
|
117
|
+
|
|
118
|
+
function settleView() {
|
|
119
|
+
if (settleQueued) return;
|
|
120
|
+
settleQueued = true;
|
|
121
|
+
requestAnimationFrame(() =>
|
|
122
|
+
requestAnimationFrame(() => {
|
|
123
|
+
settleQueued = false;
|
|
124
|
+
const flow = flowRef.value;
|
|
125
|
+
if (
|
|
126
|
+
!flow ||
|
|
127
|
+
!props.graph.nodes.every((n) => flow.findNode(n.id)?.dimensions.width)
|
|
128
|
+
)
|
|
129
|
+
return;
|
|
130
|
+
if (fitPending) {
|
|
131
|
+
fitPending = false;
|
|
132
|
+
fitView();
|
|
133
|
+
// The node the editor points at stays the one shown.
|
|
134
|
+
if (props.selectedNodeId)
|
|
135
|
+
reveal.pending ??= { id: props.selectedNodeId, readable: true };
|
|
136
|
+
}
|
|
137
|
+
if (reveal.pending) {
|
|
138
|
+
const { id, readable } = reveal.pending;
|
|
139
|
+
reveal.pending = null;
|
|
140
|
+
focusNode(id, readable);
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Vue Flow emits this once every node on the canvas has been measured.
|
|
147
|
+
function onNodesInitialized() {
|
|
148
|
+
settleView();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
watch(
|
|
152
|
+
() => props.viewKey,
|
|
153
|
+
() => {
|
|
154
|
+
fitPending = true;
|
|
155
|
+
nextTick(settleView);
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
watch(
|
|
160
|
+
() => props.selectedNodeId,
|
|
161
|
+
(id) => {
|
|
162
|
+
const flow = flowRef.value;
|
|
163
|
+
// The editor closed its inspector: the canvas lets go of the node too.
|
|
164
|
+
if (!id) {
|
|
165
|
+
if (flow?.getSelectedNodes.length)
|
|
166
|
+
flow.removeSelectedNodes(flow.getSelectedNodes);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
// A node selected on the canvas itself is already where the user looks.
|
|
170
|
+
if (flow?.findNode(id)?.selected) return;
|
|
171
|
+
reveal.pending = { id, readable: true };
|
|
172
|
+
nextTick(settleView);
|
|
173
|
+
},
|
|
174
|
+
// The editor may name a node (a `?node=` link) before the canvas exists.
|
|
175
|
+
{ immediate: true },
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
// Vue Flow caches each node's handle bounding boxes in its internal store and
|
|
179
|
+
// only re-measures when `updateNodeInternals(id)` is called. When a port is
|
|
180
|
+
// renamed or moved between the title bar and body (e.g. renaming a port to
|
|
181
|
+
// "main" moves the handle from a body row into the header), the Handle DOM
|
|
182
|
+
// element ends up in a different on-screen position but the cached bbox stays
|
|
183
|
+
// stale — connected edges keep drawing to the OLD coordinates until the next
|
|
184
|
+
// re-measure.
|
|
185
|
+
//
|
|
186
|
+
// To keep edges glued to handles, watch a signature derived from the per-node
|
|
187
|
+
// port lists / kinds and force a re-measure of every node after the DOM has
|
|
188
|
+
// applied the new template. Watching the full `props.graph` would fire on
|
|
189
|
+
// every drag (each emitGraph returns a fresh object) — costly and pointless,
|
|
190
|
+
// since node positions trigger their own internal updates already. The
|
|
191
|
+
// signature only changes when port shape changes, which is exactly when we
|
|
192
|
+
// need to re-measure.
|
|
193
|
+
const portsSignature = computed(() => {
|
|
194
|
+
const own = props.graph.nodes
|
|
195
|
+
.map((n) => {
|
|
196
|
+
const ports = (n as AppGraphNode & { ports?: unknown }).ports;
|
|
197
|
+
const portsKey = Array.isArray(ports) ? JSON.stringify(ports) : "";
|
|
198
|
+
return `${n.id}:${n.kind}:${portsKey}`;
|
|
199
|
+
})
|
|
200
|
+
.join("|");
|
|
201
|
+
// Sentinel nodes (groupInput / groupOutput) inside this canvas render
|
|
202
|
+
// handles derived from `parentGroupPorts`, not from their own node data.
|
|
203
|
+
// A rename on the outer group's port list re-renders the sentinel but
|
|
204
|
+
// doesn't show up in `props.graph.nodes` above, so we must also fold
|
|
205
|
+
// the parent ports into the signature.
|
|
206
|
+
const parent = Array.isArray(props.parentGroupPorts)
|
|
207
|
+
? JSON.stringify(props.parentGroupPorts)
|
|
208
|
+
: "";
|
|
209
|
+
return `${own}#${parent}`;
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
watch(portsSignature, () => {
|
|
213
|
+
nextTick(() => {
|
|
214
|
+
for (const node of props.graph.nodes) {
|
|
215
|
+
flowRef.value?.updateNodeInternals(node.id);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const zoomPercent = computed(() => {
|
|
221
|
+
const zoom = flowRef.value?.viewport.zoom ?? 1;
|
|
222
|
+
return `${Math.round(zoom * 100)}%`;
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
function resetZoom() {
|
|
226
|
+
flowRef.value?.zoomTo(1);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return { fitView, onNodesInitialized, zoomPercent, resetZoom };
|
|
230
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { WordedTrigger } from "../../utils/describe";
|
|
2
|
+
import type {
|
|
3
|
+
GroupPort,
|
|
4
|
+
GraphNode,
|
|
5
|
+
ProcedureGraph,
|
|
6
|
+
} from "../../composables/useGraphConnect";
|
|
7
|
+
|
|
8
|
+
export interface ProcedureRecord {
|
|
9
|
+
_id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
graph: ProcedureGraph;
|
|
14
|
+
// The graph's version (it moves with the graph only), and the revision
|
|
15
|
+
// (it moves with every write: a save, a pause from the list). A save sends
|
|
16
|
+
// the revision it started from back, so the server refuses to overwrite
|
|
17
|
+
// what was written elsewhere in the meantime.
|
|
18
|
+
version?: number;
|
|
19
|
+
revision?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Subgraph navigation stack. The first entry is always the procedure root;
|
|
23
|
+
// each subsequent entry is a group / template segment the user has entered.
|
|
24
|
+
// Cleared and re-seeded whenever the selected procedure changes (see the
|
|
25
|
+
// watch on selectedId below).
|
|
26
|
+
//
|
|
27
|
+
// kind === 'procedure' — id is the procedure _id, name is its display name.
|
|
28
|
+
// kind === 'group' — id is the group node's id within its parent graph.
|
|
29
|
+
// kind === 'template' — reserved for the dedicated template editor view.
|
|
30
|
+
// Navigation into local groups pushes as 'group';
|
|
31
|
+
// template instances likewise push as 'group' with
|
|
32
|
+
// the read-only signal taken from the node having a
|
|
33
|
+
// templateId, not from the path kind.
|
|
34
|
+
export interface SubgraphPathSegment {
|
|
35
|
+
kind: "procedure" | "group" | "template";
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ProcedureSnapshot {
|
|
41
|
+
name: string;
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
graph: ProcedureGraph;
|
|
44
|
+
// Template mode only: the template's outer ports, edited at its root.
|
|
45
|
+
ports?: GroupPort[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Walk the procedure graph following subgraphPath. Returns the full chain
|
|
49
|
+
// of (segment, containerGraph, groupNode|null) so currentGraph and
|
|
50
|
+
// currentParentGroupPorts can be derived from one traversal without
|
|
51
|
+
// re-walking.
|
|
52
|
+
//
|
|
53
|
+
// If a path segment can't be resolved (e.g. the group node was deleted in
|
|
54
|
+
// the outer graph), traversal stops at the last valid level — the caller
|
|
55
|
+
// is expected to also watch the stale path and trim it (see the watch on
|
|
56
|
+
// `selected.graph`).
|
|
57
|
+
export interface SubgraphFrame {
|
|
58
|
+
segment: SubgraphPathSegment;
|
|
59
|
+
graph: ProcedureGraph;
|
|
60
|
+
// The group node that owns `graph` (i.e. graph === groupNode.subgraph).
|
|
61
|
+
// Null for the procedure root.
|
|
62
|
+
groupNode: GraphNode | null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Problems of the draft, asked of the server (the same validator a save
|
|
66
|
+
// runs) a moment after each change.
|
|
67
|
+
// Each issue carries a `code` (and its `params`) the locale words; its English
|
|
68
|
+
// `message` is the fallback for a code the locale does not know.
|
|
69
|
+
export interface GraphIssue {
|
|
70
|
+
severity: "error" | "warning";
|
|
71
|
+
message: string;
|
|
72
|
+
code?: string;
|
|
73
|
+
params?: Record<string, unknown>;
|
|
74
|
+
nodeId?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ProcedureTriggers {
|
|
78
|
+
triggers: Array<WordedTrigger & { nextAt: string | null }>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface Choice<C extends string> {
|
|
82
|
+
value: C;
|
|
83
|
+
label: string;
|
|
84
|
+
color?: "primary" | "neutral" | "error" | "warning";
|
|
85
|
+
variant?: "solid" | "outline" | "ghost" | "soft";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ChoiceQuestion<C extends string> {
|
|
89
|
+
title: string;
|
|
90
|
+
description: string;
|
|
91
|
+
choices: Choice<C>[];
|
|
92
|
+
/** The answer of a dialog closed without choosing (Escape, ✕, a click outside). */
|
|
93
|
+
dismiss: C;
|
|
94
|
+
}
|