@dudousxd/nestjs-catalog-react 0.4.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CatalogManager.js +86 -9
- package/dist/ConnectionPanel.js +131 -34
- package/dist/DashboardBoard.js +49 -7
- package/dist/FlowView.js +35 -26
- package/dist/ObjectExplorer.js +15 -8
- package/dist/PipelineConsole.js +68 -34
- package/dist/QueryConsole.js +36 -43
- package/dist/TransformEditor.d.ts +0 -9
- package/dist/TransformEditor.js +24 -11
- package/dist/WorkflowCanvas.js +221 -128
- package/dist/charts/bklit/area.js +0 -1
- package/dist/charts/bklit/bar-chart.js +0 -1
- package/dist/charts/bklit/grid.js +0 -1
- package/dist/charts/bklit/line-loading-pulse.js +0 -1
- package/dist/charts/bklit/tooltip/chart-tooltip.js +0 -1
- package/dist/charts/bklit/tooltip/tooltip-indicator.js +0 -1
- package/dist/charts/bklit/use-chart-phase-orchestrator.js +0 -2
- package/dist/charts/bklit/use-mount-progress.js +0 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/source-fields.js +61 -42
- package/dist/ui/chart.js +35 -16
- package/dist/ui/code-editor.d.ts +17 -0
- package/dist/ui/code-editor.js +81 -0
- package/dist/ui/data-table.d.ts +92 -0
- package/dist/ui/data-table.js +101 -0
- package/dist/ui/rich-text-field.d.ts +21 -0
- package/dist/ui/rich-text-field.js +133 -0
- package/dist/ui/select.d.ts +10 -1
- package/dist/ui/select.js +8 -2
- package/dist/ui/switch.js +7 -1
- package/dist/workflow/graph.js +51 -35
- package/package.json +15 -3
package/dist/WorkflowCanvas.js
CHANGED
|
@@ -98,7 +98,161 @@ function draftFrom(workflow) {
|
|
|
98
98
|
export function WorkflowCanvas(props) {
|
|
99
99
|
return (_jsx(TooltipProvider, { children: _jsx(ReactFlowProvider, { children: _jsx(Canvas, { ...props }) }) }));
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
/**
|
|
102
|
+
* The selection after a batch of React Flow `select` changes.
|
|
103
|
+
*
|
|
104
|
+
* React Flow reports selection one id at a time, and both nodes and edges use
|
|
105
|
+
* the same shape for it, so folding the batch here keeps one description of what
|
|
106
|
+
* selecting means. Returns the array it was given when nothing selected,
|
|
107
|
+
* so an unrelated batch of changes does not re-render the canvas.
|
|
108
|
+
*/
|
|
109
|
+
function nextSelection(current, changes) {
|
|
110
|
+
let next = current;
|
|
111
|
+
for (const change of changes) {
|
|
112
|
+
if (change.type !== 'select')
|
|
113
|
+
continue;
|
|
114
|
+
next = change.selected
|
|
115
|
+
? [...new Set([...next, change.id])]
|
|
116
|
+
: next.filter((id) => id !== change.id);
|
|
117
|
+
}
|
|
118
|
+
return next;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A fresh node of one kind, carrying only the fields that kind has.
|
|
122
|
+
*
|
|
123
|
+
* Built per kind rather than as one shape with optional fields, because the
|
|
124
|
+
* executable model is a discriminated union: a source carries a source kind and
|
|
125
|
+
* a config, a transform carries a transform, a sink carries the type it commits,
|
|
126
|
+
* and nothing carries a field belonging to another kind.
|
|
127
|
+
*/
|
|
128
|
+
function newNodeOfKind(kind, id, position) {
|
|
129
|
+
const name = defaultLabel(kind);
|
|
130
|
+
if (kind === 'source') {
|
|
131
|
+
return { id, name, kind: 'source', sourceKind: 'http', config: {}, position };
|
|
132
|
+
}
|
|
133
|
+
if (kind === 'transform') {
|
|
134
|
+
return { id, name, kind: 'transform', transformId: '', position };
|
|
135
|
+
}
|
|
136
|
+
return { id, name, kind: 'sink', targetType: '', position };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A server refusal, verbatim.
|
|
140
|
+
*
|
|
141
|
+
* The server knows things this canvas does not — which types exist, who may
|
|
142
|
+
* write to them, whether a transform's output fits the sink — so its wording is
|
|
143
|
+
* the useful one, not a generic "could not save".
|
|
144
|
+
*/
|
|
145
|
+
function RefusalNote({ lead, error }) {
|
|
146
|
+
return (_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: [lead, " ", error instanceof Error ? error.message : 'no reason given.'] }));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Save, run, delete.
|
|
150
|
+
*
|
|
151
|
+
* Save is deliberately **not** disabled when the local checks fail. Disabling
|
|
152
|
+
* would make this screen the gate, and the checks beside the canvas cannot see
|
|
153
|
+
* everything the server sees — a rule that is subtly wrong here would become a
|
|
154
|
+
* graph nobody can save at all, with no error to read. The button is coloured to
|
|
155
|
+
* warn and the tooltip says what will happen; the refusal, when it comes, comes
|
|
156
|
+
* from the server with its reasons.
|
|
157
|
+
*/
|
|
158
|
+
function CanvasActions({ draft, canEdit, blocked, saving, running, durabilityDetail, onSave, onRun, onAskDelete, }) {
|
|
159
|
+
return (_jsxs("div", { className: "flex flex-wrap items-start gap-2 self-end pb-1", children: [_jsx(Tooltip, { content: blocked
|
|
160
|
+
? '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.'
|
|
161
|
+
: 'Store it. The server checks it again, and its answer is the one that counts.', children: _jsxs("button", { type: "button", onClick: onSave, disabled: !canEdit ||
|
|
162
|
+
saving ||
|
|
163
|
+
draft.name.trim().length === 0 ||
|
|
164
|
+
(!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
|
|
165
|
+
? 'bg-amber-600 text-white'
|
|
166
|
+
: 'bg-zinc-950 text-zinc-50 dark:bg-zinc-100 dark:text-zinc-950'), children: [saving ? _jsx(Loader2, { size: 12, className: "animate-spin" }) : _jsx(Save, { size: 12 }), draft.dirty ? 'Save' : 'Saved'] }) }), _jsx(Tooltip, { content: draft.dirty
|
|
167
|
+
? 'Save first — a run executes the stored graph, not what is on screen.'
|
|
168
|
+
: durabilityDetail, children: _jsxs("button", { type: "button", onClick: onRun, disabled: !canEdit || !draft.id || draft.dirty || running, 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: [running ? _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: onAskDelete, "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 }) }) }))] }));
|
|
169
|
+
}
|
|
170
|
+
/** The three things that can be put on the canvas, and the button that tidies them. */
|
|
171
|
+
function AddNodeBar({ refreshing, onAdd, onTidy, }) {
|
|
172
|
+
return (_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: () => onAdd('source') }), _jsx(AddButton, { icon: Repeat, label: "Transform", hint: "Code that reshapes whatever is wired into it.", onClick: () => onAdd('transform') }), _jsx(AddButton, { icon: Database, label: "Sink", hint: "Writes and commits one object type. Several are fine \u2014 each commits independently.", onClick: () => onAdd('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: onTidy, 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"] }) }), refreshing && (
|
|
173
|
+
// A background refetch says so without replacing anything: the graph on
|
|
174
|
+
// screen stays exactly where it is.
|
|
175
|
+
_jsx("span", { className: cn('ml-auto font-mono text-[10px]', MUTED), children: "refreshing\u2026" }))] }));
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Which workflow the screen should be showing.
|
|
179
|
+
*
|
|
180
|
+
* Falls through to the first stored one so an empty picker opens on something
|
|
181
|
+
* rather than on a blank canvas, and to the new-workflow sentinel when there is
|
|
182
|
+
* nothing stored at all.
|
|
183
|
+
*/
|
|
184
|
+
function wantedWorkflowId(list, selected) {
|
|
185
|
+
return selected || list[0]?.id || NEW_WORKFLOW;
|
|
186
|
+
}
|
|
187
|
+
/** The draft for a chosen id: the stored graph, or a blank one if there is none. */
|
|
188
|
+
function draftForId(list, wanted) {
|
|
189
|
+
if (wanted === NEW_WORKFLOW)
|
|
190
|
+
return blankDraft();
|
|
191
|
+
const found = list.find((workflow) => workflow.id === wanted);
|
|
192
|
+
return found ? draftFrom(found) : blankDraft();
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The minimap dot colour for a node, by kind.
|
|
196
|
+
*
|
|
197
|
+
* Narrowed rather than asserted: MiniMap types `data` as an open record, and a
|
|
198
|
+
* bad `kind` here would be a thrown error inside React Flow's own render rather
|
|
199
|
+
* than a mis-coloured dot.
|
|
200
|
+
*/
|
|
201
|
+
function miniMapColor(data) {
|
|
202
|
+
const kind = data?.kind;
|
|
203
|
+
if (!isWorkflowNodeKind(kind))
|
|
204
|
+
return '#a1a1aa';
|
|
205
|
+
if (kind === 'source')
|
|
206
|
+
return '#0ea5e9';
|
|
207
|
+
if (kind === 'sink')
|
|
208
|
+
return '#10b981';
|
|
209
|
+
return '#8b5cf6';
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The graph itself, and the two states in which there is no graph to draw.
|
|
213
|
+
*
|
|
214
|
+
* Loading and failure are drawn inside the canvas's own frame rather than in
|
|
215
|
+
* place of the screen, so the header and its controls stay put while a refetch
|
|
216
|
+
* resolves — and a failed read never looks like an empty workflow.
|
|
217
|
+
*/
|
|
218
|
+
function GraphSurface({ loading, failed, error, onRetry, canEdit, draft, flowNodes, flowEdges, onInspect, onEditCode, onNodesChange, onEdgesChange, onConnect, isValidConnection, onConnectEnd, }) {
|
|
219
|
+
return (_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: [loading && _jsx(CanvasSkeleton, {}), failed && _jsx(CanvasFailure, { error: error, onRetry: onRetry }), !loading && !failed && (_jsx(WorkflowNodeProvider, { handlers: { onInspect, onEditCode, canEdit }, children: _jsxs(ReactFlow, { className: CANVAS_THEME, nodes: flowNodes, edges: flowEdges, nodeTypes: workflowNodeTypes, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, isValidConnection: isValidConnection, onConnectEnd: onConnectEnd, connectionLineType: ConnectionLineType.SmoothStep, nodesDraggable: canEdit, nodesConnectable: canEdit, elementsSelectable: true, nodesFocusable: true, edgesFocusable: true, deleteKeyCode: canEdit ? ['Delete', 'Backspace'] : null,
|
|
220
|
+
// A wider drop zone than the 20px default, because these handles are
|
|
221
|
+
// the only drop target on the screen and missing one reads as the
|
|
222
|
+
// canvas ignoring you.
|
|
223
|
+
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) => miniMapColor(node.data) })] }) }))] }));
|
|
224
|
+
}
|
|
225
|
+
/** A node's display name, falling back to its id when it is not in the graph. */
|
|
226
|
+
function nodeLabelIn(nodes, id) {
|
|
227
|
+
const found = nodes.find((candidate) => candidate.id === id);
|
|
228
|
+
return found ? nodeName(found) : id;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* What this graph commits, read off the sinks.
|
|
232
|
+
*
|
|
233
|
+
* A summary and never a control. The type is set on the sink that commits it,
|
|
234
|
+
* because a graph may have several sinks writing several types and a single
|
|
235
|
+
* field at the top of the screen could only ever name one of them.
|
|
236
|
+
*/
|
|
237
|
+
function CommitsBadge({ produces }) {
|
|
238
|
+
if (produces.length === 0)
|
|
239
|
+
return null;
|
|
240
|
+
return (_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(', ')] }) }));
|
|
241
|
+
}
|
|
242
|
+
/** Where React Flow moved nodes to, and which it removed, out of one batch. */
|
|
243
|
+
function nodeMovesAndRemovals(changes) {
|
|
244
|
+
const positions = new Map();
|
|
245
|
+
const removed = new Set();
|
|
246
|
+
for (const change of changes) {
|
|
247
|
+
if (change.type === 'position' && change.position) {
|
|
248
|
+
positions.set(change.id, change.position);
|
|
249
|
+
}
|
|
250
|
+
if (change.type === 'remove')
|
|
251
|
+
removed.add(change.id);
|
|
252
|
+
}
|
|
253
|
+
return { positions, removed };
|
|
254
|
+
}
|
|
255
|
+
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
256
|
const client = useCatalogClient();
|
|
103
257
|
const queryClient = useQueryClient();
|
|
104
258
|
const { fitView } = useReactFlow();
|
|
@@ -157,14 +311,13 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
157
311
|
const list = workflows.data;
|
|
158
312
|
if (!list)
|
|
159
313
|
return;
|
|
160
|
-
const wanted =
|
|
314
|
+
const wanted = wantedWorkflowId(list, selected);
|
|
161
315
|
if (loadedRef.current === wanted)
|
|
162
316
|
return;
|
|
163
317
|
loadedRef.current = wanted;
|
|
164
318
|
if (selected !== wanted)
|
|
165
319
|
setSelected(wanted);
|
|
166
|
-
|
|
167
|
-
setDraft(found ? draftFrom(found) : blankDraft());
|
|
320
|
+
setDraft(draftForId(list, wanted));
|
|
168
321
|
setSelectedNodeIds([]);
|
|
169
322
|
setSelectedEdgeIds([]);
|
|
170
323
|
setInspecting(null);
|
|
@@ -174,6 +327,10 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
174
327
|
// out. Calling it in the same tick fits an empty canvas, because React Flow
|
|
175
328
|
// has not measured anything yet.
|
|
176
329
|
const draftId = draft.id;
|
|
330
|
+
// `draftId` is the trigger, not a value the body reads — which is exactly why
|
|
331
|
+
// the rule calls it unnecessary. Dropping it would fit the view once on mount
|
|
332
|
+
// and never again, leaving every workflow opened afterwards off-screen.
|
|
333
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: draftId is what the effect watches for, not something its body uses
|
|
177
334
|
useEffect(() => {
|
|
178
335
|
const frame = window.requestAnimationFrame(() => fitView({ padding: 0.25, duration: 200 }));
|
|
179
336
|
return () => window.cancelAnimationFrame(frame);
|
|
@@ -214,22 +371,8 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
214
371
|
* does not match what was on screen.
|
|
215
372
|
*/
|
|
216
373
|
const onNodesChange = useCallback((changes) => {
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
}
|
|
374
|
+
setSelectedNodeIds((current) => nextSelection(current, changes));
|
|
375
|
+
const { positions, removed } = nodeMovesAndRemovals(changes);
|
|
233
376
|
if (positions.size === 0 && removed.size === 0)
|
|
234
377
|
return;
|
|
235
378
|
edit((current) => ({
|
|
@@ -250,13 +393,7 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
250
393
|
}
|
|
251
394
|
}, [edit]);
|
|
252
395
|
const onEdgesChange = useCallback((changes) => {
|
|
253
|
-
|
|
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
|
-
}
|
|
396
|
+
setSelectedEdgeIds((current) => nextSelection(current, changes));
|
|
260
397
|
const removed = new Set(changes.filter((change) => change.type === 'remove').map((c) => c.id));
|
|
261
398
|
if (removed.size === 0)
|
|
262
399
|
return;
|
|
@@ -280,15 +417,11 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
280
417
|
setAnnouncement(verdict.reason);
|
|
281
418
|
return;
|
|
282
419
|
}
|
|
283
|
-
const label = (id) => {
|
|
284
|
-
const node = draft.nodes.find((candidate) => candidate.id === id);
|
|
285
|
-
return node ? nodeName(node) : id;
|
|
286
|
-
};
|
|
287
420
|
// Appended rather than inserted anywhere else: a node with several inbound
|
|
288
421
|
// edges receives its inputs in the order the edges appear in this array,
|
|
289
422
|
// and that order is part of what the graph produces.
|
|
290
423
|
edit((current) => ({ ...current, edges: [...current.edges, { from, to }] }));
|
|
291
|
-
setAnnouncement(`${
|
|
424
|
+
setAnnouncement(`${nodeLabelIn(draft.nodes, from)} now feeds ${nodeLabelIn(draft.nodes, to)}.`);
|
|
292
425
|
}, [draft.nodes, draft.edges, edit]);
|
|
293
426
|
const onConnect = useCallback((connection) => {
|
|
294
427
|
// Narrowed rather than trusted: React Flow types both ends as `string`
|
|
@@ -298,6 +431,24 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
298
431
|
return;
|
|
299
432
|
connect(connection.source, connection.target);
|
|
300
433
|
}, [connect]);
|
|
434
|
+
/**
|
|
435
|
+
* Why a drag was refused, said once at the end of it.
|
|
436
|
+
*
|
|
437
|
+
* At the end rather than on every pointer move, which would set state dozens
|
|
438
|
+
* of times a second while somebody is still deciding where to drop. The
|
|
439
|
+
* boolean half of this lives in `isValidConnection` below.
|
|
440
|
+
*/
|
|
441
|
+
const announceRefusedDrop = useCallback((_event, state) => {
|
|
442
|
+
if (state.isValid !== false)
|
|
443
|
+
return;
|
|
444
|
+
const from = state.fromNode?.id;
|
|
445
|
+
const to = state.toNode?.id;
|
|
446
|
+
if (!from || !to)
|
|
447
|
+
return;
|
|
448
|
+
const verdict = canConnect(draft.nodes, draft.edges, from, to);
|
|
449
|
+
if (!verdict.ok)
|
|
450
|
+
setAnnouncement(verdict.reason);
|
|
451
|
+
}, [draft.nodes, draft.edges]);
|
|
301
452
|
/**
|
|
302
453
|
* The while-drawing check.
|
|
303
454
|
*
|
|
@@ -354,35 +505,7 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
354
505
|
const addNode = useCallback((kind) => {
|
|
355
506
|
const id = newLocalId(kind);
|
|
356
507
|
setDraft((current) => {
|
|
357
|
-
const
|
|
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
|
-
};
|
|
508
|
+
const node = newNodeOfKind(kind, id, nextPosition(current.nodes));
|
|
386
509
|
return { ...current, nodes: [...current.nodes, node], dirty: true };
|
|
387
510
|
});
|
|
388
511
|
setInspecting(id);
|
|
@@ -416,13 +539,6 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
416
539
|
})),
|
|
417
540
|
{ value: NEW_WORKFLOW, label: `New ${WORKFLOW_NAME.singular}` },
|
|
418
541
|
], [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
542
|
const produces = producedTypes(draft.nodes);
|
|
427
543
|
return (
|
|
428
544
|
/*
|
|
@@ -437,56 +553,10 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
437
553
|
* not save that: it fits the graph into a box, and half the box was off
|
|
438
554
|
* screen. See `QueryConsole` for the same pattern.
|
|
439
555
|
*/
|
|
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 }),
|
|
556
|
+
_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 }), _jsx(CommitsBadge, { produces: produces })] }), _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
557
|
loadedRef.current = null;
|
|
442
558
|
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-
|
|
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) => ({
|
|
559
|
+
}, options: workflowOptions, disabled: workflows.isPending }), _jsx(TextField, { label: "Name", value: draft.name, onChange: (name) => edit((current) => ({ ...current, name })), placeholder: "Fleet readiness", disabled: !canEdit }), _jsx(CanvasActions, { draft: draft, canEdit: canEdit, blocked: blocked, saving: save.isPending, running: runIt.isPending, durabilityDetail: durability.detail, onSave: () => save.mutate(), onRun: () => draft.id && runIt.mutate(draft.id), onAskDelete: () => setConfirmingDelete(true) })] }), save.error && _jsx(RefusalNote, { lead: "The server refused it:", error: save.error }), runIt.error && _jsx(RefusalNote, { lead: "The run could not start:", error: runIt.error })] }), canEdit && (_jsx(AddNodeBar, { refreshing: workflows.isFetching && !workflows.isPending, onAdd: addNode, onTidy: tidy })), _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: [_jsx(GraphSurface, { loading: workflows.isPending, failed: workflows.isError, error: workflows.error, onRetry: () => workflows.refetch(), canEdit: canEdit, draft: draft, flowNodes: flowNodes, flowEdges: flowEdges, onInspect: setInspecting, onEditCode: setEditingCodeFor, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, isValidConnection: isValidConnection, onConnectEnd: announceRefusedDrop }), _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
560
|
...current,
|
|
491
561
|
nodes: current.nodes.map((node) => (node.id === next.id ? next : node)),
|
|
492
562
|
})), onConnect: connect, onDisconnect: disconnect, onDelete: (nodeId) => {
|
|
@@ -575,6 +645,39 @@ function WiringRail({ draft, problems, run, canEdit, onInspect, onDisconnect, })
|
|
|
575
645
|
: 'no outcome recorded' })] }, sink.id));
|
|
576
646
|
}) }), _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
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* One end of a node's wiring — everything feeding it, or everything it feeds.
|
|
650
|
+
*
|
|
651
|
+
* Both directions render the same list off the same edges, so they share one
|
|
652
|
+
* description of it. Only which end of the edge to name, and how removing it is
|
|
653
|
+
* announced, differ; `children` carries whatever belongs under the list.
|
|
654
|
+
*/
|
|
655
|
+
function WiringList({ title, edges, otherEnd, describeRemoval, canEdit, onDisconnect, children, }) {
|
|
656
|
+
return (_jsxs("section", { children: [_jsx("h3", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: title }), edges.length === 0 ? (_jsx("p", { className: cn('mt-1 text-[11px]', MUTED), children: "Nothing yet." })) : (_jsx("ul", { className: "mt-1 space-y-1", children: edges.map((edge) => (_jsxs("li", { className: "flex items-center gap-1.5 text-[11px]", children: [_jsx("span", { className: "truncate", children: otherEnd(edge) }), canEdit && (_jsx(Tooltip, { content: "Remove this connection.", children: _jsx("button", { type: "button", onClick: () => onDisconnect(edge), "aria-label": describeRemoval(otherEnd(edge)), className: "ml-auto rounded p-0.5 text-zinc-400 hover:text-red-600", children: _jsx(Unplug, { size: 11 }) }) }))] }, edgeId(edge)))) })), children] }));
|
|
657
|
+
}
|
|
658
|
+
/** Which transform runs here, and a way into its code. */
|
|
659
|
+
function TransformInspector({ node, transforms, canEdit, onChange, onEditCode, }) {
|
|
660
|
+
return (_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) => ({
|
|
661
|
+
value: transform.id,
|
|
662
|
+
label: transform.name,
|
|
663
|
+
hint: `${transform.language} · v${transform.version}`,
|
|
664
|
+
})), 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"] })] }));
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* What this sink commits, and whether it replaces or merges.
|
|
668
|
+
*
|
|
669
|
+
* The type is set here, on the node that commits it, rather than once for the
|
|
670
|
+
* whole graph — several sinks may write several types.
|
|
671
|
+
*/
|
|
672
|
+
function SinkInspector({ node, typeOptions, canEdit, onChange, }) {
|
|
673
|
+
return (_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({
|
|
674
|
+
...node,
|
|
675
|
+
mode: mode === 'incremental' ? 'incremental' : 'full',
|
|
676
|
+
}), options: [
|
|
677
|
+
{ value: 'full', label: 'Full — replace the dataset' },
|
|
678
|
+
{ value: 'incremental', label: 'Incremental — merge into it' },
|
|
679
|
+
], 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."] })] }));
|
|
680
|
+
}
|
|
578
681
|
function NodeInspector({ node, draft, transforms, connections, typeOptions, canEdit, problems, onClose, onChange, onConnect, onDisconnect, onDelete, onEditCode, }) {
|
|
579
682
|
const [pendingTarget, setPendingTarget] = useState('');
|
|
580
683
|
const label = (id) => {
|
|
@@ -606,21 +709,11 @@ function NodeInspector({ node, draft, transforms, connections, typeOptions, canE
|
|
|
606
709
|
return (_jsx(Sheet, { open: node !== null, onOpenChange: (open) => {
|
|
607
710
|
if (!open)
|
|
608
711
|
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' && (
|
|
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
|
|
712
|
+
}, 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' && (_jsx(TransformInspector, { node: node, transforms: transforms, canEdit: canEdit, onChange: onChange, onEditCode: onEditCode })), node.kind === 'source' && (_jsx(SourceInspector
|
|
614
713
|
// Keyed so the text fields reset when a different source is
|
|
615
714
|
// opened. Without it the draft state would survive the swap and
|
|
616
715
|
// one node's URL would appear inside another.
|
|
617
|
-
, { node: node, connections: connections, canEdit: canEdit, onChange: onChange }, node.id)), node.kind === 'sink' && (
|
|
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
|
|
716
|
+
, { node: node, connections: connections, canEdit: canEdit, onChange: onChange }, node.id)), node.kind === 'sink' && (_jsx(SinkInspector, { node: node, typeOptions: typeOptions, canEdit: canEdit, onChange: onChange })), _jsx(WiringList, { title: "Fed by", edges: incoming, otherEnd: (edge) => label(edge.from), describeRemoval: (name) => `Stop ${name} feeding this node`, canEdit: canEdit, onDisconnect: onDisconnect, children: 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(WiringList, { title: "Feeds", edges: outgoing, otherEnd: (edge) => label(edge.to), describeRemoval: (name) => `Stop this node feeding ${name}`, canEdit: canEdit, onDisconnect: onDisconnect, children: [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
717
|
? 'Nothing can be wired from here'
|
|
625
718
|
: 'Send its output to…', disabled: eligible.length === 0 }) }), _jsx("button", { type: "button", onClick: () => {
|
|
626
719
|
if (!pendingTarget)
|
|
@@ -46,7 +46,6 @@ function useAreaLoadingPulseState(chartPhase, loading, loadingPulseMode, notifyL
|
|
|
46
46
|
showSeriesContent,
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: mirrors Line series layout (fill, stroke, dash, markers, pulse)
|
|
50
49
|
export function Area({ dataKey, yAxisId, fill = chartCssVars.linePrimary, fillOpacity = 0.4, stroke, strokeWidth = 2, curve = curveMonotoneX, animate = true, showLine = true, showHighlight = true, gradientToOpacity = 0, gradientSpan = 1, fadeEdges = false, showMarkers = false, markers, dashFromIndex, dashArray = '6,4', loading, loadingStroke = chartCssVars.foreground, loadingStrokeOpacity = 0.5, loadingPulseMode, loadingStyle = 'pulse', }) {
|
|
51
50
|
// Stable slice only: hover state lives inside `<SeriesHoverDim>` and
|
|
52
51
|
// `<SeriesHighlightLayer>` so this component (and its expensive
|
|
@@ -213,7 +213,6 @@ const ChartCore = memo(function ChartCore({ width, height, data, xDataKey, margi
|
|
|
213
213
|
return scale;
|
|
214
214
|
}, [categoryScale, innerWidth, data.length]);
|
|
215
215
|
// Animation timing — replay when motion settings change
|
|
216
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: revealSignature
|
|
217
216
|
useEffect(() => {
|
|
218
217
|
setRevealEpoch((n) => n + 1);
|
|
219
218
|
setIsLoaded(false);
|
|
@@ -33,7 +33,6 @@ function resolveRowTickValues(options) {
|
|
|
33
33
|
}
|
|
34
34
|
return filtered.length > 0 ? filtered : undefined;
|
|
35
35
|
}
|
|
36
|
-
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: grid fade masks and shimmer share one layer tree
|
|
37
36
|
export function Grid({ horizontal = true, vertical = false, numTicksRows = 5, numTicksColumns = 10, rowTickValues, stroke = chartCssVars.grid, loadingStroke, strokeOpacity = 1, strokeWidth = 1, strokeDasharray = '4,4', highlightRowValues, highlightRowStroke = chartCssVars.foregroundMuted, highlightRowStrokeOpacity = 1, highlightRowStrokeWidth = 1, highlightRowStrokeDasharray = '0', fadeHorizontal = true, fadeVertical = false, hideHorizontalEdgeLines = false, hideVerticalEdgeLines = false, yAxisId, shimmer = false, shimmerStroke = DEFAULT_SHIMMER_STROKE, shimmerLength = DEFAULT_SHIMMER_LENGTH_PX, shimmerSpeed = DEFAULT_SHIMMER_SPEED, shimmerSync = false, }) {
|
|
38
37
|
const { xScale, innerWidth, innerHeight, orientation, barScale, chartPhase } = useChartStable();
|
|
39
38
|
const yScale = useYScale(yAxisId);
|
|
@@ -45,7 +45,6 @@ function useGrowExitClip(innerWidth, mode, loopEpoch, onComplete) {
|
|
|
45
45
|
const shrink = (p - 0.5) / 0.5;
|
|
46
46
|
return rightEdge - (1 - shrink) * paddedFullWidth;
|
|
47
47
|
});
|
|
48
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: loopEpoch restarts pulse when orchestrator advances
|
|
49
48
|
useEffect(() => {
|
|
50
49
|
if (innerWidth <= 0) {
|
|
51
50
|
return;
|
|
@@ -145,7 +145,6 @@ function DatePillTrackerInner({ labels, currentIndex, xWithMargin, discreteInter
|
|
|
145
145
|
if (!discreteInteraction) {
|
|
146
146
|
animatedX.set(xWithMargin);
|
|
147
147
|
}
|
|
148
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: we need to jump the animatedX when the visible prop changes
|
|
149
148
|
useEffect(() => {
|
|
150
149
|
animatedX.set(xWithMargin);
|
|
151
150
|
}, [animatedX, visible]);
|
|
@@ -51,7 +51,6 @@ function TooltipIndicatorInner({ x, visible, height, width = 'line', span, colum
|
|
|
51
51
|
animatedX.set(rectX);
|
|
52
52
|
animatedLineX.set(lineX);
|
|
53
53
|
}
|
|
54
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: we need to jump the animatedX when the visible prop changes
|
|
55
54
|
useEffect(() => {
|
|
56
55
|
animatedX.set(rectX);
|
|
57
56
|
animatedLineX.set(lineX);
|
|
@@ -19,7 +19,6 @@ export function useChartPhaseOrchestrator({ chartStatus, targetData, skeletonDat
|
|
|
19
19
|
const prevStatusRef = useRef(chartStatus);
|
|
20
20
|
const phaseRef = useRef(chartPhase);
|
|
21
21
|
phaseRef.current = chartPhase;
|
|
22
|
-
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: status transition branches for animation durations
|
|
23
22
|
useEffect(() => {
|
|
24
23
|
const prevStatus = prevStatusRef.current;
|
|
25
24
|
if (prevStatus === chartStatus) {
|
|
@@ -59,7 +58,6 @@ export function useChartPhaseOrchestrator({ chartStatus, targetData, skeletonDat
|
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
}, [animationDuration, chartStatus, skeletonData, targetData, yDomainTweenDuration]);
|
|
62
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: revealSignature replays enter
|
|
63
61
|
useEffect(() => {
|
|
64
62
|
if (skipEnterReveal) {
|
|
65
63
|
return;
|
|
@@ -17,7 +17,6 @@ export function useMountProgress(enterTransition, delaySeconds, replayKey) {
|
|
|
17
17
|
const transitionRef = useRef(enterTransition);
|
|
18
18
|
transitionRef.current = enterTransition;
|
|
19
19
|
// replayKey intentionally retriggers enter when motion settings change
|
|
20
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: replayKey
|
|
21
20
|
useEffect(() => {
|
|
22
21
|
progress.set(0);
|
|
23
22
|
const controls = animate(progress, 1, {
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export { FieldGroup, TextAreaField, TextField } from './ui/field';
|
|
|
26
26
|
export { Select, SelectField, type SelectOption } from './ui/select';
|
|
27
27
|
export { Switch } from './ui/switch';
|
|
28
28
|
export { Sheet } from './ui/sheet';
|
|
29
|
+
export { CodeEditor, type CodeEditorProps } from './ui/code-editor';
|
|
30
|
+
export { RichTextField, RichTextView, type RichTextFieldProps, } from './ui/rich-text-field';
|
|
29
31
|
export { Button, type ButtonProps, type ButtonSize, type ButtonVariant } from './ui/button';
|
|
30
32
|
export { Tabs, TabsList, TabsPanel, TabsTab } from './ui/tabs';
|
|
31
33
|
export { Tooltip, TooltipProvider } from './ui/tooltip';
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,8 @@ export { FieldGroup, TextAreaField, TextField } from './ui/field';
|
|
|
61
61
|
export { Select, SelectField } from './ui/select';
|
|
62
62
|
export { Switch } from './ui/switch';
|
|
63
63
|
export { Sheet } from './ui/sheet';
|
|
64
|
+
export { CodeEditor } from './ui/code-editor';
|
|
65
|
+
export { RichTextField, RichTextView, } from './ui/rich-text-field';
|
|
64
66
|
export { Button } from './ui/button';
|
|
65
67
|
export { Tabs, TabsList, TabsPanel, TabsTab } from './ui/tabs';
|
|
66
68
|
export { Tooltip, TooltipProvider } from './ui/tooltip';
|