@atolis-hq/corum 0.1.15 → 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 +41 -7
- package/web/primitives.jsx +83 -24
- package/web/style.css +8 -0
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
|
|
|
@@ -451,7 +464,11 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
451
464
|
<div className="card">
|
|
452
465
|
<div className="card-head">Properties</div>
|
|
453
466
|
<div className="card-body">
|
|
454
|
-
<PropertiesTable
|
|
467
|
+
<PropertiesTable
|
|
468
|
+
properties={root.properties}
|
|
469
|
+
onNavigate={handlePropertyNavigate}
|
|
470
|
+
propertyHints={template?.ui?.propertyDisplay ?? {}}
|
|
471
|
+
/>
|
|
455
472
|
</div>
|
|
456
473
|
</div>
|
|
457
474
|
)}
|
|
@@ -466,6 +483,7 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
466
483
|
anchorIdForNode={anchorIdForNode}
|
|
467
484
|
overlayFields={cluster.overlay ? cluster.overlay.fields : null}
|
|
468
485
|
overlayRefs={cluster.overlay ? cluster.overlay.overlayRefs : null}
|
|
486
|
+
compact={compact}
|
|
469
487
|
/>
|
|
470
488
|
))}
|
|
471
489
|
{includedSchemaNodes.length > 0 && (
|
|
@@ -477,6 +495,7 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
477
495
|
edges={edges}
|
|
478
496
|
anchorIdForNode={anchorIdForNode}
|
|
479
497
|
isShared={true}
|
|
498
|
+
compact={compact}
|
|
480
499
|
/>
|
|
481
500
|
)}
|
|
482
501
|
{includedEnumNodes.length > 0 && (
|
|
@@ -488,6 +507,7 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
488
507
|
edges={edges}
|
|
489
508
|
anchorIdForNode={anchorIdForNode}
|
|
490
509
|
isShared={true}
|
|
510
|
+
compact={compact}
|
|
491
511
|
/>
|
|
492
512
|
)}
|
|
493
513
|
</div>
|
|
@@ -521,6 +541,17 @@ function App() {
|
|
|
521
541
|
const [overlayRefs, setOverlayRefs] = useState([]);
|
|
522
542
|
const [overlayMode, setOverlayMode] = useState('single');
|
|
523
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
|
+
}
|
|
524
555
|
|
|
525
556
|
const refreshGraphData = useCallback((targetViewingRef = viewingRef) => {
|
|
526
557
|
setError(null);
|
|
@@ -597,9 +628,11 @@ function App() {
|
|
|
597
628
|
const activeSection = activeNodeId ? 'components' : (route.pathname.slice(1) || 'dashboard');
|
|
598
629
|
const navTree = buildNavTree(nodes, templates);
|
|
599
630
|
const showTree = activeSection === 'components' || activeNodeId;
|
|
600
|
-
const activeOverlayRefs =
|
|
631
|
+
const activeOverlayRefs = useMemo(() =>
|
|
632
|
+
overlayMode === 'single' ? [] :
|
|
601
633
|
overlayMode === 'consolidated' ? branches.filter(branch => branch.ref !== viewingRef).map(branch => branch.ref) :
|
|
602
|
-
overlayRefs
|
|
634
|
+
overlayRefs,
|
|
635
|
+
[overlayMode, branches, viewingRef, overlayRefs]);
|
|
603
636
|
|
|
604
637
|
useEffect(() => {
|
|
605
638
|
setOverlayRefs(prev => prev.filter(ref => ref !== viewingRef && branches.some(branch => branch.ref === ref)));
|
|
@@ -644,6 +677,7 @@ function App() {
|
|
|
644
677
|
refreshToken={refreshToken}
|
|
645
678
|
viewingRef={viewingRef}
|
|
646
679
|
overlayRefs={activeOverlayRefs}
|
|
680
|
+
compact={!debugMode}
|
|
647
681
|
/>
|
|
648
682
|
);
|
|
649
683
|
} else {
|
|
@@ -674,7 +708,7 @@ function App() {
|
|
|
674
708
|
/>
|
|
675
709
|
)}
|
|
676
710
|
<div className="main">
|
|
677
|
-
<NavRail activeSection={activeSection} onSection={handleSection} />
|
|
711
|
+
<NavRail activeSection={activeSection} onSection={handleSection} debugMode={debugMode} onDebugMode={handleDebugMode} />
|
|
678
712
|
{showTree && !loading && !error && (
|
|
679
713
|
<NavTree
|
|
680
714
|
navTree={navTree}
|
package/web/primitives.jsx
CHANGED
|
@@ -74,10 +74,28 @@ function PropertyValue({ value, onNavigate }) {
|
|
|
74
74
|
return <span>{String(value)}</span>;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function
|
|
77
|
+
function InlineObjectValue({ value }) {
|
|
78
|
+
if (!value || typeof value !== 'object') return <PropertyValue value={value} />;
|
|
79
|
+
const parts = Object.entries(value).filter(([, v]) => v !== null && v !== undefined);
|
|
80
|
+
if (parts.length === 0) return <span className="prop-empty">-</span>;
|
|
81
|
+
return (
|
|
82
|
+
<span>
|
|
83
|
+
{parts.map(([k, v], i) => (
|
|
84
|
+
<React.Fragment key={k}>
|
|
85
|
+
{i > 0 && <span style={{ margin: '0 6px', opacity: 0.4 }}>|</span>}
|
|
86
|
+
<span className="prop-key-label prop-key-label--inline mono">{k}:</span>
|
|
87
|
+
{' '}{String(v)}
|
|
88
|
+
</React.Fragment>
|
|
89
|
+
))}
|
|
90
|
+
</span>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function buildPropertyRows(entries, onNavigate, depth = 0, parentPath = '', propertyHints = {}) {
|
|
78
95
|
return entries.flatMap(([key, value], index) => {
|
|
79
96
|
const rowPath = parentPath ? `${parentPath}.${key}` : key;
|
|
80
97
|
const rowKey = `${rowPath}:${index}`;
|
|
98
|
+
const hint = depth === 0 ? propertyHints[key] : null;
|
|
81
99
|
|
|
82
100
|
if (Array.isArray(value)) {
|
|
83
101
|
const rows = [{
|
|
@@ -96,7 +114,7 @@ function buildPropertyRows(entries, onNavigate, depth = 0, parentPath = '') {
|
|
|
96
114
|
depth: depth + 1,
|
|
97
115
|
value: <span className="prop-empty">-</span>,
|
|
98
116
|
});
|
|
99
|
-
rows.push(...buildPropertyRows(Object.entries(item), onNavigate, depth + 2, itemPath));
|
|
117
|
+
rows.push(...buildPropertyRows(Object.entries(item), onNavigate, depth + 2, itemPath, propertyHints));
|
|
100
118
|
} else {
|
|
101
119
|
rows.push({
|
|
102
120
|
key: `${itemPath}:value`,
|
|
@@ -111,6 +129,17 @@ function buildPropertyRows(entries, onNavigate, depth = 0, parentPath = '') {
|
|
|
111
129
|
}
|
|
112
130
|
|
|
113
131
|
if (value && typeof value === 'object' && !('display' in value)) {
|
|
132
|
+
if (hint?.as === 'inline') {
|
|
133
|
+
return [
|
|
134
|
+
{ key: rowKey, label: key, depth, value: <span className="prop-empty">-</span> },
|
|
135
|
+
...Object.entries(value).map(([childKey, childValue], childIndex) => ({
|
|
136
|
+
key: `${rowPath}.${childKey}:${childIndex}`,
|
|
137
|
+
label: childKey,
|
|
138
|
+
depth: depth + 1,
|
|
139
|
+
value: <InlineObjectValue value={childValue} />,
|
|
140
|
+
})),
|
|
141
|
+
];
|
|
142
|
+
}
|
|
114
143
|
return [
|
|
115
144
|
{
|
|
116
145
|
key: rowKey,
|
|
@@ -118,7 +147,7 @@ function buildPropertyRows(entries, onNavigate, depth = 0, parentPath = '') {
|
|
|
118
147
|
depth,
|
|
119
148
|
value: <span className="prop-empty">-</span>,
|
|
120
149
|
},
|
|
121
|
-
...buildPropertyRows(Object.entries(value), onNavigate, depth + 1, rowPath),
|
|
150
|
+
...buildPropertyRows(Object.entries(value), onNavigate, depth + 1, rowPath, propertyHints),
|
|
122
151
|
];
|
|
123
152
|
}
|
|
124
153
|
|
|
@@ -131,9 +160,9 @@ function buildPropertyRows(entries, onNavigate, depth = 0, parentPath = '') {
|
|
|
131
160
|
});
|
|
132
161
|
}
|
|
133
162
|
|
|
134
|
-
function PropertiesTable({ properties, onNavigate }) {
|
|
163
|
+
function PropertiesTable({ properties, onNavigate, propertyHints = {} }) {
|
|
135
164
|
const entries = Object.entries(properties ?? {});
|
|
136
|
-
const rows = buildPropertyRows(entries, onNavigate);
|
|
165
|
+
const rows = buildPropertyRows(entries, onNavigate, 0, '', propertyHints);
|
|
137
166
|
if (entries.length === 0) {
|
|
138
167
|
return <p className="label-sm" style={{ padding: '10px 14px' }}>No properties.</p>;
|
|
139
168
|
}
|
|
@@ -190,9 +219,23 @@ function clusterNodeId(nodeId) {
|
|
|
190
219
|
return nodeId.replace(/\.(fields|values)\.[^.]+$/, '');
|
|
191
220
|
}
|
|
192
221
|
|
|
193
|
-
function refName(ref) {
|
|
194
|
-
if (typeof ref === 'string')
|
|
195
|
-
|
|
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
|
+
}
|
|
196
239
|
return String(ref);
|
|
197
240
|
}
|
|
198
241
|
|
|
@@ -211,12 +254,12 @@ function refLocalSchemaName(ref) {
|
|
|
211
254
|
return lastDot >= 0 ? ref.slice(lastDot + 1) : null;
|
|
212
255
|
}
|
|
213
256
|
|
|
214
|
-
function fieldType(properties) {
|
|
257
|
+
function fieldType(properties, compact = false) {
|
|
215
258
|
const c = properties?.collection;
|
|
216
259
|
const suffix = c === 'array' ? '[]' : c === 'map' ? '{}' : c === 'map-of-map' ? '{{}}' : c === 'map-of-array' ? '{[]}' : '';
|
|
217
260
|
if (properties?.type) return `${properties.type}${suffix}`;
|
|
218
261
|
const ref = properties?.['$ref'];
|
|
219
|
-
if (ref) return `${refName(ref)}${suffix}`;
|
|
262
|
+
if (ref) return `${refName(ref, compact)}${suffix}`;
|
|
220
263
|
return suffix ? `unknown${suffix}` : 'unknown';
|
|
221
264
|
}
|
|
222
265
|
|
|
@@ -230,10 +273,10 @@ function fieldCardinality(properties) {
|
|
|
230
273
|
return properties?.collection ?? 'one';
|
|
231
274
|
}
|
|
232
275
|
|
|
233
|
-
function fieldDetails(properties) {
|
|
276
|
+
function fieldDetails(properties, compact = false) {
|
|
234
277
|
const parts = [];
|
|
235
278
|
const ref = properties?.['$ref'];
|
|
236
|
-
if (ref) parts.push(`ref ${refName(ref)}`);
|
|
279
|
+
if (ref) parts.push(`ref ${refName(ref, compact)}`);
|
|
237
280
|
if (properties?.description) parts.push(properties.description);
|
|
238
281
|
return parts.length > 0 ? parts.join(' · ') : '-';
|
|
239
282
|
}
|
|
@@ -310,7 +353,8 @@ function buildSchemaModel(schemaNodes, allNodes) {
|
|
|
310
353
|
};
|
|
311
354
|
}
|
|
312
355
|
|
|
313
|
-
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());
|
|
314
358
|
const fields = model.fieldsBySchema.get(schemaName) ?? [];
|
|
315
359
|
if (fields.length === 0) {
|
|
316
360
|
return (
|
|
@@ -345,12 +389,25 @@ function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited =
|
|
|
345
389
|
&& e.type !== 'has-value',
|
|
346
390
|
);
|
|
347
391
|
|
|
392
|
+
const isCollapsed = collapsed.has(field.id);
|
|
393
|
+
const typeDisplay = fieldType(field.properties, compact);
|
|
394
|
+
const typeFull = compact ? fieldType(field.properties, false) : null;
|
|
348
395
|
return (
|
|
349
396
|
<React.Fragment key={field.id}>
|
|
350
397
|
<div className={`field-row${depth > 0 ? ' nested' : ''}`} style={{ '--field-depth': depth }}>
|
|
351
|
-
<div
|
|
352
|
-
|
|
353
|
-
|
|
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>
|
|
354
411
|
<div className="cardinality">{fieldCardinality(field.properties)}</div>
|
|
355
412
|
<div className="req">{fieldRequirement(field.properties)}</div>
|
|
356
413
|
<div className="state"><StateTag state={field.state} /></div>
|
|
@@ -371,10 +428,10 @@ function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited =
|
|
|
371
428
|
</React.Fragment>
|
|
372
429
|
);
|
|
373
430
|
})
|
|
374
|
-
: fieldDetails(field.properties)}
|
|
431
|
+
: fieldDetails(field.properties, compact)}
|
|
375
432
|
</div>
|
|
376
433
|
</div>
|
|
377
|
-
{canExpand && (
|
|
434
|
+
{canExpand && !isCollapsed && (
|
|
378
435
|
<>
|
|
379
436
|
<SchemaFieldRows
|
|
380
437
|
schemaName={localRef}
|
|
@@ -385,9 +442,10 @@ function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited =
|
|
|
385
442
|
edges={edges}
|
|
386
443
|
overlayFields={overlayFields}
|
|
387
444
|
overlayRefs={overlayRefs}
|
|
445
|
+
compact={compact}
|
|
388
446
|
/>
|
|
389
447
|
{childGhostFields.length > 0 && (
|
|
390
|
-
<GhostFieldRows fields={childGhostFields} overlayRefs={overlayRefs} prefix={childPrefix} depth={depth + 1} />
|
|
448
|
+
<GhostFieldRows fields={childGhostFields} overlayRefs={overlayRefs} prefix={childPrefix} depth={depth + 1} compact={compact} />
|
|
391
449
|
)}
|
|
392
450
|
</>
|
|
393
451
|
)}
|
|
@@ -411,15 +469,15 @@ function overlayFieldsForSchema(overlayFields, schemaNodeId) {
|
|
|
411
469
|
return overlayFields.filter(field => field.id.startsWith(prefix));
|
|
412
470
|
}
|
|
413
471
|
|
|
414
|
-
function GhostFieldRows({ fields, overlayRefs, prefix = '', depth = 0 }) {
|
|
472
|
+
function GhostFieldRows({ fields, overlayRefs, prefix = '', depth = 0, compact = false }) {
|
|
415
473
|
return (
|
|
416
474
|
<>
|
|
417
475
|
{fields.map(field => {
|
|
418
476
|
const isConflict = field.ghostState === 'ghost-conflict' || field.ghostState === 'local-modified';
|
|
419
477
|
const refIndex = overlayRefs ? overlayRefs.indexOf(field.sourceRef) : 0;
|
|
420
478
|
const stripeClass = isConflict ? 'overlay-conflict' : ghostStripeClass(Math.max(0, refIndex));
|
|
421
|
-
const name = prefix +
|
|
422
|
-
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) : '-');
|
|
423
481
|
return (
|
|
424
482
|
<div
|
|
425
483
|
key={field.id}
|
|
@@ -473,7 +531,7 @@ function OverlayLegend({ overlayRefs }) {
|
|
|
473
531
|
);
|
|
474
532
|
}
|
|
475
533
|
|
|
476
|
-
function SchemaCard({ title, nodes, allNodes, edges, anchorIdForNode, overlayFields, overlayRefs, isShared }) {
|
|
534
|
+
function SchemaCard({ title, nodes, allNodes, edges, anchorIdForNode, overlayFields, overlayRefs, isShared, compact = false }) {
|
|
477
535
|
if (!nodes || nodes.length === 0) return null;
|
|
478
536
|
|
|
479
537
|
if (title === 'EnumDefinition') {
|
|
@@ -564,9 +622,10 @@ function SchemaCard({ title, nodes, allNodes, edges, anchorIdForNode, overlayFie
|
|
|
564
622
|
edges={edges ?? []}
|
|
565
623
|
overlayFields={overlayFields}
|
|
566
624
|
overlayRefs={overlayRefs}
|
|
625
|
+
compact={compact}
|
|
567
626
|
/>
|
|
568
627
|
{ghostFields.length > 0 && (
|
|
569
|
-
<GhostFieldRows fields={ghostFields} overlayRefs={overlayRefs} />
|
|
628
|
+
<GhostFieldRows fields={ghostFields} overlayRefs={overlayRefs} compact={compact} />
|
|
570
629
|
)}
|
|
571
630
|
</div>
|
|
572
631
|
);
|
package/web/style.css
CHANGED
|
@@ -352,6 +352,14 @@ button {
|
|
|
352
352
|
padding-left: calc(var(--prop-depth, 0) * 24px);
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
+
.prop-key-label--inline {
|
|
356
|
+
display: inline;
|
|
357
|
+
padding-left: 0;
|
|
358
|
+
color: var(--ink-3);
|
|
359
|
+
font-size: 11px;
|
|
360
|
+
font-weight: 600;
|
|
361
|
+
}
|
|
362
|
+
|
|
355
363
|
.node-ref-link {
|
|
356
364
|
cursor: pointer;
|
|
357
365
|
color: var(--accent);
|