@dudousxd/nestjs-catalog-react 0.19.0-preview.0 → 0.19.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.
@@ -20,14 +20,15 @@ import { INLINE_CONNECTION, KIND_OPTIONS, ReadModeFields, SourceFields, readsInc
20
20
  import { Button } from './ui/button';
21
21
  import { ComboboxField } from './ui/combobox';
22
22
  import { ConfirmDialog } from './ui/dialog';
23
- import { TextAreaField, TextField } from './ui/field';
23
+ import { FieldGroup, TextAreaField, TextField } from './ui/field';
24
24
  import { Select, SelectField } from './ui/select';
25
25
  import { Sheet } from './ui/sheet';
26
+ import { Switch } from './ui/switch';
26
27
  import { Tooltip, TooltipProvider } from './ui/tooltip';
27
28
  import { WorkflowEdgeProvider, workflowEdgeTypes } from './workflow/edges';
28
- import { NODE_HEIGHT, NODE_WIDTH, defaultLabel, flowingEdgeIds, layout, layoutIfUnarranged, nextPosition, toFlowEdges, toFlowNodes, } from './workflow/graph';
29
+ import { NODE_HEIGHT, NODE_WIDTH, defaultLabel, describeFilterPredicate, flowingEdgeIds, layout, layoutIfUnarranged, nextPosition, toFlowEdges, toFlowNodes, } from './workflow/graph';
29
30
  import { PublishControls, RunControls, SchedulePanel, ShrinkRefusalNote, WorkflowStatusBadge, } from './workflow/lifecycle';
30
- import { WORKFLOW_BRANCH_LABELS, WORKFLOW_NODE_KINDS, callableWorkflowBlock, describeDurability, isWorkflowBranchLabel, isWorkflowNodeKind, isWorkflowPredicateKind, newLocalId, nodeName, producedTypes, unreachableNodeKind, unreachablePredicateKind, } from './workflow/model';
31
+ import { WORKFLOW_BRANCH_LABELS, WORKFLOW_FILTER_MAX_DEPTH, WORKFLOW_FILTER_MAX_VALUES, WORKFLOW_FILTER_OPERATORS, WORKFLOW_NODE_KINDS, callableWorkflowBlock, describeDurability, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicateKind, isWorkflowNodeKind, isWorkflowPredicateKind, newLocalId, nodeName, producedTypes, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, workflowNarrowedTypes, } from './workflow/model';
31
32
  import { WORKFLOW_NAME } from './workflow/name';
32
33
  import { WorkflowNodeProvider, workflowNodeTypes } from './workflow/nodes';
33
34
  import { RunsAsPanel } from './workflow/runs';
@@ -162,6 +163,30 @@ function newNodeOfKind(kind, id, position, name) {
162
163
  // threshold would publish happily while testing something nobody chose.
163
164
  return { id, name, kind: 'if', predicate: { kind: 'env', envVar: '' }, position };
164
165
  }
166
+ if (kind === 'filter') {
167
+ // One empty comparison rather than an empty `all`, and rather than nothing.
168
+ //
169
+ // Nothing is not available: the model has no "no predicate yet" state, on
170
+ // purpose, because a filter whose test is absent has to be given one by
171
+ // somebody and every default is a rule about rows nobody wrote. An empty
172
+ // `all` *is* representable and is refused by the validator, which is exactly
173
+ // why it is not the starting point — a group with no conditions keeps every
174
+ // row, so a filter that started that way would draw as a working node that
175
+ // does nothing.
176
+ //
177
+ // So it starts as one comparison with no column, which the validator refuses
178
+ // by name: the node says "needs a column" on the canvas from the moment it
179
+ // is dropped. The operator defaults to `equals` because it is the only one
180
+ // that is a guess about *form* rather than about data — every other choice
181
+ // implies something about the column's type before a column is chosen.
182
+ return {
183
+ id,
184
+ name,
185
+ kind: 'filter',
186
+ predicate: { kind: 'compare', column: '', operator: 'equals', value: '' },
187
+ position,
188
+ };
189
+ }
165
190
  if (kind === 'sink') {
166
191
  return { id, name, kind: 'sink', targetType: '', position };
167
192
  }
@@ -567,6 +592,12 @@ function miniMapColor(data) {
567
592
  // a graph too big to read, so it is the one place the two must not blur.
568
593
  if (kind === 'if')
569
594
  return '#d946ef';
595
+ // Rose-500, the filter's own accent (see `KIND_STYLE`), and specifically not
596
+ // the fuchsia beside it: the overview is where somebody looks for "where do
597
+ // rows disappear in this graph", and a gate and a filter are the two boxes
598
+ // that answer that question in completely different ways.
599
+ if (kind === 'filter')
600
+ return '#f43f5e';
570
601
  return '#8b5cf6';
571
602
  }
572
603
  /**
@@ -2233,6 +2264,288 @@ function RowCountPredicateFields({ predicate, canEdit, onChange, }) {
2233
2264
  });
2234
2265
  }, inputMode: "numeric", placeholder: "1", disabled: !canEdit, hint: "1 is \u201Cdid anything arrive at all\u201D. A larger number is for a load whose export is never legitimately small \u2014 under it, treat the upstream as broken rather than as data." }), _jsx("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: "The count is the one on the single wire feeding this node, taken from what that node recorded \u2014 nothing is re-counted, and nothing is read out of the staged rows." })] }));
2235
2266
  }
2267
+ /**
2268
+ * Building a filter's predicate, and acknowledging what it shrinks.
2269
+ *
2270
+ * Two halves, and the second one is the reason this inspector is not just a form
2271
+ * over a tree. The predicate editor is the ordinary part: a recursive tree of
2272
+ * conditions with "and"/"or" groups, built from the vocabulary core exports so a
2273
+ * form that offered an operator the runner cannot evaluate is a build failure
2274
+ * rather than a graph somebody saves and a step that throws mid-load.
2275
+ *
2276
+ * The acknowledgement is the part that matters. If this filter is the only thing
2277
+ * feeding a sink that *replaces* what a type publishes, then whatever it drops
2278
+ * disappears from that type — silently, because the run succeeds. The graph
2279
+ * cannot tell that apart from filtering to derive something new (see
2280
+ * `WorkflowFilterNode.narrows`: they are structurally identical graphs), so the
2281
+ * screen asks, per type, and the server refuses the graph until it is answered.
2282
+ * The switches below are that question, and they are shown *only* when the
2283
+ * question is live — offering them on a filter that narrows nothing would train
2284
+ * people to flip them.
2285
+ */
2286
+ function FilterInspector({ node, graph, canEdit, onChange, }) {
2287
+ // Core's answer, not this file's. A canvas that worked out its own set would
2288
+ // offer acknowledgements the server then refuses, which is a person ticking a
2289
+ // box to be told no.
2290
+ const narrowable = workflowNarrowedTypes(graph, node.id);
2291
+ const acknowledged = node.narrows ?? [];
2292
+ const setPredicate = (predicate) => onChange({ ...node, predicate });
2293
+ const setNarrows = (type, on) => {
2294
+ const next = on ? [...acknowledged, type] : acknowledged.filter((named) => named !== type);
2295
+ // Stored as absent rather than as `[]`, so "acknowledged nothing" has one
2296
+ // spelling. The boundary normalises the same way.
2297
+ onChange({ ...node, narrows: next.length === 0 ? undefined : next });
2298
+ };
2299
+ return (_jsxs("div", { className: "space-y-3", children: [_jsx(FilterPredicateEditor, { predicate: node.predicate, depth: 0, canEdit: canEdit, onChange: setPredicate, onRemove: undefined }), _jsxs("p", { className: cn('font-mono text-[10px] leading-relaxed', MUTED), children: ["keeps ", describeFilterPredicate(node.predicate)] }), _jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["Rows that match are passed on; the rest are dropped here. The run records", ' ', _jsx("strong", { children: "how many went in and how many came out" }), ", so the panel can say what this node removed \u2014 a filter whose effect is invisible is how data goes missing quietly."] }), _jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["A column with no value never matches, not even a \u201Cdoes not equal\u201D test \u2014 that is what a database would answer, and it is what keeps this test meaning the same thing if it is ever pushed into the source query. Use ", _jsx("em", { children: "is empty" }), " to find those rows. A value the test cannot compare against \u2014 text where the test names a number \u2014 does not match either, and the run says how many of those there were."] }), narrowable.length > 0 && (_jsx(FieldGroup, { title: "What this shrinks", hint: _jsxs(_Fragment, { children: ["This filter is the only thing feeding", ' ', narrowable.length === 1 ? 'a sink that replaces' : 'sinks that replace', " what", ' ', narrowable.length === 1 ? 'a type publishes' : 'these types publish', ". So everything it drops disappears from ", narrowable.length === 1 ? 'that type' : 'those types', " the next time this graph runs, and the run reports success while doing it. Say so here if that is what you mean. If you meant to build something new out of a subset, point the sink at a different object type; if you meant to add rows rather than replace them, set the sink to incremental."] }), children: narrowable.map((type) => (_jsx(Switch, { checked: acknowledged.includes(type), onCheckedChange: (on) => setNarrows(type, on), disabled: !canEdit, label: `Replace what ${type} publishes with the rows that pass`, hint: `The published snapshot of ${type} will hold only what this filter keeps. The type's row-count bound still applies and can still refuse the commit.` }, type))) })), acknowledged.some((type) => !narrowable.includes(type)) && (_jsxs("p", { className: "text-[11px] leading-relaxed text-amber-600 dark:text-amber-400", children: ["This filter says it narrows", ' ', acknowledged
2300
+ .filter((type) => !narrowable.includes(type))
2301
+ .map((type) => `“${type}”`)
2302
+ .join(', '), ", and it no longer does \u2014 rows now reach that sink another way, or it merges rather than replaces. Turn it off: an acknowledgement nothing reads is worse than none, because the next reader believes it."] }))] }));
2303
+ }
2304
+ /**
2305
+ * One node of the predicate tree: a group, or a single condition.
2306
+ *
2307
+ * Recursive rather than flattened, because the model is a tree and a flat list
2308
+ * of conditions with a single and/or toggle cannot express "A and (B or C)" —
2309
+ * which is the second thing anybody wants after "A and B".
2310
+ *
2311
+ * `onRemove` is absent exactly at the root, which is what makes the root
2312
+ * unremovable without a separate flag: a predicate is required, so there is
2313
+ * always at least one condition and the button that would delete the last one
2314
+ * does not exist.
2315
+ */
2316
+ function FilterPredicateEditor({ predicate, depth, canEdit, onChange, onRemove, }) {
2317
+ if (predicate.kind === 'all' || predicate.kind === 'any') {
2318
+ return (_jsx(FilterGroupEditor, { predicate: predicate, depth: depth, canEdit: canEdit, onChange: onChange, onRemove: onRemove }));
2319
+ }
2320
+ return (_jsx(FilterConditionEditor, { predicate: predicate, depth: depth, canEdit: canEdit, onChange: onChange, onRemove: onRemove }));
2321
+ }
2322
+ /** The word between a group's conditions, and the two ways to add another one. */
2323
+ function FilterGroupEditor({ predicate, depth, canEdit, onChange, onRemove, }) {
2324
+ const replaceChild = (index, child) => onChange({
2325
+ ...predicate,
2326
+ children: predicate.children.map((existing, at) => (at === index ? child : existing)),
2327
+ });
2328
+ // Removing the last child would leave an empty group, which keeps every row
2329
+ // (`all`) or drops every row (`any`) and is refused by the validator. Rather
2330
+ // than let somebody build one and then be told, removing the second-to-last
2331
+ // child collapses the group into the one that is left.
2332
+ const removeChild = (index) => {
2333
+ const left = predicate.children.filter((_, at) => at !== index);
2334
+ onChange(left.length === 1 ? left[0] : { ...predicate, children: left });
2335
+ };
2336
+ return (_jsxs("div", { className: cn('space-y-2 rounded-md border px-2 py-2', RULE), children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(SelectField, { label: "Match", ariaLabel: "Whether every condition in this group has to match, or any one of them", value: predicate.kind, onValueChange: (kind) => {
2337
+ if (kind !== 'all' && kind !== 'any')
2338
+ return;
2339
+ onChange({ ...predicate, kind });
2340
+ }, options: [
2341
+ { value: 'all', label: 'Every condition', hint: 'and' },
2342
+ { value: 'any', label: 'Any one condition', hint: 'or' },
2343
+ ], disabled: !canEdit }) }), onRemove && canEdit && (_jsx(Button, { variant: "ghost", size: "sm", onClick: onRemove, className: "mt-4 shrink-0", children: "Remove group" }))] }), predicate.children.map((child, index) => (_jsx(FilterPredicateEditor
2344
+ // Positional keys, because a condition has no id and nothing in this
2345
+ // tree is reordered — the only edits are replace-in-place, append and
2346
+ // remove, and a removal re-renders the whole subtree from the model
2347
+ // anyway. There is no draft state below this point to be preserved.
2348
+ // biome-ignore lint/suspicious/noArrayIndexKey: see above
2349
+ , { predicate: child, depth: depth + 1, canEdit: canEdit, onChange: (next) => replaceChild(index, next), onRemove: () => removeChild(index) }, index))), canEdit && (_jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", onClick: () => onChange({ ...predicate, children: [...predicate.children, freshFilterCondition()] }), children: "Add condition" }), depth + 1 < WORKFLOW_FILTER_MAX_DEPTH && (_jsx(Button, { variant: "outline", size: "sm", onClick: () => onChange({
2350
+ ...predicate,
2351
+ children: [
2352
+ ...predicate.children,
2353
+ { kind: 'any', children: [freshFilterCondition()] },
2354
+ ],
2355
+ }), children: "Add group" }))] }))] }));
2356
+ }
2357
+ /** One condition: a column, a test, and whatever that test compares against. */
2358
+ function FilterConditionEditor({ predicate, depth, canEdit, onChange, onRemove, }) {
2359
+ return (_jsxs("div", { className: cn('space-y-2 rounded-md border px-2 py-2', RULE), children: [_jsx(TextField, { label: "Column", value: predicate.column, onChange: (column) => onChange({ ...predicate, column }), placeholder: "status", disabled: !canEdit, hint: "The bare name as the rows carry it \u2014 letters, digits and underscore, starting with a letter or underscore. No table prefix and no expression: the name has to be usable as an identifier so this test can one day be handed to the source as a WHERE. Rename anything else in a transform first." }), _jsx(SelectField, { label: "Test", ariaLabel: "What kind of test this condition makes", value: predicate.kind, onValueChange: (kind) => {
2360
+ if (!isWorkflowFilterPredicateKind(kind))
2361
+ return;
2362
+ onChange(retargetFilterCondition(predicate, kind));
2363
+ }, options: [
2364
+ { value: 'compare', label: 'Compare against a value' },
2365
+ { value: 'oneOf', label: 'Is one of a list' },
2366
+ { value: 'present', label: 'Is empty, or has a value' },
2367
+ ], disabled: !canEdit }), _jsx(FilterConditionFields, { predicate: predicate, canEdit: canEdit, onChange: onChange }), onRemove && canEdit && (_jsx("div", { className: "flex justify-end", children: _jsx(Button, { variant: "ghost", size: "sm", onClick: onRemove, children: "Remove condition" }) })), depth === 0 && canEdit && (
2368
+ // The root starts as a single condition, so the only way to reach a
2369
+ // group is from here. Wrapping rather than offering a group at the top
2370
+ // level keeps a one-condition filter looking like a one-condition
2371
+ // filter, which is what nearly all of them are.
2372
+ _jsx("div", { className: "flex justify-end", children: _jsx(Button, { variant: "outline", size: "sm", onClick: () => onChange({ kind: 'all', children: [predicate, freshFilterCondition()] }), children: "Add another condition" }) }))] }));
2373
+ }
2374
+ /**
2375
+ * The fields one kind of condition has, and none of the fields the others have.
2376
+ *
2377
+ * Split per kind and ending in a refusal, for the reason `PredicateFields`
2378
+ * gives about gates: a kind added to the model without a form here would be a
2379
+ * condition somebody can select, that shows nothing to fill in, and that decides
2380
+ * which rows a published type contains.
2381
+ */
2382
+ function FilterConditionFields({ predicate, canEdit, onChange, }) {
2383
+ if (predicate.kind === 'present') {
2384
+ return (_jsx(SelectField, { label: "Has a value?", ariaLabel: "Whether the column has to be empty or has to hold something", value: predicate.operator, onValueChange: (operator) => {
2385
+ if (operator !== 'isNull' && operator !== 'isNotNull')
2386
+ return;
2387
+ onChange({ ...predicate, operator });
2388
+ }, options: [
2389
+ { value: 'isNotNull', label: 'Has a value' },
2390
+ { value: 'isNull', label: 'Is empty' },
2391
+ ], disabled: !canEdit, hint: "The only test that can see an empty column. Every other test here treats an empty value as \u201Ccannot say\u201D, which never matches." }));
2392
+ }
2393
+ if (predicate.kind === 'oneOf') {
2394
+ return (_jsxs(_Fragment, { children: [_jsx(SelectField, { label: "In the list?", ariaLabel: "Whether the column has to be in the list or out of it", value: predicate.operator, onValueChange: (operator) => {
2395
+ if (operator !== 'in' && operator !== 'notIn')
2396
+ return;
2397
+ onChange({ ...predicate, operator });
2398
+ }, options: [
2399
+ { value: 'in', label: 'Is one of these' },
2400
+ { value: 'notIn', label: 'Is none of these' },
2401
+ ], disabled: !canEdit }), _jsx(FilterValueTypeField, { value: predicate.values[0], canEdit: canEdit, onChange: (sample) => onChange({
2402
+ ...predicate,
2403
+ values: predicate.values.map((existing) => castFilterValue(existing, sample)),
2404
+ }) }), _jsx(TextAreaField, { label: "Values", value: predicate.values.map((value) => String(value)).join('\n'), onChange: (text) => onChange({ ...predicate, values: parseFilterValues(text, predicate.values[0]) }), rows: 4, mono: true, disabled: !canEdit, hint: `One per line. At most ${WORKFLOW_FILTER_MAX_VALUES} — past that this is a join against another dataset rather than a filter, and the thing to do is read that dataset in as a second source.` })] }));
2405
+ }
2406
+ if (predicate.kind === 'compare') {
2407
+ return (_jsxs(_Fragment, { children: [_jsx(SelectField, { label: "Comparison", ariaLabel: "How the column is compared against the value", value: predicate.operator, onValueChange: (operator) => {
2408
+ if (!isWorkflowFilterOperator(operator))
2409
+ return;
2410
+ onChange({ ...predicate, operator });
2411
+ }, options: WORKFLOW_FILTER_OPERATORS.map((operator) => ({
2412
+ value: operator,
2413
+ label: FILTER_OPERATOR_LABELS[operator],
2414
+ })), disabled: !canEdit }), _jsx(FilterValueTypeField, { value: predicate.value, canEdit: canEdit, onChange: (sample) => onChange({ ...predicate, value: castFilterValue(predicate.value, sample) }) }), _jsx(FilterValueField, { value: predicate.value, canEdit: canEdit, onChange: (value) => onChange({ ...predicate, value }) })] }));
2415
+ }
2416
+ return unreachableFilterPredicateKind(predicate, 'FilterConditionFields');
2417
+ }
2418
+ /**
2419
+ * Each operator, spelled out in a sentence rather than in symbols.
2420
+ *
2421
+ * The node's face uses `>` and `≥` because it has 224 pixels; a dropdown has
2422
+ * room, and "is after / greater than" is what somebody scanning a list of ten
2423
+ * options is actually reading for. A `Record` keyed by the union, so an operator
2424
+ * added to core without a label here stops the build rather than rendering an
2425
+ * empty row in a select.
2426
+ */
2427
+ const FILTER_OPERATOR_LABELS = {
2428
+ equals: 'equals',
2429
+ notEquals: 'does not equal',
2430
+ greaterThan: 'is greater than',
2431
+ greaterThanOrEqual: 'is greater than or equal to',
2432
+ lessThan: 'is less than',
2433
+ lessThanOrEqual: 'is less than or equal to',
2434
+ contains: 'contains',
2435
+ notContains: 'does not contain',
2436
+ startsWith: 'starts with',
2437
+ notStartsWith: 'does not start with',
2438
+ };
2439
+ /**
2440
+ * Whether the value is text, a number, or true/false.
2441
+ *
2442
+ * A visible choice rather than something inferred from what was typed, and this
2443
+ * is the field most likely to be mistaken for clutter. It is not: `"10"` and
2444
+ * `10` are different values here and neither matches the other, exactly as a
2445
+ * strongly-typed column would answer, and a form that guessed from the
2446
+ * characters would silently flip a text column's test to numeric the moment
2447
+ * somebody filtered on an order number. The run log reports those rows as
2448
+ * incomparable; this field is how they are avoided in the first place.
2449
+ */
2450
+ function FilterValueTypeField({ value, canEdit, onChange, }) {
2451
+ return (_jsx(SelectField, { label: "Value type", ariaLabel: "Whether the value is text, a number, or true/false", value: typeof value === 'number' ? 'number' : typeof value === 'boolean' ? 'boolean' : 'text', onValueChange: (type) => {
2452
+ if (type === 'number')
2453
+ return onChange(0);
2454
+ if (type === 'boolean')
2455
+ return onChange(true);
2456
+ onChange('');
2457
+ }, options: [
2458
+ { value: 'text', label: 'Text' },
2459
+ { value: 'number', label: 'A number' },
2460
+ { value: 'boolean', label: 'True or false' },
2461
+ ], disabled: !canEdit, hint: "Text and numbers are never equal to each other here, and neither is greater or less than the other \u2014 a row whose column holds the wrong one of the two is reported on the run rather than quietly matching. Dates are text: ISO-8601 sorts correctly." }));
2462
+ }
2463
+ /** The value itself, in whichever control the chosen type deserves. */
2464
+ function FilterValueField({ value, canEdit, onChange, }) {
2465
+ if (typeof value === 'boolean') {
2466
+ return (_jsx(SelectField, { label: "Value", ariaLabel: "The true or false value this column is compared against", value: value ? 'true' : 'false', onValueChange: (chosen) => onChange(chosen === 'true'), options: [
2467
+ { value: 'true', label: 'True' },
2468
+ { value: 'false', label: 'False' },
2469
+ ], disabled: !canEdit }));
2470
+ }
2471
+ if (typeof value === 'number') {
2472
+ return (_jsx(TextField, { label: "Value",
2473
+ // A text box with a numeric keypad rather than `type="number"`, which is
2474
+ // the rule the row-count threshold above already writes down: that
2475
+ // control drops what it cannot parse and answers a scroll wheel.
2476
+ value: Number.isFinite(value) ? String(value) : '', onChange: (typed) => {
2477
+ const cleaned = typed.replace(/[^0-9.-]/g, '');
2478
+ const parsed = Number.parseFloat(cleaned);
2479
+ // An unparseable box stores 0 rather than `NaN`: every comparison
2480
+ // against `NaN` is false, so a filter holding one drops every row
2481
+ // while looking perfectly well configured — and the model refuses to
2482
+ // store it, so the graph could not be saved to find that out.
2483
+ onChange(Number.isFinite(parsed) ? parsed : 0);
2484
+ }, inputMode: "numeric", placeholder: "0", disabled: !canEdit }));
2485
+ }
2486
+ return (_jsx(TextField, { label: "Value", value: value, onChange: onChange, placeholder: "OPEN", disabled: !canEdit, hint: "Compared exactly, with no trimming and no case folding. Collation is a property of the column in every database this runs against, so a case-insensitive test evaluated here and the same one evaluated in the source would legitimately disagree \u2014 normalise in a transform instead." }));
2487
+ }
2488
+ /** A condition somebody has not filled in yet. Refused by the validator until they do. */
2489
+ function freshFilterCondition() {
2490
+ return { kind: 'compare', column: '', operator: 'equals', value: '' };
2491
+ }
2492
+ /**
2493
+ * The same condition, asked to be a different kind of test.
2494
+ *
2495
+ * The **column is carried across** and nothing else is, which is the split worth
2496
+ * arguing: the column is what somebody typed and is the expensive half to
2497
+ * retype, while an operator and a value belong to the test that is being left
2498
+ * behind — `greaterThan` has no meaning for a presence check and a value has
2499
+ * none either.
2500
+ */
2501
+ function retargetFilterCondition(predicate, kind) {
2502
+ if (kind === 'compare') {
2503
+ return { kind: 'compare', column: predicate.column, operator: 'equals', value: '' };
2504
+ }
2505
+ if (kind === 'oneOf') {
2506
+ return { kind: 'oneOf', column: predicate.column, operator: 'in', values: [''] };
2507
+ }
2508
+ if (kind === 'present') {
2509
+ return { kind: 'present', column: predicate.column, operator: 'isNotNull' };
2510
+ }
2511
+ // The two group kinds are reachable from the select's type but never from its
2512
+ // options, because a group is added by its own button and is not a *test* a
2513
+ // condition can be switched to. Refusing rather than building one keeps the
2514
+ // exhaustiveness honest without pretending this is a conversion.
2515
+ if (kind === 'all' || kind === 'any')
2516
+ return predicate;
2517
+ return unreachableFilterPredicateKind(kind, 'retargetFilterCondition');
2518
+ }
2519
+ /** One value, moved to the type of a sample, keeping whatever survives the move. */
2520
+ function castFilterValue(value, sample) {
2521
+ if (typeof sample === 'number') {
2522
+ const parsed = typeof value === 'number' ? value : Number.parseFloat(String(value));
2523
+ return Number.isFinite(parsed) ? parsed : 0;
2524
+ }
2525
+ if (typeof sample === 'boolean')
2526
+ return value === true || value === 'true';
2527
+ return String(value);
2528
+ }
2529
+ /**
2530
+ * A textarea of values, one per line, in the type the list is already in.
2531
+ *
2532
+ * Blank lines are dropped rather than kept as empty strings, because a trailing
2533
+ * newline is what a textarea has after every entry and a list ending in `""`
2534
+ * would filter for a value nobody typed. An entirely empty box keeps one blank
2535
+ * entry: the model refuses an empty list, and clearing the box should leave a
2536
+ * condition to finish rather than a graph that cannot be saved with no visible
2537
+ * cause.
2538
+ */
2539
+ function parseFilterValues(text, sample) {
2540
+ const lines = text
2541
+ .split('\n')
2542
+ .map((line) => line.trim())
2543
+ .filter((line) => line.length > 0);
2544
+ if (lines.length === 0)
2545
+ return [''];
2546
+ const cast = sample ?? '';
2547
+ return lines.slice(0, WORKFLOW_FILTER_MAX_VALUES).map((line) => castFilterValue(line, cast));
2548
+ }
2236
2549
  /**
2237
2550
  * The parameter box's two directions, kept together because they are inverses.
2238
2551
  *
@@ -2274,7 +2587,7 @@ function parseConfigText(text) {
2274
2587
  * a kind added without a branch here shows up as a node with a name and nothing
2275
2588
  * to configure, which is visible on the screen rather than silent.
2276
2589
  */
2277
- function KindInspector({ node, transforms, connections, typeOptions, canEdit, modelHref, discovery, discoverable, onDiscovered, onChange, onEditCode, onCreateTransform, creatingTransform, createTransformError, }) {
2590
+ function KindInspector({ node, graph, transforms, connections, typeOptions, canEdit, modelHref, discovery, discoverable, onDiscovered, onChange, onEditCode, onCreateTransform, creatingTransform, createTransformError, }) {
2278
2591
  if (node.kind === 'transform') {
2279
2592
  return (_jsx(TransformInspector, { node: node, transforms: transforms, canEdit: canEdit, creating: creatingTransform, createError: createTransformError, onChange: onChange, onEditCode: onEditCode, onCreate: onCreateTransform }));
2280
2593
  }
@@ -2294,6 +2607,13 @@ function KindInspector({ node, transforms, connections, typeOptions, canEdit, mo
2294
2607
  if (node.kind === 'if') {
2295
2608
  return _jsx(IfInspector, { node: node, canEdit: canEdit, onChange: onChange }, node.id);
2296
2609
  }
2610
+ if (node.kind === 'filter') {
2611
+ // Given the whole graph, not only the node, because the one question this
2612
+ // inspector cannot answer from the node alone is the important one: which
2613
+ // published types this filter stands in front of. See
2614
+ // `WorkflowFilterNode.narrows`.
2615
+ return (_jsx(FilterInspector, { node: node, graph: graph, canEdit: canEdit, onChange: onChange }, node.id));
2616
+ }
2297
2617
  if (node.kind === 'sink') {
2298
2618
  return (_jsx(SinkInspector, { node: node, typeOptions: typeOptions, canEdit: canEdit, modelHref: modelHref, onChange: onChange }));
2299
2619
  }
@@ -2344,7 +2664,7 @@ function NodeInspector({ node, draft, transforms, connections, typeOptions, canE
2344
2664
  return (_jsx(Sheet, { open: node !== null, onOpenChange: (open) => {
2345
2665
  if (!open)
2346
2666
  onClose();
2347
- }, 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." }), _jsx(KindInspector, { node: node, transforms: transforms, connections: connections, typeOptions: typeOptions, canEdit: canEdit, modelHref: modelHref, discovery: discovery, discoverable: discoverable, onDiscovered: onDiscovered, onChange: onChange, onEditCode: onEditCode, onCreateTransform: onCreateTransform, creatingTransform: creatingTransform, createTransformError: createTransformError }), _jsx(WiringList, { title: "Fed by", edges: incoming, otherEnd: (edge) => label(edge.from), describeRemoval: (name) => `Stop ${name} feeding this node`, canEdit: canEdit, onDisconnect: onDisconnect, children: incoming.length > 1 && (_jsx("p", { className: cn('mt-1 text-[11px] leading-relaxed', MUTED), children: "Inputs arrive in this order, and the order is part of what the graph produces \u2014 a transform joining two feeds sees them exactly like this." })) }), _jsxs(WiringList, { title: "Feeds", edges: outgoing, otherEnd: (edge) => label(edge.to), describeRemoval: (name) => `Stop this node feeding ${name}`, canEdit: canEdit, onDisconnect: onDisconnect,
2667
+ }, 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." }), _jsx(KindInspector, { node: node, graph: draft, transforms: transforms, connections: connections, typeOptions: typeOptions, canEdit: canEdit, modelHref: modelHref, discovery: discovery, discoverable: discoverable, onDiscovered: onDiscovered, onChange: onChange, onEditCode: onEditCode, onCreateTransform: onCreateTransform, creatingTransform: creatingTransform, createTransformError: createTransformError }), _jsx(WiringList, { title: "Fed by", edges: incoming, otherEnd: (edge) => label(edge.from), describeRemoval: (name) => `Stop ${name} feeding this node`, canEdit: canEdit, onDisconnect: onDisconnect, children: incoming.length > 1 && (_jsx("p", { className: cn('mt-1 text-[11px] leading-relaxed', MUTED), children: "Inputs arrive in this order, and the order is part of what the graph produces \u2014 a transform joining two feeds sees them exactly like this." })) }), _jsxs(WiringList, { title: "Feeds", edges: outgoing, otherEnd: (edge) => label(edge.to), describeRemoval: (name) => `Stop this node feeding ${name}`, canEdit: canEdit, onDisconnect: onDisconnect,
2348
2668
  // Only a gate's wires have a side to be on. `validateWorkflow`
2349
2669
  // refuses a label on any other wire, so offering the control there
2350
2670
  // would be offering a change the server will not take.
@@ -1,5 +1,5 @@
1
1
  import type { Edge, Node } from '@xyflow/react';
2
- import { type WorkflowEdge, type WorkflowNode, type WorkflowNodeKind, type WorkflowRunNode } from './model';
2
+ import { type WorkflowEdge, type WorkflowFilterPredicate, type WorkflowNode, type WorkflowNodeKind, type WorkflowRunNode } from './model';
3
3
  import { type WorkflowProblem } from './validate';
4
4
  /**
5
5
  * Turning the stored graph into what React Flow draws, and back.
@@ -60,6 +60,29 @@ export interface NodeDescriptions {
60
60
  transformName(id: string | undefined): string | undefined;
61
61
  connectionName(id: string | undefined): string | undefined;
62
62
  }
63
+ /**
64
+ * A predicate as a sentence.
65
+ *
66
+ * Shared by the node's face and by the inspector's summary, so the two cannot
67
+ * describe one filter differently — which on a screen whose whole job is making
68
+ * a drop visible would be worse than describing it badly.
69
+ *
70
+ * Groups are parenthesised whenever they are nested, and never at the top, so
71
+ * the common single-group predicate reads as a list rather than as a formula.
72
+ */
73
+ export declare function describeFilterPredicate(predicate: WorkflowFilterPredicate, nested?: boolean): string;
74
+ /**
75
+ * What a filter did to a run, as a phrase — or nothing, for every other node.
76
+ *
77
+ * Keyed off `rowsIn` being **present** rather than off the node's kind, which is
78
+ * the only check that stays right in both directions: a filter that ran before
79
+ * the server recorded an input count has no drop to report and must not claim
80
+ * one, and no other kind sets the field at all. Subtracting from a defaulted
81
+ * zero would make every historical node read as having dropped its whole output.
82
+ *
83
+ * Exported so the node badge and the aria label say the same sentence.
84
+ */
85
+ export declare function describeDrop(run: WorkflowRunNode): string | undefined;
63
86
  export declare function toFlowNodes(nodes: WorkflowNode[], edges: WorkflowEdge[], describe: NodeDescriptions, problemsFor: Map<string, WorkflowProblem[]>, runFor: Map<string, WorkflowRunNode>): WorkflowFlowNode[];
64
87
  export declare function defaultLabel(kind: WorkflowNodeKind): string;
65
88
  /**
@@ -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, unreachableNodeKind, unreachablePredicateKind, } from './model';
3
+ import { nodeName, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, } from './model';
4
4
  import { edgeId } from './validate';
5
5
  /**
6
6
  * Turning the stored graph into what React Flow draws, and back.
@@ -50,11 +50,121 @@ function subtitleFor(node, describe) {
50
50
  return callSubtitle(node);
51
51
  if (node.kind === 'if')
52
52
  return ifSubtitle(node);
53
+ if (node.kind === 'filter')
54
+ return filterSubtitle(node);
53
55
  if (node.kind === 'transform') {
54
56
  return describe.transformName(node.transformId) ?? 'no transform chosen';
55
57
  }
56
58
  return unreachableNodeKind(node, 'subtitleFor');
57
59
  }
60
+ /**
61
+ * How much a node's face will spend on a predicate before summarising it.
62
+ *
63
+ * A node is 224px wide and the subtitle is one truncated line, so a long
64
+ * predicate spelled out in full is an ellipsis and nothing else. Past this many
65
+ * leaves the face says how many conditions there are instead, which at least
66
+ * tells a reader there is something to open.
67
+ */
68
+ const FILTER_FACE_LEAVES = 2;
69
+ /**
70
+ * The test, on the face of the node — the reason this kind exists rather than a
71
+ * transform that returns a subset.
72
+ *
73
+ * "Keep the open orders" readable off the canvas is reason one of three on
74
+ * `WorkflowFilterNode`, so the subtitle is the feature and not decoration. It
75
+ * shows the *values* as well as the columns, which is a difference from
76
+ * `ifSubtitle` and a deliberate one: an if node stores the name of an
77
+ * environment variable and never its contents, because that is where a
78
+ * credential would be, while a filter's value is a business constant somebody
79
+ * typed into the graph and is already visible to anyone who can see the node.
80
+ *
81
+ * The predicate is read into a variable that admits `undefined` before it is
82
+ * narrowed, for the reason `ifSubtitle` gives: this draws whatever a server
83
+ * sent, and a canvas that throws while rendering a node is a screen nobody can
84
+ * use to fix that node.
85
+ */
86
+ function filterSubtitle(node) {
87
+ const predicate = node.predicate;
88
+ if (!predicate)
89
+ return 'nothing to test';
90
+ const leaves = countFilterLeaves(predicate);
91
+ if (leaves > FILTER_FACE_LEAVES)
92
+ return `keeps rows matching ${leaves} conditions`;
93
+ return `keeps ${describeFilterPredicate(predicate)}`;
94
+ }
95
+ /** How many comparisons a predicate is made of, groups not counted. */
96
+ function countFilterLeaves(predicate) {
97
+ if (predicate.kind === 'all' || predicate.kind === 'any') {
98
+ let total = 0;
99
+ for (const child of predicate.children)
100
+ total += countFilterLeaves(child);
101
+ return total;
102
+ }
103
+ return 1;
104
+ }
105
+ /**
106
+ * A predicate as a sentence.
107
+ *
108
+ * Shared by the node's face and by the inspector's summary, so the two cannot
109
+ * describe one filter differently — which on a screen whose whole job is making
110
+ * a drop visible would be worse than describing it badly.
111
+ *
112
+ * Groups are parenthesised whenever they are nested, and never at the top, so
113
+ * the common single-group predicate reads as a list rather than as a formula.
114
+ */
115
+ export function describeFilterPredicate(predicate, nested = false) {
116
+ if (predicate.kind === 'all' || predicate.kind === 'any') {
117
+ const joined = predicate.children
118
+ .map((child) => describeFilterPredicate(child, true))
119
+ .join(predicate.kind === 'all' ? ' and ' : ' or ');
120
+ return nested && predicate.children.length > 1 ? `(${joined})` : joined;
121
+ }
122
+ if (predicate.kind === 'present') {
123
+ return `${predicate.column} ${predicate.operator === 'isNull' ? 'is empty' : 'has a value'}`;
124
+ }
125
+ if (predicate.kind === 'oneOf') {
126
+ const values = predicate.values.map((value) => showFilterValue(value)).join(', ');
127
+ return `${predicate.column} ${predicate.operator === 'in' ? 'is one of' : 'is none of'} ${values}`;
128
+ }
129
+ if (predicate.kind === 'compare') {
130
+ return `${predicate.column} ${FILTER_OPERATOR_WORDS[predicate.operator]} ${showFilterValue(predicate.value)}`;
131
+ }
132
+ return unreachableFilterPredicateKind(predicate, 'describeFilterPredicate');
133
+ }
134
+ /**
135
+ * Each operator as the words a reader of the canvas would use.
136
+ *
137
+ * A `Record` keyed by the operator union, so an operator added to core without a
138
+ * phrase here is a build failure rather than a node whose subtitle silently says
139
+ * `undefined` — the same reason `BRANCH_STYLE` above is a record.
140
+ *
141
+ * Symbols rather than words for the four orderings, because `>` is unambiguous
142
+ * in every locale a column name is written in and "greater than" is three words
143
+ * of a line that has to fit in 224 pixels.
144
+ */
145
+ const FILTER_OPERATOR_WORDS = {
146
+ equals: '=',
147
+ notEquals: '≠',
148
+ greaterThan: '>',
149
+ greaterThanOrEqual: '≥',
150
+ lessThan: '<',
151
+ lessThanOrEqual: '≤',
152
+ contains: 'contains',
153
+ notContains: 'does not contain',
154
+ startsWith: 'starts with',
155
+ notStartsWith: 'does not start with',
156
+ };
157
+ /**
158
+ * One value, quoted only when it is text.
159
+ *
160
+ * `status = "OPEN"` and `qty = 10` are different tests, and the quotes are the
161
+ * only thing on the face that says which — three-valued logic aside, a string
162
+ * `"10"` never equals a number `10` here, and that is exactly the mistake the
163
+ * run log has to report as an incomparable value.
164
+ */
165
+ function showFilterValue(value) {
166
+ return typeof value === 'string' ? `"${value}"` : String(value);
167
+ }
58
168
  /**
59
169
  * The test, on the face of the node.
60
170
  *
@@ -134,12 +244,41 @@ function ariaLabelFor(node, data, incoming, outgoing) {
134
244
  const because = data.run.skippedBecause === 'branch-not-taken'
135
245
  ? ', because it is on the branch that was not taken, so it committed nothing'
136
246
  : '';
137
- parts.push(`last run ${data.run.status}${branch}${because}`);
247
+ // The drop is in the spoken label as well as the tooltip, because a tooltip
248
+ // is a hover and this is the sentence a screen reader user gets instead of
249
+ // the whole canvas. A filter that dropped nine tenths of a load and said so
250
+ // only on hover would be invisible to exactly the reader who cannot check.
251
+ const dropped = describeDrop(data.run);
252
+ parts.push(`last run ${data.run.status}${branch}${because}${dropped ? `, ${dropped}` : ''}`);
138
253
  }
139
254
  for (const problem of data.problems)
140
255
  parts.push(problem.message);
141
256
  return parts.join('. ');
142
257
  }
258
+ /**
259
+ * What a filter did to a run, as a phrase — or nothing, for every other node.
260
+ *
261
+ * Keyed off `rowsIn` being **present** rather than off the node's kind, which is
262
+ * the only check that stays right in both directions: a filter that ran before
263
+ * the server recorded an input count has no drop to report and must not claim
264
+ * one, and no other kind sets the field at all. Subtracting from a defaulted
265
+ * zero would make every historical node read as having dropped its whole output.
266
+ *
267
+ * Exported so the node badge and the aria label say the same sentence.
268
+ */
269
+ export function describeDrop(run) {
270
+ const given = run.rowsIn;
271
+ if (typeof given !== 'number' || typeof run.rows !== 'number')
272
+ return undefined;
273
+ const dropped = given - run.rows;
274
+ if (dropped <= 0)
275
+ return `${given} rows in, none dropped`;
276
+ // The percentage is what makes the number readable: "7,541,187 dropped" needs
277
+ // arithmetic before anybody can tell a working filter from a broken predicate,
278
+ // and "98.7%" does not.
279
+ const share = given === 0 ? 0 : Math.round((dropped / given) * 1000) / 10;
280
+ return `${given} rows in, ${run.rows} out — ${dropped} dropped (${share}%)`;
281
+ }
143
282
  export function toFlowNodes(nodes, edges, describe, problemsFor, runFor) {
144
283
  const labelOf = new Map(nodes.map((node) => [node.id, nodeName(node)]));
145
284
  const names = (ids) => ids.map((id) => labelOf.get(id) ?? id);
@@ -189,6 +328,8 @@ export function defaultLabel(kind) {
189
328
  return 'Call';
190
329
  if (kind === 'if')
191
330
  return 'If';
331
+ if (kind === 'filter')
332
+ return 'Filter';
192
333
  if (kind === 'transform')
193
334
  return 'Transform';
194
335
  return unreachableNodeKind(kind, 'defaultLabel');
@@ -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, WorkflowBranchLabel, WorkflowEdge, WorkflowCallNode, WorkflowEnvPredicate, WorkflowGraph, WorkflowIfNode, WorkflowIfPredicate, WorkflowNode, WorkflowNodeKind, WorkflowPredicateKind, WorkflowRowCountPredicate, WorkflowSinkNode, WorkflowSkipReason, WorkflowSourceNode, WorkflowTransformNode, } from '@dudousxd/nestjs-catalog/client';
22
- export { callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowNodeKind, isWorkflowPredicateKind, unreachableNodeKind, unreachablePredicateKind, WORKFLOW_BRANCH_LABELS, WORKFLOW_PREDICATE_KINDS, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
21
+ export type { CallableWorkflowBlock, CallableWorkflowDisagreement, CallableWorkflowRef, CatalogWorkflow, WorkflowBranchLabel, WorkflowEdge, WorkflowCallNode, WorkflowEnvPredicate, WorkflowFilterAll, WorkflowFilterAny, WorkflowFilterComparison, WorkflowFilterGroup, WorkflowFilterNode, WorkflowFilterOneOf, WorkflowFilterOperator, WorkflowFilterPredicate, WorkflowFilterPredicateKind, WorkflowFilterPresence, WorkflowFilterValue, WorkflowGraph, WorkflowIfNode, WorkflowIfPredicate, WorkflowNode, WorkflowNodeKind, WorkflowPredicateKind, WorkflowRowCountPredicate, WorkflowSinkNode, WorkflowSkipReason, WorkflowSourceNode, WorkflowTransformNode, } from '@dudousxd/nestjs-catalog/client';
22
+ export { callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicate, isWorkflowFilterPredicateKind, isWorkflowFilterValue, isWorkflowNodeKind, isWorkflowPredicateKind, unreachableFilterOperator, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, 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_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.
@@ -132,6 +132,17 @@ export interface WorkflowRunNode {
132
132
  */
133
133
  skippedBecause?: WorkflowSkipReason;
134
134
  rows?: number;
135
+ /**
136
+ * What a filter node was handed, where {@link rows} is what it passed on.
137
+ *
138
+ * The pair is the whole reporting contract of a filter, and both halves have
139
+ * to reach the screen or the node's effect is invisible — which is how rows go
140
+ * missing quietly. Absent on every other kind, and absent on filters that ran
141
+ * before the server recorded it; a panel must therefore check for its presence
142
+ * rather than subtract from a defaulted zero, or every historical node would
143
+ * claim to have dropped everything it produced.
144
+ */
145
+ rowsIn?: number;
135
146
  error?: string;
136
147
  startedAt?: string;
137
148
  finishedAt?: string;
@@ -23,7 +23,12 @@ 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, isWorkflowNodeKind, isWorkflowPredicateKind, unreachableNodeKind, unreachablePredicateKind, WORKFLOW_BRANCH_LABELS, WORKFLOW_PREDICATE_KINDS, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
26
+ callableWorkflowBlock, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicate, isWorkflowFilterPredicateKind, isWorkflowFilterValue, isWorkflowNodeKind, isWorkflowPredicateKind, unreachableFilterOperator, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind,
27
+ // Core's, not a copy, for the reason every other rule here is core's: the
28
+ // inspector has to offer exactly the acknowledgements `validateWorkflow`
29
+ // requires, and a screen that worked out its own list would offer a set the
30
+ // server then refuses — with the person having ticked a box to be told no.
31
+ 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_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from '@dudousxd/nestjs-catalog/client';
27
32
  import { WORKFLOW_NODE_ID_PATTERN, } from '@dudousxd/nestjs-catalog/client';
28
33
  export function describeDurability(durability) {
29
34
  if (!durability) {
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Handle, Position } from '@xyflow/react';
3
- import { CircleAlert, CircleCheck, CircleSlash, Code2, Database, ExternalLink, GitBranch, Loader2, Plug, Repeat, TriangleAlert, } from 'lucide-react';
3
+ import { CircleAlert, CircleCheck, CircleSlash, Code2, Database, ExternalLink, Filter, GitBranch, Loader2, Plug, Repeat, 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';
7
7
  import { Tooltip } from '../ui/tooltip';
8
- import { NODE_WIDTH } from './graph';
8
+ import { NODE_WIDTH, describeDrop } from './graph';
9
9
  const RULE = 'border-zinc-200 dark:border-zinc-800';
10
10
  const PANEL = 'bg-white dark:bg-zinc-900';
11
11
  const MUTED = 'text-zinc-400 dark:text-zinc-500';
@@ -83,6 +83,20 @@ const KIND_STYLE = {
83
83
  icon: GitBranch,
84
84
  noun: 'if',
85
85
  },
86
+ // Rose and a funnel. It is the only kind whose effect is *subtraction* — every
87
+ // other node either produces rows, reshapes them or decides which boxes run —
88
+ // and the whole reason it is a node rather than a transform returning a subset
89
+ // is that "rows are being dropped here" should be visible without opening
90
+ // anything. Deliberately not the fuchsia an `if` wears: both of them make a
91
+ // load smaller and they do it in completely different ways, so they are the
92
+ // two that must never be confused at a glance.
93
+ filter: {
94
+ accent: 'bg-gradient-to-b from-rose-400 to-rose-600',
95
+ chip: 'text-rose-700 dark:text-rose-300',
96
+ wash: 'bg-rose-50/70 dark:bg-rose-950/30',
97
+ icon: Filter,
98
+ noun: 'filter',
99
+ },
86
100
  };
87
101
  /**
88
102
  * Handles are styled larger than React Flow's default 6px dot.
@@ -174,7 +188,14 @@ function RunBadge({ run }) {
174
188
  ? // The single most useful fact on a resumed run, and there is
175
189
  // nowhere else on the screen to read it from.
176
190
  'Replayed from a checkpoint — this step did not run again.'
177
- : `${describeBranchTaken(run) ?? 'Ran'}${typeof run.rows === 'number' ? `, ${run.rows} rows` : ''}.`, children: _jsx("span", { className: "flex items-center", children: _jsx(CircleCheck, { size: 11, className: run.replayed ? 'text-zinc-400' : 'text-emerald-500' }) }) }));
191
+ : // A filter reports the pair rather than the total, and it is the
192
+ // one kind for which "42 rows" would be an actively misleading
193
+ // badge: the number that matters is what it *removed*, and a node
194
+ // that showed only its output would make a filter that dropped
195
+ // nine tenths of a load look identical to a source that read a
196
+ // tenth as much. `describeDrop` answers for filters and stays
197
+ // silent for everything else, so this stays one expression.
198
+ `${describeBranchTaken(run) ?? 'Ran'}${describeRunSize(run)}.`, children: _jsx("span", { className: "flex items-center", children: _jsx(CircleCheck, { size: 11, className: run.replayed ? 'text-zinc-400' : 'text-emerald-500' }) }) }));
178
199
  }
179
200
  // Drawn rather than left blank, which is what this was.
180
201
  //
@@ -202,6 +223,21 @@ function RunBadge({ run }) {
202
223
  * for whether skipping an animation costs anybody information.
203
224
  */
204
225
  const ARRIVE = { type: 'spring', stiffness: 420, damping: 34, mass: 0.7 };
226
+ /**
227
+ * How much data went through a node, in the terms that node is measured in.
228
+ *
229
+ * A filter reports the pair — in, out, and what that means as a share — because
230
+ * for a filter the number that matters is what it *removed*, and a badge showing
231
+ * only its output would make one that dropped nine tenths of a load look exactly
232
+ * like a source that read a tenth as much. Everything else reports what it
233
+ * produced, which is what "rows" has always meant on this badge.
234
+ */
235
+ function describeRunSize(run) {
236
+ const dropped = describeDrop(run);
237
+ if (dropped)
238
+ return `: ${dropped}`;
239
+ return typeof run.rows === 'number' ? `, ${run.rows} rows` : '';
240
+ }
205
241
  /** What an `if` node's badge says it decided. Absent on every other kind. */
206
242
  function describeBranchTaken(run) {
207
243
  if (!run?.branch)
@@ -66,6 +66,17 @@ const NODE_FACTORIES = {
66
66
  // wrong is a half of the graph that silently does not run, which is the one
67
67
  // failure this node had to be built not to have.
68
68
  if: (id, name, init) => ({ id, name, kind: 'if', ...init }),
69
+ // `filter` arrived third, and the map stopped the build a third time.
70
+ //
71
+ // Also unused by every template below, and this one is the clearest case of
72
+ // the three. A filter's content is a *column name and a value* — which are
73
+ // facts about one organisation's data, not about a pipeline shape — and a
74
+ // template that guessed `status = "OPEN"` would prefill a predicate that is
75
+ // wrong everywhere it is opened. Worse, a prefilled filter sitting in front of
76
+ // a sink is precisely the accident `WorkflowFilterNode.narrows` exists to make
77
+ // impossible: the template would be shipping a graph that shrinks a published
78
+ // type, with nobody having chosen it.
79
+ filter: (id, name, init) => ({ id, name, kind: 'filter', ...init }),
69
80
  };
70
81
  /* -------------------------------------------------------------------------- */
71
82
  /* Starter transform code */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-catalog-react",
3
- "version": "0.19.0-preview.0",
3
+ "version": "0.19.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",
@@ -55,7 +55,7 @@
55
55
  "@dnd-kit/core": ">=6",
56
56
  "@dnd-kit/sortable": ">=10",
57
57
  "@dnd-kit/utilities": ">=3",
58
- "@dudousxd/nestjs-catalog": "0.16.0-preview.0",
58
+ "@dudousxd/nestjs-catalog": ">=0.1.0",
59
59
  "@tanstack/react-query": ">=5",
60
60
  "@tanstack/react-table": ">=9",
61
61
  "@tiptap/core": ">=3",