@dudousxd/nestjs-catalog-react 0.17.0 → 0.19.0-preview.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 +39 -13
- package/dist/CatalogManager.d.ts +23 -1
- package/dist/CatalogManager.js +76 -13
- package/dist/ConnectionPanel.d.ts +11 -7
- package/dist/ConnectionPanel.js +78 -149
- package/dist/LoadedBySection.d.ts +39 -0
- package/dist/LoadedBySection.js +143 -0
- package/dist/PipelineConsole.d.ts +23 -126
- package/dist/PipelineConsole.js +39 -551
- package/dist/WorkflowCanvas.d.ts +16 -0
- package/dist/WorkflowCanvas.js +1064 -64
- package/dist/connection-form.d.ts +241 -0
- package/dist/connection-form.js +235 -0
- package/dist/context.d.ts +236 -38
- package/dist/context.js +46 -11
- package/dist/index.d.ts +10 -3
- package/dist/index.js +63 -14
- package/dist/routes.d.ts +84 -13
- package/dist/routes.js +7 -4
- package/dist/schema-discovery.d.ts +232 -0
- package/dist/schema-discovery.js +225 -0
- package/dist/source-connection.d.ts +82 -0
- package/dist/source-connection.js +176 -0
- package/dist/source-fields.d.ts +16 -14
- package/dist/source-fields.js +28 -18
- package/dist/ui/code-editor.d.ts +44 -2
- package/dist/ui/code-editor.js +10 -2
- package/dist/ui/combobox.d.ts +97 -0
- package/dist/ui/combobox.js +80 -0
- package/dist/ui/dialog.d.ts +13 -1
- package/dist/ui/dialog.js +13 -2
- package/dist/workflow/edges.d.ts +110 -0
- package/dist/workflow/edges.js +112 -0
- package/dist/workflow/graph.d.ts +39 -1
- package/dist/workflow/graph.js +212 -52
- package/dist/workflow/index.d.ts +8 -0
- package/dist/workflow/index.js +12 -0
- package/dist/workflow/lifecycle.d.ts +135 -0
- package/dist/workflow/lifecycle.js +216 -0
- package/dist/workflow/model.d.ts +17 -3
- package/dist/workflow/model.js +7 -2
- package/dist/workflow/nodes.d.ts +4 -1
- package/dist/workflow/nodes.js +198 -10
- package/dist/workflow/runs.d.ts +38 -0
- package/dist/workflow/runs.js +101 -0
- package/dist/workflow/shape.d.ts +169 -0
- package/dist/workflow/shape.js +249 -0
- package/dist/workflow/templates.d.ts +623 -0
- package/dist/workflow/templates.js +1102 -0
- package/dist/workflow/validate.d.ts +20 -1
- package/dist/workflow/validate.js +52 -3
- package/dist/workflow/wiring.d.ts +84 -0
- package/dist/workflow/wiring.js +254 -0
- package/package.json +9 -9
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, 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
|
*
|
|
@@ -33,20 +40,78 @@ const ROW_GAP = 32;
|
|
|
33
40
|
* circular, since a connector references a workflow.
|
|
34
41
|
*/
|
|
35
42
|
function subtitleFor(node, describe) {
|
|
36
|
-
if (node.kind === 'source')
|
|
37
|
-
|
|
38
|
-
if (kind.length === 0)
|
|
39
|
-
return 'no source kind chosen';
|
|
40
|
-
const connection = describe.connectionName(node.connectionId);
|
|
41
|
-
if (connection)
|
|
42
|
-
return `${kind} · ${connection}`;
|
|
43
|
-
return node.mode === 'incremental' ? `${kind} · incremental` : kind;
|
|
44
|
-
}
|
|
43
|
+
if (node.kind === 'source')
|
|
44
|
+
return sourceSubtitle(node, describe);
|
|
45
45
|
if (node.kind === 'sink') {
|
|
46
46
|
const type = typeof node.targetType === 'string' ? node.targetType.trim() : '';
|
|
47
47
|
return type.length > 0 ? `commits ${type}` : 'no object type chosen';
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
if (node.kind === 'call')
|
|
50
|
+
return callSubtitle(node);
|
|
51
|
+
if (node.kind === 'if')
|
|
52
|
+
return ifSubtitle(node);
|
|
53
|
+
if (node.kind === 'transform') {
|
|
54
|
+
return describe.transformName(node.transformId) ?? 'no transform chosen';
|
|
55
|
+
}
|
|
56
|
+
return unreachableNodeKind(node, 'subtitleFor');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The test, on the face of the node.
|
|
60
|
+
*
|
|
61
|
+
* Written as the condition rather than as the variable alone, because the whole
|
|
62
|
+
* question somebody reads a branch to answer is "which way does this go here",
|
|
63
|
+
* and `CLICKHOUSE_URL` on its own does not say whether it is being tested for
|
|
64
|
+
* presence or for a value. The name is shown; a value never is — the node stores
|
|
65
|
+
* the name of a variable and this screen has no more than that.
|
|
66
|
+
*
|
|
67
|
+
* The predicate is read into a variable that admits `undefined` before it is
|
|
68
|
+
* narrowed, even though the type says it is always there. This runs on whatever
|
|
69
|
+
* a server sent, and a canvas that throws while drawing a node is a screen
|
|
70
|
+
* nobody can use to fix the node — a subtitle saying the gate has no test is.
|
|
71
|
+
*/
|
|
72
|
+
function ifSubtitle(node) {
|
|
73
|
+
const predicate = node.predicate;
|
|
74
|
+
if (!predicate)
|
|
75
|
+
return 'nothing to decide on';
|
|
76
|
+
if (predicate.kind === 'env') {
|
|
77
|
+
const name = typeof predicate.envVar === 'string' ? predicate.envVar.trim() : '';
|
|
78
|
+
if (name.length === 0)
|
|
79
|
+
return 'no variable chosen';
|
|
80
|
+
return predicate.equals === undefined
|
|
81
|
+
? `if ${name} is set`
|
|
82
|
+
: `if ${name} = ${predicate.equals}`;
|
|
83
|
+
}
|
|
84
|
+
if (predicate.kind === 'rowCount') {
|
|
85
|
+
return predicate.atLeast === 1
|
|
86
|
+
? 'if any rows arrived'
|
|
87
|
+
: `if ${predicate.atLeast} rows or more arrived`;
|
|
88
|
+
}
|
|
89
|
+
return unreachablePredicateKind(predicate, 'ifSubtitle');
|
|
90
|
+
}
|
|
91
|
+
/** What a source reads from: its kind, and the connection or mode that narrows it. */
|
|
92
|
+
function sourceSubtitle(node, describe) {
|
|
93
|
+
const kind = typeof node.sourceKind === 'string' ? node.sourceKind : '';
|
|
94
|
+
if (kind.length === 0)
|
|
95
|
+
return 'no source kind chosen';
|
|
96
|
+
const connection = describe.connectionName(node.connectionId);
|
|
97
|
+
if (connection)
|
|
98
|
+
return `${kind} · ${connection}`;
|
|
99
|
+
return node.mode === 'incremental' ? `${kind} · incremental` : kind;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* `name@version`, and the version is on the face of the node deliberately.
|
|
103
|
+
*
|
|
104
|
+
* It is the half that decides which code actually runs and the half people
|
|
105
|
+
* forget is there: a node reading `billing` and a node reading `billing@2` are
|
|
106
|
+
* different loads, and only one of them is pinned. So an unpinned call says so
|
|
107
|
+
* on the canvas rather than only in the inspector nobody has open.
|
|
108
|
+
*/
|
|
109
|
+
function callSubtitle(node) {
|
|
110
|
+
const name = typeof node.callName === 'string' ? node.callName.trim() : '';
|
|
111
|
+
const version = typeof node.callVersion === 'string' ? node.callVersion.trim() : '';
|
|
112
|
+
if (name.length === 0)
|
|
113
|
+
return 'no workflow chosen';
|
|
114
|
+
return version.length > 0 ? `${name}@${version}` : `${name} · no version pinned`;
|
|
50
115
|
}
|
|
51
116
|
/**
|
|
52
117
|
* The sentence a screen reader reads when a node takes focus.
|
|
@@ -60,8 +125,17 @@ function ariaLabelFor(node, data, incoming, outgoing) {
|
|
|
60
125
|
const parts = [`${node.kind} node, ${data.label}, ${data.subtitle}`];
|
|
61
126
|
parts.push(incoming.length === 0 ? 'nothing feeds it' : `fed by ${incoming.join(', ')}`);
|
|
62
127
|
parts.push(outgoing.length === 0 ? 'feeds nothing' : `feeds ${outgoing.join(', ')}`);
|
|
63
|
-
|
|
64
|
-
|
|
128
|
+
// The branch and the reason for a skip are in here as well as in the tooltip,
|
|
129
|
+
// because on a canvas this string is the only thing a screen reader gets — and
|
|
130
|
+
// "skipped" alone cannot distinguish a node a branch stood down from a node a
|
|
131
|
+
// failure stranded, which is the one distinction this feature adds.
|
|
132
|
+
if (data.run) {
|
|
133
|
+
const branch = data.run.branch ? `, took the ${data.run.branch} branch` : '';
|
|
134
|
+
const because = data.run.skippedBecause === 'branch-not-taken'
|
|
135
|
+
? ', because it is on the branch that was not taken, so it committed nothing'
|
|
136
|
+
: '';
|
|
137
|
+
parts.push(`last run ${data.run.status}${branch}${because}`);
|
|
138
|
+
}
|
|
65
139
|
for (const problem of data.problems)
|
|
66
140
|
parts.push(problem.message);
|
|
67
141
|
return parts.join('. ');
|
|
@@ -111,31 +185,99 @@ export function defaultLabel(kind) {
|
|
|
111
185
|
return 'Source';
|
|
112
186
|
if (kind === 'sink')
|
|
113
187
|
return 'Sink';
|
|
114
|
-
|
|
188
|
+
if (kind === 'call')
|
|
189
|
+
return 'Call';
|
|
190
|
+
if (kind === 'if')
|
|
191
|
+
return 'If';
|
|
192
|
+
if (kind === 'transform')
|
|
193
|
+
return 'Transform';
|
|
194
|
+
return unreachableNodeKind(kind, 'defaultLabel');
|
|
115
195
|
}
|
|
116
|
-
|
|
196
|
+
/**
|
|
197
|
+
* How a branch is drawn: a word on the wire, and a colour that means it.
|
|
198
|
+
*
|
|
199
|
+
* A **label**, not only a colour, and that is the accessibility half rather than
|
|
200
|
+
* a stylistic one — two lines leaving one box differing by hue alone are one
|
|
201
|
+
* line as far as a colour-blind reader is concerned, and this particular
|
|
202
|
+
* distinction decides which half of a pipeline runs. Emerald for the branch
|
|
203
|
+
* taken when the test passes and zinc for the other reads as "the positive one
|
|
204
|
+
* and the fallback", which is what a then and an else are.
|
|
205
|
+
*
|
|
206
|
+
* Kept as a `Record` keyed by the label union so a third branch label added to
|
|
207
|
+
* core without a line here is a type error rather than an unlabelled grey wire.
|
|
208
|
+
*/
|
|
209
|
+
const BRANCH_STYLE = {
|
|
210
|
+
else: { stroke: '#a1a1aa', text: '#71717a' },
|
|
211
|
+
// 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.
|
|
212
|
+
then: { stroke: '#10b981', text: '#059669' },
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* The stored edges, as React Flow draws them.
|
|
216
|
+
*
|
|
217
|
+
* `flowing` is the set of edge ids whose upstream node is running right now, and
|
|
218
|
+
* it is a parameter rather than something derived here because this module knows
|
|
219
|
+
* nothing about runs. It is also **the caller's job to pass an empty set when
|
|
220
|
+
* motion is unwanted** — see `WorkflowCanvas`, which reads `prefers-reduced-motion`
|
|
221
|
+
* — because React Flow's `animated` flag is a CSS keyframe in its own stylesheet
|
|
222
|
+
* and there is nothing this package can turn off from the outside.
|
|
223
|
+
*/
|
|
224
|
+
export function toFlowEdges(edges, nodes, brokenEdgeIds, flowing = new Set()) {
|
|
117
225
|
const labelOf = new Map(nodes.map((node) => [node.id, nodeName(node)]));
|
|
118
|
-
return edges.map((edge) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
226
|
+
return edges.map((edge) => toFlowEdge(edge, {
|
|
227
|
+
from: labelOf.get(edge.from) ?? edge.from,
|
|
228
|
+
to: labelOf.get(edge.to) ?? edge.to,
|
|
229
|
+
broken: brokenEdgeIds.has(edgeId(edge)),
|
|
230
|
+
flowing: flowing.has(edgeId(edge)),
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* One wire, drawn.
|
|
235
|
+
*
|
|
236
|
+
* Split out of the `map` above so the styling decisions — arrowhead, branch
|
|
237
|
+
* colour, the red a loop wears — sit in one function that is about a wire,
|
|
238
|
+
* rather than in a closure that is also about resolving names.
|
|
239
|
+
*/
|
|
240
|
+
function toFlowEdge(edge, context) {
|
|
241
|
+
const branch = edge.branch === undefined ? undefined : BRANCH_STYLE[edge.branch];
|
|
242
|
+
return {
|
|
243
|
+
id: edgeId(edge),
|
|
244
|
+
source: edge.from,
|
|
245
|
+
target: edge.to,
|
|
246
|
+
// This package's own edge rather than the built-in `smoothstep`, because
|
|
247
|
+
// clicking a connection has to offer to remove it. See `workflow/edges.tsx`.
|
|
248
|
+
type: 'workflowEdge',
|
|
249
|
+
// The names, not the ids: they become the accessible name of the delete
|
|
250
|
+
// button, which has to say which connection it removes in the words that
|
|
251
|
+
// are on the canvas.
|
|
252
|
+
data: { fromLabel: context.from, toLabel: context.to },
|
|
253
|
+
// Marching ants while the node feeding this edge is actually running. The
|
|
254
|
+
// one thing a canvas can say about a run that a list of statuses cannot:
|
|
255
|
+
// where the work currently is.
|
|
256
|
+
animated: context.flowing,
|
|
257
|
+
// An arrowhead, because "the output of this feeds that" is directional and
|
|
258
|
+
// a plain line says only that two nodes are related.
|
|
259
|
+
markerEnd: { type: MarkerType.ArrowClosed, width: 14, height: 14 },
|
|
260
|
+
label: edge.branch,
|
|
261
|
+
labelStyle: branch ? { fill: branch.text, fontSize: 10, fontWeight: 600 } : undefined,
|
|
262
|
+
// The word sits on the wire, so it takes the canvas behind it rather than a
|
|
263
|
+
// filled plate that would blank out whatever the wire crosses.
|
|
264
|
+
labelBgStyle: branch ? { fill: 'transparent' } : undefined,
|
|
265
|
+
ariaLabel: `the output of ${context.from} feeds ${context.to}${edge.branch ? `, on the ${edge.branch} branch` : ''}${context.broken ? ', part of a loop' : ''}`,
|
|
266
|
+
// An inline stroke rather than a class, because the stroke lands on an
|
|
267
|
+
// SVG `<path>` React Flow owns: a Tailwind class on the edge wrapper does
|
|
268
|
+
// not reach it, and inventing a stylesheet rule would mean this package
|
|
269
|
+
// ships CSS for the first time just to colour one line.
|
|
270
|
+
//
|
|
271
|
+
// Broken wins over branch: a wire in a loop is a graph that will not run at
|
|
272
|
+
// all, which is a bigger fact than which side of a decision it is on.
|
|
273
|
+
style: edgeStroke(context, branch),
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/** Red for a loop, the branch's colour for a branch, React Flow's default otherwise. */
|
|
277
|
+
function edgeStroke(context, branch) {
|
|
278
|
+
if (context.broken)
|
|
279
|
+
return { stroke: '#ef4444', strokeWidth: 2 };
|
|
280
|
+
return branch ? { stroke: branch.stroke, strokeWidth: 2 } : undefined;
|
|
139
281
|
}
|
|
140
282
|
/** Who feeds each node, by node id. Every node gets an entry, most of them empty. */
|
|
141
283
|
function feedersByNode(nodes, edges) {
|
|
@@ -236,13 +378,7 @@ export function layout(nodes, edges) {
|
|
|
236
378
|
const placed = node.kind === 'sink' ? sinkColumn : (column.get(node.id) ?? 0);
|
|
237
379
|
const row = rows.get(placed) ?? 0;
|
|
238
380
|
rows.set(placed, row + 1);
|
|
239
|
-
return {
|
|
240
|
-
...node,
|
|
241
|
-
position: {
|
|
242
|
-
x: placed * (NODE_WIDTH + COLUMN_GAP),
|
|
243
|
-
y: row * (NODE_HEIGHT + ROW_GAP),
|
|
244
|
-
},
|
|
245
|
-
};
|
|
381
|
+
return { ...node, position: { x: workflowColumnX(placed), y: workflowRowY(row) } };
|
|
246
382
|
});
|
|
247
383
|
}
|
|
248
384
|
/**
|
|
@@ -293,6 +429,30 @@ export function layoutIfUnarranged(nodes, edges) {
|
|
|
293
429
|
}
|
|
294
430
|
return arranged ? nodes : layout(nodes, edges);
|
|
295
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Which edges should show their work moving, and when that is none of them.
|
|
434
|
+
*
|
|
435
|
+
* An edge flows while the node feeding it is running. That is the one thing a
|
|
436
|
+
* picture can say about a run which the per-node status list cannot: not what
|
|
437
|
+
* each step's outcome was, but where the work *is* right now.
|
|
438
|
+
*
|
|
439
|
+
* `reducedMotion` short-circuits to the empty set, and this function exists
|
|
440
|
+
* largely so that decision is a value rather than a branch inside a render.
|
|
441
|
+
* React Flow's `animated` is a CSS keyframe in its own stylesheet — there is no
|
|
442
|
+
* prop to soften it and no way to reach it from here — so the only honest
|
|
443
|
+
* accommodation is not to mark the edge at all. Nothing is lost by it: a running
|
|
444
|
+
* node still spins its own badge and the run panel still lists every step, which
|
|
445
|
+
* is the test for whether an animation was carrying information or decorating
|
|
446
|
+
* it.
|
|
447
|
+
*/
|
|
448
|
+
export function flowingEdgeIds(edges, runNodes, options) {
|
|
449
|
+
if (options.reducedMotion)
|
|
450
|
+
return new Set();
|
|
451
|
+
const running = new Set(runNodes.filter((node) => node.status === 'running').map((node) => node.nodeId));
|
|
452
|
+
if (running.size === 0)
|
|
453
|
+
return new Set();
|
|
454
|
+
return new Set(edges.filter((edge) => running.has(edge.from)).map((edge) => edgeId(edge)));
|
|
455
|
+
}
|
|
296
456
|
/**
|
|
297
457
|
* Where to drop a node somebody just added.
|
|
298
458
|
*
|
|
@@ -306,8 +466,8 @@ export function nextPosition(nodes) {
|
|
|
306
466
|
const xs = nodes.map((node) => node.position?.x ?? 0);
|
|
307
467
|
const right = Math.max(...xs);
|
|
308
468
|
const inColumn = xs.filter((x) => x === right);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
};
|
|
469
|
+
// `workflowColumnX(1)` is one whole column — the node's width plus the gap —
|
|
470
|
+
// added to wherever the rightmost node happens to be, which need not sit on a
|
|
471
|
+
// column boundary once somebody has dragged things around.
|
|
472
|
+
return { x: right + workflowColumnX(1), y: workflowRowY(inColumn.length) };
|
|
313
473
|
}
|
package/dist/workflow/index.d.ts
CHANGED
|
@@ -11,6 +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';
|
|
23
|
+
export { PublishControls, refusedForShrink, RunControls, SchedulePanel, ShrinkRefusalNote, WorkflowStatusBadge, } from './lifecycle';
|
|
24
|
+
export { RunsAsPanel } from './runs';
|
package/dist/workflow/index.js
CHANGED
|
@@ -11,6 +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';
|
|
23
|
+
// What happens to a graph once it is drawn. Here rather than on the root entry
|
|
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';
|
|
28
|
+
export { RunsAsPanel } from './runs';
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What happens to a graph after it is drawn: publish it, schedule it, run it.
|
|
3
|
+
*
|
|
4
|
+
* WHY THESE ARE ONE MODULE AND NOT PART OF THE CANVAS
|
|
5
|
+
* ---------------------------------------------------
|
|
6
|
+
* They arrived together, from a screen that no longer exists. Publishing,
|
|
7
|
+
* scheduling and running-with-an-acknowledgement all used to be connector
|
|
8
|
+
* concerns reached from `#connectors`; the connector stopped being something
|
|
9
|
+
* anybody authors, so all three landed on the graph. Putting them in the canvas
|
|
10
|
+
* file would have added four dialogs and three mutations to a component that is
|
|
11
|
+
* already the largest thing in this package, and none of them touch React Flow —
|
|
12
|
+
* which is also what lets this module be imported without a canvas at all.
|
|
13
|
+
*
|
|
14
|
+
* THE ONE THING TO BE CAREFUL WITH
|
|
15
|
+
* --------------------------------
|
|
16
|
+
* `expectShrink`. It is the only way an operator can re-drive a load the
|
|
17
|
+
* row-count bound refused, and it exists on exactly one route now. The
|
|
18
|
+
* alternative, when it is not reachable, is not "the load stays refused" — it is
|
|
19
|
+
* somebody raising `rowCount.maxShrink` in the type's policy, which stands the
|
|
20
|
+
* guard down for every future load of that type instead of for the one snapshot
|
|
21
|
+
* in front of them. So it is a visible control, it says what it does where it is
|
|
22
|
+
* used, and it will not send a blank reason.
|
|
23
|
+
*/
|
|
24
|
+
import { type WorkflowRunOptions } from '../context';
|
|
25
|
+
import type { CatalogWorkflow, WorkflowRun } from './model';
|
|
26
|
+
/**
|
|
27
|
+
* Whether a failure is the row-count bound refusing a load, rather than
|
|
28
|
+
* anything else that can go wrong in a run.
|
|
29
|
+
*
|
|
30
|
+
* Matched on the label the refusal names, which is the one token in that
|
|
31
|
+
* sentence that is not prose: the message ends by telling the reader to set
|
|
32
|
+
* `_expectShrink` in the load's labels or raise `rowCount.maxShrink`, and this
|
|
33
|
+
* screen is the place that can do the first of those in one click.
|
|
34
|
+
*
|
|
35
|
+
* A miss costs nothing — the acknowledgement control is on screen regardless,
|
|
36
|
+
* and this only decides whether the refusal itself grows a way straight into it.
|
|
37
|
+
* That is deliberately the weaker of the two paths: a console that could offer
|
|
38
|
+
* the escape hatch *only* after a refusal would be a console where an operator
|
|
39
|
+
* who already knows a truncation is coming has to trigger a failed load first.
|
|
40
|
+
*/
|
|
41
|
+
export declare function refusedForShrink(message: string | undefined): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Draft or ready, and — where it applies — who decided.
|
|
44
|
+
*
|
|
45
|
+
* Rendered even for `draft`, which is the status a screen is tempted to leave
|
|
46
|
+
* unsaid because it is the default. It is not decoration: a draft cannot be
|
|
47
|
+
* scheduled and does not run on its own, so "why did my pipeline not fire last
|
|
48
|
+
* night" has its answer here.
|
|
49
|
+
*/
|
|
50
|
+
export declare function WorkflowStatusBadge({ workflow }: {
|
|
51
|
+
workflow: CatalogWorkflow;
|
|
52
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
/**
|
|
54
|
+
* Publish, or take it back to draft.
|
|
55
|
+
*
|
|
56
|
+
* Publishing is not offered while the canvas has unsaved edits, and that is the
|
|
57
|
+
* one place on this screen where blocking is right: publishing validates the
|
|
58
|
+
* STORED graph, so pressing it with edits on screen would report on a shape
|
|
59
|
+
* nobody is looking at — and, worse, would succeed on it.
|
|
60
|
+
*
|
|
61
|
+
* The local checks do not gate it. They cannot see which types exist or who may
|
|
62
|
+
* write to them, and a rule that is subtly wrong here would become a graph
|
|
63
|
+
* nobody can publish with no error to read. The server refuses, in its own
|
|
64
|
+
* words, and those words are what gets rendered.
|
|
65
|
+
*/
|
|
66
|
+
export declare function PublishControls({ workflow, dirty, canEdit, onPublished, }: {
|
|
67
|
+
workflow: CatalogWorkflow;
|
|
68
|
+
dirty: boolean;
|
|
69
|
+
canEdit: boolean;
|
|
70
|
+
onPublished: (workflow: CatalogWorkflow) => void;
|
|
71
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
/**
|
|
73
|
+
* Run it now, and the one thing a run may be told about itself.
|
|
74
|
+
*
|
|
75
|
+
* Two controls rather than one, and deliberately not a checkbox tucked beside
|
|
76
|
+
* the button: an acknowledgement that a load is expected to lose most of its
|
|
77
|
+
* rows is not a preference, it is a statement somebody signs. The second control
|
|
78
|
+
* opens a dialog that says exactly what it is about to do and refuses to submit
|
|
79
|
+
* without a reason — the reason is written into the snapshot's labels and is the
|
|
80
|
+
* only answer anybody will have in six months to "why was this load allowed to
|
|
81
|
+
* collapse?".
|
|
82
|
+
*
|
|
83
|
+
* It is on screen always, not only after a refusal. An operator who already
|
|
84
|
+
* knows a base is being cut should not have to trigger a failed load first in
|
|
85
|
+
* order to be offered the way through it.
|
|
86
|
+
*/
|
|
87
|
+
export declare function RunControls({ workflowId, dirty, canEdit, running, durabilityDetail, acknowledging, onAcknowledgingChange, onRun, }: {
|
|
88
|
+
workflowId: string | undefined;
|
|
89
|
+
dirty: boolean;
|
|
90
|
+
canEdit: boolean;
|
|
91
|
+
running: boolean;
|
|
92
|
+
durabilityDetail: string;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the acknowledgement dialog is open, held by the CALLER.
|
|
95
|
+
*
|
|
96
|
+
* Controlled rather than internal because there are two ways in and they are
|
|
97
|
+
* in different parts of the screen: the icon button here, and the refusal
|
|
98
|
+
* note that appears after a load the bound turned away — which is the moment
|
|
99
|
+
* somebody most needs it and is nowhere near this row of buttons.
|
|
100
|
+
*/
|
|
101
|
+
acknowledging: boolean;
|
|
102
|
+
onAcknowledgingChange: (open: boolean) => void;
|
|
103
|
+
onRun: (options?: WorkflowRunOptions) => void;
|
|
104
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
105
|
+
/**
|
|
106
|
+
* When this graph runs on its own.
|
|
107
|
+
*
|
|
108
|
+
* Its own write, `PUT workflows/:id/schedule`, rather than fields folded into
|
|
109
|
+
* the save the canvas performs on every drag — a cron that rides along with an
|
|
110
|
+
* autosave is one a stale tab can silently revert.
|
|
111
|
+
*
|
|
112
|
+
* The `warning` is the reason this panel does not just show a text box. There
|
|
113
|
+
* are several ways to store a cron that will never fire — the graph is a draft,
|
|
114
|
+
* the graph is disabled, the expression does not parse — and the incident behind
|
|
115
|
+
* this route is a scheduler that logged it was watching schedules every 30
|
|
116
|
+
* seconds while parsing nothing. The server names which one, and this prints it.
|
|
117
|
+
*/
|
|
118
|
+
export declare function SchedulePanel({ workflow, canEdit, onScheduled, }: {
|
|
119
|
+
workflow: CatalogWorkflow;
|
|
120
|
+
canEdit: boolean;
|
|
121
|
+
onScheduled: (workflow: CatalogWorkflow) => void;
|
|
122
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
123
|
+
/**
|
|
124
|
+
* A run that was refused by the row-count bound, with the way through it.
|
|
125
|
+
*
|
|
126
|
+
* The refusal itself is the server's sentence and is printed whole. What this
|
|
127
|
+
* adds is the one action that answers it, at the moment somebody is reading the
|
|
128
|
+
* reason — because the alternative they will otherwise reach for is the type's
|
|
129
|
+
* policy, which is the wrong lever and the hard one to put back.
|
|
130
|
+
*/
|
|
131
|
+
export declare function ShrinkRefusalNote({ run, error, onAcknowledge, }: {
|
|
132
|
+
run: WorkflowRun | null;
|
|
133
|
+
error: unknown;
|
|
134
|
+
onAcknowledge: () => void;
|
|
135
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|