@dudousxd/nestjs-catalog-react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-bklit +21 -0
- package/README.md +282 -0
- package/dist/AccessConsole.d.ts +40 -0
- package/dist/AccessConsole.js +160 -0
- package/dist/CatalogManager.d.ts +12 -0
- package/dist/CatalogManager.js +123 -0
- package/dist/ConnectionPanel.d.ts +41 -0
- package/dist/ConnectionPanel.js +228 -0
- package/dist/CoverageLedger.d.ts +16 -0
- package/dist/CoverageLedger.js +16 -0
- package/dist/DashboardBoard.d.ts +10 -0
- package/dist/DashboardBoard.js +206 -0
- package/dist/EditableField.d.ts +18 -0
- package/dist/EditableField.js +61 -0
- package/dist/FlowView.d.ts +13 -0
- package/dist/FlowView.js +93 -0
- package/dist/GovernanceTimeline.d.ts +16 -0
- package/dist/GovernanceTimeline.js +93 -0
- package/dist/ObjectExplorer.d.ts +9 -0
- package/dist/ObjectExplorer.js +153 -0
- package/dist/PipelineConsole.d.ts +20 -0
- package/dist/PipelineConsole.js +272 -0
- package/dist/QueryConsole.d.ts +11 -0
- package/dist/QueryConsole.js +144 -0
- package/dist/SavedQueryPanel.d.ts +16 -0
- package/dist/SavedQueryPanel.js +78 -0
- package/dist/TraceExplorer.d.ts +54 -0
- package/dist/TraceExplorer.js +342 -0
- package/dist/TransformEditor.d.ts +23 -0
- package/dist/TransformEditor.js +129 -0
- package/dist/WorkflowCanvas.d.ts +24 -0
- package/dist/WorkflowCanvas.js +701 -0
- package/dist/charts/bklit/animation.d.ts +19 -0
- package/dist/charts/bklit/animation.js +28 -0
- package/dist/charts/bklit/area-chart-loading.d.ts +33 -0
- package/dist/charts/bklit/area-chart-loading.js +30 -0
- package/dist/charts/bklit/area-chart.d.ts +47 -0
- package/dist/charts/bklit/area-chart.js +65 -0
- package/dist/charts/bklit/area-gradient-defs.d.ts +28 -0
- package/dist/charts/bklit/area-gradient-defs.js +23 -0
- package/dist/charts/bklit/area.d.ts +75 -0
- package/dist/charts/bklit/area.js +112 -0
- package/dist/charts/bklit/bar-chart-loading.d.ts +16 -0
- package/dist/charts/bklit/bar-chart-loading.js +22 -0
- package/dist/charts/bklit/bar-chart.d.ts +54 -0
- package/dist/charts/bklit/bar-chart.js +440 -0
- package/dist/charts/bklit/bar-depth-geometry.d.ts +41 -0
- package/dist/charts/bklit/bar-depth-geometry.js +46 -0
- package/dist/charts/bklit/bar-squares-layout.d.ts +36 -0
- package/dist/charts/bklit/bar-squares-layout.js +46 -0
- package/dist/charts/bklit/bar-squares.d.ts +48 -0
- package/dist/charts/bklit/bar-squares.js +206 -0
- package/dist/charts/bklit/bar-x-axis.d.ts +13 -0
- package/dist/charts/bklit/bar-x-axis.js +81 -0
- package/dist/charts/bklit/bar-y-axis.d.ts +11 -0
- package/dist/charts/bklit/bar-y-axis.js +72 -0
- package/dist/charts/bklit/bar.d.ts +40 -0
- package/dist/charts/bklit/bar.js +207 -0
- package/dist/charts/bklit/chart-child-passthrough.d.ts +25 -0
- package/dist/charts/bklit/chart-child-passthrough.js +82 -0
- package/dist/charts/bklit/chart-config-context.d.ts +34 -0
- package/dist/charts/bklit/chart-config-context.js +55 -0
- package/dist/charts/bklit/chart-context.d.ts +207 -0
- package/dist/charts/bklit/chart-context.js +200 -0
- package/dist/charts/bklit/chart-defs.d.ts +21 -0
- package/dist/charts/bklit/chart-defs.js +57 -0
- package/dist/charts/bklit/chart-formatters.d.ts +16 -0
- package/dist/charts/bklit/chart-formatters.js +26 -0
- package/dist/charts/bklit/chart-legend-hover.d.ts +21 -0
- package/dist/charts/bklit/chart-legend-hover.js +26 -0
- package/dist/charts/bklit/chart-loading-label.d.ts +9 -0
- package/dist/charts/bklit/chart-loading-label.js +29 -0
- package/dist/charts/bklit/chart-phase.d.ts +39 -0
- package/dist/charts/bklit/chart-phase.js +20 -0
- package/dist/charts/bklit/chart-reveal-clip.d.ts +32 -0
- package/dist/charts/bklit/chart-reveal-clip.js +23 -0
- package/dist/charts/bklit/dash-tail-stroke.d.ts +17 -0
- package/dist/charts/bklit/dash-tail-stroke.js +21 -0
- package/dist/charts/bklit/decimate-time-series.d.ts +18 -0
- package/dist/charts/bklit/decimate-time-series.js +120 -0
- package/dist/charts/bklit/fade-edges.d.ts +42 -0
- package/dist/charts/bklit/fade-edges.js +34 -0
- package/dist/charts/bklit/filter-data-by-x-domain.d.ts +13 -0
- package/dist/charts/bklit/filter-data-by-x-domain.js +50 -0
- package/dist/charts/bklit/generate-chart-skeleton-data.d.ts +24 -0
- package/dist/charts/bklit/generate-chart-skeleton-data.js +33 -0
- package/dist/charts/bklit/grid.d.ts +57 -0
- package/dist/charts/bklit/grid.js +88 -0
- package/dist/charts/bklit/highlight-segment-bounds.d.ts +26 -0
- package/dist/charts/bklit/highlight-segment-bounds.js +35 -0
- package/dist/charts/bklit/highlight-segment.d.ts +30 -0
- package/dist/charts/bklit/highlight-segment.js +22 -0
- package/dist/charts/bklit/indicator-fade.d.ts +23 -0
- package/dist/charts/bklit/indicator-fade.js +41 -0
- package/dist/charts/bklit/line-chart-loading.d.ts +33 -0
- package/dist/charts/bklit/line-chart-loading.js +30 -0
- package/dist/charts/bklit/line-chart.d.ts +45 -0
- package/dist/charts/bklit/line-chart.js +99 -0
- package/dist/charts/bklit/line-loading-pulse.d.ts +19 -0
- package/dist/charts/bklit/line-loading-pulse.js +132 -0
- package/dist/charts/bklit/line-loading-timing.d.ts +18 -0
- package/dist/charts/bklit/line-loading-timing.js +18 -0
- package/dist/charts/bklit/line-series-terminal-marker.d.ts +15 -0
- package/dist/charts/bklit/line-series-terminal-marker.js +54 -0
- package/dist/charts/bklit/line.d.ts +63 -0
- package/dist/charts/bklit/line.js +104 -0
- package/dist/charts/bklit/loading-sweep.d.ts +65 -0
- package/dist/charts/bklit/loading-sweep.js +182 -0
- package/dist/charts/bklit/motion-utils.d.ts +17 -0
- package/dist/charts/bklit/motion-utils.js +27 -0
- package/dist/charts/bklit/path-stroke-utils.d.ts +28 -0
- package/dist/charts/bklit/path-stroke-utils.js +64 -0
- package/dist/charts/bklit/pattern-area.d.ts +20 -0
- package/dist/charts/bklit/pattern-area.js +27 -0
- package/dist/charts/bklit/pattern-preset.d.ts +34 -0
- package/dist/charts/bklit/pattern-preset.js +82 -0
- package/dist/charts/bklit/projection-config.d.ts +19 -0
- package/dist/charts/bklit/projection-config.js +88 -0
- package/dist/charts/bklit/projection-line-end-marker.d.ts +14 -0
- package/dist/charts/bklit/projection-line-end-marker.js +35 -0
- package/dist/charts/bklit/projection-line.d.ts +39 -0
- package/dist/charts/bklit/projection-line.js +87 -0
- package/dist/charts/bklit/projection-utils.d.ts +54 -0
- package/dist/charts/bklit/projection-utils.js +252 -0
- package/dist/charts/bklit/reference-area-config.d.ts +18 -0
- package/dist/charts/bklit/reference-area-config.js +47 -0
- package/dist/charts/bklit/reference-area-registration-context.d.ts +7 -0
- package/dist/charts/bklit/reference-area-registration-context.js +15 -0
- package/dist/charts/bklit/series-bar-layout.d.ts +26 -0
- package/dist/charts/bklit/series-bar-layout.js +39 -0
- package/dist/charts/bklit/series-dash-tail-overlay.d.ts +16 -0
- package/dist/charts/bklit/series-dash-tail-overlay.js +47 -0
- package/dist/charts/bklit/series-highlight-layer.d.ts +31 -0
- package/dist/charts/bklit/series-highlight-layer.js +20 -0
- package/dist/charts/bklit/series-hover-dim.d.ts +28 -0
- package/dist/charts/bklit/series-hover-dim.js +34 -0
- package/dist/charts/bklit/series-markers.d.ts +13 -0
- package/dist/charts/bklit/series-markers.js +106 -0
- package/dist/charts/bklit/series-path-utils.d.ts +18 -0
- package/dist/charts/bklit/series-path-utils.js +68 -0
- package/dist/charts/bklit/series-point-marker.d.ts +47 -0
- package/dist/charts/bklit/series-point-marker.js +47 -0
- package/dist/charts/bklit/static-chart-preview-context.d.ts +15 -0
- package/dist/charts/bklit/static-chart-preview-context.js +20 -0
- package/dist/charts/bklit/time-series-chart-shell.d.ts +46 -0
- package/dist/charts/bklit/time-series-chart-shell.js +398 -0
- package/dist/charts/bklit/tooltip/chart-tooltip.d.ts +75 -0
- package/dist/charts/bklit/tooltip/chart-tooltip.js +158 -0
- package/dist/charts/bklit/tooltip/date-ticker.d.ts +10 -0
- package/dist/charts/bklit/tooltip/date-ticker.js +85 -0
- package/dist/charts/bklit/tooltip/index.d.ts +15 -0
- package/dist/charts/bklit/tooltip/index.js +15 -0
- package/dist/charts/bklit/tooltip/tooltip-box.d.ts +56 -0
- package/dist/charts/bklit/tooltip/tooltip-box.js +122 -0
- package/dist/charts/bklit/tooltip/tooltip-content.d.ts +26 -0
- package/dist/charts/bklit/tooltip/tooltip-content.js +8 -0
- package/dist/charts/bklit/tooltip/tooltip-dot.d.ts +27 -0
- package/dist/charts/bklit/tooltip/tooltip-dot.js +62 -0
- package/dist/charts/bklit/tooltip/tooltip-indicator.d.ts +44 -0
- package/dist/charts/bklit/tooltip/tooltip-indicator.js +73 -0
- package/dist/charts/bklit/use-animated-series-path.d.ts +18 -0
- package/dist/charts/bklit/use-animated-series-path.js +101 -0
- package/dist/charts/bklit/use-animated-y-domains.d.ts +13 -0
- package/dist/charts/bklit/use-animated-y-domains.js +158 -0
- package/dist/charts/bklit/use-chart-interaction.d.ts +40 -0
- package/dist/charts/bklit/use-chart-interaction.js +252 -0
- package/dist/charts/bklit/use-chart-phase-orchestrator.d.ts +22 -0
- package/dist/charts/bklit/use-chart-phase-orchestrator.js +147 -0
- package/dist/charts/bklit/use-enter-complete.d.ts +16 -0
- package/dist/charts/bklit/use-enter-complete.js +22 -0
- package/dist/charts/bklit/use-grid-shimmer.d.ts +15 -0
- package/dist/charts/bklit/use-grid-shimmer.js +71 -0
- package/dist/charts/bklit/use-highlight-segment.d.ts +22 -0
- package/dist/charts/bklit/use-highlight-segment.js +42 -0
- package/dist/charts/bklit/use-mount-progress.d.ts +12 -0
- package/dist/charts/bklit/use-mount-progress.js +30 -0
- package/dist/charts/bklit/use-scheduled-tooltip.d.ts +8 -0
- package/dist/charts/bklit/use-scheduled-tooltip.js +84 -0
- package/dist/charts/bklit/visx-pattern.d.ts +27 -0
- package/dist/charts/bklit/visx-pattern.js +28 -0
- package/dist/charts/bklit/x-axis.d.ts +26 -0
- package/dist/charts/bklit/x-axis.js +423 -0
- package/dist/charts/bklit/y-axis-scales.d.ts +34 -0
- package/dist/charts/bklit/y-axis-scales.js +80 -0
- package/dist/charts/bklit/y-axis-ticks.d.ts +20 -0
- package/dist/charts/bklit/y-axis-ticks.js +32 -0
- package/dist/charts/bklit/y-domain-utils.d.ts +26 -0
- package/dist/charts/bklit/y-domain-utils.js +96 -0
- package/dist/charts/bklit.d.ts +2 -0
- package/dist/charts/bklit.js +90 -0
- package/dist/charts/components/shimmering-text.d.ts +31 -0
- package/dist/charts/components/shimmering-text.js +39 -0
- package/dist/charts/css.d.ts +35 -0
- package/dist/charts/css.js +64 -0
- package/dist/charts/recharts.d.ts +28 -0
- package/dist/charts/recharts.js +48 -0
- package/dist/charts/registry.d.ts +34 -0
- package/dist/charts/registry.js +60 -0
- package/dist/charts/skeleton.d.ts +55 -0
- package/dist/charts/skeleton.js +66 -0
- package/dist/cn.d.ts +10 -0
- package/dist/cn.js +13 -0
- package/dist/context.d.ts +346 -0
- package/dist/context.js +95 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +65 -0
- package/dist/routes.d.ts +70 -0
- package/dist/routes.js +73 -0
- package/dist/source-fields.d.ts +111 -0
- package/dist/source-fields.js +204 -0
- package/dist/ui/chart.d.ts +54 -0
- package/dist/ui/chart.js +122 -0
- package/dist/ui/dialog.d.ts +27 -0
- package/dist/ui/dialog.js +24 -0
- package/dist/ui/field.d.ts +29 -0
- package/dist/ui/field.js +31 -0
- package/dist/ui/select.d.ts +42 -0
- package/dist/ui/select.js +30 -0
- package/dist/ui/sheet.d.ts +38 -0
- package/dist/ui/sheet.js +37 -0
- package/dist/ui/switch.d.ts +17 -0
- package/dist/ui/switch.js +14 -0
- package/dist/ui/tabs.d.ts +30 -0
- package/dist/ui/tabs.js +36 -0
- package/dist/ui/tooltip.d.ts +37 -0
- package/dist/ui/tooltip.js +43 -0
- package/dist/workflow/graph.d.ts +112 -0
- package/dist/workflow/graph.js +297 -0
- package/dist/workflow/index.d.ts +16 -0
- package/dist/workflow/index.js +16 -0
- package/dist/workflow/model.d.ts +151 -0
- package/dist/workflow/model.js +97 -0
- package/dist/workflow/name.d.ts +28 -0
- package/dist/workflow/name.js +28 -0
- package/dist/workflow/nodes.d.ts +40 -0
- package/dist/workflow/nodes.js +86 -0
- package/dist/workflow/validate.d.ts +104 -0
- package/dist/workflow/validate.js +199 -0
- package/package.json +148 -0
|
@@ -0,0 +1,701 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Background, BackgroundVariant, ConnectionLineType, Controls, MiniMap, ReactFlow, ReactFlowProvider, useReactFlow, } from '@xyflow/react';
|
|
3
|
+
// React Flow ships its own stylesheet and renders as an unstyled pile of divs
|
|
4
|
+
// without it — no edges, every node at the top-left corner. Imported by the
|
|
5
|
+
// component that needs it rather than left to the host, because a missing
|
|
6
|
+
// stylesheet does not error and the host that forgets has nothing to go on.
|
|
7
|
+
// See src/styles.d.ts for why `tsc` tolerates this import.
|
|
8
|
+
import '@xyflow/react/dist/style.css';
|
|
9
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
10
|
+
import { ArrowRight, CircleAlert, Code2, Database, LayoutGrid, Loader2, Play, Plug, Plus, Repeat, Save, Trash2, TriangleAlert, Unplug, } from 'lucide-react';
|
|
11
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
|
+
import { TransformEditor } from './TransformEditor';
|
|
13
|
+
import { cn } from './cn';
|
|
14
|
+
import { catalogQueryKeys, useCatalogClient } from './context';
|
|
15
|
+
import { CredentialField, INLINE_CONNECTION, KIND_OPTIONS, ReadModeFields, SourceFields, connectionOptions, readsIncrementally, sourceConfigFrom, sourceDraftFrom, toConnectorKind, usesConnection, } from './source-fields';
|
|
16
|
+
import { ConfirmDialog } from './ui/dialog';
|
|
17
|
+
import { TextField } from './ui/field';
|
|
18
|
+
import { Select, SelectField } from './ui/select';
|
|
19
|
+
import { Sheet } from './ui/sheet';
|
|
20
|
+
import { Tooltip, TooltipProvider } from './ui/tooltip';
|
|
21
|
+
import { defaultLabel, layout, layoutIfUnarranged, nextPosition, toFlowEdges, toFlowNodes, } from './workflow/graph';
|
|
22
|
+
import { describeDurability, isWorkflowNodeKind, newLocalId, nodeName, producedTypes, } from './workflow/model';
|
|
23
|
+
import { WORKFLOW_NAME } from './workflow/name';
|
|
24
|
+
import { WorkflowNodeProvider, workflowNodeTypes } from './workflow/nodes';
|
|
25
|
+
import { canConnect, edgeId, hasBlockingProblem, problemsByNode, validateWorkflow, } from './workflow/validate';
|
|
26
|
+
const MUTED = 'text-zinc-400 dark:text-zinc-500';
|
|
27
|
+
const RULE = 'border-zinc-200 dark:border-zinc-800';
|
|
28
|
+
const PANEL = 'bg-white dark:bg-zinc-900';
|
|
29
|
+
/**
|
|
30
|
+
* The value the workflow picker uses for "start a fresh one".
|
|
31
|
+
*
|
|
32
|
+
* A sentinel rather than a null option, because Base UI's select hands back the
|
|
33
|
+
* item's value and a null there is indistinguishable from a cleared select.
|
|
34
|
+
*/
|
|
35
|
+
const NEW_WORKFLOW = '__new__';
|
|
36
|
+
/**
|
|
37
|
+
* React Flow's own theme, expressed as overrides of its CSS variables.
|
|
38
|
+
*
|
|
39
|
+
* Driven by the host's `dark:` class rather than by React Flow's `colorMode`
|
|
40
|
+
* prop, and that is the whole point. `colorMode="system"` follows the operating
|
|
41
|
+
* system, which is not the same thing as the app's theme: a host whose user has
|
|
42
|
+
* chosen light inside an app on a dark desktop would get a dark canvas embedded
|
|
43
|
+
* in a light page. Tying the variables to `dark:` means the canvas is dark
|
|
44
|
+
* exactly when everything around it is.
|
|
45
|
+
*/
|
|
46
|
+
const CANVAS_THEME = cn('[--xy-background-color:#fafafa] dark:[--xy-background-color:#09090b]', '[--xy-background-pattern-color:#d4d4d8] dark:[--xy-background-pattern-color:#3f3f46]', '[--xy-edge-stroke:#a1a1aa] dark:[--xy-edge-stroke:#52525b]', '[--xy-edge-stroke-selected:#8b5cf6] dark:[--xy-edge-stroke-selected:#a78bfa]', '[--xy-connectionline-stroke:#8b5cf6] dark:[--xy-connectionline-stroke:#a78bfa]', '[--xy-controls-button-background-color:#ffffff] dark:[--xy-controls-button-background-color:#18181b]', '[--xy-controls-button-background-color-hover:#f4f4f5] dark:[--xy-controls-button-background-color-hover:#27272a]', '[--xy-controls-button-color:#52525b] dark:[--xy-controls-button-color:#a1a1aa]', '[--xy-controls-button-border-color:#e4e4e7] dark:[--xy-controls-button-border-color:#27272a]', '[--xy-minimap-background-color:#ffffff] dark:[--xy-minimap-background-color:#18181b]', '[--xy-minimap-node-background-color:#d4d4d8] dark:[--xy-minimap-node-background-color:#52525b]', '[--xy-minimap-mask-background-color:rgba(244,244,245,0.7)] dark:[--xy-minimap-mask-background-color:rgba(24,24,27,0.7)]', '[--xy-attribution-background-color:transparent]', '[--xy-selection-background-color:rgba(139,92,246,0.08)]', '[--xy-selection-border:1px_dotted_#8b5cf6]');
|
|
47
|
+
/**
|
|
48
|
+
* React Flow's built-in screen-reader copy, replaced with copy that says what
|
|
49
|
+
* the keys actually do here.
|
|
50
|
+
*
|
|
51
|
+
* The default node description talks about arrow keys and nothing else, which
|
|
52
|
+
* leaves the one thing a keyboard user cannot discover — that wiring is done
|
|
53
|
+
* from the inspector, not from the canvas — entirely unsaid.
|
|
54
|
+
*/
|
|
55
|
+
const ARIA_LABELS = {
|
|
56
|
+
'node.a11yDescription.default': "Press Enter to open this node's inspector, where it can be renamed, wired to another node and deleted. Press the arrow keys to move it. Press Delete to remove it.",
|
|
57
|
+
'controls.ariaLabel': 'Canvas controls',
|
|
58
|
+
'minimap.ariaLabel': `Overview of the ${WORKFLOW_NAME.singular}`,
|
|
59
|
+
};
|
|
60
|
+
function blankDraft() {
|
|
61
|
+
return { name: '', description: '', nodes: [], edges: [], dirty: false };
|
|
62
|
+
}
|
|
63
|
+
function draftFrom(workflow) {
|
|
64
|
+
return {
|
|
65
|
+
id: workflow.id,
|
|
66
|
+
name: workflow.name,
|
|
67
|
+
description: workflow.description ?? '',
|
|
68
|
+
// Copied rather than referenced: the query cache owns the objects it
|
|
69
|
+
// returned, and mutating a node's position in place would edit the cached
|
|
70
|
+
// workflow, so a background refetch would silently "confirm" edits that
|
|
71
|
+
// were never saved.
|
|
72
|
+
//
|
|
73
|
+
// Arranged on the way in, when nothing has arranged it. A graph created
|
|
74
|
+
// through the API — by a scheduler, by a promotion, by a script — carries no
|
|
75
|
+
// positions, and drawing those at the origin stacks every node on the first
|
|
76
|
+
// one and makes a perfectly ordinary DAG read as a loop. See
|
|
77
|
+
// `layoutIfUnarranged`.
|
|
78
|
+
nodes: layoutIfUnarranged(workflow.nodes.map((node) => ({
|
|
79
|
+
...node,
|
|
80
|
+
position: node.position ? { ...node.position } : undefined,
|
|
81
|
+
})), workflow.edges),
|
|
82
|
+
edges: workflow.edges.map((edge) => ({ from: edge.from, to: edge.to })),
|
|
83
|
+
version: workflow.version,
|
|
84
|
+
dirty: false,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Transforms wired to each other, ending at one or more sinks.
|
|
89
|
+
*
|
|
90
|
+
* Deliberately **not** called Flow. `FlowView` in this package is a *derived*
|
|
91
|
+
* picture — it reconstructs who feeds what from the audit trail, and argues in
|
|
92
|
+
* its own comment that inferring the graph from what publishers actually did is
|
|
93
|
+
* more truthful than a diagram somebody maintains. This screen is the opposite
|
|
94
|
+
* claim: a graph a person authors and the server then executes. Sharing a name
|
|
95
|
+
* would leave two screens making opposite promises about where the truth is.
|
|
96
|
+
* See `workflow/name.ts`.
|
|
97
|
+
*/
|
|
98
|
+
export function WorkflowCanvas(props) {
|
|
99
|
+
return (_jsx(TooltipProvider, { children: _jsx(ReactFlowProvider, { children: _jsx(Canvas, { ...props }) }) }));
|
|
100
|
+
}
|
|
101
|
+
function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intro = `Wire sources through transforms into sinks. Each sink commits its own object type independently, so one expensive read can feed several outputs.`, canEdit = true, }) {
|
|
102
|
+
const client = useCatalogClient();
|
|
103
|
+
const queryClient = useQueryClient();
|
|
104
|
+
const { fitView } = useReactFlow();
|
|
105
|
+
const workflows = useQuery({
|
|
106
|
+
queryKey: catalogQueryKeys.workflows,
|
|
107
|
+
queryFn: () => client.listWorkflows(),
|
|
108
|
+
});
|
|
109
|
+
const { data: transforms = [] } = useQuery({
|
|
110
|
+
queryKey: catalogQueryKeys.transforms,
|
|
111
|
+
queryFn: () => client.listTransforms(),
|
|
112
|
+
staleTime: 30_000,
|
|
113
|
+
});
|
|
114
|
+
const { data: connections = [] } = useQuery({
|
|
115
|
+
queryKey: catalogQueryKeys.connections,
|
|
116
|
+
queryFn: () => client.listConnections(),
|
|
117
|
+
staleTime: 30_000,
|
|
118
|
+
});
|
|
119
|
+
const { data: capabilities } = useQuery({
|
|
120
|
+
queryKey: catalogQueryKeys.capabilities,
|
|
121
|
+
queryFn: () => client.pipelineCapabilities(),
|
|
122
|
+
// Which languages an image can execute, and whether a durable engine is
|
|
123
|
+
// wired up, cannot change without a redeploy — and a redeploy reloads the
|
|
124
|
+
// page. Refetching would be a request that can only return the same answer.
|
|
125
|
+
staleTime: Number.POSITIVE_INFINITY,
|
|
126
|
+
});
|
|
127
|
+
const { data: snapshot } = useQuery({
|
|
128
|
+
queryKey: catalogQueryKeys.snapshot,
|
|
129
|
+
queryFn: () => client.snapshot(),
|
|
130
|
+
staleTime: 30_000,
|
|
131
|
+
});
|
|
132
|
+
const [selected, setSelected] = useState('');
|
|
133
|
+
const [draft, setDraft] = useState(blankDraft);
|
|
134
|
+
const [selectedNodeIds, setSelectedNodeIds] = useState([]);
|
|
135
|
+
const [selectedEdgeIds, setSelectedEdgeIds] = useState([]);
|
|
136
|
+
const [inspecting, setInspecting] = useState(null);
|
|
137
|
+
const [editingCodeFor, setEditingCodeFor] = useState(null);
|
|
138
|
+
const [confirmingDelete, setConfirmingDelete] = useState(false);
|
|
139
|
+
const [run, setRun] = useState(null);
|
|
140
|
+
/**
|
|
141
|
+
* The last thing the canvas refused, and the last thing it did.
|
|
142
|
+
*
|
|
143
|
+
* One string, announced politely, because a canvas gives no other feedback to
|
|
144
|
+
* somebody who cannot see it: a refused drag is silence, and a node added off
|
|
145
|
+
* screen is silence too.
|
|
146
|
+
*/
|
|
147
|
+
const [announcement, setAnnouncement] = useState('');
|
|
148
|
+
/**
|
|
149
|
+
* Which workflow the draft was built from.
|
|
150
|
+
*
|
|
151
|
+
* A ref rather than state so that a background refetch — which produces a new
|
|
152
|
+
* array with the same ids — does not re-enter the load branch and throw away
|
|
153
|
+
* everything somebody has moved since.
|
|
154
|
+
*/
|
|
155
|
+
const loadedRef = useRef(null);
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
const list = workflows.data;
|
|
158
|
+
if (!list)
|
|
159
|
+
return;
|
|
160
|
+
const wanted = selected || list[0]?.id || NEW_WORKFLOW;
|
|
161
|
+
if (loadedRef.current === wanted)
|
|
162
|
+
return;
|
|
163
|
+
loadedRef.current = wanted;
|
|
164
|
+
if (selected !== wanted)
|
|
165
|
+
setSelected(wanted);
|
|
166
|
+
const found = wanted === NEW_WORKFLOW ? undefined : list.find((w) => w.id === wanted);
|
|
167
|
+
setDraft(found ? draftFrom(found) : blankDraft());
|
|
168
|
+
setSelectedNodeIds([]);
|
|
169
|
+
setSelectedEdgeIds([]);
|
|
170
|
+
setInspecting(null);
|
|
171
|
+
setRun(null);
|
|
172
|
+
}, [workflows.data, selected]);
|
|
173
|
+
// Fit after the graph swaps, on the frame after the new nodes have been laid
|
|
174
|
+
// out. Calling it in the same tick fits an empty canvas, because React Flow
|
|
175
|
+
// has not measured anything yet.
|
|
176
|
+
const draftId = draft.id;
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
const frame = window.requestAnimationFrame(() => fitView({ padding: 0.25, duration: 200 }));
|
|
179
|
+
return () => window.cancelAnimationFrame(frame);
|
|
180
|
+
}, [draftId, fitView]);
|
|
181
|
+
const edit = useCallback((change) => {
|
|
182
|
+
setDraft((current) => ({ ...change(current), dirty: true }));
|
|
183
|
+
}, []);
|
|
184
|
+
const transformIds = useMemo(() => new Set(transforms.map((transform) => transform.id)), [transforms]);
|
|
185
|
+
const problems = useMemo(() => validateWorkflow({ nodes: draft.nodes, edges: draft.edges }, { transformIds }), [draft.nodes, draft.edges, transformIds]);
|
|
186
|
+
const problemsFor = useMemo(() => problemsByNode(problems), [problems]);
|
|
187
|
+
const brokenEdgeIds = useMemo(() => new Set(problems.flatMap((problem) => problem.edgeIds)), [problems]);
|
|
188
|
+
const runFor = useMemo(() => new Map((run?.nodes ?? []).map((node) => [node.nodeId, node])), [run]);
|
|
189
|
+
const describe = useMemo(() => ({
|
|
190
|
+
transformName: (id) => (id ? transforms.find((t) => t.id === id)?.name : undefined),
|
|
191
|
+
connectionName: (id) => (id ? connections.find((c) => c.id === id)?.name : undefined),
|
|
192
|
+
}), [transforms, connections]);
|
|
193
|
+
const flowNodes = useMemo(() => {
|
|
194
|
+
const selectedIds = new Set(selectedNodeIds);
|
|
195
|
+
return toFlowNodes(draft.nodes, draft.edges, describe, problemsFor, runFor).map((node) => ({
|
|
196
|
+
...node,
|
|
197
|
+
selected: selectedIds.has(node.id),
|
|
198
|
+
}));
|
|
199
|
+
}, [draft.nodes, draft.edges, describe, problemsFor, runFor, selectedNodeIds]);
|
|
200
|
+
const flowEdges = useMemo(() => {
|
|
201
|
+
const selectedIds = new Set(selectedEdgeIds);
|
|
202
|
+
return toFlowEdges(draft.edges, draft.nodes, brokenEdgeIds).map((edge) => ({
|
|
203
|
+
...edge,
|
|
204
|
+
selected: selectedIds.has(edge.id),
|
|
205
|
+
}));
|
|
206
|
+
}, [draft.edges, draft.nodes, brokenEdgeIds, selectedEdgeIds]);
|
|
207
|
+
/**
|
|
208
|
+
* React Flow's changes, applied to the stored model rather than to a second
|
|
209
|
+
* copy of the graph.
|
|
210
|
+
*
|
|
211
|
+
* The alternative — `useNodesState` holding React Flow's own nodes as the
|
|
212
|
+
* source of truth — means two representations of the same graph that have to
|
|
213
|
+
* be kept in step, and the bug that produces is a saved workflow whose wiring
|
|
214
|
+
* does not match what was on screen.
|
|
215
|
+
*/
|
|
216
|
+
const onNodesChange = useCallback((changes) => {
|
|
217
|
+
for (const change of changes) {
|
|
218
|
+
if (change.type === 'select') {
|
|
219
|
+
setSelectedNodeIds((current) => change.selected
|
|
220
|
+
? [...new Set([...current, change.id])]
|
|
221
|
+
: current.filter((id) => id !== change.id));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const positions = new Map();
|
|
225
|
+
const removed = new Set();
|
|
226
|
+
for (const change of changes) {
|
|
227
|
+
if (change.type === 'position' && change.position) {
|
|
228
|
+
positions.set(change.id, change.position);
|
|
229
|
+
}
|
|
230
|
+
if (change.type === 'remove')
|
|
231
|
+
removed.add(change.id);
|
|
232
|
+
}
|
|
233
|
+
if (positions.size === 0 && removed.size === 0)
|
|
234
|
+
return;
|
|
235
|
+
edit((current) => ({
|
|
236
|
+
...current,
|
|
237
|
+
nodes: current.nodes
|
|
238
|
+
.filter((node) => !removed.has(node.id))
|
|
239
|
+
.map((node) => {
|
|
240
|
+
const position = positions.get(node.id);
|
|
241
|
+
return position ? { ...node, position } : node;
|
|
242
|
+
}),
|
|
243
|
+
// A removed node takes its wiring with it. Leaving the edges behind
|
|
244
|
+
// would produce edges pointing at nothing, which React Flow silently
|
|
245
|
+
// drops from the canvas while the save still sends them.
|
|
246
|
+
edges: current.edges.filter((edge) => !removed.has(edge.from) && !removed.has(edge.to)),
|
|
247
|
+
}));
|
|
248
|
+
if (removed.size > 0) {
|
|
249
|
+
setAnnouncement(`${removed.size} node${removed.size === 1 ? '' : 's'} removed, along with their connections.`);
|
|
250
|
+
}
|
|
251
|
+
}, [edit]);
|
|
252
|
+
const onEdgesChange = useCallback((changes) => {
|
|
253
|
+
for (const change of changes) {
|
|
254
|
+
if (change.type === 'select') {
|
|
255
|
+
setSelectedEdgeIds((current) => change.selected
|
|
256
|
+
? [...new Set([...current, change.id])]
|
|
257
|
+
: current.filter((id) => id !== change.id));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const removed = new Set(changes.filter((change) => change.type === 'remove').map((c) => c.id));
|
|
261
|
+
if (removed.size === 0)
|
|
262
|
+
return;
|
|
263
|
+
edit((current) => ({
|
|
264
|
+
...current,
|
|
265
|
+
edges: current.edges.filter((edge) => !removed.has(edgeId(edge))),
|
|
266
|
+
}));
|
|
267
|
+
setAnnouncement(`${removed.size} connection${removed.size === 1 ? '' : 's'} removed.`);
|
|
268
|
+
}, [edit]);
|
|
269
|
+
const disconnect = useCallback((edge) => {
|
|
270
|
+
const id = edgeId(edge);
|
|
271
|
+
edit((current) => ({
|
|
272
|
+
...current,
|
|
273
|
+
edges: current.edges.filter((candidate) => edgeId(candidate) !== id),
|
|
274
|
+
}));
|
|
275
|
+
setAnnouncement('Connection removed.');
|
|
276
|
+
}, [edit]);
|
|
277
|
+
const connect = useCallback((from, to) => {
|
|
278
|
+
const verdict = canConnect(draft.nodes, draft.edges, from, to);
|
|
279
|
+
if (!verdict.ok) {
|
|
280
|
+
setAnnouncement(verdict.reason);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const label = (id) => {
|
|
284
|
+
const node = draft.nodes.find((candidate) => candidate.id === id);
|
|
285
|
+
return node ? nodeName(node) : id;
|
|
286
|
+
};
|
|
287
|
+
// Appended rather than inserted anywhere else: a node with several inbound
|
|
288
|
+
// edges receives its inputs in the order the edges appear in this array,
|
|
289
|
+
// and that order is part of what the graph produces.
|
|
290
|
+
edit((current) => ({ ...current, edges: [...current.edges, { from, to }] }));
|
|
291
|
+
setAnnouncement(`${label(from)} now feeds ${label(to)}.`);
|
|
292
|
+
}, [draft.nodes, draft.edges, edit]);
|
|
293
|
+
const onConnect = useCallback((connection) => {
|
|
294
|
+
// Narrowed rather than trusted: React Flow types both ends as `string`
|
|
295
|
+
// but a connection dropped on empty canvas arrives with no target on
|
|
296
|
+
// some paths, and an edge with an empty id renders as a line to nowhere.
|
|
297
|
+
if (!connection.source || !connection.target)
|
|
298
|
+
return;
|
|
299
|
+
connect(connection.source, connection.target);
|
|
300
|
+
}, [connect]);
|
|
301
|
+
/**
|
|
302
|
+
* The while-drawing check.
|
|
303
|
+
*
|
|
304
|
+
* Boolean only, and asked on every pointer move, so it cannot be where the
|
|
305
|
+
* explanation lives — React Flow uses the answer to put a valid/invalid class
|
|
306
|
+
* on the handle under the cursor, which is what makes an illegal drop refuse
|
|
307
|
+
* itself visibly before the mouse is released. The sentence comes from
|
|
308
|
+
* `onConnectEnd`, below, using the same function.
|
|
309
|
+
*/
|
|
310
|
+
const isValidConnection = useCallback((candidate) => {
|
|
311
|
+
if (!candidate.source || !candidate.target)
|
|
312
|
+
return false;
|
|
313
|
+
return canConnect(draft.nodes, draft.edges, candidate.source, candidate.target).ok;
|
|
314
|
+
}, [draft.nodes, draft.edges]);
|
|
315
|
+
const save = useMutation({
|
|
316
|
+
mutationFn: () => client.saveWorkflow({
|
|
317
|
+
id: draft.id,
|
|
318
|
+
name: draft.name.trim(),
|
|
319
|
+
description: draft.description.trim() || undefined,
|
|
320
|
+
nodes: draft.nodes,
|
|
321
|
+
edges: draft.edges,
|
|
322
|
+
}),
|
|
323
|
+
onSuccess: (saved) => {
|
|
324
|
+
loadedRef.current = saved.id;
|
|
325
|
+
setSelected(saved.id);
|
|
326
|
+
setDraft(draftFrom(saved));
|
|
327
|
+
setAnnouncement(`Saved. This is now v${saved.version}.`);
|
|
328
|
+
queryClient.invalidateQueries({ queryKey: catalogQueryKeys.workflows });
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
const runIt = useMutation({
|
|
332
|
+
mutationFn: (id) => client.runWorkflow(id),
|
|
333
|
+
onSuccess: (result) => {
|
|
334
|
+
setRun(result);
|
|
335
|
+
// A run writes rows, so the catalog snapshot every other screen reads is
|
|
336
|
+
// now stale. Invalidating it here is what stops the object explorer
|
|
337
|
+
// showing yesterday's counts beside a run that just finished.
|
|
338
|
+
queryClient.invalidateQueries({ queryKey: catalogQueryKeys.snapshot });
|
|
339
|
+
queryClient.invalidateQueries({ queryKey: catalogQueryKeys.workflows });
|
|
340
|
+
setAnnouncement(result.status === 'succeeded'
|
|
341
|
+
? 'The run finished. Check each sink below for what it committed.'
|
|
342
|
+
: `The run ${result.status}. ${result.error ?? ''}`);
|
|
343
|
+
},
|
|
344
|
+
});
|
|
345
|
+
const remove = useMutation({
|
|
346
|
+
mutationFn: (id) => client.deleteWorkflow(id),
|
|
347
|
+
onSuccess: () => {
|
|
348
|
+
setConfirmingDelete(false);
|
|
349
|
+
loadedRef.current = null;
|
|
350
|
+
setSelected('');
|
|
351
|
+
queryClient.invalidateQueries({ queryKey: catalogQueryKeys.workflows });
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
const addNode = useCallback((kind) => {
|
|
355
|
+
const id = newLocalId(kind);
|
|
356
|
+
setDraft((current) => {
|
|
357
|
+
const position = nextPosition(current.nodes);
|
|
358
|
+
// Built per kind rather than as one shape with optional fields, because
|
|
359
|
+
// the executable model is a discriminated union: a source carries a source
|
|
360
|
+
// kind and a config, a transform carries a transform, a sink carries the
|
|
361
|
+
// type it commits, and nothing carries a field belonging to another kind.
|
|
362
|
+
const node = kind === 'source'
|
|
363
|
+
? {
|
|
364
|
+
id,
|
|
365
|
+
name: defaultLabel(kind),
|
|
366
|
+
kind: 'source',
|
|
367
|
+
sourceKind: 'http',
|
|
368
|
+
config: {},
|
|
369
|
+
position,
|
|
370
|
+
}
|
|
371
|
+
: kind === 'transform'
|
|
372
|
+
? {
|
|
373
|
+
id,
|
|
374
|
+
name: defaultLabel(kind),
|
|
375
|
+
kind: 'transform',
|
|
376
|
+
transformId: '',
|
|
377
|
+
position,
|
|
378
|
+
}
|
|
379
|
+
: {
|
|
380
|
+
id,
|
|
381
|
+
name: defaultLabel(kind),
|
|
382
|
+
kind: 'sink',
|
|
383
|
+
targetType: '',
|
|
384
|
+
position,
|
|
385
|
+
};
|
|
386
|
+
return { ...current, nodes: [...current.nodes, node], dirty: true };
|
|
387
|
+
});
|
|
388
|
+
setInspecting(id);
|
|
389
|
+
setAnnouncement(`A ${kind} node was added. Its inspector is open.`);
|
|
390
|
+
}, []);
|
|
391
|
+
const tidy = useCallback(() => {
|
|
392
|
+
edit((current) => ({
|
|
393
|
+
...current,
|
|
394
|
+
nodes: layout(current.nodes, current.edges),
|
|
395
|
+
}));
|
|
396
|
+
window.requestAnimationFrame(() => fitView({ padding: 0.25, duration: 200 }));
|
|
397
|
+
setAnnouncement('The nodes were laid out left to right by dependency, with every sink in the last column.');
|
|
398
|
+
}, [edit, fitView]);
|
|
399
|
+
const durability = describeDurability(capabilities?.durable);
|
|
400
|
+
const blocked = hasBlockingProblem(problems);
|
|
401
|
+
const inspectingNode = draft.nodes.find((node) => node.id === inspecting) ?? null;
|
|
402
|
+
const editingNode = draft.nodes.find((node) => node.id === editingCodeFor);
|
|
403
|
+
const editingTransform = editingNode?.kind === 'transform'
|
|
404
|
+
? transforms.find((transform) => transform.id === editingNode.transformId)
|
|
405
|
+
: undefined;
|
|
406
|
+
const typeOptions = useMemo(() => (snapshot?.types ?? []).map((type) => ({
|
|
407
|
+
value: type.name,
|
|
408
|
+
label: type.displayName,
|
|
409
|
+
hint: type.name,
|
|
410
|
+
})), [snapshot]);
|
|
411
|
+
const workflowOptions = useMemo(() => [
|
|
412
|
+
...(workflows.data ?? []).map((workflow) => ({
|
|
413
|
+
value: workflow.id,
|
|
414
|
+
label: workflow.name,
|
|
415
|
+
hint: `${workflow.nodes.length} nodes → ${producedTypes(workflow.nodes).join(', ') || 'nothing yet'}`,
|
|
416
|
+
})),
|
|
417
|
+
{ value: NEW_WORKFLOW, label: `New ${WORKFLOW_NAME.singular}` },
|
|
418
|
+
], [workflows.data]);
|
|
419
|
+
/**
|
|
420
|
+
* What this graph commits, read off the sinks.
|
|
421
|
+
*
|
|
422
|
+
* A summary and never a control. The type is set on the sink that commits it,
|
|
423
|
+
* because a graph may have several sinks writing several types and a single
|
|
424
|
+
* field at the top of the screen could only ever name one of them.
|
|
425
|
+
*/
|
|
426
|
+
const produces = producedTypes(draft.nodes);
|
|
427
|
+
return (
|
|
428
|
+
/*
|
|
429
|
+
* The screen lives inside the viewport: a header sized to its content and a
|
|
430
|
+
* canvas that takes whatever is left.
|
|
431
|
+
*
|
|
432
|
+
* `min-h-0` on both this column and the row below it is the load-bearing
|
|
433
|
+
* part. A flex child defaults to `min-height: auto`, which means "at least
|
|
434
|
+
* as tall as my content" and makes it refuse to shrink — so a canvas with a
|
|
435
|
+
* minimum height pushed itself past the bottom of a `main` that does not
|
|
436
|
+
* scroll, and there was no way to reach the lower half of it. Fit View could
|
|
437
|
+
* not save that: it fits the graph into a box, and half the box was off
|
|
438
|
+
* screen. See `QueryConsole` for the same pattern.
|
|
439
|
+
*/
|
|
440
|
+
_jsxs("div", { className: "flex h-full min-h-0 flex-col", children: [_jsxs("div", { className: "shrink-0 px-6 pt-5", children: [_jsxs("div", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1", children: [_jsx("p", { className: cn('font-mono text-[11px] uppercase tracking-[0.18em]', MUTED), children: eyebrow }), _jsx("h1", { className: "text-xl font-semibold tracking-tight", children: title }), produces.length > 0 && (_jsx(Tooltip, { content: `Read off the sinks. Each one commits its own type independently — a run that writes ${produces[0]} and fails on another is a failed run that committed ${produces[0]}, not a success.`, children: _jsxs("span", { className: cn('font-mono text-[10px]', MUTED), children: ["commits ", produces.join(', ')] }) }))] }), _jsx("p", { className: "mt-0.5 max-w-3xl text-xs text-zinc-500 dark:text-zinc-400", children: intro }), _jsx(DurabilityBanner, { durability: durability }), _jsxs("div", { className: "mt-2.5 grid gap-3 sm:grid-cols-2 lg:grid-cols-3", children: [_jsx(SelectField, { label: WORKFLOW_NAME.title, ariaLabel: `Which ${WORKFLOW_NAME.singular} to edit`, value: selected, onValueChange: (value) => {
|
|
441
|
+
loadedRef.current = null;
|
|
442
|
+
setSelected(value);
|
|
443
|
+
}, options: workflowOptions, disabled: workflows.isPending }), _jsx(TextField, { label: "Name", value: draft.name, onChange: (name) => edit((current) => ({ ...current, name })), placeholder: "Fleet readiness", disabled: !canEdit }), _jsxs("div", { className: "flex flex-wrap items-start gap-2 self-end pb-1", children: [_jsx(Tooltip, { content: blocked
|
|
444
|
+
? 'There are errors listed beside the canvas, and the server will almost certainly refuse this. Sending it anyway is allowed — the server decides, not this screen.'
|
|
445
|
+
: 'Store it. The server checks it again, and its answer is the one that counts.', children: _jsxs("button", { type: "button", onClick: () => save.mutate(), disabled: !canEdit ||
|
|
446
|
+
save.isPending ||
|
|
447
|
+
draft.name.trim().length === 0 ||
|
|
448
|
+
(!draft.dirty && Boolean(draft.id)), className: cn('flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs disabled:opacity-40', blocked
|
|
449
|
+
? 'bg-amber-600 text-white'
|
|
450
|
+
: 'bg-zinc-950 text-zinc-50 dark:bg-zinc-100 dark:text-zinc-950'), children: [save.isPending ? (_jsx(Loader2, { size: 12, className: "animate-spin" })) : (_jsx(Save, { size: 12 })), draft.dirty ? 'Save' : 'Saved'] }) }), _jsx(Tooltip, { content: draft.dirty
|
|
451
|
+
? 'Save first — a run executes the stored graph, not what is on screen.'
|
|
452
|
+
: durability.detail, children: _jsxs("button", { type: "button", onClick: () => draft.id && runIt.mutate(draft.id), disabled: !canEdit || !draft.id || draft.dirty || runIt.isPending, className: cn('flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs disabled:opacity-40', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [runIt.isPending ? (_jsx(Loader2, { size: 12, className: "animate-spin" })) : (_jsx(Play, { size: 12 })), "Run"] }) }), draft.id && canEdit && (_jsx(Tooltip, { content: `Delete this ${WORKFLOW_NAME.singular}.`, children: _jsx("button", { type: "button", onClick: () => setConfirmingDelete(true), "aria-label": `Delete this ${WORKFLOW_NAME.singular}`, className: cn('rounded-md border p-1.5 text-zinc-400 hover:text-red-600', RULE), children: _jsx(Trash2, { size: 12 }) }) }))] })] }), save.error && (_jsxs("p", { className: "mt-2 rounded-md border border-red-200 bg-red-50 px-3 py-1.5 text-[11px] text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300", children: ["The server refused it:", ' ', save.error instanceof Error ? save.error.message : 'no reason given.'] })), runIt.error && (_jsxs("p", { className: "mt-2 rounded-md border border-red-200 bg-red-50 px-3 py-1.5 text-[11px] text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300", children: ["The run could not start:", ' ', runIt.error instanceof Error ? runIt.error.message : 'no reason given.'] }))] }), canEdit && (_jsxs("div", { className: "flex shrink-0 flex-wrap items-center gap-2 px-6 pt-3", children: [_jsx(AddButton, { icon: Plug, label: "Source", hint: "Reads records out of a system: a kind, an optional named connection, and a config.", onClick: () => addNode('source') }), _jsx(AddButton, { icon: Repeat, label: "Transform", hint: "Code that reshapes whatever is wired into it.", onClick: () => addNode('transform') }), _jsx(AddButton, { icon: Database, label: "Sink", hint: "Writes and commits one object type. Several are fine \u2014 each commits independently.", onClick: () => addNode('sink') }), _jsx(Tooltip, { content: "Lay the nodes out left to right by dependency, with every sink in the last column.", children: _jsxs("button", { type: "button", onClick: tidy, className: cn('flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs', RULE, MUTED, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(LayoutGrid, { size: 12 }), "Tidy"] }) }), workflows.isFetching && !workflows.isPending && (
|
|
453
|
+
// A background refetch says so without replacing anything: the
|
|
454
|
+
// graph on screen stays exactly where it is.
|
|
455
|
+
_jsx("span", { className: cn('ml-auto font-mono text-[10px]', MUTED), children: "refreshing\u2026" }))] })), _jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-6 pb-5 pt-3 lg:flex-row lg:overflow-hidden", children: [_jsxs("div", { className: cn('relative h-[55vh] min-h-[15rem] shrink-0 overflow-hidden rounded-lg border', 'lg:h-auto lg:min-h-0 lg:flex-1 lg:shrink', RULE), children: [workflows.isPending && _jsx(CanvasSkeleton, {}), workflows.isError && (_jsx(CanvasFailure, { error: workflows.error, onRetry: () => workflows.refetch() })), !workflows.isPending && !workflows.isError && (_jsx(WorkflowNodeProvider, { handlers: {
|
|
456
|
+
onInspect: setInspecting,
|
|
457
|
+
onEditCode: setEditingCodeFor,
|
|
458
|
+
canEdit,
|
|
459
|
+
}, children: _jsxs(ReactFlow, { className: CANVAS_THEME, nodes: flowNodes, edges: flowEdges, nodeTypes: workflowNodeTypes, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, isValidConnection: isValidConnection, onConnectEnd: (_event, state) => {
|
|
460
|
+
// The reason, once, at the end of the drag — rather than on
|
|
461
|
+
// every pointer move, which would set state dozens of times a
|
|
462
|
+
// second while somebody is still deciding where to drop.
|
|
463
|
+
if (state.isValid !== false)
|
|
464
|
+
return;
|
|
465
|
+
const from = state.fromNode?.id;
|
|
466
|
+
const to = state.toNode?.id;
|
|
467
|
+
if (!from || !to)
|
|
468
|
+
return;
|
|
469
|
+
const verdict = canConnect(draft.nodes, draft.edges, from, to);
|
|
470
|
+
if (!verdict.ok)
|
|
471
|
+
setAnnouncement(verdict.reason);
|
|
472
|
+
}, connectionLineType: ConnectionLineType.SmoothStep, nodesDraggable: canEdit, nodesConnectable: canEdit, elementsSelectable: true, nodesFocusable: true, edgesFocusable: true, deleteKeyCode: canEdit ? ['Delete', 'Backspace'] : null,
|
|
473
|
+
// A wider drop zone than the 20px default, because these
|
|
474
|
+
// handles are the only drop target on the screen and missing
|
|
475
|
+
// one reads as the canvas ignoring you.
|
|
476
|
+
connectionRadius: 28, proOptions: { hideAttribution: false }, ariaLabelConfig: ARIA_LABELS, "aria-label": `${WORKFLOW_NAME.title} canvas. ${draft.nodes.length} nodes, ${draft.edges.length} connections.`, fitView: true, children: [_jsx(Background, { variant: BackgroundVariant.Dots, gap: 18, size: 1 }), _jsx(Controls, { showInteractive: false }), _jsx(MiniMap, { pannable: true, zoomable: true, nodeColor: (node) => {
|
|
477
|
+
// Narrowed rather than asserted: MiniMap types `data` as an
|
|
478
|
+
// open record, and a bad `kind` here would be a thrown
|
|
479
|
+
// error inside React Flow's own render rather than a
|
|
480
|
+
// mis-coloured dot.
|
|
481
|
+
const kind = node.data?.kind;
|
|
482
|
+
if (!isWorkflowNodeKind(kind))
|
|
483
|
+
return '#a1a1aa';
|
|
484
|
+
if (kind === 'source')
|
|
485
|
+
return '#0ea5e9';
|
|
486
|
+
if (kind === 'sink')
|
|
487
|
+
return '#10b981';
|
|
488
|
+
return '#8b5cf6';
|
|
489
|
+
} })] }) }))] }), _jsx(WiringRail, { draft: draft, problems: problems, run: run, canEdit: canEdit, onInspect: setInspecting, onDisconnect: disconnect })] }), _jsx("output", { "aria-live": "polite", className: "sr-only", children: announcement }), _jsx(NodeInspector, { node: inspectingNode, draft: draft, transforms: transforms, connections: connections, typeOptions: typeOptions, canEdit: canEdit, problems: inspectingNode ? (problemsFor.get(inspectingNode.id) ?? []) : [], onClose: () => setInspecting(null), onChange: (next) => edit((current) => ({
|
|
490
|
+
...current,
|
|
491
|
+
nodes: current.nodes.map((node) => (node.id === next.id ? next : node)),
|
|
492
|
+
})), onConnect: connect, onDisconnect: disconnect, onDelete: (nodeId) => {
|
|
493
|
+
edit((current) => ({
|
|
494
|
+
...current,
|
|
495
|
+
nodes: current.nodes.filter((node) => node.id !== nodeId),
|
|
496
|
+
edges: current.edges.filter((edge) => edge.from !== nodeId && edge.to !== nodeId),
|
|
497
|
+
}));
|
|
498
|
+
setInspecting(null);
|
|
499
|
+
setAnnouncement('Node removed, along with its connections.');
|
|
500
|
+
}, onEditCode: (nodeId) => setEditingCodeFor(nodeId) }), _jsx(Sheet, { open: editingCodeFor !== null, onOpenChange: (open) => {
|
|
501
|
+
if (!open)
|
|
502
|
+
setEditingCodeFor(null);
|
|
503
|
+
}, width: "wide", title: editingTransform ? editingTransform.name : 'Transform', description: "The canvas behind this is still exactly as you left it.", children: editingTransform ? (_jsx(TransformEditor, { transform: editingTransform, languages: capabilities?.languages ?? ['javascript'], pythonPackages: capabilities?.pythonPackages ?? [], onClose: () => setEditingCodeFor(null), onSaved: () => {
|
|
504
|
+
setEditingCodeFor(null);
|
|
505
|
+
queryClient.invalidateQueries({
|
|
506
|
+
queryKey: catalogQueryKeys.transforms,
|
|
507
|
+
});
|
|
508
|
+
} })) : (_jsx("p", { className: cn('py-8 text-center text-xs', MUTED), children: "This node does not name a transform yet. Choose one in the inspector first \u2014 there is no code to open until it does." })) }), _jsx(ConfirmDialog, { open: confirmingDelete, onOpenChange: setConfirmingDelete, title: `Delete "${draft.name || WORKFLOW_NAME.singular}"?`, description: `The graph goes with it. The transforms and connections it wired together are not touched — they are shared, and other ${WORKFLOW_NAME.plural} may use them.`, confirmLabel: "Delete", pending: remove.isPending, error: remove.error instanceof Error ? remove.error.message : undefined, onConfirm: () => draft.id && remove.mutate(draft.id) })] }));
|
|
509
|
+
}
|
|
510
|
+
function AddButton({ icon: Icon, label, hint, onClick, }) {
|
|
511
|
+
return (_jsx(Tooltip, { content: hint, children: _jsxs("button", { type: "button", onClick: onClick, className: cn('flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Plus, { size: 11 }), _jsx(Icon, { size: 12 }), label] }) }));
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Whether a failed run resumes or restarts, stated on the screen that implies
|
|
515
|
+
* it.
|
|
516
|
+
*
|
|
517
|
+
* Not a tooltip and not a footnote. A canvas of discrete boxes looks like a
|
|
518
|
+
* checkpointed pipeline whether or not one exists, and somebody who builds a
|
|
519
|
+
* ten-node graph on that assumption finds out only when node seven fails at
|
|
520
|
+
* three in the morning. Kept to one line so it costs the canvas as little
|
|
521
|
+
* height as a fact this important can be said in.
|
|
522
|
+
*/
|
|
523
|
+
function DurabilityBanner({ durability, }) {
|
|
524
|
+
const tone = durability.state === 'durable'
|
|
525
|
+
? 'border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300'
|
|
526
|
+
: durability.state === 'inline'
|
|
527
|
+
? 'border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-300'
|
|
528
|
+
: 'border-zinc-200 bg-zinc-50 text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400';
|
|
529
|
+
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', tone), children: [_jsx("p", { className: "font-mono text-[10px] uppercase tracking-[0.14em]", children: durability.label }), _jsx("p", { className: "text-[11px] leading-relaxed", children: durability.detail })] }));
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* A skeleton, never an empty canvas.
|
|
533
|
+
*
|
|
534
|
+
* An empty canvas is a real state — a workflow with no nodes looks exactly like
|
|
535
|
+
* this — so rendering one while the list is still in flight tells somebody
|
|
536
|
+
* their graph is gone.
|
|
537
|
+
*/
|
|
538
|
+
function CanvasSkeleton() {
|
|
539
|
+
return (_jsx("div", { className: "flex h-full w-full items-center justify-center bg-zinc-50 dark:bg-zinc-950", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "h-16 w-48 animate-pulse rounded-lg bg-zinc-200 dark:bg-zinc-800" }), _jsx(ArrowRight, { size: 14, className: MUTED }), _jsx("div", { className: "h-16 w-48 animate-pulse rounded-lg bg-zinc-200 dark:bg-zinc-800" }), _jsx(ArrowRight, { size: 14, className: MUTED }), _jsx("div", { className: "h-16 w-48 animate-pulse rounded-lg bg-zinc-200 dark:bg-zinc-800" })] }) }));
|
|
540
|
+
}
|
|
541
|
+
function CanvasFailure({ error, onRetry, }) {
|
|
542
|
+
return (_jsx("div", { className: "flex h-full w-full items-center justify-center bg-red-50 px-6 dark:bg-red-950/30", children: _jsxs("div", { className: "max-w-md text-center", children: [_jsx(CircleAlert, { size: 18, className: "mx-auto text-red-600" }), _jsxs("p", { className: "mt-2 text-sm text-red-700 dark:text-red-300", children: ["The ", WORKFLOW_NAME.plural, " could not be read, so nothing below is drawn. This is not an empty ", WORKFLOW_NAME.singular, "."] }), _jsx("p", { className: "mt-1 font-mono text-[11px] text-red-600 dark:text-red-400", children: error instanceof Error ? error.message : 'No reason was given.' }), _jsx("button", { type: "button", onClick: onRetry, className: "mt-3 rounded-md border border-red-300 px-3 py-1 text-xs text-red-700 dark:border-red-800 dark:text-red-300", children: "Try again" })] }) }));
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* The graph as a list, beside the graph as a picture.
|
|
546
|
+
*
|
|
547
|
+
* Not a convenience. React Flow makes nodes focusable and movable from the
|
|
548
|
+
* keyboard, but there is no keyboard gesture for drawing an edge — dragging
|
|
549
|
+
* from one handle to another is a pointer interaction and nothing else. Without
|
|
550
|
+
* a linear, operable representation of the wiring, this screen would be
|
|
551
|
+
* buildable only with a mouse, and readable only by somebody who can see it.
|
|
552
|
+
*
|
|
553
|
+
* The problems list sits in the same rail for the same reason: a red ring
|
|
554
|
+
* around a node off the left edge of the viewport communicates nothing.
|
|
555
|
+
*/
|
|
556
|
+
function WiringRail({ draft, problems, run, canEdit, onInspect, onDisconnect, }) {
|
|
557
|
+
const label = (id) => {
|
|
558
|
+
const node = draft.nodes.find((n) => n.id === id);
|
|
559
|
+
return node ? nodeName(node) : id;
|
|
560
|
+
};
|
|
561
|
+
const errors = problems.filter((problem) => problem.level === 'error');
|
|
562
|
+
const warnings = problems.filter((problem) => problem.level === 'warning');
|
|
563
|
+
const sinks = draft.nodes.filter((node) => node.kind === 'sink');
|
|
564
|
+
return (_jsxs("aside", { className: "flex w-full shrink-0 flex-col gap-3 lg:w-72 lg:min-h-0 lg:overflow-y-auto", "aria-label": `${WORKFLOW_NAME.title} wiring and problems`, children: [_jsxs("section", { className: cn('rounded-lg border p-3', RULE, PANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Wiring" }), draft.edges.length === 0 ? (_jsx("p", { className: cn('mt-2 text-[11px]', MUTED), children: "Nothing is wired together yet." })) : (_jsx("ul", { className: "mt-2 space-y-1", children: draft.edges.map((edge) => (_jsxs("li", { className: "flex items-center gap-1.5 text-[11px]", children: [_jsx("button", { type: "button", onClick: () => onInspect(edge.from), className: "truncate hover:underline", children: label(edge.from) }), _jsx(ArrowRight, { size: 10, className: cn('shrink-0', MUTED) }), _jsx("button", { type: "button", onClick: () => onInspect(edge.to), className: "truncate hover:underline", children: label(edge.to) }), canEdit && (_jsx(Tooltip, { content: "Remove this connection.", children: _jsx("button", { type: "button", onClick: () => onDisconnect(edge), "aria-label": `Disconnect ${label(edge.from)} from ${label(edge.to)}`, className: "ml-auto shrink-0 rounded p-0.5 text-zinc-400 hover:text-red-600", children: _jsx(Unplug, { size: 11 }) }) }))] }, edgeId(edge)))) }))] }), _jsxs("section", { className: cn('rounded-lg border p-3', RULE, PANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Problems" }), problems.length === 0 ? (_jsx("p", { className: cn('mt-2 text-[11px]', MUTED), children: "Nothing to flag here. The server checks it again on save." })) : (_jsx("ul", { className: "mt-2 space-y-2", children: [...errors, ...warnings].map((problem) => (_jsxs("li", { className: "flex gap-1.5 text-[11px] leading-relaxed", children: [problem.level === 'error' ? (_jsx(CircleAlert, { size: 11, className: "mt-0.5 shrink-0 text-red-500" })) : (_jsx(TriangleAlert, { size: 11, className: "mt-0.5 shrink-0 text-amber-500" })), _jsxs("span", { children: [problem.message, problem.nodeIds.length > 0 && (_jsx("span", { className: "ml-1", children: problem.nodeIds.map((nodeId) => (_jsx("button", { type: "button", onClick: () => onInspect(nodeId), className: cn('mr-1 rounded border px-1 font-mono text-[9px]', RULE, MUTED), children: label(nodeId) }, nodeId))) }))] })] }, `${problem.code}:${problem.nodeIds.join(',')}`))) }))] }), run && (_jsxs("section", { className: cn('rounded-lg border p-3', RULE, PANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Last run" }), _jsxs("p", { className: "mt-1 text-[11px]", children: [run.status, _jsx("span", { className: cn('ml-1 font-mono text-[10px]', MUTED), children: run.durable ? 'checkpointed per node' : 'ran inline, no checkpoints' })] }), sinks.length > 0 && (_jsxs("div", { className: "mt-2", children: [_jsx("h3", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Committed" }), _jsx("ul", { className: "mt-1 space-y-1", children: sinks.map((sink) => {
|
|
565
|
+
const outcome = run.nodes.find((node) => node.nodeId === sink.id);
|
|
566
|
+
const type = sink.kind === 'sink' && sink.targetType ? sink.targetType : 'no type';
|
|
567
|
+
return (_jsxs("li", { className: "flex items-center gap-1.5 text-[11px]", children: [_jsx("span", { className: "truncate font-mono text-[10px]", children: type }), _jsx("span", { className: cn('ml-auto shrink-0 font-mono text-[10px]', outcome?.status === 'failed'
|
|
568
|
+
? 'text-red-500'
|
|
569
|
+
: outcome?.status === 'succeeded'
|
|
570
|
+
? 'text-emerald-600 dark:text-emerald-400'
|
|
571
|
+
: MUTED), children: outcome
|
|
572
|
+
? outcome.status === 'succeeded' && typeof outcome.rows === 'number'
|
|
573
|
+
? `${outcome.rows} rows`
|
|
574
|
+
: outcome.status
|
|
575
|
+
: 'no outcome recorded' })] }, sink.id));
|
|
576
|
+
}) }), _jsx("p", { className: cn('mt-1 text-[10px] leading-relaxed', MUTED), children: "Each sink commits on its own. One committing and another failing is a failed run that nevertheless wrote something, not a partial success that will be rolled back." })] })), _jsx("ul", { className: "mt-2 space-y-1", children: run.nodes.map((node) => (_jsxs("li", { className: "flex items-center gap-1.5 font-mono text-[10px]", children: [_jsx("span", { className: "truncate", children: label(node.nodeId) }), _jsx("span", { className: cn('ml-auto shrink-0', node.status === 'failed' ? 'text-red-500' : MUTED), children: node.replayed ? 'replayed' : node.status })] }, node.nodeId))) }), run.error && _jsx("p", { className: "mt-2 text-[11px] text-red-600", children: run.error })] }))] }));
|
|
577
|
+
}
|
|
578
|
+
function NodeInspector({ node, draft, transforms, connections, typeOptions, canEdit, problems, onClose, onChange, onConnect, onDisconnect, onDelete, onEditCode, }) {
|
|
579
|
+
const [pendingTarget, setPendingTarget] = useState('');
|
|
580
|
+
const label = (id) => {
|
|
581
|
+
const found = draft.nodes.find((n) => n.id === id);
|
|
582
|
+
return found ? nodeName(found) : id;
|
|
583
|
+
};
|
|
584
|
+
const outgoing = node ? draft.edges.filter((edge) => edge.from === node.id) : [];
|
|
585
|
+
const incoming = node ? draft.edges.filter((edge) => edge.to === node.id) : [];
|
|
586
|
+
/**
|
|
587
|
+
* The keyboard path to wiring.
|
|
588
|
+
*
|
|
589
|
+
* React Flow has no keyboard gesture for drawing an edge — a connection is a
|
|
590
|
+
* drag from one handle to another and nothing else — so without this control
|
|
591
|
+
* the screen would be operable with a mouse only. The eligible list is
|
|
592
|
+
* filtered by the same `canConnect` the drag uses, so a target that would
|
|
593
|
+
* close a loop is simply not offered rather than offered and then refused.
|
|
594
|
+
*/
|
|
595
|
+
const eligible = useMemo(() => {
|
|
596
|
+
if (!node)
|
|
597
|
+
return [];
|
|
598
|
+
return draft.nodes
|
|
599
|
+
.filter((candidate) => canConnect(draft.nodes, draft.edges, node.id, candidate.id).ok)
|
|
600
|
+
.map((candidate) => ({
|
|
601
|
+
value: candidate.id,
|
|
602
|
+
label: nodeName(candidate),
|
|
603
|
+
hint: candidate.kind,
|
|
604
|
+
}));
|
|
605
|
+
}, [node, draft.nodes, draft.edges]);
|
|
606
|
+
return (_jsx(Sheet, { open: node !== null, onOpenChange: (open) => {
|
|
607
|
+
if (!open)
|
|
608
|
+
onClose();
|
|
609
|
+
}, title: node ? nodeName(node) : '', description: node ? `${node.kind} node` : undefined, children: node && (_jsxs("div", { className: "space-y-4", children: [problems.length > 0 && (_jsx("ul", { className: "space-y-1.5 rounded-md border border-red-200 bg-red-50 p-2 dark:border-red-900 dark:bg-red-950/40", children: problems.map((problem) => (_jsx("li", { className: "text-[11px] leading-relaxed text-red-700 dark:text-red-300", children: problem.message }, problem.code))) })), _jsx(TextField, { label: "Name", value: node.name, onChange: (name) => onChange({ ...node, name }), placeholder: node.kind, disabled: !canEdit, hint: "What it is called on the canvas and in the wiring list. Renaming it does not change what the graph does, so it does not bump the version." }), node.kind === 'transform' && (_jsxs("div", { className: "space-y-2", children: [_jsx(SelectField, { label: "Transform", ariaLabel: "Which transform runs at this node", value: node.transformId, onValueChange: (transformId) => onChange({ ...node, transformId }), options: transforms.map((transform) => ({
|
|
610
|
+
value: transform.id,
|
|
611
|
+
label: transform.name,
|
|
612
|
+
hint: `${transform.language} · v${transform.version}`,
|
|
613
|
+
})), placeholder: "Choose a transform\u2026", disabled: !canEdit }), _jsxs("button", { type: "button", onClick: () => onEditCode(node.id), disabled: node.transformId.length === 0, className: cn('flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs disabled:opacity-40', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Code2, { size: 12 }), "Open the code"] })] })), node.kind === 'source' && (_jsx(SourceInspector
|
|
614
|
+
// Keyed so the text fields reset when a different source is
|
|
615
|
+
// opened. Without it the draft state would survive the swap and
|
|
616
|
+
// one node's URL would appear inside another.
|
|
617
|
+
, { node: node, connections: connections, canEdit: canEdit, onChange: onChange }, node.id)), node.kind === 'sink' && (_jsxs("div", { className: "space-y-3", children: [_jsx(SelectField, { label: "Commits", ariaLabel: "Which object type this sink writes", value: node.targetType, onValueChange: (targetType) => onChange({ ...node, targetType }), options: typeOptions, placeholder: "Choose one type\u2026", disabled: !canEdit, hint: "The type is set here, on the node that commits it, rather than once for the whole graph \u2014 several sinks may write several types." }), _jsx(SelectField, { label: "Commit mode", ariaLabel: "Whether this sink replaces the dataset or merges into it", value: node.mode ?? 'full', onValueChange: (mode) => onChange({
|
|
618
|
+
...node,
|
|
619
|
+
mode: mode === 'incremental' ? 'incremental' : 'full',
|
|
620
|
+
}), options: [
|
|
621
|
+
{ value: 'full', label: 'Full — replace the dataset' },
|
|
622
|
+
{ value: 'incremental', label: 'Incremental — merge into it' },
|
|
623
|
+
], disabled: !canEdit }), _jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["This sink commits ", node.targetType || 'its type', " on its own. Another sink in the same graph committing a different type is a separate commit \u2014 one can succeed while this one fails, and the run is reported as failed when any of them does."] })] })), _jsxs("section", { children: [_jsx("h3", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Fed by" }), incoming.length === 0 ? (_jsx("p", { className: cn('mt-1 text-[11px]', MUTED), children: "Nothing yet." })) : (_jsx("ul", { className: "mt-1 space-y-1", children: incoming.map((edge) => (_jsxs("li", { className: "flex items-center gap-1.5 text-[11px]", children: [_jsx("span", { className: "truncate", children: label(edge.from) }), canEdit && (_jsx(Tooltip, { content: "Remove this connection.", children: _jsx("button", { type: "button", onClick: () => onDisconnect(edge), "aria-label": `Stop ${label(edge.from)} feeding this node`, className: "ml-auto rounded p-0.5 text-zinc-400 hover:text-red-600", children: _jsx(Unplug, { size: 11 }) }) }))] }, edgeId(edge)))) })), incoming.length > 1 && (_jsx("p", { className: cn('mt-1 text-[11px] leading-relaxed', MUTED), children: "Inputs arrive in this order, and the order is part of what the graph produces \u2014 a transform joining two feeds sees them exactly like this." }))] }), _jsxs("section", { children: [_jsx("h3", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Feeds" }), outgoing.length === 0 ? (_jsx("p", { className: cn('mt-1 text-[11px]', MUTED), children: "Nothing yet." })) : (_jsx("ul", { className: "mt-1 space-y-1", children: outgoing.map((edge) => (_jsxs("li", { className: "flex items-center gap-1.5 text-[11px]", children: [_jsx("span", { className: "truncate", children: label(edge.to) }), canEdit && (_jsx(Tooltip, { content: "Remove this connection.", children: _jsx("button", { type: "button", onClick: () => onDisconnect(edge), "aria-label": `Stop this node feeding ${label(edge.to)}`, className: "ml-auto rounded p-0.5 text-zinc-400 hover:text-red-600", children: _jsx(Unplug, { size: 11 }) }) }))] }, edgeId(edge)))) })), canEdit && (_jsxs("div", { className: "mt-2 flex items-end gap-2", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(Select, { ariaLabel: "Send this node's output to", value: pendingTarget, onValueChange: setPendingTarget, options: eligible, placeholder: eligible.length === 0
|
|
624
|
+
? 'Nothing can be wired from here'
|
|
625
|
+
: 'Send its output to…', disabled: eligible.length === 0 }) }), _jsx("button", { type: "button", onClick: () => {
|
|
626
|
+
if (!pendingTarget)
|
|
627
|
+
return;
|
|
628
|
+
onConnect(node.id, pendingTarget);
|
|
629
|
+
setPendingTarget('');
|
|
630
|
+
}, disabled: !pendingTarget, className: cn('shrink-0 rounded-md border px-2.5 py-1.5 text-xs disabled:opacity-40', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: "Connect" })] })), _jsx("p", { className: cn('mt-1 text-[11px] leading-relaxed', MUTED), children: "Only nodes that can legally take this one's output are listed \u2014 anything that would close a loop, or feed a source, is left out." })] }), canEdit && (_jsxs("button", { type: "button", onClick: () => onDelete(node.id), className: "flex items-center gap-1.5 rounded-md border border-red-200 px-2.5 py-1.5 text-xs text-red-600 hover:bg-red-50 dark:border-red-900 dark:hover:bg-red-950/40", children: [_jsx(Trash2, { size: 12 }), "Remove this node"] }))] })) }));
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Where a source reads from.
|
|
634
|
+
*
|
|
635
|
+
* The same fields the connector form uses, from the same module, because a
|
|
636
|
+
* source node and a connector are the same half of the same idea and the
|
|
637
|
+
* executable model gives them the same vocabulary: a kind, an optional named
|
|
638
|
+
* connection, a config, the name of an env var holding the credential, and
|
|
639
|
+
* whether it reads everything or only what changed.
|
|
640
|
+
*
|
|
641
|
+
* There is deliberately no "which connector feeds this" picker. A connector
|
|
642
|
+
* references a *workflow*, so a source referencing a connector would be
|
|
643
|
+
* circular — and it would leave one load with two authorities on where its data
|
|
644
|
+
* comes from.
|
|
645
|
+
*
|
|
646
|
+
* The text fields are held locally and pushed up as a config on every change,
|
|
647
|
+
* rather than read back out of the node. Re-deriving them from the stored config
|
|
648
|
+
* would make a half-typed number disappear the moment it stopped parsing.
|
|
649
|
+
*/
|
|
650
|
+
function SourceInspector({ node, connections, canEdit, onChange, }) {
|
|
651
|
+
const [source, setSource] = useState(() => sourceDraftFrom(node.config));
|
|
652
|
+
const kind = toConnectorKind(node.sourceKind ?? 'http');
|
|
653
|
+
const options = connectionOptions(kind, connections);
|
|
654
|
+
// A connection chosen for one kind is meaningless for another, so switching
|
|
655
|
+
// the kind drops it rather than keeping an id the server would reject.
|
|
656
|
+
const chosen = options.some((option) => option.value === node.connectionId)
|
|
657
|
+
? (node.connectionId ?? INLINE_CONNECTION)
|
|
658
|
+
: INLINE_CONNECTION;
|
|
659
|
+
const viaConnection = chosen !== INLINE_CONNECTION;
|
|
660
|
+
const mode = node.mode === 'incremental' ? 'incremental' : 'full';
|
|
661
|
+
const incremental = readsIncrementally(kind) && mode === 'incremental';
|
|
662
|
+
/** One place that turns the text fields back into a stored config. */
|
|
663
|
+
const push = (next, over = {}) => {
|
|
664
|
+
const merged = { ...node, ...over };
|
|
665
|
+
const mergedKind = toConnectorKind(merged.sourceKind ?? 'http');
|
|
666
|
+
const mergedVia = Boolean(merged.connectionId);
|
|
667
|
+
onChange({
|
|
668
|
+
...merged,
|
|
669
|
+
config: sourceConfigFrom(mergedKind, next, {
|
|
670
|
+
viaConnection: mergedVia,
|
|
671
|
+
incremental: readsIncrementally(mergedKind) && merged.mode === 'incremental',
|
|
672
|
+
}),
|
|
673
|
+
});
|
|
674
|
+
};
|
|
675
|
+
const update = (next) => {
|
|
676
|
+
setSource(next);
|
|
677
|
+
push(next);
|
|
678
|
+
};
|
|
679
|
+
return (_jsxs("div", { className: "space-y-3", children: [_jsx(SelectField, { label: "Source kind", ariaLabel: "What kind of system this reads from", value: kind, onValueChange: (value) => {
|
|
680
|
+
const sourceKind = toConnectorKind(value);
|
|
681
|
+
// The connection goes with the kind it belonged to. Keeping it would
|
|
682
|
+
// point an S3 source at a SQL address.
|
|
683
|
+
push(source, { sourceKind, connectionId: undefined });
|
|
684
|
+
}, options: KIND_OPTIONS, disabled: !canEdit }), usesConnection(kind) && (_jsx(SelectField, { label: "Read through", ariaLabel: "Connection", value: chosen, onValueChange: (value) => push(source, {
|
|
685
|
+
// Omitted, never sent empty: an empty string is a connection id
|
|
686
|
+
// the server would look up and fail to find, where absent means
|
|
687
|
+
// "this source carries its own address".
|
|
688
|
+
connectionId: value === INLINE_CONNECTION ? undefined : value,
|
|
689
|
+
}), options: [
|
|
690
|
+
{
|
|
691
|
+
value: INLINE_CONNECTION,
|
|
692
|
+
label: 'Configure the address here',
|
|
693
|
+
hint: 'This source alone',
|
|
694
|
+
},
|
|
695
|
+
...options,
|
|
696
|
+
], disabled: !canEdit, hint: options.length === 0
|
|
697
|
+
? 'No connections of this kind yet. One is worth making when a second source needs the same address.'
|
|
698
|
+
: viaConnection
|
|
699
|
+
? 'The connection supplies the address and the credential. What stays below is only what is specific to this load.'
|
|
700
|
+
: undefined })), _jsx(SourceFields, { kind: kind, draft: source, onChange: update, viaConnection: viaConnection, disabled: !canEdit }), _jsx(ReadModeFields, { kind: kind, mode: mode, onModeChange: (next) => push(source, { mode: next }), draft: source, onChange: update, disabled: !canEdit }), !viaConnection && (_jsx(CredentialField, { kind: kind, value: node.secretEnvVar ?? '', onChange: (value) => push(source, { secretEnvVar: value.trim() ? value : undefined }), disabled: !canEdit })), incremental && (_jsx("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: "A watermark is kept per node, so two sources in the same graph reading incrementally do not overwrite each other's position." }))] }));
|
|
701
|
+
}
|