@dudousxd/nestjs-catalog-react 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConnectionPanel.js +21 -2
- package/dist/PipelineConsole.js +13 -13
- package/dist/WorkflowCanvas.js +670 -35
- package/package.json +2 -2
package/dist/ConnectionPanel.js
CHANGED
|
@@ -245,9 +245,28 @@ function connectionIsIncomplete(kind, draft) {
|
|
|
245
245
|
function HttpFields({ draft, update }) {
|
|
246
246
|
return (_jsxs(_Fragment, { children: [_jsx(TextField, { label: "URL", value: draft.url, onChange: (url) => update({ url }), placeholder: "https://api.example.mil/v1", hint: "The base the connectors reading through this will hang their paths off." }), _jsx(TextField, { label: "Credential env var", value: draft.secretEnvVar, onChange: (secretEnvVar) => update({ secretEnvVar }), placeholder: "Optional \u2014 sent as a bearer token" })] }));
|
|
247
247
|
}
|
|
248
|
-
/**
|
|
248
|
+
/**
|
|
249
|
+
* The connection string, and nothing beside it.
|
|
250
|
+
*
|
|
251
|
+
* This was two fields — an inline URL and the name of an environment variable
|
|
252
|
+
* holding one — presented side by side with a paragraph explaining when each
|
|
253
|
+
* applied. Two doors for one decision, and only one of them worked for a
|
|
254
|
+
* database with a password, which is every database anybody connects to. The
|
|
255
|
+
* question it produced was "what is this second field", which is the form
|
|
256
|
+
* asking the reader to understand its implementation.
|
|
257
|
+
*
|
|
258
|
+
* One field now. Whether the URL may REST in the catalog's own table is the
|
|
259
|
+
* store's decision (`allowInlineCredentials`) and not something to ask on a
|
|
260
|
+
* form — and it is a decision about the deployment, not about this connection.
|
|
261
|
+
* The server refuses and says why if the answer is no, which is a better place
|
|
262
|
+
* to learn it than a hint nobody reads until afterwards.
|
|
263
|
+
*
|
|
264
|
+
* `secretEnvVar` still exists on the model and is still what a hardened
|
|
265
|
+
* deployment should use; it is not on this screen. A host that wants it back
|
|
266
|
+
* has the field on the record.
|
|
267
|
+
*/
|
|
249
268
|
function SqlFields({ draft, update }) {
|
|
250
|
-
return (_jsx(FieldGroup, { title: "Address", hint: "
|
|
269
|
+
return (_jsx(FieldGroup, { title: "Address", hint: "The connection string, as your database gives it to you. It is served back redacted, so the password never travels in a response \u2014 but it does rest in this catalog's own table, and a deployment can refuse that.", children: _jsx(TextField, { label: "Connection URL", value: draft.url, onChange: (url) => update({ url }), placeholder: "mysql://user:pass@host:3306/database" }) }));
|
|
251
270
|
}
|
|
252
271
|
/** A bucket, plus everything needed to address a non-AWS one. */
|
|
253
272
|
function S3Fields({ draft, update }) {
|
package/dist/PipelineConsole.js
CHANGED
|
@@ -8,7 +8,7 @@ import { cn } from './cn';
|
|
|
8
8
|
import { catalogQueryKeys, useCatalogClient } from './context';
|
|
9
9
|
// One description of what a source needs, shared with the workflow canvas's
|
|
10
10
|
// source inspector. See the header of that module for why it is not two.
|
|
11
|
-
import {
|
|
11
|
+
import { INLINE_CONNECTION, KIND_OPTIONS, ReadModeFields, SourceFields, parseRecords, readsIncrementally, sourceConfigFrom, sourceDraftFrom, sourceIsIncomplete, toConnectorKind, usesConnection, } from './source-fields';
|
|
12
12
|
import { ConfirmDialog } from './ui/dialog';
|
|
13
13
|
import { TextField } from './ui/field';
|
|
14
14
|
import { SelectField } from './ui/select';
|
|
@@ -486,18 +486,18 @@ function ConnectorForm({ connector, transforms, connections, schemaDiscovery, on
|
|
|
486
486
|
return (_jsxs("form", { className: cn('mt-6 space-y-4 rounded-lg border p-4', RULE, PANEL), onSubmit: (event) => {
|
|
487
487
|
event.preventDefault();
|
|
488
488
|
save.mutate();
|
|
489
|
-
}, children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(TextField, { label: "Name", value: draft.name, onChange: (name) => setDraft({ ...draft, name }), placeholder: "Nightly fleet load" }), _jsx(TextField, { label: "Target object type", value: draft.targetType, onChange: (targetType) => setDraft({ ...draft, targetType }), placeholder: "e.g. Mvr" }), _jsx(SelectField, { label: "Source kind", ariaLabel: "Source kind", value: kind, onValueChange: (value) => setKind(toConnectorKind(value)), options: KIND_OPTIONS })] }), usesConnection(kind) && (_jsx(ConnectionPicker, { value: chosenConnection, options: connectionOptions, viaConnection: viaConnection, onChange: setConnectionId })), schemaDiscovery && connector?.id && (_jsx(SchemaDiscoveryPanel, { connectorId: connector.id, bridge: schemaDiscovery })), _jsx(SourceFields, { kind: kind, draft: source, onChange: setSource, viaConnection: viaConnection }), _jsx(ReadModeFields, { kind: kind, mode: mode, onModeChange: setMode, draft: source, onChange: setSource }),
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
489
|
+
}, children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(TextField, { label: "Name", value: draft.name, onChange: (name) => setDraft({ ...draft, name }), placeholder: "Nightly fleet load" }), _jsx(TextField, { label: "Target object type", value: draft.targetType, onChange: (targetType) => setDraft({ ...draft, targetType }), placeholder: "e.g. Mvr" }), _jsx(SelectField, { label: "Source kind", ariaLabel: "Source kind", value: kind, onValueChange: (value) => setKind(toConnectorKind(value)), options: KIND_OPTIONS })] }), usesConnection(kind) && (_jsx(ConnectionPicker, { value: chosenConnection, options: connectionOptions, viaConnection: viaConnection, onChange: setConnectionId })), schemaDiscovery && connector?.id && (_jsx(SchemaDiscoveryPanel, { connectorId: connector.id, bridge: schemaDiscovery })), _jsx(SourceFields, { kind: kind, draft: source, onChange: setSource, viaConnection: viaConnection }), _jsx(ReadModeFields, { kind: kind, mode: mode, onModeChange: setMode, draft: source, onChange: setSource }), _jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: _jsx(SelectField, { label: "Transform", ariaLabel: "Transform", value: draft.transformId, onValueChange: (transformId) => setDraft({ ...draft, transformId }), options: [
|
|
490
|
+
{
|
|
491
|
+
value: '',
|
|
492
|
+
label: 'No transform',
|
|
493
|
+
hint: 'Store records as they arrive',
|
|
494
|
+
},
|
|
495
|
+
...transforms.map((transform) => ({
|
|
496
|
+
value: transform.id,
|
|
497
|
+
label: transform.name,
|
|
498
|
+
hint: `${transform.language} · v${transform.version}`,
|
|
499
|
+
})),
|
|
500
|
+
] }) }), _jsx(Switch, { checked: enabled, onCheckedChange: setEnabled, label: "Enabled", hint: "A disabled connector keeps its configuration and its watermark, and refuses to run." }), _jsx(ConnectorFormActions, { editing: connector !== undefined, pending: save.isPending, incomplete: incomplete, error: save.error, onClose: onClose })] }));
|
|
501
501
|
}
|
|
502
502
|
function TransformList({ canEdit, languages, pythonPackages, }) {
|
|
503
503
|
const client = useCatalogClient();
|
package/dist/WorkflowCanvas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
import { Background, BackgroundVariant, ConnectionLineType, Controls, MiniMap, NodeToolbar, Position, ReactFlow, ReactFlowProvider, useReactFlow, } from '@xyflow/react';
|
|
3
3
|
// React Flow ships its own stylesheet and renders as an unstyled pile of divs
|
|
4
4
|
// without it — no edges, every node at the top-left corner. Imported by the
|
|
5
5
|
// component that needs it rather than left to the host, because a missing
|
|
@@ -7,19 +7,19 @@ import { Background, BackgroundVariant, ConnectionLineType, Controls, MiniMap, R
|
|
|
7
7
|
// See src/styles.d.ts for why `tsc` tolerates this import.
|
|
8
8
|
import '@xyflow/react/dist/style.css';
|
|
9
9
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
10
|
-
import { ArrowRight, CircleAlert, Code2, Database, LayoutGrid, Loader2, Play, Plug, Plus, Repeat, Save, Trash2, TriangleAlert, Unplug, } from 'lucide-react';
|
|
10
|
+
import { ArrowRight, CircleAlert, CircleDashed, Code2, Database, LayoutGrid, Link2, Loader2, Play, Plug, Plus, Repeat, Save, Trash2, TriangleAlert, Unplug, } from 'lucide-react';
|
|
11
11
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
12
|
import { TransformEditor } from './TransformEditor';
|
|
13
13
|
import { cn } from './cn';
|
|
14
14
|
import { catalogQueryKeys, useCatalogClient } from './context';
|
|
15
|
-
import {
|
|
15
|
+
import { INLINE_CONNECTION, KIND_OPTIONS, ReadModeFields, SourceFields, connectionOptions, readsIncrementally, sourceConfigFrom, sourceDraftFrom, toConnectorKind, usesConnection, } from './source-fields';
|
|
16
16
|
import { ConfirmDialog } from './ui/dialog';
|
|
17
17
|
import { TextField } from './ui/field';
|
|
18
18
|
import { Select, SelectField } from './ui/select';
|
|
19
19
|
import { Sheet } from './ui/sheet';
|
|
20
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';
|
|
21
|
+
import { NODE_HEIGHT, NODE_WIDTH, defaultLabel, layout, layoutIfUnarranged, nextPosition, toFlowEdges, toFlowNodes, } from './workflow/graph';
|
|
22
|
+
import { WORKFLOW_NODE_KINDS, describeDurability, isWorkflowNodeKind, newLocalId, nodeName, producedTypes, } from './workflow/model';
|
|
23
23
|
import { WORKFLOW_NAME } from './workflow/name';
|
|
24
24
|
import { WorkflowNodeProvider, workflowNodeTypes } from './workflow/nodes';
|
|
25
25
|
import { canConnect, edgeId, hasBlockingProblem, problemsByNode, validateWorkflow, } from './workflow/validate';
|
|
@@ -125,8 +125,7 @@ function nextSelection(current, changes) {
|
|
|
125
125
|
* a config, a transform carries a transform, a sink carries the type it commits,
|
|
126
126
|
* and nothing carries a field belonging to another kind.
|
|
127
127
|
*/
|
|
128
|
-
function newNodeOfKind(kind, id, position) {
|
|
129
|
-
const name = defaultLabel(kind);
|
|
128
|
+
function newNodeOfKind(kind, id, position, name) {
|
|
130
129
|
if (kind === 'source') {
|
|
131
130
|
return { id, name, kind: 'source', sourceKind: 'http', config: {}, position };
|
|
132
131
|
}
|
|
@@ -135,6 +134,264 @@ function newNodeOfKind(kind, id, position) {
|
|
|
135
134
|
}
|
|
136
135
|
return { id, name, kind: 'sink', targetType: '', position };
|
|
137
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* The code a transform created from this canvas starts as: the batch, unchanged.
|
|
139
|
+
*
|
|
140
|
+
* Keyed by the language union rather than by `string`, so a language added to
|
|
141
|
+
* the library without a line here is a type error rather than a transform that
|
|
142
|
+
* saves empty and fails at run time.
|
|
143
|
+
*
|
|
144
|
+
* Deliberately the identity and not a worked example. `TransformEditor` ships
|
|
145
|
+
* starters that teach the shape of a mapping, and they belong there — somebody
|
|
146
|
+
* who opened the editor came to write a transform. Somebody who pressed this
|
|
147
|
+
* button came to get *past* an empty picker, and the useful default is the
|
|
148
|
+
* smallest thing that actually runs: the graph is now complete, it commits what
|
|
149
|
+
* the source produced, and the mapping is an edit rather than a prerequisite.
|
|
150
|
+
*/
|
|
151
|
+
const IDENTITY_TRANSFORM = {
|
|
152
|
+
javascript: '// Whatever is wired into this step arrives as `records`.\nreturn records;',
|
|
153
|
+
typescript: '// Whatever is wired into this step arrives as `records`.\nreturn records;',
|
|
154
|
+
python: '# Whatever is wired into this step arrives as `records`.\nreturn records',
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* The transform to create for a node that has none, ready to send.
|
|
158
|
+
*
|
|
159
|
+
* Named after the node, so the two are findable from each other in a Transforms
|
|
160
|
+
* list that knows nothing about graphs. In the deployment's own first language,
|
|
161
|
+
* because offering one the image cannot execute turns a deployment difference
|
|
162
|
+
* into a traceback the author cannot act on — the same reason `TransformEditor`
|
|
163
|
+
* takes its languages from `pipelineCapabilities()` rather than listing all
|
|
164
|
+
* three.
|
|
165
|
+
*/
|
|
166
|
+
function starterTransform(node, languages) {
|
|
167
|
+
const language = languages?.[0] ?? 'javascript';
|
|
168
|
+
return {
|
|
169
|
+
name: node ? nodeName(node) : defaultLabel('transform'),
|
|
170
|
+
language,
|
|
171
|
+
code: IDENTITY_TRANSFORM[language],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The node a "make one and wire it" action would create, and whether it is legal.
|
|
176
|
+
*
|
|
177
|
+
* Pure, and separate from the state update it feeds, so the decision can be
|
|
178
|
+
* described in one place and tested without a canvas. The verdict is asked even
|
|
179
|
+
* though the menu only offers kinds `newKindsFrom` already approved: the menu
|
|
180
|
+
* asking one question and the action taking a different answer is the class of
|
|
181
|
+
* bug that puts an illegal edge into a saved graph.
|
|
182
|
+
*
|
|
183
|
+
* `reason: null` distinguishes "that node is not on this canvas" — nothing
|
|
184
|
+
* happened, and there is nothing to say about it — from a refusal somebody
|
|
185
|
+
* should hear.
|
|
186
|
+
*/
|
|
187
|
+
function nodeWiredFrom(draft, fromId, kind) {
|
|
188
|
+
const from = draft.nodes.find((node) => node.id === fromId);
|
|
189
|
+
if (!from)
|
|
190
|
+
return { ok: false, reason: null };
|
|
191
|
+
const node = newNodeOfKind(kind, newLocalId(kind), placeNextTo(from, draft.nodes), uniqueName(draft.nodes, kind));
|
|
192
|
+
const verdict = canConnect([...draft.nodes, node], draft.edges, fromId, node.id);
|
|
193
|
+
return verdict.ok ? { ok: true, node, from } : { ok: false, reason: verdict.reason };
|
|
194
|
+
}
|
|
195
|
+
/** The graph with one transform node pointed at the code it now runs. */
|
|
196
|
+
function runningTransform(nodes, nodeId, transformId) {
|
|
197
|
+
return nodes.map((node) => node.id === nodeId && node.kind === 'transform' ? { ...node, transformId } : node);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* A name nobody has used yet, so the fourth transform is not also "Transform".
|
|
201
|
+
*
|
|
202
|
+
* Every node used to be born called exactly `defaultLabel(kind)`, which is how
|
|
203
|
+
* a graph ends up with three boxes called "Transform" and a problem message
|
|
204
|
+
* that has to fall back to naming the id — `Sink (sink_3b5a…)` — because the
|
|
205
|
+
* name it was given identifies nothing. A message that names an id is a message
|
|
206
|
+
* whose reader has to go hunting for which box it means.
|
|
207
|
+
*
|
|
208
|
+
* Compared against what nodes are *called* rather than against a counter, so
|
|
209
|
+
* renaming "Transform 2" to "Join" frees the number again, and so a name typed
|
|
210
|
+
* by hand is never duplicated by one generated afterwards. `nodeName` is what
|
|
211
|
+
* the rest of the screen displays, so it is what has to be unique.
|
|
212
|
+
*/
|
|
213
|
+
function uniqueName(nodes, kind) {
|
|
214
|
+
const base = defaultLabel(kind);
|
|
215
|
+
const taken = new Set(nodes.map((node) => nodeName(node)));
|
|
216
|
+
if (!taken.has(base))
|
|
217
|
+
return base;
|
|
218
|
+
// `taken.size + 1` candidates for `taken.size` names: one of them is free, so
|
|
219
|
+
// this always returns from inside the loop.
|
|
220
|
+
for (let n = 2; n <= taken.size + 1; n += 1) {
|
|
221
|
+
const candidate = `${base} ${n}`;
|
|
222
|
+
if (!taken.has(candidate))
|
|
223
|
+
return candidate;
|
|
224
|
+
}
|
|
225
|
+
return `${base} ${taken.size + 2}`;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The grid `layout` uses, restated because it keeps its gaps to itself.
|
|
229
|
+
*
|
|
230
|
+
* `NODE_WIDTH` and `NODE_HEIGHT` are exported from `workflow/graph`; the column
|
|
231
|
+
* and row gaps are not. They are repeated here so that a node created by wiring
|
|
232
|
+
* from another one lands on the same grid Tidy would have put it on — otherwise
|
|
233
|
+
* the two disagree and pressing Tidy shuffles everything by a few pixels for no
|
|
234
|
+
* reason a reader can see. If they ever drift, the consequence is spacing that
|
|
235
|
+
* looks slightly off, never a node in the wrong place: the placement below is
|
|
236
|
+
* defined by what is *occupied*, not by these numbers.
|
|
237
|
+
*/
|
|
238
|
+
const COLUMN_STEP = NODE_WIDTH + 96;
|
|
239
|
+
const ROW_STEP = NODE_HEIGHT + 32;
|
|
240
|
+
/**
|
|
241
|
+
* Where a node created *by wiring from another node* goes.
|
|
242
|
+
*
|
|
243
|
+
* One column to the right of the node that spawned it, because that is exactly
|
|
244
|
+
* what the canvas's arrangement means: `layout` puts a node one column past the
|
|
245
|
+
* deepest thing feeding it, and a node created by this action is fed by that
|
|
246
|
+
* node and nothing else. So the position that matches the picture is not a
|
|
247
|
+
* guess — it is the position the layout would have chosen anyway.
|
|
248
|
+
*
|
|
249
|
+
* Then down a row at a time until the spot is free. The three obvious
|
|
250
|
+
* alternatives are each wrong in their own way: under the cursor puts a node
|
|
251
|
+
* wherever a menu happened to be dismissed, on top of an existing node reads as
|
|
252
|
+
* "the button did nothing", and off-screen — which is what `nextPosition` does,
|
|
253
|
+
* correctly, for the toolbar's add buttons, since those have no parent to sit
|
|
254
|
+
* beside — leaves somebody looking at an unchanged canvas. Sitting beside its
|
|
255
|
+
* parent means it is on screen whenever its parent is, which is the only
|
|
256
|
+
* guarantee available without measuring the viewport.
|
|
257
|
+
*/
|
|
258
|
+
function placeNextTo(from, nodes) {
|
|
259
|
+
const taken = new Set(nodes.map((node) => `${node.position?.x ?? 0},${node.position?.y ?? 0}`));
|
|
260
|
+
const x = (from.position?.x ?? 0) + COLUMN_STEP;
|
|
261
|
+
let y = from.position?.y ?? 0;
|
|
262
|
+
while (taken.has(`${x},${y}`))
|
|
263
|
+
y += ROW_STEP;
|
|
264
|
+
return { x, y };
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Which kinds of new node this one could legally feed — asked, never restated.
|
|
268
|
+
*
|
|
269
|
+
* The menu must offer only edges the graph allows, and the temptation is to
|
|
270
|
+
* write that down: "a source may feed a transform or a sink; nothing follows a
|
|
271
|
+
* sink". Writing it down is how the canvas ends up with a second copy of rules
|
|
272
|
+
* that live in `canConnect`, and the first time the two disagree the menu either
|
|
273
|
+
* offers an edge that is then refused or hides one that was always fine.
|
|
274
|
+
*
|
|
275
|
+
* So this builds a throwaway node of each kind, drops it into a copy of the
|
|
276
|
+
* graph, and asks `canConnect` — the same function the drag uses, the same one
|
|
277
|
+
* the "send its output to" picker filters with. The probe is never stored and
|
|
278
|
+
* its id never leaves this function. When a rule changes, this follows.
|
|
279
|
+
*/
|
|
280
|
+
function newKindsFrom(from, nodes, edges) {
|
|
281
|
+
const probeId = '__probe__';
|
|
282
|
+
return WORKFLOW_NODE_KINDS.filter((kind) => {
|
|
283
|
+
const probe = newNodeOfKind(kind, probeId, { x: 0, y: 0 }, probeId);
|
|
284
|
+
return canConnect([...nodes, probe], edges, from.id, probeId).ok;
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Problems about a node nobody has finished, held back from the error list.
|
|
289
|
+
*
|
|
290
|
+
* THE DISTINCTION THIS DRAWS
|
|
291
|
+
* --------------------------
|
|
292
|
+
* A node that has just been added is unwired and unconfigured *by construction*.
|
|
293
|
+
* Clicking "+ Sink" and being told, in the same instant, that the sink "is not
|
|
294
|
+
* reachable from any source, so it would never run" and "does not say which
|
|
295
|
+
* object type it writes" is true and useless: nobody has had the chance to do
|
|
296
|
+
* either yet. Worse, it is expensive. That prose was written for somebody about
|
|
297
|
+
* to save a graph that would silently do nothing, and firing it at somebody
|
|
298
|
+
* mid-click is how a validator becomes something people learn to scroll past —
|
|
299
|
+
* which is the exact failure `workflow/validate.ts` opens by describing.
|
|
300
|
+
*
|
|
301
|
+
* So the split is between INCOMPLETE and WRONG. A node the author has not
|
|
302
|
+
* finished is a to-do. A node the author *thinks* is finished and is not is a
|
|
303
|
+
* problem, and only that deserves the checks' own language.
|
|
304
|
+
*
|
|
305
|
+
* WHAT COUNTS AS "NOT FINISHED"
|
|
306
|
+
* -----------------------------
|
|
307
|
+
* The only honest signal a browser has is: the node was created in this editing
|
|
308
|
+
* session and nothing has happened to it since. `unstarted` is that set. It is
|
|
309
|
+
* component state, so it survives re-render and dies on reload — which is right,
|
|
310
|
+
* because a node that came back from the server is one somebody saved and walked
|
|
311
|
+
* away from, and is therefore finished as far as its author was concerned.
|
|
312
|
+
*
|
|
313
|
+
* A node touched once and abandoned — renamed, or wired, and then left — is
|
|
314
|
+
* removed from the set and reports in full. That is not a gap in the rule, it is
|
|
315
|
+
* the rule: acting on a node and stopping is precisely "I think this is done".
|
|
316
|
+
*
|
|
317
|
+
* WHAT THIS DOES NOT DO
|
|
318
|
+
* ---------------------
|
|
319
|
+
* It does not suppress anything. `hasBlockingProblem` is still asked about every
|
|
320
|
+
* problem, held back or not, so the save button is coloured as blocked from the
|
|
321
|
+
* moment the graph would not run; the held-back items are listed on screen the
|
|
322
|
+
* whole time as work outstanding; and pressing Save clears `unstarted` outright,
|
|
323
|
+
* so a save attempt promotes every one of them to a full error before the
|
|
324
|
+
* request is even answered. A graph that would silently do nothing cannot be
|
|
325
|
+
* saved unnoticed, which is what these checks exist for.
|
|
326
|
+
*
|
|
327
|
+
* A problem naming several nodes is held back only when *every* node it names is
|
|
328
|
+
* unstarted. Two sinks writing the same type, one old and one new, is a fact
|
|
329
|
+
* about the old one too.
|
|
330
|
+
*
|
|
331
|
+
* Worth being honest about: under the touch rule above, `every` and `some`
|
|
332
|
+
* currently cannot disagree. The only check that names two nodes is
|
|
333
|
+
* `duplicate-sink-type`, and reaching it means setting a type on the new sink,
|
|
334
|
+
* which starts it. `every` is written anyway because it is the rule that is
|
|
335
|
+
* *correct* — if "touched" is ever loosened, `some` would start holding back
|
|
336
|
+
* complaints about nodes somebody finished months ago, and it would do it
|
|
337
|
+
* silently.
|
|
338
|
+
*/
|
|
339
|
+
function partitionProblems(problems, unstarted) {
|
|
340
|
+
const live = [];
|
|
341
|
+
const pending = [];
|
|
342
|
+
for (const problem of problems) {
|
|
343
|
+
// A problem with no node ids is about the graph, not about a box somebody is
|
|
344
|
+
// half-way through — nothing is "not finished yet" about an empty workflow.
|
|
345
|
+
const held = problem.nodeIds.length > 0 && problem.nodeIds.every((id) => unstarted.has(id));
|
|
346
|
+
(held ? pending : live).push(problem);
|
|
347
|
+
}
|
|
348
|
+
return { live, pending };
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* The same fact, said as work rather than as failure.
|
|
352
|
+
*
|
|
353
|
+
* Deliberately **not** the checks' own messages. Those are long, and they are
|
|
354
|
+
* long on purpose — they argue why the shape is refused, for a reader who
|
|
355
|
+
* believes their graph is finished. Repeating them under a friendlier heading
|
|
356
|
+
* would keep every word that makes them premature and change only the colour.
|
|
357
|
+
*
|
|
358
|
+
* A verb phrase instead, one per code. Which codes appear is still entirely the
|
|
359
|
+
* validators' decision; all this supplies is the imperative form, and the
|
|
360
|
+
* fallback means a code added later shows up as outstanding work rather than
|
|
361
|
+
* vanishing from this list.
|
|
362
|
+
*/
|
|
363
|
+
const TODO_FOR = {
|
|
364
|
+
unreachable: 'wire something into it',
|
|
365
|
+
'dead-end': 'wire it into something that ends at a sink',
|
|
366
|
+
'sink-has-no-type': 'choose the object type it commits',
|
|
367
|
+
'transform-not-named': 'choose the transform it runs',
|
|
368
|
+
'missing-transform': 'choose a transform that still exists',
|
|
369
|
+
'source-has-input': 'unwire whatever feeds it — a source reads, it is not fed',
|
|
370
|
+
'sink-has-output': 'unwire what it feeds — nothing runs after a sink',
|
|
371
|
+
};
|
|
372
|
+
function todoFor(problem) {
|
|
373
|
+
return TODO_FOR[problem.code] ?? 'finish setting it up';
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* A set with some ids taken out, and the same set back when none were in it.
|
|
377
|
+
*
|
|
378
|
+
* The identity return is what stops `unstarted` becoming a new object on every
|
|
379
|
+
* edit to an unrelated node, which would re-run `partitionProblems` and rebuild
|
|
380
|
+
* every React Flow node for nothing.
|
|
381
|
+
*/
|
|
382
|
+
function without(set, ids) {
|
|
383
|
+
if (!ids.some((id) => set.has(id)))
|
|
384
|
+
return set;
|
|
385
|
+
const next = new Set(set);
|
|
386
|
+
for (const id of ids)
|
|
387
|
+
next.delete(id);
|
|
388
|
+
return next;
|
|
389
|
+
}
|
|
390
|
+
/** The nodes named by held-back checks, by the name the reader sees. */
|
|
391
|
+
function unfinishedNames(pending, nodes) {
|
|
392
|
+
const ids = new Set(pending.flatMap((problem) => problem.nodeIds));
|
|
393
|
+
return [...ids].map((id) => nodeLabelIn(nodes, id));
|
|
394
|
+
}
|
|
138
395
|
/**
|
|
139
396
|
* A server refusal, verbatim.
|
|
140
397
|
*
|
|
@@ -145,6 +402,32 @@ function newNodeOfKind(kind, id, position) {
|
|
|
145
402
|
function RefusalNote({ lead, error }) {
|
|
146
403
|
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
404
|
}
|
|
405
|
+
/**
|
|
406
|
+
* What pressing Save will do, in the three states it can be in.
|
|
407
|
+
*
|
|
408
|
+
* The middle case is the one that had to be added. "There are errors listed
|
|
409
|
+
* beside the canvas" is exactly wrong when the list beside the canvas is empty
|
|
410
|
+
* and the only thing standing in the way is a node nobody has finished — it
|
|
411
|
+
* sends somebody looking for a message that is not there. So that case names the
|
|
412
|
+
* nodes instead, and says the thing they most need to know: pressing Save is
|
|
413
|
+
* what stops the checks being held back.
|
|
414
|
+
*
|
|
415
|
+
* None of these say the server will refuse the graph any more, and that is a
|
|
416
|
+
* correction rather than a softening. Saving an unfinished graph SUCCEEDS — it
|
|
417
|
+
* is stored as a draft, which is the whole point of drafts existing. The
|
|
418
|
+
* refusal moved to publishing, so a hint that still promised one would be
|
|
419
|
+
* confidently wrong about the case it fires most often in.
|
|
420
|
+
*/
|
|
421
|
+
function saveHint(blocked, unfinished) {
|
|
422
|
+
if (unfinished.length > 0) {
|
|
423
|
+
const one = unfinished.length === 1;
|
|
424
|
+
return `Nothing is wrong yet, but ${one ? 'one node is' : `${unfinished.length} nodes are`} not finished: ${unfinished.join(', ')}. Saving keeps ${one ? 'it' : 'them'} exactly as ${one ? 'it is' : 'they are'} — the graph is stored as a draft, and the checks stop being held back the moment you press it.`;
|
|
425
|
+
}
|
|
426
|
+
if (blocked) {
|
|
427
|
+
return 'There are errors listed beside the canvas. Saving still works — the graph is kept as a draft, which is what a draft is for. It will not run until it is finished and published, and publishing is where these checks are answered for real.';
|
|
428
|
+
}
|
|
429
|
+
return "Store it. Publishing is what validates it, and the server's answer there is the one that counts.";
|
|
430
|
+
}
|
|
148
431
|
/**
|
|
149
432
|
* Save, run, delete.
|
|
150
433
|
*
|
|
@@ -154,11 +437,16 @@ function RefusalNote({ lead, error }) {
|
|
|
154
437
|
* graph nobody can save at all, with no error to read. The button is coloured to
|
|
155
438
|
* warn and the tooltip says what will happen; the refusal, when it comes, comes
|
|
156
439
|
* from the server with its reasons.
|
|
440
|
+
*
|
|
441
|
+
* `blocked` is asked about every check, including the ones held back from the
|
|
442
|
+
* error list while their node is still being worked on — so the colour never
|
|
443
|
+
* lags behind the graph. What `unfinished` changes is only what the tooltip
|
|
444
|
+
* *says*: "there are errors listed beside the canvas" would be a lie when the
|
|
445
|
+
* list beside the canvas is empty and the real answer is "two boxes are not
|
|
446
|
+
* finished", so that case gets its own sentence and names them.
|
|
157
447
|
*/
|
|
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 ||
|
|
448
|
+
function CanvasActions({ draft, canEdit, blocked, unfinished, saving, running, durabilityDetail, onSave, onRun, onAskDelete, }) {
|
|
449
|
+
return (_jsxs("div", { className: "flex flex-wrap items-start gap-2 self-end pb-1", children: [_jsx(Tooltip, { content: saveHint(blocked, unfinished), children: _jsxs("button", { type: "button", onClick: onSave, disabled: !canEdit ||
|
|
162
450
|
saving ||
|
|
163
451
|
draft.name.trim().length === 0 ||
|
|
164
452
|
(!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
|
|
@@ -215,12 +503,144 @@ function miniMapColor(data) {
|
|
|
215
503
|
* place of the screen, so the header and its controls stay put while a refetch
|
|
216
504
|
* resolves — and a failed read never looks like an empty workflow.
|
|
217
505
|
*/
|
|
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,
|
|
506
|
+
function GraphSurface({ loading, failed, error, onRetry, canEdit, draft, flowNodes, flowEdges, onInspect, onEditCode, onNodesChange, onEdgesChange, onConnect, isValidConnection, onConnectEnd, onNodeEnter, onNodeLeave, onPaneClick, nodeMenu, }) {
|
|
507
|
+
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, onNodeMouseEnter: (_event, node) => onNodeEnter(node.id), onNodeMouseLeave: onNodeLeave, onPaneClick: onPaneClick, connectionLineType: ConnectionLineType.SmoothStep, nodesDraggable: canEdit, nodesConnectable: canEdit, elementsSelectable: true, nodesFocusable: true, edgesFocusable: true, deleteKeyCode: canEdit ? ['Delete', 'Backspace'] : null,
|
|
220
508
|
// A wider drop zone than the 20px default, because these handles are
|
|
221
509
|
// the only drop target on the screen and missing one reads as the
|
|
222
510
|
// 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) })] }) }))] }));
|
|
511
|
+
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) }), nodeMenu] }) }))] }));
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* The wiring control that lives on a node, and the menu behind it.
|
|
515
|
+
*
|
|
516
|
+
* WHY THIS EXISTS
|
|
517
|
+
* ---------------
|
|
518
|
+
* Until this, the only way to make an edge on this canvas was to drag from one
|
|
519
|
+
* handle to another. That is React Flow's gesture, it is perfectly good, and it
|
|
520
|
+
* is invisible: nothing on the screen says the small circles are draggable, so
|
|
521
|
+
* the canvas worked for people who had used a node editor before and read as
|
|
522
|
+
* broken to everybody else. The wiring rail and the inspector's picker were the
|
|
523
|
+
* answers for keyboard users — they are still the answers for keyboard users —
|
|
524
|
+
* but reaching either means knowing to open a panel first.
|
|
525
|
+
*
|
|
526
|
+
* A control on the node, offering "connect to something that exists" and "make
|
|
527
|
+
* the next thing and connect it", is the ordinary affordance for this kind of
|
|
528
|
+
* editor. Its absence was the whole complaint.
|
|
529
|
+
*
|
|
530
|
+
* WHAT IT OFFERS
|
|
531
|
+
* --------------
|
|
532
|
+
* Only edges the graph allows, and it does not know which those are. Every
|
|
533
|
+
* option — existing target, new kind, all of it — is filtered by `canConnect`,
|
|
534
|
+
* the same function the drag is refused by. Offering an edge that is then
|
|
535
|
+
* rejected teaches somebody the menu is a guess; restating the node-kind rules
|
|
536
|
+
* here so the menu could be "smart" would be the same rules in a second place,
|
|
537
|
+
* which is how they drift.
|
|
538
|
+
*
|
|
539
|
+
* Disconnect is here too. Removing a wire otherwise means finding a two-pixel
|
|
540
|
+
* line on a canvas and pressing Delete, or scrolling the rail to the right row;
|
|
541
|
+
* the node is where somebody knows *which* wire they mean, so it is where the
|
|
542
|
+
* offer belongs.
|
|
543
|
+
*
|
|
544
|
+
* HOW IT IS PLACED
|
|
545
|
+
* ----------------
|
|
546
|
+
* `NodeToolbar` with an explicit `nodeId`, which is React Flow's documented way
|
|
547
|
+
* of rendering a toolbar for a node from outside that node's own component. So
|
|
548
|
+
* the position comes from the same measurements the canvas draws with, and this
|
|
549
|
+
* file does not do arithmetic on a viewport transform.
|
|
550
|
+
*/
|
|
551
|
+
function NodeWiringMenu({ node, draft, canEdit, open, onOpenChange, onHoverChange, onConnect, onConnectToNew, onDisconnect, }) {
|
|
552
|
+
if (!node || !canEdit)
|
|
553
|
+
return null;
|
|
554
|
+
const targets = draft.nodes.filter((candidate) => canConnect(draft.nodes, draft.edges, node.id, candidate.id).ok);
|
|
555
|
+
const kinds = newKindsFrom(node, draft.nodes, draft.edges);
|
|
556
|
+
const wires = draft.edges.filter((edge) => edge.from === node.id || edge.to === node.id);
|
|
557
|
+
const label = (id) => nodeLabelIn(draft.nodes, id);
|
|
558
|
+
return (_jsxs(NodeToolbar, { nodeId: node.id, isVisible: true, position: Position.Top, align: "end",
|
|
559
|
+
// Flush against the node. The pointer has to travel from the node to this
|
|
560
|
+
// toolbar to use it, and any gap is canvas — which means `onNodeMouseLeave`
|
|
561
|
+
// fires with nothing to catch it and the control vanishes on the way to
|
|
562
|
+
// itself. Touching, the leave and the enter land in the same React batch.
|
|
563
|
+
offset: 0, onMouseEnter: () => onHoverChange(true), onMouseLeave: () => onHoverChange(false), className: "flex flex-col items-end gap-1", children: [_jsx(Tooltip, { content: `Wire ${nodeName(node)} to something, or make the next node from it.`, children: _jsxs("button", { type: "button", onClick: () => onOpenChange(!open), "aria-expanded": open, "aria-haspopup": "menu", "aria-label": `Wire ${nodeName(node)}`, className: cn('flex items-center gap-1 rounded-md border px-1.5 py-1 text-[10px] shadow-sm', RULE, PANEL, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Link2, { size: 11 }), "Wire"] }) }), open && (_jsxs("div", { role: "menu", "aria-label": `Wiring for ${nodeName(node)}`, onKeyDown: (event) => {
|
|
564
|
+
if (event.key === 'Escape')
|
|
565
|
+
onOpenChange(false);
|
|
566
|
+
}, className: cn('w-60 rounded-md border p-1 text-left shadow-lg', RULE, PANEL,
|
|
567
|
+
// Above the nodes, which React Flow gives a z-index of their own.
|
|
568
|
+
'z-10'), children: [_jsx(MenuGroup, { title: "Send its output to", children: targets.length === 0 ? (_jsx(MenuNote, { children: node.kind === 'sink'
|
|
569
|
+
? 'A sink commits its rows. Nothing runs after one.'
|
|
570
|
+
: 'Nothing on the canvas can take its output yet. Make one below.' })) : (targets.map((target) => (_jsx(MenuItem, { onClick: () => {
|
|
571
|
+
onConnect(node.id, target.id);
|
|
572
|
+
onOpenChange(false);
|
|
573
|
+
}, icon: _jsx(ArrowRight, { size: 11, className: MUTED }), hint: target.kind, children: nodeName(target) }, target.id)))) }), kinds.length > 0 && (_jsx(MenuGroup, { title: "Or make one", children: kinds.map((kind) => (_jsxs(MenuItem, { onClick: () => onConnectToNew(node.id, kind), icon: _jsx(Plus, { size: 11, className: MUTED }), hint: "added and wired", children: ["New ", kind] }, kind))) })), wires.length > 0 && (_jsx(MenuGroup, { title: "Already wired", children: wires.map((edge) => (_jsxs(MenuItem, { onClick: () => {
|
|
574
|
+
onDisconnect(edge);
|
|
575
|
+
onOpenChange(false);
|
|
576
|
+
}, icon: _jsx(Unplug, { size: 11, className: MUTED }), hint: edge.from === node.id ? 'feeds' : 'fed by', children: ["Disconnect ", label(edge.from === node.id ? edge.to : edge.from)] }, edgeId(edge)))) }))] }))] }));
|
|
577
|
+
}
|
|
578
|
+
function MenuGroup({ title, children }) {
|
|
579
|
+
return (_jsxs("div", { className: "py-0.5", children: [_jsx("p", { className: cn('px-1.5 pb-0.5 font-mono text-[9px] uppercase tracking-[0.14em]', MUTED), children: title }), children] }));
|
|
580
|
+
}
|
|
581
|
+
function MenuNote({ children }) {
|
|
582
|
+
return _jsx("p", { className: cn('px-1.5 py-0.5 text-[11px] leading-relaxed', MUTED), children: children });
|
|
583
|
+
}
|
|
584
|
+
function MenuItem({ onClick, icon, hint, children, }) {
|
|
585
|
+
return (_jsxs("button", { type: "button", role: "menuitem", onClick: onClick, className: cn('flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left text-[11px]', 'hover:bg-zinc-100 dark:hover:bg-zinc-800'), children: [icon, _jsx("span", { className: "truncate", children: children }), _jsx("span", { className: cn('ml-auto shrink-0 font-mono text-[9px]', MUTED), children: hint })] }));
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Which node the wiring control is attached to right now.
|
|
589
|
+
*
|
|
590
|
+
* Three sources, in falling order of intent. An open menu wins outright — it was
|
|
591
|
+
* opened deliberately and must not close because the pointer moved. Then the
|
|
592
|
+
* node under the pointer, which is what makes the control discoverable at all.
|
|
593
|
+
* Then a single selected node, so the control is reachable without a pointer:
|
|
594
|
+
* hover-only affordances are invisible to anybody driving from the keyboard.
|
|
595
|
+
*
|
|
596
|
+
* A single selection only. Several selected nodes would mean several toolbars
|
|
597
|
+
* and a "wire this" offered against an ambiguous "this".
|
|
598
|
+
*/
|
|
599
|
+
function wiringAnchor(nodes, menuFor, hovered, selected) {
|
|
600
|
+
const wanted = menuFor ?? hovered ?? (selected.length === 1 ? selected[0] : null);
|
|
601
|
+
return nodes.find((node) => node.id === wanted) ?? null;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Which node the wiring control is on, and everything that moves it.
|
|
605
|
+
*
|
|
606
|
+
* Two pieces of state and not one, and that is the whole subtlety. `hovered` is
|
|
607
|
+
* what makes the control discoverable — a small button appearing on the node
|
|
608
|
+
* under the pointer is the ordinary affordance for this kind of editor, and its
|
|
609
|
+
* absence is the entire reason this canvas felt like it needed prior knowledge
|
|
610
|
+
* of React Flow. `openFor` is what keeps the menu open once it has been opened,
|
|
611
|
+
* because the pointer has to leave the node to reach the menu's own items, and a
|
|
612
|
+
* menu that closed on the way to itself would be unusable.
|
|
613
|
+
*
|
|
614
|
+
* A hook rather than four `useState` calls in the canvas, because these five
|
|
615
|
+
* handlers only make sense together: every one of them is "and therefore the
|
|
616
|
+
* anchor is now …", and split across a 700-line component they read as five
|
|
617
|
+
* unrelated setters.
|
|
618
|
+
*/
|
|
619
|
+
function useWiringMenu(nodes, selectedNodeIds) {
|
|
620
|
+
const [hovered, setHovered] = useState(null);
|
|
621
|
+
const [openFor, setOpenFor] = useState(null);
|
|
622
|
+
const anchor = wiringAnchor(nodes, openFor, hovered, selectedNodeIds);
|
|
623
|
+
const anchorId = anchor?.id ?? null;
|
|
624
|
+
const onNodeLeave = useCallback(() => setHovered(null), []);
|
|
625
|
+
const close = useCallback(() => setOpenFor(null), []);
|
|
626
|
+
const reset = useCallback(() => {
|
|
627
|
+
setOpenFor(null);
|
|
628
|
+
setHovered(null);
|
|
629
|
+
}, []);
|
|
630
|
+
return {
|
|
631
|
+
anchor,
|
|
632
|
+
open: openFor !== null && openFor === anchorId,
|
|
633
|
+
onNodeEnter: setHovered,
|
|
634
|
+
onNodeLeave,
|
|
635
|
+
close,
|
|
636
|
+
reset,
|
|
637
|
+
onOpenChange: (next) => setOpenFor(next ? anchorId : null),
|
|
638
|
+
onHoverChange: (hovering) => setHovered(hovering ? anchorId : null),
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
/** The problems naming one node, or none when no node is open. */
|
|
642
|
+
function problemsOf(byNode, node) {
|
|
643
|
+
return node ? (byNode.get(node.id) ?? []) : [];
|
|
224
644
|
}
|
|
225
645
|
/** A node's display name, falling back to its id when it is not in the graph. */
|
|
226
646
|
function nodeLabelIn(nodes, id) {
|
|
@@ -291,6 +711,15 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
291
711
|
const [editingCodeFor, setEditingCodeFor] = useState(null);
|
|
292
712
|
const [confirmingDelete, setConfirmingDelete] = useState(false);
|
|
293
713
|
const [run, setRun] = useState(null);
|
|
714
|
+
/**
|
|
715
|
+
* Nodes added in this session that nobody has done anything to yet.
|
|
716
|
+
*
|
|
717
|
+
* The whole argument is on `partitionProblems`. What matters here is that this
|
|
718
|
+
* is component state and nothing else: it is not saved, not sent, and not
|
|
719
|
+
* restored, because a node that arrives from the server is by definition one
|
|
720
|
+
* somebody finished with.
|
|
721
|
+
*/
|
|
722
|
+
const [unstarted, setUnstarted] = useState(() => new Set());
|
|
294
723
|
/**
|
|
295
724
|
* The last thing the canvas refused, and the last thing it did.
|
|
296
725
|
*
|
|
@@ -299,6 +728,7 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
299
728
|
* screen is silence too.
|
|
300
729
|
*/
|
|
301
730
|
const [announcement, setAnnouncement] = useState('');
|
|
731
|
+
const menu = useWiringMenu(draft.nodes, selectedNodeIds);
|
|
302
732
|
/**
|
|
303
733
|
* Which workflow the draft was built from.
|
|
304
734
|
*
|
|
@@ -322,7 +752,11 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
322
752
|
setSelectedEdgeIds([]);
|
|
323
753
|
setInspecting(null);
|
|
324
754
|
setRun(null);
|
|
325
|
-
|
|
755
|
+
// Everything in a freshly loaded draft came off the server, so nothing in it
|
|
756
|
+
// is "not finished yet" — see `partitionProblems`.
|
|
757
|
+
setUnstarted(new Set());
|
|
758
|
+
menu.reset();
|
|
759
|
+
}, [workflows.data, selected, menu.reset]);
|
|
326
760
|
// Fit after the graph swaps, on the frame after the new nodes have been laid
|
|
327
761
|
// out. Calling it in the same tick fits an empty canvas, because React Flow
|
|
328
762
|
// has not measured anything yet.
|
|
@@ -340,8 +774,18 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
340
774
|
}, []);
|
|
341
775
|
const transformIds = useMemo(() => new Set(transforms.map((transform) => transform.id)), [transforms]);
|
|
342
776
|
const problems = useMemo(() => validateWorkflow({ nodes: draft.nodes, edges: draft.edges }, { transformIds }), [draft.nodes, draft.edges, transformIds]);
|
|
343
|
-
|
|
344
|
-
|
|
777
|
+
/**
|
|
778
|
+
* The same checks, split by whether the node they name is finished.
|
|
779
|
+
*
|
|
780
|
+
* `live` is what the canvas draws in red and what the Problems list says.
|
|
781
|
+
* `pending` is the same data presented as outstanding work. Nothing is thrown
|
|
782
|
+
* away — see `partitionProblems`, and note that `blocked` below is still
|
|
783
|
+
* computed from `problems`, not from `live`.
|
|
784
|
+
*/
|
|
785
|
+
const { live, pending } = useMemo(() => partitionProblems(problems, unstarted), [problems, unstarted]);
|
|
786
|
+
const problemsFor = useMemo(() => problemsByNode(live), [live]);
|
|
787
|
+
const pendingFor = useMemo(() => problemsByNode(pending), [pending]);
|
|
788
|
+
const brokenEdgeIds = useMemo(() => new Set(live.flatMap((problem) => problem.edgeIds)), [live]);
|
|
345
789
|
const runFor = useMemo(() => new Map((run?.nodes ?? []).map((node) => [node.nodeId, node])), [run]);
|
|
346
790
|
const describe = useMemo(() => ({
|
|
347
791
|
transformName: (id) => (id ? transforms.find((t) => t.id === id)?.name : undefined),
|
|
@@ -389,6 +833,10 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
389
833
|
edges: current.edges.filter((edge) => !removed.has(edge.from) && !removed.has(edge.to)),
|
|
390
834
|
}));
|
|
391
835
|
if (removed.size > 0) {
|
|
836
|
+
// Housekeeping, not a rule: a node that no longer exists cannot be
|
|
837
|
+
// unfinished, and leaving its id behind would hold back a later node
|
|
838
|
+
// that happened to be given the same one.
|
|
839
|
+
setUnstarted((current) => without(current, [...removed]));
|
|
392
840
|
setAnnouncement(`${removed.size} node${removed.size === 1 ? '' : 's'} removed, along with their connections.`);
|
|
393
841
|
}
|
|
394
842
|
}, [edit]);
|
|
@@ -403,14 +851,26 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
403
851
|
}));
|
|
404
852
|
setAnnouncement(`${removed.size} connection${removed.size === 1 ? '' : 's'} removed.`);
|
|
405
853
|
}, [edit]);
|
|
854
|
+
/**
|
|
855
|
+
* Somebody has acted on these nodes, so their checks stop being held back.
|
|
856
|
+
*
|
|
857
|
+
* Called from every path that changes a node or its wiring *after* it exists.
|
|
858
|
+
* Deliberately not called for a position change: dragging a box arranges the
|
|
859
|
+
* picture and says nothing about whether its author is done with it, and none
|
|
860
|
+
* of the checks read a position anyway.
|
|
861
|
+
*/
|
|
862
|
+
const markStarted = useCallback((...ids) => {
|
|
863
|
+
setUnstarted((current) => without(current, ids));
|
|
864
|
+
}, []);
|
|
406
865
|
const disconnect = useCallback((edge) => {
|
|
407
866
|
const id = edgeId(edge);
|
|
408
867
|
edit((current) => ({
|
|
409
868
|
...current,
|
|
410
869
|
edges: current.edges.filter((candidate) => edgeId(candidate) !== id),
|
|
411
870
|
}));
|
|
871
|
+
markStarted(edge.from, edge.to);
|
|
412
872
|
setAnnouncement('Connection removed.');
|
|
413
|
-
}, [edit]);
|
|
873
|
+
}, [edit, markStarted]);
|
|
414
874
|
const connect = useCallback((from, to) => {
|
|
415
875
|
const verdict = canConnect(draft.nodes, draft.edges, from, to);
|
|
416
876
|
if (!verdict.ok) {
|
|
@@ -421,8 +881,9 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
421
881
|
// edges receives its inputs in the order the edges appear in this array,
|
|
422
882
|
// and that order is part of what the graph produces.
|
|
423
883
|
edit((current) => ({ ...current, edges: [...current.edges, { from, to }] }));
|
|
884
|
+
markStarted(from, to);
|
|
424
885
|
setAnnouncement(`${nodeLabelIn(draft.nodes, from)} now feeds ${nodeLabelIn(draft.nodes, to)}.`);
|
|
425
|
-
}, [draft.nodes, draft.edges, edit]);
|
|
886
|
+
}, [draft.nodes, draft.edges, edit, markStarted]);
|
|
426
887
|
const onConnect = useCallback((connection) => {
|
|
427
888
|
// Narrowed rather than trusted: React Flow types both ends as `string`
|
|
428
889
|
// but a connection dropped on empty canvas arrives with no target on
|
|
@@ -493,6 +954,53 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
493
954
|
: `The run ${result.status}. ${result.error ?? ''}`);
|
|
494
955
|
},
|
|
495
956
|
});
|
|
957
|
+
/**
|
|
958
|
+
* Write the first transform without leaving the canvas.
|
|
959
|
+
*
|
|
960
|
+
* The detour this removes: leave the graph, go to Transforms, write one, come
|
|
961
|
+
* back, find the node again, pick it. On a deployment with no transforms at
|
|
962
|
+
* all that detour was not a convenience problem — the picker offered a choice
|
|
963
|
+
* that did not exist and the screen gave no hint that the way out was on
|
|
964
|
+
* another tab.
|
|
965
|
+
*
|
|
966
|
+
* Created here rather than by opening `TransformEditor` empty, because the
|
|
967
|
+
* editor reports that it saved and not *what* it saved: its `onSaved` takes no
|
|
968
|
+
* argument, so the canvas would have no id to put on the node and the person
|
|
969
|
+
* would come back to the same empty picker. One `saveTransform` gives an id,
|
|
970
|
+
* which goes on the node, and the editor then opens on a transform that
|
|
971
|
+
* exists.
|
|
972
|
+
*
|
|
973
|
+
* The new transform is named after the node so the two are findable from each
|
|
974
|
+
* other, and its code is the identity — return the batch unchanged. That runs,
|
|
975
|
+
* commits, and is the smallest thing that is not a placeholder;
|
|
976
|
+
* `TransformEditor`'s own starters teach the shape of a mapping and belong
|
|
977
|
+
* where somebody chose to write one, not where somebody clicked past a dead
|
|
978
|
+
* end.
|
|
979
|
+
*/
|
|
980
|
+
const createTransform = useMutation({
|
|
981
|
+
mutationFn: async (nodeId) => {
|
|
982
|
+
const created = await client.saveTransform(starterTransform(draft.nodes.find((candidate) => candidate.id === nodeId), capabilities?.languages));
|
|
983
|
+
return { nodeId, created };
|
|
984
|
+
},
|
|
985
|
+
onSuccess: ({ nodeId, created }) => {
|
|
986
|
+
edit((current) => ({
|
|
987
|
+
...current,
|
|
988
|
+
nodes: runningTransform(current.nodes, nodeId, created.id),
|
|
989
|
+
}));
|
|
990
|
+
markStarted(nodeId);
|
|
991
|
+
// Written into the cache as well as invalidated: the code sheet below
|
|
992
|
+
// resolves the transform out of this list, and opening it before the
|
|
993
|
+
// refetch lands would tell somebody the node names no transform one click
|
|
994
|
+
// after they created one.
|
|
995
|
+
queryClient.setQueryData(catalogQueryKeys.transforms, (current) => [
|
|
996
|
+
...(current ?? []),
|
|
997
|
+
created,
|
|
998
|
+
]);
|
|
999
|
+
queryClient.invalidateQueries({ queryKey: catalogQueryKeys.transforms });
|
|
1000
|
+
setEditingCodeFor(nodeId);
|
|
1001
|
+
setAnnouncement(`"${created.name}" was created and this node now runs it. Its code is open — it returns the batch unchanged until you change it.`);
|
|
1002
|
+
},
|
|
1003
|
+
});
|
|
496
1004
|
const remove = useMutation({
|
|
497
1005
|
mutationFn: (id) => client.deleteWorkflow(id),
|
|
498
1006
|
onSuccess: () => {
|
|
@@ -505,12 +1013,48 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
505
1013
|
const addNode = useCallback((kind) => {
|
|
506
1014
|
const id = newLocalId(kind);
|
|
507
1015
|
setDraft((current) => {
|
|
508
|
-
const node = newNodeOfKind(kind, id, nextPosition(current.nodes));
|
|
1016
|
+
const node = newNodeOfKind(kind, id, nextPosition(current.nodes), uniqueName(current.nodes, kind));
|
|
509
1017
|
return { ...current, nodes: [...current.nodes, node], dirty: true };
|
|
510
1018
|
});
|
|
1019
|
+
setUnstarted((current) => new Set([...current, id]));
|
|
511
1020
|
setInspecting(id);
|
|
512
1021
|
setAnnouncement(`A ${kind} node was added. Its inspector is open.`);
|
|
513
1022
|
}, []);
|
|
1023
|
+
/**
|
|
1024
|
+
* Make the next node and wire it in, as one action.
|
|
1025
|
+
*
|
|
1026
|
+
* The thing the canvas could not do. Adding a node and connecting it were two
|
|
1027
|
+
* separate gestures, the second of which was a drag between two handles — an
|
|
1028
|
+
* interaction that is perfectly discoverable to somebody who already knows it
|
|
1029
|
+
* is there, and invisible to everybody else.
|
|
1030
|
+
*
|
|
1031
|
+
* The edge made here is part of the node's *creation*, which is why the new
|
|
1032
|
+
* node still goes into `unstarted`: nobody has acted on it, they have only
|
|
1033
|
+
* brought it into being. Wiring it *afterwards* is what counts as acting on
|
|
1034
|
+
* it, and that path goes through `connect`.
|
|
1035
|
+
*
|
|
1036
|
+
* The verdict is asked even though the menu only offers legal kinds, because
|
|
1037
|
+
* the menu asking one question and the action taking another answer is the
|
|
1038
|
+
* class of bug that puts an illegal edge in a saved graph.
|
|
1039
|
+
*/
|
|
1040
|
+
const connectToNew = useCallback((fromId, kind) => {
|
|
1041
|
+
const made = nodeWiredFrom(draft, fromId, kind);
|
|
1042
|
+
if (!made.ok) {
|
|
1043
|
+
if (made.reason)
|
|
1044
|
+
setAnnouncement(made.reason);
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
const { node, from } = made;
|
|
1048
|
+
edit((current) => ({
|
|
1049
|
+
...current,
|
|
1050
|
+
nodes: [...current.nodes, node],
|
|
1051
|
+
edges: [...current.edges, { from: fromId, to: node.id }],
|
|
1052
|
+
}));
|
|
1053
|
+
setUnstarted((current) => new Set([...current, node.id]));
|
|
1054
|
+
menu.close();
|
|
1055
|
+
setInspecting(node.id);
|
|
1056
|
+
setAnnouncement(`${nodeName(node)} was added and ${nodeName(from)} now feeds it. Its inspector is open.`);
|
|
1057
|
+
}, [draft, edit, menu.close]);
|
|
514
1058
|
const tidy = useCallback(() => {
|
|
515
1059
|
edit((current) => ({
|
|
516
1060
|
...current,
|
|
@@ -520,7 +1064,32 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
520
1064
|
setAnnouncement('The nodes were laid out left to right by dependency, with every sink in the last column.');
|
|
521
1065
|
}, [edit, fitView]);
|
|
522
1066
|
const durability = describeDurability(capabilities?.durable);
|
|
1067
|
+
// Asked about EVERY problem, not about `live`. This is the guarantee: a graph
|
|
1068
|
+
// that would silently do nothing is coloured as unsaveable from the moment it
|
|
1069
|
+
// becomes one, whether or not the node responsible is still being worked on.
|
|
523
1070
|
const blocked = hasBlockingProblem(problems);
|
|
1071
|
+
/**
|
|
1072
|
+
* The nodes standing between this graph and a save that would be accepted,
|
|
1073
|
+
* where the only thing wrong with them is that they are not finished.
|
|
1074
|
+
*
|
|
1075
|
+
* Named so the save tooltip can point at them. A button that goes amber
|
|
1076
|
+
* without saying which box to go and look at is the same failure as a message
|
|
1077
|
+
* that names an id.
|
|
1078
|
+
*/
|
|
1079
|
+
const unfinished = useMemo(() => unfinishedNames(pending, draft.nodes), [pending, draft.nodes]);
|
|
1080
|
+
/**
|
|
1081
|
+
* Save says "I think this is finished", so nothing is held back after it.
|
|
1082
|
+
*
|
|
1083
|
+
* Cleared before the request rather than in `onSuccess` or `onError`, because
|
|
1084
|
+
* the point is not what the server answers — it is that the person has
|
|
1085
|
+
* declared the graph done, which is exactly the condition under which every
|
|
1086
|
+
* check's own wording becomes the right wording. If the server refuses, the
|
|
1087
|
+
* reasons are already on screen in full beside its refusal.
|
|
1088
|
+
*/
|
|
1089
|
+
const saveNow = useCallback(() => {
|
|
1090
|
+
setUnstarted(new Set());
|
|
1091
|
+
save.mutate();
|
|
1092
|
+
}, [save]);
|
|
524
1093
|
const inspectingNode = draft.nodes.find((node) => node.id === inspecting) ?? null;
|
|
525
1094
|
const editingNode = draft.nodes.find((node) => node.id === editingCodeFor);
|
|
526
1095
|
const editingTransform = editingNode?.kind === 'transform'
|
|
@@ -556,10 +1125,15 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
556
1125
|
_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) => {
|
|
557
1126
|
loadedRef.current = null;
|
|
558
1127
|
setSelected(value);
|
|
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:
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
1128
|
+
}, 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, unfinished: unfinished, saving: save.isPending, running: runIt.isPending, durabilityDetail: durability.detail, onSave: saveNow, 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, onNodeEnter: menu.onNodeEnter, onNodeLeave: menu.onNodeLeave, onPaneClick: menu.close, nodeMenu: _jsx(NodeWiringMenu, { node: menu.anchor, draft: draft, canEdit: canEdit, open: menu.open, onOpenChange: menu.onOpenChange, onHoverChange: menu.onHoverChange, onConnect: connect, onConnectToNew: connectToNew, onDisconnect: disconnect }) }), _jsx(WiringRail, { draft: draft, problems: live, pending: pending, 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: problemsOf(problemsFor, inspectingNode), pending: problemsOf(pendingFor, inspectingNode), onClose: () => setInspecting(null), onChange: (next) => {
|
|
1129
|
+
// Editing any field is the clearest statement there is that somebody
|
|
1130
|
+
// is working on this node rather than looking at one they just made.
|
|
1131
|
+
markStarted(next.id);
|
|
1132
|
+
edit((current) => ({
|
|
1133
|
+
...current,
|
|
1134
|
+
nodes: current.nodes.map((node) => (node.id === next.id ? next : node)),
|
|
1135
|
+
}));
|
|
1136
|
+
}, onConnect: connect, onConnectToNew: connectToNew, onDisconnect: disconnect, onCreateTransform: (nodeId) => createTransform.mutate(nodeId), creatingTransform: createTransform.isPending, createTransformError: createTransform.error, onDelete: (nodeId) => {
|
|
563
1137
|
edit((current) => ({
|
|
564
1138
|
...current,
|
|
565
1139
|
nodes: current.nodes.filter((node) => node.id !== nodeId),
|
|
@@ -578,7 +1152,7 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
|
|
|
578
1152
|
} })) : (_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) })] }));
|
|
579
1153
|
}
|
|
580
1154
|
function AddButton({ icon: Icon, label, hint, onClick, }) {
|
|
581
|
-
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] }) }));
|
|
1155
|
+
return (_jsx(Tooltip, { content: hint, children: _jsxs("button", { type: "button", onClick: onClick, "aria-label": `Add a ${label.toLowerCase()} node`, 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] }) }));
|
|
582
1156
|
}
|
|
583
1157
|
/**
|
|
584
1158
|
* Whether a failed run resumes or restarts, stated on the screen that implies
|
|
@@ -623,7 +1197,7 @@ function CanvasFailure({ error, onRetry, }) {
|
|
|
623
1197
|
* The problems list sits in the same rail for the same reason: a red ring
|
|
624
1198
|
* around a node off the left edge of the viewport communicates nothing.
|
|
625
1199
|
*/
|
|
626
|
-
function WiringRail({ draft, problems, run, canEdit, onInspect, onDisconnect, }) {
|
|
1200
|
+
function WiringRail({ draft, problems, pending, run, canEdit, onInspect, onDisconnect, }) {
|
|
627
1201
|
const label = (id) => {
|
|
628
1202
|
const node = draft.nodes.find((n) => n.id === id);
|
|
629
1203
|
return node ? nodeName(node) : id;
|
|
@@ -631,7 +1205,7 @@ function WiringRail({ draft, problems, run, canEdit, onInspect, onDisconnect, })
|
|
|
631
1205
|
const errors = problems.filter((problem) => problem.level === 'error');
|
|
632
1206
|
const warnings = problems.filter((problem) => problem.level === 'warning');
|
|
633
1207
|
const sinks = draft.nodes.filter((node) => node.kind === 'sink');
|
|
634
|
-
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) => {
|
|
1208
|
+
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)))) }))] }), _jsx(PendingWork, { pending: pending, label: label, onInspect: onInspect }), _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) => {
|
|
635
1209
|
const outcome = run.nodes.find((node) => node.nodeId === sink.id);
|
|
636
1210
|
const type = sink.kind === 'sink' && sink.targetType ? sink.targetType : 'no type';
|
|
637
1211
|
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'
|
|
@@ -645,6 +1219,26 @@ function WiringRail({ draft, problems, run, canEdit, onInspect, onDisconnect, })
|
|
|
645
1219
|
: 'no outcome recorded' })] }, sink.id));
|
|
646
1220
|
}) }), _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 })] }))] }));
|
|
647
1221
|
}
|
|
1222
|
+
/**
|
|
1223
|
+
* What is left to do on the nodes nobody has finished.
|
|
1224
|
+
*
|
|
1225
|
+
* The same checks as the Problems list below it, and deliberately not the same
|
|
1226
|
+
* words. Grouped by node rather than listed one per check, because "Sink" with
|
|
1227
|
+
* two things outstanding is one piece of work, not two complaints — and because
|
|
1228
|
+
* the group heading is the node's name, which is what somebody needs in order to
|
|
1229
|
+
* go and find it.
|
|
1230
|
+
*
|
|
1231
|
+
* Rendered as nothing at all when there is nothing outstanding, rather than as
|
|
1232
|
+
* an empty panel: a heading that is permanently on screen with "nothing here"
|
|
1233
|
+
* under it is a heading that stops being read, and this one has to be noticed on
|
|
1234
|
+
* the occasions it is not empty.
|
|
1235
|
+
*/
|
|
1236
|
+
function PendingWork({ pending, label, onInspect, }) {
|
|
1237
|
+
const byNode = useMemo(() => problemsByNode(pending), [pending]);
|
|
1238
|
+
if (byNode.size === 0)
|
|
1239
|
+
return null;
|
|
1240
|
+
return (_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: "Still to do" }), _jsx("ul", { className: "mt-2 space-y-1.5", children: [...byNode.entries()].map(([nodeId, items]) => (_jsxs("li", { className: "flex gap-1.5 text-[11px] leading-relaxed", children: [_jsx(CircleDashed, { size: 11, className: cn('mt-0.5 shrink-0', MUTED) }), _jsxs("span", { children: [_jsx("button", { type: "button", onClick: () => onInspect(nodeId), className: "font-medium hover:underline", children: label(nodeId) }), _jsxs("span", { className: MUTED, children: [' — ', items.map((problem) => todoFor(problem)).join('; '), "."] })] })] }, nodeId))) }), _jsx("p", { className: cn('mt-2 text-[10px] leading-relaxed', MUTED), children: "These are not problems yet \u2014 a node that was just added is unwired and unconfigured by construction. They are checked in full the moment you save." })] }));
|
|
1241
|
+
}
|
|
648
1242
|
/**
|
|
649
1243
|
* One end of a node's wiring — everything feeding it, or everything it feeds.
|
|
650
1244
|
*
|
|
@@ -655,13 +1249,44 @@ function WiringRail({ draft, problems, run, canEdit, onInspect, onDisconnect, })
|
|
|
655
1249
|
function WiringList({ title, edges, otherEnd, describeRemoval, canEdit, onDisconnect, children, }) {
|
|
656
1250
|
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
1251
|
}
|
|
658
|
-
/**
|
|
659
|
-
|
|
660
|
-
|
|
1252
|
+
/**
|
|
1253
|
+
* Which code runs here, and a way into it.
|
|
1254
|
+
*
|
|
1255
|
+
* THE TWO THINGS THIS SCREEN KEPT CONFLATING
|
|
1256
|
+
* ------------------------------------------
|
|
1257
|
+
* A reader's complaint, verbatim: "the transform node needs another transform,
|
|
1258
|
+
* it reads a bit strange". They are right, and the model is not wrong — a
|
|
1259
|
+
* `CatalogTransform` is named, reusable code, deliberately shared between
|
|
1260
|
+
* connectors and graphs, and a node is a *position* in a graph that runs some.
|
|
1261
|
+
* Two different things. What made them look like one thing was this form: a
|
|
1262
|
+
* field called "Transform", inside a sheet describing a transform node, asking
|
|
1263
|
+
* you to choose a Transform.
|
|
1264
|
+
*
|
|
1265
|
+
* The field is therefore labelled by what it asks for — the code — and says in
|
|
1266
|
+
* one line why the two are separate. What is deliberately **not** done is
|
|
1267
|
+
* renaming the node: `defaultLabel` and the badge the node draws itself with
|
|
1268
|
+
* both live in `workflow/`, so a rename here would produce a step called "Step"
|
|
1269
|
+
* wearing a badge that says TRANSFORM, which is the same disease with an extra
|
|
1270
|
+
* word in it. One vocabulary or the other, and half of it is not reachable from
|
|
1271
|
+
* this file.
|
|
1272
|
+
*
|
|
1273
|
+
* A FRESH CATALOG
|
|
1274
|
+
* ---------------
|
|
1275
|
+
* With no transforms stored, the old form offered "Choose a transform…" over an
|
|
1276
|
+
* empty list, and a disabled "Open the code" that `opacity-40` did not make look
|
|
1277
|
+
* disabled. So the screen presented a promise it could not keep and a control
|
|
1278
|
+
* that answered clicks with silence, on a node somebody had added ten seconds
|
|
1279
|
+
* earlier. Now: the empty case says it is empty and offers the way out, and the
|
|
1280
|
+
* code button is not rendered at all until there is code behind it — a control
|
|
1281
|
+
* that cannot act is better absent than present and inert.
|
|
1282
|
+
*/
|
|
1283
|
+
function TransformInspector({ node, transforms, canEdit, creating, createError, onChange, onEditCode, onCreate, }) {
|
|
1284
|
+
const empty = transforms.length === 0;
|
|
1285
|
+
return (_jsxs("div", { className: "space-y-2", children: [empty ? (_jsx("div", { className: cn('rounded-md border p-2', RULE), children: _jsx("p", { className: "text-[11px] leading-relaxed", children: "There are no transforms in this catalog yet, so there is nothing to choose. Make one here and its code opens straight away \u2014 it is stored on its own, and other steps and connectors can run it afterwards." }) })) : (_jsx(SelectField, { label: "Code it runs", ariaLabel: "Which transform's code runs at this step", value: node.transformId, onValueChange: (transformId) => onChange({ ...node, transformId }), options: transforms.map((transform) => ({
|
|
661
1286
|
value: transform.id,
|
|
662
1287
|
label: transform.name,
|
|
663
1288
|
hint: `${transform.language} · v${transform.version}`,
|
|
664
|
-
})), placeholder: "Choose
|
|
1289
|
+
})), placeholder: "Choose the code\u2026", disabled: !canEdit, hint: "A transform is named code, stored on its own so a connector and several steps can run the same one. This node is a position in the graph; choosing here says which code runs at it, and does not copy it." })), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [node.transformId.length > 0 && (_jsxs("button", { type: "button", onClick: () => onEditCode(node.id), 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(Code2, { size: 12 }), "Open the code"] })), canEdit && (_jsxs("button", { type: "button", onClick: () => onCreate(node.id), disabled: creating, 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: [creating ? _jsx(Loader2, { size: 12, className: "animate-spin" }) : _jsx(Plus, { size: 12 }), empty ? 'Write the first transform' : 'New transform'] }))] }), createError ? _jsx(RefusalNote, { lead: "It could not be created:", error: createError }) : null] }));
|
|
665
1290
|
}
|
|
666
1291
|
/**
|
|
667
1292
|
* What this sink commits, and whether it replaces or merges.
|
|
@@ -678,7 +1303,7 @@ function SinkInspector({ node, typeOptions, canEdit, onChange, }) {
|
|
|
678
1303
|
{ value: 'incremental', label: 'Incremental — merge into it' },
|
|
679
1304
|
], 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
1305
|
}
|
|
681
|
-
function NodeInspector({ node, draft, transforms, connections, typeOptions, canEdit, problems, onClose, onChange, onConnect, onDisconnect, onDelete, onEditCode, }) {
|
|
1306
|
+
function NodeInspector({ node, draft, transforms, connections, typeOptions, canEdit, problems, pending, onClose, onChange, onConnect, onConnectToNew, onDisconnect, onDelete, onEditCode, onCreateTransform, creatingTransform, createTransformError, }) {
|
|
682
1307
|
const [pendingTarget, setPendingTarget] = useState('');
|
|
683
1308
|
const label = (id) => {
|
|
684
1309
|
const found = draft.nodes.find((n) => n.id === id);
|
|
@@ -706,10 +1331,20 @@ function NodeInspector({ node, draft, transforms, connections, typeOptions, canE
|
|
|
706
1331
|
hint: candidate.kind,
|
|
707
1332
|
}));
|
|
708
1333
|
}, [node, draft.nodes, draft.edges]);
|
|
1334
|
+
/**
|
|
1335
|
+
* The keyboard half of "make the next node and wire it".
|
|
1336
|
+
*
|
|
1337
|
+
* The canvas menu is a pointer affordance and cannot be anything else, so the
|
|
1338
|
+
* action it introduced has to exist here too or it is an action half the
|
|
1339
|
+
* people using this screen cannot reach. Same function, same rules — the kinds
|
|
1340
|
+
* come from `newKindsFrom`, which asks `canConnect` rather than restating what
|
|
1341
|
+
* may follow what.
|
|
1342
|
+
*/
|
|
1343
|
+
const newKinds = useMemo(() => (node ? newKindsFrom(node, draft.nodes, draft.edges) : []), [node, draft.nodes, draft.edges]);
|
|
709
1344
|
return (_jsx(Sheet, { open: node !== null, onOpenChange: (open) => {
|
|
710
1345
|
if (!open)
|
|
711
1346
|
onClose();
|
|
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
|
|
1347
|
+
}, 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))) })), pending.length > 0 && (_jsxs("div", { className: cn('rounded-md border p-2', RULE), children: [_jsx("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Still to do" }), _jsx("ul", { className: "mt-1 space-y-0.5", children: pending.map((problem) => (_jsx("li", { className: "text-[11px] leading-relaxed", children: todoFor(problem) }, 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, creating: creatingTransform, createError: createTransformError, onChange: onChange, onEditCode: onEditCode, onCreate: onCreateTransform })), node.kind === 'source' && (_jsx(SourceInspector
|
|
713
1348
|
// Keyed so the text fields reset when a different source is
|
|
714
1349
|
// opened. Without it the draft state would survive the swap and
|
|
715
1350
|
// one node's URL would appear inside another.
|
|
@@ -720,7 +1355,7 @@ function NodeInspector({ node, draft, transforms, connections, typeOptions, canE
|
|
|
720
1355
|
return;
|
|
721
1356
|
onConnect(node.id, pendingTarget);
|
|
722
1357
|
setPendingTarget('');
|
|
723
|
-
}, 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"] }))] })) }));
|
|
1358
|
+
}, 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" })] })), canEdit && newKinds.length > 0 && (_jsx("div", { className: "mt-2 flex flex-wrap items-center gap-1.5", children: newKinds.map((kind) => (_jsxs("button", { type: "button", onClick: () => onConnectToNew(node.id, kind), className: cn('flex items-center gap-1 rounded-md border px-2 py-1 text-[11px]', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Plus, { size: 10 }), "New ", kind] }, kind))) })), _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. \"New\" makes one and wires it in the same action, one column to the right of this node." })] }), 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"] }))] })) }));
|
|
724
1359
|
}
|
|
725
1360
|
/**
|
|
726
1361
|
* Where a source reads from.
|
|
@@ -790,5 +1425,5 @@ function SourceInspector({ node, connections, canEdit, onChange, }) {
|
|
|
790
1425
|
? 'No connections of this kind yet. One is worth making when a second source needs the same address.'
|
|
791
1426
|
: viaConnection
|
|
792
1427
|
? 'The connection supplies the address and the credential. What stays below is only what is specific to this load.'
|
|
793
|
-
: 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 }),
|
|
1428
|
+
: 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 }), 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." }))] }));
|
|
794
1429
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-catalog-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Ready-made React screens for @dudousxd/nestjs-catalog — a model manager and a generic object explorer you can drop into your own app shell.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davide Carvalho",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"@tiptap/pm": "3.29.2",
|
|
107
107
|
"tiptap-markdown": "0.9.0",
|
|
108
108
|
"@tiptap/core": "3.29.2",
|
|
109
|
-
"@dudousxd/nestjs-catalog": "0.
|
|
109
|
+
"@dudousxd/nestjs-catalog": "0.11.0"
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"clsx": "2.1.1",
|