@dudousxd/nestjs-catalog-react 0.6.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConnectionPanel.js +131 -34
- package/dist/DashboardBoard.js +30 -3
- package/dist/FlowView.js +35 -26
- package/dist/PipelineConsole.js +68 -34
- package/dist/QueryConsole.js +14 -6
- package/dist/TransformEditor.d.ts +0 -9
- package/dist/TransformEditor.js +23 -1
- package/dist/WorkflowCanvas.js +221 -128
- package/dist/charts/bklit/area.js +0 -1
- package/dist/charts/bklit/bar-chart.js +0 -1
- package/dist/charts/bklit/grid.js +0 -1
- package/dist/charts/bklit/line-loading-pulse.js +0 -1
- package/dist/charts/bklit/tooltip/chart-tooltip.js +0 -1
- package/dist/charts/bklit/tooltip/tooltip-indicator.js +0 -1
- package/dist/charts/bklit/use-chart-phase-orchestrator.js +0 -2
- package/dist/charts/bklit/use-mount-progress.js +0 -1
- package/dist/source-fields.js +61 -42
- package/dist/ui/chart.js +35 -16
- package/dist/ui/select.d.ts +10 -1
- package/dist/ui/select.js +8 -2
- package/dist/ui/switch.js +7 -1
- package/dist/ui/tabs.d.ts +11 -1
- package/dist/ui/tabs.js +2 -2
- package/dist/workflow/graph.js +51 -35
- package/package.json +2 -2
package/dist/source-fields.js
CHANGED
|
@@ -92,6 +92,58 @@ export function parseRecords(text) {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
+
/** The url unless a connection supplies it, plus the sub-path off it if there is one. */
|
|
96
|
+
function httpConfig(draft, viaConnection) {
|
|
97
|
+
return {
|
|
98
|
+
...(viaConnection ? {} : { url: draft.url }),
|
|
99
|
+
...(draft.path ? { path: draft.path } : {}),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** The query, the url unless a connection supplies it, and the watermark if it is in play. */
|
|
103
|
+
function sqlConfig(draft, viaConnection, incremental) {
|
|
104
|
+
return {
|
|
105
|
+
query: draft.query,
|
|
106
|
+
...(viaConnection || !draft.url ? {} : { url: draft.url }),
|
|
107
|
+
// Only when it will be used. A watermark column left on a source somebody
|
|
108
|
+
// switched back to full reads as a bound that is being applied, and it is
|
|
109
|
+
// not.
|
|
110
|
+
...(incremental && draft.watermarkColumn ? { watermarkColumn: draft.watermarkColumn } : {}),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** A path on disk — `url` doubles as the path here — and the format if it was picked. */
|
|
114
|
+
function fileConfig(draft) {
|
|
115
|
+
return {
|
|
116
|
+
path: draft.path || draft.url,
|
|
117
|
+
...(draft.format ? { format: draft.format } : {}),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** Bucket and addressing, which a connection can supply, then the per-load narrowing. */
|
|
121
|
+
function s3Config(draft, viaConnection) {
|
|
122
|
+
return {
|
|
123
|
+
...(viaConnection
|
|
124
|
+
? {}
|
|
125
|
+
: {
|
|
126
|
+
bucket: draft.bucket,
|
|
127
|
+
...(draft.endpoint ? { endpoint: draft.endpoint } : {}),
|
|
128
|
+
...(draft.region ? { region: draft.region } : {}),
|
|
129
|
+
...(draft.forcePathStyle ? { forcePathStyle: true } : {}),
|
|
130
|
+
}),
|
|
131
|
+
...(draft.prefix ? { prefix: draft.prefix } : {}),
|
|
132
|
+
...(draft.suffix ? { suffix: draft.suffix } : {}),
|
|
133
|
+
...(draft.format ? { format: draft.format } : {}),
|
|
134
|
+
...(draft.maxObjectsPerRun ? { maxObjectsPerRun: Number(draft.maxObjectsPerRun) } : {}),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The pasted records, or none when the text will not parse.
|
|
139
|
+
*
|
|
140
|
+
* Unparseable text keeps the previous records rather than wiping them: the
|
|
141
|
+
* caller shows the message from `parseRecords` and refuses to save.
|
|
142
|
+
*/
|
|
143
|
+
function inlineConfig(draft) {
|
|
144
|
+
const parsed = parseRecords(draft.records);
|
|
145
|
+
return { records: parsed.ok ? parsed.records : [] };
|
|
146
|
+
}
|
|
95
147
|
/**
|
|
96
148
|
* The stored config for one kind, and nothing else.
|
|
97
149
|
*
|
|
@@ -100,48 +152,15 @@ export function parseRecords(text) {
|
|
|
100
152
|
* stale url on a SQL source, which reads as configuration somebody meant.
|
|
101
153
|
*/
|
|
102
154
|
export function sourceConfigFrom(kind, draft, { viaConnection, incremental }) {
|
|
103
|
-
if (kind === 'http')
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (kind === '
|
|
110
|
-
return
|
|
111
|
-
|
|
112
|
-
...(viaConnection || !draft.url ? {} : { url: draft.url }),
|
|
113
|
-
// Only when it will be used. A watermark column left on a source somebody
|
|
114
|
-
// switched back to full reads as a bound that is being applied, and it is
|
|
115
|
-
// not.
|
|
116
|
-
...(incremental && draft.watermarkColumn ? { watermarkColumn: draft.watermarkColumn } : {}),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
if (kind === 'file') {
|
|
120
|
-
return {
|
|
121
|
-
path: draft.path || draft.url,
|
|
122
|
-
...(draft.format ? { format: draft.format } : {}),
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
if (kind === 's3') {
|
|
126
|
-
return {
|
|
127
|
-
...(viaConnection
|
|
128
|
-
? {}
|
|
129
|
-
: {
|
|
130
|
-
bucket: draft.bucket,
|
|
131
|
-
...(draft.endpoint ? { endpoint: draft.endpoint } : {}),
|
|
132
|
-
...(draft.region ? { region: draft.region } : {}),
|
|
133
|
-
...(draft.forcePathStyle ? { forcePathStyle: true } : {}),
|
|
134
|
-
}),
|
|
135
|
-
...(draft.prefix ? { prefix: draft.prefix } : {}),
|
|
136
|
-
...(draft.suffix ? { suffix: draft.suffix } : {}),
|
|
137
|
-
...(draft.format ? { format: draft.format } : {}),
|
|
138
|
-
...(draft.maxObjectsPerRun ? { maxObjectsPerRun: Number(draft.maxObjectsPerRun) } : {}),
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
const parsed = parseRecords(draft.records);
|
|
142
|
-
// Unparseable text keeps the previous records rather than wiping them: the
|
|
143
|
-
// caller shows the message from `parseRecords` and refuses to save.
|
|
144
|
-
return { records: parsed.ok ? parsed.records : [] };
|
|
155
|
+
if (kind === 'http')
|
|
156
|
+
return httpConfig(draft, viaConnection);
|
|
157
|
+
if (kind === 'sql')
|
|
158
|
+
return sqlConfig(draft, viaConnection, incremental);
|
|
159
|
+
if (kind === 'file')
|
|
160
|
+
return fileConfig(draft);
|
|
161
|
+
if (kind === 's3')
|
|
162
|
+
return s3Config(draft, viaConnection);
|
|
163
|
+
return inlineConfig(draft);
|
|
145
164
|
}
|
|
146
165
|
/**
|
|
147
166
|
* Whether there is enough here to read anything at all.
|
package/dist/ui/chart.js
CHANGED
|
@@ -53,6 +53,40 @@ ${colorConfig
|
|
|
53
53
|
} }));
|
|
54
54
|
};
|
|
55
55
|
export const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
56
|
+
/** The swatch to the left of a tooltip row — a dot, a bar, or a dashed rule. */
|
|
57
|
+
function ChartTooltipIndicator({ color, indicator, nestLabel, }) {
|
|
58
|
+
return (_jsx("div", { className: cn('shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)', {
|
|
59
|
+
'h-2.5 w-2.5': indicator === 'dot',
|
|
60
|
+
'w-1': indicator === 'line',
|
|
61
|
+
'w-0 border-[1.5px] border-dashed bg-transparent': indicator === 'dashed',
|
|
62
|
+
'my-0.5': nestLabel && indicator === 'dashed',
|
|
63
|
+
}), style: {
|
|
64
|
+
'--color-bg': color,
|
|
65
|
+
'--color-border': color,
|
|
66
|
+
} }));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The right-hand side of a tooltip row: the series name, then its value.
|
|
70
|
+
*
|
|
71
|
+
* When the tooltip holds a single non-dot series the shared label is nested in
|
|
72
|
+
* here instead of sitting above the rows, so it reads as part of the one entry
|
|
73
|
+
* rather than as a heading over a list of one.
|
|
74
|
+
*/
|
|
75
|
+
function ChartTooltipNameAndValue({ name, value, nestLabel, tooltipLabel, }) {
|
|
76
|
+
return (_jsxs("div", { className: cn('flex flex-1 justify-between leading-none', nestLabel ? 'items-end' : 'items-center'), children: [_jsxs("div", { className: "grid gap-1.5", children: [nestLabel ? tooltipLabel : null, _jsx("span", { className: "text-zinc-500 dark:text-zinc-400", children: name })] }), value !== undefined && (_jsx("span", { className: "font-mono font-medium tabular-nums", children: typeof value === 'number' ? value.toLocaleString() : String(value) }))] }));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* One series inside the tooltip: swatch, name, value.
|
|
80
|
+
*
|
|
81
|
+
* A caller's `formatter` replaces the whole row rather than any part of it,
|
|
82
|
+
* which is why it short-circuits everything below it.
|
|
83
|
+
*/
|
|
84
|
+
function ChartTooltipRow({ item, index, config, color, formatter, indicator, hideIndicator, nestLabel, nameKey, tooltipLabel, }) {
|
|
85
|
+
const key = `${nameKey || item.name || item.dataKey || 'value'}`;
|
|
86
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
87
|
+
const indicatorColor = color || item.payload?.fill || item.color;
|
|
88
|
+
return (_jsx("div", { className: cn('flex w-full flex-wrap items-stretch gap-2', '[&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-zinc-400', indicator === 'dot' && 'items-center'), children: formatter && item?.value !== undefined && item.name ? (formatter(item.value, item.name, item, index, item.payload)) : (_jsxs(_Fragment, { children: [itemConfig?.icon ? (_jsx(itemConfig.icon, {})) : (!hideIndicator && (_jsx(ChartTooltipIndicator, { color: indicatorColor, indicator: indicator, nestLabel: nestLabel }))), _jsx(ChartTooltipNameAndValue, { name: itemConfig?.label || item.name, value: item.value, nestLabel: nestLabel, tooltipLabel: tooltipLabel })] })) }));
|
|
89
|
+
}
|
|
56
90
|
export function ChartTooltipContent({ active, payload, className, indicator = 'dot', hideLabel = false, hideIndicator = false, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }) {
|
|
57
91
|
const { config } = useChart();
|
|
58
92
|
const tooltipLabel = React.useMemo(() => {
|
|
@@ -74,22 +108,7 @@ export function ChartTooltipContent({ active, payload, className, indicator = 'd
|
|
|
74
108
|
if (!active || !payload?.length)
|
|
75
109
|
return null;
|
|
76
110
|
const nestLabel = payload.length === 1 && indicator !== 'dot';
|
|
77
|
-
return (_jsxs("div", { className: cn('grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-zinc-200 bg-white px-2.5 py-1.5 text-xs shadow-xl', 'dark:border-zinc-800 dark:bg-zinc-900', className), children: [!nestLabel ? tooltipLabel : null, _jsx("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
|
|
78
|
-
const key = `${nameKey || item.name || item.dataKey || 'value'}`;
|
|
79
|
-
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
80
|
-
const indicatorColor = color || item.payload?.fill || item.color;
|
|
81
|
-
return (_jsx("div", { className: cn('flex w-full flex-wrap items-stretch gap-2', '[&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-zinc-400', indicator === 'dot' && 'items-center'), children: formatter && item?.value !== undefined && item.name ? (formatter(item.value, item.name, item, index, item.payload)) : (_jsxs(_Fragment, { children: [itemConfig?.icon ? (_jsx(itemConfig.icon, {})) : (!hideIndicator && (_jsx("div", { className: cn('shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)', {
|
|
82
|
-
'h-2.5 w-2.5': indicator === 'dot',
|
|
83
|
-
'w-1': indicator === 'line',
|
|
84
|
-
'w-0 border-[1.5px] border-dashed bg-transparent': indicator === 'dashed',
|
|
85
|
-
'my-0.5': nestLabel && indicator === 'dashed',
|
|
86
|
-
}), style: {
|
|
87
|
-
'--color-bg': indicatorColor,
|
|
88
|
-
'--color-border': indicatorColor,
|
|
89
|
-
} }))), _jsxs("div", { className: cn('flex flex-1 justify-between leading-none', nestLabel ? 'items-end' : 'items-center'), children: [_jsxs("div", { className: "grid gap-1.5", children: [nestLabel ? tooltipLabel : null, _jsx("span", { className: "text-zinc-500 dark:text-zinc-400", children: itemConfig?.label || item.name })] }), item.value !== undefined && (_jsx("span", { className: "font-mono font-medium tabular-nums", children: typeof item.value === 'number'
|
|
90
|
-
? item.value.toLocaleString()
|
|
91
|
-
: String(item.value) }))] })] })) }, item.dataKey ?? index));
|
|
92
|
-
}) })] }));
|
|
111
|
+
return (_jsxs("div", { className: cn('grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-zinc-200 bg-white px-2.5 py-1.5 text-xs shadow-xl', 'dark:border-zinc-800 dark:bg-zinc-900', className), children: [!nestLabel ? tooltipLabel : null, _jsx("div", { className: "grid gap-1.5", children: payload.map((item, index) => (_jsx(ChartTooltipRow, { item: item, index: index, config: config, color: color, formatter: formatter, indicator: indicator, hideIndicator: hideIndicator, nestLabel: nestLabel, nameKey: nameKey, tooltipLabel: tooltipLabel }, item.dataKey ?? index))) })] }));
|
|
93
112
|
}
|
|
94
113
|
export const ChartLegend = RechartsPrimitive.Legend;
|
|
95
114
|
export function ChartLegendContent({ className, hideIcon = false, payload, verticalAlign = 'bottom', nameKey, }) {
|
package/dist/ui/select.d.ts
CHANGED
|
@@ -36,7 +36,16 @@ export declare function Select({ value, onValueChange, options, ariaLabel, place
|
|
|
36
36
|
*
|
|
37
37
|
* Separate from `Select` so a toolbar can still drop a bare one in.
|
|
38
38
|
*/
|
|
39
|
-
export declare function SelectField({ label, hint, ...props }: Parameters<typeof Select>[0] & {
|
|
39
|
+
export declare function SelectField({ label, hint, ariaLabel, ...props }: Omit<Parameters<typeof Select>[0], 'ariaLabel'> & {
|
|
40
40
|
label: string;
|
|
41
41
|
hint?: ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* The accessible name, when it should differ from the visible one.
|
|
44
|
+
*
|
|
45
|
+
* Defaults to `label`, so the common case cannot forget it. Overriding is
|
|
46
|
+
* for the case the call sites already use deliberately: a visible "Kind"
|
|
47
|
+
* reads fine beside the fields around it, while a screen reader announcing
|
|
48
|
+
* "Kind" alone has nothing to go on and wants "Connection kind".
|
|
49
|
+
*/
|
|
50
|
+
ariaLabel?: string;
|
|
42
51
|
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/ui/select.js
CHANGED
|
@@ -25,6 +25,12 @@ export function Select({ value, onValueChange, options, ariaLabel, placeholder =
|
|
|
25
25
|
*
|
|
26
26
|
* Separate from `Select` so a toolbar can still drop a bare one in.
|
|
27
27
|
*/
|
|
28
|
-
export function SelectField({ label, hint, ...props }) {
|
|
29
|
-
return (
|
|
28
|
+
export function SelectField({ label, hint, ariaLabel, ...props }) {
|
|
29
|
+
return (
|
|
30
|
+
// `Select` renders a BUTTON, and a label does not implicitly name a button —
|
|
31
|
+
// which is why `Select` requires an accessible name of its own and is given
|
|
32
|
+
// one below. This element is the visible caption and the layout wrapper; the
|
|
33
|
+
// naming is done by `ariaLabel`.
|
|
34
|
+
// biome-ignore lint/a11y/noLabelWithoutControl: see above
|
|
35
|
+
_jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1 block font-mono text-[10px] uppercase tracking-[0.14em] text-zinc-400 dark:text-zinc-500", children: label }), _jsx(Select, { ...props, ariaLabel: ariaLabel ?? label }), hint && (_jsx("span", { className: "mt-1 block text-[11px] text-zinc-400 dark:text-zinc-500", children: hint }))] }));
|
|
30
36
|
}
|
package/dist/ui/switch.js
CHANGED
|
@@ -10,5 +10,11 @@ import { cn } from '../cn';
|
|
|
10
10
|
* checkbox reads as "include this in what I am about to submit".
|
|
11
11
|
*/
|
|
12
12
|
export function Switch({ checked, onCheckedChange, label, hint, disabled, }) {
|
|
13
|
-
return (
|
|
13
|
+
return (
|
|
14
|
+
// Base UI's Switch renders a hidden native input inside its root, so the
|
|
15
|
+
// implicit association a wrapping label gives DOES resolve here — verified
|
|
16
|
+
// by `switch.spec.tsx`, which asks for the control by its accessible name.
|
|
17
|
+
// The rule cannot see through the component boundary to know that.
|
|
18
|
+
// biome-ignore lint/a11y/noLabelWithoutControl: see above
|
|
19
|
+
_jsxs("label", { className: "flex items-start gap-2.5", children: [_jsx(BaseSwitch.Root, { checked: checked, onCheckedChange: onCheckedChange, disabled: disabled, className: cn('relative mt-0.5 h-4 w-7 shrink-0 rounded-full border transition-colors outline-none', 'border-zinc-300 bg-zinc-200 dark:border-zinc-700 dark:bg-zinc-800', 'data-[checked]:border-sky-600 data-[checked]:bg-sky-600', 'focus-visible:ring-2 focus-visible:ring-sky-500/30', 'disabled:opacity-40'), children: _jsx(BaseSwitch.Thumb, { className: cn('block h-3 w-3 translate-x-0.5 rounded-full bg-white shadow-sm transition-transform', 'data-[checked]:translate-x-[14px]') }) }), _jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block text-[11px] text-zinc-600 dark:text-zinc-300", children: label }), hint && _jsx("span", { className: "block text-[11px] text-zinc-400 dark:text-zinc-500", children: hint })] })] }));
|
|
14
20
|
}
|
package/dist/ui/tabs.d.ts
CHANGED
|
@@ -24,11 +24,21 @@ export declare function TabsList({ children, className, ref, }: {
|
|
|
24
24
|
*/
|
|
25
25
|
ref?: Ref<HTMLDivElement>;
|
|
26
26
|
}): import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
export declare function TabsTab({ value, children, className, }: {
|
|
27
|
+
export declare function TabsTab({ value, children, className, ref, }: {
|
|
28
28
|
value: string;
|
|
29
29
|
children: ReactNode;
|
|
30
30
|
/** For a caller whose strip has its own metrics — the console nav is taller. */
|
|
31
31
|
className?: string;
|
|
32
|
+
/**
|
|
33
|
+
* For a caller that has to bring the selected tab into view.
|
|
34
|
+
*
|
|
35
|
+
* Worth the prop rather than letting the caller render a marker element
|
|
36
|
+
* inside the tab: a zero-size `sr-only` marker is `position: absolute`, which
|
|
37
|
+
* escapes the strip's `overflow-x` clipping and reports the strip's full
|
|
38
|
+
* scroll extent as the DOCUMENT's width. The page then scrolls sideways —
|
|
39
|
+
* which is the bug this scrolling was introduced to fix.
|
|
40
|
+
*/
|
|
41
|
+
ref?: Ref<HTMLButtonElement>;
|
|
32
42
|
}): import("react/jsx-runtime").JSX.Element;
|
|
33
43
|
export declare function TabsPanel({ value, children, className, }: {
|
|
34
44
|
value: string;
|
package/dist/ui/tabs.js
CHANGED
|
@@ -24,8 +24,8 @@ export function Tabs({ value, onValueChange, children, className, }) {
|
|
|
24
24
|
export function TabsList({ children, className, ref, }) {
|
|
25
25
|
return (_jsx(BaseTabs.List, { ref: ref, className: cn('flex gap-1 border-b border-zinc-200 dark:border-zinc-800', className), children: children }));
|
|
26
26
|
}
|
|
27
|
-
export function TabsTab({ value, children, className, }) {
|
|
28
|
-
return (_jsx(BaseTabs.Tab, { value: value, className: cn('flex items-center gap-1.5 border-b-2 px-3 py-2 text-sm transition-colors outline-none', 'border-transparent text-zinc-500', 'hover:text-zinc-950 dark:hover:text-zinc-50', 'focus-visible:ring-2 focus-visible:ring-sky-500/30', 'data-[selected]:border-sky-600 data-[selected]:text-zinc-950', 'dark:data-[selected]:text-zinc-50', className), children: children }));
|
|
27
|
+
export function TabsTab({ value, children, className, ref, }) {
|
|
28
|
+
return (_jsx(BaseTabs.Tab, { ref: ref, value: value, className: cn('flex items-center gap-1.5 border-b-2 px-3 py-2 text-sm transition-colors outline-none', 'border-transparent text-zinc-500', 'hover:text-zinc-950 dark:hover:text-zinc-50', 'focus-visible:ring-2 focus-visible:ring-sky-500/30', 'data-[selected]:border-sky-600 data-[selected]:text-zinc-950', 'dark:data-[selected]:text-zinc-50', className), children: children }));
|
|
29
29
|
}
|
|
30
30
|
export function TabsPanel({ value, children, className, }) {
|
|
31
31
|
// Not `keepMounted`: a panel holding a half-typed connector form should keep
|
package/dist/workflow/graph.js
CHANGED
|
@@ -137,6 +137,49 @@ export function toFlowEdges(edges, nodes, brokenEdgeIds) {
|
|
|
137
137
|
};
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
+
/** Who feeds each node, by node id. Every node gets an entry, most of them empty. */
|
|
141
|
+
function feedersByNode(nodes, edges) {
|
|
142
|
+
const incoming = new Map();
|
|
143
|
+
for (const node of nodes)
|
|
144
|
+
incoming.set(node.id, []);
|
|
145
|
+
for (const edge of edges) {
|
|
146
|
+
const list = incoming.get(edge.to);
|
|
147
|
+
if (list)
|
|
148
|
+
list.push(edge.from);
|
|
149
|
+
}
|
|
150
|
+
return incoming;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Move one node to one column past the deepest thing feeding it, never left.
|
|
154
|
+
*
|
|
155
|
+
* Only ever increasing is what makes it safe to call repeatedly on the same
|
|
156
|
+
* node, which is what the relaxation below relies on.
|
|
157
|
+
*/
|
|
158
|
+
function placeAfterFeeders(id, column, feeders) {
|
|
159
|
+
const depth = feeders.length === 0 ? 0 : Math.max(...feeders.map((from) => (column.get(from) ?? 0) + 1));
|
|
160
|
+
column.set(id, Math.max(depth, column.get(id) ?? 0));
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Layer a graph that has no usable run order, by longest path.
|
|
164
|
+
*
|
|
165
|
+
* Relax every node repeatedly until nothing moves. With no cycle that settles in
|
|
166
|
+
* at most one pass per node; with a cycle the pass cap is what stops it, and the
|
|
167
|
+
* nodes on the cycle end up wherever the cap left them. So a graph with a loop
|
|
168
|
+
* still draws — badly — rather than hanging while somebody is trying to see the
|
|
169
|
+
* loop they need to remove.
|
|
170
|
+
*/
|
|
171
|
+
function relaxColumns(nodes, incoming, column) {
|
|
172
|
+
for (let pass = 0; pass < nodes.length + 1; pass += 1) {
|
|
173
|
+
const before = [...column.values()].join(',');
|
|
174
|
+
for (const node of nodes)
|
|
175
|
+
placeAfterFeeders(node.id, column, incoming.get(node.id) ?? []);
|
|
176
|
+
if ([...column.values()].join(',') === before)
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
for (const node of nodes)
|
|
180
|
+
if (!column.has(node.id))
|
|
181
|
+
column.set(node.id, 0);
|
|
182
|
+
}
|
|
140
183
|
/**
|
|
141
184
|
* Which column each node belongs in, left to right.
|
|
142
185
|
*
|
|
@@ -148,50 +191,23 @@ export function toFlowEdges(edges, nodes, brokenEdgeIds) {
|
|
|
148
191
|
*
|
|
149
192
|
* `workflowRunOrder` throws on a graph it will not run, which is a graph
|
|
150
193
|
* somebody is in the middle of drawing — half-wired, or with a loop they are
|
|
151
|
-
* about to remove. That is exactly when a canvas most needs to draw, so
|
|
152
|
-
*
|
|
153
|
-
* at the node count so a cycle cannot spin it forever.
|
|
194
|
+
* about to remove. That is exactly when a canvas most needs to draw, so
|
|
195
|
+
* `relaxColumns` layers it by longest path anyway.
|
|
154
196
|
*/
|
|
155
197
|
function columnsFor(nodes, edges) {
|
|
156
|
-
const incoming =
|
|
157
|
-
for (const node of nodes)
|
|
158
|
-
incoming.set(node.id, []);
|
|
159
|
-
for (const edge of edges) {
|
|
160
|
-
const list = incoming.get(edge.to);
|
|
161
|
-
if (list)
|
|
162
|
-
list.push(edge.from);
|
|
163
|
-
}
|
|
198
|
+
const incoming = feedersByNode(nodes, edges);
|
|
164
199
|
const column = new Map();
|
|
165
|
-
const place = (id) => {
|
|
166
|
-
const feeders = incoming.get(id) ?? [];
|
|
167
|
-
const depth = feeders.length === 0 ? 0 : Math.max(...feeders.map((from) => (column.get(from) ?? 0) + 1));
|
|
168
|
-
column.set(id, Math.max(depth, column.get(id) ?? 0));
|
|
169
|
-
};
|
|
170
200
|
try {
|
|
171
201
|
// Topological order, so one pass is exact: everything feeding a node has
|
|
172
202
|
// already been placed by the time the node is reached.
|
|
173
|
-
for (const entry of workflowRunOrder({ nodes, edges }))
|
|
174
|
-
|
|
175
|
-
|
|
203
|
+
for (const entry of workflowRunOrder({ nodes, edges })) {
|
|
204
|
+
placeAfterFeeders(entry.node.id, column, incoming.get(entry.node.id) ?? []);
|
|
205
|
+
}
|
|
176
206
|
}
|
|
177
207
|
catch {
|
|
178
|
-
|
|
179
|
-
// this settles in at most one pass per node, and with a cycle the cap is
|
|
180
|
-
// what stops it. Nodes on the cycle end up wherever the cap left them, so a
|
|
181
|
-
// graph with a loop still draws — badly — rather than hanging while
|
|
182
|
-
// somebody is trying to see the loop they need to remove.
|
|
183
|
-
for (let pass = 0; pass < nodes.length + 1; pass += 1) {
|
|
184
|
-
const before = [...column.values()].join(',');
|
|
185
|
-
for (const node of nodes)
|
|
186
|
-
place(node.id);
|
|
187
|
-
if ([...column.values()].join(',') === before)
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
for (const node of nodes)
|
|
191
|
-
if (!column.has(node.id))
|
|
192
|
-
column.set(node.id, 0);
|
|
193
|
-
return column;
|
|
208
|
+
relaxColumns(nodes, incoming, column);
|
|
194
209
|
}
|
|
210
|
+
return column;
|
|
195
211
|
}
|
|
196
212
|
/**
|
|
197
213
|
* Lay the graph out left to right, one column per dependency depth.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-catalog-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Ready-made React screens for @dudousxd/nestjs-catalog — a model manager and a generic object explorer you can drop into your own app shell.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davide Carvalho",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"@tiptap/pm": "3.29.2",
|
|
107
107
|
"tiptap-markdown": "0.9.0",
|
|
108
108
|
"@tiptap/core": "3.29.2",
|
|
109
|
-
"@dudousxd/nestjs-catalog": "0.4.
|
|
109
|
+
"@dudousxd/nestjs-catalog": "0.4.1"
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"clsx": "2.1.1",
|