@dudousxd/nestjs-catalog-react 0.20.0 → 0.21.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.
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Background, BackgroundVariant, ConnectionLineType, Controls, MiniMap, NodeToolbar, Position, ReactFlow, ReactFlowProvider, useReactFlow, } from '@xyflow/react';
2
+ import { Background, BackgroundVariant, ConnectionLineType, Controls, MiniMap, NodeToolbar, Panel, Position, ReactFlow, ReactFlowProvider, useReactFlow, } from '@xyflow/react';
3
3
  // React Flow ships its own stylesheet and renders as an unstyled pile of divs
4
4
  // without it — no edges, every node at the top-left corner. Imported by the
5
5
  // component that needs it rather than left to the host, because a missing
@@ -7,7 +7,7 @@ import { Background, BackgroundVariant, ConnectionLineType, Controls, MiniMap, N
7
7
  // See src/styles.d.ts for why `tsc` tolerates this import.
8
8
  import '@xyflow/react/dist/style.css';
9
9
  import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
10
- import { ArrowRight, CircleAlert, CircleDashed, Code2, Database, ExternalLink, Filter, GitBranch, Info, LayoutGrid, Link2, Loader2, PanelRight, Plug, Plus, Repeat, Save, Trash2, TriangleAlert, Unplug, X, } from 'lucide-react';
10
+ import { ArrowRight, ChevronDown, CircleAlert, CircleDashed, Code2, Database, ExternalLink, Filter, GitBranch, Info, LayoutGrid, Link2, Loader2, Maximize2, Minimize2, PanelRight, Plug, Plus, Repeat, Save, Trash2, TriangleAlert, Unplug, X, } from 'lucide-react';
11
11
  import { AnimatePresence, motion, useReducedMotion } from 'motion/react';
12
12
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
13
13
  import { connectionOptionsFor } from './ConnectionPanel';
@@ -76,11 +76,28 @@ const CHROME = {
76
76
  side: 28,
77
77
  /** The rail's width plus its gutter, when it is open. */
78
78
  rail: 336,
79
+ /**
80
+ * The top inset once the workflow card is collapsed to its head.
81
+ *
82
+ * The card is the tallest thing on this screen and the only one focus mode
83
+ * changes the height of, so it is the only inset that moves with the mode.
84
+ * The dock is still at the bottom and the actions are untouched, so those two
85
+ * keep their numbers.
86
+ */
87
+ topFocused: 76,
79
88
  };
80
- /** {@link CHROME} as the padding `fitView` wants. The right edge is the only side that moves. */
81
- function chromeFitPadding(railOpen) {
89
+ /**
90
+ * {@link CHROME} as the padding `fitView` wants.
91
+ *
92
+ * Two sides move, and only two: the right, because the rail comes and goes, and
93
+ * the top, because focus mode collapses the card to its head. The whole reason
94
+ * this function exists is that a fit which ignored either would put a node under
95
+ * a panel — so a mode that makes the chrome smaller has to say so here, or the
96
+ * canvas it just bought would go unused.
97
+ */
98
+ function chromeFitPadding(railOpen, cardCollapsed) {
82
99
  return {
83
- top: `${CHROME.top}px`,
100
+ top: `${cardCollapsed ? CHROME.topFocused : CHROME.top}px`,
84
101
  bottom: `${CHROME.bottom}px`,
85
102
  left: `${CHROME.side}px`,
86
103
  right: `${railOpen ? CHROME.rail : CHROME.side}px`,
@@ -99,9 +116,293 @@ function chromeFitPadding(railOpen) {
99
116
  * answer there: it is what hydrates into on a desktop, and a panel that appears
100
117
  * after hydration is a worse first paint than one that was always there.
101
118
  */
102
- function railOpenByDefault() {
119
+ function railOpenByWidth() {
103
120
  return typeof window === 'undefined' ? true : window.innerWidth >= 1024;
104
121
  }
122
+ /**
123
+ * Whether this is a pointer that can hover at all.
124
+ *
125
+ * The whole shrink-and-expand idea below is built on hover, and hover is not a
126
+ * thing every pointer has. On a touch screen there is no state between "not
127
+ * touching" and "touching": the first contact with a pannable minimap IS a pan,
128
+ * so a map that expanded on touch would turn a navigation gesture into a resize
129
+ * gesture and move the viewport while doing it. There is no version of
130
+ * hover-to-expand that works there, so the honest answer is not to shrink at
131
+ * all — a finger gets the map exactly as it is today.
132
+ *
133
+ * `pointer: fine` as well as `hover: hover`, because the pair is what excludes a
134
+ * TV remote and a Wii-style pointer: those report `hover: hover` with a coarse
135
+ * pointer, and a 96px target you have to wave at is worse than a 200px one.
136
+ *
137
+ * Every failure answers `false` — no window, no `matchMedia` (jsdom does not
138
+ * implement it), or a throw. `false` means "do not shrink", which is the answer
139
+ * that takes nothing away, and that is the same rule
140
+ * {@link focusModeAtMount} follows for the same reason.
141
+ */
142
+ const HOVER_POINTER_QUERY = '(hover: hover) and (pointer: fine)';
143
+ function hoverCapablePointer() {
144
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
145
+ return false;
146
+ try {
147
+ return window.matchMedia(HOVER_POINTER_QUERY).matches;
148
+ }
149
+ catch {
150
+ return false;
151
+ }
152
+ }
153
+ /**
154
+ * How much of its size the overview keeps while focus mode has the screen.
155
+ *
156
+ * React Flow's minimap is 200×150, and 0.48 of that is 96×72 — whole pixels on
157
+ * both axes, which a rounder-looking 0.5 would also give but 0.45 would not. A
158
+ * fractional height puts the mask's bottom edge on a half-pixel and the
159
+ * viewport box picks up a grey seam that reads as a border it does not have.
160
+ *
161
+ * WHAT SURVIVES AT THIS SIZE, which is the only question that matters — a
162
+ * shrunk minimap that reads as decoration has taken the navigation aid away and
163
+ * kept the pixels. At 96×72 the map still carries the one thing it is for: WHERE
164
+ * THE VIEWPORT IS IN THE GRAPH. That is drawn as a hole in a tinted mask, so it
165
+ * is an area rather than a detail, and area survives scaling — the box keeps its
166
+ * position and its proportion of the whole, which is the entire "am I looking at
167
+ * the middle of this graph or the far edge" question. The node dots keep their
168
+ * kind colours (see {@link miniMapColor}), so a cluster and a lone box on the
169
+ * other side of the graph are still two different pictures.
170
+ *
171
+ * WHAT IS SACRIFICED: reading an individual node's position precisely, and any
172
+ * hope of telling two adjacent nodes apart. Both are recovered by hovering, and
173
+ * neither was ever a gesture here — no `onNodeClick` is passed to the minimap,
174
+ * so a dot has never been a target.
175
+ *
176
+ * A single scale rather than a smaller `style={{ width, height }}`, and that is
177
+ * NOT a shortcut — see {@link FocusMiniMap} for why it is the only version of
178
+ * this that cannot make a drag jump under the finger.
179
+ *
180
+ * SPELLED AS A LITERAL CLASS, and it has to be. This package ships as compiled
181
+ * JS and the console's stylesheet points Tailwind at `dist/**\/*.js` to find the
182
+ * classes in it. Tailwind emits only what it can SEE in that text, so a class
183
+ * built as `scale-[${scale}]` survives compilation as an un-evaluated template
184
+ * and the rule is never generated — no error, no warning, and a focus mode
185
+ * whose minimap simply never shrinks. Hence one string, and the arithmetic in
186
+ * this comment rather than in the code: 200×150 × 0.48 = 96×72.
187
+ */
188
+ const MINIMAP_FOCUSED_CLASS = 'scale-[0.48]';
189
+ /* ---------------------------------------------------------------------------
190
+ * Focus mode.
191
+ * ------------------------------------------------------------------------- */
192
+ /**
193
+ * The key focus mode is remembered under, and — deliberately — `sessionStorage`.
194
+ *
195
+ * ## Why it is remembered at all
196
+ *
197
+ * A mode somebody has to re-enter after every reload is a mode nobody uses. The
198
+ * person this exists for is the one drawing a forty-node graph, and that person
199
+ * reloads: a deploy lands, a query is retried, a tab is restored. Losing the
200
+ * layout each time makes the gesture a novelty.
201
+ *
202
+ * ## Why it is not `localStorage`
203
+ *
204
+ * This mode HIDES things — the workflow picker, the name field, the description.
205
+ * A preference that hides controls and is restored silently a week later is
206
+ * somebody opening the console, finding a screen with fewer controls than they
207
+ * remember, and having no way to connect that to a keypress from last Tuesday.
208
+ * That is the exact confusion a persisted hiding-mode causes, and it is worse
209
+ * than re-pressing a key.
210
+ *
211
+ * `sessionStorage` is the honest middle: the mode lives exactly as long as the
212
+ * TAB that chose it. A reload keeps it, because a reload is the same working
213
+ * session and is usually not even deliberate. A new tab, or tomorrow, starts
214
+ * with the chrome present. Nobody inherits a hidden control from a decision they
215
+ * cannot remember making.
216
+ *
217
+ * It is per-tab rather than per-workflow on purpose: focus is a statement about
218
+ * how somebody wants to WORK, not about a particular graph, and re-entering it
219
+ * on every switch of the picker would make it feel like a property of the
220
+ * document.
221
+ */
222
+ const FOCUS_STORAGE_KEY = 'catalog.workflowCanvas.focus';
223
+ /**
224
+ * Whether focus mode was on in this tab.
225
+ *
226
+ * Every failure answers `false` — no window (a host rendering this on a server),
227
+ * no storage (Safari's private mode throws on `sessionStorage` access rather
228
+ * than returning null), or anything stored that is not exactly `'1'`. The chrome
229
+ * being present is the state that hides nothing, so it is the only safe answer
230
+ * to "I could not tell".
231
+ */
232
+ function focusModeAtMount() {
233
+ if (typeof window === 'undefined')
234
+ return false;
235
+ try {
236
+ return window.sessionStorage.getItem(FOCUS_STORAGE_KEY) === '1';
237
+ }
238
+ catch {
239
+ return false;
240
+ }
241
+ }
242
+ /**
243
+ * Whether the details rail starts on screen, once focus mode has had its say.
244
+ *
245
+ * A mount that restores focus (see {@link focusModeAtMount}) has to start with
246
+ * the rail away, or a reload puts back the one panel the mode had just taken and
247
+ * focus arrives half-applied. Measured in a browser before this existed: press
248
+ * F, reload, and the rail was open again with the toggle still reading "Turn off
249
+ * focus mode" — a screen making two claims about itself.
250
+ */
251
+ function railOpenByDefault() {
252
+ return !focusModeAtMount() && railOpenByWidth();
253
+ }
254
+ /** Remember it, or fail silently — a mode is not worth an exception. */
255
+ function rememberFocusMode(on) {
256
+ if (typeof window === 'undefined')
257
+ return;
258
+ try {
259
+ window.sessionStorage.setItem(FOCUS_STORAGE_KEY, on ? '1' : '0');
260
+ }
261
+ catch {
262
+ // A browser that refuses storage still gets the mode, for this render.
263
+ }
264
+ }
265
+ /**
266
+ * The key that toggles focus mode.
267
+ *
268
+ * A bare letter rather than a chord, because this is a drawing surface and the
269
+ * hand that would reach for a modifier is the hand on the pointer. `f` is the
270
+ * mnemonic and nothing else on this screen claims it: React Flow binds only
271
+ * Delete/Backspace and the arrows, and Escape already means "put the half-drawn
272
+ * wire away" (see `workflow/wiring.tsx`), which is why this is not Escape.
273
+ *
274
+ * Discoverable rather than folklore: the toggle renders the letter beside its
275
+ * icon and its tooltip names it, so the shortcut is learnable from the control
276
+ * it duplicates instead of from a changelog.
277
+ */
278
+ const FOCUS_SHORTCUT = 'f';
279
+ /**
280
+ * Whether a keypress belongs to whatever the person is typing into.
281
+ *
282
+ * The failure this prevents is specific and would be reported as "the panels
283
+ * vanish while I name a node": this screen is covered in text fields — the name
284
+ * field, the inspector's config editor, the transform's code surface — and a
285
+ * bare-letter shortcut that did not ask would fire on the `f` of "fleet".
286
+ *
287
+ * Narrowed with `instanceof` rather than by reading `tagName` off an `EventTarget`,
288
+ * because a target can be a document or a window and neither has one.
289
+ * `isContentEditable` covers the code editor, which is a `div`.
290
+ */
291
+ function typingInto(target) {
292
+ if (!(target instanceof HTMLElement))
293
+ return false;
294
+ if (target.isContentEditable)
295
+ return true;
296
+ return (target instanceof HTMLInputElement ||
297
+ target instanceof HTMLTextAreaElement ||
298
+ target instanceof HTMLSelectElement);
299
+ }
300
+ /**
301
+ * Whether the chrome is compacted so the graph gets the screen, and the one
302
+ * gesture that changes it.
303
+ *
304
+ * ## What the mode does, and what it deliberately does not
305
+ *
306
+ * ON: the workflow card collapses to its head, the node dock drops its labels
307
+ * (the form it already takes on a phone — see `AddButton` — rather than a second
308
+ * compact form invented for this), and the rail goes away.
309
+ *
310
+ * OFF-LIMITS: the action cluster. That is not an oversight, it is the reason the
311
+ * mode is safe. Every signal on this screen that prevents a mistake lives in that
312
+ * cluster or hangs off it — Save doubles as the unsaved indicator, the refusal
313
+ * notes appear beneath the button that caused them, the shrink refusal with its
314
+ * acknowledge control is one of those notes, and the rail toggle carries the
315
+ * problem count and its colour while the rail is away. It is also the smallest of
316
+ * the three groups, so hiding it would buy the least canvas for the most risk.
317
+ * What is left in focus is a graph plus the things that can tell you the graph is
318
+ * wrong.
319
+ *
320
+ * ## Why one gesture rather than three
321
+ *
322
+ * Because the ask was "compactar os menus" for "real estate", and real estate is
323
+ * a property of the whole screen. Three independent collapses is three decisions
324
+ * and six states to be in; a person who wants the room wants the room. The rail
325
+ * keeps its own toggle because it had one before this and closing it alone is a
326
+ * legitimate smaller wish.
327
+ *
328
+ * ## Why the rail is passed in rather than owned here
329
+ *
330
+ * Because it existed first and is still operable on its own. This hook borrows
331
+ * it for the duration of the mode and gives it back; it does not become the
332
+ * rail's owner, which is what taking the `useState` would have meant.
333
+ */
334
+ function useFocusMode(railOpen, setRailOpen) {
335
+ const [focused, setFocused] = useState(focusModeAtMount);
336
+ /**
337
+ * Whether the rail was open before focus took it away.
338
+ *
339
+ * A ref rather than state: nothing renders from it, and leaving focus should
340
+ * put the screen back the way it was found rather than assert a default. A
341
+ * person who had closed the rail themselves and then used focus would
342
+ * otherwise get a panel they never asked for on the way out.
343
+ *
344
+ * Seeded from the WIDTH rather than from `railOpen`, and the two differ in
345
+ * exactly one case: a mount that restored focus, where `railOpen` is already
346
+ * false because focus put it there. Seeding from it would mean leaving focus
347
+ * after a reload left the rail away too — restoring a state that focus itself
348
+ * created rather than the one it displaced.
349
+ */
350
+ const railBeforeFocus = useRef(railOpenByWidth());
351
+ const toggleFocus = useCallback(() => {
352
+ const next = !focused;
353
+ rememberFocusMode(next);
354
+ if (next)
355
+ railBeforeFocus.current = railOpen;
356
+ setRailOpen(next ? false : railBeforeFocus.current);
357
+ setFocused(next);
358
+ }, [focused, railOpen, setRailOpen]);
359
+ /**
360
+ * The keyboard way in and out. See {@link FOCUS_SHORTCUT}.
361
+ *
362
+ * On `window` rather than on the canvas container, because the point of the
363
+ * shortcut is that it works while the hands are on the graph — and React
364
+ * Flow's pane is not a focusable element, so a container-scoped handler would
365
+ * only fire after somebody had tabbed to something.
366
+ *
367
+ * Every modifier is refused rather than ignored: `Ctrl+F` is find, `Cmd+F` is
368
+ * find, and a shortcut that swallowed either would be a bug reported as "the
369
+ * browser's search is broken on this screen".
370
+ */
371
+ useEffect(() => {
372
+ function onKeyDown(event) {
373
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
374
+ return;
375
+ if (event.key.toLowerCase() !== FOCUS_SHORTCUT)
376
+ return;
377
+ if (typingInto(event.target))
378
+ return;
379
+ event.preventDefault();
380
+ toggleFocus();
381
+ }
382
+ window.addEventListener('keydown', onKeyDown);
383
+ return () => window.removeEventListener('keydown', onKeyDown);
384
+ }, [toggleFocus]);
385
+ return { focused, toggleFocus };
386
+ }
387
+ /**
388
+ * Whether the workflow card actually folds — because focus mode REFUSES to fold
389
+ * it while the graph has no name.
390
+ *
391
+ * The one place this mode could become a trap. Save is disabled on an empty name
392
+ * (see `CanvasActions`), and the field that fills it in is inside the card — so a
393
+ * focus mode that collapsed the card unconditionally would leave somebody who had
394
+ * just picked "New workflow" with a dead Save button, a tooltip about a field
395
+ * they cannot see, and no way to connect the two.
396
+ *
397
+ * So the card is chrome that is quiet when it has nothing to report and asserts
398
+ * itself when it does: it stays open, in focus mode, exactly while the only
399
+ * control that can unblock Save is the one it holds. {@link FocusToggle} says so
400
+ * rather than appearing broken, and `WorkflowCard` additionally declines to fold
401
+ * while the caret is still in the field.
402
+ */
403
+ function focusCollapsesTheCard(focused, draftName) {
404
+ return focused && draftName.trim().length > 0;
405
+ }
105
406
  /**
106
407
  * Every kind of node, and how it is offered.
107
408
  *
@@ -688,8 +989,8 @@ function CanvasActions({ draft, stored, canEdit, blocked, unfinished, saving, ru
688
989
  * the dock cannot fall behind the model — see the note on `ADD_NODE` for the bug
689
990
  * that made that necessary.
690
991
  */
691
- function AddNodeBar({ refreshing, onAdd, onTidy, }) {
692
- return (_jsxs("div", { className: cn('pointer-events-auto flex max-w-full items-center gap-1 overflow-x-auto p-1.5', FLOATING), children: [WORKFLOW_NODE_KINDS.map((kind) => (_jsx(AddButton, { kind: kind, onClick: () => onAdd(kind) }, kind))), _jsx("span", { className: cn('mx-1 h-6 w-px shrink-0 bg-zinc-200 dark:bg-zinc-800'), "aria-hidden": true }), _jsx(Tooltip, { content: "Lay the nodes out left to right by dependency, with every sink in the last column.", children: _jsxs(Button, { variant: "ghost", size: "sm", onClick: onTidy, "aria-label": "Tidy the layout", className: "shrink-0", children: [_jsx(LayoutGrid, { size: 12 }), _jsx("span", { className: "hidden md:inline", children: "Tidy" })] }) }), refreshing && (
992
+ function AddNodeBar({ refreshing, compact, onAdd, onTidy, }) {
993
+ return (_jsxs("div", { className: cn('pointer-events-auto flex max-w-full items-center gap-1 overflow-x-auto p-1.5', FLOATING), children: [WORKFLOW_NODE_KINDS.map((kind) => (_jsx(AddButton, { kind: kind, compact: compact, onClick: () => onAdd(kind) }, kind))), _jsx("span", { className: cn('mx-1 h-6 w-px shrink-0 bg-zinc-200 dark:bg-zinc-800'), "aria-hidden": true }), _jsx(Tooltip, { content: "Lay the nodes out left to right by dependency, with every sink in the last column.", children: _jsxs(Button, { variant: "ghost", size: "sm", onClick: onTidy, "aria-label": "Tidy the layout", className: "shrink-0", children: [_jsx(LayoutGrid, { size: 12 }), _jsx("span", { className: compact ? 'hidden' : 'hidden md:inline', children: "Tidy" })] }) }), refreshing && (
693
994
  // A background refetch says so without replacing anything: the graph on
694
995
  // screen stays exactly where it is.
695
996
  _jsx("span", { className: cn('shrink-0 px-1 font-mono text-[10px]', MUTED), children: "refreshing\u2026" }))] }));
@@ -743,6 +1044,142 @@ function miniMapColor(data) {
743
1044
  return '#f43f5e';
744
1045
  return '#8b5cf6';
745
1046
  }
1047
+ /**
1048
+ * The overview, and the one thing focus mode does to it.
1049
+ *
1050
+ * WHY IT SHRINKS RATHER THAN GOES
1051
+ * -------------------------------
1052
+ * Focus mode's argument everywhere else is that the chrome it hides is chrome
1053
+ * you do not need while drawing. The minimap is the exception: it is a
1054
+ * navigation aid for exactly the big graph that made somebody want the room in
1055
+ * the first place, so taking it away is taking away the thing the mode is FOR.
1056
+ * It shrinks to the size at which it still answers "where am I", and hovering
1057
+ * it brings the rest back. See {@link MINIMAP_FOCUSED_CLASS} for what survives
1058
+ * at that size and what does not.
1059
+ *
1060
+ * WHY A TRANSFORM AND NOT A SMALLER MINIMAP
1061
+ * -----------------------------------------
1062
+ * React Flow sizes the minimap from `style.width`/`style.height` (defaulting to
1063
+ * 200×150) and derives `viewScale` from them — `boundingRect.width /
1064
+ * elementWidth`. Its pan handler then moves the viewport by `rawClientDelta *
1065
+ * viewScale`, reading `viewScale` LIVE from a ref on every mousemove.
1066
+ *
1067
+ * So shrinking the honest way — passing a smaller width and height — would
1068
+ * change the pan gain, and change it on every frame of an animation between the
1069
+ * two sizes. A drag that started while the map was small and expanded mid-
1070
+ * gesture would have the viewport accelerate under the finger, continuously,
1071
+ * for the length of the animation. That is the exact failure worth avoiding.
1072
+ *
1073
+ * Scaling has none of it: `style.width` stays 200 in both states, so `viewScale`
1074
+ * is a constant and the pan gain is IDENTICAL small, large, and every frame in
1075
+ * between. Scale is a compositor property, so the animation never touches
1076
+ * layout, never re-renders React Flow, and never resolves against `height:
1077
+ * auto` — which is the shape of animation that never settled under jsdom and
1078
+ * left the card body mounted forever in a test. There is nothing here for that
1079
+ * to happen to: the element is always mounted, always 200×150 in layout, and
1080
+ * the only thing moving is one compositor property.
1081
+ *
1082
+ * (Tailwind v4 emits `scale-*` as the INDEPENDENT `scale` property rather than
1083
+ * as `transform: scale(...)`, so the computed `transform` here reads `none` and
1084
+ * the size lives in `scale`. It honours `transform-origin` exactly the same
1085
+ * way, and `transition-transform` in v4 expands to `transform, translate,
1086
+ * scale, rotate` — so the transition below does cover it. Both checked in a
1087
+ * browser rather than assumed, because a transition that silently covers
1088
+ * nothing is a snap that looks like a missing animation.)
1089
+ *
1090
+ * The residue is that while shrunk the pan gain is calibrated for the large map
1091
+ * — a drag would move the viewport less than the small drawing suggests. On a
1092
+ * fine pointer that state is unreachable: a drag needs a press, a press needs
1093
+ * the pointer over the element, and the pointer being over the element is what
1094
+ * expands it. Every drag begins on a settled, full-size map. On a touch screen
1095
+ * there is no shrinking at all ({@link hoverCapablePointer}), so it cannot
1096
+ * arise there either. Expand-then-pan, arrived at by geometry rather than by
1097
+ * disabling anything.
1098
+ *
1099
+ * WHY IT CANNOT FLICKER
1100
+ * ---------------------
1101
+ * Both states are anchored at the same bottom-left corner and the transform
1102
+ * origin is that corner, so the small box is a strict sub-rectangle of the
1103
+ * large one. A pointer that enters the small box is therefore still inside the
1104
+ * large box once it expands, and expansion can never move the element out from
1105
+ * under the pointer that caused it. The one geometry that oscillates — expand,
1106
+ * pointer now outside, collapse, repeat — needs the two boxes to disagree about
1107
+ * a region, and containment is what rules that out.
1108
+ *
1109
+ * It also cannot collide with the zoom controls above it, because the expanded
1110
+ * size is the size the minimap already is today: the gap the shrink opens up is
1111
+ * space that was always reserved for this element, so growing back into it
1112
+ * covers nothing that was not already covered.
1113
+ */
1114
+ function FocusMiniMap({ focused }) {
1115
+ /*
1116
+ * Read once at mount rather than subscribed to, which is the same call
1117
+ * `railOpenByWidth` makes and for the same reason: a live query would re-shrink
1118
+ * the map under a pointer that is resting on it because a tablet was docked.
1119
+ * The cost of being wrong is one session on the size it booted with.
1120
+ */
1121
+ const [canHover] = useState(hoverCapablePointer);
1122
+ const shrinks = focused && canHover;
1123
+ return (
1124
+ /*
1125
+ * React Flow's own `Panel`, so this wrapper IS the panel: it takes the
1126
+ * absolute positioning, the 15px margin, the z-index and — the reason it is
1127
+ * `Panel` rather than a hand-rolled div — the rule that switches
1128
+ * `pointer-events` off while a box-selection is being dragged across the
1129
+ * canvas. The minimap inside is switched to `static` so it stops being the
1130
+ * positioned element and becomes this one's content; without that there
1131
+ * would be two absolutely-positioned boxes fighting over one corner.
1132
+ */
1133
+ _jsx(Panel, { position: "bottom-left",
1134
+ /*
1135
+ * THE KEYBOARD PATH, and it exists only while the map is shrunk.
1136
+ *
1137
+ * A minimap that expands on hover cannot be expanded by somebody who has
1138
+ * no pointer, and `focus-within` is only an answer if something in here
1139
+ * can hold a caret — React Flow's minimap is an `svg` with `role="img"`,
1140
+ * which cannot. So the panel itself becomes the focus stop.
1141
+ *
1142
+ * Conditional on `shrinks`, and that is the whole reason this is safe:
1143
+ * outside focus mode the tab order is byte-for-byte the one the previous
1144
+ * round measured and settled — app nav, card, actions, rail toggle, dock,
1145
+ * rail, canvas — because `undefined` puts no stop here at all. Inside
1146
+ * focus mode there is one extra stop, at the end, on the element that
1147
+ * needs it. That is a net gain for a keyboard: the minimap was never
1148
+ * reachable before, in either mode.
1149
+ */
1150
+ tabIndex: shrinks ? 0 : undefined, role: shrinks ? 'group' : undefined, "aria-label": shrinks
1151
+ ? 'Graph overview, reduced. Hold focus here, or hover it, to see it full size.'
1152
+ : undefined, className: cn(
1153
+ // An overview is worth least on the screen with least room for it:
1154
+ // below `lg` it would cover a sixth of the canvas to describe the other
1155
+ // five. Moved here from the minimap itself along with the positioning.
1156
+ 'hidden lg:block',
1157
+ // The corner both states share. `scale` alone would shrink about the
1158
+ // centre and unpin the map from the corner it is anchored to, which is
1159
+ // also what makes the containment argument above hold.
1160
+ 'origin-bottom-left',
1161
+ /*
1162
+ * A tween on a transform, matching the duration and the curve the card
1163
+ * body folds on, so the two halves of one gesture move as one gesture.
1164
+ *
1165
+ * `prefers-reduced-motion` gets the same end state and no transition —
1166
+ * a CSS variant rather than the `useReducedMotion()` hook the motion
1167
+ * components here use, because this animation is CSS and the media
1168
+ * query is the direct expression of it. There is no state to keep in
1169
+ * step and nothing to settle.
1170
+ */
1171
+ 'transition-transform duration-200 ease-[cubic-bezier(0.32,0.72,0,1)]', 'motion-reduce:transition-none',
1172
+ // `focus` as well as `focus-within`: the stop is on this element, so it
1173
+ // is `focus` that fires today. `focus-within` is here so that a control
1174
+ // added inside later expands the map rather than being drawn at half
1175
+ // size under somebody's caret.
1176
+ shrinks && MINIMAP_FOCUSED_CLASS, shrinks && 'hover:scale-100 focus:scale-100 focus-within:scale-100',
1177
+ // The focus ring goes on the panel, because the panel is the focus stop.
1178
+ shrinks && 'rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-sky-500'), children: _jsx(MiniMap, { pannable: true, zoomable: true,
1179
+ // Positioning now belongs to the panel above, so the minimap stops
1180
+ // claiming a corner and just draws in the box it is given.
1181
+ position: "bottom-left", nodeColor: (node) => miniMapColor(node.data), className: cn('!static !m-0', '!overflow-hidden !rounded-lg !border !border-zinc-200 !shadow-sm dark:!border-zinc-800') }) }));
1182
+ }
746
1183
  /**
747
1184
  * The graph itself, and the two states in which there is no graph to draw.
748
1185
  *
@@ -750,7 +1187,7 @@ function miniMapColor(data) {
750
1187
  * place of the screen, so the header and its controls stay put while a refetch
751
1188
  * resolves — and a failed read never looks like an empty workflow.
752
1189
  */
753
- function GraphSurface({ loading, failed, error, onRetry, canEdit, draft, flowNodes, flowEdges, onInspect, onEditCode, onNodesChange, onEdgesChange, onConnect, isValidConnection, onConnectEnd, onNodeEnter, onNodeLeave, onPaneClick, onDisconnect, wiring, wiringRefusal, nodeMenu, fitPadding, }) {
1190
+ function GraphSurface({ loading, failed, error, onRetry, canEdit, draft, flowNodes, flowEdges, onInspect, onEditCode, onNodesChange, onEdgesChange, onConnect, isValidConnection, onConnectEnd, onNodeEnter, onNodeLeave, onPaneClick, onDisconnect, wiring, wiringRefusal, nodeMenu, fitPadding, focused, }) {
754
1191
  /*
755
1192
  * Memoised because they are context values read by every node and every edge
756
1193
  * on the canvas. Written inline, as they were, each of these was a fresh
@@ -781,11 +1218,7 @@ function GraphSurface({ loading, failed, error, onRetry, canEdit, draft, flowNod
781
1218
  connectionRadius: 28, proOptions: { hideAttribution: false }, ariaLabelConfig: ARIA_LABELS, "aria-label": `${WORKFLOW_NAME.title} canvas. ${draft.nodes.length} nodes, ${draft.edges.length} connections.`, fitView: true, fitViewOptions: { padding: fitPadding }, children: [_jsx(Background, { variant: BackgroundVariant.Dots, gap: 18, size: 1 }), _jsx(Controls, { showInteractive: false, position: "bottom-left", className: cn('!bottom-[9.5rem] !overflow-hidden !rounded-lg !border !border-zinc-200', '!shadow-sm dark:!border-zinc-800 [&>button]:!border-none',
782
1219
  // Below `lg` the minimap is gone, so the zoom controls drop
783
1220
  // back down into the corner it vacated.
784
- '!bottom-0 lg:!bottom-[9.5rem]') }), _jsx(MiniMap, { pannable: true, zoomable: true, position: "bottom-left", nodeColor: (node) => miniMapColor(node.data),
785
- // An overview is worth least on the screen with least room for
786
- // it: below `lg` it would cover a sixth of the canvas to
787
- // describe the other five.
788
- className: cn('!hidden lg:!block', '!overflow-hidden !rounded-lg !border !border-zinc-200 !shadow-sm dark:!border-zinc-800') }), _jsx(PendingWireLine, { pending: wiring.pending }), _jsx(WiringHint, { pending: wiring.pending, refusal: wiringRefusal, nodes: draft.nodes, onCancel: wiring.cancel }), nodeMenu] }) }) }))] }));
1221
+ '!bottom-0 lg:!bottom-[9.5rem]') }), _jsx(FocusMiniMap, { focused: focused }), _jsx(PendingWireLine, { pending: wiring.pending }), _jsx(WiringHint, { pending: wiring.pending, refusal: wiringRefusal, nodes: draft.nodes, onCancel: wiring.cancel }), nodeMenu] }) }) }))] }));
789
1222
  }
790
1223
  /**
791
1224
  * The wiring control that lives on a node, and the menu behind it.
@@ -1094,23 +1527,28 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1094
1527
  * SSR, and a bare `window` there is a crash rather than a layout bug.
1095
1528
  */
1096
1529
  const [railOpen, setRailOpen] = useState(railOpenByDefault);
1530
+ const { focused, toggleFocus } = useFocusMode(railOpen, setRailOpen);
1531
+ const cardCollapsed = focusCollapsesTheCard(focused, draft.name);
1097
1532
  /**
1098
1533
  * The region of the viewport the graph should be fitted into.
1099
1534
  *
1100
- * See {@link CHROME}. The right edge is the only side that moves, because the
1101
- * rail is the only panel that comes and goes.
1535
+ * See {@link CHROME}. Two sides move: the right with the rail, the top with
1536
+ * the card's collapse.
1102
1537
  *
1103
1538
  * Declared up here with the state rather than beside its use, because both
1104
1539
  * `fitView` call sites below name it in a dependency array — and a `const` read
1105
1540
  * by a hook that runs earlier in the body is a temporal-dead-zone crash, not a
1106
1541
  * lint warning.
1107
1542
  *
1108
- * Toggling the rail deliberately does NOT re-fit. That would throw away a
1109
- * viewport somebody had panned to, in response to an action about a panel; the
1110
- * new padding applies at the next fit that was going to happen anyway —
1111
- * opening a graph, or pressing Tidy.
1543
+ * Toggling the rail deliberately does NOT re-fit, and neither does entering
1544
+ * focus. That would throw away a viewport somebody had panned to, in response
1545
+ * to an action about a panel; the new padding applies at the next fit that was
1546
+ * going to happen anyway — opening a graph, or pressing Tidy. Focus is the
1547
+ * stronger case for the same rule: somebody who has just asked for room is
1548
+ * looking at a particular part of the graph, and jumping the viewport is the
1549
+ * one thing that would lose it.
1112
1550
  */
1113
- const fitPadding = useMemo(() => chromeFitPadding(railOpen), [railOpen]);
1551
+ const fitPadding = useMemo(() => chromeFitPadding(railOpen, cardCollapsed), [railOpen, cardCollapsed]);
1114
1552
  /**
1115
1553
  * Whether the "this load is expected to shrink" dialog is open.
1116
1554
  *
@@ -1823,7 +2261,7 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1823
2261
  * covers rather than into the raw viewport — which is what stops a node
1824
2262
  * being centred underneath the action cluster.
1825
2263
  */
1826
- _jsxs("div", { className: "relative h-full min-h-0 w-full overflow-hidden", children: [_jsxs("div", { className: "pointer-events-none absolute inset-0 z-20 flex flex-col gap-3 p-3 sm:p-4", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsx(WorkflowCard, { eyebrow: eyebrow, title: title, intro: intro, stored: stored, produces: produces, durability: durability, selected: selected, workflowOptions: workflowOptions, workflowsPending: workflows.isPending, draftName: draft.name, canEdit: canEdit, onSelect: (value) => {
2264
+ _jsxs("div", { className: "relative h-full min-h-0 w-full overflow-hidden", children: [_jsxs("div", { className: "pointer-events-none absolute inset-0 z-20 flex flex-col gap-3 p-3 sm:p-4", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsx(WorkflowCard, { eyebrow: eyebrow, title: title, intro: intro, stored: stored, produces: produces, durability: durability, selected: selected, workflowOptions: workflowOptions, workflowsPending: workflows.isPending, draftName: draft.name, canEdit: canEdit, collapsed: cardCollapsed, reducedMotion: reducedMotion, onExpand: toggleFocus, onSelect: (value) => {
1827
2265
  loadedRef.current = null;
1828
2266
  setSelected(value);
1829
2267
  },
@@ -1833,7 +2271,7 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1833
2271
  onRename: (name) => edit((current) => ({ ...current, name }), {
1834
2272
  label: 'renaming this workflow',
1835
2273
  run: 'rename',
1836
- }) }), _jsxs("div", { className: "flex max-w-full flex-col items-end gap-2", children: [_jsxs("div", { className: cn('pointer-events-auto flex items-start gap-2 p-1.5', FLOATING), children: [_jsx(CanvasActions, { draft: draft, stored: stored, canEdit: canEdit, blocked: blocked, unfinished: unfinished, saving: save.isPending, running: runIt.isPending, durabilityDetail: durability.detail, acknowledging: acknowledging, reducedMotion: reducedMotion, resetting: resetting, onAcknowledgingChange: setAcknowledging, onResettingChange: setResetting, onUndo: undo, onReset: reset, onSave: saveNow, onRun: runNow, onLifecycleChange: onLifecycleChange, onAskDelete: () => setConfirmingDelete(true) }), _jsx("span", { className: "h-6 w-px shrink-0 bg-zinc-200 dark:bg-zinc-800", "aria-hidden": true }), _jsx(RailToggle, { open: railOpen, problems: live, onToggle: () => setRailOpen((o) => !o) })] }), _jsxs("div", { className: "pointer-events-auto w-[min(26rem,100%)] empty:hidden", children: [save.error && _jsx(RefusalNote, { lead: "The server refused it:", error: save.error }), runIt.error && _jsx(RefusalNote, { lead: "The run could not start:", error: runIt.error }), _jsx(ShrinkRefusalNote, { run: run, error: runIt.error, onAcknowledge: () => setAcknowledging(true) })] })] })] }), canEdit && (_jsx("div", { className: "absolute inset-x-0 bottom-3 flex justify-center px-3 sm:bottom-4 sm:px-4", children: _jsx(AddNodeBar, { refreshing: workflows.isFetching && !workflows.isPending, onAdd: addNode, onTidy: tidy }) })), _jsx("div", { className: "flex min-h-0 flex-1 justify-end pb-14", children: _jsx(AnimatePresence, { initial: false, children: railOpen && (_jsx(WiringRail, { draft: draft, problems: live, pending: pending, run: run, canEdit: canEdit, reducedMotion: reducedMotion, onInspect: setInspecting, onDisconnect: disconnect, onClose: () => setRailOpen(false), children: stored && (_jsxs(_Fragment, { children: [_jsx(SchedulePanel, { workflow: stored, canEdit: canEdit, onScheduled: onLifecycleChange }, stored.id), _jsx(RunsAsPanel, { workflowId: stored.id, status: stored.status, transforms: graphTransforms })] })) })) }) })] }), _jsx(GraphSurface, { loading: workflows.isPending, failed: workflows.isError, error: workflows.error, onRetry: () => workflows.refetch(), canEdit: canEdit, draft: draft, flowNodes: flowNodes, flowEdges: flowEdges, onInspect: setInspecting, onEditCode: setEditingCodeFor, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, isValidConnection: isValidConnection, onConnectEnd: announceRefusedDrop, onNodeEnter: menu.onNodeEnter, onNodeLeave: menu.onNodeLeave,
2274
+ }) }), _jsxs("div", { className: "flex max-w-full flex-col items-end gap-2", children: [_jsxs("div", { className: cn('pointer-events-auto flex items-start gap-2 p-1.5', FLOATING), children: [_jsx(CanvasActions, { draft: draft, stored: stored, canEdit: canEdit, blocked: blocked, unfinished: unfinished, saving: save.isPending, running: runIt.isPending, durabilityDetail: durability.detail, acknowledging: acknowledging, reducedMotion: reducedMotion, resetting: resetting, onAcknowledgingChange: setAcknowledging, onResettingChange: setResetting, onUndo: undo, onReset: reset, onSave: saveNow, onRun: runNow, onLifecycleChange: onLifecycleChange, onAskDelete: () => setConfirmingDelete(true) }), _jsx("span", { className: "h-6 w-px shrink-0 bg-zinc-200 dark:bg-zinc-800", "aria-hidden": true }), _jsx(RailToggle, { open: railOpen, problems: live, onToggle: () => setRailOpen((o) => !o) }), _jsx(FocusToggle, { on: focused, cardCollapsed: cardCollapsed, onToggle: toggleFocus })] }), _jsxs("div", { className: "pointer-events-auto w-[min(26rem,100%)] empty:hidden", children: [save.error && _jsx(RefusalNote, { lead: "The server refused it:", error: save.error }), runIt.error && _jsx(RefusalNote, { lead: "The run could not start:", error: runIt.error }), _jsx(ShrinkRefusalNote, { run: run, error: runIt.error, onAcknowledge: () => setAcknowledging(true) })] })] })] }), canEdit && (_jsx("div", { className: "absolute inset-x-0 bottom-3 flex justify-center px-3 sm:bottom-4 sm:px-4", children: _jsx(AddNodeBar, { refreshing: workflows.isFetching && !workflows.isPending, compact: focused, onAdd: addNode, onTidy: tidy }) })), _jsx("div", { className: "flex min-h-0 flex-1 justify-end pb-14", children: _jsx(AnimatePresence, { initial: false, children: railOpen && (_jsx(WiringRail, { draft: draft, problems: live, pending: pending, run: run, canEdit: canEdit, reducedMotion: reducedMotion, onInspect: setInspecting, onDisconnect: disconnect, onClose: () => setRailOpen(false), children: stored && (_jsxs(_Fragment, { children: [_jsx(SchedulePanel, { workflow: stored, canEdit: canEdit, onScheduled: onLifecycleChange }, stored.id), _jsx(RunsAsPanel, { workflowId: stored.id, status: stored.status, transforms: graphTransforms })] })) })) }) })] }), _jsx(GraphSurface, { focused: focused, loading: workflows.isPending, failed: workflows.isError, error: workflows.error, onRetry: () => workflows.refetch(), canEdit: canEdit, draft: draft, flowNodes: flowNodes, flowEdges: flowEdges, onInspect: setInspecting, onEditCode: setEditingCodeFor, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, isValidConnection: isValidConnection, onConnectEnd: announceRefusedDrop, onNodeEnter: menu.onNodeEnter, onNodeLeave: menu.onNodeLeave,
1837
2275
  // Clicking empty canvas puts away everything that is half-open: the
1838
2276
  // wiring menu, and a wire that was started and never landed. React
1839
2277
  // Flow only fires this for clicks on the pane ITSELF, so finishing a
@@ -1894,10 +2332,10 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1894
2332
  function article(word) {
1895
2333
  return /^[aeiou]/i.test(word) ? 'an' : 'a';
1896
2334
  }
1897
- function AddButton({ kind, onClick }) {
2335
+ function AddButton({ kind, compact, onClick, }) {
1898
2336
  const { icon: Icon, label, hint } = ADD_NODE[kind];
1899
2337
  const noun = label.toLowerCase();
1900
- return (_jsx(Tooltip, { content: hint, children: _jsxs(Button, { variant: "ghost", size: "sm", onClick: onClick, "aria-label": `Add ${article(noun)} ${noun} node`, className: "shrink-0 text-zinc-600 dark:text-zinc-300", children: [_jsx(Plus, { size: 11 }), _jsx(Icon, { size: 12 }), _jsx("span", { className: "hidden md:inline", children: label })] }) }));
2338
+ return (_jsx(Tooltip, { content: hint, children: _jsxs(Button, { variant: "ghost", size: "sm", onClick: onClick, "aria-label": `Add ${article(noun)} ${noun} node`, className: "shrink-0 text-zinc-600 dark:text-zinc-300", children: [_jsx(Plus, { size: 11 }), _jsx(Icon, { size: 12 }), _jsx("span", { className: compact ? 'hidden' : 'hidden md:inline', children: label })] }) }));
1901
2339
  }
1902
2340
  /**
1903
2341
  * Whether a failed run resumes or restarts, stated on the screen that implies
@@ -1979,6 +2417,55 @@ function problemBadge(problems) {
1979
2417
  }
1980
2418
  return null;
1981
2419
  }
2420
+ /**
2421
+ * Give the canvas the screen, or give the chrome back.
2422
+ *
2423
+ * ## What this control promises, and what it does not
2424
+ *
2425
+ * It promises room, and it says exactly what it takes to get it — "the card and
2426
+ * the dock labels" — rather than "focus mode", because a mode named after a
2427
+ * feeling is a mode nobody can predict. What it explicitly does not promise is
2428
+ * that the screen goes quiet: the action cluster it sits inside stays whole, so
2429
+ * Save, the refusals and the problem count are all still here after it is
2430
+ * pressed. Somebody reading the tooltip should come away knowing that nothing
2431
+ * which can stop a mistake is about to disappear.
2432
+ *
2433
+ * ## The refusal
2434
+ *
2435
+ * The refusal is the case where the mode is ON and the card stayed open anyway,
2436
+ * because the graph has no name and the field that fixes that is inside it (see
2437
+ * `cardCollapsed`). A control that had been pressed and visibly done nothing
2438
+ * would read as broken, so it says which of the two things it is. The word is in
2439
+ * the accessible name too, not only in the tooltip — a tooltip is a pointer
2440
+ * affordance and this is the one state where the button's behaviour differs
2441
+ * from its label.
2442
+ *
2443
+ * ## The shortcut
2444
+ *
2445
+ * Rendered as a letter beside the icon rather than mentioned only in prose. A
2446
+ * keyboard shortcut nobody can see is a shortcut for whoever read the commit,
2447
+ * and this screen's whole argument is that the hands stay on the canvas.
2448
+ * `aria-hidden` on the glyph because the accessible name already spells it out
2449
+ * as a sentence, and "F" read aloud in the middle of one is noise.
2450
+ */
2451
+ function FocusToggle({ on, cardCollapsed, onToggle, }) {
2452
+ const refusing = on && !cardCollapsed;
2453
+ const hint = refusing
2454
+ ? `Focus is on, but the card is staying until this ${WORKFLOW_NAME.singular} has a name — the field that gives it one is in there, and Save is held back without it. Press ${FOCUS_SHORTCUT.toUpperCase()} or this button to turn focus off.`
2455
+ : on
2456
+ ? `Bring back the ${WORKFLOW_NAME.singular} card and the dock's labels. Shortcut: ${FOCUS_SHORTCUT.toUpperCase()}.`
2457
+ : `Collapse the ${WORKFLOW_NAME.singular} card, drop the dock to icons and put the details panel away, so the graph gets the screen. Save, the refusals and the problem count stay exactly where they are. Shortcut: ${FOCUS_SHORTCUT.toUpperCase()}.`;
2458
+ const name = refusing
2459
+ ? 'Turn off focus mode (the card is staying: this workflow has no name yet)'
2460
+ : on
2461
+ ? `Turn off focus mode, shortcut ${FOCUS_SHORTCUT.toUpperCase()}`
2462
+ : `Turn on focus mode and give the canvas the room, shortcut ${FOCUS_SHORTCUT.toUpperCase()}`;
2463
+ return (_jsx(Tooltip, { content: hint, children: _jsxs(Button, { variant: "ghost", size: "sm", onClick: onToggle, "aria-pressed": on, "aria-label": name, className: cn('shrink-0',
2464
+ // On, the control is the only thing on screen saying so — the chrome
2465
+ // it collapsed cannot say it is missing. So it carries the state in
2466
+ // its own colour rather than relying on a panel that is gone.
2467
+ on && 'bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300'), children: [on ? _jsx(Minimize2, { size: 12 }) : _jsx(Maximize2, { size: 12 }), _jsx("span", { "aria-hidden": true, className: "rounded border border-current/30 px-1 font-mono text-[10px] leading-4 opacity-70", children: FOCUS_SHORTCUT.toUpperCase() })] }) }));
2468
+ }
1982
2469
  /**
1983
2470
  * Which graph this is, and the two fields that name it — top-left, floating.
1984
2471
  *
@@ -1988,9 +2475,87 @@ function problemBadge(problems) {
1988
2475
  * costs three lines of canvas forever to be read once. It is still reachable
1989
2476
  * from the button beside the title, and still read out in full to a screen
1990
2477
  * reader, which is the one audience a tooltip would have failed.
2478
+ *
2479
+ * ## Collapsed
2480
+ *
2481
+ * The tallest panel on the screen, so the one focus mode is really about: ~400
2482
+ * by ~270 of the canvas, most of it two fields and a paragraph about durability
2483
+ * that nobody reads twice. Collapsed, what is left is the head — and the head
2484
+ * gains something rather than only losing things, because the name that was in
2485
+ * the field has to go somewhere: it moves up beside the title, truncated, so the
2486
+ * card still answers "which graph am I looking at" while it is small.
2487
+ *
2488
+ * What SURVIVES the collapse is the point. The status badges stay, so a graph
2489
+ * that is `adopted`, unpublished or disabled still says so; the commits badge
2490
+ * stays, so which type this writes is still on screen. Those are the two facts
2491
+ * on this card that can stop a mistake, and neither of them is worth the height
2492
+ * that the fields cost.
2493
+ *
2494
+ * The `h1` is in both states, at the same level, so collapsing does not knock a
2495
+ * heading out of the document outline — a screen whose only `h1` comes and goes
2496
+ * with a display preference is a screen that reads differently to a screen
2497
+ * reader depending on a decision made about pixels.
1991
2498
  */
1992
- function WorkflowCard({ eyebrow, title, intro, stored, produces, durability, selected, workflowOptions, workflowsPending, draftName, canEdit, onSelect, onRename, }) {
1993
- return (_jsxs("div", { className: cn('pointer-events-auto w-[min(24rem,100%)] p-3', FLOATING), children: [_jsxs("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-1", children: [_jsx("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.18em]', MUTED), children: eyebrow }), _jsx("h1", { className: "text-sm font-semibold tracking-tight", children: title }), stored && _jsx(WorkflowStatusBadge, { workflow: stored }), _jsx(CommitsBadge, { produces: produces }), _jsx(Tooltip, { content: intro, children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "What this screen is for", className: "ml-auto h-5 w-5", children: _jsx(Info, { size: 11 }) }) })] }), _jsx("p", { className: "sr-only", children: intro }), _jsxs("div", { className: "mt-2.5 grid gap-2", children: [_jsx(SelectField, { label: WORKFLOW_NAME.title, ariaLabel: `Which ${WORKFLOW_NAME.singular} to edit`, value: selected, onValueChange: onSelect, options: workflowOptions, disabled: workflowsPending }), _jsx(TextField, { label: "Name", value: draftName, onChange: onRename, placeholder: "Fleet readiness", disabled: !canEdit })] }), _jsx(DurabilityBanner, { durability: durability })] }));
2499
+ function WorkflowCard({ eyebrow, title, intro, stored, produces, durability, selected, workflowOptions, workflowsPending, draftName, canEdit, collapsed, reducedMotion, onExpand, onSelect, onRename, }) {
2500
+ /**
2501
+ * Whether something inside this card currently has the keyboard.
2502
+ *
2503
+ * The card will not fold while it does, and that is a correctness fix rather
2504
+ * than a nicety. The refusal above holds the card open while the graph has no
2505
+ * name — so the very next thing that happens is somebody typing one, and the
2506
+ * condition that was holding the card open stops being true on the FIRST
2507
+ * character. Without this, the field disappears out from under the caret
2508
+ * mid-word and the rest of the name is typed into nothing.
2509
+ *
2510
+ * Tracked by bubbling rather than by handlers on each field: `focusin` and
2511
+ * `focusout` bubble (unlike `focus` and `blur`), which React exposes as
2512
+ * `onFocus`/`onBlur` on any ancestor, so this works for the picker, the name
2513
+ * field and anything added to the card later without threading a prop.
2514
+ *
2515
+ * `relatedTarget` is where the focus WENT. Still inside the card — Tab from
2516
+ * the picker to the name field — is not a departure. `null` is a departure:
2517
+ * it is what a click on something unfocusable produces, and the card folding
2518
+ * then is right.
2519
+ */
2520
+ const [holdsFocus, setHoldsFocus] = useState(false);
2521
+ const folded = collapsed && !holdsFocus;
2522
+ return (
2523
+ /*
2524
+ * `layout` rather than a CSS transition, because the box goes from a fixed
2525
+ * 24rem to whatever its head needs and there is no width to transition TO —
2526
+ * `auto` is not an animatable value. Motion measures both states and
2527
+ * interpolates the real numbers, which is the difference between a panel
2528
+ * that folds and one that snaps and then re-renders at the new size.
2529
+ */
2530
+ _jsxs(motion.div, { layout: !reducedMotion, transition: reducedMotion ? { duration: 0 } : { type: 'spring', stiffness: 420, damping: 34 }, onFocus: () => setHoldsFocus(true), onBlur: (event) => {
2531
+ if (!event.currentTarget.contains(event.relatedTarget))
2532
+ setHoldsFocus(false);
2533
+ }, className: cn('pointer-events-auto p-3',
2534
+ // Collapsed it is allowed to be WIDER than the 24rem it is fixed at
2535
+ // open, and that is not a slip. Wrapping the head onto a second line
2536
+ // costs 23px of height across the full width of the panel; letting it
2537
+ // run to 30rem costs a strip of canvas beside a title, at the top-left
2538
+ // corner where a graph laid out left-to-right has nothing yet. Height is
2539
+ // the expensive axis here, so the trade goes that way.
2540
+ folded ? 'w-auto max-w-[min(30rem,100%)] py-2' : 'w-[min(24rem,100%)]', FLOATING), children: [_jsxs("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-1", children: [!folded && (_jsx("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.18em]', MUTED), children: eyebrow })), _jsx("h1", { className: "text-sm font-semibold tracking-tight", children: title }), folded && (_jsx("p", { className: cn('max-w-[12rem] truncate text-xs', MUTED), title: draftName, children: draftName })), stored && _jsx(WorkflowStatusBadge, { workflow: stored }), _jsx(CommitsBadge, { produces: produces }), folded ? (_jsx(Tooltip, { content: `Bring the ${WORKFLOW_NAME.singular} picker, the name field and the checkpointing note back, and leave focus mode. Shortcut: ${FOCUS_SHORTCUT.toUpperCase()}.`, children: _jsx(Button, { variant: "ghost", size: "icon", onClick: onExpand, "aria-expanded": false, "aria-label": "Show the workflow card and leave focus mode", className: "ml-auto h-5 w-5", children: _jsx(ChevronDown, { size: 11 }) }) })) : (_jsx(Tooltip, { content: intro, children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "What this screen is for", className: "ml-auto h-5 w-5", children: _jsx(Info, { size: 11 }) }) }))] }), _jsx("p", { className: "sr-only", children: intro }), _jsx(AnimatePresence, { initial: false, children: !folded && (_jsxs(motion.div, { initial: reducedMotion ? false : { height: 0, opacity: 0 }, animate: { height: 'auto', opacity: 1 }, exit: reducedMotion ? { opacity: 0 } : { height: 0, opacity: 0 },
2541
+ /*
2542
+ * A tween, and NOT the spring the rail and the outer box use.
2543
+ *
2544
+ * Two reasons, one aesthetic and one that cost an afternoon. A
2545
+ * spring overshoots, and a height overshooting past zero is a panel
2546
+ * that clips itself against its own border on the way down — the
2547
+ * one place on this screen where bounce reads as a glitch rather
2548
+ * than as life. And a spring on a height resolved from `auto` has
2549
+ * no analytic end: it settles by threshold, on frames. Under jsdom,
2550
+ * which reports no layout, it never settled at all and
2551
+ * `AnimatePresence` therefore never unmounted the body — so focus
2552
+ * mode "worked" in a browser and left the picker and the name field
2553
+ * in the document forever in a test. A tween ends on a clock.
2554
+ */
2555
+ transition: reducedMotion ? { duration: 0 } : { duration: 0.22, ease: [0.32, 0.72, 0, 1] },
2556
+ // Or the fields spill out of the box on the way down: the height is
2557
+ // being animated from zero and their own height is not.
2558
+ className: "overflow-hidden", children: [_jsxs("div", { className: "mt-2.5 grid gap-2", children: [_jsx(SelectField, { label: WORKFLOW_NAME.title, ariaLabel: `Which ${WORKFLOW_NAME.singular} to edit`, value: selected, onValueChange: onSelect, options: workflowOptions, disabled: workflowsPending }), _jsx(TextField, { label: "Name", value: draftName, onChange: onRename, placeholder: "Fleet readiness", disabled: !canEdit })] }), _jsx(DurabilityBanner, { durability: durability })] }, "body")) })] }));
1994
2559
  }
1995
2560
  /**
1996
2561
  * That there are none, said rather than drawn as a blank canvas.
package/dist/context.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CallableWorkflowRef, CatalogAuditEvent, CatalogConnection, CatalogConnector, CatalogObjectPage, CatalogQueryRelation, CatalogQueryResult, CatalogRevision, CatalogSearchResult, CatalogSnapshot, CatalogTrace, CatalogTraceList, CatalogTransform, ConnectionCheck, ConnectorRun, Dashboard, DashboardCard, DeleteReconciliation, LoadExpectation, LoadExpectationInput, ObjectQueryParams, PropertyPatch, ResolvedLoadExpectation, RowCountBound, SaveQueryInput, SavedQuery, SnapshotRef, StoredLoadExpectation, TraceQuery, TransformLanguage, TransformResult, TypePatch } from '@dudousxd/nestjs-catalog/client';
1
+ import type { CallableWorkflowRef, CatalogAuditEvent, CatalogConnection, CatalogConnector, CatalogObjectPage, CatalogQueryRelation, CatalogQueryResult, CatalogReusableNode, CatalogRevision, CatalogSearchResult, CatalogSnapshot, CatalogTrace, CatalogTraceList, CatalogTransform, ConnectionCheck, ConnectorRun, Dashboard, DashboardCard, DeleteReconciliation, LoadExpectation, LoadExpectationInput, ObjectQueryParams, PropertyPatch, ResolvedLoadExpectation, ReusableNodeBody, RowCountBound, SaveQueryInput, SavedQuery, SnapshotRef, StoredLoadExpectation, TraceQuery, TransformLanguage, TransformResult, TypePatch } from '@dudousxd/nestjs-catalog/client';
2
2
  import { type ReactNode } from 'react';
3
3
  import type { EmbeddedChartPayload, EmbeddedDashboardPayload } from './embed/payload';
4
4
  import { type PeopleQuery } from './routes';
@@ -168,6 +168,69 @@ export interface ConnectionUse {
168
168
  status: CatalogWorkflow['status'];
169
169
  through: string;
170
170
  }
171
+ /**
172
+ * One place a shared node body — or a transform — is used.
173
+ *
174
+ * The same shape for both, because they answer the same question about two
175
+ * stored objects and a second shape would be a second thing to keep in step.
176
+ * `CatalogReusableNodeUse` in core is the server's word for it; this is the same
177
+ * fields, re-declared here rather than imported for the reason
178
+ * {@link ConnectionUse} is: the transform route answers this shape too, and core
179
+ * has no type that covers both.
180
+ *
181
+ * Per **node**, not per graph. Three nodes of one graph using the same body are
182
+ * three places an edit lands, which is what somebody about to edit it is asking.
183
+ */
184
+ export interface ReusableNodeUsage {
185
+ workflowId: string;
186
+ workflowName: string;
187
+ status: CatalogWorkflow['status'];
188
+ nodeId: string;
189
+ nodeName: string;
190
+ /**
191
+ * The version this node pinned, or absent for a reference that follows the
192
+ * latest.
193
+ *
194
+ * The field that turns a count into a decision. An unpinned node picks up this
195
+ * edit on its next run; a pinned one does not, until somebody edits that
196
+ * graph. A usage list without it would say "four graphs" and leave the reader
197
+ * unable to tell how many of them they are about to change.
198
+ */
199
+ pinnedVersion?: number;
200
+ }
201
+ /**
202
+ * A reusable node as the picker sees it: the body, plus how many places use it.
203
+ *
204
+ * The count is on the row rather than behind a request per row, because there is
205
+ * no library screen — the maintainer was explicit that reusable nodes belong
206
+ * where a node is added — so this list IS the picker, and a number that changes
207
+ * somebody's decision has to be there before the click.
208
+ */
209
+ export interface ListedReusableNode extends CatalogReusableNode {
210
+ usedBy: number;
211
+ }
212
+ export interface ReusableNodeInput {
213
+ id?: string;
214
+ name: string;
215
+ description?: string;
216
+ body: ReusableNodeBody;
217
+ }
218
+ /**
219
+ * What lifting a node into the library answers with.
220
+ *
221
+ * `setOnNode` rather than an edited graph, and it is the server saying out loud
222
+ * what the caller still has to do: the node is not an instance of anything until
223
+ * `useId` is on it and the graph is saved. A call that had rewritten the graph
224
+ * itself would move its version for a reason its author cannot see in their own
225
+ * diff, which is the class of silence this whole feature exists to end.
226
+ */
227
+ export interface SavedNodeAsReusable {
228
+ reusableNode: CatalogReusableNode;
229
+ setOnNode: {
230
+ nodeId: string;
231
+ useId: string;
232
+ };
233
+ }
171
234
  /**
172
235
  * What a manual run may say about itself.
173
236
  *
@@ -606,6 +669,20 @@ export interface CatalogClient {
606
669
  * thing the screen has to be able to say out loud.
607
670
  */
608
671
  listTransformRevisions(id: string): Promise<CatalogRevision[]>;
672
+ /**
673
+ * Which graphs run this transform, and at which node within each.
674
+ *
675
+ * The answer to "how many places use this", asked of the shared object that
676
+ * already existed. Read in the transform editor rather than in a listing,
677
+ * because the number changes a decision exactly when somebody is about to edit
678
+ * code four other graphs depend on — which is not a moment they spend on a
679
+ * listing page.
680
+ *
681
+ * `pinnedVersion` is what turns the count into a decision rather than an
682
+ * alarm: an unpinned node moves the moment this is saved, a pinned one does
683
+ * not, and the two need different amounts of care.
684
+ */
685
+ listTransformWorkflows(id: string): Promise<ReusableNodeUsage[]>;
609
686
  /**
610
687
  * Run code against sample records without storing anything.
611
688
  *
@@ -627,6 +704,40 @@ export interface CatalogClient {
627
704
  * rather than as a toast a minute later. Sharing the code is not the same as
628
705
  * trusting the client: this call is still made, and its refusal always wins.
629
706
  */
707
+ /**
708
+ * Node bodies saved under a name and used from several graphs, each with the
709
+ * number of places it is used.
710
+ *
711
+ * There is deliberately no library screen behind this. It is the source of the
712
+ * picker offered where a node is added, and the count rides along on every row
713
+ * rather than behind a request per row — a number that changes somebody's
714
+ * decision has to be there before the click.
715
+ *
716
+ * Refuses by name on a deployment whose store cannot hold reusable nodes,
717
+ * rather than answering an empty list. "There are none yet" and "there cannot
718
+ * be any here" look identical to somebody who has never seen one, and the
719
+ * first invites them to keep looking for the button.
720
+ */
721
+ listReusableNodes(): Promise<ListedReusableNode[]>;
722
+ saveReusableNode(input: ReusableNodeInput): Promise<CatalogReusableNode>;
723
+ deleteReusableNode(id: string): Promise<{
724
+ deleted: boolean;
725
+ }>;
726
+ /** Which graphs use it, and at which node within each. */
727
+ listReusableNodeWorkflows(id: string): Promise<ReusableNodeUsage[]>;
728
+ /**
729
+ * Lift one node of a saved graph into a reusable node, by reference.
730
+ *
731
+ * **It does not edit the graph.** It answers with the reusable node and the
732
+ * `useId` to put on that node; setting it and saving is one ordinary
733
+ * {@link CatalogClient.saveWorkflow}, which bumps the graph's version and
734
+ * shows a diff. A call that stored one thing and silently rewrote another
735
+ * would move a version for a reason its author cannot see in their own diff.
736
+ */
737
+ saveNodeAsReusable(workflowId: string, nodeId: string, input: {
738
+ name?: string;
739
+ description?: string;
740
+ }): Promise<SavedNodeAsReusable>;
630
741
  listWorkflows(): Promise<CatalogWorkflow[]>;
631
742
  saveWorkflow(input: WorkflowInput): Promise<CatalogWorkflow>;
632
743
  /**
@@ -807,6 +918,17 @@ export declare const catalogQueryKeys: {
807
918
  * today's code, which is the one thing it exists not to do.
808
919
  */
809
920
  transformRevisions: (id: string) => readonly ["nestjs-catalog", "pipeline", "transforms", string, "revisions"];
921
+ /**
922
+ * Which graphs run one transform, keyed UNDER `transforms` for the reason its
923
+ * neighbour above is: saving a graph is what changes this, and the list
924
+ * invalidation a save already performs has to reach it — a usage count that
925
+ * kept yesterday's number is worse than none, because it is read by somebody
926
+ * deciding whether an edit is safe.
927
+ */
928
+ transformWorkflows: (id: string) => readonly ["nestjs-catalog", "pipeline", "transforms", string, "workflows"];
929
+ reusableNodes: readonly ["nestjs-catalog", "pipeline", "reusable-nodes"];
930
+ /** Keyed under `reusableNodes`, so saving one invalidates its usage list too. */
931
+ reusableNodeWorkflows: (id: string) => readonly ["nestjs-catalog", "pipeline", "reusable-nodes", string, "workflows"];
810
932
  runs: (connectorId?: string) => readonly ["nestjs-catalog", "pipeline", "runs", string];
811
933
  /**
812
934
  * One type's resolved load expectation.
package/dist/context.js CHANGED
@@ -88,7 +88,13 @@ export function CatalogProvider({ transport, pipelineBasePath = DEFAULT_PIPELINE
88
88
  saveTransform: (input) => transport.post(pipeline.transforms(), input),
89
89
  deleteTransform: (id) => transport.delete(pipeline.transform(id)),
90
90
  listTransformRevisions: (id) => transport.get(pipeline.transformRevisions(id)),
91
+ listTransformWorkflows: (id) => transport.get(pipeline.transformWorkflows(id)),
91
92
  tryTransform: (input) => transport.post(pipeline.tryTransform(), input),
93
+ listReusableNodes: () => transport.get(pipeline.reusableNodes()),
94
+ saveReusableNode: (input) => transport.post(pipeline.reusableNodes(), input),
95
+ deleteReusableNode: (id) => transport.delete(pipeline.reusableNode(id)),
96
+ listReusableNodeWorkflows: (id) => transport.get(pipeline.reusableNodeWorkflows(id)),
97
+ saveNodeAsReusable: (workflowId, nodeId, input) => transport.post(pipeline.saveNodeAsReusable(workflowId, nodeId), input),
92
98
  listWorkflows: () => transport.get(pipeline.workflows()),
93
99
  saveWorkflow: (input) => transport.post(pipeline.workflows(), input),
94
100
  publishWorkflow: (id) => transport.post(pipeline.publishWorkflow(id), {}),
@@ -192,6 +198,17 @@ export const catalogQueryKeys = {
192
198
  * today's code, which is the one thing it exists not to do.
193
199
  */
194
200
  transformRevisions: (id) => ['nestjs-catalog', 'pipeline', 'transforms', id, 'revisions'],
201
+ /**
202
+ * Which graphs run one transform, keyed UNDER `transforms` for the reason its
203
+ * neighbour above is: saving a graph is what changes this, and the list
204
+ * invalidation a save already performs has to reach it — a usage count that
205
+ * kept yesterday's number is worse than none, because it is read by somebody
206
+ * deciding whether an edit is safe.
207
+ */
208
+ transformWorkflows: (id) => ['nestjs-catalog', 'pipeline', 'transforms', id, 'workflows'],
209
+ reusableNodes: ['nestjs-catalog', 'pipeline', 'reusable-nodes'],
210
+ /** Keyed under `reusableNodes`, so saving one invalidates its usage list too. */
211
+ reusableNodeWorkflows: (id) => ['nestjs-catalog', 'pipeline', 'reusable-nodes', id, 'workflows'],
195
212
  runs: (connectorId) => ['nestjs-catalog', 'pipeline', 'runs', connectorId ?? 'all'],
196
213
  /**
197
214
  * One type's resolved load expectation.
package/dist/index.d.ts CHANGED
@@ -29,7 +29,7 @@ export { WORKFLOW_NAME } from './workflow/name';
29
29
  export { checkShapes, type ShapeKnowledge, type SourceColumn, type SourceShape, type TargetProperty, type TargetShape, } from './workflow/shape';
30
30
  export { canConnect, type ConnectionVerdict, edgeId, hasBlockingProblem, problemsByNode, type ValidateOptions, validateWorkflow, type WorkflowDraft, type WorkflowProblem, type WorkflowProblemCode, type WorkflowProblemLevel, wouldCycle, } from './workflow/validate';
31
31
  export { attachTransformIds, buildWorkflowTemplate, type EnrichOptions, enrichWithLookup, fanOutTypes, type FanOutOptions, type FanOutTarget, FILE_DROP_KINDS, type FileDropOptions, joinSources, type JoinOptions, loadFileDrop, type PeriodicFullReloadOptions, periodicFullReload, planIsRunnable, planToWorkflowInput, refuseUnusableColumnNames, RELOAD_CADENCE_IDS, RELOAD_CADENCES, type ReloadCadence, replicateTable, type ReplicateTableOptions, SOURCE_KINDS, type TemplateDeclaration, type TemplateExpectation, type TemplateOutcome, type TemplatePlan, type TemplateRefusal, type TemplateRefusalCode, type TemplateRequest, type TemplateSchedule, type TemplateTransformRequest, withinMsFor, WORKFLOW_TEMPLATE_IDS, WORKFLOW_TEMPLATES, type WorkflowTemplateId, type WorkflowTemplateMeta, } from './workflow/templates';
32
- export { type CatalogClient, type CatalogIdentity, type CatalogRevision, type CatalogPeoplePage, type CatalogPersonRole, type CatalogPersonSummary, type CatalogPrincipalSummary, CatalogProvider, type CatalogProviderProps, type CatalogTransport, type ConnectionInput, type ConnectionUse, catalogQueryKeys, type DeleteReconciliation, type LoadExpectation, type LoadExpectationInput, type ResolvedLoadExpectation, type RowCountBound, type StoredLoadExpectation, type PersonInput, type PersonUpsertResult, type PipelineCapabilities, type CallableWorkflowList, type ScheduledWorkflow, type TransformInput, type WorkflowRunOptions, type WorkflowScheduleInput, useCatalogClient, } from './context';
32
+ export { type CatalogClient, type CatalogIdentity, type CatalogRevision, type CatalogPeoplePage, type CatalogPersonRole, type CatalogPersonSummary, type CatalogPrincipalSummary, CatalogProvider, type CatalogProviderProps, type CatalogTransport, type ConnectionInput, type ConnectionUse, catalogQueryKeys, type DeleteReconciliation, type LoadExpectation, type LoadExpectationInput, type ResolvedLoadExpectation, type RowCountBound, type StoredLoadExpectation, type PersonInput, type PersonUpsertResult, type PipelineCapabilities, type CallableWorkflowList, type ScheduledWorkflow, type TransformInput, type ListedReusableNode, type ReusableNodeInput, type ReusableNodeUsage, type SavedNodeAsReusable, type WorkflowRunOptions, type WorkflowScheduleInput, useCatalogClient, } from './context';
33
33
  export { type AccessRoutes, accessRoutes, DEFAULT_ACCESS_BASE_PATH, DEFAULT_PIPELINE_BASE_PATH, DEFAULT_PUBLISH_BASE_PATH, embedRoutes, type PeopleQuery, type PipelineRoutes, pipelineRoutes, } from './routes';
34
34
  export { ConfirmDialog } from './ui/dialog';
35
35
  export { FieldGroup, TextAreaField, TextField } from './ui/field';
package/dist/routes.d.ts CHANGED
@@ -170,7 +170,43 @@ export interface PipelineRoutes {
170
170
  * traceable and the code did not.
171
171
  */
172
172
  transformRevisions(id: string): string;
173
+ /**
174
+ * Which graphs run this transform, and at which node within each.
175
+ *
176
+ * The sibling of {@link PipelineRoutes.connectionWorkflows}, one shared object
177
+ * over. Both are pressed by somebody about to change something and wondering
178
+ * who is downstream, and both are answerable only because the reference is by
179
+ * id rather than by copy.
180
+ *
181
+ * A sub-resource rather than a count on `transforms`, unlike
182
+ * {@link PipelineRoutes.reusableNodes} which does carry one. The difference is
183
+ * where the number is read: a reusable node's count is rendered on the row of
184
+ * a picker somebody is about to click, and a transform's is read once, in an
185
+ * editor already open on one transform.
186
+ */
187
+ transformWorkflows(id: string): string;
173
188
  tryTransform(): string;
189
+ /**
190
+ * Node bodies saved under a name and used from several graphs. GET lists
191
+ * (each with a `usedBy` count), POST creates or updates one.
192
+ *
193
+ * There is deliberately **no library screen** behind this, and no tab. The
194
+ * maintainer was explicit that reusable nodes belong where a node is added
195
+ * rather than in a listing of their own, so this list is the picker's source:
196
+ * the count rides along on every row, because a number that changes somebody's
197
+ * decision has to be there before the click rather than one request after it.
198
+ */
199
+ reusableNodes(): string;
200
+ reusableNode(id: string): string;
201
+ /**
202
+ * Which graphs use this reusable node, and at which node within each.
203
+ *
204
+ * Reports each *node*, not each graph — three nodes in one graph are three
205
+ * places an edit lands, which is the question somebody about to edit a shared
206
+ * body is actually asking. {@link PipelineRoutes.connectionWorkflows} reports
207
+ * each graph once, because deleting a connection breaks a graph once.
208
+ */
209
+ reusableNodeWorkflows(id: string): string;
174
210
  /**
175
211
  * Authored graphs of transforms. GET lists, POST creates or updates.
176
212
  *
@@ -218,6 +254,18 @@ export interface PipelineRoutes {
218
254
  * a source has a shape to report.
219
255
  */
220
256
  discoverSourceSchema(id: string, nodeId: string): string;
257
+ /**
258
+ * Lift one node of a graph into a reusable node, by reference.
259
+ *
260
+ * Beside `.../discover` because it is the same shape of thing: an action on
261
+ * one node of one graph. It stores the body and answers with the reusable
262
+ * node and the `useId` to put on that node — **it does not edit the graph**,
263
+ * because a route that stored one thing and silently rewrote another would
264
+ * move a graph's version for a reason its author cannot see in their own diff.
265
+ * The caller sets `useId` and saves the graph, which is one ordinary
266
+ * {@link PipelineRoutes.workflows} POST.
267
+ */
268
+ saveNodeAsReusable(id: string, nodeId: string): string;
221
269
  /**
222
270
  * Every per-type load expectation an operator has stored.
223
271
  *
package/dist/routes.js CHANGED
@@ -143,7 +143,11 @@ export function pipelineRoutes(basePath = DEFAULT_PIPELINE_BASE_PATH) {
143
143
  transforms: () => `${base}/transforms`,
144
144
  transform: (id) => `${base}/transforms/${encodeURIComponent(id)}`,
145
145
  transformRevisions: (id) => `${base}/transforms/${encodeURIComponent(id)}/revisions`,
146
+ transformWorkflows: (id) => `${base}/transforms/${encodeURIComponent(id)}/workflows`,
146
147
  tryTransform: () => `${base}/transforms/try`,
148
+ reusableNodes: () => `${base}/reusable-nodes`,
149
+ reusableNode: (id) => `${base}/reusable-nodes/${encodeURIComponent(id)}`,
150
+ reusableNodeWorkflows: (id) => `${base}/reusable-nodes/${encodeURIComponent(id)}/workflows`,
147
151
  workflows: () => `${base}/workflows`,
148
152
  workflow: (id) => `${base}/workflows/${encodeURIComponent(id)}`,
149
153
  publishWorkflow: (id) => `${base}/workflows/${encodeURIComponent(id)}/publish`,
@@ -151,6 +155,7 @@ export function pipelineRoutes(basePath = DEFAULT_PIPELINE_BASE_PATH) {
151
155
  runWorkflow: (id) => `${base}/workflows/${encodeURIComponent(id)}/run`,
152
156
  workflowSchedule: (id) => `${base}/workflows/${encodeURIComponent(id)}/schedule`,
153
157
  discoverSourceSchema: (id, nodeId) => `${base}/workflows/${encodeURIComponent(id)}/nodes/${encodeURIComponent(nodeId)}/discover`,
158
+ saveNodeAsReusable: (id, nodeId) => `${base}/workflows/${encodeURIComponent(id)}/nodes/${encodeURIComponent(nodeId)}/save-as-reusable`,
154
159
  loadExpectations: () => expectations.expectations(),
155
160
  loadExpectation: (typeName) => expectations.expectation(typeName),
156
161
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-catalog-react",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Ready-made React screens for @dudousxd/nestjs-catalog — a model manager and a generic object explorer you can drop into your own app shell.",
5
5
  "license": "MIT",
6
6
  "author": "Davide Carvalho",
@@ -110,7 +110,7 @@
110
110
  "tailwind-merge": "3.4.1",
111
111
  "tiptap-markdown": "0.9.0",
112
112
  "typescript": "5.9.3",
113
- "@dudousxd/nestjs-catalog": "0.17.0"
113
+ "@dudousxd/nestjs-catalog": "0.18.0"
114
114
  },
115
115
  "dependencies": {
116
116
  "clsx": "2.1.1",