@atolis-hq/corum 0.1.23 → 0.1.25
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 +3 -12
- package/dist/src/adapters/openapi/mapper.js +3 -14
- package/dist/src/loader/cluster-loader.js +74 -3
- package/dist/src/web/server.js +17 -15
- package/dist/src/writer/graph-writer.js +1 -1
- package/package.json +1 -1
- package/web/app.jsx +167 -27
- package/web/nav.js +6 -4
- package/web/primitives.jsx +28 -14
- package/web/style.css +3 -0
|
@@ -328,7 +328,6 @@ export function mapDocument(document, entry, packConfig, componentNameReplacemen
|
|
|
328
328
|
if (payloadSchemaName) {
|
|
329
329
|
const globalId = sharedSchemas.get(payloadSchemaName);
|
|
330
330
|
if (globalId) {
|
|
331
|
-
emitReadsEdge(eventId, globalId, edges);
|
|
332
331
|
properties.payload = globalId;
|
|
333
332
|
}
|
|
334
333
|
else {
|
|
@@ -387,12 +386,6 @@ function makeNode(template, component, specPath, id) {
|
|
|
387
386
|
properties: {},
|
|
388
387
|
};
|
|
389
388
|
}
|
|
390
|
-
function emitReadsEdge(from, to, edges) {
|
|
391
|
-
const id = `${from}__reads__${to}`;
|
|
392
|
-
if (!edges.some(e => e.id === id)) {
|
|
393
|
-
edges.push({ id, from, to, type: 'reads', state: 'implemented', stability: 'unstable' });
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
389
|
function refName(ref) {
|
|
397
390
|
return ref.split('/').pop() ?? ref;
|
|
398
391
|
}
|
|
@@ -407,13 +400,12 @@ function resolveAllOfRef(schema) {
|
|
|
407
400
|
return s.allOf[0];
|
|
408
401
|
return schema;
|
|
409
402
|
}
|
|
410
|
-
function resolveSchemaRef(schemaName, nullable, collection,
|
|
403
|
+
function resolveSchemaRef(schemaName, nullable, collection, rootId, component, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas, localMappings) {
|
|
411
404
|
const extra = { nullable };
|
|
412
405
|
if (collection)
|
|
413
406
|
extra.collection = collection;
|
|
414
407
|
const globalId = sharedSchemas.get(schemaName);
|
|
415
408
|
if (globalId) {
|
|
416
|
-
emitReadsEdge(readsSource, globalId, edges);
|
|
417
409
|
return { $ref: globalId, ...extra };
|
|
418
410
|
}
|
|
419
411
|
if (localSchemas.has(schemaName))
|
|
@@ -482,7 +474,6 @@ function createMapping(mappingName, addlRaw, parentId, rootId, component, packCo
|
|
|
482
474
|
return mappingId;
|
|
483
475
|
}
|
|
484
476
|
function emitFields(schema, parentId, section, rootId, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas, localMappings) {
|
|
485
|
-
const readsSource = rootId ?? parentId;
|
|
486
477
|
const [component] = parentId.split('.');
|
|
487
478
|
for (const [fieldName, rawFieldSchema] of Object.entries(schema.properties ?? {})) {
|
|
488
479
|
const resolvedSchemaId = componentSchemaIdOf(rawFieldSchema);
|
|
@@ -495,7 +486,7 @@ function emitFields(schema, parentId, section, rootId, packConfig, specPath, nod
|
|
|
495
486
|
? resolvedSchemaId
|
|
496
487
|
: (isRefSchema(fieldSchema) ? refName(fieldSchema.$ref) : undefined);
|
|
497
488
|
if (schemaName !== undefined) {
|
|
498
|
-
fieldNode.properties = resolveSchemaRef(schemaName, !required, undefined,
|
|
489
|
+
fieldNode.properties = resolveSchemaRef(schemaName, !required, undefined, rootId, component, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas, localMappings);
|
|
499
490
|
}
|
|
500
491
|
else {
|
|
501
492
|
const fs = fieldSchema;
|
|
@@ -514,7 +505,7 @@ function emitFields(schema, parentId, section, rootId, packConfig, specPath, nod
|
|
|
514
505
|
fieldNode.properties = { type: 'string', nullable, collection: 'array' };
|
|
515
506
|
}
|
|
516
507
|
else if (isRefSchema(items)) {
|
|
517
|
-
fieldNode.properties = resolveSchemaRef(refName(items.$ref), nullable, 'array',
|
|
508
|
+
fieldNode.properties = resolveSchemaRef(refName(items.$ref), nullable, 'array', rootId, component, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas, localMappings);
|
|
518
509
|
if (!fieldNode.properties.$ref)
|
|
519
510
|
fieldNode.properties = { type: 'string', nullable, collection: 'array' };
|
|
520
511
|
}
|
|
@@ -37,12 +37,6 @@ export function deriveNodeId(kind, component, name, parentId, section) {
|
|
|
37
37
|
export function refName(ref) {
|
|
38
38
|
return ref.split('/').pop() ?? ref;
|
|
39
39
|
}
|
|
40
|
-
function emitReadsEdge(from, to, edges) {
|
|
41
|
-
const id = `${from}__reads__${to}`;
|
|
42
|
-
if (!edges.some(e => e.id === id)) {
|
|
43
|
-
edges.push({ id, from, to, type: 'reads', state: 'implemented', stability: 'unstable' });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
40
|
export function mapDocument(document, entry, packConfig, componentNameReplacements = []) {
|
|
47
41
|
const nodes = [];
|
|
48
42
|
const edges = [];
|
|
@@ -283,8 +277,6 @@ function emitSchemaNode(schema, name, parentId, section, rootId, packConfig, spe
|
|
|
283
277
|
const schemaName = refName(schema.$ref);
|
|
284
278
|
const globalId = sharedSchemas.get(schemaName);
|
|
285
279
|
if (globalId) {
|
|
286
|
-
if (rootId)
|
|
287
|
-
emitReadsEdge(rootId, globalId, edges);
|
|
288
280
|
return globalId;
|
|
289
281
|
}
|
|
290
282
|
if (localSchemas.has(schemaName))
|
|
@@ -311,13 +303,12 @@ function createInlineSchema(schema, name, parentId, section, rootId, packConfig,
|
|
|
311
303
|
emitFields(schema, schemaId, 'fields', rootId, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas, localMappings);
|
|
312
304
|
return localRef;
|
|
313
305
|
}
|
|
314
|
-
function resolveFieldRef(schemaName, collection, required, rootId,
|
|
306
|
+
function resolveFieldRef(schemaName, collection, required, rootId, refSchema, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas, localMappings) {
|
|
315
307
|
const extra = { nullable: !required };
|
|
316
308
|
if (collection !== 'one')
|
|
317
309
|
extra.collection = collection;
|
|
318
310
|
const globalId = sharedSchemas.get(schemaName);
|
|
319
311
|
if (globalId) {
|
|
320
|
-
emitReadsEdge(readsSource, globalId, edges);
|
|
321
312
|
return { $ref: globalId, ...extra };
|
|
322
313
|
}
|
|
323
314
|
if (localSchemas.has(schemaName))
|
|
@@ -411,8 +402,6 @@ function createMapping(mappingName, addlRaw, parentId, rootId, packConfig, specP
|
|
|
411
402
|
return mappingId;
|
|
412
403
|
}
|
|
413
404
|
function emitFields(schema, parentId, section, rootId, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas, localMappings) {
|
|
414
|
-
// readsSource: when in endpoint context use rootId, otherwise use the schema itself
|
|
415
|
-
const readsSource = rootId ?? parentId;
|
|
416
405
|
for (const [fieldName, rawFieldSchema] of Object.entries(schema.properties ?? {})) {
|
|
417
406
|
const fieldSchema = resolveAllOfRef(rawFieldSchema);
|
|
418
407
|
const fieldId = deriveNodeId('field', undefined, fieldName, parentId, section);
|
|
@@ -420,7 +409,7 @@ function emitFields(schema, parentId, section, rootId, packConfig, specPath, nod
|
|
|
420
409
|
const fieldNode = makeNode(packConfig.constructs.schemaProperty?.template ?? 'Field', component, specPath, fieldId);
|
|
421
410
|
const required = Array.isArray(schema.required) && schema.required.includes(fieldName);
|
|
422
411
|
if (isRefSchema(fieldSchema)) {
|
|
423
|
-
fieldNode.properties = resolveFieldRef(refName(fieldSchema.$ref), 'one', required, rootId,
|
|
412
|
+
fieldNode.properties = resolveFieldRef(refName(fieldSchema.$ref), 'one', required, rootId, fieldSchema, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas, localMappings);
|
|
424
413
|
}
|
|
425
414
|
else {
|
|
426
415
|
const fs = fieldSchema;
|
|
@@ -435,7 +424,7 @@ function emitFields(schema, parentId, section, rootId, packConfig, specPath, nod
|
|
|
435
424
|
fieldNode.properties = { type: 'string', nullable: !required, collection: 'array' };
|
|
436
425
|
}
|
|
437
426
|
else if (isRefSchema(items)) {
|
|
438
|
-
fieldNode.properties = resolveFieldRef(refName(items.$ref), 'array', required, rootId,
|
|
427
|
+
fieldNode.properties = resolveFieldRef(refName(items.$ref), 'array', required, rootId, items, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas, localMappings);
|
|
439
428
|
}
|
|
440
429
|
else {
|
|
441
430
|
const itemType = deriveScalarType(items.type ?? 'string', items.format, packConfig.scalarTypes);
|
|
@@ -38,11 +38,64 @@ export function loadClusters(content, templates, diagnostics) {
|
|
|
38
38
|
properties: isRecord(record.properties) ? record.properties : {},
|
|
39
39
|
};
|
|
40
40
|
addNode(result, root, key, diagnostics);
|
|
41
|
-
|
|
41
|
+
const rootTemplate = templates.get(root.template);
|
|
42
|
+
if (rootTemplate) {
|
|
43
|
+
for (const target of getNodeRefTargets(root, rootTemplate)) {
|
|
44
|
+
const readsId = `${root.id}__reads__${target}`;
|
|
45
|
+
const existingFrom = result.edgesByFrom.get(root.id) ?? [];
|
|
46
|
+
if (!existingFrom.some(e => e.id === readsId)) {
|
|
47
|
+
addEdge(result, {
|
|
48
|
+
id: readsId, from: root.id, to: target, type: 'reads',
|
|
49
|
+
state: root.state, stability: root.stability, generated: true,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
materialiseChildren(result, root, root, record, templates, key, diagnostics);
|
|
42
55
|
}
|
|
43
56
|
return result;
|
|
44
57
|
}
|
|
45
|
-
function
|
|
58
|
+
function getPropertySchemasFromTemplate(props) {
|
|
59
|
+
if (Array.isArray(props.allOf)) {
|
|
60
|
+
const merged = {};
|
|
61
|
+
for (const schema of props.allOf) {
|
|
62
|
+
Object.assign(merged, getPropertySchemasFromTemplate(schema));
|
|
63
|
+
}
|
|
64
|
+
return merged;
|
|
65
|
+
}
|
|
66
|
+
if (typeof props.properties === 'object' && props.properties !== null) {
|
|
67
|
+
return props.properties;
|
|
68
|
+
}
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
function getNodeRefTargets(node, template) {
|
|
72
|
+
if (!template.properties)
|
|
73
|
+
return [];
|
|
74
|
+
const propSchemas = getPropertySchemasFromTemplate(template.properties);
|
|
75
|
+
const targets = [];
|
|
76
|
+
for (const [key, schema] of Object.entries(propSchemas)) {
|
|
77
|
+
const s = schema;
|
|
78
|
+
if (s.format === 'node-ref') {
|
|
79
|
+
const value = node.properties[key];
|
|
80
|
+
if (typeof value === 'string' && !value.startsWith('#/'))
|
|
81
|
+
targets.push(value);
|
|
82
|
+
}
|
|
83
|
+
else if (s.type === 'object' &&
|
|
84
|
+
typeof s.additionalProperties === 'object' &&
|
|
85
|
+
s.additionalProperties !== null &&
|
|
86
|
+
s.additionalProperties.format === 'node-ref') {
|
|
87
|
+
const map = node.properties[key];
|
|
88
|
+
if (typeof map === 'object' && map !== null && !Array.isArray(map)) {
|
|
89
|
+
for (const value of Object.values(map)) {
|
|
90
|
+
if (typeof value === 'string' && !value.startsWith('#/'))
|
|
91
|
+
targets.push(value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return targets;
|
|
97
|
+
}
|
|
98
|
+
function materialiseChildren(result, parent, clusterRoot, source, templates, filePath, diagnostics) {
|
|
46
99
|
const template = templates.get(parent.template);
|
|
47
100
|
if (!template) {
|
|
48
101
|
diagnostics.push({ severity: 'error', file: filePath, nodeId: parent.id, message: `unknown template: ${parent.template}` });
|
|
@@ -85,7 +138,25 @@ function materialiseChildren(result, parent, source, templates, filePath, diagno
|
|
|
85
138
|
stability: child.stability,
|
|
86
139
|
});
|
|
87
140
|
}
|
|
88
|
-
|
|
141
|
+
const childTemplate = templates.get(child.template);
|
|
142
|
+
if (childTemplate) {
|
|
143
|
+
for (const target of getNodeRefTargets(child, childTemplate)) {
|
|
144
|
+
const readsId = `${clusterRoot.id}__reads__${target}`;
|
|
145
|
+
const existingFrom = result.edgesByFrom.get(clusterRoot.id) ?? [];
|
|
146
|
+
if (!existingFrom.some(e => e.id === readsId)) {
|
|
147
|
+
addEdge(result, {
|
|
148
|
+
id: readsId,
|
|
149
|
+
from: clusterRoot.id,
|
|
150
|
+
to: target,
|
|
151
|
+
type: 'reads',
|
|
152
|
+
state: clusterRoot.state,
|
|
153
|
+
stability: clusterRoot.stability,
|
|
154
|
+
generated: true,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
materialiseChildren(result, child, clusterRoot, value, templates, filePath, diagnostics);
|
|
89
160
|
}
|
|
90
161
|
}
|
|
91
162
|
}
|
package/dist/src/web/server.js
CHANGED
|
@@ -41,24 +41,26 @@ async function getPluginFiles() {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
function getNavigationOwnership(graph, node) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
// Walk up the node's own ID hierarchy in 2-segment strides (section + name),
|
|
45
|
+
// returning the deepest valid parent. This is O(depth) per node instead of O(N).
|
|
46
|
+
const parts = node.id.split('.');
|
|
47
|
+
let endIdx = parts.length - 2;
|
|
48
|
+
while (endIdx >= 1) {
|
|
49
|
+
const candidateId = parts.slice(0, endIdx).join('.');
|
|
50
|
+
const section = parts[endIdx];
|
|
51
|
+
const candidate = graph.nodesById.get(candidateId);
|
|
52
|
+
if (candidate) {
|
|
53
|
+
const tmpl = graph.templates.get(candidate.template);
|
|
54
|
+
if (tmpl) {
|
|
55
|
+
const ownedSections = getOwnedSections(tmpl);
|
|
56
|
+
if (section in ownedSections && ownedSections[section] === node.template) {
|
|
57
|
+
return { parentId: candidateId, ownedSection: section };
|
|
58
|
+
}
|
|
58
59
|
}
|
|
59
60
|
}
|
|
61
|
+
endIdx -= 2;
|
|
60
62
|
}
|
|
61
|
-
return
|
|
63
|
+
return undefined;
|
|
62
64
|
}
|
|
63
65
|
function summarizeNodeForNavigation(graph, node) {
|
|
64
66
|
const ownership = getNavigationOwnership(graph, node);
|
|
@@ -13,7 +13,7 @@ export function serializeGraph(graph, options = {}) {
|
|
|
13
13
|
map.set(clusterPath(root), stringifyGraphYaml(toClusterDocument(graph, root)));
|
|
14
14
|
}
|
|
15
15
|
const explicitEdges = getAllEdges(graph)
|
|
16
|
-
.filter(edge => !STRUCTURAL_EDGE_TYPES.has(edge.type))
|
|
16
|
+
.filter(edge => !STRUCTURAL_EDGE_TYPES.has(edge.type) && edge.generated !== true)
|
|
17
17
|
.sort((a, b) => a.id.localeCompare(b.id));
|
|
18
18
|
if (explicitEdges.length > 0) {
|
|
19
19
|
map.set('edges/corum.edges.yaml', stringifyGraphYaml({ edges: explicitEdges.map(toEdgeDocument) }));
|
package/package.json
CHANGED
package/web/app.jsx
CHANGED
|
@@ -14,6 +14,29 @@ const {
|
|
|
14
14
|
const { buildNavTree, buildOverlayIndicatorIds } = window.CorumNav;
|
|
15
15
|
const { parseRoute, buildRoute } = window.CorumRouter;
|
|
16
16
|
|
|
17
|
+
const PANEL_EDGE_TYPES = new Set(['triggers', 'produces', 'calls', 'implements']);
|
|
18
|
+
|
|
19
|
+
const EDGE_TYPE_STYLES = {
|
|
20
|
+
triggers: { background: '#fef3c7', color: '#b45309' },
|
|
21
|
+
produces: { background: '#ccfbf1', color: '#0f766e' },
|
|
22
|
+
calls: { background: '#ede9fe', color: '#6d28d9' },
|
|
23
|
+
implements: { background: '#f1f5f9', color: '#475569' },
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function classifyEdges(edges, clusterIds) {
|
|
27
|
+
const inbound = [];
|
|
28
|
+
const outbound = [];
|
|
29
|
+
for (const edge of edges) {
|
|
30
|
+
if (!PANEL_EDGE_TYPES.has(edge.type)) continue;
|
|
31
|
+
if (clusterIds.has(edge.from) && !clusterIds.has(edge.to)) {
|
|
32
|
+
outbound.push(edge);
|
|
33
|
+
} else if (!clusterIds.has(edge.from) && clusterIds.has(edge.to)) {
|
|
34
|
+
inbound.push(edge);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { inbound, outbound };
|
|
38
|
+
}
|
|
39
|
+
|
|
17
40
|
function displayName(id) {
|
|
18
41
|
const parts = id.split('.');
|
|
19
42
|
return parts[parts.length - 1];
|
|
@@ -91,6 +114,7 @@ function NavTree({ navTree, templates, activeNodeId, onNode, overlayIndicatorIds
|
|
|
91
114
|
const sortedComponents = [...navTree.keys()].sort((a, b) => a.localeCompare(b));
|
|
92
115
|
const [openComponent, setOpenComponent] = useState();
|
|
93
116
|
const [openEntryKeys, setOpenEntryKeys] = useState(new Set());
|
|
117
|
+
const [openGroupKeys, setOpenGroupKeys] = useState(new Set());
|
|
94
118
|
const templateMap = new Map(templates.map(template => [template.name, template]));
|
|
95
119
|
|
|
96
120
|
function openComponentWithEntries(component) {
|
|
@@ -129,6 +153,26 @@ function NavTree({ navTree, templates, activeNodeId, onNode, overlayIndicatorIds
|
|
|
129
153
|
}
|
|
130
154
|
}, [activeNodeId, navTree]);
|
|
131
155
|
|
|
156
|
+
// Auto-expand groups for the active node; collapse all others.
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if (!activeNodeId || !navTree.size) return;
|
|
159
|
+
for (const entries of navTree.values()) {
|
|
160
|
+
for (const entry of entries) {
|
|
161
|
+
if (entry.kind === 'group') continue;
|
|
162
|
+
for (const node of entry.nodes) {
|
|
163
|
+
const isOwner =
|
|
164
|
+
node.id === activeNodeId ||
|
|
165
|
+
(node.navChildren ?? []).some(g => g.nodes.some(c => c.id === activeNodeId));
|
|
166
|
+
if (isOwner) {
|
|
167
|
+
setOpenGroupKeys(new Set((node.navChildren ?? []).map(g => `${node.id}:${g.label}`)));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
setOpenGroupKeys(new Set());
|
|
174
|
+
}, [activeNodeId, navTree]);
|
|
175
|
+
|
|
132
176
|
function toggleComponent(component) {
|
|
133
177
|
if (openComponent === component) { openComponentWithEntries(null); }
|
|
134
178
|
else { openComponentWithEntries(component); }
|
|
@@ -234,32 +278,47 @@ function NavTree({ navTree, templates, activeNodeId, onNode, overlayIndicatorIds
|
|
|
234
278
|
>
|
|
235
279
|
{displayName(node.id)}
|
|
236
280
|
</div>
|
|
237
|
-
{(node.navChildren ?? []).map(group =>
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
281
|
+
{(node.navChildren ?? []).map(group => {
|
|
282
|
+
const groupKey = `${node.id}:${group.label}`;
|
|
283
|
+
const groupOpen = openGroupKeys.has(groupKey);
|
|
284
|
+
return (
|
|
285
|
+
<div className="nav-child-group" key={group.label}>
|
|
286
|
+
<div
|
|
287
|
+
className="nav-child-head"
|
|
288
|
+
style={{ cursor: 'pointer' }}
|
|
289
|
+
onClick={() => setOpenGroupKeys(prev => {
|
|
290
|
+
const next = new Set(prev);
|
|
291
|
+
next.has(groupKey) ? next.delete(groupKey) : next.add(groupKey);
|
|
292
|
+
return next;
|
|
293
|
+
})}
|
|
294
|
+
>
|
|
295
|
+
{group.label}
|
|
296
|
+
<Icon name={groupOpen ? 'chevron-down' : 'chevron-right'} size={10} />
|
|
297
|
+
</div>
|
|
298
|
+
{groupOpen && group.nodes.map(child => {
|
|
299
|
+
const childTemplate = templateMap.get(child.template);
|
|
300
|
+
const childColour = childTemplate?.ui?.colour ?? colour;
|
|
301
|
+
const childIsActive = child.id === activeNodeId;
|
|
302
|
+
return (
|
|
303
|
+
<div
|
|
304
|
+
key={child.id}
|
|
305
|
+
className={`nav-node-item nav-node-child${childIsActive ? ' active' : ''}`}
|
|
306
|
+
onClick={() => onNode(child.id)}
|
|
307
|
+
title={child.id}
|
|
308
|
+
style={childIsActive ? { '--nav-node-active-bg': childColour } : undefined}
|
|
309
|
+
>
|
|
310
|
+
{displayName(child.id)}
|
|
311
|
+
{overlayIndicatorIds && overlayIndicatorIds.has(child.id) && (
|
|
312
|
+
<span className="signal-dots">
|
|
313
|
+
<span className="signal-dot signal-dot-0" />
|
|
314
|
+
</span>
|
|
315
|
+
)}
|
|
316
|
+
</div>
|
|
317
|
+
);
|
|
318
|
+
})}
|
|
319
|
+
</div>
|
|
320
|
+
);
|
|
321
|
+
})}
|
|
263
322
|
</div>
|
|
264
323
|
);
|
|
265
324
|
})}
|
|
@@ -423,6 +482,77 @@ function ComponentsPage() {
|
|
|
423
482
|
return <div className="content"><h1>Components</h1></div>;
|
|
424
483
|
}
|
|
425
484
|
|
|
485
|
+
function EdgePanel({ inbound, outbound, allNodes, templates, onNavigate }) {
|
|
486
|
+
const { useState: useLocalState } = React;
|
|
487
|
+
const [open, setOpen] = useLocalState(() => {
|
|
488
|
+
try { return localStorage.getItem('corum:edgePanelOpen') === 'true'; } catch { return false; }
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
if (inbound.length === 0 && outbound.length === 0) return null;
|
|
492
|
+
|
|
493
|
+
function toggle() {
|
|
494
|
+
setOpen(prev => {
|
|
495
|
+
const next = !prev;
|
|
496
|
+
try { localStorage.setItem('corum:edgePanelOpen', String(next)); } catch {}
|
|
497
|
+
return next;
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
const nodeMap = new Map(allNodes.map(n => [n.id, n]));
|
|
502
|
+
const templateMap = new Map(templates.map(t => [t.name, t]));
|
|
503
|
+
|
|
504
|
+
function EdgeRow({ edge, linkedNodeId }) {
|
|
505
|
+
const node = nodeMap.get(linkedNodeId);
|
|
506
|
+
const tmpl = node ? templateMap.get(node.template) : null;
|
|
507
|
+
const colour = tmpl?.ui?.colour ?? null;
|
|
508
|
+
const name = linkedNodeId.split('.').pop();
|
|
509
|
+
return (
|
|
510
|
+
<div
|
|
511
|
+
onClick={() => onNavigate(linkedNodeId)}
|
|
512
|
+
title={linkedNodeId}
|
|
513
|
+
style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '5px 0', cursor: 'pointer' }}
|
|
514
|
+
>
|
|
515
|
+
<span className="tag" style={EDGE_TYPE_STYLES[edge.type] ?? {}}>{edge.type}</span>
|
|
516
|
+
<TemplateBadge name={tmpl?.ui?.displayName ?? node?.template ?? '?'} colour={colour} />
|
|
517
|
+
<span style={{ fontWeight: 500, fontSize: 13 }}>{name}</span>
|
|
518
|
+
{node && <StateTag state={node.state} />}
|
|
519
|
+
{node && <StabilityTag stability={node.stability} />}
|
|
520
|
+
</div>
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return (
|
|
525
|
+
<div className="card" style={{ marginBottom: 16 }}>
|
|
526
|
+
<div
|
|
527
|
+
className="card-head"
|
|
528
|
+
onClick={toggle}
|
|
529
|
+
style={{ cursor: 'pointer', display: 'flex', alignItems: 'center', gap: 12, userSelect: 'none' }}
|
|
530
|
+
>
|
|
531
|
+
<span>Connections</span>
|
|
532
|
+
{inbound.length > 0 && <span className="label-sm">← {inbound.length} inbound</span>}
|
|
533
|
+
{outbound.length > 0 && <span className="label-sm">→ {outbound.length} outbound</span>}
|
|
534
|
+
<span style={{ marginLeft: 'auto' }}><Icon name={open ? 'chevron-up' : 'chevron-down'} size={12} /></span>
|
|
535
|
+
</div>
|
|
536
|
+
{open && (
|
|
537
|
+
<div className="card-body" style={{ display: 'flex', flexDirection: 'column', gap: 16, padding: '12px 16px' }}>
|
|
538
|
+
{inbound.length > 0 && (
|
|
539
|
+
<div>
|
|
540
|
+
<div className="label-xs" style={{ marginBottom: 8 }}>Inbound</div>
|
|
541
|
+
{inbound.map(edge => <EdgeRow key={edge.id} edge={edge} linkedNodeId={edge.from} />)}
|
|
542
|
+
</div>
|
|
543
|
+
)}
|
|
544
|
+
{outbound.length > 0 && (
|
|
545
|
+
<div>
|
|
546
|
+
<div className="label-xs" style={{ marginBottom: 8 }}>Outbound</div>
|
|
547
|
+
{outbound.map(edge => <EdgeRow key={edge.id} edge={edge} linkedNodeId={edge.to} />)}
|
|
548
|
+
</div>
|
|
549
|
+
)}
|
|
550
|
+
</div>
|
|
551
|
+
)}
|
|
552
|
+
</div>
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
|
|
426
556
|
function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, overlayRefs, compact = true }) {
|
|
427
557
|
const [cluster, setCluster] = useState(null);
|
|
428
558
|
const [error, setError] = useState(null);
|
|
@@ -435,7 +565,7 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
435
565
|
const overlayParam = overlayRefs && overlayRefs.length > 0
|
|
436
566
|
? '&' + overlayRefs.map(ref => `overlayRefs=${encodeURIComponent(ref)}`).join('&')
|
|
437
567
|
: '';
|
|
438
|
-
fetch(`/api/cluster?nodeId=${encodeURIComponent(nodeId)}&includeEdges=maps-to,reads${refParam}${overlayParam}`)
|
|
568
|
+
fetch(`/api/cluster?nodeId=${encodeURIComponent(nodeId)}&includeEdges=maps-to,reads,triggers,produces,calls,implements${refParam}${overlayParam}`)
|
|
439
569
|
.then(response => response.ok ? response.json() : Promise.reject(response.status))
|
|
440
570
|
.then(setCluster)
|
|
441
571
|
.catch(err => setError(String(err)));
|
|
@@ -446,6 +576,8 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
446
576
|
if (!cluster) return <div className="content"><p className="label-sm">Loading...</p></div>;
|
|
447
577
|
|
|
448
578
|
const { root, descendants, includedNodes, edges } = cluster;
|
|
579
|
+
const clusterIds = new Set([root.id, ...descendants.map(d => d.id)]);
|
|
580
|
+
const { inbound: panelInbound, outbound: panelOutbound } = classifyEdges(edges, clusterIds);
|
|
449
581
|
const template = templates.find(item => item.name === root.template);
|
|
450
582
|
const colour = template?.ui?.colour ?? null;
|
|
451
583
|
const nestedSections = new Set((template?.ui?.nav?.nestOwned ?? []).map(item => item.section));
|
|
@@ -491,6 +623,14 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
491
623
|
<div className="label-sm mono">{root.id}</div>
|
|
492
624
|
</div>
|
|
493
625
|
|
|
626
|
+
<EdgePanel
|
|
627
|
+
inbound={panelInbound}
|
|
628
|
+
outbound={panelOutbound}
|
|
629
|
+
allNodes={[root, ...descendants, ...includedNodes]}
|
|
630
|
+
templates={templates}
|
|
631
|
+
onNavigate={onNavigate}
|
|
632
|
+
/>
|
|
633
|
+
|
|
494
634
|
<div className="meta-strip">
|
|
495
635
|
{[
|
|
496
636
|
['Component', root.component],
|
package/web/nav.js
CHANGED
|
@@ -46,10 +46,12 @@ function buildNavTree(nodes, templates) {
|
|
|
46
46
|
if (nestedNodeIds.has(node.id)) continue;
|
|
47
47
|
const template = templateMap.get(node.template);
|
|
48
48
|
const navGroup = template?.ui?.nav?.navGroup;
|
|
49
|
-
const navChildren = [...(nestedByParent.get(node.id)?.values() ?? [])]
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
const navChildren = [...(nestedByParent.get(node.id)?.values() ?? [])]
|
|
50
|
+
.sort((a, b) => a.label.localeCompare(b.label))
|
|
51
|
+
.map(group => ({
|
|
52
|
+
label: group.label,
|
|
53
|
+
nodes: group.nodes.sort((a, b) => a.id.localeCompare(b.id)),
|
|
54
|
+
}));
|
|
53
55
|
const nodeWithChildren = { ...node, navChildren };
|
|
54
56
|
|
|
55
57
|
if (navGroup) {
|
package/web/primitives.jsx
CHANGED
|
@@ -323,23 +323,33 @@ function enumValueDescription(node) {
|
|
|
323
323
|
return node.properties?.description ?? '-';
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
function parentSchemaId(fieldNodeId) {
|
|
327
|
+
const idx = fieldNodeId.lastIndexOf('.fields.');
|
|
328
|
+
return idx >= 0 ? fieldNodeId.slice(0, idx) : null;
|
|
329
|
+
}
|
|
330
|
+
|
|
326
331
|
function buildSchemaModel(schemaNodes, allNodes) {
|
|
327
|
-
// Include all Schema nodes from allNodes so canExpand works for included/referenced schemas
|
|
328
332
|
const allSchemaNodes = (allNodes ?? []).filter(n => n.template === 'Schema');
|
|
329
333
|
const allMappingNodes = (allNodes ?? []).filter(n => n.template === 'Mapping');
|
|
330
334
|
const schemasByName = new Map(allSchemaNodes.map(node => [localSchemaName(node.id), node]));
|
|
335
|
+
const schemasById = new Map(allSchemaNodes.map(node => [node.id, node]));
|
|
331
336
|
const mappingsByNodeId = new Map(allMappingNodes.map(node => [node.id, node]));
|
|
332
337
|
// Ensure the primary schemaNodes are always present (they may not be in allNodes)
|
|
333
|
-
for (const node of schemaNodes)
|
|
338
|
+
for (const node of schemaNodes) {
|
|
339
|
+
schemasByName.set(localSchemaName(node.id), node);
|
|
340
|
+
schemasById.set(node.id, node);
|
|
341
|
+
}
|
|
342
|
+
// fieldsBySchema keyed by full schema node ID — prevents same-named schemas from
|
|
343
|
+
// different clusters contaminating each other's field lists
|
|
334
344
|
const fieldsBySchema = new Map();
|
|
335
345
|
const referencedSchemas = new Set();
|
|
336
346
|
|
|
337
347
|
for (const node of allNodes ?? []) {
|
|
338
348
|
if (node.template !== 'Field') continue;
|
|
339
|
-
const
|
|
340
|
-
if (!
|
|
341
|
-
if (!fieldsBySchema.has(
|
|
342
|
-
fieldsBySchema.get(
|
|
349
|
+
const schemaId = parentSchemaId(node.id);
|
|
350
|
+
if (!schemaId) continue;
|
|
351
|
+
if (!fieldsBySchema.has(schemaId)) fieldsBySchema.set(schemaId, []);
|
|
352
|
+
fieldsBySchema.get(schemaId).push(node);
|
|
343
353
|
|
|
344
354
|
const ref = node.properties?.['$ref'];
|
|
345
355
|
const localName = refLocalSchemaName(ref);
|
|
@@ -351,6 +361,7 @@ function buildSchemaModel(schemaNodes, allNodes) {
|
|
|
351
361
|
const topSchemas = schemaNodes.filter(node => !referencedSchemas.has(localSchemaName(node.id)));
|
|
352
362
|
return {
|
|
353
363
|
schemasByName,
|
|
364
|
+
schemasById,
|
|
354
365
|
mappingsByNodeId,
|
|
355
366
|
fieldsBySchema,
|
|
356
367
|
topSchemas: topSchemas.length > 0 ? topSchemas : schemaNodes,
|
|
@@ -409,7 +420,7 @@ function MappingInlineRows({ mappingNode, depth, model, edges, compact, visited
|
|
|
409
420
|
{valueCanExpand && !valueCollapsed && (
|
|
410
421
|
valueCanExpandSchema ? (
|
|
411
422
|
<SchemaFieldRows
|
|
412
|
-
|
|
423
|
+
schemaNodeId={valueSchema.id}
|
|
413
424
|
model={model}
|
|
414
425
|
depth={depth + 1}
|
|
415
426
|
visited={nextVisited}
|
|
@@ -431,9 +442,9 @@ function MappingInlineRows({ mappingNode, depth, model, edges, compact, visited
|
|
|
431
442
|
);
|
|
432
443
|
}
|
|
433
444
|
|
|
434
|
-
function SchemaFieldRows({
|
|
445
|
+
function SchemaFieldRows({ schemaNodeId, model, prefix = '', depth = 0, visited = new Set(), edges = [], overlayFields, overlayRefs, compact = false }) {
|
|
435
446
|
const [collapsed, setCollapsed] = React.useState(new Set());
|
|
436
|
-
const fields = model.fieldsBySchema.get(
|
|
447
|
+
const fields = model.fieldsBySchema.get(schemaNodeId) ?? [];
|
|
437
448
|
if (fields.length === 0) {
|
|
438
449
|
return (
|
|
439
450
|
<div className="field-row">
|
|
@@ -457,14 +468,17 @@ function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited =
|
|
|
457
468
|
const refNodeId = ref && typeof ref === 'object' && 'nodeId' in ref ? ref.nodeId : null;
|
|
458
469
|
const mappingNode = refNodeId ? (model.mappingsByNodeId?.get(refNodeId) ?? null) : null;
|
|
459
470
|
const canExpandMapping = !!mappingNode;
|
|
460
|
-
|
|
461
|
-
const
|
|
471
|
+
// Prefer exact node ID lookup to avoid same-named schemas from different clusters
|
|
472
|
+
const childSchemaNode = !canExpandMapping
|
|
473
|
+
? (refNodeId ? (model.schemasById?.get(refNodeId) ?? null) : (localRef ? (model.schemasByName.get(localRef) ?? null) : null))
|
|
474
|
+
: null;
|
|
475
|
+
const canExpand = !!childSchemaNode && !visited.has(childSchemaNode.id);
|
|
462
476
|
const isExpandable = canExpand || canExpandMapping;
|
|
463
477
|
const childGhostFields = childSchemaNode ? overlayFieldsForSchema(overlayFields, childSchemaNode.id) : [];
|
|
464
478
|
const c = field.properties?.collection;
|
|
465
479
|
const childPrefix = `${prefix}${name}${c === 'array' ? '[].' : '.'}`;
|
|
466
480
|
const nextVisited = new Set(visited);
|
|
467
|
-
nextVisited.add(
|
|
481
|
+
nextVisited.add(schemaNodeId);
|
|
468
482
|
const links = edges.filter(e =>
|
|
469
483
|
(e.from === field.id || e.to === field.id)
|
|
470
484
|
&& e.type !== 'has-field'
|
|
@@ -525,7 +539,7 @@ function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited =
|
|
|
525
539
|
) : (
|
|
526
540
|
<>
|
|
527
541
|
<SchemaFieldRows
|
|
528
|
-
|
|
542
|
+
schemaNodeId={childSchemaNode.id}
|
|
529
543
|
model={model}
|
|
530
544
|
prefix={childPrefix}
|
|
531
545
|
depth={depth + 1}
|
|
@@ -708,7 +722,7 @@ function SchemaCard({ title, nodes, allNodes, edges, anchorIdForNode, overlayFie
|
|
|
708
722
|
<div className="label-xs">Links</div>
|
|
709
723
|
</div>
|
|
710
724
|
<SchemaFieldRows
|
|
711
|
-
|
|
725
|
+
schemaNodeId={schema.id}
|
|
712
726
|
model={model}
|
|
713
727
|
visited={new Set()}
|
|
714
728
|
edges={edges ?? []}
|