@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/nodes.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type NodeProps } from '@xyflow/react';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
|
-
import type
|
|
3
|
+
import { type WorkflowFlowNode } from './graph';
|
|
4
|
+
import type { WorkflowWiring } from './wiring';
|
|
4
5
|
/**
|
|
5
6
|
* What a node can reach without being handed a callback in its `data`.
|
|
6
7
|
*
|
|
@@ -20,6 +21,8 @@ interface WorkflowNodeHandlers {
|
|
|
20
21
|
onEditCode(nodeId: string): void;
|
|
21
22
|
/** Whether editing is offered at all. */
|
|
22
23
|
canEdit: boolean;
|
|
24
|
+
/** Click-to-click wiring: what a click on a handle does, and what is in flight. */
|
|
25
|
+
wiring: WorkflowWiring;
|
|
23
26
|
}
|
|
24
27
|
export declare function WorkflowNodeProvider({ handlers, children, }: {
|
|
25
28
|
handlers: WorkflowNodeHandlers;
|
package/dist/workflow/nodes.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Handle, Position } from '@xyflow/react';
|
|
3
|
-
import { CircleAlert, CircleCheck, Code2, Database, ExternalLink, Loader2, Plug, Repeat, TriangleAlert, } from 'lucide-react';
|
|
4
|
-
import {
|
|
3
|
+
import { CircleAlert, CircleCheck, CircleSlash, Code2, Database, ExternalLink, Filter, GitBranch, Loader2, Plug, Repeat, TriangleAlert, } from 'lucide-react';
|
|
4
|
+
import { motion, useReducedMotion } from 'motion/react';
|
|
5
|
+
import { createContext, useContext, } from 'react';
|
|
5
6
|
import { cn } from '../cn';
|
|
6
7
|
import { Tooltip } from '../ui/tooltip';
|
|
8
|
+
import { NODE_WIDTH, describeDrop } from './graph';
|
|
7
9
|
const RULE = 'border-zinc-200 dark:border-zinc-800';
|
|
8
10
|
const PANEL = 'bg-white dark:bg-zinc-900';
|
|
9
11
|
const MUTED = 'text-zinc-400 dark:text-zinc-500';
|
|
@@ -18,22 +20,45 @@ function useWorkflowNodeHandlers() {
|
|
|
18
20
|
}
|
|
19
21
|
return handlers;
|
|
20
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* The per-kind palette, in three coordinated pieces rather than one accent.
|
|
25
|
+
*
|
|
26
|
+
* `accent` is the rail down the left edge, `chip` colours the icon and the kind
|
|
27
|
+
* word, and `wash` tints the strip they sit in. Three tokens per kind rather
|
|
28
|
+
* than one, because a single accent bar on an otherwise identical white box
|
|
29
|
+
* meant the four kinds were told apart by four pixels of colour — which at the
|
|
30
|
+
* zoom people actually work at is no difference at all.
|
|
31
|
+
*
|
|
32
|
+
* Every entry names a `dark:` variant, and that is not decoration: this canvas
|
|
33
|
+
* is embedded in a host whose theme it follows (see `CANVAS_THEME`), and a
|
|
34
|
+
* colour with no dark counterpart is the failure mode that has bitten the
|
|
35
|
+
* dropdowns in this package before — legible on the theme it was written on,
|
|
36
|
+
* unreadable on the other.
|
|
37
|
+
*
|
|
38
|
+
* The rail is a gradient rather than a flat fill. It is 4px wide and runs the
|
|
39
|
+
* full height of the box, which is exactly the shape where a flat fill reads as
|
|
40
|
+
* a printing error and a gradient reads as an edge — and it is the only piece of
|
|
41
|
+
* a node that carries its kind at a glance from across the canvas.
|
|
42
|
+
*/
|
|
21
43
|
const KIND_STYLE = {
|
|
22
44
|
source: {
|
|
23
|
-
accent: 'bg-sky-
|
|
45
|
+
accent: 'bg-gradient-to-b from-sky-400 to-sky-600',
|
|
24
46
|
chip: 'text-sky-700 dark:text-sky-300',
|
|
47
|
+
wash: 'bg-sky-50/70 dark:bg-sky-950/30',
|
|
25
48
|
icon: Plug,
|
|
26
49
|
noun: 'source',
|
|
27
50
|
},
|
|
28
51
|
transform: {
|
|
29
|
-
accent: 'bg-
|
|
30
|
-
chip: 'text-
|
|
52
|
+
accent: 'bg-gradient-to-b from-violet-400 to-violet-600',
|
|
53
|
+
chip: 'text-violet-700 dark:text-violet-300',
|
|
54
|
+
wash: 'bg-violet-50/70 dark:bg-violet-950/30',
|
|
31
55
|
icon: Repeat,
|
|
32
56
|
noun: 'transform',
|
|
33
57
|
},
|
|
34
58
|
sink: {
|
|
35
|
-
accent: 'bg-emerald-
|
|
59
|
+
accent: 'bg-gradient-to-b from-emerald-400 to-emerald-600',
|
|
36
60
|
chip: 'text-emerald-700 dark:text-emerald-300',
|
|
61
|
+
wash: 'bg-emerald-50/70 dark:bg-emerald-950/30',
|
|
37
62
|
icon: Database,
|
|
38
63
|
noun: 'sink',
|
|
39
64
|
},
|
|
@@ -41,11 +66,37 @@ const KIND_STYLE = {
|
|
|
41
66
|
// happen here: the box on the canvas is a handle on a workflow somebody else
|
|
42
67
|
// owns, and it should not read as another transform.
|
|
43
68
|
call: {
|
|
44
|
-
accent: 'bg-amber-
|
|
69
|
+
accent: 'bg-gradient-to-b from-amber-400 to-amber-600',
|
|
45
70
|
chip: 'text-amber-700 dark:text-amber-300',
|
|
71
|
+
wash: 'bg-amber-50/70 dark:bg-amber-950/30',
|
|
46
72
|
icon: ExternalLink,
|
|
47
73
|
noun: 'call',
|
|
48
74
|
},
|
|
75
|
+
// Violet and a fork, because an if is the only node whose effect is on the
|
|
76
|
+
// *graph* rather than on the rows: everything else here does something to
|
|
77
|
+
// data, and this one decides which boxes exist for this run. It should not
|
|
78
|
+
// read as another step in the line.
|
|
79
|
+
if: {
|
|
80
|
+
accent: 'bg-gradient-to-b from-fuchsia-400 to-fuchsia-600',
|
|
81
|
+
chip: 'text-fuchsia-700 dark:text-fuchsia-300',
|
|
82
|
+
wash: 'bg-fuchsia-50/70 dark:bg-fuchsia-950/30',
|
|
83
|
+
icon: GitBranch,
|
|
84
|
+
noun: 'if',
|
|
85
|
+
},
|
|
86
|
+
// Rose and a funnel. It is the only kind whose effect is *subtraction* — every
|
|
87
|
+
// other node either produces rows, reshapes them or decides which boxes run —
|
|
88
|
+
// and the whole reason it is a node rather than a transform returning a subset
|
|
89
|
+
// is that "rows are being dropped here" should be visible without opening
|
|
90
|
+
// anything. Deliberately not the fuchsia an `if` wears: both of them make a
|
|
91
|
+
// load smaller and they do it in completely different ways, so they are the
|
|
92
|
+
// two that must never be confused at a glance.
|
|
93
|
+
filter: {
|
|
94
|
+
accent: 'bg-gradient-to-b from-rose-400 to-rose-600',
|
|
95
|
+
chip: 'text-rose-700 dark:text-rose-300',
|
|
96
|
+
wash: 'bg-rose-50/70 dark:bg-rose-950/30',
|
|
97
|
+
icon: Filter,
|
|
98
|
+
noun: 'filter',
|
|
99
|
+
},
|
|
49
100
|
};
|
|
50
101
|
/**
|
|
51
102
|
* Handles are styled larger than React Flow's default 6px dot.
|
|
@@ -55,11 +106,76 @@ const KIND_STYLE = {
|
|
|
55
106
|
* drag on one. `connectionRadius` on the canvas widens the drop zone; this
|
|
56
107
|
* widens what you can see to aim at.
|
|
57
108
|
*/
|
|
58
|
-
const HANDLE = cn('!h-3 !w-3 !rounded-full !border-2', '!border-zinc-300 !bg-white dark:!border-zinc-600 dark:!bg-zinc-800',
|
|
109
|
+
const HANDLE = cn('!h-3 !w-3 !rounded-full !border-2 !transition-all !duration-150', '!border-zinc-300 !bg-white dark:!border-zinc-600 dark:!bg-zinc-800',
|
|
110
|
+
// A pointer, not a crosshair: a click is now enough. See `wiring.tsx`.
|
|
111
|
+
'!cursor-pointer',
|
|
112
|
+
// Grows under the pointer, so the thing you are about to click
|
|
113
|
+
// acknowledges you before you commit to it.
|
|
114
|
+
'hover:!scale-125 hover:!border-violet-400', 'focus-visible:!outline-none focus-visible:!ring-2 focus-visible:!ring-sky-500/50',
|
|
59
115
|
// React Flow adds these while a connection is being dragged. Colouring them
|
|
60
116
|
// is what makes an illegal target — one that would close a loop, or a source
|
|
61
117
|
// that takes no input — visibly refuse *before* the mouse is released.
|
|
62
118
|
'[.react-flow__handle-connecting&]:!border-red-500', '[.react-flow__handle-valid&]:!border-emerald-500 [.react-flow__handle-valid&]:!bg-emerald-500');
|
|
119
|
+
const HANDLE_WIRING = {
|
|
120
|
+
idle: '',
|
|
121
|
+
origin: '!border-violet-500 !bg-violet-500 !ring-4 !ring-violet-500/25',
|
|
122
|
+
open: cn('!border-emerald-500 !bg-emerald-500 !ring-4 !ring-emerald-500/25', 'motion-safe:!animate-pulse'),
|
|
123
|
+
shut: '!opacity-20',
|
|
124
|
+
};
|
|
125
|
+
function handleWiringState(wiring, nodeId, type) {
|
|
126
|
+
const { pending } = wiring;
|
|
127
|
+
if (!pending)
|
|
128
|
+
return 'idle';
|
|
129
|
+
if (pending.nodeId === nodeId && pending.type === type)
|
|
130
|
+
return 'origin';
|
|
131
|
+
return wiring.accepts(nodeId, type) ? 'open' : 'shut';
|
|
132
|
+
}
|
|
133
|
+
/** The box's version of {@link handleWiringState}. Drawn on the whole node. */
|
|
134
|
+
function nodeWiringState(wiring, nodeId) {
|
|
135
|
+
if (!wiring.pending)
|
|
136
|
+
return 'idle';
|
|
137
|
+
if (wiring.pending.nodeId === nodeId)
|
|
138
|
+
return 'origin';
|
|
139
|
+
if (wiring.accepts(nodeId, 'target') || wiring.accepts(nodeId, 'source'))
|
|
140
|
+
return 'open';
|
|
141
|
+
return 'shut';
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The props that turn a handle into something a click, or a key, can operate.
|
|
145
|
+
*
|
|
146
|
+
* Spread onto `<Handle>` rather than written inline twice, because the two
|
|
147
|
+
* handles differ only in which side of the node they are. React Flow spreads its
|
|
148
|
+
* own rest props last, so an `onClick` given here is the one that runs — and the
|
|
149
|
+
* canvas turns `connectOnClick` off besides, so there is exactly one click path
|
|
150
|
+
* and it is this one. `onMouseDown` is untouched: that is where the drag lives,
|
|
151
|
+
* and the drag still works.
|
|
152
|
+
*
|
|
153
|
+
* `role`/`tabIndex`/`onKeyDown` because a handle is now a control, and a control
|
|
154
|
+
* that only a pointer can reach is not one. React Flow renders a `<div>`, so the
|
|
155
|
+
* button semantics have to be stated rather than inherited.
|
|
156
|
+
*/
|
|
157
|
+
function wireOn(nodeId, type, wiring) {
|
|
158
|
+
const start = () => wiring.onHandleClick(nodeId, type);
|
|
159
|
+
return {
|
|
160
|
+
role: 'button',
|
|
161
|
+
tabIndex: 0,
|
|
162
|
+
onClick: (event) => {
|
|
163
|
+
// Kept off the node underneath, which would otherwise read the same click
|
|
164
|
+
// as "open this node's inspector" and cover the canvas with a sheet.
|
|
165
|
+
event.stopPropagation();
|
|
166
|
+
start();
|
|
167
|
+
},
|
|
168
|
+
onKeyDown: (event) => {
|
|
169
|
+
if (event.key !== 'Enter' && event.key !== ' ')
|
|
170
|
+
return;
|
|
171
|
+
// Space on a focused element scrolls the page by default, and Enter would
|
|
172
|
+
// reach the node's own key handling.
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
event.stopPropagation();
|
|
175
|
+
start();
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
63
179
|
function RunBadge({ run }) {
|
|
64
180
|
if (run.status === 'running') {
|
|
65
181
|
return (_jsx(Tooltip, { content: "Running now.", children: _jsx("span", { className: "flex items-center", children: _jsx(Loader2, { size: 11, className: "animate-spin text-sky-500" }) }) }));
|
|
@@ -72,17 +188,116 @@ function RunBadge({ run }) {
|
|
|
72
188
|
? // The single most useful fact on a resumed run, and there is
|
|
73
189
|
// nowhere else on the screen to read it from.
|
|
74
190
|
'Replayed from a checkpoint — this step did not run again.'
|
|
75
|
-
:
|
|
191
|
+
: // A filter reports the pair rather than the total, and it is the
|
|
192
|
+
// one kind for which "42 rows" would be an actively misleading
|
|
193
|
+
// badge: the number that matters is what it *removed*, and a node
|
|
194
|
+
// that showed only its output would make a filter that dropped
|
|
195
|
+
// nine tenths of a load look identical to a source that read a
|
|
196
|
+
// tenth as much. `describeDrop` answers for filters and stays
|
|
197
|
+
// silent for everything else, so this stays one expression.
|
|
198
|
+
`${describeBranchTaken(run) ?? 'Ran'}${describeRunSize(run)}.`, children: _jsx("span", { className: "flex items-center", children: _jsx(CircleCheck, { size: 11, className: run.replayed ? 'text-zinc-400' : 'text-emerald-500' }) }) }));
|
|
199
|
+
}
|
|
200
|
+
// Drawn rather than left blank, which is what this was.
|
|
201
|
+
//
|
|
202
|
+
// A skipped node used to render nothing at all, which was defensible while
|
|
203
|
+
// `skipped` meant only "the run stopped before here" — the failed node beside
|
|
204
|
+
// it carried the story. It is not defensible now that a node can be skipped by
|
|
205
|
+
// a branch on a run that went perfectly: a sink that quietly shows no badge is
|
|
206
|
+
// exactly the "nothing loaded and nothing said so" this feature has to avoid.
|
|
207
|
+
if (run.status === 'skipped') {
|
|
208
|
+
return (_jsx(Tooltip, { content: describeSkip(run), children: _jsx("span", { className: "flex items-center", children: _jsx(CircleSlash, { size: 11, className: "text-zinc-400" }) }) }));
|
|
76
209
|
}
|
|
77
210
|
return null;
|
|
78
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* How a node arrives.
|
|
214
|
+
*
|
|
215
|
+
* On mount only, so it plays when a graph is opened and when somebody adds a box
|
|
216
|
+
* — and not while one is dragged, because dragging does not remount. Scale from
|
|
217
|
+
* just under one rather than from zero: the node grows into place instead of
|
|
218
|
+
* being inflated, which at eight nodes on a canvas is the difference between a
|
|
219
|
+
* screen settling and a screen erupting.
|
|
220
|
+
*
|
|
221
|
+
* Under `prefers-reduced-motion` the node is simply there. Nothing is conveyed
|
|
222
|
+
* by the arrival that its presence does not already convey, which is the test
|
|
223
|
+
* for whether skipping an animation costs anybody information.
|
|
224
|
+
*/
|
|
225
|
+
const ARRIVE = { type: 'spring', stiffness: 420, damping: 34, mass: 0.7 };
|
|
226
|
+
/**
|
|
227
|
+
* How much data went through a node, in the terms that node is measured in.
|
|
228
|
+
*
|
|
229
|
+
* A filter reports the pair — in, out, and what that means as a share — because
|
|
230
|
+
* for a filter the number that matters is what it *removed*, and a badge showing
|
|
231
|
+
* only its output would make one that dropped nine tenths of a load look exactly
|
|
232
|
+
* like a source that read a tenth as much. Everything else reports what it
|
|
233
|
+
* produced, which is what "rows" has always meant on this badge.
|
|
234
|
+
*/
|
|
235
|
+
function describeRunSize(run) {
|
|
236
|
+
const dropped = describeDrop(run);
|
|
237
|
+
if (dropped)
|
|
238
|
+
return `: ${dropped}`;
|
|
239
|
+
return typeof run.rows === 'number' ? `, ${run.rows} rows` : '';
|
|
240
|
+
}
|
|
241
|
+
/** What an `if` node's badge says it decided. Absent on every other kind. */
|
|
242
|
+
function describeBranchTaken(run) {
|
|
243
|
+
if (!run?.branch)
|
|
244
|
+
return undefined;
|
|
245
|
+
return `Took the "${run.branch}" branch`;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The two meanings of `skipped`, told apart.
|
|
249
|
+
*
|
|
250
|
+
* The branch wording deliberately says what did **not** happen to the data,
|
|
251
|
+
* because for a sink that is the whole question: a node that never ran committed
|
|
252
|
+
* nothing, so whatever was published before this run is still published. A
|
|
253
|
+
* reader who is not told that assumes the load emptied it.
|
|
254
|
+
*/
|
|
255
|
+
function describeSkip(run) {
|
|
256
|
+
if (run.skippedBecause === 'branch-not-taken') {
|
|
257
|
+
return 'Skipped: this is on the branch that was not taken. It did not run, so it wrote nothing and committed nothing — anything it publishes is still whatever was there before this run.';
|
|
258
|
+
}
|
|
259
|
+
return 'Skipped: the run stopped before reaching this step.';
|
|
260
|
+
}
|
|
79
261
|
export function WorkflowNodeBody({ id, data, selected }) {
|
|
80
|
-
const { onInspect, onEditCode, canEdit } = useWorkflowNodeHandlers();
|
|
262
|
+
const { onInspect, onEditCode, canEdit, wiring } = useWorkflowNodeHandlers();
|
|
263
|
+
const reduced = useReducedMotion();
|
|
81
264
|
const style = KIND_STYLE[data.kind];
|
|
82
265
|
const Icon = style.icon;
|
|
83
266
|
const errors = data.problems.filter((problem) => problem.level === 'error');
|
|
84
267
|
const warnings = data.problems.filter((problem) => problem.level === 'warning');
|
|
85
|
-
|
|
268
|
+
const landing = nodeWiringState(wiring, id);
|
|
269
|
+
return (_jsxs(motion.div
|
|
270
|
+
// The width comes from the constant rather than from a `w-56` class, and
|
|
271
|
+
// that is the whole mechanism behind the overlap fix: `WORKFLOW_NODE_WIDTH`
|
|
272
|
+
// is what the server spaces its columns by, so a node whose drawn width
|
|
273
|
+
// came from somewhere else could silently stop matching the layout that
|
|
274
|
+
// was computed for it. There is now one number and no way to change the
|
|
275
|
+
// box without changing it.
|
|
276
|
+
//
|
|
277
|
+
// A width in `style` rather than an animated value, deliberately: React
|
|
278
|
+
// Flow measures `offsetWidth` to place the edges, and a width mid-tween
|
|
279
|
+
// would move every connection while it settled.
|
|
280
|
+
, {
|
|
281
|
+
// The width comes from the constant rather than from a `w-56` class, and
|
|
282
|
+
// that is the whole mechanism behind the overlap fix: `WORKFLOW_NODE_WIDTH`
|
|
283
|
+
// is what the server spaces its columns by, so a node whose drawn width
|
|
284
|
+
// came from somewhere else could silently stop matching the layout that
|
|
285
|
+
// was computed for it. There is now one number and no way to change the
|
|
286
|
+
// box without changing it.
|
|
287
|
+
//
|
|
288
|
+
// A width in `style` rather than an animated value, deliberately: React
|
|
289
|
+
// Flow measures `offsetWidth` to place the edges, and a width mid-tween
|
|
290
|
+
// would move every connection while it settled.
|
|
291
|
+
style: { width: NODE_WIDTH }, initial: reduced ? false : { opacity: 0, scale: 0.94 }, animate: { opacity: 1, scale: 1 }, transition: reduced ? { duration: 0 } : ARRIVE, className: cn('group/node relative overflow-hidden rounded-xl border',
|
|
292
|
+
// A lift on hover and a deeper one while selected. `transition-all`
|
|
293
|
+
// rather than `transition-shadow` because the ring width changes too,
|
|
294
|
+
// and a ring that snaps while the shadow fades reads as a glitch.
|
|
295
|
+
'shadow-sm transition-all duration-150 motion-safe:hover:-translate-y-0.5 hover:shadow-lg', 'hover:border-zinc-300 dark:hover:border-zinc-700', RULE, PANEL, selected && 'shadow-md ring-2 ring-sky-500/50 dark:ring-sky-400/50', errors.length > 0 && 'border-red-400 dark:border-red-800', errors.length === 0 && warnings.length > 0 && 'border-amber-300 dark:border-amber-800',
|
|
296
|
+
// While a wire is open, the whole box says whether it can take it — the
|
|
297
|
+
// handle is 12px across and the node is 224, and somebody looking for
|
|
298
|
+
// "where can this go" is looking at boxes. Same judgement, same
|
|
299
|
+
// function, drawn bigger.
|
|
300
|
+
landing === 'open' && 'ring-2 ring-emerald-500/45 dark:ring-emerald-400/45', landing === 'origin' && 'ring-2 ring-violet-500/50 dark:ring-violet-400/50', landing === 'shut' && 'opacity-40'), children: [_jsx("span", { className: cn('absolute inset-y-0 left-0 w-1', style.accent) }), data.kind !== 'source' && (_jsx(Handle, { type: "target", position: Position.Left, className: cn(HANDLE, HANDLE_WIRING[handleWiringState(wiring, id, 'target')]), "aria-label": `input of ${data.label}`, ...wireOn(id, 'target', wiring) })), data.kind !== 'sink' && (_jsx(Handle, { type: "source", position: Position.Right, className: cn(HANDLE, HANDLE_WIRING[handleWiringState(wiring, id, 'source')]), "aria-label": `output of ${data.label}`, ...wireOn(id, 'source', wiring) })), _jsxs("div", { className: cn('flex items-center gap-1.5 border-b pl-3 pr-2 py-1', RULE, style.wash), children: [_jsx(Icon, { size: 12, className: style.chip }), _jsx("span", { className: cn('font-mono text-[9px] uppercase tracking-[0.16em]', style.chip), children: style.noun }), _jsxs("span", { className: "ml-auto flex items-center gap-1", children: [data.run && _jsx(RunBadge, { run: data.run }), errors.length > 0 && (_jsx(Tooltip, { content: errors.map((p) => p.message).join(' '), children: _jsx("span", { className: "flex items-center", children: _jsx(CircleAlert, { size: 11, className: "text-red-500" }) }) })), errors.length === 0 && warnings.length > 0 && (_jsx(Tooltip, { content: warnings.map((p) => p.message).join(' '), children: _jsx("span", { className: "flex items-center", children: _jsx(TriangleAlert, { size: 11, className: "text-amber-500" }) }) }))] })] }), _jsxs("div", { className: "pl-3 pr-2 py-2", children: [_jsxs("button", { type: "button", onClick: () => onInspect(id), className: "nodrag block w-full text-left", children: [_jsx("span", { className: "block truncate text-[13px] font-medium leading-snug", children: data.label }), _jsx("span", { className: cn('mt-0.5 block truncate font-mono text-[10px]', MUTED), children: data.subtitle })] }), data.kind === 'transform' && canEdit && (_jsx("div", { className: "mt-1.5 flex", children: _jsx(Tooltip, { content: "Open this transform's code. The canvas stays where it is.", children: _jsxs("button", { type: "button", onClick: () => onEditCode(id), "aria-label": `Edit the code behind ${data.label}`, className: cn('nodrag flex items-center gap-1 rounded border px-1.5 py-0.5 font-mono text-[9px]', 'transition-colors', RULE, MUTED, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Code2, { size: 9 }), "code"] }) }) }))] })] }));
|
|
86
301
|
}
|
|
87
302
|
/**
|
|
88
303
|
* Declared once, at module scope.
|
|
@@ -56,6 +56,27 @@ const NODE_FACTORIES = {
|
|
|
56
56
|
// deployment's registrations to offer a choice from. The factory is complete
|
|
57
57
|
// so that a template CAN build one the day a case is worth prefilling.
|
|
58
58
|
call: (id, name, init) => ({ id, name, kind: 'call', ...init }),
|
|
59
|
+
// `if` arrived the same way `call` did, and the map stopped the build again.
|
|
60
|
+
//
|
|
61
|
+
// Also unused by every template below, for a reason of its own: which
|
|
62
|
+
// environment variable tells one deployment apart from another is the entire
|
|
63
|
+
// content of a gate, and it is knowledge about a *deployment* rather than
|
|
64
|
+
// about a pipeline shape. A template that guessed one would prefill a decision
|
|
65
|
+
// that is wrong everywhere except where it was written — and a branch that is
|
|
66
|
+
// wrong is a half of the graph that silently does not run, which is the one
|
|
67
|
+
// failure this node had to be built not to have.
|
|
68
|
+
if: (id, name, init) => ({ id, name, kind: 'if', ...init }),
|
|
69
|
+
// `filter` arrived third, and the map stopped the build a third time.
|
|
70
|
+
//
|
|
71
|
+
// Also unused by every template below, and this one is the clearest case of
|
|
72
|
+
// the three. A filter's content is a *column name and a value* — which are
|
|
73
|
+
// facts about one organisation's data, not about a pipeline shape — and a
|
|
74
|
+
// template that guessed `status = "OPEN"` would prefill a predicate that is
|
|
75
|
+
// wrong everywhere it is opened. Worse, a prefilled filter sitting in front of
|
|
76
|
+
// a sink is precisely the accident `WorkflowFilterNode.narrows` exists to make
|
|
77
|
+
// impossible: the template would be shipping a graph that shrinks a published
|
|
78
|
+
// type, with nobody having chosen it.
|
|
79
|
+
filter: (id, name, init) => ({ id, name, kind: 'filter', ...init }),
|
|
59
80
|
};
|
|
60
81
|
/* -------------------------------------------------------------------------- */
|
|
61
82
|
/* Starter transform code */
|
|
@@ -204,6 +204,17 @@ export function canConnect(nodes, edges, from, to) {
|
|
|
204
204
|
reason: `Those two are already wired together, and wiring them twice would send "${nodeName(target)}" the same rows twice.`,
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
|
+
// Refused a moment before core would, exactly like every other rule here. An
|
|
208
|
+
// if node hands its successors the stage it was given rather than a copy, so
|
|
209
|
+
// it carries one stream and one only; a second inbound wire would be silently
|
|
210
|
+
// dropped, which is the failure mode this screen exists to make visible while
|
|
211
|
+
// somebody is still dragging.
|
|
212
|
+
if (target.kind === 'if' && edges.some((edge) => edge.to === to)) {
|
|
213
|
+
return {
|
|
214
|
+
ok: false,
|
|
215
|
+
reason: `"${nodeName(target)}" already has something feeding it. An if node is a gate — it passes one stream straight down whichever branch it takes — so it cannot merge two. Wire both into a transform and gate that instead.`,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
207
218
|
if (wouldCycle(edges, from, to)) {
|
|
208
219
|
return {
|
|
209
220
|
ok: false,
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type WorkflowEdge, type WorkflowNode } from './model';
|
|
2
|
+
/** Which side of a node a handle is. React Flow's word, not the node's kind. */
|
|
3
|
+
export type WiringHandleType = 'source' | 'target';
|
|
4
|
+
/** The handle a click-to-click connection is being drawn from. */
|
|
5
|
+
export interface PendingWire {
|
|
6
|
+
nodeId: string;
|
|
7
|
+
type: WiringHandleType;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* What a node needs in order to take part in click-to-click wiring.
|
|
11
|
+
*
|
|
12
|
+
* Handed down the same context the node's other callbacks travel in, for the
|
|
13
|
+
* same reason: React Flow rebuilds a node's props from `data`, so anything
|
|
14
|
+
* function-shaped in there invalidates every node on every render of the screen.
|
|
15
|
+
*/
|
|
16
|
+
export interface WorkflowWiring {
|
|
17
|
+
/** The handle a wire is currently coming out of, or null almost always. */
|
|
18
|
+
pending: PendingWire | null;
|
|
19
|
+
/** A click landed on a handle. The whole gesture is two of these. */
|
|
20
|
+
onHandleClick(nodeId: string, type: WiringHandleType): void;
|
|
21
|
+
/**
|
|
22
|
+
* Could the wire being drawn right now legally end on this handle?
|
|
23
|
+
*
|
|
24
|
+
* False whenever nothing is being drawn, so a resting canvas is not a canvas
|
|
25
|
+
* of green dots. Used only to colour handles — the answer is asked again, from
|
|
26
|
+
* the same function, when the click actually arrives.
|
|
27
|
+
*/
|
|
28
|
+
accepts(nodeId: string, type: WiringHandleType): boolean;
|
|
29
|
+
/** Put the half-drawn wire away. The pane, Escape, and the hint's button. */
|
|
30
|
+
cancel(): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The two-click gesture, and the sentence it says when it refuses.
|
|
34
|
+
*
|
|
35
|
+
* The refusal is kept in state rather than only announced, because the whole
|
|
36
|
+
* point of moving this off the drag is that a click has no "hold it there and
|
|
37
|
+
* look at the red handle" moment. A click that is not allowed has to say so in
|
|
38
|
+
* words that stay on the screen, and {@link WiringHint} is where they go.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useClickWiring({ canEdit, nodes, edges, onConnect, onSay, }: {
|
|
41
|
+
canEdit: boolean;
|
|
42
|
+
nodes: WorkflowNode[];
|
|
43
|
+
edges: WorkflowEdge[];
|
|
44
|
+
/** Make the connection. Already validated by the time this is called. */
|
|
45
|
+
onConnect(from: string, to: string): void;
|
|
46
|
+
/** The live region. Everything visible here is also said out loud. */
|
|
47
|
+
onSay(sentence: string): void;
|
|
48
|
+
}): {
|
|
49
|
+
wiring: WorkflowWiring;
|
|
50
|
+
refusal: string | null;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The line that follows the pointer while a click-started wire is open.
|
|
54
|
+
*
|
|
55
|
+
* React Flow will not draw this one — see the note at the top of this file — so
|
|
56
|
+
* it is drawn here, into `ViewportPortal`, which puts it in the same transformed
|
|
57
|
+
* layer as the edges. That is what keeps it registered with the graph while
|
|
58
|
+
* somebody pans or zooms mid-gesture; arithmetic on the viewport transform in
|
|
59
|
+
* this file would be a second, worse copy of what that portal already does.
|
|
60
|
+
*
|
|
61
|
+
* Dashed and travelling, because a wire that is not committed yet should not
|
|
62
|
+
* look like one that is. Under `prefers-reduced-motion` the dashes hold still —
|
|
63
|
+
* the line, its colour and its position are the information; the march is not.
|
|
64
|
+
*/
|
|
65
|
+
export declare function PendingWireLine({ pending }: {
|
|
66
|
+
pending: PendingWire | null;
|
|
67
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
68
|
+
/**
|
|
69
|
+
* What the canvas says while a wire is open, and when it will not close one.
|
|
70
|
+
*
|
|
71
|
+
* On the canvas rather than only in the live region, because this is the
|
|
72
|
+
* gesture's entire feedback for somebody using a mouse: the drag could refuse
|
|
73
|
+
* itself by turning a handle red under the cursor, and a click has no equivalent
|
|
74
|
+
* moment. "Refused visibly" has to mean a sentence somebody can read.
|
|
75
|
+
*
|
|
76
|
+
* `Panel` places it in React Flow's own overlay layer, so it stays put while the
|
|
77
|
+
* graph is panned underneath it.
|
|
78
|
+
*/
|
|
79
|
+
export declare function WiringHint({ pending, refusal, nodes, onCancel, }: {
|
|
80
|
+
pending: PendingWire | null;
|
|
81
|
+
refusal: string | null;
|
|
82
|
+
nodes: WorkflowNode[];
|
|
83
|
+
onCancel(): void;
|
|
84
|
+
}): import("react/jsx-runtime").JSX.Element;
|