@dudousxd/nestjs-catalog-react 0.18.0 → 0.19.0-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/CatalogManager.d.ts +23 -1
  2. package/dist/CatalogManager.js +76 -13
  3. package/dist/ConnectionPanel.js +15 -123
  4. package/dist/LoadedBySection.d.ts +39 -0
  5. package/dist/LoadedBySection.js +143 -0
  6. package/dist/WorkflowCanvas.d.ts +16 -0
  7. package/dist/WorkflowCanvas.js +705 -77
  8. package/dist/connection-form.d.ts +241 -0
  9. package/dist/connection-form.js +235 -0
  10. package/dist/context.d.ts +78 -4
  11. package/dist/context.js +11 -0
  12. package/dist/index.d.ts +5 -1
  13. package/dist/index.js +23 -0
  14. package/dist/routes.d.ts +30 -0
  15. package/dist/routes.js +2 -0
  16. package/dist/schema-discovery.d.ts +17 -1
  17. package/dist/schema-discovery.js +3 -3
  18. package/dist/source-connection.d.ts +82 -0
  19. package/dist/source-connection.js +176 -0
  20. package/dist/source-fields.d.ts +15 -2
  21. package/dist/source-fields.js +15 -2
  22. package/dist/ui/combobox.d.ts +97 -0
  23. package/dist/ui/combobox.js +80 -0
  24. package/dist/workflow/edges.d.ts +110 -0
  25. package/dist/workflow/edges.js +112 -0
  26. package/dist/workflow/graph.d.ts +39 -1
  27. package/dist/workflow/graph.js +181 -43
  28. package/dist/workflow/index.d.ts +7 -1
  29. package/dist/workflow/index.js +10 -5
  30. package/dist/workflow/lifecycle.d.ts +0 -29
  31. package/dist/workflow/lifecycle.js +2 -35
  32. package/dist/workflow/model.d.ts +17 -3
  33. package/dist/workflow/model.js +7 -2
  34. package/dist/workflow/nodes.d.ts +4 -1
  35. package/dist/workflow/nodes.js +190 -11
  36. package/dist/workflow/templates.js +10 -0
  37. package/dist/workflow/validate.js +11 -0
  38. package/dist/workflow/wiring.d.ts +84 -0
  39. package/dist/workflow/wiring.js +254 -0
  40. package/package.json +9 -9
@@ -11,8 +11,14 @@
11
11
  * The graph model, the working name and the validation rules stay on the root
12
12
  * entry — none of them import React Flow, and a host should be able to check a
13
13
  * graph, or name one, without pulling in a canvas to do it.
14
+ *
15
+ * `motion` is the second optional peer this subpath needs, for the same class of
16
+ * reason: the delete control on a selected edge animates in and out, and
17
+ * `useReducedMotion` is how it declines to. Both are declined together —
18
+ * anything mounting a node canvas is already installing a graph library, and a
19
+ * host that wants neither wants the root entry point instead.
14
20
  */
15
21
  export { WorkflowCanvas, type WorkflowCanvasProps } from '../WorkflowCanvas';
16
22
  export { layout, layoutIfUnarranged, NODE_HEIGHT, NODE_WIDTH, type WorkflowFlowEdge, type WorkflowFlowNode, type WorkflowNodeData, } from './graph';
17
- export { AdoptionNote, PublishControls, refusedForShrink, RunControls, SchedulePanel, ShrinkRefusalNote, wasAdopted, WORKFLOW_ADOPTION_ACTOR, WorkflowStatusBadge, } from './lifecycle';
23
+ export { PublishControls, refusedForShrink, RunControls, SchedulePanel, ShrinkRefusalNote, WorkflowStatusBadge, } from './lifecycle';
18
24
  export { RunsAsPanel } from './runs';
@@ -11,13 +11,18 @@
11
11
  * The graph model, the working name and the validation rules stay on the root
12
12
  * entry — none of them import React Flow, and a host should be able to check a
13
13
  * graph, or name one, without pulling in a canvas to do it.
14
+ *
15
+ * `motion` is the second optional peer this subpath needs, for the same class of
16
+ * reason: the delete control on a selected edge animates in and out, and
17
+ * `useReducedMotion` is how it declines to. Both are declined together —
18
+ * anything mounting a node canvas is already installing a graph library, and a
19
+ * host that wants neither wants the root entry point instead.
14
20
  */
15
21
  export { WorkflowCanvas } from '../WorkflowCanvas';
16
22
  export { layout, layoutIfUnarranged, NODE_HEIGHT, NODE_WIDTH, } from './graph';
17
23
  // What happens to a graph once it is drawn. Here rather than on the root entry
18
- // because a host reaching for these is already mounting the canvas — and here
19
- // rather than nowhere because `wasAdopted` and `refusedForShrink` are the two
20
- // judgements a host might want to make outside a canvas: "did anybody actually
21
- // draw this" and "was that failure the row-count bound".
22
- export { AdoptionNote, PublishControls, refusedForShrink, RunControls, SchedulePanel, ShrinkRefusalNote, wasAdopted, WORKFLOW_ADOPTION_ACTOR, WorkflowStatusBadge, } from './lifecycle';
24
+ // because a host reaching for these is already mounting the canvas — and
25
+ // `refusedForShrink` is here rather than nowhere because "was that failure the
26
+ // row-count bound" is a judgement a host might want to make outside a canvas.
27
+ export { PublishControls, refusedForShrink, RunControls, SchedulePanel, ShrinkRefusalNote, WorkflowStatusBadge, } from './lifecycle';
23
28
  export { RunsAsPanel } from './runs';
@@ -23,24 +23,6 @@
23
23
  */
24
24
  import { type WorkflowRunOptions } from '../context';
25
25
  import type { CatalogWorkflow, WorkflowRun } from './model';
26
- /**
27
- * Who a graph is attributed to when nobody drew it.
28
- *
29
- * `ConnectorAdoption` wraps a pre-workflow connector into the graph it always
30
- * was, at boot, and publishes it — so an operator on an upgraded deployment
31
- * opens this screen and finds pipelines marked `ready` that they never drew and
32
- * never declared finished. That is worth saying out loud rather than leaving
33
- * them to infer it from a description.
34
- *
35
- * Matched on `createdBy` rather than on the generated description, because a
36
- * connector that carried a description of its own keeps it — so the description
37
- * is silent on exactly the graphs that had the most history behind them. The
38
- * string is the server's `ADOPTION_ACTOR`, and it is a copy: a rename there
39
- * makes this badge disappear rather than lie, which is the failure mode to
40
- * prefer between the two.
41
- */
42
- export declare const WORKFLOW_ADOPTION_ACTOR = "connector-adoption";
43
- export declare function wasAdopted(workflow: Pick<CatalogWorkflow, 'createdBy'>): boolean;
44
26
  /**
45
27
  * Whether a failure is the row-count bound refusing a load, rather than
46
28
  * anything else that can go wrong in a run.
@@ -68,17 +50,6 @@ export declare function refusedForShrink(message: string | undefined): boolean;
68
50
  export declare function WorkflowStatusBadge({ workflow }: {
69
51
  workflow: CatalogWorkflow;
70
52
  }): import("react/jsx-runtime").JSX.Element;
71
- /**
72
- * The paragraph the badge cannot hold.
73
- *
74
- * On screen rather than in a tooltip, and only for an adopted graph, because a
75
- * tooltip is something you find when you already suspect there is something to
76
- * find. Somebody opening a pipeline they have never seen and being told it is
77
- * `ready` has no reason to hover anything.
78
- */
79
- export declare function AdoptionNote({ workflow }: {
80
- workflow: CatalogWorkflow;
81
- }): import("react/jsx-runtime").JSX.Element | null;
82
53
  /**
83
54
  * Publish, or take it back to draft.
84
55
  *
@@ -23,7 +23,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
23
23
  * used, and it will not send a blank reason.
24
24
  */
25
25
  import { useMutation, useQueryClient } from '@tanstack/react-query';
26
- import { CircleCheck, Clock, Loader2, Play, Sparkles, TriangleAlert, Undo2, Upload, } from 'lucide-react';
26
+ import { CircleCheck, Clock, Loader2, Play, TriangleAlert, Undo2, Upload } from 'lucide-react';
27
27
  import { useState } from 'react';
28
28
  import { cn } from '../cn';
29
29
  import { catalogQueryKeys, useCatalogClient, } from '../context';
@@ -36,26 +36,6 @@ import { WORKFLOW_NAME } from './name';
36
36
  const MUTED = 'text-zinc-400 dark:text-zinc-500';
37
37
  const RULE = 'border-zinc-200 dark:border-zinc-800';
38
38
  const PANEL = 'bg-white dark:bg-zinc-900';
39
- /**
40
- * Who a graph is attributed to when nobody drew it.
41
- *
42
- * `ConnectorAdoption` wraps a pre-workflow connector into the graph it always
43
- * was, at boot, and publishes it — so an operator on an upgraded deployment
44
- * opens this screen and finds pipelines marked `ready` that they never drew and
45
- * never declared finished. That is worth saying out loud rather than leaving
46
- * them to infer it from a description.
47
- *
48
- * Matched on `createdBy` rather than on the generated description, because a
49
- * connector that carried a description of its own keeps it — so the description
50
- * is silent on exactly the graphs that had the most history behind them. The
51
- * string is the server's `ADOPTION_ACTOR`, and it is a copy: a rename there
52
- * makes this badge disappear rather than lie, which is the failure mode to
53
- * prefer between the two.
54
- */
55
- export const WORKFLOW_ADOPTION_ACTOR = 'connector-adoption';
56
- export function wasAdopted(workflow) {
57
- return workflow.createdBy === WORKFLOW_ADOPTION_ACTOR;
58
- }
59
39
  /**
60
40
  * Whether a failure is the row-count bound refusing a load, rather than
61
41
  * anything else that can go wrong in a run.
@@ -88,20 +68,7 @@ export function WorkflowStatusBadge({ workflow }) {
88
68
  ? `Declared finished, and validated when it was. It runs as a connector of its own, and only a ready ${WORKFLOW_NAME.singular} can be scheduled.`
89
69
  : 'Being drawn. It saves without being validated — that is what a draft is for — and it neither runs on a schedule nor mints anything. Publishing is where the checks are answered for real.', children: _jsx("span", { className: cn('cursor-help rounded-sm px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em]', ready
90
70
  ? 'bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-300'
91
- : 'bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300'), children: workflow.status }) }), !workflow.enabled && (_jsx(Tooltip, { content: "Turned off. It keeps its configuration, its schedule and its incremental watermark, and refuses to fire.", children: _jsx("span", { className: cn('cursor-help rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em]', 'text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300'), children: "disabled" }) })), wasAdopted(workflow) && (_jsx(Tooltip, { content: `Nobody drew this. It was a connector from before a ${WORKFLOW_NAME.singular} was the only thing anybody authors, and it was wrapped into this graph at boot — one source, optionally one transform, one sink — and published as ready without a person declaring it finished. It keeps the connector's id, so its run history and its incremental watermark carry over. Worth reading before you trust the shape.`, children: _jsxs("span", { className: "flex cursor-help items-center gap-1 rounded-sm bg-sky-100 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em] text-sky-800 dark:bg-sky-950 dark:text-sky-300", children: [_jsx(Sparkles, { size: 9, "aria-hidden": true }), "adopted"] }) }))] }));
92
- }
93
- /**
94
- * The paragraph the badge cannot hold.
95
- *
96
- * On screen rather than in a tooltip, and only for an adopted graph, because a
97
- * tooltip is something you find when you already suspect there is something to
98
- * find. Somebody opening a pipeline they have never seen and being told it is
99
- * `ready` has no reason to hover anything.
100
- */
101
- export function AdoptionNote({ workflow }) {
102
- if (!wasAdopted(workflow))
103
- return null;
104
- return (_jsxs("div", { className: cn('mt-2.5 flex flex-wrap items-baseline gap-x-2 rounded-md border px-2.5 py-1.5', 'border-sky-200 bg-sky-50 text-sky-900', 'dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200'), children: [_jsx("p", { className: "font-mono text-[10px] uppercase tracking-[0.14em]", children: "adopted at boot" }), _jsxs("p", { className: "text-[11px] leading-relaxed", children: ["This graph was not drawn by anybody. A connector that predates ", WORKFLOW_NAME.plural, " was wrapped into it and published as ", _jsx("em", { children: "ready" }), " automatically, so \"ready\" here means \"it validated\", not \"somebody looked at it and said it was finished\". Its run history and incremental watermark carried over with the connector's id."] })] }));
71
+ : 'bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300'), children: workflow.status }) }), !workflow.enabled && (_jsx(Tooltip, { content: "Turned off. It keeps its configuration, its schedule and its incremental watermark, and refuses to fire.", children: _jsx("span", { className: cn('cursor-help rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em]', 'text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300'), children: "disabled" }) }))] }));
105
72
  }
106
73
  /**
107
74
  * Publish, or take it back to draft.
@@ -18,9 +18,9 @@
18
18
  * executes it, it belongs to core; if only this screen has an opinion about it,
19
19
  * it belongs here.
20
20
  */
21
- export type { CallableWorkflowRef, CatalogWorkflow, WorkflowEdge, WorkflowCallNode, WorkflowGraph, WorkflowNode, WorkflowNodeKind, WorkflowSinkNode, WorkflowSourceNode, WorkflowTransformNode, } from '@dudousxd/nestjs-catalog/client';
22
- export { isWorkflowNodeKind, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
23
- import { type WorkflowNode } from '@dudousxd/nestjs-catalog/client';
21
+ export type { CallableWorkflowBlock, CallableWorkflowDisagreement, CallableWorkflowRef, CatalogWorkflow, WorkflowBranchLabel, WorkflowEdge, WorkflowCallNode, WorkflowEnvPredicate, WorkflowGraph, WorkflowIfNode, WorkflowIfPredicate, WorkflowNode, WorkflowNodeKind, WorkflowPredicateKind, WorkflowRowCountPredicate, WorkflowSinkNode, WorkflowSkipReason, WorkflowSourceNode, WorkflowTransformNode, } from '@dudousxd/nestjs-catalog/client';
22
+ export { callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowNodeKind, isWorkflowPredicateKind, unreachableNodeKind, unreachablePredicateKind, WORKFLOW_BRANCH_LABELS, WORKFLOW_PREDICATE_KINDS, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
23
+ import { type WorkflowBranchLabel, type WorkflowNode, type WorkflowSkipReason } from '@dudousxd/nestjs-catalog/client';
24
24
  /**
25
25
  * What a caller may set.
26
26
  *
@@ -117,6 +117,20 @@ export interface WorkflowRunNode {
117
117
  * nowhere else to read it from.
118
118
  */
119
119
  replayed?: boolean;
120
+ /** Which branch an `if` node took on this run. See {@link WorkflowIfNode}. */
121
+ branch?: WorkflowBranchLabel;
122
+ /**
123
+ * Why a `skipped` node did not run, when a branch is the reason rather than a
124
+ * failure above it.
125
+ *
126
+ * The distinction a run panel exists to draw for a **sink**: skipped by a
127
+ * branch means it committed nothing *and was right not to*, so the snapshot
128
+ * that was live before the run is still live. Skipped with no reason means the
129
+ * run fell over before reaching it. Rendering the two identically would answer
130
+ * "why is there no fresh data in X" with the same shrug for a healthy run and
131
+ * a broken one.
132
+ */
133
+ skippedBecause?: WorkflowSkipReason;
120
134
  rows?: number;
121
135
  error?: string;
122
136
  startedAt?: string;
@@ -18,8 +18,13 @@
18
18
  * executes it, it belongs to core; if only this screen has an opinion about it,
19
19
  * it belongs here.
20
20
  */
21
- export { isWorkflowNodeKind, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
22
- import { WORKFLOW_NODE_ID_PATTERN } from '@dudousxd/nestjs-catalog/client';
21
+ export {
22
+ // Whether an announced workflow may be committed onto a call node. Core's,
23
+ // not a copy: the picker greys an entry out and the server reasons about the
24
+ // same list, and two copies of that rule is a picker that eventually offers
25
+ // something the rest of the system will not accept.
26
+ callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowNodeKind, isWorkflowPredicateKind, unreachableNodeKind, unreachablePredicateKind, WORKFLOW_BRANCH_LABELS, WORKFLOW_PREDICATE_KINDS, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
27
+ import { WORKFLOW_NODE_ID_PATTERN, } from '@dudousxd/nestjs-catalog/client';
23
28
  export function describeDurability(durability) {
24
29
  if (!durability) {
25
30
  return {
@@ -1,6 +1,7 @@
1
1
  import { type NodeProps } from '@xyflow/react';
2
2
  import { type ReactNode } from 'react';
3
- import type { WorkflowFlowNode } from './graph';
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;
@@ -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 { createContext, useContext } from 'react';
3
+ import { CircleAlert, CircleCheck, CircleSlash, Code2, Database, ExternalLink, 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 } 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-500',
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-sky-500',
30
- chip: 'text-sky-700 dark:text-sky-300',
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-500',
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,23 @@ 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-500',
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
+ },
49
86
  };
50
87
  /**
51
88
  * Handles are styled larger than React Flow's default 6px dot.
@@ -55,11 +92,76 @@ const KIND_STYLE = {
55
92
  * drag on one. `connectionRadius` on the canvas widens the drop zone; this
56
93
  * widens what you can see to aim at.
57
94
  */
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',
95
+ 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',
96
+ // A pointer, not a crosshair: a click is now enough. See `wiring.tsx`.
97
+ '!cursor-pointer',
98
+ // Grows under the pointer, so the thing you are about to click
99
+ // acknowledges you before you commit to it.
100
+ 'hover:!scale-125 hover:!border-violet-400', 'focus-visible:!outline-none focus-visible:!ring-2 focus-visible:!ring-sky-500/50',
59
101
  // React Flow adds these while a connection is being dragged. Colouring them
60
102
  // is what makes an illegal target — one that would close a loop, or a source
61
103
  // that takes no input — visibly refuse *before* the mouse is released.
62
104
  '[.react-flow__handle-connecting&]:!border-red-500', '[.react-flow__handle-valid&]:!border-emerald-500 [.react-flow__handle-valid&]:!bg-emerald-500');
105
+ const HANDLE_WIRING = {
106
+ idle: '',
107
+ origin: '!border-violet-500 !bg-violet-500 !ring-4 !ring-violet-500/25',
108
+ open: cn('!border-emerald-500 !bg-emerald-500 !ring-4 !ring-emerald-500/25', 'motion-safe:!animate-pulse'),
109
+ shut: '!opacity-20',
110
+ };
111
+ function handleWiringState(wiring, nodeId, type) {
112
+ const { pending } = wiring;
113
+ if (!pending)
114
+ return 'idle';
115
+ if (pending.nodeId === nodeId && pending.type === type)
116
+ return 'origin';
117
+ return wiring.accepts(nodeId, type) ? 'open' : 'shut';
118
+ }
119
+ /** The box's version of {@link handleWiringState}. Drawn on the whole node. */
120
+ function nodeWiringState(wiring, nodeId) {
121
+ if (!wiring.pending)
122
+ return 'idle';
123
+ if (wiring.pending.nodeId === nodeId)
124
+ return 'origin';
125
+ if (wiring.accepts(nodeId, 'target') || wiring.accepts(nodeId, 'source'))
126
+ return 'open';
127
+ return 'shut';
128
+ }
129
+ /**
130
+ * The props that turn a handle into something a click, or a key, can operate.
131
+ *
132
+ * Spread onto `<Handle>` rather than written inline twice, because the two
133
+ * handles differ only in which side of the node they are. React Flow spreads its
134
+ * own rest props last, so an `onClick` given here is the one that runs — and the
135
+ * canvas turns `connectOnClick` off besides, so there is exactly one click path
136
+ * and it is this one. `onMouseDown` is untouched: that is where the drag lives,
137
+ * and the drag still works.
138
+ *
139
+ * `role`/`tabIndex`/`onKeyDown` because a handle is now a control, and a control
140
+ * that only a pointer can reach is not one. React Flow renders a `<div>`, so the
141
+ * button semantics have to be stated rather than inherited.
142
+ */
143
+ function wireOn(nodeId, type, wiring) {
144
+ const start = () => wiring.onHandleClick(nodeId, type);
145
+ return {
146
+ role: 'button',
147
+ tabIndex: 0,
148
+ onClick: (event) => {
149
+ // Kept off the node underneath, which would otherwise read the same click
150
+ // as "open this node's inspector" and cover the canvas with a sheet.
151
+ event.stopPropagation();
152
+ start();
153
+ },
154
+ onKeyDown: (event) => {
155
+ if (event.key !== 'Enter' && event.key !== ' ')
156
+ return;
157
+ // Space on a focused element scrolls the page by default, and Enter would
158
+ // reach the node's own key handling.
159
+ event.preventDefault();
160
+ event.stopPropagation();
161
+ start();
162
+ },
163
+ };
164
+ }
63
165
  function RunBadge({ run }) {
64
166
  if (run.status === 'running') {
65
167
  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 +174,94 @@ function RunBadge({ run }) {
72
174
  ? // The single most useful fact on a resumed run, and there is
73
175
  // nowhere else on the screen to read it from.
74
176
  'Replayed from a checkpoint — this step did not run again.'
75
- : `Ran${typeof run.rows === 'number' ? `, ${run.rows} rows` : ''}.`, children: _jsx("span", { className: "flex items-center", children: _jsx(CircleCheck, { size: 11, className: run.replayed ? 'text-zinc-400' : 'text-emerald-500' }) }) }));
177
+ : `${describeBranchTaken(run) ?? 'Ran'}${typeof run.rows === 'number' ? `, ${run.rows} rows` : ''}.`, children: _jsx("span", { className: "flex items-center", children: _jsx(CircleCheck, { size: 11, className: run.replayed ? 'text-zinc-400' : 'text-emerald-500' }) }) }));
178
+ }
179
+ // Drawn rather than left blank, which is what this was.
180
+ //
181
+ // A skipped node used to render nothing at all, which was defensible while
182
+ // `skipped` meant only "the run stopped before here" — the failed node beside
183
+ // it carried the story. It is not defensible now that a node can be skipped by
184
+ // a branch on a run that went perfectly: a sink that quietly shows no badge is
185
+ // exactly the "nothing loaded and nothing said so" this feature has to avoid.
186
+ if (run.status === 'skipped') {
187
+ return (_jsx(Tooltip, { content: describeSkip(run), children: _jsx("span", { className: "flex items-center", children: _jsx(CircleSlash, { size: 11, className: "text-zinc-400" }) }) }));
76
188
  }
77
189
  return null;
78
190
  }
191
+ /**
192
+ * How a node arrives.
193
+ *
194
+ * On mount only, so it plays when a graph is opened and when somebody adds a box
195
+ * — and not while one is dragged, because dragging does not remount. Scale from
196
+ * just under one rather than from zero: the node grows into place instead of
197
+ * being inflated, which at eight nodes on a canvas is the difference between a
198
+ * screen settling and a screen erupting.
199
+ *
200
+ * Under `prefers-reduced-motion` the node is simply there. Nothing is conveyed
201
+ * by the arrival that its presence does not already convey, which is the test
202
+ * for whether skipping an animation costs anybody information.
203
+ */
204
+ const ARRIVE = { type: 'spring', stiffness: 420, damping: 34, mass: 0.7 };
205
+ /** What an `if` node's badge says it decided. Absent on every other kind. */
206
+ function describeBranchTaken(run) {
207
+ if (!run?.branch)
208
+ return undefined;
209
+ return `Took the "${run.branch}" branch`;
210
+ }
211
+ /**
212
+ * The two meanings of `skipped`, told apart.
213
+ *
214
+ * The branch wording deliberately says what did **not** happen to the data,
215
+ * because for a sink that is the whole question: a node that never ran committed
216
+ * nothing, so whatever was published before this run is still published. A
217
+ * reader who is not told that assumes the load emptied it.
218
+ */
219
+ function describeSkip(run) {
220
+ if (run.skippedBecause === 'branch-not-taken') {
221
+ 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.';
222
+ }
223
+ return 'Skipped: the run stopped before reaching this step.';
224
+ }
79
225
  export function WorkflowNodeBody({ id, data, selected }) {
80
- const { onInspect, onEditCode, canEdit } = useWorkflowNodeHandlers();
226
+ const { onInspect, onEditCode, canEdit, wiring } = useWorkflowNodeHandlers();
227
+ const reduced = useReducedMotion();
81
228
  const style = KIND_STYLE[data.kind];
82
229
  const Icon = style.icon;
83
230
  const errors = data.problems.filter((problem) => problem.level === 'error');
84
231
  const warnings = data.problems.filter((problem) => problem.level === 'warning');
85
- return (_jsxs("div", { className: cn('relative w-56 overflow-hidden rounded-lg border shadow-sm transition-shadow', RULE, PANEL, selected && 'ring-2 ring-sky-500/40', errors.length > 0 && 'border-red-400 dark:border-red-800', errors.length === 0 && warnings.length > 0 && 'border-amber-300 dark:border-amber-800'), 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: HANDLE, "aria-label": `input of ${data.label}` })), data.kind !== 'sink' && (_jsx(Handle, { type: "source", position: Position.Right, className: HANDLE, "aria-label": `output of ${data.label}` })), _jsxs("div", { className: "pl-3 pr-2 py-2", children: [_jsxs("div", { className: "flex items-center gap-1.5", 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("button", { type: "button", onClick: () => onInspect(id), className: "nodrag mt-1 block w-full text-left", children: [_jsx("span", { className: "block truncate text-[13px] font-medium", children: data.label }), _jsx("span", { className: cn('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]', RULE, MUTED, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Code2, { size: 9 }), "code"] }) }) }))] })] }));
232
+ const landing = nodeWiringState(wiring, id);
233
+ return (_jsxs(motion.div
234
+ // The width comes from the constant rather than from a `w-56` class, and
235
+ // that is the whole mechanism behind the overlap fix: `WORKFLOW_NODE_WIDTH`
236
+ // is what the server spaces its columns by, so a node whose drawn width
237
+ // came from somewhere else could silently stop matching the layout that
238
+ // was computed for it. There is now one number and no way to change the
239
+ // box without changing it.
240
+ //
241
+ // A width in `style` rather than an animated value, deliberately: React
242
+ // Flow measures `offsetWidth` to place the edges, and a width mid-tween
243
+ // would move every connection while it settled.
244
+ , {
245
+ // The width comes from the constant rather than from a `w-56` class, and
246
+ // that is the whole mechanism behind the overlap fix: `WORKFLOW_NODE_WIDTH`
247
+ // is what the server spaces its columns by, so a node whose drawn width
248
+ // came from somewhere else could silently stop matching the layout that
249
+ // was computed for it. There is now one number and no way to change the
250
+ // box without changing it.
251
+ //
252
+ // A width in `style` rather than an animated value, deliberately: React
253
+ // Flow measures `offsetWidth` to place the edges, and a width mid-tween
254
+ // would move every connection while it settled.
255
+ 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',
256
+ // A lift on hover and a deeper one while selected. `transition-all`
257
+ // rather than `transition-shadow` because the ring width changes too,
258
+ // and a ring that snaps while the shadow fades reads as a glitch.
259
+ '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',
260
+ // While a wire is open, the whole box says whether it can take it — the
261
+ // handle is 12px across and the node is 224, and somebody looking for
262
+ // "where can this go" is looking at boxes. Same judgement, same
263
+ // function, drawn bigger.
264
+ 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
265
  }
87
266
  /**
88
267
  * Declared once, at module scope.
@@ -56,6 +56,16 @@ 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 }),
59
69
  };
60
70
  /* -------------------------------------------------------------------------- */
61
71
  /* 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;