@dudousxd/nestjs-catalog-react 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CatalogManager.d.ts +23 -1
- package/dist/CatalogManager.js +76 -13
- package/dist/ConnectionPanel.js +15 -123
- package/dist/LoadedBySection.d.ts +39 -0
- package/dist/LoadedBySection.js +143 -0
- package/dist/WorkflowCanvas.d.ts +16 -0
- package/dist/WorkflowCanvas.js +1026 -78
- package/dist/connection-form.d.ts +241 -0
- package/dist/connection-form.js +235 -0
- package/dist/context.d.ts +78 -4
- package/dist/context.js +11 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +23 -0
- package/dist/routes.d.ts +30 -0
- package/dist/routes.js +2 -0
- package/dist/schema-discovery.d.ts +17 -1
- package/dist/schema-discovery.js +3 -3
- package/dist/source-connection.d.ts +82 -0
- package/dist/source-connection.js +176 -0
- package/dist/source-fields.d.ts +15 -2
- package/dist/source-fields.js +15 -2
- package/dist/ui/combobox.d.ts +97 -0
- package/dist/ui/combobox.js +80 -0
- package/dist/workflow/edges.d.ts +110 -0
- package/dist/workflow/edges.js +112 -0
- package/dist/workflow/graph.d.ts +63 -2
- package/dist/workflow/graph.js +322 -43
- package/dist/workflow/index.d.ts +7 -1
- package/dist/workflow/index.js +10 -5
- package/dist/workflow/lifecycle.d.ts +0 -29
- package/dist/workflow/lifecycle.js +2 -35
- package/dist/workflow/model.d.ts +28 -3
- package/dist/workflow/model.js +12 -2
- package/dist/workflow/nodes.d.ts +4 -1
- package/dist/workflow/nodes.js +226 -11
- package/dist/workflow/templates.js +21 -0
- package/dist/workflow/validate.js +11 -0
- package/dist/workflow/wiring.d.ts +84 -0
- package/dist/workflow/wiring.js +254 -0
- package/package.json +8 -8
package/dist/workflow/graph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { workflowRunOrder } from '@dudousxd/nestjs-catalog/client';
|
|
1
|
+
import { WORKFLOW_NODE_HEIGHT, WORKFLOW_NODE_WIDTH, workflowColumnX, workflowRowY, workflowRunOrder, } from '@dudousxd/nestjs-catalog/client';
|
|
2
2
|
import { MarkerType } from '@xyflow/react';
|
|
3
|
-
import { nodeName, } from './model';
|
|
3
|
+
import { nodeName, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, } from './model';
|
|
4
4
|
import { edgeId } from './validate';
|
|
5
5
|
/**
|
|
6
6
|
* Turning the stored graph into what React Flow draws, and back.
|
|
@@ -19,11 +19,18 @@ import { edgeId } from './validate';
|
|
|
19
19
|
* measured anything — on a graph loaded from the server, or one somebody just
|
|
20
20
|
* pasted — and a layout that waits for measurements draws every node stacked at
|
|
21
21
|
* the origin for one frame, which reads as a broken canvas.
|
|
22
|
+
*
|
|
23
|
+
* **Re-exported from core rather than declared here**, and that is the point of
|
|
24
|
+
* the change that moved them. The server also writes positions —
|
|
25
|
+
* `adoptConnector` wraps a connector into a graph and has to space its columns —
|
|
26
|
+
* and while these numbers lived only in this file it had nothing to derive from,
|
|
27
|
+
* so it used a literal that was four pixels narrower than the node. Every
|
|
28
|
+
* adopted graph drew its boxes overlapping. Sharing the constant is what stops
|
|
29
|
+
* the two from being able to disagree; the names stay `NODE_WIDTH`/`NODE_HEIGHT`
|
|
30
|
+
* because they are part of this package's published `/workflow` surface.
|
|
22
31
|
*/
|
|
23
|
-
export const NODE_WIDTH =
|
|
24
|
-
export const NODE_HEIGHT =
|
|
25
|
-
const COLUMN_GAP = 96;
|
|
26
|
-
const ROW_GAP = 32;
|
|
32
|
+
export const NODE_WIDTH = WORKFLOW_NODE_WIDTH;
|
|
33
|
+
export const NODE_HEIGHT = WORKFLOW_NODE_HEIGHT;
|
|
27
34
|
/**
|
|
28
35
|
* The second line on a node, per kind.
|
|
29
36
|
*
|
|
@@ -41,7 +48,155 @@ function subtitleFor(node, describe) {
|
|
|
41
48
|
}
|
|
42
49
|
if (node.kind === 'call')
|
|
43
50
|
return callSubtitle(node);
|
|
44
|
-
|
|
51
|
+
if (node.kind === 'if')
|
|
52
|
+
return ifSubtitle(node);
|
|
53
|
+
if (node.kind === 'filter')
|
|
54
|
+
return filterSubtitle(node);
|
|
55
|
+
if (node.kind === 'transform') {
|
|
56
|
+
return describe.transformName(node.transformId) ?? 'no transform chosen';
|
|
57
|
+
}
|
|
58
|
+
return unreachableNodeKind(node, 'subtitleFor');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* How much a node's face will spend on a predicate before summarising it.
|
|
62
|
+
*
|
|
63
|
+
* A node is 224px wide and the subtitle is one truncated line, so a long
|
|
64
|
+
* predicate spelled out in full is an ellipsis and nothing else. Past this many
|
|
65
|
+
* leaves the face says how many conditions there are instead, which at least
|
|
66
|
+
* tells a reader there is something to open.
|
|
67
|
+
*/
|
|
68
|
+
const FILTER_FACE_LEAVES = 2;
|
|
69
|
+
/**
|
|
70
|
+
* The test, on the face of the node — the reason this kind exists rather than a
|
|
71
|
+
* transform that returns a subset.
|
|
72
|
+
*
|
|
73
|
+
* "Keep the open orders" readable off the canvas is reason one of three on
|
|
74
|
+
* `WorkflowFilterNode`, so the subtitle is the feature and not decoration. It
|
|
75
|
+
* shows the *values* as well as the columns, which is a difference from
|
|
76
|
+
* `ifSubtitle` and a deliberate one: an if node stores the name of an
|
|
77
|
+
* environment variable and never its contents, because that is where a
|
|
78
|
+
* credential would be, while a filter's value is a business constant somebody
|
|
79
|
+
* typed into the graph and is already visible to anyone who can see the node.
|
|
80
|
+
*
|
|
81
|
+
* The predicate is read into a variable that admits `undefined` before it is
|
|
82
|
+
* narrowed, for the reason `ifSubtitle` gives: this draws whatever a server
|
|
83
|
+
* sent, and a canvas that throws while rendering a node is a screen nobody can
|
|
84
|
+
* use to fix that node.
|
|
85
|
+
*/
|
|
86
|
+
function filterSubtitle(node) {
|
|
87
|
+
const predicate = node.predicate;
|
|
88
|
+
if (!predicate)
|
|
89
|
+
return 'nothing to test';
|
|
90
|
+
const leaves = countFilterLeaves(predicate);
|
|
91
|
+
if (leaves > FILTER_FACE_LEAVES)
|
|
92
|
+
return `keeps rows matching ${leaves} conditions`;
|
|
93
|
+
return `keeps ${describeFilterPredicate(predicate)}`;
|
|
94
|
+
}
|
|
95
|
+
/** How many comparisons a predicate is made of, groups not counted. */
|
|
96
|
+
function countFilterLeaves(predicate) {
|
|
97
|
+
if (predicate.kind === 'all' || predicate.kind === 'any') {
|
|
98
|
+
let total = 0;
|
|
99
|
+
for (const child of predicate.children)
|
|
100
|
+
total += countFilterLeaves(child);
|
|
101
|
+
return total;
|
|
102
|
+
}
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A predicate as a sentence.
|
|
107
|
+
*
|
|
108
|
+
* Shared by the node's face and by the inspector's summary, so the two cannot
|
|
109
|
+
* describe one filter differently — which on a screen whose whole job is making
|
|
110
|
+
* a drop visible would be worse than describing it badly.
|
|
111
|
+
*
|
|
112
|
+
* Groups are parenthesised whenever they are nested, and never at the top, so
|
|
113
|
+
* the common single-group predicate reads as a list rather than as a formula.
|
|
114
|
+
*/
|
|
115
|
+
export function describeFilterPredicate(predicate, nested = false) {
|
|
116
|
+
if (predicate.kind === 'all' || predicate.kind === 'any') {
|
|
117
|
+
const joined = predicate.children
|
|
118
|
+
.map((child) => describeFilterPredicate(child, true))
|
|
119
|
+
.join(predicate.kind === 'all' ? ' and ' : ' or ');
|
|
120
|
+
return nested && predicate.children.length > 1 ? `(${joined})` : joined;
|
|
121
|
+
}
|
|
122
|
+
if (predicate.kind === 'present') {
|
|
123
|
+
return `${predicate.column} ${predicate.operator === 'isNull' ? 'is empty' : 'has a value'}`;
|
|
124
|
+
}
|
|
125
|
+
if (predicate.kind === 'oneOf') {
|
|
126
|
+
const values = predicate.values.map((value) => showFilterValue(value)).join(', ');
|
|
127
|
+
return `${predicate.column} ${predicate.operator === 'in' ? 'is one of' : 'is none of'} ${values}`;
|
|
128
|
+
}
|
|
129
|
+
if (predicate.kind === 'compare') {
|
|
130
|
+
return `${predicate.column} ${FILTER_OPERATOR_WORDS[predicate.operator]} ${showFilterValue(predicate.value)}`;
|
|
131
|
+
}
|
|
132
|
+
return unreachableFilterPredicateKind(predicate, 'describeFilterPredicate');
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Each operator as the words a reader of the canvas would use.
|
|
136
|
+
*
|
|
137
|
+
* A `Record` keyed by the operator union, so an operator added to core without a
|
|
138
|
+
* phrase here is a build failure rather than a node whose subtitle silently says
|
|
139
|
+
* `undefined` — the same reason `BRANCH_STYLE` above is a record.
|
|
140
|
+
*
|
|
141
|
+
* Symbols rather than words for the four orderings, because `>` is unambiguous
|
|
142
|
+
* in every locale a column name is written in and "greater than" is three words
|
|
143
|
+
* of a line that has to fit in 224 pixels.
|
|
144
|
+
*/
|
|
145
|
+
const FILTER_OPERATOR_WORDS = {
|
|
146
|
+
equals: '=',
|
|
147
|
+
notEquals: '≠',
|
|
148
|
+
greaterThan: '>',
|
|
149
|
+
greaterThanOrEqual: '≥',
|
|
150
|
+
lessThan: '<',
|
|
151
|
+
lessThanOrEqual: '≤',
|
|
152
|
+
contains: 'contains',
|
|
153
|
+
notContains: 'does not contain',
|
|
154
|
+
startsWith: 'starts with',
|
|
155
|
+
notStartsWith: 'does not start with',
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* One value, quoted only when it is text.
|
|
159
|
+
*
|
|
160
|
+
* `status = "OPEN"` and `qty = 10` are different tests, and the quotes are the
|
|
161
|
+
* only thing on the face that says which — three-valued logic aside, a string
|
|
162
|
+
* `"10"` never equals a number `10` here, and that is exactly the mistake the
|
|
163
|
+
* run log has to report as an incomparable value.
|
|
164
|
+
*/
|
|
165
|
+
function showFilterValue(value) {
|
|
166
|
+
return typeof value === 'string' ? `"${value}"` : String(value);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The test, on the face of the node.
|
|
170
|
+
*
|
|
171
|
+
* Written as the condition rather than as the variable alone, because the whole
|
|
172
|
+
* question somebody reads a branch to answer is "which way does this go here",
|
|
173
|
+
* and `CLICKHOUSE_URL` on its own does not say whether it is being tested for
|
|
174
|
+
* presence or for a value. The name is shown; a value never is — the node stores
|
|
175
|
+
* the name of a variable and this screen has no more than that.
|
|
176
|
+
*
|
|
177
|
+
* The predicate is read into a variable that admits `undefined` before it is
|
|
178
|
+
* narrowed, even though the type says it is always there. This runs on whatever
|
|
179
|
+
* a server sent, and a canvas that throws while drawing a node is a screen
|
|
180
|
+
* nobody can use to fix the node — a subtitle saying the gate has no test is.
|
|
181
|
+
*/
|
|
182
|
+
function ifSubtitle(node) {
|
|
183
|
+
const predicate = node.predicate;
|
|
184
|
+
if (!predicate)
|
|
185
|
+
return 'nothing to decide on';
|
|
186
|
+
if (predicate.kind === 'env') {
|
|
187
|
+
const name = typeof predicate.envVar === 'string' ? predicate.envVar.trim() : '';
|
|
188
|
+
if (name.length === 0)
|
|
189
|
+
return 'no variable chosen';
|
|
190
|
+
return predicate.equals === undefined
|
|
191
|
+
? `if ${name} is set`
|
|
192
|
+
: `if ${name} = ${predicate.equals}`;
|
|
193
|
+
}
|
|
194
|
+
if (predicate.kind === 'rowCount') {
|
|
195
|
+
return predicate.atLeast === 1
|
|
196
|
+
? 'if any rows arrived'
|
|
197
|
+
: `if ${predicate.atLeast} rows or more arrived`;
|
|
198
|
+
}
|
|
199
|
+
return unreachablePredicateKind(predicate, 'ifSubtitle');
|
|
45
200
|
}
|
|
46
201
|
/** What a source reads from: its kind, and the connection or mode that narrows it. */
|
|
47
202
|
function sourceSubtitle(node, describe) {
|
|
@@ -80,12 +235,50 @@ function ariaLabelFor(node, data, incoming, outgoing) {
|
|
|
80
235
|
const parts = [`${node.kind} node, ${data.label}, ${data.subtitle}`];
|
|
81
236
|
parts.push(incoming.length === 0 ? 'nothing feeds it' : `fed by ${incoming.join(', ')}`);
|
|
82
237
|
parts.push(outgoing.length === 0 ? 'feeds nothing' : `feeds ${outgoing.join(', ')}`);
|
|
83
|
-
|
|
84
|
-
|
|
238
|
+
// The branch and the reason for a skip are in here as well as in the tooltip,
|
|
239
|
+
// because on a canvas this string is the only thing a screen reader gets — and
|
|
240
|
+
// "skipped" alone cannot distinguish a node a branch stood down from a node a
|
|
241
|
+
// failure stranded, which is the one distinction this feature adds.
|
|
242
|
+
if (data.run) {
|
|
243
|
+
const branch = data.run.branch ? `, took the ${data.run.branch} branch` : '';
|
|
244
|
+
const because = data.run.skippedBecause === 'branch-not-taken'
|
|
245
|
+
? ', because it is on the branch that was not taken, so it committed nothing'
|
|
246
|
+
: '';
|
|
247
|
+
// The drop is in the spoken label as well as the tooltip, because a tooltip
|
|
248
|
+
// is a hover and this is the sentence a screen reader user gets instead of
|
|
249
|
+
// the whole canvas. A filter that dropped nine tenths of a load and said so
|
|
250
|
+
// only on hover would be invisible to exactly the reader who cannot check.
|
|
251
|
+
const dropped = describeDrop(data.run);
|
|
252
|
+
parts.push(`last run ${data.run.status}${branch}${because}${dropped ? `, ${dropped}` : ''}`);
|
|
253
|
+
}
|
|
85
254
|
for (const problem of data.problems)
|
|
86
255
|
parts.push(problem.message);
|
|
87
256
|
return parts.join('. ');
|
|
88
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* What a filter did to a run, as a phrase — or nothing, for every other node.
|
|
260
|
+
*
|
|
261
|
+
* Keyed off `rowsIn` being **present** rather than off the node's kind, which is
|
|
262
|
+
* the only check that stays right in both directions: a filter that ran before
|
|
263
|
+
* the server recorded an input count has no drop to report and must not claim
|
|
264
|
+
* one, and no other kind sets the field at all. Subtracting from a defaulted
|
|
265
|
+
* zero would make every historical node read as having dropped its whole output.
|
|
266
|
+
*
|
|
267
|
+
* Exported so the node badge and the aria label say the same sentence.
|
|
268
|
+
*/
|
|
269
|
+
export function describeDrop(run) {
|
|
270
|
+
const given = run.rowsIn;
|
|
271
|
+
if (typeof given !== 'number' || typeof run.rows !== 'number')
|
|
272
|
+
return undefined;
|
|
273
|
+
const dropped = given - run.rows;
|
|
274
|
+
if (dropped <= 0)
|
|
275
|
+
return `${given} rows in, none dropped`;
|
|
276
|
+
// The percentage is what makes the number readable: "7,541,187 dropped" needs
|
|
277
|
+
// arithmetic before anybody can tell a working filter from a broken predicate,
|
|
278
|
+
// and "98.7%" does not.
|
|
279
|
+
const share = given === 0 ? 0 : Math.round((dropped / given) * 1000) / 10;
|
|
280
|
+
return `${given} rows in, ${run.rows} out — ${dropped} dropped (${share}%)`;
|
|
281
|
+
}
|
|
89
282
|
export function toFlowNodes(nodes, edges, describe, problemsFor, runFor) {
|
|
90
283
|
const labelOf = new Map(nodes.map((node) => [node.id, nodeName(node)]));
|
|
91
284
|
const names = (ids) => ids.map((id) => labelOf.get(id) ?? id);
|
|
@@ -133,31 +326,99 @@ export function defaultLabel(kind) {
|
|
|
133
326
|
return 'Sink';
|
|
134
327
|
if (kind === 'call')
|
|
135
328
|
return 'Call';
|
|
136
|
-
|
|
329
|
+
if (kind === 'if')
|
|
330
|
+
return 'If';
|
|
331
|
+
if (kind === 'filter')
|
|
332
|
+
return 'Filter';
|
|
333
|
+
if (kind === 'transform')
|
|
334
|
+
return 'Transform';
|
|
335
|
+
return unreachableNodeKind(kind, 'defaultLabel');
|
|
137
336
|
}
|
|
138
|
-
|
|
337
|
+
/**
|
|
338
|
+
* How a branch is drawn: a word on the wire, and a colour that means it.
|
|
339
|
+
*
|
|
340
|
+
* A **label**, not only a colour, and that is the accessibility half rather than
|
|
341
|
+
* a stylistic one — two lines leaving one box differing by hue alone are one
|
|
342
|
+
* line as far as a colour-blind reader is concerned, and this particular
|
|
343
|
+
* distinction decides which half of a pipeline runs. Emerald for the branch
|
|
344
|
+
* taken when the test passes and zinc for the other reads as "the positive one
|
|
345
|
+
* and the fallback", which is what a then and an else are.
|
|
346
|
+
*
|
|
347
|
+
* Kept as a `Record` keyed by the label union so a third branch label added to
|
|
348
|
+
* core without a line here is a type error rather than an unlabelled grey wire.
|
|
349
|
+
*/
|
|
350
|
+
const BRANCH_STYLE = {
|
|
351
|
+
else: { stroke: '#a1a1aa', text: '#71717a' },
|
|
352
|
+
// biome-ignore lint/suspicious/noThenProperty: the rule guards against an object being mistaken for a thenable by `await`; the key here is one of core's two branch labels and this record is only ever indexed by one of them, never awaited nor returned from anything async. Keying it by the label union is what makes a third label a compile error rather than an unlabelled grey wire, which is the whole reason it is a record and not a function.
|
|
353
|
+
then: { stroke: '#10b981', text: '#059669' },
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* The stored edges, as React Flow draws them.
|
|
357
|
+
*
|
|
358
|
+
* `flowing` is the set of edge ids whose upstream node is running right now, and
|
|
359
|
+
* it is a parameter rather than something derived here because this module knows
|
|
360
|
+
* nothing about runs. It is also **the caller's job to pass an empty set when
|
|
361
|
+
* motion is unwanted** — see `WorkflowCanvas`, which reads `prefers-reduced-motion`
|
|
362
|
+
* — because React Flow's `animated` flag is a CSS keyframe in its own stylesheet
|
|
363
|
+
* and there is nothing this package can turn off from the outside.
|
|
364
|
+
*/
|
|
365
|
+
export function toFlowEdges(edges, nodes, brokenEdgeIds, flowing = new Set()) {
|
|
139
366
|
const labelOf = new Map(nodes.map((node) => [node.id, nodeName(node)]));
|
|
140
|
-
return edges.map((edge) => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
367
|
+
return edges.map((edge) => toFlowEdge(edge, {
|
|
368
|
+
from: labelOf.get(edge.from) ?? edge.from,
|
|
369
|
+
to: labelOf.get(edge.to) ?? edge.to,
|
|
370
|
+
broken: brokenEdgeIds.has(edgeId(edge)),
|
|
371
|
+
flowing: flowing.has(edgeId(edge)),
|
|
372
|
+
}));
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* One wire, drawn.
|
|
376
|
+
*
|
|
377
|
+
* Split out of the `map` above so the styling decisions — arrowhead, branch
|
|
378
|
+
* colour, the red a loop wears — sit in one function that is about a wire,
|
|
379
|
+
* rather than in a closure that is also about resolving names.
|
|
380
|
+
*/
|
|
381
|
+
function toFlowEdge(edge, context) {
|
|
382
|
+
const branch = edge.branch === undefined ? undefined : BRANCH_STYLE[edge.branch];
|
|
383
|
+
return {
|
|
384
|
+
id: edgeId(edge),
|
|
385
|
+
source: edge.from,
|
|
386
|
+
target: edge.to,
|
|
387
|
+
// This package's own edge rather than the built-in `smoothstep`, because
|
|
388
|
+
// clicking a connection has to offer to remove it. See `workflow/edges.tsx`.
|
|
389
|
+
type: 'workflowEdge',
|
|
390
|
+
// The names, not the ids: they become the accessible name of the delete
|
|
391
|
+
// button, which has to say which connection it removes in the words that
|
|
392
|
+
// are on the canvas.
|
|
393
|
+
data: { fromLabel: context.from, toLabel: context.to },
|
|
394
|
+
// Marching ants while the node feeding this edge is actually running. The
|
|
395
|
+
// one thing a canvas can say about a run that a list of statuses cannot:
|
|
396
|
+
// where the work currently is.
|
|
397
|
+
animated: context.flowing,
|
|
398
|
+
// An arrowhead, because "the output of this feeds that" is directional and
|
|
399
|
+
// a plain line says only that two nodes are related.
|
|
400
|
+
markerEnd: { type: MarkerType.ArrowClosed, width: 14, height: 14 },
|
|
401
|
+
label: edge.branch,
|
|
402
|
+
labelStyle: branch ? { fill: branch.text, fontSize: 10, fontWeight: 600 } : undefined,
|
|
403
|
+
// The word sits on the wire, so it takes the canvas behind it rather than a
|
|
404
|
+
// filled plate that would blank out whatever the wire crosses.
|
|
405
|
+
labelBgStyle: branch ? { fill: 'transparent' } : undefined,
|
|
406
|
+
ariaLabel: `the output of ${context.from} feeds ${context.to}${edge.branch ? `, on the ${edge.branch} branch` : ''}${context.broken ? ', part of a loop' : ''}`,
|
|
407
|
+
// An inline stroke rather than a class, because the stroke lands on an
|
|
408
|
+
// SVG `<path>` React Flow owns: a Tailwind class on the edge wrapper does
|
|
409
|
+
// not reach it, and inventing a stylesheet rule would mean this package
|
|
410
|
+
// ships CSS for the first time just to colour one line.
|
|
411
|
+
//
|
|
412
|
+
// Broken wins over branch: a wire in a loop is a graph that will not run at
|
|
413
|
+
// all, which is a bigger fact than which side of a decision it is on.
|
|
414
|
+
style: edgeStroke(context, branch),
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
/** Red for a loop, the branch's colour for a branch, React Flow's default otherwise. */
|
|
418
|
+
function edgeStroke(context, branch) {
|
|
419
|
+
if (context.broken)
|
|
420
|
+
return { stroke: '#ef4444', strokeWidth: 2 };
|
|
421
|
+
return branch ? { stroke: branch.stroke, strokeWidth: 2 } : undefined;
|
|
161
422
|
}
|
|
162
423
|
/** Who feeds each node, by node id. Every node gets an entry, most of them empty. */
|
|
163
424
|
function feedersByNode(nodes, edges) {
|
|
@@ -258,13 +519,7 @@ export function layout(nodes, edges) {
|
|
|
258
519
|
const placed = node.kind === 'sink' ? sinkColumn : (column.get(node.id) ?? 0);
|
|
259
520
|
const row = rows.get(placed) ?? 0;
|
|
260
521
|
rows.set(placed, row + 1);
|
|
261
|
-
return {
|
|
262
|
-
...node,
|
|
263
|
-
position: {
|
|
264
|
-
x: placed * (NODE_WIDTH + COLUMN_GAP),
|
|
265
|
-
y: row * (NODE_HEIGHT + ROW_GAP),
|
|
266
|
-
},
|
|
267
|
-
};
|
|
522
|
+
return { ...node, position: { x: workflowColumnX(placed), y: workflowRowY(row) } };
|
|
268
523
|
});
|
|
269
524
|
}
|
|
270
525
|
/**
|
|
@@ -315,6 +570,30 @@ export function layoutIfUnarranged(nodes, edges) {
|
|
|
315
570
|
}
|
|
316
571
|
return arranged ? nodes : layout(nodes, edges);
|
|
317
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* Which edges should show their work moving, and when that is none of them.
|
|
575
|
+
*
|
|
576
|
+
* An edge flows while the node feeding it is running. That is the one thing a
|
|
577
|
+
* picture can say about a run which the per-node status list cannot: not what
|
|
578
|
+
* each step's outcome was, but where the work *is* right now.
|
|
579
|
+
*
|
|
580
|
+
* `reducedMotion` short-circuits to the empty set, and this function exists
|
|
581
|
+
* largely so that decision is a value rather than a branch inside a render.
|
|
582
|
+
* React Flow's `animated` is a CSS keyframe in its own stylesheet — there is no
|
|
583
|
+
* prop to soften it and no way to reach it from here — so the only honest
|
|
584
|
+
* accommodation is not to mark the edge at all. Nothing is lost by it: a running
|
|
585
|
+
* node still spins its own badge and the run panel still lists every step, which
|
|
586
|
+
* is the test for whether an animation was carrying information or decorating
|
|
587
|
+
* it.
|
|
588
|
+
*/
|
|
589
|
+
export function flowingEdgeIds(edges, runNodes, options) {
|
|
590
|
+
if (options.reducedMotion)
|
|
591
|
+
return new Set();
|
|
592
|
+
const running = new Set(runNodes.filter((node) => node.status === 'running').map((node) => node.nodeId));
|
|
593
|
+
if (running.size === 0)
|
|
594
|
+
return new Set();
|
|
595
|
+
return new Set(edges.filter((edge) => running.has(edge.from)).map((edge) => edgeId(edge)));
|
|
596
|
+
}
|
|
318
597
|
/**
|
|
319
598
|
* Where to drop a node somebody just added.
|
|
320
599
|
*
|
|
@@ -328,8 +607,8 @@ export function nextPosition(nodes) {
|
|
|
328
607
|
const xs = nodes.map((node) => node.position?.x ?? 0);
|
|
329
608
|
const right = Math.max(...xs);
|
|
330
609
|
const inColumn = xs.filter((x) => x === right);
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
};
|
|
610
|
+
// `workflowColumnX(1)` is one whole column — the node's width plus the gap —
|
|
611
|
+
// added to wherever the rightmost node happens to be, which need not sit on a
|
|
612
|
+
// column boundary once somebody has dragged things around.
|
|
613
|
+
return { x: right + workflowColumnX(1), y: workflowRowY(inColumn.length) };
|
|
335
614
|
}
|
package/dist/workflow/index.d.ts
CHANGED
|
@@ -11,8 +11,14 @@
|
|
|
11
11
|
* The graph model, the working name and the validation rules stay on the root
|
|
12
12
|
* entry — none of them import React Flow, and a host should be able to check a
|
|
13
13
|
* graph, or name one, without pulling in a canvas to do it.
|
|
14
|
+
*
|
|
15
|
+
* `motion` is the second optional peer this subpath needs, for the same class of
|
|
16
|
+
* reason: the delete control on a selected edge animates in and out, and
|
|
17
|
+
* `useReducedMotion` is how it declines to. Both are declined together —
|
|
18
|
+
* anything mounting a node canvas is already installing a graph library, and a
|
|
19
|
+
* host that wants neither wants the root entry point instead.
|
|
14
20
|
*/
|
|
15
21
|
export { WorkflowCanvas, type WorkflowCanvasProps } from '../WorkflowCanvas';
|
|
16
22
|
export { layout, layoutIfUnarranged, NODE_HEIGHT, NODE_WIDTH, type WorkflowFlowEdge, type WorkflowFlowNode, type WorkflowNodeData, } from './graph';
|
|
17
|
-
export {
|
|
23
|
+
export { PublishControls, refusedForShrink, RunControls, SchedulePanel, ShrinkRefusalNote, WorkflowStatusBadge, } from './lifecycle';
|
|
18
24
|
export { RunsAsPanel } from './runs';
|
package/dist/workflow/index.js
CHANGED
|
@@ -11,13 +11,18 @@
|
|
|
11
11
|
* The graph model, the working name and the validation rules stay on the root
|
|
12
12
|
* entry — none of them import React Flow, and a host should be able to check a
|
|
13
13
|
* graph, or name one, without pulling in a canvas to do it.
|
|
14
|
+
*
|
|
15
|
+
* `motion` is the second optional peer this subpath needs, for the same class of
|
|
16
|
+
* reason: the delete control on a selected edge animates in and out, and
|
|
17
|
+
* `useReducedMotion` is how it declines to. Both are declined together —
|
|
18
|
+
* anything mounting a node canvas is already installing a graph library, and a
|
|
19
|
+
* host that wants neither wants the root entry point instead.
|
|
14
20
|
*/
|
|
15
21
|
export { WorkflowCanvas } from '../WorkflowCanvas';
|
|
16
22
|
export { layout, layoutIfUnarranged, NODE_HEIGHT, NODE_WIDTH, } from './graph';
|
|
17
23
|
// What happens to a graph once it is drawn. Here rather than on the root entry
|
|
18
|
-
// because a host reaching for these is already mounting the canvas — and
|
|
19
|
-
// rather than nowhere because
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
export { AdoptionNote, PublishControls, refusedForShrink, RunControls, SchedulePanel, ShrinkRefusalNote, wasAdopted, WORKFLOW_ADOPTION_ACTOR, WorkflowStatusBadge, } from './lifecycle';
|
|
24
|
+
// because a host reaching for these is already mounting the canvas — and
|
|
25
|
+
// `refusedForShrink` is here rather than nowhere because "was that failure the
|
|
26
|
+
// row-count bound" is a judgement a host might want to make outside a canvas.
|
|
27
|
+
export { PublishControls, refusedForShrink, RunControls, SchedulePanel, ShrinkRefusalNote, WorkflowStatusBadge, } from './lifecycle';
|
|
23
28
|
export { RunsAsPanel } from './runs';
|
|
@@ -23,24 +23,6 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import { type WorkflowRunOptions } from '../context';
|
|
25
25
|
import type { CatalogWorkflow, WorkflowRun } from './model';
|
|
26
|
-
/**
|
|
27
|
-
* Who a graph is attributed to when nobody drew it.
|
|
28
|
-
*
|
|
29
|
-
* `ConnectorAdoption` wraps a pre-workflow connector into the graph it always
|
|
30
|
-
* was, at boot, and publishes it — so an operator on an upgraded deployment
|
|
31
|
-
* opens this screen and finds pipelines marked `ready` that they never drew and
|
|
32
|
-
* never declared finished. That is worth saying out loud rather than leaving
|
|
33
|
-
* them to infer it from a description.
|
|
34
|
-
*
|
|
35
|
-
* Matched on `createdBy` rather than on the generated description, because a
|
|
36
|
-
* connector that carried a description of its own keeps it — so the description
|
|
37
|
-
* is silent on exactly the graphs that had the most history behind them. The
|
|
38
|
-
* string is the server's `ADOPTION_ACTOR`, and it is a copy: a rename there
|
|
39
|
-
* makes this badge disappear rather than lie, which is the failure mode to
|
|
40
|
-
* prefer between the two.
|
|
41
|
-
*/
|
|
42
|
-
export declare const WORKFLOW_ADOPTION_ACTOR = "connector-adoption";
|
|
43
|
-
export declare function wasAdopted(workflow: Pick<CatalogWorkflow, 'createdBy'>): boolean;
|
|
44
26
|
/**
|
|
45
27
|
* Whether a failure is the row-count bound refusing a load, rather than
|
|
46
28
|
* anything else that can go wrong in a run.
|
|
@@ -68,17 +50,6 @@ export declare function refusedForShrink(message: string | undefined): boolean;
|
|
|
68
50
|
export declare function WorkflowStatusBadge({ workflow }: {
|
|
69
51
|
workflow: CatalogWorkflow;
|
|
70
52
|
}): import("react/jsx-runtime").JSX.Element;
|
|
71
|
-
/**
|
|
72
|
-
* The paragraph the badge cannot hold.
|
|
73
|
-
*
|
|
74
|
-
* On screen rather than in a tooltip, and only for an adopted graph, because a
|
|
75
|
-
* tooltip is something you find when you already suspect there is something to
|
|
76
|
-
* find. Somebody opening a pipeline they have never seen and being told it is
|
|
77
|
-
* `ready` has no reason to hover anything.
|
|
78
|
-
*/
|
|
79
|
-
export declare function AdoptionNote({ workflow }: {
|
|
80
|
-
workflow: CatalogWorkflow;
|
|
81
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
|
82
53
|
/**
|
|
83
54
|
* Publish, or take it back to draft.
|
|
84
55
|
*
|
|
@@ -23,7 +23,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
23
23
|
* used, and it will not send a blank reason.
|
|
24
24
|
*/
|
|
25
25
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
26
|
-
import { CircleCheck, Clock, Loader2, Play,
|
|
26
|
+
import { CircleCheck, Clock, Loader2, Play, TriangleAlert, Undo2, Upload } from 'lucide-react';
|
|
27
27
|
import { useState } from 'react';
|
|
28
28
|
import { cn } from '../cn';
|
|
29
29
|
import { catalogQueryKeys, useCatalogClient, } from '../context';
|
|
@@ -36,26 +36,6 @@ import { WORKFLOW_NAME } from './name';
|
|
|
36
36
|
const MUTED = 'text-zinc-400 dark:text-zinc-500';
|
|
37
37
|
const RULE = 'border-zinc-200 dark:border-zinc-800';
|
|
38
38
|
const PANEL = 'bg-white dark:bg-zinc-900';
|
|
39
|
-
/**
|
|
40
|
-
* Who a graph is attributed to when nobody drew it.
|
|
41
|
-
*
|
|
42
|
-
* `ConnectorAdoption` wraps a pre-workflow connector into the graph it always
|
|
43
|
-
* was, at boot, and publishes it — so an operator on an upgraded deployment
|
|
44
|
-
* opens this screen and finds pipelines marked `ready` that they never drew and
|
|
45
|
-
* never declared finished. That is worth saying out loud rather than leaving
|
|
46
|
-
* them to infer it from a description.
|
|
47
|
-
*
|
|
48
|
-
* Matched on `createdBy` rather than on the generated description, because a
|
|
49
|
-
* connector that carried a description of its own keeps it — so the description
|
|
50
|
-
* is silent on exactly the graphs that had the most history behind them. The
|
|
51
|
-
* string is the server's `ADOPTION_ACTOR`, and it is a copy: a rename there
|
|
52
|
-
* makes this badge disappear rather than lie, which is the failure mode to
|
|
53
|
-
* prefer between the two.
|
|
54
|
-
*/
|
|
55
|
-
export const WORKFLOW_ADOPTION_ACTOR = 'connector-adoption';
|
|
56
|
-
export function wasAdopted(workflow) {
|
|
57
|
-
return workflow.createdBy === WORKFLOW_ADOPTION_ACTOR;
|
|
58
|
-
}
|
|
59
39
|
/**
|
|
60
40
|
* Whether a failure is the row-count bound refusing a load, rather than
|
|
61
41
|
* anything else that can go wrong in a run.
|
|
@@ -88,20 +68,7 @@ export function WorkflowStatusBadge({ workflow }) {
|
|
|
88
68
|
? `Declared finished, and validated when it was. It runs as a connector of its own, and only a ready ${WORKFLOW_NAME.singular} can be scheduled.`
|
|
89
69
|
: 'Being drawn. It saves without being validated — that is what a draft is for — and it neither runs on a schedule nor mints anything. Publishing is where the checks are answered for real.', children: _jsx("span", { className: cn('cursor-help rounded-sm px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em]', ready
|
|
90
70
|
? 'bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-300'
|
|
91
|
-
: 'bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300'), children: workflow.status }) }), !workflow.enabled && (_jsx(Tooltip, { content: "Turned off. It keeps its configuration, its schedule and its incremental watermark, and refuses to fire.", children: _jsx("span", { className: cn('cursor-help rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em]', 'text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300'), children: "disabled" }) }))
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* The paragraph the badge cannot hold.
|
|
95
|
-
*
|
|
96
|
-
* On screen rather than in a tooltip, and only for an adopted graph, because a
|
|
97
|
-
* tooltip is something you find when you already suspect there is something to
|
|
98
|
-
* find. Somebody opening a pipeline they have never seen and being told it is
|
|
99
|
-
* `ready` has no reason to hover anything.
|
|
100
|
-
*/
|
|
101
|
-
export function AdoptionNote({ workflow }) {
|
|
102
|
-
if (!wasAdopted(workflow))
|
|
103
|
-
return null;
|
|
104
|
-
return (_jsxs("div", { className: cn('mt-2.5 flex flex-wrap items-baseline gap-x-2 rounded-md border px-2.5 py-1.5', 'border-sky-200 bg-sky-50 text-sky-900', 'dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200'), children: [_jsx("p", { className: "font-mono text-[10px] uppercase tracking-[0.14em]", children: "adopted at boot" }), _jsxs("p", { className: "text-[11px] leading-relaxed", children: ["This graph was not drawn by anybody. A connector that predates ", WORKFLOW_NAME.plural, " was wrapped into it and published as ", _jsx("em", { children: "ready" }), " automatically, so \"ready\" here means \"it validated\", not \"somebody looked at it and said it was finished\". Its run history and incremental watermark carried over with the connector's id."] })] }));
|
|
71
|
+
: 'bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300'), children: workflow.status }) }), !workflow.enabled && (_jsx(Tooltip, { content: "Turned off. It keeps its configuration, its schedule and its incremental watermark, and refuses to fire.", children: _jsx("span", { className: cn('cursor-help rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em]', 'text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300'), children: "disabled" }) }))] }));
|
|
105
72
|
}
|
|
106
73
|
/**
|
|
107
74
|
* Publish, or take it back to draft.
|
package/dist/workflow/model.d.ts
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
* executes it, it belongs to core; if only this screen has an opinion about it,
|
|
19
19
|
* it belongs here.
|
|
20
20
|
*/
|
|
21
|
-
export type { CallableWorkflowRef, CatalogWorkflow, WorkflowEdge, WorkflowCallNode, WorkflowGraph, WorkflowNode, WorkflowNodeKind, WorkflowSinkNode, WorkflowSourceNode, WorkflowTransformNode, } from '@dudousxd/nestjs-catalog/client';
|
|
22
|
-
export { isWorkflowNodeKind, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
|
|
23
|
-
import { type WorkflowNode } from '@dudousxd/nestjs-catalog/client';
|
|
21
|
+
export type { CallableWorkflowBlock, CallableWorkflowDisagreement, CallableWorkflowRef, CatalogWorkflow, WorkflowBranchLabel, WorkflowEdge, WorkflowCallNode, WorkflowEnvPredicate, WorkflowFilterAll, WorkflowFilterAny, WorkflowFilterComparison, WorkflowFilterGroup, WorkflowFilterNode, WorkflowFilterOneOf, WorkflowFilterOperator, WorkflowFilterPredicate, WorkflowFilterPredicateKind, WorkflowFilterPresence, WorkflowFilterValue, WorkflowGraph, WorkflowIfNode, WorkflowIfPredicate, WorkflowNode, WorkflowNodeKind, WorkflowPredicateKind, WorkflowRowCountPredicate, WorkflowSinkNode, WorkflowSkipReason, WorkflowSourceNode, WorkflowTransformNode, } from '@dudousxd/nestjs-catalog/client';
|
|
22
|
+
export { callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicate, isWorkflowFilterPredicateKind, isWorkflowFilterValue, isWorkflowNodeKind, isWorkflowPredicateKind, unreachableFilterOperator, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, workflowNarrowedTypes, WORKFLOW_BRANCH_LABELS, WORKFLOW_FILTER_COLUMN_PATTERN, WORKFLOW_FILTER_MAX_DEPTH, WORKFLOW_FILTER_MAX_VALUES, WORKFLOW_FILTER_OPERATORS, WORKFLOW_FILTER_PREDICATE_KINDS, WORKFLOW_PREDICATE_KINDS, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
|
|
23
|
+
import { type WorkflowBranchLabel, type WorkflowNode, type WorkflowSkipReason } from '@dudousxd/nestjs-catalog/client';
|
|
24
24
|
/**
|
|
25
25
|
* What a caller may set.
|
|
26
26
|
*
|
|
@@ -117,7 +117,32 @@ export interface WorkflowRunNode {
|
|
|
117
117
|
* nowhere else to read it from.
|
|
118
118
|
*/
|
|
119
119
|
replayed?: boolean;
|
|
120
|
+
/** Which branch an `if` node took on this run. See {@link WorkflowIfNode}. */
|
|
121
|
+
branch?: WorkflowBranchLabel;
|
|
122
|
+
/**
|
|
123
|
+
* Why a `skipped` node did not run, when a branch is the reason rather than a
|
|
124
|
+
* failure above it.
|
|
125
|
+
*
|
|
126
|
+
* The distinction a run panel exists to draw for a **sink**: skipped by a
|
|
127
|
+
* branch means it committed nothing *and was right not to*, so the snapshot
|
|
128
|
+
* that was live before the run is still live. Skipped with no reason means the
|
|
129
|
+
* run fell over before reaching it. Rendering the two identically would answer
|
|
130
|
+
* "why is there no fresh data in X" with the same shrug for a healthy run and
|
|
131
|
+
* a broken one.
|
|
132
|
+
*/
|
|
133
|
+
skippedBecause?: WorkflowSkipReason;
|
|
120
134
|
rows?: number;
|
|
135
|
+
/**
|
|
136
|
+
* What a filter node was handed, where {@link rows} is what it passed on.
|
|
137
|
+
*
|
|
138
|
+
* The pair is the whole reporting contract of a filter, and both halves have
|
|
139
|
+
* to reach the screen or the node's effect is invisible — which is how rows go
|
|
140
|
+
* missing quietly. Absent on every other kind, and absent on filters that ran
|
|
141
|
+
* before the server recorded it; a panel must therefore check for its presence
|
|
142
|
+
* rather than subtract from a defaulted zero, or every historical node would
|
|
143
|
+
* claim to have dropped everything it produced.
|
|
144
|
+
*/
|
|
145
|
+
rowsIn?: number;
|
|
121
146
|
error?: string;
|
|
122
147
|
startedAt?: string;
|
|
123
148
|
finishedAt?: string;
|
package/dist/workflow/model.js
CHANGED
|
@@ -18,8 +18,18 @@
|
|
|
18
18
|
* executes it, it belongs to core; if only this screen has an opinion about it,
|
|
19
19
|
* it belongs here.
|
|
20
20
|
*/
|
|
21
|
-
export {
|
|
22
|
-
|
|
21
|
+
export {
|
|
22
|
+
// Whether an announced workflow may be committed onto a call node. Core's,
|
|
23
|
+
// not a copy: the picker greys an entry out and the server reasons about the
|
|
24
|
+
// same list, and two copies of that rule is a picker that eventually offers
|
|
25
|
+
// something the rest of the system will not accept.
|
|
26
|
+
callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicate, isWorkflowFilterPredicateKind, isWorkflowFilterValue, isWorkflowNodeKind, isWorkflowPredicateKind, unreachableFilterOperator, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind,
|
|
27
|
+
// Core's, not a copy, for the reason every other rule here is core's: the
|
|
28
|
+
// inspector has to offer exactly the acknowledgements `validateWorkflow`
|
|
29
|
+
// requires, and a screen that worked out its own list would offer a set the
|
|
30
|
+
// server then refuses — with the person having ticked a box to be told no.
|
|
31
|
+
workflowNarrowedTypes, WORKFLOW_BRANCH_LABELS, WORKFLOW_FILTER_COLUMN_PATTERN, WORKFLOW_FILTER_MAX_DEPTH, WORKFLOW_FILTER_MAX_VALUES, WORKFLOW_FILTER_OPERATORS, WORKFLOW_FILTER_PREDICATE_KINDS, WORKFLOW_PREDICATE_KINDS, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
|
|
32
|
+
import { WORKFLOW_NODE_ID_PATTERN, } from '@dudousxd/nestjs-catalog/client';
|
|
23
33
|
export function describeDurability(durability) {
|
|
24
34
|
if (!durability) {
|
|
25
35
|
return {
|