@antelopejs/dms-automation 0.2.7 → 0.3.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 +46 -2
- package/dist/data/procedures-table.d.ts +38 -4
- package/dist/data/procedures-table.js +264 -82
- package/dist/data/procedures-table.js.map +1 -1
- package/dist/data/runs-table.d.ts +19 -3
- package/dist/data/runs-table.js +254 -19
- package/dist/data/runs-table.js.map +1 -1
- package/dist/db/index.d.ts +1 -2
- package/dist/db/index.js +1 -2
- package/dist/db/index.js.map +1 -1
- package/dist/db/models/automation_template.model.d.ts +16 -1
- package/dist/db/models/automation_template.model.js +31 -11
- package/dist/db/models/automation_template.model.js.map +1 -1
- package/dist/db/models/index.d.ts +1 -1
- package/dist/db/models/index.js +1 -1
- package/dist/db/models/procedure.model.d.ts +1 -0
- package/dist/db/models/procedure.model.js +7 -0
- package/dist/db/models/procedure.model.js.map +1 -1
- package/dist/db/models/procedure_run.model.d.ts +16 -9
- package/dist/db/models/procedure_run.model.js +96 -17
- package/dist/db/models/procedure_run.model.js.map +1 -1
- package/dist/db/models/stats.model.d.ts +60 -61
- package/dist/db/models/stats.model.js +189 -236
- package/dist/db/models/stats.model.js.map +1 -1
- package/dist/db/models/type_switch.model.d.ts +25 -0
- package/dist/db/models/type_switch.model.js +25 -0
- package/dist/db/models/type_switch.model.js.map +1 -0
- package/dist/db/tables/index.d.ts +1 -2
- package/dist/db/tables/index.js +1 -2
- package/dist/db/tables/index.js.map +1 -1
- package/dist/db/tables/procedure.table.d.ts +6 -0
- package/dist/db/tables/procedure.table.js +24 -0
- package/dist/db/tables/procedure.table.js.map +1 -1
- package/dist/db/tables/procedure_run.table.d.ts +15 -1
- package/dist/db/tables/procedure_run.table.js +54 -0
- package/dist/db/tables/procedure_run.table.js.map +1 -1
- package/dist/db/tables/type_switch.table.d.ts +8 -0
- package/dist/db/tables/{trigger_type_config.table.js → type_switch.table.js} +16 -15
- package/dist/db/tables/type_switch.table.js.map +1 -0
- package/dist/displays/index.d.ts +14 -0
- package/dist/displays/index.js +23 -0
- package/dist/displays/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/pages/builder.d.ts +1 -1
- package/dist/pages/builder.js +10 -3
- package/dist/pages/builder.js.map +1 -1
- package/dist/pages/index.d.ts +2 -1
- package/dist/pages/index.js +2 -1
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/library.d.ts +2 -1
- package/dist/pages/library.js +54 -4
- package/dist/pages/library.js.map +1 -1
- package/dist/pages/overview.d.ts +6 -1
- package/dist/pages/overview.js +121 -2
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/procedures.js +106 -16
- package/dist/pages/procedures.js.map +1 -1
- package/dist/pages/runs.d.ts +4 -1
- package/dist/pages/runs.js +109 -13
- package/dist/pages/runs.js.map +1 -1
- package/dist/pages/shared.d.ts +18 -0
- package/dist/pages/shared.js +238 -0
- package/dist/pages/shared.js.map +1 -0
- package/dist/pages/trace.d.ts +10 -0
- package/dist/pages/trace.js +41 -0
- package/dist/pages/trace.js.map +1 -0
- package/dist/realtime.d.ts +3 -0
- package/dist/realtime.js +14 -0
- package/dist/realtime.js.map +1 -0
- package/dist/routes/action-types.d.ts +2 -14
- package/dist/routes/action-types.js +2 -32
- package/dist/routes/action-types.js.map +1 -1
- package/dist/routes/deleteConfirm.d.ts +3 -0
- package/dist/routes/deleteConfirm.js +64 -0
- package/dist/routes/deleteConfirm.js.map +1 -0
- package/dist/routes/graphSchema.d.ts +3 -90
- package/dist/routes/graphSchema.js +36 -9
- package/dist/routes/graphSchema.js.map +1 -1
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/library.d.ts +40 -0
- package/dist/routes/library.js +147 -0
- package/dist/routes/library.js.map +1 -0
- package/dist/routes/procedureChecks.d.ts +16 -0
- package/dist/routes/procedureChecks.js +72 -0
- package/dist/routes/procedureChecks.js.map +1 -0
- package/dist/routes/procedureRuns.d.ts +21 -0
- package/dist/routes/procedureRuns.js +45 -0
- package/dist/routes/procedureRuns.js.map +1 -0
- package/dist/routes/procedureSchemas.d.ts +107 -0
- package/dist/routes/procedureSchemas.js +61 -0
- package/dist/routes/procedureSchemas.js.map +1 -0
- package/dist/routes/procedures.d.ts +125 -7
- package/dist/routes/procedures.js +363 -67
- package/dist/routes/procedures.js.map +1 -1
- package/dist/routes/requests.d.ts +15 -0
- package/dist/routes/requests.js +35 -0
- package/dist/routes/requests.js.map +1 -0
- package/dist/routes/runs.d.ts +107 -2
- package/dist/routes/runs.js +340 -37
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/stats.d.ts +19 -1
- package/dist/routes/stats.js +160 -4
- package/dist/routes/stats.js.map +1 -1
- package/dist/routes/templates.d.ts +6 -2
- package/dist/routes/templates.js +106 -36
- package/dist/routes/templates.js.map +1 -1
- package/dist/routes/trigger-types.d.ts +2 -15
- package/dist/routes/trigger-types.js +2 -32
- package/dist/routes/trigger-types.js.map +1 -1
- package/dist/routes/typeConfigShared.d.ts +7 -11
- package/dist/routes/typeConfigShared.js +25 -15
- package/dist/routes/typeConfigShared.js.map +1 -1
- package/dist/runtime/armErrors.d.ts +16 -0
- package/dist/runtime/armErrors.js +69 -0
- package/dist/runtime/armErrors.js.map +1 -0
- package/dist/runtime/boundRunLog.d.ts +24 -0
- package/dist/runtime/boundRunLog.js +202 -10
- package/dist/runtime/boundRunLog.js.map +1 -1
- package/dist/runtime/builtins/actions/http.d.ts +10 -1
- package/dist/runtime/builtins/actions/http.js +306 -19
- package/dist/runtime/builtins/actions/http.js.map +1 -1
- package/dist/runtime/builtins/actions/log.js +2 -2
- package/dist/runtime/builtins/actions/log.js.map +1 -1
- package/dist/runtime/builtins/data/boolean.d.ts +1 -0
- package/dist/runtime/builtins/data/boolean.js +18 -10
- package/dist/runtime/builtins/data/boolean.js.map +1 -1
- package/dist/runtime/builtins/data/compare.js +60 -11
- package/dist/runtime/builtins/data/compare.js.map +1 -1
- package/dist/runtime/builtins/data/constant.js +9 -12
- package/dist/runtime/builtins/data/constant.js.map +1 -1
- package/dist/runtime/builtins/data/json.js +4 -4
- package/dist/runtime/builtins/data/json.js.map +1 -1
- package/dist/runtime/builtins/data/math.js +44 -24
- package/dist/runtime/builtins/data/math.js.map +1 -1
- package/dist/runtime/builtins/data/object.js +10 -10
- package/dist/runtime/builtins/data/object.js.map +1 -1
- package/dist/runtime/builtins/data/string.js +31 -20
- package/dist/runtime/builtins/data/string.js.map +1 -1
- package/dist/runtime/builtins/nodes/action.js +4 -0
- package/dist/runtime/builtins/nodes/action.js.map +1 -1
- package/dist/runtime/builtins/nodes/delay.js +1 -1
- package/dist/runtime/builtins/nodes/delay.js.map +1 -1
- package/dist/runtime/builtins/nodes/forRange.d.ts +1 -1
- package/dist/runtime/builtins/nodes/forRange.js +10 -4
- package/dist/runtime/builtins/nodes/forRange.js.map +1 -1
- package/dist/runtime/builtins/nodes/if.js +2 -1
- package/dist/runtime/builtins/nodes/if.js.map +1 -1
- package/dist/runtime/builtins/nodes/parallel.js +9 -2
- package/dist/runtime/builtins/nodes/parallel.js.map +1 -1
- package/dist/runtime/builtins/nodes/retry.js +1 -1
- package/dist/runtime/builtins/nodes/retry.js.map +1 -1
- package/dist/runtime/builtins/nodes/setVariable.js +1 -3
- package/dist/runtime/builtins/nodes/setVariable.js.map +1 -1
- package/dist/runtime/builtins/triggers/cron.d.ts +3 -0
- package/dist/runtime/builtins/triggers/cron.js +21 -7
- package/dist/runtime/builtins/triggers/cron.js.map +1 -1
- package/dist/runtime/builtins/triggers/manual.js +2 -2
- package/dist/runtime/builtins/triggers/manual.js.map +1 -1
- package/dist/runtime/builtins/triggers/webhook.d.ts +14 -1
- package/dist/runtime/builtins/triggers/webhook.js +116 -30
- package/dist/runtime/builtins/triggers/webhook.js.map +1 -1
- package/dist/runtime/describe.d.ts +23 -0
- package/dist/runtime/describe.js +114 -0
- package/dist/runtime/describe.js.map +1 -0
- package/dist/runtime/executionResult.d.ts +1 -0
- package/dist/runtime/executor.js +82 -5
- package/dist/runtime/executor.js.map +1 -1
- package/dist/runtime/graphIssues.d.ts +20 -0
- package/dist/runtime/graphIssues.js +290 -0
- package/dist/runtime/graphIssues.js.map +1 -0
- package/dist/runtime/graphVersion.d.ts +2 -0
- package/dist/runtime/graphVersion.js +43 -0
- package/dist/runtime/graphVersion.js.map +1 -0
- package/dist/runtime/nodeKinds.d.ts +4 -4
- package/dist/runtime/nodeKinds.js +1 -2
- package/dist/runtime/nodeKinds.js.map +1 -1
- package/dist/runtime/registry.d.ts +2 -1
- package/dist/runtime/registry.js +1 -2
- package/dist/runtime/registry.js.map +1 -1
- package/dist/runtime/resolveInputs.d.ts +3 -1
- package/dist/runtime/resolveInputs.js +12 -2
- package/dist/runtime/resolveInputs.js.map +1 -1
- package/dist/runtime/resolveSubgraph.d.ts +12 -1
- package/dist/runtime/resolveSubgraph.js +36 -0
- package/dist/runtime/resolveSubgraph.js.map +1 -1
- package/dist/runtime/retention.d.ts +6 -0
- package/dist/runtime/retention.js +54 -0
- package/dist/runtime/retention.js.map +1 -0
- package/dist/runtime/runProcedure.d.ts +12 -0
- package/dist/runtime/runProcedure.js +130 -0
- package/dist/runtime/runProcedure.js.map +1 -0
- package/dist/runtime/schedule.d.ts +2 -0
- package/dist/runtime/schedule.js +139 -0
- package/dist/runtime/schedule.js.map +1 -0
- package/dist/runtime/subscriptions.d.ts +11 -1
- package/dist/runtime/subscriptions.js +91 -125
- package/dist/runtime/subscriptions.js.map +1 -1
- package/dist/runtime/subwalk.js +2 -3
- package/dist/runtime/subwalk.js.map +1 -1
- package/dist/runtime/templateUsages.d.ts +4 -0
- package/dist/runtime/templateUsages.js +102 -0
- package/dist/runtime/templateUsages.js.map +1 -0
- package/dist/runtime/topo.d.ts +1 -0
- package/dist/runtime/topo.js +23 -0
- package/dist/runtime/topo.js.map +1 -1
- package/dist/runtime/trace.d.ts +44 -0
- package/dist/runtime/trace.js +240 -0
- package/dist/runtime/trace.js.map +1 -0
- package/dist/runtime/typeSwitches.d.ts +3 -0
- package/dist/runtime/typeSwitches.js +27 -0
- package/dist/runtime/typeSwitches.js.map +1 -0
- package/dist/runtime/validate.d.ts +11 -0
- package/dist/runtime/validate.js +118 -61
- package/dist/runtime/validate.js.map +1 -1
- package/dist/runtime/webhookRoutes.d.ts +4 -0
- package/dist/runtime/webhookRoutes.js +68 -0
- package/dist/runtime/webhookRoutes.js.map +1 -0
- package/dist/runtime/withTimeout.d.ts +1 -0
- package/dist/runtime/withTimeout.js +17 -0
- package/dist/runtime/withTimeout.js.map +1 -0
- package/dist/runtime/wording.d.ts +10 -0
- package/dist/runtime/wording.js +118 -0
- package/dist/runtime/wording.js.map +1 -0
- package/dist/stats/health-banner.d.ts +13 -0
- package/dist/stats/health-banner.js +149 -0
- package/dist/stats/health-banner.js.map +1 -0
- package/dist/stats/health.d.ts +49 -0
- package/dist/stats/health.js +130 -0
- package/dist/stats/health.js.map +1 -0
- package/dist/stats/kpi.d.ts +21 -0
- package/dist/stats/kpi.js +101 -0
- package/dist/stats/kpi.js.map +1 -0
- package/dist/stats/overview.d.ts +94 -0
- package/dist/stats/overview.js +244 -0
- package/dist/stats/overview.js.map +1 -0
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/constants.js +1 -2
- package/dist/types/constants.js.map +1 -1
- package/dist/types/runLog.d.ts +2 -0
- package/dist/types/runLog.js +4 -0
- package/dist/types/runLog.js.map +1 -1
- package/frontend-vue/app/components/AttentionList.vue +276 -0
- package/frontend-vue/app/components/Catalog/SchemaTable.vue +127 -0
- package/frontend-vue/app/components/Catalog.vue +457 -0
- package/frontend-vue/app/components/Editor/BottomDock.vue +188 -0
- package/frontend-vue/app/components/Editor/BuilderPalette.vue +101 -45
- package/frontend-vue/app/components/Editor/GraphCanvas.vue +818 -206
- package/frontend-vue/app/components/Editor/GroupPortEditor.vue +29 -18
- package/frontend-vue/app/components/Editor/JsonField.vue +3 -3
- package/frontend-vue/app/components/Editor/NewProcedureDialog.vue +108 -0
- package/frontend-vue/app/components/Editor/NodeInspector.vue +373 -101
- package/frontend-vue/app/components/Editor/ProcedureSwitcher.vue +147 -0
- package/frontend-vue/app/components/Editor/RunNowDialog.vue +145 -0
- package/frontend-vue/app/components/Editor/WiredField.vue +3 -3
- package/frontend-vue/app/components/Editor/nodes/GenericNode.vue +97 -91
- package/frontend-vue/app/components/Editor/nodes/GroupNode.vue +5 -6
- package/frontend-vue/app/components/Editor/nodes/GroupSentinel.vue +3 -2
- package/frontend-vue/app/components/Editor/nodes/styles.ts +14 -18
- package/frontend-vue/app/components/Editor.vue +1894 -705
- package/frontend-vue/app/components/IconPicker.vue +122 -0
- package/frontend-vue/app/components/LiveTopics.vue +20 -0
- package/frontend-vue/app/components/Run/RunCompare.vue +115 -0
- package/frontend-vue/app/components/Run/RunFailure.vue +54 -0
- package/frontend-vue/app/components/Run/RunLogList.vue +167 -0
- package/frontend-vue/app/components/Run/RunPathTaken.vue +139 -0
- package/frontend-vue/app/components/Run/RunPayload.vue +85 -0
- package/frontend-vue/app/components/Run/RunWaterfall.vue +374 -0
- package/frontend-vue/app/components/RunPeek.vue +132 -0
- package/frontend-vue/app/components/RunTrace.vue +462 -0
- package/frontend-vue/app/components/Templates.vue +382 -537
- package/frontend-vue/app/components/WebhookEndpoint.vue +81 -0
- package/frontend-vue/app/composables/useAutomationNodeKinds.ts +23 -6
- package/frontend-vue/app/composables/useAutomationRuns.ts +160 -25
- package/frontend-vue/app/composables/useGraphConnect.ts +103 -51
- package/frontend-vue/app/composables/useRunActions.ts +60 -0
- package/frontend-vue/app/plugins/cell-displays.ts +169 -0
- package/frontend-vue/app/utils/automation.ts +4 -36
- package/frontend-vue/app/utils/describe.ts +252 -0
- package/frontend-vue/app/utils/redactedHeaders.ts +31 -0
- package/frontend-vue/dms.frontend.build.ts +7 -0
- package/frontend-vue/dms.frontend.ts +7 -4
- package/frontend-vue/i18n/locales/dms-automation-en-GB.json +1149 -309
- package/frontend-vue/i18n/locales/dms-automation-fr-FR.json +1154 -314
- package/frontend-vue/package.json +1 -1
- package/package.json +7 -5
- package/dist/db/models/type_config.model.d.ts +0 -47
- package/dist/db/models/type_config.model.js +0 -51
- package/dist/db/models/type_config.model.js.map +0 -1
- package/dist/db/tables/action_type_config.table.d.ts +0 -7
- package/dist/db/tables/action_type_config.table.js +0 -35
- package/dist/db/tables/action_type_config.table.js.map +0 -1
- package/dist/db/tables/trigger_type_config.table.d.ts +0 -7
- package/dist/db/tables/trigger_type_config.table.js.map +0 -1
- package/frontend-vue/app/components/Actions.vue +0 -151
- package/frontend-vue/app/components/Catalog/TypeConfigForm.vue +0 -170
- package/frontend-vue/app/components/Catalog/TypeList.vue +0 -203
- package/frontend-vue/app/components/DataNodes.vue +0 -275
- package/frontend-vue/app/components/Editor/ProcedureList.vue +0 -156
- package/frontend-vue/app/components/Editor/RunsDrawer.vue +0 -312
- package/frontend-vue/app/components/Library.vue +0 -69
- package/frontend-vue/app/components/Overview.vue +0 -503
- package/frontend-vue/app/components/RunDetailDrawer.vue +0 -165
- package/frontend-vue/app/components/RunFireTree.vue +0 -170
- package/frontend-vue/app/components/RunTraceDrawer.vue +0 -59
- package/frontend-vue/app/components/RunsStats.vue +0 -126
- package/frontend-vue/app/components/RunsTimelineDisplay.vue +0 -287
- package/frontend-vue/app/components/Triggers.vue +0 -147
- package/frontend-vue/app/plugins/runs-timeline-display.client.ts +0 -16
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, markRaw, nextTick, ref, watch } from 'vue'
|
|
3
3
|
import { newId } from '../../utils/automation'
|
|
4
|
+
import { roleOf, summarizeNode, type WordedTrigger } from '../../utils/describe'
|
|
5
|
+
import type { NodeRunState } from './nodes/GenericNode.vue'
|
|
4
6
|
// The canvas chrome (dotted DMS background, zoom controls, themed
|
|
5
7
|
// node/handle/edge styling, pan/zoom + fit-view) now comes from the shared
|
|
6
8
|
// DmsFlowCanvas wrapper (dms ≥0.0.25). We only keep the @vue-flow/core bits
|
|
@@ -41,25 +43,20 @@ import type {
|
|
|
41
43
|
DataNodeType,
|
|
42
44
|
JsonSchema,
|
|
43
45
|
GroupPort,
|
|
46
|
+
ConnectResult,
|
|
44
47
|
} from '../../composables/useGraphConnect'
|
|
45
|
-
import
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
import {
|
|
49
|
+
PALETTE_DRAG_TYPE,
|
|
50
|
+
type NodeKindEntry,
|
|
51
|
+
type NodeKindUI,
|
|
52
|
+
type PaletteBlock,
|
|
53
|
+
type TemplateSummary,
|
|
48
54
|
} from '../../composables/useAutomationNodeKinds'
|
|
49
55
|
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
// edits don't retroactively mutate the instance's port list (the resolved
|
|
55
|
-
// subgraph still updates live — that's the live-link model).
|
|
56
|
-
interface TemplateSummary {
|
|
57
|
-
_id: string
|
|
58
|
-
name: string
|
|
59
|
-
icon?: string
|
|
60
|
-
ports: GroupPort[]
|
|
61
|
-
}
|
|
62
|
-
|
|
56
|
+
// A template's `ports` are deep-cloned (JSON round-trip) onto each new
|
|
57
|
+
// template-instance group node so future template edits don't retroactively
|
|
58
|
+
// mutate the instance's port list (the resolved subgraph still updates live —
|
|
59
|
+
// that's the live-link model).
|
|
63
60
|
const props = defineProps<{
|
|
64
61
|
graph: ProcedureGraph
|
|
65
62
|
triggerTypes: TriggerType[]
|
|
@@ -74,8 +71,6 @@ const props = defineProps<{
|
|
|
74
71
|
nodeKinds: NodeKindEntry[]
|
|
75
72
|
canUndo?: boolean
|
|
76
73
|
canRedo?: boolean
|
|
77
|
-
isDirty?: boolean
|
|
78
|
-
applying?: boolean
|
|
79
74
|
// When the canvas is showing a group's inner subgraph, these are the
|
|
80
75
|
// parent group's declared ports — the sentinel nodes (groupInput /
|
|
81
76
|
// groupOutput) render handles derived from this list rather than
|
|
@@ -88,8 +83,37 @@ const props = defineProps<{
|
|
|
88
83
|
// User can still pan / zoom / select / inspect, just not connect,
|
|
89
84
|
// move, delete, or edit. The "Apply / Cancel" buttons are hidden too.
|
|
90
85
|
readOnly?: boolean
|
|
86
|
+
/** Outcome of each node in the run shown over the canvas (a test run, a debugged run). */
|
|
87
|
+
runStates?: Record<string, NodeRunState>
|
|
88
|
+
/** The problem of each node the validator named. */
|
|
89
|
+
issues?: Record<string, NodeIssue>
|
|
90
|
+
/**
|
|
91
|
+
* The node the editor has selected (inspector, dock "Select node", a
|
|
92
|
+
* `?node=` link): the canvas selects it too and brings it into view.
|
|
93
|
+
*/
|
|
94
|
+
selectedNodeId?: string | null
|
|
95
|
+
/**
|
|
96
|
+
* Names the graph shown (the procedure, the group entered): a new key
|
|
97
|
+
* fits the new graph into view.
|
|
98
|
+
*/
|
|
99
|
+
viewKey?: string
|
|
100
|
+
/**
|
|
101
|
+
* An element drawn over the canvas's right edge (the inspector on narrow
|
|
102
|
+
* screens): fitting and centring keep the nodes out from under it.
|
|
103
|
+
*/
|
|
104
|
+
coveredBy?: HTMLElement | null
|
|
105
|
+
/** The draft's triggers, worded by the server: a schedule reads in words. */
|
|
106
|
+
triggers?: WordedTrigger[]
|
|
91
107
|
}>()
|
|
92
108
|
|
|
109
|
+
interface NodeIssue {
|
|
110
|
+
severity: 'error' | 'warning'
|
|
111
|
+
message: string
|
|
112
|
+
/** Problem code, translated as `dms_automation.editor.problems.codes.<code>`. */
|
|
113
|
+
code?: string
|
|
114
|
+
params?: Record<string, unknown>
|
|
115
|
+
}
|
|
116
|
+
|
|
93
117
|
const emit = defineEmits<{
|
|
94
118
|
(e: 'update:graph', g: ProcedureGraph): void
|
|
95
119
|
(e: 'select:node', id: string | null): void
|
|
@@ -100,8 +124,6 @@ const emit = defineEmits<{
|
|
|
100
124
|
(e: 'selection-change', payload: { ids: string[] }): void
|
|
101
125
|
(e: 'undo'): void
|
|
102
126
|
(e: 'redo'): void
|
|
103
|
-
(e: 'cancel'): void
|
|
104
|
-
(e: 'apply'): void
|
|
105
127
|
// Bubbles up GroupNode's @dblclick — Editor.vue uses this to push the
|
|
106
128
|
// group onto the subgraph navigation path. Filtered by kind here so
|
|
107
129
|
// the parent doesn't need to look the node up itself.
|
|
@@ -110,6 +132,19 @@ const emit = defineEmits<{
|
|
|
110
132
|
|
|
111
133
|
const toast = useToast()
|
|
112
134
|
const { processI18n } = useTranslation()
|
|
135
|
+
const { processText } = useComposedText()
|
|
136
|
+
const { t, te } = useI18n()
|
|
137
|
+
|
|
138
|
+
// Fit view never zooms past 100% (a lone trigger would fill the canvas) and
|
|
139
|
+
// may go down to 10% so a large graph fits whole.
|
|
140
|
+
const FIT_PADDING = 0.15
|
|
141
|
+
const FIT_MAX_ZOOM = 1
|
|
142
|
+
const MIN_ZOOM = 0.1
|
|
143
|
+
const MAX_ZOOM = 1.5
|
|
144
|
+
// Room left around a new node, and the size assumed for a node not drawn
|
|
145
|
+
// yet (GenericNode's width, a typical height).
|
|
146
|
+
const NODE_GAP = 60
|
|
147
|
+
const NEW_NODE_SIZE = { width: 230, height: 90 }
|
|
113
148
|
|
|
114
149
|
const nodeTypes = markRaw({
|
|
115
150
|
genericNode: GenericNode,
|
|
@@ -163,6 +198,22 @@ function lookupTypeBySpec(spec: NodeKindUI, typeId: string | undefined) {
|
|
|
163
198
|
return null
|
|
164
199
|
}
|
|
165
200
|
|
|
201
|
+
// A schedule in words, once the server has worded its current expression.
|
|
202
|
+
function scheduleTextOf(node: AppGraphNode): string | undefined {
|
|
203
|
+
const cron = node.config?.cron
|
|
204
|
+
const worded = props.triggers?.find((tr) => tr.nodeId === node.id && tr.cron === cron)
|
|
205
|
+
return worded ? processText(worded.text) : undefined
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// The validator's problem on a node, in the reader's language (its English
|
|
209
|
+
// message when this version has no text for the code).
|
|
210
|
+
function issueOf(id: string): NodeIssue | null {
|
|
211
|
+
const issue = props.issues?.[id]
|
|
212
|
+
if (!issue) return null
|
|
213
|
+
const key = `dms_automation.editor.problems.codes.${issue.code}`
|
|
214
|
+
return issue.code && te(key) ? { ...issue, message: t(key, issue.params ?? {}) } : issue
|
|
215
|
+
}
|
|
216
|
+
|
|
166
217
|
// Build the GenericNode `data` payload from a graph node. For every kind
|
|
167
218
|
// with `ui` metadata (every kind except group + sentinels), one
|
|
168
219
|
// data-driven resolver applies: combine `spec` from the backend with the
|
|
@@ -206,8 +257,16 @@ function dataFor(node: AppGraphNode) {
|
|
|
206
257
|
: []
|
|
207
258
|
const triggerOuts = [...dynPorts, ...spec.staticTriggerOuts]
|
|
208
259
|
|
|
260
|
+
const own = (node as AppGraphNode & { label?: string }).label
|
|
261
|
+
const module = (type as { module?: string } | null)?.module
|
|
209
262
|
return {
|
|
210
|
-
label,
|
|
263
|
+
label: own || label,
|
|
264
|
+
typeName: label,
|
|
265
|
+
role: roleOf(node.kind, spec.category),
|
|
266
|
+
module,
|
|
267
|
+
summary: summarizeNode(node.kind, node.typeId, node.config, processI18n, scheduleTextOf(node)),
|
|
268
|
+
run: props.runStates?.[node.id] ?? null,
|
|
269
|
+
issue: issueOf(node.id),
|
|
211
270
|
icon,
|
|
212
271
|
category,
|
|
213
272
|
typeId: node.typeId,
|
|
@@ -226,12 +285,17 @@ function dataFor(node: AppGraphNode) {
|
|
|
226
285
|
// GroupNode interface) — surface them so the renderer can display
|
|
227
286
|
// handles, linked badges, etc.
|
|
228
287
|
const g = node as AppGraphNode & {
|
|
288
|
+
label?: string
|
|
229
289
|
ports?: unknown
|
|
230
290
|
templateId?: string
|
|
231
291
|
subgraph?: unknown
|
|
232
292
|
}
|
|
293
|
+
// Step name (`label`) first, as for any node; `config.name` is the name
|
|
294
|
+
// the group or its template was created with.
|
|
233
295
|
return {
|
|
234
|
-
label: node.config?.name
|
|
296
|
+
label: g.label || (node.config?.name as string | undefined) || t('dms_automation.nodes.role.group'),
|
|
297
|
+
run: props.runStates?.[node.id] ?? null,
|
|
298
|
+
issue: issueOf(node.id),
|
|
235
299
|
ports: Array.isArray(g.ports) ? g.ports : [],
|
|
236
300
|
templateId: g.templateId,
|
|
237
301
|
subgraph: g.subgraph,
|
|
@@ -254,16 +318,39 @@ function dataFor(node: AppGraphNode) {
|
|
|
254
318
|
return {}
|
|
255
319
|
}
|
|
256
320
|
|
|
321
|
+
// What a screen reader announces for a node: its type when the node has a
|
|
322
|
+
// name of its own, its name, and what it does.
|
|
323
|
+
function ariaLabelOf(data: { label?: string; typeName?: string; summary?: string }) {
|
|
324
|
+
if (!data.label) return undefined
|
|
325
|
+
const type = data.typeName && data.typeName !== data.label ? `${data.typeName}: ` : ''
|
|
326
|
+
return `${type}${data.label}${data.summary ? `, ${data.summary}` : ''}`
|
|
327
|
+
}
|
|
328
|
+
|
|
257
329
|
const vfNodes = computed(() =>
|
|
258
|
-
props.graph.nodes.map((n) =>
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
330
|
+
props.graph.nodes.map((n) => {
|
|
331
|
+
const data = dataFor(n)
|
|
332
|
+
return {
|
|
333
|
+
id: n.id,
|
|
334
|
+
type: vfTypeFor(n.kind),
|
|
335
|
+
position: n.position,
|
|
336
|
+
data,
|
|
337
|
+
ariaLabel: SENTINEL_KINDS.has(n.kind)
|
|
338
|
+
? t(n.kind === 'groupInput' ? 'dms_automation.nodes.groupInput' : 'dms_automation.nodes.groupOutput')
|
|
339
|
+
: ariaLabelOf(data),
|
|
340
|
+
sourcePosition: Position.Bottom,
|
|
341
|
+
targetPosition: Position.Top,
|
|
342
|
+
}
|
|
343
|
+
}),
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
// How the canvas names a node in its messages: its label, else (a group's
|
|
347
|
+
// sentinels) the group role.
|
|
348
|
+
const nodeNames = computed(
|
|
349
|
+
() => new Map(vfNodes.value.map((n) => [n.id, (n.data as { label?: string }).label])),
|
|
266
350
|
)
|
|
351
|
+
function nodeName(id: string): string {
|
|
352
|
+
return nodeNames.value.get(id) || t('dms_automation.nodes.role.group')
|
|
353
|
+
}
|
|
267
354
|
|
|
268
355
|
// Look up the kind of an edge endpoint by node id — needed for the group
|
|
269
356
|
// handle-id derivation below. Sentinels and groups have richer handle
|
|
@@ -320,6 +407,17 @@ function dataTargetHandle(e: DataEdge, targetKind: NodeKind | undefined): string
|
|
|
320
407
|
return `data-in-${e.to.field}`
|
|
321
408
|
}
|
|
322
409
|
|
|
410
|
+
// After a run, the edges it took are drawn solid and the one into the failing
|
|
411
|
+
// step red; the others fade.
|
|
412
|
+
function edgeClass(from: string, to: string): string {
|
|
413
|
+
const runs = props.runStates
|
|
414
|
+
if (!runs) return 'edge-trigger'
|
|
415
|
+
const target = runs[to]?.status
|
|
416
|
+
const taken = runs[from] && target && target !== 'skipped'
|
|
417
|
+
if (taken && target === 'failed') return 'edge-trigger edge-failed'
|
|
418
|
+
return taken ? 'edge-trigger edge-taken' : 'edge-trigger edge-idle'
|
|
419
|
+
}
|
|
420
|
+
|
|
323
421
|
// Edge styling lives in <style> (.edge-trigger / .edge-data) so the
|
|
324
422
|
// `.selected` highlight can win without `!important`. Inline `style`
|
|
325
423
|
// on a vue-flow edge defeats the .selected rule — documented gotcha.
|
|
@@ -332,7 +430,8 @@ const vfEdges = computed(() => {
|
|
|
332
430
|
sourceHandle: triggerSourceHandle(e, kinds.get(e.from.node)),
|
|
333
431
|
targetHandle: triggerTargetHandle(e, kinds.get(e.to.node)),
|
|
334
432
|
data: { kind: 'trigger' as const },
|
|
335
|
-
|
|
433
|
+
ariaLabel: `${menuName(e.from.node)} → ${menuName(e.to.node)}`,
|
|
434
|
+
class: edgeClass(e.from.node, e.to.node),
|
|
336
435
|
}))
|
|
337
436
|
const dataEdges = props.graph.dataEdges.map((e) => ({
|
|
338
437
|
id: e.id,
|
|
@@ -341,6 +440,7 @@ const vfEdges = computed(() => {
|
|
|
341
440
|
sourceHandle: dataSourceHandle(e, kinds.get(e.from.node)),
|
|
342
441
|
targetHandle: dataTargetHandle(e, kinds.get(e.to.node)),
|
|
343
442
|
data: { kind: 'data' as const },
|
|
443
|
+
ariaLabel: `${menuName(e.from.node)} · ${e.from.port} → ${menuName(e.to.node)} · ${e.to.field}`,
|
|
344
444
|
class: 'edge-data',
|
|
345
445
|
}))
|
|
346
446
|
return [...triggerEdges, ...dataEdges]
|
|
@@ -351,10 +451,166 @@ function emitGraph(g: ProcedureGraph) {
|
|
|
351
451
|
emit('update:graph', g)
|
|
352
452
|
}
|
|
353
453
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
454
|
+
interface XY {
|
|
455
|
+
x: number
|
|
456
|
+
y: number
|
|
457
|
+
}
|
|
458
|
+
interface Rect extends XY {
|
|
459
|
+
width: number
|
|
460
|
+
height: number
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function nodeRects(): Rect[] {
|
|
464
|
+
return props.graph.nodes.map((n) => {
|
|
465
|
+
const size = flowRef.value?.findNode(n.id)?.dimensions
|
|
466
|
+
return {
|
|
467
|
+
...n.position,
|
|
468
|
+
width: size?.width || NEW_NODE_SIZE.width,
|
|
469
|
+
height: size?.height || NEW_NODE_SIZE.height,
|
|
470
|
+
}
|
|
471
|
+
})
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function overlaps(a: Rect, b: Rect): boolean {
|
|
475
|
+
const gap = NODE_GAP / 2
|
|
476
|
+
return a.x < b.x + b.width + gap && b.x < a.x + a.width + gap && a.y < b.y + b.height + gap && b.y < a.y + a.height + gap
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// The first place at or below `pos` where a new node covers no other one.
|
|
480
|
+
function freeSpot(pos: XY): XY {
|
|
481
|
+
const rects = nodeRects()
|
|
482
|
+
const spot: Rect = { ...pos, ...NEW_NODE_SIZE }
|
|
483
|
+
for (let hit = rects.find((r) => overlaps(spot, r)); hit; hit = rects.find((r) => overlaps(spot, r))) {
|
|
484
|
+
spot.y = hit.y + hit.height + NODE_GAP
|
|
485
|
+
}
|
|
486
|
+
return { x: Math.round(spot.x), y: Math.round(spot.y) }
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// A new step goes right of the selected one, else in the middle of what the
|
|
490
|
+
// canvas shows.
|
|
491
|
+
function newNodePosition(anchor: AppGraphNode | undefined): XY {
|
|
492
|
+
const flow = flowRef.value
|
|
493
|
+
if (anchor) {
|
|
494
|
+
const width = flow?.findNode(anchor.id)?.dimensions.width || NEW_NODE_SIZE.width
|
|
495
|
+
return freeSpot({ x: anchor.position.x + width + NODE_GAP, y: anchor.position.y })
|
|
496
|
+
}
|
|
497
|
+
if (!flow) return freeSpot({ x: 0, y: 0 })
|
|
498
|
+
const { x, y, zoom } = flow.viewport
|
|
499
|
+
return freeSpot({
|
|
500
|
+
x: (flow.dimensions.width / 2 - x) / zoom - NEW_NODE_SIZE.width / 2,
|
|
501
|
+
y: (flow.dimensions.height / 2 - y) / zoom - NEW_NODE_SIZE.height / 2,
|
|
502
|
+
})
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// The node a new step follows: the one selected last on this canvas.
|
|
506
|
+
function anchorNode(): AppGraphNode | undefined {
|
|
507
|
+
const id = props.selectedNodeId ?? canvasSelection.value[canvasSelection.value.length - 1]
|
|
508
|
+
return props.graph.nodes.find((n) => n.id === id)
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
interface Port {
|
|
512
|
+
/** Vue Flow handle id. */
|
|
513
|
+
id: string
|
|
514
|
+
/** Port name ('' for the single trigger input of a step). */
|
|
515
|
+
name: string
|
|
516
|
+
}
|
|
517
|
+
interface NodeHandles {
|
|
518
|
+
triggerIns: Port[]
|
|
519
|
+
triggerOuts: Port[]
|
|
520
|
+
dataIns: Port[]
|
|
521
|
+
dataOuts: Port[]
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// The handles a node draws, named as its renderer names them (see the
|
|
525
|
+
// handle prefix table in useGraphConnect).
|
|
526
|
+
function handlesOf(node: AppGraphNode): NodeHandles {
|
|
527
|
+
if (node.kind === 'group' || SENTINEL_KINDS.has(node.kind)) {
|
|
528
|
+
const ports =
|
|
529
|
+
node.kind === 'group'
|
|
530
|
+
? ((node as AppGraphNode & { ports?: GroupPort[] }).ports ?? [])
|
|
531
|
+
: (props.parentGroupPorts ?? [])
|
|
532
|
+
const pick = (kind: GroupPort['kind'], direction: GroupPort['direction'], prefix: string) =>
|
|
533
|
+
ports
|
|
534
|
+
.filter((p) => p.kind === kind && p.direction === direction)
|
|
535
|
+
.map((p) => ({ id: `${prefix}${p.name}`, name: p.name }))
|
|
536
|
+
if (node.kind === 'group') {
|
|
537
|
+
return {
|
|
538
|
+
triggerIns: pick('trigger', 'in', 'group-trigger-in-'),
|
|
539
|
+
triggerOuts: pick('trigger', 'out', 'group-trigger-out-'),
|
|
540
|
+
dataIns: pick('data', 'in', 'group-data-in-'),
|
|
541
|
+
dataOuts: pick('data', 'out', 'group-data-out-'),
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
// The sentinels face inwards: the group's inputs leave groupInput, its
|
|
545
|
+
// outputs enter groupOutput.
|
|
546
|
+
if (node.kind === 'groupInput') {
|
|
547
|
+
return {
|
|
548
|
+
triggerIns: [],
|
|
549
|
+
triggerOuts: pick('trigger', 'in', 'groupInput-trigger-out-'),
|
|
550
|
+
dataIns: [],
|
|
551
|
+
dataOuts: pick('data', 'in', 'groupInput-data-out-'),
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return {
|
|
555
|
+
triggerIns: pick('trigger', 'out', 'groupOutput-trigger-in-'),
|
|
556
|
+
triggerOuts: [],
|
|
557
|
+
dataIns: pick('data', 'out', 'groupOutput-data-in-'),
|
|
558
|
+
dataOuts: [],
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
const data = dataFor(node) as {
|
|
562
|
+
hasTriggerIn?: boolean
|
|
563
|
+
hasMainTriggerOut?: boolean
|
|
564
|
+
triggerOuts?: string[]
|
|
565
|
+
dataIns?: Array<{ name: string }>
|
|
566
|
+
dataOuts?: Array<{ name: string }>
|
|
567
|
+
}
|
|
568
|
+
const branches = [...(data.hasMainTriggerOut === false ? [] : ['main']), ...(data.triggerOuts ?? [])]
|
|
569
|
+
return {
|
|
570
|
+
triggerIns: data.hasTriggerIn === false ? [] : [{ id: 'trigger-in', name: '' }],
|
|
571
|
+
triggerOuts: branches.map((name) => ({ id: `trigger-out-${name}`, name })),
|
|
572
|
+
dataIns: (data.dataIns ?? []).map((p) => ({ id: `data-in-${p.name}`, name: p.name })),
|
|
573
|
+
dataOuts: (data.dataOuts ?? []).map((p) => ({ id: `data-out-${p.name}`, name: p.name })),
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
function check(graph: ProcedureGraph, conn: Connection) {
|
|
578
|
+
return canConnect(
|
|
579
|
+
graph,
|
|
580
|
+
props.nodeKinds,
|
|
581
|
+
props.triggerTypes,
|
|
582
|
+
props.actionTypes,
|
|
583
|
+
props.dataNodeTypes,
|
|
584
|
+
conn,
|
|
585
|
+
{ parentGroupPorts: props.parentGroupPorts },
|
|
586
|
+
)
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// The link from `from`'s main output to `to`, when that output is free and
|
|
590
|
+
// `to` has an input that accepts it.
|
|
591
|
+
function nextStepConnection(graph: ProcedureGraph, from: AppGraphNode, to: AppGraphNode): Connection | null {
|
|
592
|
+
const out = handlesOf(from).triggerOuts.find((p) => p.name === 'main')
|
|
593
|
+
const ins = handlesOf(to).triggerIns
|
|
594
|
+
const into = ins.find((p) => p.name === 'main' || p.name === '') ?? ins[0]
|
|
595
|
+
if (!out || !into) return null
|
|
596
|
+
if (graph.triggerEdges.some((e) => e.from.node === from.id && (e.from.branch ?? 'main') === 'main')) return null
|
|
597
|
+
const conn: Connection = { source: from.id, sourceHandle: out.id, target: to.id, targetHandle: into.id }
|
|
598
|
+
return check(graph, conn).ok ? conn : null
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// The node to select and bring into view once drawn: one just added, or one
|
|
602
|
+
// the editor points at (`readable`).
|
|
603
|
+
let revealPending: { id: string; readable: boolean } | null = null
|
|
604
|
+
|
|
605
|
+
// Add a node where it was dropped, or next to the selected node and linked
|
|
606
|
+
// from it (one undo step for both).
|
|
607
|
+
function insertNode(node: AppGraphNode, at?: XY) {
|
|
608
|
+
const anchor = at ? undefined : anchorNode()
|
|
609
|
+
const placed = { ...node, position: at ? freeSpot(at) : newNodePosition(anchor) }
|
|
610
|
+
const graph = { ...props.graph, nodes: [...props.graph.nodes, placed] }
|
|
611
|
+
const link = anchor ? nextStepConnection(graph, anchor, placed) : null
|
|
612
|
+
emitGraph(link ? (withConnection(graph, link)?.graph ?? graph) : graph)
|
|
613
|
+
revealPending = { id: placed.id, readable: false }
|
|
358
614
|
}
|
|
359
615
|
|
|
360
616
|
function defaultsFromSchema(schema: JsonSchema | undefined): Record<string, unknown> {
|
|
@@ -391,18 +647,17 @@ function defaultConfigFor(kind: NodeKind, typeId?: string): Record<string, unkno
|
|
|
391
647
|
: {}
|
|
392
648
|
}
|
|
393
649
|
|
|
394
|
-
function addNode(kind: NodeKind, typeId?: string) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
})
|
|
650
|
+
function addNode(kind: NodeKind, typeId?: string, at?: XY) {
|
|
651
|
+
insertNode(
|
|
652
|
+
{
|
|
653
|
+
id: newId(),
|
|
654
|
+
kind,
|
|
655
|
+
typeId,
|
|
656
|
+
config: defaultConfigFor(kind, typeId),
|
|
657
|
+
position: { x: 0, y: 0 },
|
|
658
|
+
},
|
|
659
|
+
at,
|
|
660
|
+
)
|
|
406
661
|
}
|
|
407
662
|
|
|
408
663
|
// Drop a template-instance group node into the current graph. The instance
|
|
@@ -414,7 +669,7 @@ function addNode(kind: NodeKind, typeId?: string) {
|
|
|
414
669
|
// (the "live link" model); the port list is cloned so a port rename on
|
|
415
670
|
// the template doesn't silently invalidate the outer wiring on this
|
|
416
671
|
// instance (the user can manually re-sync by forking + re-saving).
|
|
417
|
-
function addTemplateInstance(template: TemplateSummary) {
|
|
672
|
+
function addTemplateInstance(template: TemplateSummary, at?: XY) {
|
|
418
673
|
const node: AppGraphNode & {
|
|
419
674
|
ports: GroupPort[]
|
|
420
675
|
templateId: string
|
|
@@ -422,41 +677,204 @@ function addTemplateInstance(template: TemplateSummary) {
|
|
|
422
677
|
id: newId(),
|
|
423
678
|
kind: 'group',
|
|
424
679
|
config: { name: template.name },
|
|
425
|
-
position:
|
|
680
|
+
position: { x: 0, y: 0 },
|
|
426
681
|
templateId: template._id,
|
|
427
682
|
// JSON round-trip strips Vue's reactive proxy that wraps the template
|
|
428
683
|
// passed from the palette; structuredClone throws on proxies.
|
|
429
684
|
ports: JSON.parse(JSON.stringify(template.ports ?? [])) as GroupPort[],
|
|
430
685
|
}
|
|
431
|
-
|
|
432
|
-
...props.graph,
|
|
433
|
-
nodes: [...props.graph.nodes, node],
|
|
434
|
-
})
|
|
686
|
+
insertNode(node, at)
|
|
435
687
|
}
|
|
436
688
|
|
|
437
689
|
// Node creation is driven from the left BuilderPalette (in Editor.vue) — expose
|
|
438
690
|
// the two add helpers so the palette's events can reach the graph mutation.
|
|
439
691
|
defineExpose({ addNode, addTemplateInstance })
|
|
440
692
|
|
|
693
|
+
// A block dragged from the palette lands where it is dropped.
|
|
694
|
+
function onDragOver(event: DragEvent) {
|
|
695
|
+
if (props.readOnly || !event.dataTransfer?.types.includes(PALETTE_DRAG_TYPE)) return
|
|
696
|
+
event.preventDefault()
|
|
697
|
+
event.dataTransfer.dropEffect = 'copy'
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function onDrop(event: DragEvent) {
|
|
701
|
+
const raw = event.dataTransfer?.getData(PALETTE_DRAG_TYPE)
|
|
702
|
+
const flow = flowRef.value
|
|
703
|
+
if (props.readOnly || !raw || !flow) return
|
|
704
|
+
event.preventDefault()
|
|
705
|
+
const point = flow.screenToFlowCoordinate({ x: event.clientX, y: event.clientY })
|
|
706
|
+
const at = { x: point.x - NEW_NODE_SIZE.width / 2, y: point.y - NEW_NODE_SIZE.height / 2 }
|
|
707
|
+
const block = JSON.parse(raw) as PaletteBlock
|
|
708
|
+
if (block.template) addTemplateInstance(block.template, at)
|
|
709
|
+
else if (block.kind) addNode(block.kind, block.typeId, at)
|
|
710
|
+
}
|
|
711
|
+
|
|
441
712
|
// DmsFlowCanvas owns the VueFlow store (it calls `useVueFlow(flowId)` with a
|
|
442
713
|
// private id and `defineExpose`s the resulting controller). We grab that
|
|
443
714
|
// controller through a template ref instead of calling `useVueFlow()` here —
|
|
444
715
|
// a bare `useVueFlow()` would resolve to the DEFAULT store, which is NOT the
|
|
445
716
|
// one DmsFlowCanvas drives, so zoom/fit/updateNodeInternals would silently
|
|
446
717
|
// no-op. Only the handful of imperative methods we actually use are typed.
|
|
718
|
+
interface FlowNodeState {
|
|
719
|
+
id: string
|
|
720
|
+
selected?: boolean
|
|
721
|
+
computedPosition: XY
|
|
722
|
+
dimensions: { width: number; height: number }
|
|
723
|
+
}
|
|
447
724
|
interface FlowController {
|
|
448
725
|
zoomIn: () => void
|
|
449
726
|
zoomOut: () => void
|
|
450
|
-
fitView: () => void
|
|
451
727
|
zoomTo: (zoom: number) => void
|
|
728
|
+
setViewport: (viewport: XY & { zoom: number }, options?: { duration?: number }) => Promise<boolean>
|
|
729
|
+
screenToFlowCoordinate: (position: XY) => XY
|
|
730
|
+
findNode: (id: string) => FlowNodeState | undefined
|
|
731
|
+
addSelectedNodes: (nodes: FlowNodeState[]) => void
|
|
732
|
+
removeSelectedNodes: (nodes: FlowNodeState[]) => void
|
|
452
733
|
updateNodeInternals: (ids?: string | string[]) => void
|
|
453
734
|
// DmsFlowCanvas `defineExpose`s the VueFlow controller; Vue's expose proxy
|
|
454
735
|
// unwraps the `viewport` ref, so consumers read `.viewport.zoom` directly
|
|
455
736
|
// (NOT `.viewport.value.zoom` — that extra `.value` is undefined and pinned
|
|
456
|
-
// the zoom readout at 100%).
|
|
457
|
-
viewport: { zoom: number }
|
|
737
|
+
// the zoom readout at 100%). Same for the refs below.
|
|
738
|
+
viewport: XY & { zoom: number }
|
|
739
|
+
/** Size of the canvas on screen. */
|
|
740
|
+
dimensions: { width: number; height: number }
|
|
741
|
+
getSelectedNodes: FlowNodeState[]
|
|
742
|
+
getSelectedEdges: Array<{ id: string }>
|
|
743
|
+
/** 'invalid' while the link being drawn hovers a port that refuses it. */
|
|
744
|
+
connectionStatus: 'valid' | 'invalid' | null
|
|
458
745
|
}
|
|
459
746
|
const flowRef = ref<FlowController | null>(null)
|
|
747
|
+
const wrapRef = ref<HTMLElement | null>(null)
|
|
748
|
+
|
|
749
|
+
// The width of the canvas the inspector covers when it is drawn over it.
|
|
750
|
+
function coveredRight(): number {
|
|
751
|
+
const cover = props.coveredBy?.getBoundingClientRect()
|
|
752
|
+
const own = wrapRef.value?.getBoundingClientRect()
|
|
753
|
+
if (!cover?.width || !own) return 0
|
|
754
|
+
return Math.max(0, Math.min(own.right, cover.right) - Math.max(own.left, cover.left))
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// Fit every node into the part of the canvas left visible.
|
|
758
|
+
function fitView() {
|
|
759
|
+
const flow = flowRef.value
|
|
760
|
+
if (!flow) return
|
|
761
|
+
const nodes = props.graph.nodes
|
|
762
|
+
.map((n) => flow.findNode(n.id))
|
|
763
|
+
.filter((n): n is FlowNodeState => !!n?.dimensions.width)
|
|
764
|
+
if (nodes.length === 0) return
|
|
765
|
+
const left = Math.min(...nodes.map((n) => n.computedPosition.x))
|
|
766
|
+
const top = Math.min(...nodes.map((n) => n.computedPosition.y))
|
|
767
|
+
const width = Math.max(...nodes.map((n) => n.computedPosition.x + n.dimensions.width)) - left
|
|
768
|
+
const height = Math.max(...nodes.map((n) => n.computedPosition.y + n.dimensions.height)) - top
|
|
769
|
+
const visible = flow.dimensions.width - coveredRight()
|
|
770
|
+
const room = 1 + FIT_PADDING
|
|
771
|
+
const fit = Math.min(visible / (width * room), flow.dimensions.height / (height * room))
|
|
772
|
+
const zoom = Math.min(Math.max(fit, MIN_ZOOM), FIT_MAX_ZOOM)
|
|
773
|
+
flow.setViewport({
|
|
774
|
+
x: (visible - width * zoom) / 2 - left * zoom,
|
|
775
|
+
y: (flow.dimensions.height - height * zoom) / 2 - top * zoom,
|
|
776
|
+
zoom,
|
|
777
|
+
})
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
// Select a node and bring it into the visible part of the canvas. A node the
|
|
781
|
+
// editor points at (a link, a problem) is also shown at a readable zoom; a
|
|
782
|
+
// new node keeps the zoom.
|
|
783
|
+
function focusNode(id: string, readable = false) {
|
|
784
|
+
const flow = flowRef.value
|
|
785
|
+
const node = flow?.findNode(id)
|
|
786
|
+
if (!flow || !node) return
|
|
787
|
+
if (!node.selected) flow.addSelectedNodes([node])
|
|
788
|
+
// Selecting opens the inspector, which narrows or covers the canvas:
|
|
789
|
+
// look once it is drawn (two frames).
|
|
790
|
+
requestAnimationFrame(() => requestAnimationFrame(() => panTo(id, readable)))
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function panTo(id: string, readable: boolean) {
|
|
794
|
+
const flow = flowRef.value
|
|
795
|
+
const node = flow?.findNode(id)
|
|
796
|
+
if (!flow || !node) return
|
|
797
|
+
const visible = flow.dimensions.width - coveredRight()
|
|
798
|
+
const zoom = readable ? Math.max(flow.viewport.zoom, 1) : flow.viewport.zoom
|
|
799
|
+
const left = node.computedPosition.x * zoom + flow.viewport.x
|
|
800
|
+
const top = node.computedPosition.y * zoom + flow.viewport.y
|
|
801
|
+
const inSight =
|
|
802
|
+
left >= 0 &&
|
|
803
|
+
top >= 0 &&
|
|
804
|
+
left + node.dimensions.width * zoom <= visible &&
|
|
805
|
+
top + node.dimensions.height * zoom <= flow.dimensions.height
|
|
806
|
+
if (inSight && zoom === flow.viewport.zoom) return
|
|
807
|
+
flow.setViewport(
|
|
808
|
+
{
|
|
809
|
+
x: visible / 2 - (node.computedPosition.x + node.dimensions.width / 2) * zoom,
|
|
810
|
+
y: flow.dimensions.height / 2 - (node.computedPosition.y + node.dimensions.height / 2) * zoom,
|
|
811
|
+
zoom,
|
|
812
|
+
},
|
|
813
|
+
// A node pointed at is shown at once; a new one slides into view.
|
|
814
|
+
{ duration: readable ? 0 : 200 },
|
|
815
|
+
)
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// A new graph on the canvas (first load, another procedure, a group entered
|
|
819
|
+
// or left) is fitted into view; a node just added or pointed at is shown.
|
|
820
|
+
// Both wait until every node is measured and the panels around the canvas
|
|
821
|
+
// have settled (two frames): Vue Flow keeps the measures of nodes whose id
|
|
822
|
+
// the previous graph shared, so it does not always report them again.
|
|
823
|
+
let fitPending = true
|
|
824
|
+
let settleQueued = false
|
|
825
|
+
function settleView() {
|
|
826
|
+
if (settleQueued) return
|
|
827
|
+
settleQueued = true
|
|
828
|
+
requestAnimationFrame(() =>
|
|
829
|
+
requestAnimationFrame(() => {
|
|
830
|
+
settleQueued = false
|
|
831
|
+
const flow = flowRef.value
|
|
832
|
+
if (!flow || !props.graph.nodes.every((n) => flow.findNode(n.id)?.dimensions.width)) return
|
|
833
|
+
if (fitPending) {
|
|
834
|
+
fitPending = false
|
|
835
|
+
fitView()
|
|
836
|
+
// The node the editor points at stays the one shown.
|
|
837
|
+
if (props.selectedNodeId) revealPending ??= { id: props.selectedNodeId, readable: true }
|
|
838
|
+
}
|
|
839
|
+
if (revealPending) {
|
|
840
|
+
const { id, readable } = revealPending
|
|
841
|
+
revealPending = null
|
|
842
|
+
focusNode(id, readable)
|
|
843
|
+
}
|
|
844
|
+
}),
|
|
845
|
+
)
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
// Vue Flow emits this once every node on the canvas has been measured.
|
|
849
|
+
function onNodesInitialized() {
|
|
850
|
+
settleView()
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
watch(
|
|
854
|
+
() => props.viewKey,
|
|
855
|
+
() => {
|
|
856
|
+
fitPending = true
|
|
857
|
+
nextTick(settleView)
|
|
858
|
+
},
|
|
859
|
+
)
|
|
860
|
+
|
|
861
|
+
watch(
|
|
862
|
+
() => props.selectedNodeId,
|
|
863
|
+
(id) => {
|
|
864
|
+
const flow = flowRef.value
|
|
865
|
+
// The editor closed its inspector: the canvas lets go of the node too.
|
|
866
|
+
if (!id) {
|
|
867
|
+
if (flow?.getSelectedNodes.length) flow.removeSelectedNodes(flow.getSelectedNodes)
|
|
868
|
+
return
|
|
869
|
+
}
|
|
870
|
+
// A node selected on the canvas itself is already where the user looks.
|
|
871
|
+
if (flow?.findNode(id)?.selected) return
|
|
872
|
+
revealPending = { id, readable: true }
|
|
873
|
+
nextTick(settleView)
|
|
874
|
+
},
|
|
875
|
+
// The editor may name a node (a `?node=` link) before the canvas exists.
|
|
876
|
+
{ immediate: true },
|
|
877
|
+
)
|
|
460
878
|
|
|
461
879
|
// Vue Flow caches each node's handle bounding boxes in its internal store and
|
|
462
880
|
// only re-measures when `updateNodeInternals(id)` is called. When a port is
|
|
@@ -508,27 +926,12 @@ function resetZoom() {
|
|
|
508
926
|
flowRef.value?.zoomTo(1)
|
|
509
927
|
}
|
|
510
928
|
|
|
511
|
-
|
|
512
|
-
|
|
929
|
+
// The graph once `conn` is drawn, and the link it took the place of.
|
|
930
|
+
function withConnection(
|
|
931
|
+
graph: ProcedureGraph,
|
|
932
|
+
conn: Connection,
|
|
933
|
+
): { graph: ProcedureGraph; added: TriggerEdge | DataEdge; replaced?: TriggerEdge | DataEdge } | null {
|
|
513
934
|
const kind = connectionKind(conn.sourceHandle)
|
|
514
|
-
const result = canConnect(
|
|
515
|
-
props.graph,
|
|
516
|
-
props.nodeKinds,
|
|
517
|
-
props.triggerTypes,
|
|
518
|
-
props.actionTypes,
|
|
519
|
-
props.dataNodeTypes,
|
|
520
|
-
conn,
|
|
521
|
-
{ parentGroupPorts: props.parentGroupPorts },
|
|
522
|
-
)
|
|
523
|
-
if (!result.ok) {
|
|
524
|
-
toast.add({
|
|
525
|
-
title: 'Cannot connect',
|
|
526
|
-
description: result.reason,
|
|
527
|
-
color: 'warning',
|
|
528
|
-
icon: 'i-ph-warning',
|
|
529
|
-
})
|
|
530
|
-
return
|
|
531
|
-
}
|
|
532
935
|
if (kind === 'trigger') {
|
|
533
936
|
const branch = parseSourceBranch(conn.sourceHandle)
|
|
534
937
|
const toBranch = parseTargetBranch(conn.targetHandle)
|
|
@@ -543,48 +946,196 @@ function onConnect(conn: Connection) {
|
|
|
543
946
|
// Connecting again replaces any existing edge from that source/branch.
|
|
544
947
|
// (Branching across if/switch named branches still works because each
|
|
545
948
|
// branch has its own `from.branch` and only conflicts with itself.)
|
|
546
|
-
const
|
|
547
|
-
(e) =>
|
|
548
|
-
!(
|
|
549
|
-
e.from.node === conn.source &&
|
|
550
|
-
(e.from.branch ?? 'main') === branch
|
|
551
|
-
),
|
|
949
|
+
const replaced = graph.triggerEdges.find(
|
|
950
|
+
(e) => e.from.node === conn.source && (e.from.branch ?? 'main') === branch,
|
|
552
951
|
)
|
|
553
|
-
|
|
554
|
-
...
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
} else if (kind === 'data') {
|
|
558
|
-
const port = parseDataPort(conn.sourceHandle)
|
|
559
|
-
const field = parseDataField(conn.targetHandle)
|
|
560
|
-
if (!port || !field) return
|
|
561
|
-
const newEdge: DataEdge = {
|
|
562
|
-
id: newId(),
|
|
563
|
-
from: { node: conn.source, port },
|
|
564
|
-
to: { node: conn.target, field },
|
|
952
|
+
return {
|
|
953
|
+
graph: { ...graph, triggerEdges: [...graph.triggerEdges.filter((e) => e !== replaced), newEdge] },
|
|
954
|
+
added: newEdge,
|
|
955
|
+
replaced,
|
|
565
956
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
957
|
+
}
|
|
958
|
+
if (kind !== 'data') return null
|
|
959
|
+
const port = parseDataPort(conn.sourceHandle)
|
|
960
|
+
const field = parseDataField(conn.targetHandle)
|
|
961
|
+
if (!port || !field) return null
|
|
962
|
+
const newEdge: DataEdge = {
|
|
963
|
+
id: newId(),
|
|
964
|
+
from: { node: conn.source, port },
|
|
965
|
+
to: { node: conn.target, field },
|
|
966
|
+
}
|
|
967
|
+
// Overwrite: a field reads from one output only.
|
|
968
|
+
const replaced = graph.dataEdges.find((e) => e.to.node === conn.target && e.to.field === field)
|
|
969
|
+
return {
|
|
970
|
+
graph: { ...graph, dataEdges: [...graph.dataEdges.filter((e) => e !== replaced), newEdge] },
|
|
971
|
+
added: newEdge,
|
|
972
|
+
replaced,
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
function refusalText(result: ConnectResult): string {
|
|
977
|
+
return result.ok ? '' : t(`dms_automation.editor.canvas.connect.${result.code}`, result.params ?? {})
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// Undo of a replacement: the new link goes, the old one comes back — unless
|
|
981
|
+
// the new link is gone already, or an end of the old one was deleted since.
|
|
982
|
+
function restoreLink(added: TriggerEdge | DataEdge, old: TriggerEdge | DataEdge) {
|
|
983
|
+
const graph = props.graph
|
|
984
|
+
const ids = new Set(graph.nodes.map((n) => n.id))
|
|
985
|
+
const back = ids.has(old.from.node) && ids.has(old.to.node)
|
|
986
|
+
if ('port' in added.from) {
|
|
987
|
+
if (!graph.dataEdges.some((e) => e.id === added.id)) return
|
|
988
|
+
const edges = graph.dataEdges.filter((e) => e.id !== added.id)
|
|
989
|
+
emitGraph({ ...graph, dataEdges: back ? [...edges, old as DataEdge] : edges })
|
|
990
|
+
} else {
|
|
991
|
+
if (!graph.triggerEdges.some((e) => e.id === added.id)) return
|
|
992
|
+
const edges = graph.triggerEdges.filter((e) => e.id !== added.id)
|
|
993
|
+
emitGraph({ ...graph, triggerEdges: back ? [...edges, old as TriggerEdge] : edges })
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
// Drawing over an existing link replaces it: say which one, with an undo of
|
|
998
|
+
// that replacement only.
|
|
999
|
+
function notifyReplaced(added: TriggerEdge | DataEdge, old: TriggerEdge | DataEdge, conn: Connection) {
|
|
1000
|
+
let description: string
|
|
1001
|
+
if ('port' in old.from) {
|
|
1002
|
+
const port = parseDataPort(conn.sourceHandle)
|
|
1003
|
+
if (old.from.node === conn.source && old.from.port === port) return
|
|
1004
|
+
description = t('dms_automation.editor.canvas.replaced.data', {
|
|
1005
|
+
field: (old as DataEdge).to.field,
|
|
1006
|
+
step: menuName(conn.target),
|
|
1007
|
+
source: `${menuName(conn.source)} · ${port}`,
|
|
1008
|
+
previous: `${menuName(old.from.node)} · ${old.from.port}`,
|
|
1009
|
+
})
|
|
1010
|
+
} else {
|
|
1011
|
+
if (old.to.node === conn.target) return
|
|
1012
|
+
description = t('dms_automation.editor.canvas.replaced.trigger', {
|
|
1013
|
+
source: menuName(conn.source),
|
|
1014
|
+
target: menuName(conn.target),
|
|
1015
|
+
previous: menuName(old.to.node),
|
|
1016
|
+
})
|
|
1017
|
+
}
|
|
1018
|
+
toast.add({
|
|
1019
|
+
title: t('dms_automation.editor.canvas.replaced.title'),
|
|
1020
|
+
description,
|
|
1021
|
+
color: 'info',
|
|
1022
|
+
icon: 'i-ph-arrows-left-right',
|
|
1023
|
+
actions: [{ label: t('dms_automation.editor.canvas.undo'), onClick: () => restoreLink(added, old) }],
|
|
1024
|
+
})
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
function onConnect(conn: Connection) {
|
|
1028
|
+
if (props.readOnly) return
|
|
1029
|
+
const result = check(props.graph, conn)
|
|
1030
|
+
if (!result.ok) {
|
|
1031
|
+
toast.add({
|
|
1032
|
+
title: t('dms_automation.editor.canvas.connect.title'),
|
|
1033
|
+
description: refusalText(result),
|
|
1034
|
+
color: 'warning',
|
|
1035
|
+
icon: 'i-ph-warning',
|
|
574
1036
|
})
|
|
1037
|
+
return
|
|
575
1038
|
}
|
|
1039
|
+
const next = withConnection(props.graph, conn)
|
|
1040
|
+
if (!next) return
|
|
1041
|
+
emitGraph(next.graph)
|
|
1042
|
+
if (next.replaced) notifyReplaced(next.added, next.replaced, conn)
|
|
576
1043
|
}
|
|
577
1044
|
|
|
1045
|
+
// Why the port under a link being drawn refuses it, shown while it hovers.
|
|
1046
|
+
const refusal = ref('')
|
|
1047
|
+
const refusalShown = computed(() => flowRef.value?.connectionStatus === 'invalid' && refusal.value !== '')
|
|
1048
|
+
|
|
578
1049
|
function isValidConnection(conn: Connection): boolean {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
1050
|
+
const result = check(props.graph, conn)
|
|
1051
|
+
refusal.value = refusalText(result)
|
|
1052
|
+
return result.ok
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
// Released over a port that refuses the link: keep the reason on screen.
|
|
1056
|
+
function onConnectEnd() {
|
|
1057
|
+
if (refusalShown.value) {
|
|
1058
|
+
toast.add({
|
|
1059
|
+
title: t('dms_automation.editor.canvas.connect.title'),
|
|
1060
|
+
description: refusal.value,
|
|
1061
|
+
color: 'warning',
|
|
1062
|
+
icon: 'i-ph-warning',
|
|
1063
|
+
})
|
|
1064
|
+
}
|
|
1065
|
+
refusal.value = ''
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// Without a mouse: every link the selected step can make, from the canvas
|
|
1069
|
+
// toolbar (WCAG 2.5.7).
|
|
1070
|
+
|
|
1071
|
+
// Two steps with the same name are told apart by the end of their id (link
|
|
1072
|
+
// menu, replacement toast, links read aloud).
|
|
1073
|
+
function menuName(id: string): string {
|
|
1074
|
+
const name = nodeName(id)
|
|
1075
|
+
const twins = props.graph.nodes.filter((n) => nodeName(n.id) === name).length
|
|
1076
|
+
return twins > 1 ? `${name} #${id.slice(-4)}` : name
|
|
1077
|
+
}
|
|
1078
|
+
interface LinkItem {
|
|
1079
|
+
label: string
|
|
1080
|
+
connection: Connection
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
const linkGroups = computed(() => {
|
|
1084
|
+
const id = canvasSelection.value.length === 1 ? canvasSelection.value[0] : undefined
|
|
1085
|
+
const node = props.graph.nodes.find((n) => n.id === id)
|
|
1086
|
+
if (!node || props.readOnly) return []
|
|
1087
|
+
const mine = handlesOf(node)
|
|
1088
|
+
const next: LinkItem[] = []
|
|
1089
|
+
const send: LinkItem[] = []
|
|
1090
|
+
const read: LinkItem[] = []
|
|
1091
|
+
const wired = (target: string, field: string) =>
|
|
1092
|
+
props.graph.dataEdges.some((e) => e.to.node === target && e.to.field === field)
|
|
1093
|
+
const add = (into: LinkItem[], label: string, connection: Connection) => {
|
|
1094
|
+
if (check(props.graph, connection).ok) into.push({ label, connection })
|
|
1095
|
+
}
|
|
1096
|
+
for (const other of props.graph.nodes) {
|
|
1097
|
+
if (other.id === node.id) continue
|
|
1098
|
+
const theirs = handlesOf(other)
|
|
1099
|
+
const name = menuName(other.id)
|
|
1100
|
+
for (const out of mine.triggerOuts) {
|
|
1101
|
+
const current = props.graph.triggerEdges.find(
|
|
1102
|
+
(e) => e.from.node === node.id && (e.from.branch ?? 'main') === out.name,
|
|
1103
|
+
)
|
|
1104
|
+
if (current?.to.node === other.id) continue
|
|
1105
|
+
// The output already leads somewhere: the menu says what goes.
|
|
1106
|
+
const replaces = current ? ` (${t('dms_automation.editor.canvas.link.replaces', { name: menuName(current.to.node) })})` : ''
|
|
1107
|
+
for (const into of theirs.triggerIns) {
|
|
1108
|
+
const branch = out.name === 'main' ? '' : `${out.name} `
|
|
1109
|
+
const port = into.name && into.name !== 'main' ? ` · ${into.name}` : ''
|
|
1110
|
+
add(next, `${branch}→ ${name}${port}${replaces}`, { source: node.id, sourceHandle: out.id, target: other.id, targetHandle: into.id })
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
for (const out of mine.dataOuts) {
|
|
1114
|
+
for (const into of theirs.dataIns) {
|
|
1115
|
+
if (wired(other.id, into.name)) continue
|
|
1116
|
+
add(send, `${out.name} → ${name} · ${into.name}`, { source: node.id, sourceHandle: out.id, target: other.id, targetHandle: into.id })
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
for (const out of theirs.dataOuts) {
|
|
1120
|
+
for (const into of mine.dataIns) {
|
|
1121
|
+
if (wired(node.id, into.name)) continue
|
|
1122
|
+
add(read, `${name} · ${out.name} → ${into.name}`, { source: other.id, sourceHandle: out.id, target: node.id, targetHandle: into.id })
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
const group = (key: string, items: LinkItem[]) =>
|
|
1127
|
+
items.length ? [{ type: 'label' as const, label: t(`dms_automation.editor.canvas.link.${key}`) }, ...items] : []
|
|
1128
|
+
return [group('next', next), group('send', send), group('read', read)].filter((g) => g.length > 0)
|
|
1129
|
+
})
|
|
1130
|
+
|
|
1131
|
+
// The link menu is offered for a single selected step of an editable graph.
|
|
1132
|
+
const canLink = computed(() => !props.readOnly && canvasSelection.value.length === 1)
|
|
1133
|
+
|
|
1134
|
+
// The menu is an action, not a field: it never keeps a value.
|
|
1135
|
+
const linkChoice = ref<LinkItem | null>(null)
|
|
1136
|
+
function onLink(item: LinkItem | null) {
|
|
1137
|
+
if (item?.connection) onConnect(item.connection)
|
|
1138
|
+
linkChoice.value = null
|
|
588
1139
|
}
|
|
589
1140
|
|
|
590
1141
|
// Multi-selection tracking — Vue Flow emits one NodeSelectionChange per
|
|
@@ -594,6 +1145,9 @@ function isValidConnection(conn: Connection): boolean {
|
|
|
594
1145
|
// fold a sentinel into a new group). The single-node `select:node` event
|
|
595
1146
|
// is preserved for the inspector (it expects exactly one node id).
|
|
596
1147
|
const selectedNodeIds = new Set<string>()
|
|
1148
|
+
// The same set, reactive (sentinels included), for the toolbar's link menu
|
|
1149
|
+
// and the placement of new nodes.
|
|
1150
|
+
const canvasSelection = ref<string[]>([])
|
|
597
1151
|
|
|
598
1152
|
// Drop any tracked ids that no longer exist in the current graph (e.g.
|
|
599
1153
|
// after navigating to a different procedure / subgraph, or after the
|
|
@@ -617,6 +1171,7 @@ watch(
|
|
|
617
1171
|
const n = nodes.find((nn) => nn.id === id)
|
|
618
1172
|
return n ? !SENTINEL_KINDS.has(n.kind) : false
|
|
619
1173
|
})
|
|
1174
|
+
canvasSelection.value = [...selectedNodeIds]
|
|
620
1175
|
emit('selection-change', { ids })
|
|
621
1176
|
}
|
|
622
1177
|
},
|
|
@@ -634,10 +1189,13 @@ function onNodesChange(changes: NodeChange[]) {
|
|
|
634
1189
|
// can show node details; suppress position drag and delete.
|
|
635
1190
|
if (props.readOnly && c.type !== 'select') continue
|
|
636
1191
|
if (c.type === 'position' && c.position) {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
)
|
|
1192
|
+
// Positions are stored as whole pixels, and a click that moves a
|
|
1193
|
+
// node by less than one (a select, not a drag) changes nothing:
|
|
1194
|
+
// otherwise selecting a node would count as an unsaved change.
|
|
1195
|
+
const pos = { x: Math.round(c.position.x), y: Math.round(c.position.y) }
|
|
1196
|
+
const current = nextNodes.find((n) => n.id === c.id)
|
|
1197
|
+
if (current && current.position.x === pos.x && current.position.y === pos.y) continue
|
|
1198
|
+
nextNodes = nextNodes.map((n) => (n.id === c.id ? { ...n, position: pos } : n))
|
|
641
1199
|
changed = true
|
|
642
1200
|
} else if (c.type === 'remove') {
|
|
643
1201
|
// Sentinel nodes (groupInput / groupOutput) are auto-managed by
|
|
@@ -680,6 +1238,7 @@ function onNodesChange(changes: NodeChange[]) {
|
|
|
680
1238
|
const n = props.graph.nodes.find((nn) => nn.id === id)
|
|
681
1239
|
return n ? !SENTINEL_KINDS.has(n.kind) : false
|
|
682
1240
|
})
|
|
1241
|
+
canvasSelection.value = [...selectedNodeIds]
|
|
683
1242
|
emit('selection-change', { ids })
|
|
684
1243
|
}
|
|
685
1244
|
|
|
@@ -732,6 +1291,18 @@ function onEdgesChange(changes: EdgeChange[]) {
|
|
|
732
1291
|
}
|
|
733
1292
|
}
|
|
734
1293
|
|
|
1294
|
+
// The DMS canvas deletes the selected nodes on Delete / Backspace, not the
|
|
1295
|
+
// selected links: remove those here (a deleted node takes its links along).
|
|
1296
|
+
function onKeydown(event: KeyboardEvent) {
|
|
1297
|
+
if (props.readOnly || (event.key !== 'Delete' && event.key !== 'Backspace')) return
|
|
1298
|
+
const target = event.target
|
|
1299
|
+
if (target instanceof HTMLElement && (target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName))) return
|
|
1300
|
+
const flow = flowRef.value
|
|
1301
|
+
if (!flow || flow.getSelectedNodes.length > 0 || flow.getSelectedEdges.length === 0) return
|
|
1302
|
+
event.preventDefault()
|
|
1303
|
+
onEdgesChange(flow.getSelectedEdges.map((e) => ({ type: 'remove', id: e.id }) as EdgeChange))
|
|
1304
|
+
}
|
|
1305
|
+
|
|
735
1306
|
// Edge-update flow (drag an existing edge's endpoint to reattach or delete):
|
|
736
1307
|
// 1. @edge-update-start clears the success flag.
|
|
737
1308
|
// 2. @edge-update fires only if the user drops on a valid target — mark
|
|
@@ -818,7 +1389,11 @@ function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
|
|
|
818
1389
|
|
|
819
1390
|
<template>
|
|
820
1391
|
<div
|
|
821
|
-
|
|
1392
|
+
ref="wrapRef"
|
|
1393
|
+
class="graph-canvas-wrap @container relative w-full h-full border border-default rounded-lg overflow-hidden"
|
|
1394
|
+
@keydown="onKeydown"
|
|
1395
|
+
@dragover="onDragOver"
|
|
1396
|
+
@drop="onDrop"
|
|
822
1397
|
>
|
|
823
1398
|
<DmsFlowCanvas
|
|
824
1399
|
ref="flowRef"
|
|
@@ -832,7 +1407,12 @@ function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
|
|
|
832
1407
|
:elements-selectable="true"
|
|
833
1408
|
:edges-updatable="!readOnly"
|
|
834
1409
|
:deletable-nodes="!readOnly"
|
|
1410
|
+
:fit-view-on-init="false"
|
|
1411
|
+
:min-zoom="MIN_ZOOM"
|
|
1412
|
+
:max-zoom="MAX_ZOOM"
|
|
1413
|
+
@nodes-initialized="onNodesInitialized"
|
|
835
1414
|
@connect="onConnect"
|
|
1415
|
+
@connect-end="onConnectEnd"
|
|
836
1416
|
@nodes-change="onNodesChange"
|
|
837
1417
|
@delete-nodes="onDeleteNodes"
|
|
838
1418
|
@edges-change="onEdgesChange"
|
|
@@ -841,90 +1421,96 @@ function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
|
|
|
841
1421
|
@edge-update-end="onEdgeUpdateEnd"
|
|
842
1422
|
@node-double-click="onNodeDoubleClick"
|
|
843
1423
|
>
|
|
844
|
-
<!--
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
class="flex items-center gap-1 rounded-lg border border-default bg-elevated p-1 shadow-md flex-wrap"
|
|
852
|
-
>
|
|
853
|
-
<UButton
|
|
854
|
-
size="sm"
|
|
855
|
-
variant="ghost"
|
|
856
|
-
color="neutral"
|
|
857
|
-
icon="i-ph-arrow-counter-clockwise"
|
|
858
|
-
:aria-label="$t('dms_automation.editor.canvas.undo')"
|
|
859
|
-
:disabled="!canUndo"
|
|
860
|
-
@click="emit('undo')"
|
|
861
|
-
/>
|
|
862
|
-
<UButton
|
|
863
|
-
size="sm"
|
|
864
|
-
variant="ghost"
|
|
865
|
-
color="neutral"
|
|
866
|
-
icon="i-ph-arrow-clockwise"
|
|
867
|
-
:aria-label="$t('dms_automation.editor.canvas.redo')"
|
|
868
|
-
:disabled="!canRedo"
|
|
869
|
-
@click="emit('redo')"
|
|
870
|
-
/>
|
|
871
|
-
<!-- Group-related actions slotted in by Editor.vue: Group
|
|
872
|
-
selection, Save as template, Fork to local group, Enter
|
|
873
|
-
group. Kept inside the canvas toolbar so they sit next
|
|
874
|
-
to Add Node / Undo / Redo instead of in a separate card. -->
|
|
875
|
-
<template v-if="$slots.groupActions">
|
|
876
|
-
<div class="w-px h-5 bg-default mx-1" />
|
|
877
|
-
<slot name="groupActions" />
|
|
878
|
-
</template>
|
|
879
|
-
<div class="mx-1 h-5 w-px bg-default" />
|
|
880
|
-
<UButton
|
|
881
|
-
size="sm"
|
|
882
|
-
variant="ghost"
|
|
883
|
-
color="neutral"
|
|
884
|
-
:label="$t('dms_automation.editor.canvas.cancel')"
|
|
885
|
-
:disabled="!isDirty || applying"
|
|
886
|
-
@click="emit('cancel')"
|
|
887
|
-
/>
|
|
888
|
-
<UButton
|
|
889
|
-
size="sm"
|
|
890
|
-
color="primary"
|
|
891
|
-
:label="$t('dms_automation.editor.canvas.apply')"
|
|
892
|
-
:disabled="!isDirty"
|
|
893
|
-
:loading="applying"
|
|
894
|
-
@click="emit('apply')"
|
|
895
|
-
/>
|
|
896
|
-
</div>
|
|
897
|
-
<!-- Read-only fallback: Fork stays reachable from the
|
|
898
|
-
template-instance inner-subgraph view. -->
|
|
899
|
-
<div
|
|
900
|
-
v-else-if="$slots.groupActions"
|
|
901
|
-
class="flex items-center gap-1 rounded-lg border border-default bg-elevated p-1 shadow-md flex-wrap"
|
|
902
|
-
>
|
|
903
|
-
<slot name="groupActions" />
|
|
904
|
-
</div>
|
|
905
|
-
</template>
|
|
906
|
-
|
|
907
|
-
<!-- The #top-left slot is provided UNCONDITIONALLY (inner v-if gates
|
|
908
|
-
the content). DmsFlowCanvas computes its active panel positions
|
|
909
|
-
once from a non-reactive useSlots() snapshot, so a panel slot
|
|
910
|
-
added later (e.g. when a node is first selected) would never
|
|
911
|
-
render. Providing it from first render keeps the inspector panel
|
|
912
|
-
alive; it just shows nothing until a node is selected. The real
|
|
913
|
-
fix belongs upstream in DmsFlowCanvas (make panel detection
|
|
914
|
-
reactive); this is a consumer workaround. -->
|
|
1424
|
+
<!-- One row along the top edge: the breadcrumb (shrinks, truncated by
|
|
1425
|
+
its owner) and the toolbar (Undo / Redo, the link menu and the
|
|
1426
|
+
selection's group actions; saving lives in the editor's bar). A
|
|
1427
|
+
read-only template-instance view keeps only the group actions
|
|
1428
|
+
(Fork). The row lets pointer events through between the two.
|
|
1429
|
+
Provided unconditionally: DmsFlowCanvas reads its panel slots
|
|
1430
|
+
once, so a slot added later would never render. -->
|
|
915
1431
|
<template #top-left>
|
|
916
|
-
<div
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
1432
|
+
<div class="pointer-events-none flex w-[calc(100cqw-1.5rem)] items-start justify-between gap-2">
|
|
1433
|
+
<!-- The breadcrumb takes what the toolbar leaves (6rem at least),
|
|
1434
|
+
the toolbar wraps only past that. -->
|
|
1435
|
+
<div class="min-w-24 flex-1 basis-0">
|
|
1436
|
+
<div class="pointer-events-auto w-fit max-w-full">
|
|
1437
|
+
<slot name="breadcrumb" />
|
|
1438
|
+
</div>
|
|
1439
|
+
</div>
|
|
1440
|
+
<div
|
|
1441
|
+
v-if="canLink || $slots.groupActions"
|
|
1442
|
+
class="pointer-events-auto flex min-w-0 flex-wrap items-center justify-end gap-1 rounded-lg border border-default bg-elevated p-1 shadow-md"
|
|
1443
|
+
>
|
|
1444
|
+
<template v-if="canLink">
|
|
1445
|
+
<!-- Links the selected step can make, for keyboard users: an
|
|
1446
|
+
icon, so the row stays on one line. -->
|
|
1447
|
+
<UTooltip :text="$t('dms_automation.editor.canvas.link.label')">
|
|
1448
|
+
<USelectMenu
|
|
1449
|
+
:model-value="linkChoice"
|
|
1450
|
+
:items="linkGroups"
|
|
1451
|
+
size="sm"
|
|
1452
|
+
variant="ghost"
|
|
1453
|
+
icon="i-ph-flow-arrow"
|
|
1454
|
+
:aria-label="$t('dms_automation.editor.canvas.link.label')"
|
|
1455
|
+
:search-input="{ placeholder: $t('dms_automation.editor.canvas.link.search') }"
|
|
1456
|
+
:content="{ align: 'end' }"
|
|
1457
|
+
:ui="{ content: 'min-w-72', base: 'ps-1.5 pe-1.5', leading: 'static p-0', placeholder: 'hidden', trailing: 'hidden' }"
|
|
1458
|
+
@update:model-value="onLink"
|
|
1459
|
+
>
|
|
1460
|
+
<template #empty>
|
|
1461
|
+
{{ $t('dms_automation.editor.canvas.link.empty') }}
|
|
1462
|
+
</template>
|
|
1463
|
+
</USelectMenu>
|
|
1464
|
+
</UTooltip>
|
|
1465
|
+
<div v-if="$slots.groupActions" class="mx-1 h-5 w-px bg-default" />
|
|
1466
|
+
</template>
|
|
1467
|
+
<!-- Group-related actions slotted in by Editor.vue: Group
|
|
1468
|
+
selection, Save as template, Fork to local group, Enter
|
|
1469
|
+
group. -->
|
|
1470
|
+
<slot name="groupActions" />
|
|
1471
|
+
</div>
|
|
921
1472
|
</div>
|
|
922
1473
|
</template>
|
|
923
1474
|
|
|
924
1475
|
<template #bottom-center>
|
|
1476
|
+
<p
|
|
1477
|
+
v-if="refusalShown"
|
|
1478
|
+
role="status"
|
|
1479
|
+
class="mx-auto mb-2 flex w-fit max-w-sm items-center gap-1.5 rounded-md border border-warning/40 bg-elevated px-2 py-1 text-xs text-warning shadow-md"
|
|
1480
|
+
>
|
|
1481
|
+
<UIcon name="i-ph-prohibit" class="size-3.5 shrink-0" />
|
|
1482
|
+
{{ refusal }}
|
|
1483
|
+
</p>
|
|
925
1484
|
<div
|
|
926
|
-
class="flex items-center gap-1 rounded-lg border border-default bg-elevated p-1 shadow-md"
|
|
1485
|
+
class="mx-auto flex w-fit items-center gap-1 rounded-lg border border-default bg-elevated p-1 shadow-md"
|
|
927
1486
|
>
|
|
1487
|
+
<!-- Undo / Redo sit with the view controls, leaving the top row
|
|
1488
|
+
to the selection's actions. -->
|
|
1489
|
+
<template v-if="!readOnly">
|
|
1490
|
+
<UTooltip :text="$t('dms_automation.editor.canvas.undo')" :kbds="['meta', 'z']">
|
|
1491
|
+
<UButton
|
|
1492
|
+
size="sm"
|
|
1493
|
+
variant="ghost"
|
|
1494
|
+
color="neutral"
|
|
1495
|
+
icon="i-ph-arrow-counter-clockwise"
|
|
1496
|
+
:aria-label="$t('dms_automation.editor.canvas.undo')"
|
|
1497
|
+
:disabled="!canUndo"
|
|
1498
|
+
@click="emit('undo')"
|
|
1499
|
+
/>
|
|
1500
|
+
</UTooltip>
|
|
1501
|
+
<UTooltip :text="$t('dms_automation.editor.canvas.redo')" :kbds="['meta', 'shift', 'z']">
|
|
1502
|
+
<UButton
|
|
1503
|
+
size="sm"
|
|
1504
|
+
variant="ghost"
|
|
1505
|
+
color="neutral"
|
|
1506
|
+
icon="i-ph-arrow-clockwise"
|
|
1507
|
+
:aria-label="$t('dms_automation.editor.canvas.redo')"
|
|
1508
|
+
:disabled="!canRedo"
|
|
1509
|
+
@click="emit('redo')"
|
|
1510
|
+
/>
|
|
1511
|
+
</UTooltip>
|
|
1512
|
+
<div class="mx-1 h-5 w-px bg-default" />
|
|
1513
|
+
</template>
|
|
928
1514
|
<UButton
|
|
929
1515
|
size="sm"
|
|
930
1516
|
variant="ghost"
|
|
@@ -956,7 +1542,7 @@ function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
|
|
|
956
1542
|
color="neutral"
|
|
957
1543
|
icon="i-ph-arrows-out"
|
|
958
1544
|
:aria-label="$t('dms_automation.editor.canvas.fitView')"
|
|
959
|
-
@click="
|
|
1545
|
+
@click="fitView"
|
|
960
1546
|
/>
|
|
961
1547
|
</div>
|
|
962
1548
|
</template>
|
|
@@ -965,33 +1551,59 @@ function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
|
|
|
965
1551
|
</template>
|
|
966
1552
|
|
|
967
1553
|
<style>
|
|
968
|
-
/*
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1554
|
+
/* The top row spans the canvas: between the breadcrumb and the toolbar, the
|
|
1555
|
+
pane under it stays draggable. Vue Flow sets the panel's pointer-events
|
|
1556
|
+
inline, hence the !important. */
|
|
1557
|
+
.graph-canvas-wrap .vue-flow__panel.top.left {
|
|
1558
|
+
pointer-events: none !important;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
/* Ports keep their small dot but take a 24px target (WCAG 2.5.8). */
|
|
1562
|
+
.dms-automation-node .vue-flow__handle::before {
|
|
1563
|
+
content: '';
|
|
1564
|
+
position: absolute;
|
|
1565
|
+
inset: -8px;
|
|
1566
|
+
border-radius: 9999px;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
/* Trigger edges (control flow) take the info role, data edges the success
|
|
1570
|
+
role, dashed; theme tokens only (AU-15). The `.edge-*` class out-specifies
|
|
1571
|
+
DmsFlowCanvas's generic `.vue-flow__edge-path` rule. */
|
|
973
1572
|
.vue-flow__edge.edge-trigger .vue-flow__edge-path {
|
|
974
|
-
stroke:
|
|
1573
|
+
stroke: var(--ui-info);
|
|
975
1574
|
stroke-width: 2;
|
|
976
1575
|
}
|
|
977
1576
|
|
|
978
1577
|
.vue-flow__edge.edge-data .vue-flow__edge-path {
|
|
979
|
-
stroke:
|
|
1578
|
+
stroke: var(--ui-success);
|
|
980
1579
|
stroke-width: 2;
|
|
981
1580
|
stroke-dasharray: 4 4;
|
|
982
1581
|
}
|
|
983
1582
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1583
|
+
.vue-flow__edge.edge-trigger.edge-taken .vue-flow__edge-path {
|
|
1584
|
+
stroke: var(--ui-success);
|
|
1585
|
+
stroke-width: 2.5;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
.vue-flow__edge.edge-trigger.edge-failed .vue-flow__edge-path {
|
|
1589
|
+
stroke: var(--ui-error);
|
|
1590
|
+
stroke-width: 2.5;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
.vue-flow__edge.edge-trigger.edge-idle .vue-flow__edge-path {
|
|
1594
|
+
opacity: 0.35;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
/* Selected / focused edge highlight. The doubled `.edge-*` class lifts
|
|
1598
|
+
specificity above DmsFlowCanvas's own selected rule, which would repaint the
|
|
1599
|
+
edge in the accent and erase the trigger-vs-data distinction. */
|
|
988
1600
|
.vue-flow__edge.edge-trigger.selected .vue-flow__edge-path,
|
|
989
1601
|
.vue-flow__edge.edge-data.selected .vue-flow__edge-path,
|
|
990
1602
|
.vue-flow__edge.edge-trigger:focus .vue-flow__edge-path,
|
|
991
1603
|
.vue-flow__edge.edge-data:focus .vue-flow__edge-path,
|
|
992
1604
|
.vue-flow__edge.edge-trigger:focus-visible .vue-flow__edge-path,
|
|
993
1605
|
.vue-flow__edge.edge-data:focus-visible .vue-flow__edge-path {
|
|
994
|
-
stroke:
|
|
1606
|
+
stroke: var(--ui-warning);
|
|
995
1607
|
stroke-width: 3;
|
|
996
1608
|
}
|
|
997
1609
|
</style>
|