@dudousxd/nestjs-catalog-react 0.30.0 → 0.32.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/WorkflowCanvas.js +226 -2
- package/dist/workflow/create.js +48 -0
- package/dist/workflow/graph.js +59 -1
- package/dist/workflow/model.d.ts +2 -2
- package/dist/workflow/model.js +17 -3
- package/dist/workflow/nodes.js +28 -1
- package/dist/workflow/templates.js +21 -0
- package/package.json +2 -2
package/dist/WorkflowCanvas.js
CHANGED
|
@@ -7,7 +7,7 @@ import { Background, BackgroundVariant, ConnectionLineType, Controls, MiniMap, P
|
|
|
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, ChevronDown, CircleAlert, CircleDashed, Code2, Database, ExternalLink, Filter, GitBranch, Info, LayoutGrid, Loader2, Maximize2, Minimize2, PanelRight, Plug, Plus, Repeat, Save, TextCursorInput, Trash2, TriangleAlert, Unplug, X, } from 'lucide-react';
|
|
10
|
+
import { ArrowRight, ChevronDown, CircleAlert, CircleDashed, Code2, Combine, Database, ExternalLink, Filter, GitBranch, Info, LayoutGrid, Loader2, Maximize2, Minimize2, PanelRight, Plug, Plus, Repeat, Save, Sigma, TextCursorInput, Trash2, TriangleAlert, Unplug, X, } from 'lucide-react';
|
|
11
11
|
import { AnimatePresence, motion, useReducedMotion } from 'motion/react';
|
|
12
12
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
13
13
|
import { connectionOptionsFor } from './ConnectionPanel';
|
|
@@ -32,7 +32,7 @@ import { defaultLabel, describeFilterPredicate, flowingEdgeIds, layout, layoutIf
|
|
|
32
32
|
import { HistoryControls, keepKnown, namesOf, nodeEditAction, reverted, snapshotOf, undone, useUndoShortcut, useUnsavedGuard, withEdit, } from './workflow/history';
|
|
33
33
|
import { PublishControls, RunControls, SchedulePanel, ShrinkRefusalNote, WorkflowStatusBadge, } from './workflow/lifecycle';
|
|
34
34
|
import { CanvasContextMenu, NodeActionsToolbar } from './workflow/menu';
|
|
35
|
-
import { WORKFLOW_BRANCH_LABELS, WORKFLOW_CALL_MODES, WORKFLOW_FILTER_MAX_DEPTH, WORKFLOW_FILTER_MAX_VALUES, WORKFLOW_FILTER_OPERATORS, WORKFLOW_NODE_KINDS, WORKFLOW_RENAME_MAX_COLUMNS, callableWorkflowBlock, describeDurability, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicateKind, isWorkflowNodeKind, isWorkflowPredicateKind, isWorkflowRenameUnnamed, newLocalId, nodeName, producedTypes, renameColumnRefusals, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, workflowCallMode, workflowKnownColumns, workflowNarrowedTypes, workflowRenameUnnamed, } from './workflow/model';
|
|
35
|
+
import { WORKFLOW_AGGREGATE_FUNCTIONS, WORKFLOW_AGGREGATE_MAX_AGGREGATES, WORKFLOW_AGGREGATE_MAX_GROUP_BY, WORKFLOW_BRANCH_LABELS, WORKFLOW_CALL_MODES, WORKFLOW_FILTER_MAX_DEPTH, WORKFLOW_FILTER_MAX_VALUES, WORKFLOW_FILTER_OPERATORS, WORKFLOW_LOOKUP_MAX_FIELDS, WORKFLOW_LOOKUP_MAX_REFERENCE_ROWS, WORKFLOW_NODE_KINDS, WORKFLOW_RENAME_MAX_COLUMNS, aggregateRefusals, callableWorkflowBlock, describeDurability, isWorkflowAggregateFunction, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicateKind, isWorkflowLookupUnmatched, isWorkflowNodeKind, isWorkflowPredicateKind, isWorkflowRenameUnnamed, lookupConfigRefusals, newLocalId, nodeName, producedTypes, renameColumnRefusals, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, workflowAggregateMaxGroups, workflowAggregateNeedsColumn, workflowAggregateOutputColumns, workflowCallMode, workflowKnownColumns, workflowLookupColumns, workflowLookupUnmatched, workflowNarrowedTypes, workflowRenameUnnamed, } from './workflow/model';
|
|
36
36
|
import { WORKFLOW_NAME } from './workflow/name';
|
|
37
37
|
import { WorkflowNodeProvider, workflowNodeTypes } from './workflow/nodes';
|
|
38
38
|
import { freeSpot, placeNextTo } from './workflow/place';
|
|
@@ -465,6 +465,16 @@ const ADD_NODE = {
|
|
|
465
465
|
label: 'Rename',
|
|
466
466
|
hint: 'Renames columns, and nothing else. No code, no child process — a pure rename rewrites the staged column list and leaves every row exactly where it is. It can also drop the columns you do not name, which does cost a pass over the rows.',
|
|
467
467
|
},
|
|
468
|
+
aggregate: {
|
|
469
|
+
icon: Sigma,
|
|
470
|
+
label: 'Aggregate',
|
|
471
|
+
hint: 'Groups the rows and summarises each group — count, sum, average, min, max, or the values joined together. No code, and it holds only the groups rather than the rows, so a 44,720-row grouping into 16,119 groups never has more than one batch of records in memory. It refuses loudly if the grouping turns out to hold nearly everything.',
|
|
472
|
+
},
|
|
473
|
+
lookup: {
|
|
474
|
+
icon: Combine,
|
|
475
|
+
label: 'Lookup',
|
|
476
|
+
hint: 'Brings fields across from a reference dataset, matched by key. Wire two things into it and say which one is the reference: that side is held in memory as a map, the other streams past it. The run says how many rows matched and how many did not, which is the difference between a working join and one that silently filled a column with nulls.',
|
|
477
|
+
},
|
|
468
478
|
};
|
|
469
479
|
/**
|
|
470
480
|
* The value the workflow picker uses for "start a fresh one".
|
|
@@ -883,6 +893,18 @@ function miniMapColor(data) {
|
|
|
883
893
|
// it reads as another piece of user code hides the one thing worth seeing.
|
|
884
894
|
if (kind === 'rename')
|
|
885
895
|
return '#14b8a6';
|
|
896
|
+
// Amber-500. The one node where the number of rows changes shape rather than
|
|
897
|
+
// merely shrinking, and the one worth spotting from the overview: a grouping
|
|
898
|
+
// that holds nearly every row it read is the failure this node exists to
|
|
899
|
+
// avoid, and the box on the map is where somebody notices there is one.
|
|
900
|
+
if (kind === 'aggregate')
|
|
901
|
+
return '#f59e0b';
|
|
902
|
+
// Indigo-500, the lookup's own accent (see `KIND_STYLE`). The overview is where
|
|
903
|
+
// somebody looks for the shape of a graph, and a lookup is the one box where
|
|
904
|
+
// two lines meet for different reasons — so it must not read as a source, which
|
|
905
|
+
// is what the wire feeding it usually is.
|
|
906
|
+
if (kind === 'lookup')
|
|
907
|
+
return '#6366f1';
|
|
886
908
|
return '#8b5cf6';
|
|
887
909
|
}
|
|
888
910
|
/**
|
|
@@ -3453,6 +3475,198 @@ function RenameInspector({ node, graph, canEdit, onChange, }) {
|
|
|
3453
3475
|
{ value: 'drop', label: 'Drop them', hint: 'rebuilds every row' },
|
|
3454
3476
|
] }), _jsx("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: dropping ? (_jsxs(_Fragment, { children: ["This node ", _jsx("strong", { children: "also removes" }), " every column it does not name, so what reaches the sink is exactly the ", Object.keys(map).length, " new name", Object.keys(map).length === 1 ? '' : 's', " above. That is a projection as well as a rename, and it costs a pass over the rows \u2014 a staged batch keeps its values in positional arrays, and taking a column out moves every one of them."] })) : (_jsxs(_Fragment, { children: ["Nothing else changes. A staged batch names its columns once and keeps the values in positional arrays, so renaming one rewrites a handful of strings and", ' ', _jsx("strong", { children: "moves no data at all" }), " \u2014 which is why this is a node rather than four lines of JavaScript in a transform."] })) }), refusals.length > 0 && (_jsx("p", { className: "text-[11px] leading-relaxed text-amber-600 dark:text-amber-400", children: refusals.join(' ') })), duplicated.length > 0 && (_jsxs("p", { className: "text-[11px] leading-relaxed text-amber-600 dark:text-amber-400", children: [duplicated.map((from) => `“${from}”`).join(', '), " appears more than once on the left. A column can only be renamed to one thing, so only the last row naming it is stored."] })), known ? (_jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["A rename above this node drops the columns it does not name, so the graph knows exactly what arrives here:", ' ', _jsx("span", { className: "font-mono", children: [...known].join(', ') || 'nothing at all' }), ". A row on the left naming anything else is refused when this graph is saved, rather than found out when the column comes back empty."] })) : (_jsx("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: "The graph cannot say which columns reach this node \u2014 a source discovers its shape against the live system, and a transform is code. So the old names are taken on trust, and the run says out loud if one of them was in no row." }))] }));
|
|
3455
3477
|
}
|
|
3478
|
+
/**
|
|
3479
|
+
* The aggregate node's form: what defines a group, and what to compute per group.
|
|
3480
|
+
*
|
|
3481
|
+
* ## Why the two lists are local state and the node is not
|
|
3482
|
+
*
|
|
3483
|
+
* The same argument {@link RenameInspector} makes, arrived at from the other
|
|
3484
|
+
* direction. A rename's model is a `Record` and has to be edited as a list; an
|
|
3485
|
+
* aggregate's model is already a list, and the reason it is one is here in the
|
|
3486
|
+
* form: two aggregates reading the same column — `min(closedDate)` and
|
|
3487
|
+
* `max(closedDate)` — are the normal case rather than the mistake, so the
|
|
3488
|
+
* output name is the key and a half-typed one is still a row somebody is in the
|
|
3489
|
+
* middle of writing.
|
|
3490
|
+
*
|
|
3491
|
+
* Rows are held here, in order, and the node is derived from them. What can
|
|
3492
|
+
* diverge is two rows sharing an output name, and that is said out loud below
|
|
3493
|
+
* rather than silently resolved, because resolving it means deciding which of
|
|
3494
|
+
* somebody's numbers survives.
|
|
3495
|
+
*
|
|
3496
|
+
* ## What this panel can say that no other inspector can
|
|
3497
|
+
*
|
|
3498
|
+
* **Exactly** which columns leave the node. Every other kind's answer is an
|
|
3499
|
+
* upper bound at best and `undefined` at worst; an aggregate's output set is
|
|
3500
|
+
* closed by its own config — the group keys plus the named aggregates, on every
|
|
3501
|
+
* record, always. So the panel prints the list rather than hedging it, and the
|
|
3502
|
+
* hedge is reserved for the columns coming *in*, where `workflowKnownColumns`
|
|
3503
|
+
* genuinely may not know.
|
|
3504
|
+
*
|
|
3505
|
+
* ## And the one number it puts in front of somebody before they run it
|
|
3506
|
+
*
|
|
3507
|
+
* The group ceiling. A hash aggregate is cheap only while the groups are far
|
|
3508
|
+
* fewer than the rows, and the moment somebody groups on a near-unique column
|
|
3509
|
+
* the node holds the whole load. That is a decision made in this form, so the
|
|
3510
|
+
* bound belongs in this form and not only in the run that refuses.
|
|
3511
|
+
*/
|
|
3512
|
+
function AggregateInspector({ node, graph, canEdit, onChange, }) {
|
|
3513
|
+
const [groupBy, setGroupBy] = useState(() => node.groupBy.length > 0 ? [...node.groupBy] : ['']);
|
|
3514
|
+
const [rows, setRows] = useState(() => node.aggregates.length > 0 ? [...node.aggregates] : [{ as: '', fn: 'count' }]);
|
|
3515
|
+
const commitGroupBy = (next) => {
|
|
3516
|
+
setGroupBy(next);
|
|
3517
|
+
onChange({ ...node, groupBy: next });
|
|
3518
|
+
};
|
|
3519
|
+
const commitRows = (next) => {
|
|
3520
|
+
setRows(next);
|
|
3521
|
+
onChange({ ...node, aggregates: next });
|
|
3522
|
+
};
|
|
3523
|
+
const setFunction = (index, value) => {
|
|
3524
|
+
if (!isWorkflowAggregateFunction(value))
|
|
3525
|
+
return;
|
|
3526
|
+
commitRows(rows.map((each, at) => (at === index ? refunction(each, value) : each)));
|
|
3527
|
+
};
|
|
3528
|
+
const known = workflowKnownColumns(graph, node.id);
|
|
3529
|
+
const refusals = aggregateRefusals(node);
|
|
3530
|
+
const produces = workflowAggregateOutputColumns(node);
|
|
3531
|
+
const duplicated = rows
|
|
3532
|
+
.map((row) => row.as)
|
|
3533
|
+
.filter((as, at, all) => as.length > 0 && all.indexOf(as) !== at);
|
|
3534
|
+
return (_jsxs("div", { className: "space-y-3", children: [_jsxs(FieldGroup, { title: "Group by", hint: _jsxs(_Fragment, { children: ["What makes two records the same group. These come out under the names they went in under, so each has to be a name a column can have \u2014 letters, digits and underscore, starting with a letter or an underscore. If the source spells its headers", ' ', _jsx("code", { children: "Work Order Id" }), ", put a Rename node above this one."] }), children: [groupBy.map((column, index) => (_jsxs("div", { className: "flex items-end gap-2", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(TextField, { label: index === 0 ? 'Column' : '', value: column, placeholder: "workOrderId", disabled: !canEdit, onChange: (next) => commitGroupBy(groupBy.map((each, at) => (at === index ? next : each))) }) }), canEdit && groupBy.length > 1 && (_jsx(Button, { variant: "ghost", size: "sm", className: "shrink-0", onClick: () => commitGroupBy(groupBy.filter((_, at) => at !== index)), children: "Remove" }))] }, index))), canEdit && (_jsx(Button, { variant: "outline", size: "sm", onClick: () => commitGroupBy([...groupBy, '']), disabled: groupBy.length >= WORKFLOW_AGGREGATE_MAX_GROUP_BY, children: "Add column" }))] }), _jsxs(FieldGroup, { title: "Compute", hint: _jsxs(_Fragment, { children: ["One column out per row. ", _jsx("code", { children: "count" }), " with no column counts the records in the group; with a column it counts the ones that are not null. Anything more than these is a Transform \u2014 there is no conditional here on purpose."] }), children: [rows.map((row, index) => (_jsxs("div", { className: "space-y-2 rounded-md border border-zinc-200 p-2 dark:border-zinc-800", children: [_jsxs("div", { className: "flex items-end gap-2", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(SelectField, { label: index === 0 ? 'Function' : '', ariaLabel: "Aggregate function", value: row.fn, onValueChange: (value) => setFunction(index, value), disabled: !canEdit, options: WORKFLOW_AGGREGATE_FUNCTIONS.map((fn) => ({
|
|
3535
|
+
value: fn,
|
|
3536
|
+
label: fn,
|
|
3537
|
+
hint: AGGREGATE_HINTS[fn],
|
|
3538
|
+
})) }) }), _jsx("div", { className: "min-w-0 flex-1", children: _jsx(TextField, { label: index === 0 ? 'Of column' : '', value: row.column ?? '', placeholder: workflowAggregateNeedsColumn(row.fn) ? 'actualLaborCost' : 'every record', disabled: !canEdit, onChange: (column) => commitRows(rows.map((each, at) => at === index
|
|
3539
|
+
? column.length === 0
|
|
3540
|
+
? { ...each, column: undefined }
|
|
3541
|
+
: { ...each, column }
|
|
3542
|
+
: each)) }) }), _jsx("div", { className: "min-w-0 flex-1", children: _jsx(TextField, { label: index === 0 ? 'Called' : '', value: row.as, placeholder: "totalLaborCost", disabled: !canEdit, onChange: (as) => commitRows(rows.map((each, at) => (at === index ? { ...each, as } : each))) }) }), canEdit && rows.length > 1 && (_jsx(Button, { variant: "ghost", size: "sm", className: "shrink-0", onClick: () => commitRows(rows.filter((_, at) => at !== index)), children: "Remove" }))] }), row.fn === 'join' && (_jsxs("div", { className: "flex items-end gap-2", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(TextField, { label: "Separator", value: row.separator ?? '', placeholder: ", ", disabled: !canEdit, onChange: (separator) => commitRows(rows.map((each, at) => at === index
|
|
3543
|
+
? separator.length === 0
|
|
3544
|
+
? { ...each, separator: undefined }
|
|
3545
|
+
: { ...each, separator }
|
|
3546
|
+
: each)) }) }), _jsx("div", { className: "min-w-0 flex-1", children: _jsx(TextField, { label: "Refuse past", value: row.maxLength === undefined ? '' : String(row.maxLength), placeholder: "65535 characters", inputMode: "numeric", disabled: !canEdit, hint: "Refused, not truncated.", onChange: (text) => {
|
|
3547
|
+
const parsed = Number(text.trim());
|
|
3548
|
+
const maxLength = text.trim().length === 0 || !Number.isInteger(parsed) ? undefined : parsed;
|
|
3549
|
+
commitRows(rows.map((each, at) => (at === index ? { ...each, maxLength } : each)));
|
|
3550
|
+
} }) })] }))] }, index))), canEdit && (_jsx(Button, { variant: "outline", size: "sm", onClick: () => commitRows([...rows, { as: '', fn: 'count' }]), disabled: rows.length >= WORKFLOW_AGGREGATE_MAX_AGGREGATES, children: "Add aggregate" }))] }), _jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["This node holds ", _jsx("strong", { children: "one row per group" }), " and reads the records one staged batch at a time, so its memory is the number of groups and not the number of records. If the grouping turns out to be nearly one-to-one it holds the whole load, so the run", ' ', _jsx("strong", { children: "refuses" }), " past ", workflowAggregateMaxGroups(node).toLocaleString(), " groups rather than quietly filling the machine."] }), refusals.length > 0 && (_jsx("p", { className: "text-[11px] leading-relaxed text-amber-600 dark:text-amber-400", children: refusals.join(' ') })), duplicated.length > 0 && (_jsxs("p", { className: "text-[11px] leading-relaxed text-amber-600 dark:text-amber-400", children: [duplicated.map((as) => `“${as}”`).join(', '), " is used by more than one row. Two columns cannot share one name, and picking a winner would be a rule about which of your numbers survives."] })), produces.length > 0 && (_jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["What leaves this node is exactly ", _jsx("span", { className: "font-mono", children: produces.join(', ') }), ", on every record \u2014 including where the answer is null. Every other column of every record stops here. That set is ", _jsx("strong", { children: "exact" }), " rather than a best guess, which is what lets a filter or a sink below this node be checked when the graph is saved."] })), known ? (_jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["The graph knows exactly what arrives here:", ' ', _jsx("span", { className: "font-mono", children: [...known].join(', ') || 'nothing at all' }), ". A column named above that is not in that list is refused when this graph is saved, rather than found out when sixteen thousand rows come back as one."] })) : (_jsx("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: "The graph cannot say which columns reach this node \u2014 a source discovers its shape against the live system, and a transform is code. So the column names above are taken on trust, and the run says out loud if one of them was in no record at all." }))] }));
|
|
3551
|
+
}
|
|
3552
|
+
/**
|
|
3553
|
+
* The lookup node's form: which input is the reference, the two key columns, and
|
|
3554
|
+
* the fields to bring across.
|
|
3555
|
+
*
|
|
3556
|
+
* ## Why the reference is a picker over inbound edges and not a text box
|
|
3557
|
+
*
|
|
3558
|
+
* Because the field is a node id, and a node id typed by hand is a graph that
|
|
3559
|
+
* saves and then either refuses at validation or — worse — names a node that
|
|
3560
|
+
* happens to exist and holds the wrong side of the join in memory. The picker is
|
|
3561
|
+
* built from this node's own inbound edges, so the only offerable answers are the
|
|
3562
|
+
* ones `validateWorkflow` accepts. With nothing wired in there is nothing to
|
|
3563
|
+
* offer, and the panel says that instead of showing an empty select somebody
|
|
3564
|
+
* would read as a bug.
|
|
3565
|
+
*
|
|
3566
|
+
* ## What the panel can say that no other inspector can
|
|
3567
|
+
*
|
|
3568
|
+
* Which columns are on **which side**. Every other node with several inputs sees
|
|
3569
|
+
* them pooled — the rows arrive concatenated — so "the columns reaching this
|
|
3570
|
+
* node" is one set. A lookup is the exception: the reference's columns never flow
|
|
3571
|
+
* on, so pooling them would offer a key column that only exists over there, and a
|
|
3572
|
+
* join on a column the driving rows do not have matches nothing on every row and
|
|
3573
|
+
* commits. `workflowLookupColumns` is core's answer to that, not this screen's.
|
|
3574
|
+
*
|
|
3575
|
+
* Both sides answer "unknown" often and that is stated rather than papered over,
|
|
3576
|
+
* the stance `RenameInspector` takes about the same question.
|
|
3577
|
+
*
|
|
3578
|
+
* ## The rows are local state, the record is derived
|
|
3579
|
+
*
|
|
3580
|
+
* The same argument `RenameInspector` makes at length: a half-typed key is a key,
|
|
3581
|
+
* and rebuilding a `Record` on every keystroke collapses two rows the moment they
|
|
3582
|
+
* are briefly equal.
|
|
3583
|
+
*/
|
|
3584
|
+
function LookupInspector({ node, graph, canEdit, onChange, }) {
|
|
3585
|
+
const map = node.fields ?? {};
|
|
3586
|
+
const [rows, setRows] = useState(() => {
|
|
3587
|
+
const entries = Object.entries(map).map(([from, to]) => ({ from, to }));
|
|
3588
|
+
return entries.length > 0 ? entries : [{ from: '', to: '' }];
|
|
3589
|
+
});
|
|
3590
|
+
const commit = (next) => {
|
|
3591
|
+
setRows(next);
|
|
3592
|
+
const fields = {};
|
|
3593
|
+
for (const row of next)
|
|
3594
|
+
fields[row.from] = row.to;
|
|
3595
|
+
onChange({ ...node, fields });
|
|
3596
|
+
};
|
|
3597
|
+
const setUnmatched = (value) => {
|
|
3598
|
+
if (!isWorkflowLookupUnmatched(value))
|
|
3599
|
+
return;
|
|
3600
|
+
// Stored absent for `null`, so the default has one spelling and picking up
|
|
3601
|
+
// this release cannot renumber a graph nobody edited. The boundary
|
|
3602
|
+
// normalises the same way.
|
|
3603
|
+
onChange({ ...node, unmatched: value === 'null' ? undefined : value });
|
|
3604
|
+
};
|
|
3605
|
+
const feeds = (graph.edges ?? []).filter((edge) => edge.to === node.id).map((edge) => edge.from);
|
|
3606
|
+
const nameOf = (id) => (graph.nodes ?? []).find((each) => each.id === id)?.name ?? id;
|
|
3607
|
+
const { driving, reference } = workflowLookupColumns(graph, node);
|
|
3608
|
+
const refusals = lookupConfigRefusals(node);
|
|
3609
|
+
const duplicated = rows
|
|
3610
|
+
.map((row) => row.from)
|
|
3611
|
+
.filter((from, at, all) => from.length > 0 && all.indexOf(from) !== at);
|
|
3612
|
+
const unmatched = workflowLookupUnmatched(node);
|
|
3613
|
+
return (_jsxs("div", { className: "space-y-3", children: [feeds.length === 0 ? (_jsx("p", { className: "text-[11px] leading-relaxed text-amber-600 dark:text-amber-400", children: "Nothing is wired into this node yet. A lookup needs two inputs \u2014 the rows you want enriched, and the reference to match them against \u2014 and it has to be told which of them is the reference, because that is the side it holds in memory." })) : (_jsx(SelectField, { label: "Reference rows come from", ariaLabel: "Which input holds the reference rows", value: feeds.includes(node.reference) ? node.reference : '', onValueChange: (reference) => onChange({ ...node, reference }), disabled: !canEdit, options: feeds.map((id) => ({
|
|
3614
|
+
value: id,
|
|
3615
|
+
label: nameOf(id),
|
|
3616
|
+
hint: id === node.reference ? 'held in memory' : 'would be held in memory',
|
|
3617
|
+
})) })), _jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["The reference is read once and held as a map, up to", ' ', WORKFLOW_LOOKUP_MAX_REFERENCE_ROWS.toLocaleString(), " rows; everything else wired in streams past it a batch at a time and never accumulates. Point this at the ", _jsx("em", { children: "smaller" }), " side \u2014 a run that would hold more than that refuses rather than filling the pod."] }), _jsxs("div", { className: "flex items-end gap-2", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(TextField, { label: "Match on (the rows being enriched)", value: typeof node.key === 'string' ? node.key : '', placeholder: "planId", disabled: !canEdit, onChange: (key) => onChange({ ...node, key }) }) }), _jsx("div", { className: "min-w-0 flex-1", children: _jsx(TextField, { label: "Against (the reference rows)", value: typeof node.referenceKey === 'string' ? node.referenceKey : '', placeholder: "Plan ID", disabled: !canEdit, onChange: (referenceKey) => onChange({ ...node, referenceKey }) }) })] }), _jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["Keys are compared ", _jsx("strong", { children: "as text, exactly as written" }), " \u2014 no trimming, no case folding. That is deliberate: deciding that ", _jsx("code", { children: "21 CES" }), " and ", _jsx("code", { children: "21CES" }), " are the same unit is a rule about your data, and it belongs in a transform on both sides where you can see it. A row with nothing in its key column is counted separately and never matches."] }), _jsxs(FieldGroup, { title: "Bring across", hint: _jsxs(_Fragment, { children: ["The column on the reference rows, and the name it lands under. The reference name is whatever that side actually calls it \u2014 ", _jsx("code", { children: "Plan Name" }), " is fine. The new one has to be a name a column can have: letters, digits and underscore, starting with a letter or an underscore. Landing on a column the rows already have is expected and works: a published type declares its columns, so the ones you are filling arrive empty. A row that already holds a ", _jsx("em", { children: "value" }), " there stops the run rather than losing it."] }), children: [rows.map((row, index) => (_jsxs("div", { className: "flex items-end gap-2", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(TextField, { label: index === 0 ? 'On the reference' : '', value: row.from, placeholder: "Plan Name", disabled: !canEdit, onChange: (from) => commit(rows.map((each, at) => (at === index ? { ...each, from } : each))) }) }), _jsx("div", { className: "min-w-0 flex-1", children: _jsx(TextField, { label: index === 0 ? 'Lands as' : '', value: row.to, placeholder: "planName", disabled: !canEdit, onChange: (to) => commit(rows.map((each, at) => (at === index ? { ...each, to } : each))) }) }), canEdit && rows.length > 1 && (_jsx(Button, { variant: "ghost", size: "sm", className: "shrink-0", onClick: () => commit(rows.filter((_, at) => at !== index)), children: "Remove" }))] }, index))), canEdit && (_jsx(Button, { variant: "outline", size: "sm", onClick: () => commit([...rows, { from: '', to: '' }]), disabled: rows.length >= WORKFLOW_LOOKUP_MAX_FIELDS, children: "Add field" }))] }), _jsx(SelectField, { label: "Rows whose key matches nothing", ariaLabel: "What happens to a row whose key matches no reference row", value: unmatched, onValueChange: setUnmatched, disabled: !canEdit, options: [
|
|
3618
|
+
{ value: 'null', label: 'Pass on, fields set to null', hint: 'a LEFT JOIN' },
|
|
3619
|
+
{ value: 'drop', label: 'Drop the row', hint: 'an INNER JOIN — removes rows' },
|
|
3620
|
+
{ value: 'fail', label: 'Fail this node', hint: 'the reference is a prerequisite' },
|
|
3621
|
+
] }), _jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: [unmatched === 'drop' ? (_jsxs(_Fragment, { children: ["Unmatched rows ", _jsx("strong", { children: "will not reach the next node" }), ", so this node also removes rows \u2014 a full sink below it publishes only what matched."] })) : unmatched === 'fail' ? (_jsxs(_Fragment, { children: ["The first unmatched row ", _jsx("strong", { children: "stops the run" }), ", naming the key it could not find. Choose this when the reference is meant to cover everything and a load that cannot be enriched is one that should not commit."] })) : (_jsx(_Fragment, { children: "Unmatched rows are passed on with these columns set to null \u2014 the same result as enriching by hand, with one difference that is the whole point of the node." })), ' ', "Either way the run says how many rows matched, how many had a key that matched nothing, and how many had no key at all. A join that matched nothing looks exactly like one that worked unless somebody counts."] }), refusals.length > 0 && (_jsx("p", { className: "text-[11px] leading-relaxed text-amber-600 dark:text-amber-400", children: refusals.join(' ') })), duplicated.length > 0 && (_jsxs("p", { className: "text-[11px] leading-relaxed text-amber-600 dark:text-amber-400", children: [duplicated.map((from) => `“${from}”`).join(', '), " appears more than once on the left. A reference column can only land under one name, so only the last row naming it is stored."] })), _jsx(LookupSidesNote, { driving: driving, reference: reference })] }));
|
|
3622
|
+
}
|
|
3623
|
+
/**
|
|
3624
|
+
* One aggregate, with its function changed and the fields that no longer apply
|
|
3625
|
+
* dropped.
|
|
3626
|
+
*
|
|
3627
|
+
* Dropped rather than left behind, because a stored separator on a `sum` is a
|
|
3628
|
+
* node the server refuses — and a form that can reach a refused state by
|
|
3629
|
+
* changing a dropdown is a form that fails after Save with nothing visibly
|
|
3630
|
+
* wrong on the screen.
|
|
3631
|
+
*/
|
|
3632
|
+
function refunction(aggregate, fn) {
|
|
3633
|
+
const kept = { as: aggregate.as, fn };
|
|
3634
|
+
if (workflowAggregateNeedsColumn(fn) && aggregate.column !== undefined) {
|
|
3635
|
+
kept.column = aggregate.column;
|
|
3636
|
+
}
|
|
3637
|
+
if (fn !== 'join')
|
|
3638
|
+
return kept;
|
|
3639
|
+
if (aggregate.separator !== undefined)
|
|
3640
|
+
kept.separator = aggregate.separator;
|
|
3641
|
+
if (aggregate.maxLength !== undefined)
|
|
3642
|
+
kept.maxLength = aggregate.maxLength;
|
|
3643
|
+
return kept;
|
|
3644
|
+
}
|
|
3645
|
+
/** One line per function, for the picker. What it does, and what it costs. */
|
|
3646
|
+
const AGGREGATE_HINTS = {
|
|
3647
|
+
count: 'records in the group, or non-null values of a column',
|
|
3648
|
+
sum: 'the total, with the low-order bits kept',
|
|
3649
|
+
avg: 'the mean of the non-null values',
|
|
3650
|
+
min: 'the least value — text compares by code point, not by database collation',
|
|
3651
|
+
max: 'the greatest value — same comparison',
|
|
3652
|
+
join: 'the values run together, refusing past a length rather than truncating',
|
|
3653
|
+
};
|
|
3654
|
+
/**
|
|
3655
|
+
* Which columns the graph can prove are on each of a lookup's two sides.
|
|
3656
|
+
*
|
|
3657
|
+
* Its own component because it is the sentence that is *only* true of this node
|
|
3658
|
+
* kind: every other multi-input inspector could say "the columns reaching this
|
|
3659
|
+
* node" as one list, and saying that here would offer a key column that exists
|
|
3660
|
+
* only on the reference — a join that matches nothing on every row.
|
|
3661
|
+
*
|
|
3662
|
+
* Either side answering "unknown" is the ordinary case and is said out loud
|
|
3663
|
+
* rather than papered over, the stance `RenameInspector` takes about the same
|
|
3664
|
+
* question. `undefined` is not "no columns": treating it as empty would refuse
|
|
3665
|
+
* every lookup below a transform.
|
|
3666
|
+
*/
|
|
3667
|
+
function LookupSidesNote({ driving, reference, }) {
|
|
3668
|
+
return (_jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: [driving ? (_jsxs(_Fragment, { children: ["The graph knows exactly what reaches the rows being enriched:", ' ', _jsx("span", { className: "font-mono", children: [...driving].join(', ') || 'nothing at all' }), "."] })) : (_jsx(_Fragment, { children: "The graph cannot say which columns reach the rows being enriched \u2014 a source discovers its shape against the live system, and a transform is code \u2014 so the key is taken on trust and the run reports the counts." })), ' ', reference ? (_jsxs(_Fragment, { children: ["On the reference side it is", ' ', _jsx("span", { className: "font-mono", children: [...reference].join(', ') || 'nothing at all' }), "."] })) : (_jsx(_Fragment, { children: "The reference side is unknown for the same reason." }))] }));
|
|
3669
|
+
}
|
|
3456
3670
|
function FilterInspector({ node, graph, canEdit, onChange, }) {
|
|
3457
3671
|
// Core's answer, not this file's. A canvas that worked out its own set would
|
|
3458
3672
|
// offer acknowledgements the server then refuses, which is a person ticking a
|
|
@@ -3791,6 +4005,16 @@ function KindInspector({ node, graph, transforms, connections, storage, typeOpti
|
|
|
3791
4005
|
// node. See `workflowKnownColumns`.
|
|
3792
4006
|
return (_jsx(RenameInspector, { node: node, graph: graph, canEdit: canEdit, onChange: onChange }, node.id));
|
|
3793
4007
|
}
|
|
4008
|
+
if (node.kind === 'aggregate') {
|
|
4009
|
+
return _jsx(AggregateInspector, { node: node, graph: graph, canEdit: canEdit, onChange: onChange });
|
|
4010
|
+
}
|
|
4011
|
+
if (node.kind === 'lookup') {
|
|
4012
|
+
// Given the whole graph, and it needs it more than any other inspector does:
|
|
4013
|
+
// a lookup's `reference` is a node id, so the form cannot even list the
|
|
4014
|
+
// choices without the edges — and `workflowLookupColumns` is what lets it say
|
|
4015
|
+
// which columns are on which side rather than pooling them.
|
|
4016
|
+
return (_jsx(LookupInspector, { node: node, graph: graph, canEdit: canEdit, onChange: onChange }, node.id));
|
|
4017
|
+
}
|
|
3794
4018
|
if (node.kind === 'sink') {
|
|
3795
4019
|
return (_jsx(SinkInspector, { node: node, typeOptions: typeOptions, canEdit: canEdit, modelHref: modelHref, onChange: onChange }));
|
|
3796
4020
|
}
|
package/dist/workflow/create.js
CHANGED
|
@@ -91,6 +91,54 @@ export function newNodeOfKind(kind, id, position, name) {
|
|
|
91
91
|
// snapshot.
|
|
92
92
|
return { id, name, kind: 'rename', columns: { '': '' }, position };
|
|
93
93
|
}
|
|
94
|
+
if (kind === 'aggregate') {
|
|
95
|
+
// One blank group-by column and one blank aggregate, so the validator
|
|
96
|
+
// refuses it by name from the moment it is dropped. The same stance
|
|
97
|
+
// `filter` and `rename` take, and here the empty states are the two most
|
|
98
|
+
// dangerous in the file: an aggregate with no group-by columns commits
|
|
99
|
+
// exactly one row whether the source held everything or nothing, and one
|
|
100
|
+
// with no aggregates commits the distinct group keys with every other
|
|
101
|
+
// column of every row gone. Neither errors. So the node starts visibly
|
|
102
|
+
// incomplete rather than invisibly destructive.
|
|
103
|
+
//
|
|
104
|
+
// `count` as the starting function because it is the only one that needs no
|
|
105
|
+
// column to mean something, so the half-filled node the person is looking
|
|
106
|
+
// at is refused for the fields they have not reached yet rather than for a
|
|
107
|
+
// choice the form made on their behalf.
|
|
108
|
+
return {
|
|
109
|
+
id,
|
|
110
|
+
name,
|
|
111
|
+
kind: 'aggregate',
|
|
112
|
+
groupBy: [''],
|
|
113
|
+
aggregates: [{ as: '', fn: 'count' }],
|
|
114
|
+
position,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (kind === 'lookup') {
|
|
118
|
+
// Every field blank, and the validator refuses it by name from the moment the
|
|
119
|
+
// node is dropped — the stance `filter` and `rename` take, and for the same
|
|
120
|
+
// reason one step sharper. A lookup has *four* things to fill in and three of
|
|
121
|
+
// them have a plausible-looking wrong default: a `reference` guessed from the
|
|
122
|
+
// first inbound edge would decide which side is held in memory, and a
|
|
123
|
+
// `key`/`referenceKey` pair guessed from a column both sides happen to share
|
|
124
|
+
// would author a join nobody chose. All three are silent when wrong.
|
|
125
|
+
//
|
|
126
|
+
// `unmatched` is left absent, which means null. That is the only one of the
|
|
127
|
+
// three dispositions that changes neither which rows exist nor whether the run
|
|
128
|
+
// finishes, so it is the one a node can start on before anybody has thought
|
|
129
|
+
// about it — and the run log reports the count either way, which is the part
|
|
130
|
+
// that stops it being a guess with consequences.
|
|
131
|
+
return {
|
|
132
|
+
id,
|
|
133
|
+
name,
|
|
134
|
+
kind: 'lookup',
|
|
135
|
+
reference: '',
|
|
136
|
+
key: '',
|
|
137
|
+
referenceKey: '',
|
|
138
|
+
fields: { '': '' },
|
|
139
|
+
position,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
94
142
|
if (kind === 'sink') {
|
|
95
143
|
return { id, name, kind: 'sink', targetType: '', position };
|
|
96
144
|
}
|
package/dist/workflow/graph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WORKFLOW_NODE_HEIGHT, WORKFLOW_NODE_WIDTH, workflowColumnX, workflowRowY, workflowRunOrder, } from '@dudousxd/nestjs-catalog/client';
|
|
2
2
|
import { MarkerType } from '@xyflow/react';
|
|
3
|
-
import { nodeName, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, workflowCallMode, workflowRenameUnnamed, } from './model';
|
|
3
|
+
import { nodeName, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, workflowCallMode, workflowLookupUnmatched, workflowRenameUnnamed, } from './model';
|
|
4
4
|
import { edgeId } from './validate';
|
|
5
5
|
/**
|
|
6
6
|
* Turning the stored graph into what React Flow draws, and back.
|
|
@@ -54,6 +54,10 @@ function subtitleFor(node, describe) {
|
|
|
54
54
|
return filterSubtitle(node);
|
|
55
55
|
if (node.kind === 'rename')
|
|
56
56
|
return renameSubtitle(node);
|
|
57
|
+
if (node.kind === 'aggregate')
|
|
58
|
+
return aggregateSubtitle(node);
|
|
59
|
+
if (node.kind === 'lookup')
|
|
60
|
+
return lookupSubtitle(node);
|
|
57
61
|
if (node.kind === 'transform') {
|
|
58
62
|
return describe.transformName(node.transformId) ?? 'no transform chosen';
|
|
59
63
|
}
|
|
@@ -116,6 +120,56 @@ function renameSubtitle(node) {
|
|
|
116
120
|
: `renames ${entries.length} columns`;
|
|
117
121
|
return dropped ? `${what}, drops the rest` : what;
|
|
118
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* An aggregate's face: what defines a group, and how many numbers come out.
|
|
125
|
+
*
|
|
126
|
+
* The group-by columns are spelled out rather than counted, because they are the
|
|
127
|
+
* whole meaning of the node — `by workOrderId, assetId` says what one output row
|
|
128
|
+
* *is*, and "groups on 2 columns" says nothing anybody can check. The aggregate
|
|
129
|
+
* count is a count, because forty-nine function names do not fit on a box and
|
|
130
|
+
* the inspector is one click away.
|
|
131
|
+
*
|
|
132
|
+
* This is also the only node face that has to make a person suspicious of a
|
|
133
|
+
* grouping before they run it, which is why the columns come first: an aggregate
|
|
134
|
+
* grouped on something near-unique holds the whole load, and the name of the
|
|
135
|
+
* column is the only thing on the canvas that can give that away.
|
|
136
|
+
*/
|
|
137
|
+
function aggregateSubtitle(node) {
|
|
138
|
+
const groupBy = (node.groupBy ?? []).filter((column) => column.length > 0);
|
|
139
|
+
const aggregates = (node.aggregates ?? []).filter((each) => each.as.length > 0);
|
|
140
|
+
if (groupBy.length === 0)
|
|
141
|
+
return 'no columns to group on';
|
|
142
|
+
if (aggregates.length === 0)
|
|
143
|
+
return `by ${groupBy.join(', ')}, computing nothing`;
|
|
144
|
+
return `by ${groupBy.join(', ')} \u2192 ${aggregates.length} ${aggregates.length === 1 ? 'value' : 'values'}`;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A lookup's face: what it matches on, and how many fields it brings across.
|
|
148
|
+
*
|
|
149
|
+
* The **key pair** is what gets the room, not the field list, and that is the
|
|
150
|
+
* decision. A lookup that is wrong is almost never wrong about which columns it
|
|
151
|
+
* wanted — it is wrong about the two columns it matches on, because those are the
|
|
152
|
+
* ones that have to agree between two systems that have never met. `planId =
|
|
153
|
+
* Plan ID` readable off the canvas is the difference between spotting that and
|
|
154
|
+
* opening every node in the graph.
|
|
155
|
+
*
|
|
156
|
+
* The disposition is on the face too, and only when it is not the default, for
|
|
157
|
+
* the reason a rename says "drops the rest": `drop` means this node also removes
|
|
158
|
+
* rows, which is a thing that should never require opening a box to discover.
|
|
159
|
+
*/
|
|
160
|
+
function lookupSubtitle(node) {
|
|
161
|
+
const key = typeof node.key === 'string' ? node.key : '';
|
|
162
|
+
const referenceKey = typeof node.referenceKey === 'string' ? node.referenceKey : '';
|
|
163
|
+
if (key.length === 0 || referenceKey.length === 0)
|
|
164
|
+
return 'no key chosen';
|
|
165
|
+
const fields = Object.entries(node.fields ?? {}).filter(([from, to]) => from.length > 0 && to.length > 0);
|
|
166
|
+
if (fields.length === 0)
|
|
167
|
+
return `${key} = ${referenceKey}, no fields`;
|
|
168
|
+
const brings = fields.length === 1 ? `+${fields[0]?.[1]}` : `+${fields.length} fields`;
|
|
169
|
+
const unmatched = workflowLookupUnmatched(node);
|
|
170
|
+
const tail = unmatched === 'drop' ? ', drops misses' : unmatched === 'fail' ? ', fails on a miss' : '';
|
|
171
|
+
return `${key} = ${referenceKey} ${brings}${tail}`;
|
|
172
|
+
}
|
|
119
173
|
/** How many comparisons a predicate is made of, groups not counted. */
|
|
120
174
|
function countFilterLeaves(predicate) {
|
|
121
175
|
if (predicate.kind === 'all' || predicate.kind === 'any') {
|
|
@@ -361,6 +415,10 @@ export function defaultLabel(kind) {
|
|
|
361
415
|
return 'Filter';
|
|
362
416
|
if (kind === 'rename')
|
|
363
417
|
return 'Rename';
|
|
418
|
+
if (kind === 'aggregate')
|
|
419
|
+
return 'Aggregate';
|
|
420
|
+
if (kind === 'lookup')
|
|
421
|
+
return 'Lookup';
|
|
364
422
|
if (kind === 'transform')
|
|
365
423
|
return 'Transform';
|
|
366
424
|
return unreachableNodeKind(kind, 'defaultLabel');
|
package/dist/workflow/model.d.ts
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
* executes it, it belongs to core; if only this screen has an opinion about it,
|
|
19
19
|
* it belongs here.
|
|
20
20
|
*/
|
|
21
|
-
export type { CallableWorkflowBlock, CallableWorkflowDisagreement, CallableWorkflowRef, CatalogWorkflow, CatalogWorkflowRelease, WorkflowBranchLabel, WorkflowEdge, WorkflowCallMode, WorkflowCallNode, WorkflowEnvPredicate, WorkflowFilterAll, WorkflowFilterAny, WorkflowFilterComparison, WorkflowFilterGroup, WorkflowFilterNode, WorkflowFilterOneOf, WorkflowFilterOperator, WorkflowFilterPredicate, WorkflowFilterPredicateKind, WorkflowFilterPresence, WorkflowFilterValue, WorkflowGraph, WorkflowIfNode, WorkflowIfPredicate, WorkflowNode, WorkflowNodeKind, WorkflowPredicateKind, WorkflowRenameNode, WorkflowRenameUnnamed, WorkflowRowCountPredicate, WorkflowSinkNode, WorkflowSkipReason, WorkflowSourceNode, WorkflowTransformNode, } from '@dudousxd/nestjs-catalog/client';
|
|
22
|
-
export { callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicate, isWorkflowFilterPredicateKind, isWorkflowFilterValue, isWorkflowNodeKind, isWorkflowPredicateKind, isWorkflowRenameUnnamed, renameColumnRefusals, workflowKnownColumns, workflowRenameUnnamed, WORKFLOW_CALL_MODES, unreachableCallMode, workflowCallMode, unreachableFilterOperator, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, unreachableRenameUnnamed, workflowNarrowedTypes, WORKFLOW_BRANCH_LABELS, WORKFLOW_FILTER_COLUMN_PATTERN, WORKFLOW_FILTER_MAX_DEPTH, WORKFLOW_FILTER_MAX_VALUES, WORKFLOW_FILTER_OPERATORS, WORKFLOW_FILTER_PREDICATE_KINDS, WORKFLOW_PREDICATE_KINDS, WORKFLOW_RENAME_MAX_COLUMNS, WORKFLOW_RENAME_UNNAMED, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
|
|
21
|
+
export type { CallableWorkflowBlock, CallableWorkflowDisagreement, CallableWorkflowRef, CatalogWorkflow, CatalogWorkflowRelease, WorkflowBranchLabel, WorkflowEdge, WorkflowCallMode, WorkflowCallNode, WorkflowEnvPredicate, WorkflowFilterAll, WorkflowFilterAny, WorkflowFilterComparison, WorkflowFilterGroup, WorkflowFilterNode, WorkflowFilterOneOf, WorkflowFilterOperator, WorkflowFilterPredicate, WorkflowFilterPredicateKind, WorkflowFilterPresence, WorkflowFilterValue, WorkflowGraph, WorkflowIfNode, WorkflowIfPredicate, WorkflowAggregate, WorkflowAggregateFunction, WorkflowAggregateNode, WorkflowNode, WorkflowNodeKind, WorkflowPredicateKind, WorkflowLookupNode, WorkflowLookupUnmatched, WorkflowRenameNode, WorkflowRenameUnnamed, WorkflowRowCountPredicate, WorkflowSinkNode, WorkflowSkipReason, WorkflowSourceNode, WorkflowTransformNode, } from '@dudousxd/nestjs-catalog/client';
|
|
22
|
+
export { callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicate, isWorkflowFilterPredicateKind, isWorkflowFilterValue, isWorkflowLookupFields, isWorkflowLookupUnmatched, isWorkflowNodeKind, isWorkflowPredicateKind, isWorkflowAggregateFunction, isWorkflowRenameUnnamed, aggregateRefusals, workflowAggregateColumns, workflowAggregateJoinMaxLength, workflowAggregateMaxGroups, workflowAggregateNeedsColumn, workflowAggregateOutputColumns, workflowAggregateSeparator, renameColumnRefusals, workflowKnownColumns, workflowRenameUnnamed, lookupConfigRefusals, workflowLookupColumns, workflowLookupUnmatched, WORKFLOW_CALL_MODES, unreachableCallMode, workflowCallMode, unreachableFilterOperator, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, unreachableAggregateFunction, unreachableLookupUnmatched, unreachableRenameUnnamed, workflowNarrowedTypes, WORKFLOW_BRANCH_LABELS, WORKFLOW_FILTER_COLUMN_PATTERN, WORKFLOW_FILTER_MAX_DEPTH, WORKFLOW_FILTER_MAX_VALUES, WORKFLOW_FILTER_OPERATORS, WORKFLOW_FILTER_PREDICATE_KINDS, WORKFLOW_PREDICATE_KINDS, WORKFLOW_AGGREGATE_DEFAULT_SEPARATOR, WORKFLOW_AGGREGATE_FUNCTIONS, WORKFLOW_AGGREGATE_GROUPS_CEILING, WORKFLOW_AGGREGATE_JOIN_LENGTH_CEILING, WORKFLOW_AGGREGATE_JOIN_MAX_LENGTH, WORKFLOW_AGGREGATE_MAX_AGGREGATES, WORKFLOW_AGGREGATE_MAX_GROUP_BY, WORKFLOW_AGGREGATE_MAX_GROUPS, WORKFLOW_AGGREGATE_MAX_SEPARATOR, WORKFLOW_LOOKUP_MAX_FIELDS, WORKFLOW_LOOKUP_MAX_REFERENCE_ROWS, WORKFLOW_LOOKUP_UNMATCHED, WORKFLOW_RENAME_MAX_COLUMNS, WORKFLOW_RENAME_UNNAMED, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
|
|
23
23
|
import { type WorkflowBranchLabel, type WorkflowNode, type WorkflowSkipReason } from '@dudousxd/nestjs-catalog/client';
|
|
24
24
|
/**
|
|
25
25
|
* What a caller may set.
|
package/dist/workflow/model.js
CHANGED
|
@@ -23,25 +23,39 @@ export {
|
|
|
23
23
|
// not a copy: the picker greys an entry out and the server reasons about the
|
|
24
24
|
// same list, and two copies of that rule is a picker that eventually offers
|
|
25
25
|
// something the rest of the system will not accept.
|
|
26
|
-
callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicate, isWorkflowFilterPredicateKind, isWorkflowFilterValue, isWorkflowNodeKind, isWorkflowPredicateKind, isWorkflowRenameUnnamed,
|
|
26
|
+
callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicate, isWorkflowFilterPredicateKind, isWorkflowFilterValue, isWorkflowLookupFields, isWorkflowLookupUnmatched, isWorkflowNodeKind, isWorkflowPredicateKind, isWorkflowAggregateFunction, isWorkflowRenameUnnamed,
|
|
27
|
+
// The aggregate rules, core's for the reason every rule here is core's: an
|
|
28
|
+
// inspector that offered a function the fold cannot compute would save a
|
|
29
|
+
// graph that fails inside a durable step, and one with its own copy of the
|
|
30
|
+
// group ceiling would show a person a bound the runner does not enforce.
|
|
31
|
+
// `workflowAggregateOutputColumns` is the payoff of the config being data —
|
|
32
|
+
// the columns leaving the node, exactly, which no other kind can say.
|
|
33
|
+
aggregateRefusals, workflowAggregateColumns, workflowAggregateJoinMaxLength, workflowAggregateMaxGroups, workflowAggregateNeedsColumn, workflowAggregateOutputColumns, workflowAggregateSeparator,
|
|
27
34
|
// The rename rules, core's for the reason every rule here is core's: a form
|
|
28
35
|
// that checked a target name against its own copy of the identifier pattern
|
|
29
36
|
// would accept a name the server refuses, after Save — and `workflowKnownColumns`
|
|
30
37
|
// is what lets the inspector say which columns actually reach a node instead of
|
|
31
38
|
// guessing.
|
|
32
39
|
renameColumnRefusals, workflowKnownColumns, workflowRenameUnnamed,
|
|
40
|
+
// The lookup rules, core's for the same reason. `workflowLookupColumns` is the
|
|
41
|
+
// one that earns its place on this screen: a lookup is the only node whose two
|
|
42
|
+
// inputs are not interchangeable, so an inspector that worked out for itself
|
|
43
|
+
// which columns are on which side would eventually offer a key column that only
|
|
44
|
+
// exists on the reference — a join that matches nothing, which is the failure
|
|
45
|
+
// the node was built to end.
|
|
46
|
+
lookupConfigRefusals, workflowLookupColumns, workflowLookupUnmatched,
|
|
33
47
|
// The two wire formats a call node can be authored in, plus the reader that
|
|
34
48
|
// applies the default. Core's, not a copy, for the reason every rule here is:
|
|
35
49
|
// an inspector offering a mode the runner cannot build a payload for is a
|
|
36
50
|
// graph somebody saves and a child run that fails, and a screen carrying its
|
|
37
51
|
// own `?? 'envelope'` would eventually disagree with `workflowGraphHash` and
|
|
38
52
|
// show unsaved changes on a graph nobody edited.
|
|
39
|
-
WORKFLOW_CALL_MODES, unreachableCallMode, workflowCallMode, unreachableFilterOperator, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, unreachableRenameUnnamed,
|
|
53
|
+
WORKFLOW_CALL_MODES, unreachableCallMode, workflowCallMode, unreachableFilterOperator, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, unreachableAggregateFunction, unreachableLookupUnmatched, unreachableRenameUnnamed,
|
|
40
54
|
// Core's, not a copy, for the reason every other rule here is core's: the
|
|
41
55
|
// inspector has to offer exactly the acknowledgements `validateWorkflow`
|
|
42
56
|
// requires, and a screen that worked out its own list would offer a set the
|
|
43
57
|
// server then refuses — with the person having ticked a box to be told no.
|
|
44
|
-
workflowNarrowedTypes, WORKFLOW_BRANCH_LABELS, WORKFLOW_FILTER_COLUMN_PATTERN, WORKFLOW_FILTER_MAX_DEPTH, WORKFLOW_FILTER_MAX_VALUES, WORKFLOW_FILTER_OPERATORS, WORKFLOW_FILTER_PREDICATE_KINDS, WORKFLOW_PREDICATE_KINDS, WORKFLOW_RENAME_MAX_COLUMNS, WORKFLOW_RENAME_UNNAMED, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
|
|
58
|
+
workflowNarrowedTypes, WORKFLOW_BRANCH_LABELS, WORKFLOW_FILTER_COLUMN_PATTERN, WORKFLOW_FILTER_MAX_DEPTH, WORKFLOW_FILTER_MAX_VALUES, WORKFLOW_FILTER_OPERATORS, WORKFLOW_FILTER_PREDICATE_KINDS, WORKFLOW_PREDICATE_KINDS, WORKFLOW_AGGREGATE_DEFAULT_SEPARATOR, WORKFLOW_AGGREGATE_FUNCTIONS, WORKFLOW_AGGREGATE_GROUPS_CEILING, WORKFLOW_AGGREGATE_JOIN_LENGTH_CEILING, WORKFLOW_AGGREGATE_JOIN_MAX_LENGTH, WORKFLOW_AGGREGATE_MAX_AGGREGATES, WORKFLOW_AGGREGATE_MAX_GROUP_BY, WORKFLOW_AGGREGATE_MAX_GROUPS, WORKFLOW_AGGREGATE_MAX_SEPARATOR, WORKFLOW_LOOKUP_MAX_FIELDS, WORKFLOW_LOOKUP_MAX_REFERENCE_ROWS, WORKFLOW_LOOKUP_UNMATCHED, WORKFLOW_RENAME_MAX_COLUMNS, WORKFLOW_RENAME_UNNAMED, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
|
|
45
59
|
import { WORKFLOW_NODE_ID_PATTERN, } from '@dudousxd/nestjs-catalog/client';
|
|
46
60
|
export function describeDurability(durability) {
|
|
47
61
|
if (!durability) {
|
package/dist/workflow/nodes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Handle, Position } from '@xyflow/react';
|
|
3
|
-
import { CircleAlert, CircleCheck, CircleSlash, Code2, Database, ExternalLink, Filter, GitBranch, Loader2, Plug, Repeat, TextCursorInput, TriangleAlert, } from 'lucide-react';
|
|
3
|
+
import { CircleAlert, CircleCheck, CircleSlash, Code2, Combine, Database, ExternalLink, Filter, GitBranch, Loader2, Plug, Repeat, Sigma, TextCursorInput, TriangleAlert, } from 'lucide-react';
|
|
4
4
|
import { motion, useReducedMotion } from 'motion/react';
|
|
5
5
|
import { createContext, useContext, } from 'react';
|
|
6
6
|
import { cn } from '../cn';
|
|
@@ -110,6 +110,33 @@ const KIND_STYLE = {
|
|
|
110
110
|
icon: TextCursorInput,
|
|
111
111
|
noun: 'rename',
|
|
112
112
|
},
|
|
113
|
+
// Amber, and a mark that funnels. An aggregate is the one node in the graph
|
|
114
|
+
// where the row count *changes shape* rather than merely shrinking — a filter
|
|
115
|
+
// drops rows and leaves the survivors untouched, an aggregate replaces every
|
|
116
|
+
// row it read with a summary of several. It also has to stand out from the
|
|
117
|
+
// teal beside it, because a rename is provably cheap and an aggregate is
|
|
118
|
+
// cheap only while the grouping is sane, and a canvas where those two read
|
|
119
|
+
// alike hides the one node worth looking twice at.
|
|
120
|
+
aggregate: {
|
|
121
|
+
accent: 'bg-gradient-to-b from-amber-400 to-amber-600',
|
|
122
|
+
chip: 'text-amber-700 dark:text-amber-300',
|
|
123
|
+
wash: 'bg-amber-50/70 dark:bg-amber-950/30',
|
|
124
|
+
icon: Sigma,
|
|
125
|
+
noun: 'aggregate',
|
|
126
|
+
},
|
|
127
|
+
// Indigo and a mark of two things becoming one. A lookup is the only node with
|
|
128
|
+
// *two kinds of input* — one it holds and one it streams — and the whole way it
|
|
129
|
+
// goes wrong is somebody reading it as another step in the line and not noticing
|
|
130
|
+
// which wire is which. Deliberately not the sky a source wears, even though the
|
|
131
|
+
// reference edge usually comes straight off one: the point of the colour is that
|
|
132
|
+
// this box is where two lines meet, not where one starts.
|
|
133
|
+
lookup: {
|
|
134
|
+
accent: 'bg-gradient-to-b from-indigo-400 to-indigo-600',
|
|
135
|
+
chip: 'text-indigo-700 dark:text-indigo-300',
|
|
136
|
+
wash: 'bg-indigo-50/70 dark:bg-indigo-950/30',
|
|
137
|
+
icon: Combine,
|
|
138
|
+
noun: 'lookup',
|
|
139
|
+
},
|
|
113
140
|
};
|
|
114
141
|
/**
|
|
115
142
|
* Handles are styled larger than React Flow's default 6px dot.
|
|
@@ -113,6 +113,27 @@ const NODE_FACTORIES = {
|
|
|
113
113
|
// that do not exist in whatever the reader wired up — and the symptom of that
|
|
114
114
|
// is not an error, it is a target column absent from every row.
|
|
115
115
|
rename: (id, name, init) => ({ id, name, kind: 'rename', ...init }),
|
|
116
|
+
// `aggregate` arrived fifth, and the map stopped the build a fifth time.
|
|
117
|
+
//
|
|
118
|
+
// Unused by every template below, and the reason is the strongest of the
|
|
119
|
+
// five. A template's job is to make a decision once on a reader's behalf, and
|
|
120
|
+
// an aggregate is nothing *but* decisions about one dataset: which columns
|
|
121
|
+
// define a group, and which function is right for each of the rest. `max` and
|
|
122
|
+
// `min` over the same column answer different questions, and picking wrong
|
|
123
|
+
// does not error — it commits a plausible number. A prefilled aggregate would
|
|
124
|
+
// be a summary of somebody else's data, shipped with an air of authority.
|
|
125
|
+
aggregate: (id, name, init) => ({ id, name, kind: 'aggregate', ...init }),
|
|
126
|
+
// `lookup` arrived sixth, and the map stopped the build a sixth time.
|
|
127
|
+
//
|
|
128
|
+
// Unused by every template below, and the reason is not the one the five above
|
|
129
|
+
// give. A lookup's content is not only facts about somebody's data — it is a
|
|
130
|
+
// `reference` that names *a node id in the graph being built*, so a template
|
|
131
|
+
// that prefilled one would be writing down the id of a node it also has to
|
|
132
|
+
// create, in an order nothing enforces. When that goes wrong the graph does not
|
|
133
|
+
// fail to save: `validateWorkflow` refuses it, which is the good case, and the
|
|
134
|
+
// bad case is a template that happens to name a node that exists and quietly
|
|
135
|
+
// holds the wrong side of the join in memory.
|
|
136
|
+
lookup: (id, name, init) => ({ id, name, kind: 'lookup', ...init }),
|
|
116
137
|
};
|
|
117
138
|
/* -------------------------------------------------------------------------- */
|
|
118
139
|
/* Starter transform code */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-catalog-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Ready-made React screens for @dudousxd/nestjs-catalog — a model manager and a generic object explorer you can drop into your own app shell.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davide Carvalho",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"tailwind-merge": "3.4.1",
|
|
111
111
|
"tiptap-markdown": "0.9.0",
|
|
112
112
|
"typescript": "5.9.3",
|
|
113
|
-
"@dudousxd/nestjs-catalog": "0.
|
|
113
|
+
"@dudousxd/nestjs-catalog": "0.28.0"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
116
|
"clsx": "2.1.1",
|