@atolis-hq/corum 0.1.61 → 0.1.63
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/src/adapters/asyncapi/mapper.js +1 -1
- package/dist/src/adapters/corum/mapper.js +1 -1
- package/dist/src/adapters/openapi/mapper.js +1 -1
- package/dist/src/bin/corum.js +2 -1
- package/dist/src/graph/index.js +39 -8
- package/dist/src/linter/index.js +31 -2
- package/dist/src/loader/cluster-loader.js +7 -3
- package/dist/src/loader/index.js +5 -0
- package/dist/src/loader/kind-loader.js +63 -0
- package/dist/src/loader/namespace-loader.js +36 -0
- package/dist/src/mcp/index.js +15 -10
- package/dist/src/mcp/prompts/usage-guide.js +9 -9
- package/dist/src/mcp/serializers.js +1 -1
- package/dist/src/mutate/apply-cluster.js +3 -2
- package/dist/src/reconcile/index.js +1 -1
- package/dist/src/source/file-source.js +1 -3
- package/dist/src/source/git-source.js +2 -1
- package/dist/src/source/graph-paths.js +6 -0
- package/dist/src/web/server.js +25 -5
- package/dist/src/writer/graph-writer.js +9 -2
- package/package.json +1 -1
- package/web/app.jsx +175 -24
- package/web/graph-utils.js +45 -11
- package/web/graph-utils.test.js +42 -15
- package/web/graph.jsx +68 -20
- package/web/nav.js +36 -5
- package/web/router.js +1 -1
- package/web/search-utils.test.js +4 -4
- package/web/search.jsx +1 -1
- package/web/style.css +22 -0
package/web/graph-utils.test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// run with: node web/graph-utils.test.js
|
|
2
2
|
const graphUtils = require('./graph-utils.js');
|
|
3
|
-
const {
|
|
3
|
+
const { buildNamespaceMap, applyEdgeTypeFilter, collectEdgeTypes, getDisplayName } = graphUtils;
|
|
4
4
|
|
|
5
5
|
(async () => {
|
|
6
6
|
let passed = 0, failed = 0;
|
|
@@ -10,10 +10,10 @@ const { buildComponentMap, applyEdgeTypeFilter, collectEdgeTypes, getDisplayName
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const nodes = [
|
|
13
|
-
{ id: 'orders.DomainModel.order', template: 'DomainModel',
|
|
14
|
-
{ id: 'orders.RestAPI.ordersApi', template: 'RestAPI',
|
|
15
|
-
{ id: 'payments.DomainModel.payment', template: 'DomainModel',
|
|
16
|
-
{ id: 'payments.RestAPI.paymentsApi', template: 'RestAPI',
|
|
13
|
+
{ id: 'orders.DomainModel.order', template: 'DomainModel', namespace: 'orders', state: 'agreed', stability: 'stable' },
|
|
14
|
+
{ id: 'orders.RestAPI.ordersApi', template: 'RestAPI', namespace: 'orders', state: 'agreed', stability: 'stable' },
|
|
15
|
+
{ id: 'payments.DomainModel.payment', template: 'DomainModel', namespace: 'payments', state: 'proposed', stability: 'unstable' },
|
|
16
|
+
{ id: 'payments.RestAPI.paymentsApi', template: 'RestAPI', namespace: 'payments', state: 'proposed', stability: 'unstable' },
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
const edges = [
|
|
@@ -26,16 +26,16 @@ const { buildComponentMap, applyEdgeTypeFilter, collectEdgeTypes, getDisplayName
|
|
|
26
26
|
assert(getDisplayName('orders.DomainModel.order') === 'order', 'getDisplayName returns last segment');
|
|
27
27
|
assert(getDisplayName('payments.RestAPI.paymentsApi') === 'paymentsApi', 'getDisplayName handles nested id');
|
|
28
28
|
|
|
29
|
-
const cm =
|
|
30
|
-
assert(cm.nodes.length === 2, '
|
|
31
|
-
assert(cm.nodes.every(n => typeof n.count === 'number' && n.count > 0), '
|
|
29
|
+
const cm = buildNamespaceMap(nodes, edges);
|
|
30
|
+
assert(cm.nodes.length === 2, 'buildNamespaceMap: one node per component');
|
|
31
|
+
assert(cm.nodes.every(n => typeof n.count === 'number' && n.count > 0), 'buildNamespaceMap: nodes have count');
|
|
32
32
|
const cmOrders = cm.nodes.find(n => n.id === 'orders');
|
|
33
|
-
assert(cmOrders?.count === 2, '
|
|
34
|
-
assert(cm.edges.length === 1, '
|
|
35
|
-
assert(cm.edges[0].from === 'orders' && cm.edges[0].to === 'payments', '
|
|
36
|
-
assert(cm.edges[0].types.includes('calls'), '
|
|
37
|
-
const sameCmEdges =
|
|
38
|
-
assert(sameCmEdges.edges.length === 0, '
|
|
33
|
+
assert(cmOrders?.count === 2, 'buildNamespaceMap: orders has 2 nodes');
|
|
34
|
+
assert(cm.edges.length === 1, 'buildNamespaceMap: one cross-component edge');
|
|
35
|
+
assert(cm.edges[0].from === 'orders' && cm.edges[0].to === 'payments', 'buildNamespaceMap: edge direction correct');
|
|
36
|
+
assert(cm.edges[0].types.includes('calls'), 'buildNamespaceMap: edge types collected');
|
|
37
|
+
const sameCmEdges = buildNamespaceMap(nodes, [{ id: 'x', from: 'orders.DomainModel.order', to: 'orders.RestAPI.ordersApi', type: 'reads' }]);
|
|
38
|
+
assert(sameCmEdges.edges.length === 0, 'buildNamespaceMap: intra-component edges excluded');
|
|
39
39
|
|
|
40
40
|
const filtered = applyEdgeTypeFilter(edges, new Set(['reads']));
|
|
41
41
|
assert(filtered.length === 2, 'applyEdgeTypeFilter: keeps only matching type');
|
|
@@ -55,7 +55,7 @@ const { buildComponentMap, applyEdgeTypeFilter, collectEdgeTypes, getDisplayName
|
|
|
55
55
|
assert(ccAll.length === 1, 'computeConnectedComponents: fully linked graph is one component');
|
|
56
56
|
const ccSplit = computeConnectedComponents(nodes, [edges[0], edges[2]]);
|
|
57
57
|
assert(ccSplit.length === 2, 'computeConnectedComponents: removing bridge edge splits components');
|
|
58
|
-
const ccIsolated = computeConnectedComponents([...nodes, { id: 'lone.Node.x', template: 'X',
|
|
58
|
+
const ccIsolated = computeConnectedComponents([...nodes, { id: 'lone.Node.x', template: 'X', namespace: 'lone' }], edges);
|
|
59
59
|
assert(ccIsolated.some(c => c.length === 1 && c[0] === 'lone.Node.x'), 'computeConnectedComponents: isolated node is own component');
|
|
60
60
|
const ccMerged = computeConnectedComponents(nodes, [edges[0], edges[2]], [{ from: 'orders.DomainModel.order', to: 'payments.DomainModel.payment' }]);
|
|
61
61
|
assert(ccMerged.length === 1, 'computeConnectedComponents: extraLinks merge components');
|
|
@@ -87,6 +87,33 @@ const { buildComponentMap, applyEdgeTypeFilter, collectEdgeTypes, getDisplayName
|
|
|
87
87
|
assert(aggScope.has('a.T.reader'), 'filterOwnerScope: keeps neighbours of the owner node');
|
|
88
88
|
assert(!aggScope.has('a.T.unrelated'), 'filterOwnerScope: drops unrelated nodes');
|
|
89
89
|
|
|
90
|
+
// Kind filtering and colouring
|
|
91
|
+
const { filterByKind, collectKinds, kindColour } = graphUtils;
|
|
92
|
+
const kNodes = [
|
|
93
|
+
{ id: 'orders.A.a', namespace: 'orders', kind: 'component' },
|
|
94
|
+
{ id: 'orders.A.b', namespace: 'orders' },
|
|
95
|
+
{ id: 'signup.J.j', namespace: 'signup', kind: 'journey' },
|
|
96
|
+
];
|
|
97
|
+
const kEdges = [
|
|
98
|
+
{ id: 'k1', from: 'orders.A.a', to: 'orders.A.b', type: 'reads' },
|
|
99
|
+
{ id: 'k2', from: 'signup.J.j', to: 'orders.A.a', type: 'calls' },
|
|
100
|
+
];
|
|
101
|
+
assert(JSON.stringify(collectKinds(kNodes)) === JSON.stringify(['component', 'journey']), 'collectKinds: distinct sorted kinds, default component');
|
|
102
|
+
const fc = filterByKind(kNodes, kEdges, 'component');
|
|
103
|
+
assert(fc.nodes.length === 2 && fc.edges.length === 1, 'filterByKind: component keeps only component nodes and internal edges');
|
|
104
|
+
const fj = filterByKind(kNodes, kEdges, 'journey');
|
|
105
|
+
assert(fj.nodes.length === 1 && fj.edges.length === 0, 'filterByKind: journey keeps journey namespace only');
|
|
106
|
+
assert(filterByKind(kNodes, kEdges, 'all').nodes.length === 3, 'filterByKind: all keeps everything');
|
|
107
|
+
assert(filterByKind(kNodes, kEdges, 'mystery').nodes.length === 0, 'filterByKind: unrecognised kind matches exactly');
|
|
108
|
+
assert(kindColour('journey') === kindColour('journey') && kindColour('journey') !== kindColour('component'), 'kindColour: stable and distinct from component');
|
|
109
|
+
const { resolveKindFilter } = graphUtils;
|
|
110
|
+
assert(resolveKindFilter(null, kNodes) === 'component', 'resolveKindFilter: defaults to component when present');
|
|
111
|
+
assert(resolveKindFilter(null, [{ id: 's.J.j', namespace: 's', kind: 'journey' }]) === 'all', 'resolveKindFilter: falls back to all when no component namespace');
|
|
112
|
+
assert(resolveKindFilter(null, [{ id: 's.J.j', namespace: 's', kind: 'mystery' }]) === 'all', 'resolveKindFilter: falls back to all for unknown-only kinds');
|
|
113
|
+
assert(resolveKindFilter('journey', kNodes) === 'journey', 'resolveKindFilter: explicit choice wins');
|
|
114
|
+
const km = buildNamespaceMap(kNodes, kEdges);
|
|
115
|
+
assert(km.nodes.find(n => n.id === 'signup')?.kind === 'journey', 'buildNamespaceMap: carries kind');
|
|
116
|
+
|
|
90
117
|
console.log(`\n${passed} passed, ${failed} failed`);
|
|
91
118
|
if (failed > 0) process.exit(1);
|
|
92
119
|
})();
|
package/web/graph.jsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { useState, useEffect, useMemo, useCallback, useRef } = React;
|
|
4
4
|
const { navigate, Icon, TemplateBadge, StateTag, StabilityTag } = window.CorumPrimitives;
|
|
5
5
|
const { buildRoute, parseRoute } = window.CorumRouter;
|
|
6
|
-
const {
|
|
6
|
+
const { buildNamespaceMap, filterByKind, resolveKindFilter, collectKinds, kindColour, applyEdgeTypeFilter, collectEdgeTypes, getDisplayName, computeConnectedComponents, filterThreadScope, filterOwnerScope } = window.CorumGraphUtils;
|
|
7
7
|
|
|
8
8
|
const RF = window.ReactFlow;
|
|
9
9
|
const ReactFlowCanvas = RF.ReactFlow || RF.default;
|
|
@@ -328,7 +328,7 @@ function makeRFEdge(edge, edgeStyles) {
|
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
function buildRFNodesForNodes(graphNodes, templateMap, onNodeClick, viewingRef, fadedIds) {
|
|
331
|
+
function buildRFNodesForNodes(graphNodes, templateMap, onNodeClick, viewingRef, fadedIds, kindByNamespace) {
|
|
332
332
|
return graphNodes.map(n => {
|
|
333
333
|
const tmpl = templateMap.get(n.template);
|
|
334
334
|
const colour = tmpl?.ui?.colour ?? 'var(--ink-4)';
|
|
@@ -340,7 +340,8 @@ function buildRFNodesForNodes(graphNodes, templateMap, onNodeClick, viewingRef,
|
|
|
340
340
|
data: {
|
|
341
341
|
nodeId: n.id,
|
|
342
342
|
label: getDisplayName(n.id),
|
|
343
|
-
component: n.
|
|
343
|
+
component: n.namespace,
|
|
344
|
+
kindColour: kindColour(n.kind ?? kindByNamespace?.get(n.namespace)),
|
|
344
345
|
templateLabel: tmpl?.ui?.displayName ?? n.template,
|
|
345
346
|
colour,
|
|
346
347
|
state: n.state,
|
|
@@ -362,7 +363,7 @@ function buildRFEdgesForEdges(edges, visibleEdgeTypes) {
|
|
|
362
363
|
// Level 1: component card node
|
|
363
364
|
function ComponentCardNode({ data }) {
|
|
364
365
|
return (
|
|
365
|
-
<div className="graph-component-card" onClick={data.onClick}>
|
|
366
|
+
<div className="graph-component-card" onClick={data.onClick} data-kind={data.kind} style={{ borderLeft: `4px solid ${data.kindColour}` }}>
|
|
366
367
|
<RF.Handle type="target" position={RF.Position.Left} style={{ opacity: 0 }} />
|
|
367
368
|
<div className="graph-component-card-name">{data.label}</div>
|
|
368
369
|
<div className="graph-component-card-count">{data.count} {data.count === 1 ? 'node' : 'nodes'}</div>
|
|
@@ -384,7 +385,7 @@ function NodeCardNode({ data }) {
|
|
|
384
385
|
<div className="graph-node-card-body">
|
|
385
386
|
<div className="graph-node-card-text">
|
|
386
387
|
<div className="graph-node-card-name" title={data.nodeId}>{data.label}</div>
|
|
387
|
-
<div className="graph-node-card-component">{data.component}</div>
|
|
388
|
+
<div className="graph-node-card-component" style={{ color: data.kindColour }}>{data.component}</div>
|
|
388
389
|
</div>
|
|
389
390
|
<div className="graph-node-card-type">
|
|
390
391
|
<TemplateBadge name={data.templateLabel} colour={colour} />
|
|
@@ -510,7 +511,7 @@ function describeScope(scope, scopeOptions) {
|
|
|
510
511
|
return parts.join(' · ');
|
|
511
512
|
}
|
|
512
513
|
|
|
513
|
-
function GraphToolbar({ edgeTypes, visibleEdgeTypes, onToggleEdgeType, showMinimap, onToggleMinimap, onResetLayout, level, depth, onDepth, allNodes, focalNodeId, onFocalNode, layoutMode, onLayoutMode, scope, onScope, scopeOptions, scopeInfo }) {
|
|
514
|
+
function GraphToolbar({ edgeTypes, visibleEdgeTypes, onToggleEdgeType, showMinimap, onToggleMinimap, onResetLayout, level, kindOptions, kindFilter, onKindFilter, depth, onDepth, allNodes, focalNodeId, onFocalNode, layoutMode, onLayoutMode, scope, onScope, scopeOptions, scopeInfo }) {
|
|
514
515
|
const [searchQuery, setSearchQuery] = useState('');
|
|
515
516
|
const [searchOpen, setSearchOpen] = useState(false);
|
|
516
517
|
const [scopeOpen, setScopeOpen] = useState(false);
|
|
@@ -592,7 +593,7 @@ function GraphToolbar({ edgeTypes, visibleEdgeTypes, onToggleEdgeType, showMinim
|
|
|
592
593
|
onClick={() => { onFocalNode(n.id); setSearchQuery(''); setSearchOpen(false); }}
|
|
593
594
|
>
|
|
594
595
|
<span style={{ fontWeight: 500 }}>{getDisplayName(n.id)}</span>
|
|
595
|
-
<span style={{ color: 'var(--ink-3)', fontSize: 10, marginLeft: 4 }}>{n.
|
|
596
|
+
<span style={{ color: 'var(--ink-3)', fontSize: 10, marginLeft: 4 }}>{n.namespace}</span>
|
|
596
597
|
</div>
|
|
597
598
|
))}
|
|
598
599
|
</div>
|
|
@@ -601,6 +602,19 @@ function GraphToolbar({ edgeTypes, visibleEdgeTypes, onToggleEdgeType, showMinim
|
|
|
601
602
|
<div className="graph-toolbar-sep" />
|
|
602
603
|
</>
|
|
603
604
|
)}
|
|
605
|
+
{level === 'component' && kindOptions.length > 2 && (
|
|
606
|
+
<label className="graph-kind-filter-wrap">
|
|
607
|
+
<span className="label-xs">Kind </span>
|
|
608
|
+
<select
|
|
609
|
+
className="graph-kind-filter"
|
|
610
|
+
aria-label="Kind filter"
|
|
611
|
+
value={kindFilter}
|
|
612
|
+
onChange={e => onKindFilter(e.target.value)}
|
|
613
|
+
>
|
|
614
|
+
{kindOptions.map(option => <option key={option.id} value={option.id}>{option.label}</option>)}
|
|
615
|
+
</select>
|
|
616
|
+
</label>
|
|
617
|
+
)}
|
|
604
618
|
{level === 'interior' && scopeOptions && (
|
|
605
619
|
<>
|
|
606
620
|
<div className="graph-scope" ref={scopeRef}>
|
|
@@ -668,16 +682,34 @@ function GraphView({ route, viewingRef, templates }) {
|
|
|
668
682
|
const selectedComponent = route.params.get('component') ?? null;
|
|
669
683
|
const focalNodeId = route.params.get('focus') ?? null;
|
|
670
684
|
const level = focalNodeId ? 'focus' : selectedComponent ? 'interior' : 'component';
|
|
685
|
+
// Namespace-level map defaults to the default kind; 'all' shows every kind.
|
|
686
|
+
const requestedKind = route.params.get('kind');
|
|
687
|
+
const kindFilter = resolveKindFilter(requestedKind, graphData?.nodes ?? []);
|
|
688
|
+
const kindParams = requestedKind ? { kind: requestedKind } : {};
|
|
689
|
+
const [kindRegistry, setKindRegistry] = useState([]);
|
|
690
|
+
|
|
691
|
+
useEffect(() => {
|
|
692
|
+
const refParam = viewingRef ? `?ref=${encodeURIComponent(viewingRef)}` : '';
|
|
693
|
+
fetch(`/api/kinds${refParam}`)
|
|
694
|
+
.then(r => r.ok ? r.json() : Promise.reject(r.status))
|
|
695
|
+
.then(data => setKindRegistry(data.kinds ?? []))
|
|
696
|
+
.catch(() => setKindRegistry([]));
|
|
697
|
+
}, [viewingRef]);
|
|
698
|
+
|
|
699
|
+
const navToKind = useCallback(kind => {
|
|
700
|
+
const params = kind === 'component' ? {} : { kind };
|
|
701
|
+
navigate(buildRoute({ pathname: '/graph', params, branch: viewingRef }));
|
|
702
|
+
}, [viewingRef]);
|
|
671
703
|
|
|
672
704
|
useEffect(() => { setScope(null); }, [selectedComponent]);
|
|
673
705
|
|
|
674
706
|
const navToRoot = useCallback(() => {
|
|
675
|
-
navigate(buildRoute({ pathname: '/graph', params: {}, branch: viewingRef }));
|
|
676
|
-
}, [viewingRef]);
|
|
707
|
+
navigate(buildRoute({ pathname: '/graph', params: { ...kindParams }, branch: viewingRef }));
|
|
708
|
+
}, [viewingRef, requestedKind]);
|
|
677
709
|
|
|
678
710
|
const navToComponent = useCallback(component => {
|
|
679
|
-
navigate(buildRoute({ pathname: '/graph', params: { component }, branch: viewingRef }));
|
|
680
|
-
}, [viewingRef]);
|
|
711
|
+
navigate(buildRoute({ pathname: '/graph', params: { component, ...kindParams }, branch: viewingRef }));
|
|
712
|
+
}, [viewingRef, requestedKind]);
|
|
681
713
|
|
|
682
714
|
const navToFocus = useCallback(nodeId => {
|
|
683
715
|
const params = { focus: nodeId };
|
|
@@ -723,6 +755,18 @@ function GraphView({ route, viewingRef, templates }) {
|
|
|
723
755
|
[availableEdgeTypes, hiddenEdgeTypes],
|
|
724
756
|
);
|
|
725
757
|
|
|
758
|
+
const kindByNamespace = useMemo(
|
|
759
|
+
() => new Map((graphData?.nodes ?? []).map(n => [n.namespace, n.kind ?? 'component'])),
|
|
760
|
+
[graphData],
|
|
761
|
+
);
|
|
762
|
+
const kindOptions = useMemo(() => {
|
|
763
|
+
const labels = new Map(kindRegistry.map(k => [k.id, k.label]));
|
|
764
|
+
return [
|
|
765
|
+
{ id: 'all', label: 'All' },
|
|
766
|
+
...collectKinds(graphData?.nodes ?? []).map(id => ({ id, label: labels.get(id) ?? id })),
|
|
767
|
+
];
|
|
768
|
+
}, [graphData, kindRegistry]);
|
|
769
|
+
|
|
726
770
|
const templateColour = useCallback(templateName => {
|
|
727
771
|
return templateMap.get(templateName)?.ui?.colour ?? 'var(--ink-4)';
|
|
728
772
|
}, [templateMap]);
|
|
@@ -730,13 +774,14 @@ function GraphView({ route, viewingRef, templates }) {
|
|
|
730
774
|
// Level 1: component map
|
|
731
775
|
const level1 = useMemo(() => {
|
|
732
776
|
if (!graphData) return null;
|
|
733
|
-
const
|
|
777
|
+
const shown = filterByKind(graphData.nodes, graphData.edges, kindFilter);
|
|
778
|
+
const { nodes: cmNodes, edges: cmEdges } = buildNamespaceMap(shown.nodes, shown.edges);
|
|
734
779
|
const filteredCmEdges = cmEdges.filter(e => e.types.some(t => visibleEdgeTypes.has(t)));
|
|
735
780
|
const rfN = cmNodes.map(n => ({
|
|
736
781
|
id: n.id,
|
|
737
782
|
type: 'componentCard',
|
|
738
783
|
position: { x: 0, y: 0 },
|
|
739
|
-
data: { label: n.
|
|
784
|
+
data: { label: n.namespace, count: n.count, kind: n.kind, kindColour: kindColour(n.kind), onClick: () => navToComponent(n.namespace) },
|
|
740
785
|
}));
|
|
741
786
|
const rfE = filteredCmEdges.map(e => {
|
|
742
787
|
const repType = e.types.find(t => visibleEdgeTypes.has(t)) ?? e.types[0];
|
|
@@ -746,7 +791,7 @@ function GraphView({ route, viewingRef, templates }) {
|
|
|
746
791
|
};
|
|
747
792
|
});
|
|
748
793
|
return { rfN, rfE };
|
|
749
|
-
}, [graphData, visibleEdgeTypes, layoutKey, navToComponent]);
|
|
794
|
+
}, [graphData, visibleEdgeTypes, layoutKey, navToComponent, kindFilter]);
|
|
750
795
|
|
|
751
796
|
useEffect(() => {
|
|
752
797
|
if (level !== 'component' || !level1) return;
|
|
@@ -763,7 +808,7 @@ function GraphView({ route, viewingRef, templates }) {
|
|
|
763
808
|
// Level 2: component interior
|
|
764
809
|
const level2 = useMemo(() => {
|
|
765
810
|
if (!graphData || !selectedComponent) return null;
|
|
766
|
-
const compNodes = graphData.nodes.filter(n => n.
|
|
811
|
+
const compNodes = graphData.nodes.filter(n => n.namespace === selectedComponent);
|
|
767
812
|
const compNodeIds = new Set(compNodes.map(n => n.id));
|
|
768
813
|
const internalEdges = graphData.edges.filter(e => compNodeIds.has(e.from) && compNodeIds.has(e.to));
|
|
769
814
|
const crossEdges = graphData.edges.filter(e =>
|
|
@@ -816,13 +861,13 @@ function GraphView({ route, viewingRef, templates }) {
|
|
|
816
861
|
}
|
|
817
862
|
}
|
|
818
863
|
|
|
819
|
-
const rfN = buildRFNodesForNodes(visibleNodes, templateMap, navToFocus, viewingRef, externalNodeIds);
|
|
864
|
+
const rfN = buildRFNodesForNodes(visibleNodes, templateMap, navToFocus, viewingRef, externalNodeIds, kindByNamespace);
|
|
820
865
|
const rfE = buildRFEdgesForEdges(visibleEdges, visibleEdgeTypes).map(e => {
|
|
821
866
|
const isCross = crossEdges.some(ce => ce.id === e.id);
|
|
822
867
|
return isCross ? { ...e, style: { ...e.style, opacity: 0.45 }, labelStyle: { ...e.labelStyle, opacity: 0.45 } } : e;
|
|
823
868
|
});
|
|
824
869
|
return { rfN, rfE, scopeOptions, scopeInfo };
|
|
825
|
-
}, [graphData, selectedComponent, availableEdgeTypes, visibleEdgeTypes, templateMap, layoutKey, navToFocus, scope]);
|
|
870
|
+
}, [graphData, selectedComponent, availableEdgeTypes, visibleEdgeTypes, templateMap, layoutKey, navToFocus, scope, kindByNamespace]);
|
|
826
871
|
|
|
827
872
|
useEffect(() => {
|
|
828
873
|
if (level !== 'interior' || !level2) return;
|
|
@@ -855,11 +900,11 @@ function GraphView({ route, viewingRef, templates }) {
|
|
|
855
900
|
...(focalNode && !focusData.nodes.some(n => n.id === focalNodeId) ? [focalNode] : []),
|
|
856
901
|
...focusData.nodes,
|
|
857
902
|
].map(n => ({ ...n, parentId: parentIdMap.get(n.id) ?? null }));
|
|
858
|
-
const rfN = buildRFNodesForNodes(lineageNodes, templateMap, navToFocus, viewingRef)
|
|
903
|
+
const rfN = buildRFNodesForNodes(lineageNodes, templateMap, navToFocus, viewingRef, undefined, kindByNamespace)
|
|
859
904
|
.map(n => n.id === focalNodeId ? { ...n, data: { ...n.data, focal: true } } : n);
|
|
860
905
|
const rfE = buildRFEdgesForEdges(applyEdgeTypeFilter(focusData.edges, visibleEdgeTypes), visibleEdgeTypes);
|
|
861
906
|
return { rfN, rfE };
|
|
862
|
-
}, [focusData, focalNodeId, visibleEdgeTypes, templateMap, layoutKey, viewingRef, graphData, nodeById, navToFocus]);
|
|
907
|
+
}, [focusData, focalNodeId, visibleEdgeTypes, templateMap, layoutKey, viewingRef, graphData, nodeById, navToFocus, kindByNamespace]);
|
|
863
908
|
|
|
864
909
|
useEffect(() => {
|
|
865
910
|
if (level !== 'focus' || !level3) return;
|
|
@@ -928,7 +973,7 @@ function GraphView({ route, viewingRef, templates }) {
|
|
|
928
973
|
<div className="graph-section">
|
|
929
974
|
<GraphBreadcrumb
|
|
930
975
|
level={level}
|
|
931
|
-
selectedComponent={selectedComponent ?? (focalNodeId ? nodeById.get(focalNodeId)?.
|
|
976
|
+
selectedComponent={selectedComponent ?? (focalNodeId ? nodeById.get(focalNodeId)?.namespace ?? null : null)}
|
|
932
977
|
focalNodeId={focalNodeId}
|
|
933
978
|
onNavigateToRoot={navToRoot}
|
|
934
979
|
onNavigateToComponent={navToComponent}
|
|
@@ -941,6 +986,9 @@ function GraphView({ route, viewingRef, templates }) {
|
|
|
941
986
|
onToggleMinimap={() => setShowMinimap(v => !v)}
|
|
942
987
|
onResetLayout={() => { pendingViewportRef.current = { type: 'full' }; setLayoutKey(k => k + 1); }}
|
|
943
988
|
level={level}
|
|
989
|
+
kindOptions={kindOptions}
|
|
990
|
+
kindFilter={kindFilter}
|
|
991
|
+
onKindFilter={navToKind}
|
|
944
992
|
depth={depth}
|
|
945
993
|
onDepth={setDepth}
|
|
946
994
|
allNodes={graphData?.nodes ?? []}
|
package/web/nav.js
CHANGED
|
@@ -55,15 +55,15 @@ function buildNavTree(nodes, templates) {
|
|
|
55
55
|
const nodeWithChildren = { ...node, navChildren };
|
|
56
56
|
|
|
57
57
|
if (navGroup) {
|
|
58
|
-
if (!groupsByComponent.has(node.
|
|
59
|
-
const componentGroups = groupsByComponent.get(node.
|
|
58
|
+
if (!groupsByComponent.has(node.namespace)) groupsByComponent.set(node.namespace, new Map());
|
|
59
|
+
const componentGroups = groupsByComponent.get(node.namespace);
|
|
60
60
|
if (!componentGroups.has(navGroup)) componentGroups.set(navGroup, new Map());
|
|
61
61
|
const subtypeMap = componentGroups.get(navGroup);
|
|
62
62
|
if (!subtypeMap.has(node.template)) subtypeMap.set(node.template, []);
|
|
63
63
|
subtypeMap.get(node.template).push(nodeWithChildren);
|
|
64
64
|
} else {
|
|
65
|
-
if (!plainByComponent.has(node.
|
|
66
|
-
const componentMap = plainByComponent.get(node.
|
|
65
|
+
if (!plainByComponent.has(node.namespace)) plainByComponent.set(node.namespace, new Map());
|
|
66
|
+
const componentMap = plainByComponent.get(node.namespace);
|
|
67
67
|
if (!componentMap.has(node.template)) componentMap.set(node.template, []);
|
|
68
68
|
componentMap.get(node.template).push(nodeWithChildren);
|
|
69
69
|
}
|
|
@@ -140,4 +140,35 @@ function buildOverlayIndicatorIds(nodes, templates, overlayNodes, activeOverlayR
|
|
|
140
140
|
return indicatorIds;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
// Group namespaces into one navigation section per kind. Labels come from the
|
|
144
|
+
// kind registry ([{ id, label }]); unrecognised kinds are labelled with their id.
|
|
145
|
+
// The default kind is listed first, then the rest by label.
|
|
146
|
+
function groupNamespacesByKind(nodes, kindRegistry) {
|
|
147
|
+
const labelByKind = new Map((kindRegistry ?? []).map(kind => [kind.id, kind.label]));
|
|
148
|
+
const kindByNamespace = new Map();
|
|
149
|
+
for (const node of nodes) {
|
|
150
|
+
if (!kindByNamespace.has(node.namespace)) kindByNamespace.set(node.namespace, node.kind ?? 'component');
|
|
151
|
+
}
|
|
152
|
+
const sections = new Map();
|
|
153
|
+
for (const [namespace, kind] of kindByNamespace) {
|
|
154
|
+
if (!sections.has(kind)) sections.set(kind, { kind, label: labelByKind.get(kind) ?? kind, namespaces: [] });
|
|
155
|
+
sections.get(kind).namespaces.push(namespace);
|
|
156
|
+
}
|
|
157
|
+
for (const section of sections.values()) section.namespaces.sort((a, b) => a.localeCompare(b));
|
|
158
|
+
return [...sections.values()].sort((a, b) => {
|
|
159
|
+
if (a.kind === 'component') return -1;
|
|
160
|
+
if (b.kind === 'component') return 1;
|
|
161
|
+
return a.label.localeCompare(b.label) || a.kind.localeCompare(b.kind);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Edges crossing a namespace boundary. The namespace is the first ID segment.
|
|
166
|
+
function namespaceEdges(edges, namespace) {
|
|
167
|
+
const inNs = id => id.split('.')[0] === namespace;
|
|
168
|
+
return {
|
|
169
|
+
inbound: edges.filter(e => inNs(e.to) && !inNs(e.from)),
|
|
170
|
+
outbound: edges.filter(e => inNs(e.from) && !inNs(e.to)),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
window.CorumNav = { buildNavTree, buildOverlayIndicatorIds, groupNamespacesByKind, namespaceEdges };
|
package/web/router.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var KNOWN_PATHS = new Set(['/dashboard', '/
|
|
4
|
+
var KNOWN_PATHS = new Set(['/dashboard', '/namespaces', '/namespace', '/node', '/graph']);
|
|
5
5
|
|
|
6
6
|
function parseRoute(hash) {
|
|
7
7
|
var raw = (hash || '').replace(/^#/, '') || '/dashboard';
|
package/web/search-utils.test.js
CHANGED
|
@@ -43,10 +43,10 @@ assert(fuzzyMatch('o.o', 'orders.DomainModel.order')?.score === 1, 'non-consecut
|
|
|
43
43
|
|
|
44
44
|
// searchNodes
|
|
45
45
|
const nodes = [
|
|
46
|
-
{ id: 'orders.DomainModel.order', template: 'DomainModel',
|
|
47
|
-
{ id: 'orders.RestAPI.OrdersApi', template: 'RestAPI',
|
|
48
|
-
{ id: 'payments.DomainModel.payment', template: 'DomainModel',
|
|
49
|
-
{ id: 'orders.DomainModel.order.schemas.OrderSchema', template: 'Schema',
|
|
46
|
+
{ id: 'orders.DomainModel.order', template: 'DomainModel', namespace: 'orders' },
|
|
47
|
+
{ id: 'orders.RestAPI.OrdersApi', template: 'RestAPI', namespace: 'orders' },
|
|
48
|
+
{ id: 'payments.DomainModel.payment', template: 'DomainModel', namespace: 'payments' },
|
|
49
|
+
{ id: 'orders.DomainModel.order.schemas.OrderSchema', template: 'Schema', namespace: 'orders', parentId: 'orders.DomainModel.order' },
|
|
50
50
|
];
|
|
51
51
|
const templates = [{ name: 'DomainModel', ui: { colour: '#f00', displayName: 'Domain Model' } }];
|
|
52
52
|
|
package/web/search.jsx
CHANGED
|
@@ -82,7 +82,7 @@ function SearchModal({ nodes, templates, onNavigate, onClose }) {
|
|
|
82
82
|
>
|
|
83
83
|
<TemplateBadge name={tplName} colour={colour} />
|
|
84
84
|
<span className="search-result-name">{name}</span>
|
|
85
|
-
<span className="search-result-component">{node.
|
|
85
|
+
<span className="search-result-component">{node.namespace}</span>
|
|
86
86
|
</div>
|
|
87
87
|
);
|
|
88
88
|
})}
|
package/web/style.css
CHANGED
|
@@ -171,6 +171,28 @@ button {
|
|
|
171
171
|
border-right: 1px solid var(--rule);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
.nav-kind-head {
|
|
175
|
+
padding: 10px 6px 2px;
|
|
176
|
+
color: var(--ink);
|
|
177
|
+
font-size: 13px;
|
|
178
|
+
font-weight: 700;
|
|
179
|
+
border-bottom: 1px solid var(--rule-2);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.ns-kind-pill {
|
|
183
|
+
display: inline-block;
|
|
184
|
+
padding: 1px 8px;
|
|
185
|
+
border-radius: 10px;
|
|
186
|
+
color: #fff;
|
|
187
|
+
font-size: 11px;
|
|
188
|
+
font-weight: 600;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.graph-kind-filter {
|
|
192
|
+
font-size: 12px;
|
|
193
|
+
padding: 3px 6px;
|
|
194
|
+
}
|
|
195
|
+
|
|
174
196
|
.nav-section-head {
|
|
175
197
|
display: flex;
|
|
176
198
|
align-items: center;
|