@atolis-hq/corum 0.1.16 → 0.1.17
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/package.json +1 -1
- package/web/app.jsx +36 -6
- package/web/primitives.jsx +49 -19
package/package.json
CHANGED
package/web/app.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Main app: router, nav shell, data loading, and node pages. */
|
|
2
2
|
|
|
3
|
-
const { useState, useEffect, useCallback } = React;
|
|
3
|
+
const { useState, useEffect, useCallback, useMemo } = React;
|
|
4
4
|
const {
|
|
5
5
|
navigate,
|
|
6
6
|
BrandMark,
|
|
@@ -46,7 +46,7 @@ function TopBar() {
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function NavRail({ activeSection, onSection }) {
|
|
49
|
+
function NavRail({ activeSection, onSection, debugMode, onDebugMode }) {
|
|
50
50
|
const items = [
|
|
51
51
|
{ id: 'dashboard', icon: 'grip', label: 'Dashboard' },
|
|
52
52
|
{ id: 'components', icon: 'circle-nodes', label: 'Models' },
|
|
@@ -66,6 +66,19 @@ function NavRail({ activeSection, onSection }) {
|
|
|
66
66
|
<span>{item.label}</span>
|
|
67
67
|
</button>
|
|
68
68
|
))}
|
|
69
|
+
<button
|
|
70
|
+
className="nav-rail-item"
|
|
71
|
+
onClick={onDebugMode}
|
|
72
|
+
title="Debug mode: show fully qualified names"
|
|
73
|
+
type="button"
|
|
74
|
+
style={{
|
|
75
|
+
marginTop: 'auto',
|
|
76
|
+
...(debugMode ? { background: 'var(--paper-3)', color: 'var(--ink)', borderColor: 'var(--rule-2)' } : {}),
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<Icon name="code" size={16} />
|
|
80
|
+
<span>Debug</span>
|
|
81
|
+
</button>
|
|
69
82
|
</div>
|
|
70
83
|
);
|
|
71
84
|
}
|
|
@@ -364,7 +377,7 @@ function ComponentsPage() {
|
|
|
364
377
|
return <div className="content"><h1>Components</h1></div>;
|
|
365
378
|
}
|
|
366
379
|
|
|
367
|
-
function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, overlayRefs }) {
|
|
380
|
+
function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, overlayRefs, compact = true }) {
|
|
368
381
|
const [cluster, setCluster] = useState(null);
|
|
369
382
|
const [error, setError] = useState(null);
|
|
370
383
|
|
|
@@ -470,6 +483,7 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
470
483
|
anchorIdForNode={anchorIdForNode}
|
|
471
484
|
overlayFields={cluster.overlay ? cluster.overlay.fields : null}
|
|
472
485
|
overlayRefs={cluster.overlay ? cluster.overlay.overlayRefs : null}
|
|
486
|
+
compact={compact}
|
|
473
487
|
/>
|
|
474
488
|
))}
|
|
475
489
|
{includedSchemaNodes.length > 0 && (
|
|
@@ -481,6 +495,7 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
481
495
|
edges={edges}
|
|
482
496
|
anchorIdForNode={anchorIdForNode}
|
|
483
497
|
isShared={true}
|
|
498
|
+
compact={compact}
|
|
484
499
|
/>
|
|
485
500
|
)}
|
|
486
501
|
{includedEnumNodes.length > 0 && (
|
|
@@ -492,6 +507,7 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
492
507
|
edges={edges}
|
|
493
508
|
anchorIdForNode={anchorIdForNode}
|
|
494
509
|
isShared={true}
|
|
510
|
+
compact={compact}
|
|
495
511
|
/>
|
|
496
512
|
)}
|
|
497
513
|
</div>
|
|
@@ -525,6 +541,17 @@ function App() {
|
|
|
525
541
|
const [overlayRefs, setOverlayRefs] = useState([]);
|
|
526
542
|
const [overlayMode, setOverlayMode] = useState('single');
|
|
527
543
|
const [overlayIndicatorIds, setOverlayIndicatorIds] = useState(new Set());
|
|
544
|
+
const [debugMode, setDebugMode] = useState(() => {
|
|
545
|
+
try { return localStorage.getItem('corum:debugMode') === 'true'; } catch { return false; }
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
function handleDebugMode() {
|
|
549
|
+
setDebugMode(prev => {
|
|
550
|
+
const next = !prev;
|
|
551
|
+
try { localStorage.setItem('corum:debugMode', String(next)); } catch {}
|
|
552
|
+
return next;
|
|
553
|
+
});
|
|
554
|
+
}
|
|
528
555
|
|
|
529
556
|
const refreshGraphData = useCallback((targetViewingRef = viewingRef) => {
|
|
530
557
|
setError(null);
|
|
@@ -601,9 +628,11 @@ function App() {
|
|
|
601
628
|
const activeSection = activeNodeId ? 'components' : (route.pathname.slice(1) || 'dashboard');
|
|
602
629
|
const navTree = buildNavTree(nodes, templates);
|
|
603
630
|
const showTree = activeSection === 'components' || activeNodeId;
|
|
604
|
-
const activeOverlayRefs =
|
|
631
|
+
const activeOverlayRefs = useMemo(() =>
|
|
632
|
+
overlayMode === 'single' ? [] :
|
|
605
633
|
overlayMode === 'consolidated' ? branches.filter(branch => branch.ref !== viewingRef).map(branch => branch.ref) :
|
|
606
|
-
overlayRefs
|
|
634
|
+
overlayRefs,
|
|
635
|
+
[overlayMode, branches, viewingRef, overlayRefs]);
|
|
607
636
|
|
|
608
637
|
useEffect(() => {
|
|
609
638
|
setOverlayRefs(prev => prev.filter(ref => ref !== viewingRef && branches.some(branch => branch.ref === ref)));
|
|
@@ -648,6 +677,7 @@ function App() {
|
|
|
648
677
|
refreshToken={refreshToken}
|
|
649
678
|
viewingRef={viewingRef}
|
|
650
679
|
overlayRefs={activeOverlayRefs}
|
|
680
|
+
compact={!debugMode}
|
|
651
681
|
/>
|
|
652
682
|
);
|
|
653
683
|
} else {
|
|
@@ -678,7 +708,7 @@ function App() {
|
|
|
678
708
|
/>
|
|
679
709
|
)}
|
|
680
710
|
<div className="main">
|
|
681
|
-
<NavRail activeSection={activeSection} onSection={handleSection} />
|
|
711
|
+
<NavRail activeSection={activeSection} onSection={handleSection} debugMode={debugMode} onDebugMode={handleDebugMode} />
|
|
682
712
|
{showTree && !loading && !error && (
|
|
683
713
|
<NavTree
|
|
684
714
|
navTree={navTree}
|
package/web/primitives.jsx
CHANGED
|
@@ -219,9 +219,23 @@ function clusterNodeId(nodeId) {
|
|
|
219
219
|
return nodeId.replace(/\.(fields|values)\.[^.]+$/, '');
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
function refName(ref) {
|
|
223
|
-
if (typeof ref === 'string')
|
|
224
|
-
|
|
222
|
+
function refName(ref, compact = false) {
|
|
223
|
+
if (typeof ref === 'string') {
|
|
224
|
+
const full = ref.replace(/^#\/(schemas|enums)\//, '');
|
|
225
|
+
if (compact) {
|
|
226
|
+
const dot = full.lastIndexOf('.');
|
|
227
|
+
return dot >= 0 ? full.slice(dot + 1) : full;
|
|
228
|
+
}
|
|
229
|
+
return full;
|
|
230
|
+
}
|
|
231
|
+
if (ref && typeof ref === 'object' && 'display' in ref) {
|
|
232
|
+
const display = String(ref.display);
|
|
233
|
+
if (compact) {
|
|
234
|
+
const dot = display.lastIndexOf('.');
|
|
235
|
+
return dot >= 0 ? display.slice(dot + 1) : display;
|
|
236
|
+
}
|
|
237
|
+
return display;
|
|
238
|
+
}
|
|
225
239
|
return String(ref);
|
|
226
240
|
}
|
|
227
241
|
|
|
@@ -240,12 +254,12 @@ function refLocalSchemaName(ref) {
|
|
|
240
254
|
return lastDot >= 0 ? ref.slice(lastDot + 1) : null;
|
|
241
255
|
}
|
|
242
256
|
|
|
243
|
-
function fieldType(properties) {
|
|
257
|
+
function fieldType(properties, compact = false) {
|
|
244
258
|
const c = properties?.collection;
|
|
245
259
|
const suffix = c === 'array' ? '[]' : c === 'map' ? '{}' : c === 'map-of-map' ? '{{}}' : c === 'map-of-array' ? '{[]}' : '';
|
|
246
260
|
if (properties?.type) return `${properties.type}${suffix}`;
|
|
247
261
|
const ref = properties?.['$ref'];
|
|
248
|
-
if (ref) return `${refName(ref)}${suffix}`;
|
|
262
|
+
if (ref) return `${refName(ref, compact)}${suffix}`;
|
|
249
263
|
return suffix ? `unknown${suffix}` : 'unknown';
|
|
250
264
|
}
|
|
251
265
|
|
|
@@ -259,10 +273,10 @@ function fieldCardinality(properties) {
|
|
|
259
273
|
return properties?.collection ?? 'one';
|
|
260
274
|
}
|
|
261
275
|
|
|
262
|
-
function fieldDetails(properties) {
|
|
276
|
+
function fieldDetails(properties, compact = false) {
|
|
263
277
|
const parts = [];
|
|
264
278
|
const ref = properties?.['$ref'];
|
|
265
|
-
if (ref) parts.push(`ref ${refName(ref)}`);
|
|
279
|
+
if (ref) parts.push(`ref ${refName(ref, compact)}`);
|
|
266
280
|
if (properties?.description) parts.push(properties.description);
|
|
267
281
|
return parts.length > 0 ? parts.join(' · ') : '-';
|
|
268
282
|
}
|
|
@@ -339,7 +353,8 @@ function buildSchemaModel(schemaNodes, allNodes) {
|
|
|
339
353
|
};
|
|
340
354
|
}
|
|
341
355
|
|
|
342
|
-
function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited = new Set(), edges = [], overlayFields, overlayRefs }) {
|
|
356
|
+
function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited = new Set(), edges = [], overlayFields, overlayRefs, compact = false }) {
|
|
357
|
+
const [collapsed, setCollapsed] = React.useState(new Set());
|
|
343
358
|
const fields = model.fieldsBySchema.get(schemaName) ?? [];
|
|
344
359
|
if (fields.length === 0) {
|
|
345
360
|
return (
|
|
@@ -374,12 +389,25 @@ function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited =
|
|
|
374
389
|
&& e.type !== 'has-value',
|
|
375
390
|
);
|
|
376
391
|
|
|
392
|
+
const isCollapsed = collapsed.has(field.id);
|
|
393
|
+
const typeDisplay = fieldType(field.properties, compact);
|
|
394
|
+
const typeFull = compact ? fieldType(field.properties, false) : null;
|
|
377
395
|
return (
|
|
378
396
|
<React.Fragment key={field.id}>
|
|
379
397
|
<div className={`field-row${depth > 0 ? ' nested' : ''}`} style={{ '--field-depth': depth }}>
|
|
380
|
-
<div
|
|
381
|
-
|
|
382
|
-
|
|
398
|
+
<div
|
|
399
|
+
className="gutter"
|
|
400
|
+
style={canExpand ? { cursor: 'pointer' } : undefined}
|
|
401
|
+
onClick={canExpand ? () => setCollapsed(prev => {
|
|
402
|
+
const next = new Set(prev);
|
|
403
|
+
next.has(field.id) ? next.delete(field.id) : next.add(field.id);
|
|
404
|
+
return next;
|
|
405
|
+
}) : undefined}
|
|
406
|
+
>
|
|
407
|
+
{canExpand && <Icon name={isCollapsed ? 'caret-right' : 'caret-down'} size={11} />}
|
|
408
|
+
</div>
|
|
409
|
+
<div className="name">{compact ? name : `${prefix}${name}`}</div>
|
|
410
|
+
<div className="type" title={typeFull !== typeDisplay ? typeFull : undefined}>{typeDisplay}</div>
|
|
383
411
|
<div className="cardinality">{fieldCardinality(field.properties)}</div>
|
|
384
412
|
<div className="req">{fieldRequirement(field.properties)}</div>
|
|
385
413
|
<div className="state"><StateTag state={field.state} /></div>
|
|
@@ -400,10 +428,10 @@ function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited =
|
|
|
400
428
|
</React.Fragment>
|
|
401
429
|
);
|
|
402
430
|
})
|
|
403
|
-
: fieldDetails(field.properties)}
|
|
431
|
+
: fieldDetails(field.properties, compact)}
|
|
404
432
|
</div>
|
|
405
433
|
</div>
|
|
406
|
-
{canExpand && (
|
|
434
|
+
{canExpand && !isCollapsed && (
|
|
407
435
|
<>
|
|
408
436
|
<SchemaFieldRows
|
|
409
437
|
schemaName={localRef}
|
|
@@ -414,9 +442,10 @@ function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited =
|
|
|
414
442
|
edges={edges}
|
|
415
443
|
overlayFields={overlayFields}
|
|
416
444
|
overlayRefs={overlayRefs}
|
|
445
|
+
compact={compact}
|
|
417
446
|
/>
|
|
418
447
|
{childGhostFields.length > 0 && (
|
|
419
|
-
<GhostFieldRows fields={childGhostFields} overlayRefs={overlayRefs} prefix={childPrefix} depth={depth + 1} />
|
|
448
|
+
<GhostFieldRows fields={childGhostFields} overlayRefs={overlayRefs} prefix={childPrefix} depth={depth + 1} compact={compact} />
|
|
420
449
|
)}
|
|
421
450
|
</>
|
|
422
451
|
)}
|
|
@@ -440,15 +469,15 @@ function overlayFieldsForSchema(overlayFields, schemaNodeId) {
|
|
|
440
469
|
return overlayFields.filter(field => field.id.startsWith(prefix));
|
|
441
470
|
}
|
|
442
471
|
|
|
443
|
-
function GhostFieldRows({ fields, overlayRefs, prefix = '', depth = 0 }) {
|
|
472
|
+
function GhostFieldRows({ fields, overlayRefs, prefix = '', depth = 0, compact = false }) {
|
|
444
473
|
return (
|
|
445
474
|
<>
|
|
446
475
|
{fields.map(field => {
|
|
447
476
|
const isConflict = field.ghostState === 'ghost-conflict' || field.ghostState === 'local-modified';
|
|
448
477
|
const refIndex = overlayRefs ? overlayRefs.indexOf(field.sourceRef) : 0;
|
|
449
478
|
const stripeClass = isConflict ? 'overlay-conflict' : ghostStripeClass(Math.max(0, refIndex));
|
|
450
|
-
const name = prefix +
|
|
451
|
-
const type = field.node.properties?.type || (field.node.properties?.['$ref'] ?
|
|
479
|
+
const name = compact ? fieldLocalName(field.id) : prefix + fieldLocalName(field.id);
|
|
480
|
+
const type = field.node.properties?.type || (field.node.properties?.['$ref'] ? refName(field.node.properties['$ref'], compact) : '-');
|
|
452
481
|
return (
|
|
453
482
|
<div
|
|
454
483
|
key={field.id}
|
|
@@ -502,7 +531,7 @@ function OverlayLegend({ overlayRefs }) {
|
|
|
502
531
|
);
|
|
503
532
|
}
|
|
504
533
|
|
|
505
|
-
function SchemaCard({ title, nodes, allNodes, edges, anchorIdForNode, overlayFields, overlayRefs, isShared }) {
|
|
534
|
+
function SchemaCard({ title, nodes, allNodes, edges, anchorIdForNode, overlayFields, overlayRefs, isShared, compact = false }) {
|
|
506
535
|
if (!nodes || nodes.length === 0) return null;
|
|
507
536
|
|
|
508
537
|
if (title === 'EnumDefinition') {
|
|
@@ -593,9 +622,10 @@ function SchemaCard({ title, nodes, allNodes, edges, anchorIdForNode, overlayFie
|
|
|
593
622
|
edges={edges ?? []}
|
|
594
623
|
overlayFields={overlayFields}
|
|
595
624
|
overlayRefs={overlayRefs}
|
|
625
|
+
compact={compact}
|
|
596
626
|
/>
|
|
597
627
|
{ghostFields.length > 0 && (
|
|
598
|
-
<GhostFieldRows fields={ghostFields} overlayRefs={overlayRefs} />
|
|
628
|
+
<GhostFieldRows fields={ghostFields} overlayRefs={overlayRefs} compact={compact} />
|
|
599
629
|
)}
|
|
600
630
|
</div>
|
|
601
631
|
);
|