@conduction/nextcloud-vue 2.56.0-beta.74 → 2.56.0-beta.75

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.
Files changed (106) hide show
  1. package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue.js +1 -1
  2. package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue2.js +12 -1
  3. package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue2.js.map +1 -1
  4. package/dist/esm/components/CnBuildiqEditButton/CnBuildiqEditButton.vue3.js.map +1 -1
  5. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue.js +1 -1
  6. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js +10 -8
  7. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js.map +1 -1
  8. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js +95 -88
  9. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js.map +1 -1
  10. package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue.js +1 -1
  11. package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue2.js +86 -8
  12. package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue2.js.map +1 -1
  13. package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue3.js +137 -121
  14. package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue3.js.map +1 -1
  15. package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue.js +1 -1
  16. package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue2.js +56 -4
  17. package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue2.js.map +1 -1
  18. package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue3.js +166 -70
  19. package/dist/esm/components/CnFlowDetail/CnFlowDryRunResult.vue3.js.map +1 -1
  20. package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue.js +9 -0
  21. package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue.js.map +1 -0
  22. package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue2.js +123 -0
  23. package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue2.js.map +1 -0
  24. package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue3.js +268 -0
  25. package/dist/esm/components/CnFlowDetail/CnFlowStepList.vue3.js.map +1 -0
  26. package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue.js +9 -0
  27. package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue.js.map +1 -0
  28. package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue2.js +49 -0
  29. package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue2.js.map +1 -0
  30. package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue3.js +41 -0
  31. package/dist/esm/components/CnFlowDetail/CnFlowViewSwitch.vue3.js.map +1 -0
  32. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue.js +1 -1
  33. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js +116 -8
  34. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js.map +1 -1
  35. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js +110 -58
  36. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js.map +1 -1
  37. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js +78 -1
  38. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue2.js.map +1 -1
  39. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js +44 -3
  40. package/dist/esm/components/CnFlowsPage/CnFlowEditorPage.vue3.js.map +1 -1
  41. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +90 -75
  42. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  43. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +46 -22
  44. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  45. package/dist/esm/composables/indexSources.js +24 -4
  46. package/dist/esm/composables/indexSources.js.map +1 -1
  47. package/dist/esm/composables/useFlowStore.js +75 -4
  48. package/dist/esm/composables/useFlowStore.js.map +1 -1
  49. package/dist/esm/dialogs/CnFlowEdgeEditModal.vue.js +1 -1
  50. package/dist/esm/dialogs/CnFlowEdgeEditModal.vue2.js +17 -0
  51. package/dist/esm/dialogs/CnFlowEdgeEditModal.vue2.js.map +1 -1
  52. package/dist/esm/dialogs/CnFlowEdgeEditModal.vue3.js +9 -1
  53. package/dist/esm/dialogs/CnFlowEdgeEditModal.vue3.js.map +1 -1
  54. package/dist/esm/dialogs/CnFlowEditModal.vue.js +1 -1
  55. package/dist/esm/dialogs/CnFlowEditModal.vue2.js +15 -0
  56. package/dist/esm/dialogs/CnFlowEditModal.vue2.js.map +1 -1
  57. package/dist/esm/dialogs/CnFlowEditModal.vue3.js +13 -3
  58. package/dist/esm/dialogs/CnFlowEditModal.vue3.js.map +1 -1
  59. package/dist/esm/dialogs/CnFlowStepPickerModal.vue.js +1 -1
  60. package/dist/esm/dialogs/CnFlowStepPickerModal.vue2.js +13 -1
  61. package/dist/esm/dialogs/CnFlowStepPickerModal.vue2.js.map +1 -1
  62. package/dist/esm/dialogs/CnFlowStepPickerModal.vue3.js.map +1 -1
  63. package/dist/esm/index.js +2 -0
  64. package/dist/esm/index.js.map +1 -1
  65. package/dist/esm/l10n/en.json.js +40 -1
  66. package/dist/esm/l10n/en.json.js.map +1 -1
  67. package/dist/esm/l10n/nl.json.js +39 -1
  68. package/dist/esm/l10n/nl.json.js.map +1 -1
  69. package/dist/esm/library-style.js +1 -1
  70. package/dist/esm/nextcloud-vue.css +566 -337
  71. package/dist/esm/utils/dialogWidths.js +6 -4
  72. package/dist/esm/utils/dialogWidths.js.map +1 -1
  73. package/dist/esm/utils/flowCondition.js +177 -0
  74. package/dist/esm/utils/flowCondition.js.map +1 -0
  75. package/dist/esm/utils/flowRunStatus.js +64 -1
  76. package/dist/esm/utils/flowRunStatus.js.map +1 -1
  77. package/dist/esm/utils/flowStepList.js +385 -0
  78. package/dist/esm/utils/flowStepList.js.map +1 -0
  79. package/dist/nextcloud-vue.cjs.js +12543 -10668
  80. package/dist/nextcloud-vue.cjs.js.map +2 -2
  81. package/dist/nextcloud-vue.css +566 -337
  82. package/l10n/en.json +40 -1
  83. package/l10n/nl.json +39 -1
  84. package/package.json +1 -1
  85. package/src/components/CnBuildiqEditButton/CnBuildiqEditButton.vue +12 -1
  86. package/src/components/CnCellRenderer/CnCellRenderer.vue +8 -0
  87. package/src/components/CnFlowDetail/CnFlowDetail.vue +110 -12
  88. package/src/components/CnFlowDetail/CnFlowDryRunResult.vue +163 -5
  89. package/src/components/CnFlowDetail/CnFlowStepList.vue +408 -0
  90. package/src/components/CnFlowDetail/CnFlowViewSwitch.vue +117 -0
  91. package/src/components/CnFlowDetail/index.js +2 -0
  92. package/src/components/CnFlowsPage/CnFlowBoard.vue +182 -25
  93. package/src/components/CnFlowsPage/CnFlowEditorPage.vue +101 -3
  94. package/src/components/CnIndexPage/CnIndexPage.vue +29 -0
  95. package/src/components/index.js +1 -1
  96. package/src/composables/indexSources.js +24 -4
  97. package/src/composables/useFlowStore.js +75 -4
  98. package/src/css/index-page.css +4 -0
  99. package/src/dialogs/CnFlowEdgeEditModal.vue +28 -0
  100. package/src/dialogs/CnFlowEditModal.vue +26 -6
  101. package/src/dialogs/CnFlowStepPickerModal.vue +13 -1
  102. package/src/index.js +2 -0
  103. package/src/utils/dialogWidths.js +6 -4
  104. package/src/utils/flowCondition.js +173 -0
  105. package/src/utils/flowRunStatus.js +63 -0
  106. package/src/utils/flowStepList.js +381 -0
@@ -0,0 +1,381 @@
1
+ /**
2
+ * SPDX-License-Identifier: EUPL-1.2
3
+ * SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
4
+ */
5
+
6
+ import { translate as t } from '@nextcloud/l10n'
7
+
8
+ /**
9
+ * The list reading of a flow: the trigger, then the steps in run order.
10
+ *
11
+ * Nothing here is stored. The rows are derived from the flow document the
12
+ * canvas draws and every change goes back into that document, so the two views
13
+ * cannot drift.
14
+ *
15
+ * A `graph` is `{ nodes, lines, startIds, roleOf }`: the document's nodes, the
16
+ * store's `canvasEdges`, its `startNodeIds` and its `roleOfNodeType`.
17
+ */
18
+
19
+ /**
20
+ * @param {object} node A flow node.
21
+ * @return {{x: number, y: number}} Where it stands on the canvas.
22
+ */
23
+ function placeOf(node) {
24
+ return { x: node.position?.x ?? node.x ?? 0, y: node.position?.y ?? node.y ?? 0 }
25
+ }
26
+
27
+ /**
28
+ * @param {Array<object>} lines The lines.
29
+ * @param {string} key `source` or `target`.
30
+ * @return {Map<string, Array<object>>} The lines by that end.
31
+ */
32
+ function linesBy(lines, key) {
33
+ const grouped = new Map()
34
+ lines.forEach((line) => grouped.set(line[key], [...(grouped.get(line[key]) || []), line]))
35
+
36
+ return grouped
37
+ }
38
+
39
+ /**
40
+ * The lines that lead onward from the starts. A line back into a step still
41
+ * open is a loop, and a loop has no order to contribute.
42
+ *
43
+ * @param {object} graph The graph.
44
+ * @param graph.lines
45
+ * @param graph.startIds
46
+ * @return {Array<object>} The lines without those going back.
47
+ */
48
+ function forwardLines({ lines, startIds }) {
49
+ const outgoing = linesBy(lines, 'source')
50
+ const seen = new Map()
51
+ const kept = []
52
+ const visit = (id) => {
53
+ seen.set(id, 'open')
54
+ for (const line of outgoing.get(id) || []) {
55
+ if (seen.get(line.target) !== 'open') {
56
+ kept.push(line)
57
+ }
58
+ if (!seen.has(line.target)) {
59
+ visit(line.target)
60
+ }
61
+ }
62
+ seen.set(id, 'done')
63
+ }
64
+ startIds.filter((id) => !seen.has(id)).forEach(visit)
65
+
66
+ return kept
67
+ }
68
+
69
+ /**
70
+ * How many steps deep each reached node is, by its longest way in.
71
+ *
72
+ * @param {object} graph The graph.
73
+ * @return {Map<string, number>} The depth per node id; a loose node has none.
74
+ */
75
+ function depths(graph) {
76
+ const lines = forwardLines(graph)
77
+ const depth = new Map(graph.startIds.map((id) => [id, 0]))
78
+ const deepen = ({ source, target }) => {
79
+ if (depth.has(source) && (depth.get(target) ?? -1) <= depth.get(source)) {
80
+ depth.set(target, depth.get(source) + 1)
81
+ }
82
+ }
83
+ graph.nodes.forEach(() => lines.forEach(deepen))
84
+
85
+ return depth
86
+ }
87
+
88
+ /**
89
+ * The nodes in run order: by depth, then top to bottom and left to right as
90
+ * they stand on the canvas. Nodes nothing leads to come last.
91
+ *
92
+ * @param {object} graph The graph.
93
+ * @return {Array<{node: object, loose: boolean}>} The ordered nodes.
94
+ */
95
+ export function orderFlowNodes(graph) {
96
+ const depth = depths(graph)
97
+ const entries = graph.nodes.map((node, index) => ({
98
+ node,
99
+ index,
100
+ loose: !depth.has(node.id),
101
+ depth: depth.get(node.id) ?? Infinity,
102
+ ...placeOf(node),
103
+ }))
104
+ const byDepth = (a, b) => (a.loose === b.loose ? (a.loose ? 0 : a.depth - b.depth) : (a.loose ? 1 : -1))
105
+
106
+ return entries.sort((a, b) => byDepth(a, b) || a.y - b.y || a.x - b.x || a.index - b.index)
107
+ }
108
+
109
+ /**
110
+ * @param {object} line A drawn line.
111
+ * @return {string} When it is taken: its name, else its condition in words.
112
+ */
113
+ function lineText(line) {
114
+ return line.data?.label || line.data?.conditionText || ''
115
+ }
116
+
117
+ /**
118
+ * The chip on a step: when the line into it is taken. A plain line in means
119
+ * the step is reached regardless, so there is no condition to name.
120
+ *
121
+ * @param {Array<object>} into The lines into the step.
122
+ * @return {string} The chip's text, or ''.
123
+ */
124
+ function whenText(into) {
125
+ const texts = into.map(lineText)
126
+ if (texts.length === 0 || texts.includes('')) {
127
+ return ''
128
+ }
129
+ if (into.every((line) => !line.data?.label && !line.data?.condition)) {
130
+ return texts[0]
131
+ }
132
+
133
+ return t('nextcloud-vue', 'Only if {condition}', { condition: texts.join(` ${t('nextcloud-vue', 'or')} `) })
134
+ }
135
+
136
+ /**
137
+ * @param {object} graph The graph.
138
+ * @param {string} id A node id.
139
+ * @return {{into: Array<object>, out: Array<object>}} The lines of that node.
140
+ */
141
+ function linesOf(graph, id) {
142
+ return {
143
+ into: graph.lines.filter((line) => line.target === id),
144
+ out: graph.lines.filter((line) => line.source === id),
145
+ }
146
+ }
147
+
148
+ /**
149
+ * @param {object} node A node.
150
+ * @return {boolean} Whether it routes through declared exits.
151
+ */
152
+ function branches(node) {
153
+ return Array.isArray(node.exits) && node.exits.length > 0
154
+ }
155
+
156
+ /**
157
+ * @param {object} graph The graph.
158
+ * @param {object} node A node.
159
+ * @return {boolean} Whether it may trade places with a neighbour.
160
+ */
161
+ function isMovable(graph, node) {
162
+ return !branches(node) && !node.start && !node.initial && graph.roleOf(node.type) === 'step'
163
+ }
164
+
165
+ /**
166
+ * Whether two neighbours in the list are a plain link of one chain: only then
167
+ * does swapping them mean what the arrows promise. Steps on a branch keep their
168
+ * place until the canvas moves them.
169
+ *
170
+ * @param {object} graph The graph.
171
+ * @param {Array<object>} pair The first and the second node.
172
+ * @return {boolean} Whether they can swap.
173
+ */
174
+ function canSwap(graph, [first, second]) {
175
+ if (!isMovable(graph, first) || !isMovable(graph, second)) {
176
+ return false
177
+ }
178
+ const { out } = linesOf(graph, first.id)
179
+ const { into, out: onward } = linesOf(graph, second.id)
180
+
181
+ return out.length === 1 && out[0].target === second.id && into.length === 1 && onward.length <= 1
182
+ }
183
+
184
+ /**
185
+ * @param {object} graph The graph.
186
+ * @return {Array<object>} The steps in order, triggers left out.
187
+ */
188
+ function orderedSteps(graph) {
189
+ return orderFlowNodes(graph).filter(({ node }) => graph.roleOf(node.type) !== 'trigger')
190
+ }
191
+
192
+ /**
193
+ * The two steps a move would swap.
194
+ *
195
+ * @param {object} graph The graph.
196
+ * @param {{id: string, by: number}} move The step and -1 (up) or 1 (down).
197
+ * @return {Array<string>|null} Their ids, first in the list first; null when the move cannot be made.
198
+ */
199
+ export function flowStepSwap(graph, { id, by }) {
200
+ const steps = orderedSteps(graph).map((entry) => entry.node)
201
+ const index = steps.findIndex((node) => node.id === id)
202
+ const pair = by < 0 ? [steps[index - 1], steps[index]] : [steps[index], steps[index + 1]]
203
+ if (index < 0 || !pair[0] || !pair[1]) {
204
+ return null
205
+ }
206
+
207
+ return canSwap(graph, pair) ? pair.map((node) => node.id) : null
208
+ }
209
+
210
+ /**
211
+ * Where a step's lines lead, as the routes under a branching step.
212
+ *
213
+ * @param {Array<object>} out The step's outgoing lines.
214
+ * @param {object} names `{ numbers, titleOf }`: step numbers by id and a name fallback.
215
+ * @param names.numbers
216
+ * @param names.titleOf
217
+ * @return {Array<{id: string, label: string, to: string}>} The routes; none when it does not branch.
218
+ */
219
+ function routesOf(out, { numbers, titleOf }) {
220
+ if (out.length < 2) {
221
+ return []
222
+ }
223
+
224
+ return out.map((line) => ({
225
+ id: line.id,
226
+ label: lineText(line) || t('nextcloud-vue', 'Otherwise'),
227
+ to: numbers.has(line.target) ? t('nextcloud-vue', 'Step {n}', { n: numbers.get(line.target) }) : titleOf(line.target),
228
+ }))
229
+ }
230
+
231
+ /**
232
+ * @param {object} graph The graph.
233
+ * @param {object} names `{ numbers, titleOf }`: step numbers by id and a name by node.
234
+ * @return {(entry: {node: object, loose: boolean}) => object} Builds one row.
235
+ */
236
+ function rowBuilder(graph, names) {
237
+ return ({ node, loose }) => {
238
+ const { into, out } = linesOf(graph, node.id)
239
+
240
+ return { id: node.id, node, role: graph.roleOf(node.type), loose, n: names.numbers.get(node.id), when: whenText(into), routes: routesOf(out, names) }
241
+ }
242
+ }
243
+
244
+ /**
245
+ * The rows of the list.
246
+ *
247
+ * @param {object} graph The graph.
248
+ * @param {(node: object) => string} titleOf The name a node goes by.
249
+ * @return {{triggers: Array<object>, steps: Array<object>}} The rows.
250
+ */
251
+ export function flowStepRows(graph, titleOf) {
252
+ const ordered = orderFlowNodes(graph)
253
+ const steps = ordered.filter(({ node }) => graph.roleOf(node.type) !== 'trigger')
254
+ const numbers = new Map(steps.map(({ node }, index) => [node.id, index + 1]))
255
+ const row = rowBuilder(graph, { numbers, titleOf: (id) => titleOf(graph.nodes.find((node) => node.id === id) || { id }) })
256
+ const swaps = (index) => index >= 0 && index + 1 < steps.length && canSwap(graph, [steps[index].node, steps[index + 1].node])
257
+
258
+ return {
259
+ triggers: ordered.filter(({ node }) => graph.roleOf(node.type) === 'trigger').map(row),
260
+ steps: steps.map((entry, index) => ({ ...row(entry), canMoveUp: swaps(index - 1), canMoveDown: swaps(index) })),
261
+ }
262
+ }
263
+
264
+ /**
265
+ * @param {string|Array<string>} value An edge endpoint, one id or a list.
266
+ * @param {(id: string) => string} change What becomes of an id.
267
+ * @return {string|Array<string>} The endpoint with the ids changed.
268
+ */
269
+ function mapEndpoint(value, change) {
270
+ return Array.isArray(value) ? value.map(change) : change(value)
271
+ }
272
+
273
+ /**
274
+ * @param {object} edge A stored edge.
275
+ * @param {object} change `{ keys, map }`: the endpoint keys to touch and what becomes of an id.
276
+ * @param change.keys
277
+ * @param change.map
278
+ * @return {object} The edge with those endpoints changed, in its own spelling.
279
+ */
280
+ function mapEdge(edge, { keys, map }) {
281
+ const next = { ...edge }
282
+ keys.filter((key) => key in next).forEach((key) => {
283
+ next[key] = mapEndpoint(next[key], map)
284
+ })
285
+
286
+ return next
287
+ }
288
+
289
+ /**
290
+ * Swap two steps in the stored edges, whichever spelling they use. What led
291
+ * into the first now leads into the second, and the other way round.
292
+ *
293
+ * @param {Array<object>} edges The stored edges.
294
+ * @param {Array<string>} pair The two ids.
295
+ * @return {Array<object>} The new edges.
296
+ */
297
+ export function swapStepEdges(edges, [first, second]) {
298
+ const map = (id) => (id === first ? second : (id === second ? first : id))
299
+
300
+ return edges.map((edge) => mapEdge(edge, { keys: ['from', 'to', 'source', 'target'], map }))
301
+ }
302
+
303
+ /**
304
+ * @param {object} node A node.
305
+ * @return {object} Its canvas place, in the spellings it carries.
306
+ */
307
+ function placeFields(node) {
308
+ const { x, y, position } = node
309
+
310
+ return { x, y, position }
311
+ }
312
+
313
+ /**
314
+ * Swap two steps' places on the canvas, so the canvas reads as the list does.
315
+ *
316
+ * @param {Array<object>} nodes The nodes.
317
+ * @param {Array<string>} pair The two ids.
318
+ * @return {Array<object>} The new nodes.
319
+ */
320
+ export function swapStepPlaces(nodes, [first, second]) {
321
+ const a = nodes.find((node) => node.id === first)
322
+ const b = nodes.find((node) => node.id === second)
323
+ const places = new Map([[first, placeFields(b)], [second, placeFields(a)]])
324
+
325
+ return nodes.map((node) => (places.has(node.id) ? { ...node, ...places.get(node.id) } : node))
326
+ }
327
+
328
+ /**
329
+ * Where a step added at the bottom of the list goes in the flow.
330
+ *
331
+ * @param {object} graph The graph, before the step is added.
332
+ * @return {{end: object|null, last: object|null}} The closing step, and the step left without a way on.
333
+ */
334
+ export function flowStepTail(graph) {
335
+ const reached = orderFlowNodes(graph).filter((entry) => !entry.loose).map((entry) => entry.node)
336
+ const ends = reached.filter((node) => graph.roleOf(node.type) === 'end')
337
+ const open = reached.filter((node) => graph.roleOf(node.type) !== 'end' && linesOf(graph, node.id).out.length === 0)
338
+
339
+ return { end: ends[ends.length - 1] || null, last: open[open.length - 1] || null }
340
+ }
341
+
342
+ /**
343
+ * The edges with a new step in at the bottom: before the closing step when
344
+ * there is one, else after the last step.
345
+ *
346
+ * @param {Array<object>} edges The stored edges.
347
+ * @param {object} insert `{ id, end, last }`: the new step and flowStepTail()'s answer.
348
+ * @param insert.id
349
+ * @param insert.end
350
+ * @param insert.last
351
+ * @return {Array<object>} The new edges.
352
+ */
353
+ export function insertStepEdges(edges, { id, end, last }) {
354
+ const map = (target) => (target === end?.id ? id : target)
355
+ const leadsToEnd = (edge) => end !== null && [].concat(edge.to ?? edge.target).includes(end.id)
356
+ const reachesEnd = edges.some(leadsToEnd)
357
+ const before = last !== null && !reachesEnd ? [{ from: last.id, to: id }] : []
358
+ const after = end !== null ? [{ from: id, to: end.id }] : []
359
+
360
+ return [...edges.map((edge) => mapEdge(edge, { keys: ['to', 'target'], map })), ...before, ...after]
361
+ }
362
+
363
+ /**
364
+ * The edge that closes the gap a removed step leaves in a chain.
365
+ *
366
+ * @param {object} graph The graph.
367
+ * @param {string} id The step being removed.
368
+ * @return {object|null} The edge, or null when the step is not a plain link of a chain.
369
+ */
370
+ export function flowStepBridge(graph, id) {
371
+ const node = graph.nodes.find((candidate) => candidate.id === id)
372
+ const { into, out } = linesOf(graph, id)
373
+ const plain = node && !branches(node) && into.length === 1 && out.length === 1
374
+ if (!plain || out[0].target === into[0].source) {
375
+ return null
376
+ }
377
+ const edge = into[0].data.edge
378
+ const single = !Array.isArray(edge.from ?? edge.source) && !Array.isArray(edge.to ?? edge.target)
379
+
380
+ return single ? { ...edge, ['to' in edge ? 'to' : 'target']: out[0].target } : null
381
+ }