@atolis-hq/corum 0.1.14 → 0.1.16
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/openapi/mapper.js +52 -24
- package/package.json +1 -1
- package/web/app.jsx +5 -1
- package/web/primitives.jsx +40 -11
- package/web/style.css +8 -0
|
@@ -229,18 +229,16 @@ function extractParameters(pathItem, operation, packConfig, specPath, diagnostic
|
|
|
229
229
|
if (!schema)
|
|
230
230
|
continue;
|
|
231
231
|
let type;
|
|
232
|
-
let
|
|
232
|
+
let collection;
|
|
233
233
|
if (schema.type === 'array') {
|
|
234
|
-
|
|
234
|
+
collection = 'array';
|
|
235
235
|
const items = schema.items;
|
|
236
236
|
type = deriveScalarType(items?.type ?? 'string', items?.format, packConfig.scalarTypes) ?? 'string';
|
|
237
237
|
}
|
|
238
238
|
else if (schema.enum) {
|
|
239
|
-
cardinality = 'one';
|
|
240
239
|
type = 'string';
|
|
241
240
|
}
|
|
242
241
|
else {
|
|
243
|
-
cardinality = 'one';
|
|
244
242
|
const derived = deriveScalarType(schema.type ?? 'string', schema.format, packConfig.scalarTypes);
|
|
245
243
|
if (!derived) {
|
|
246
244
|
diagnostics.push({ severity: 'warning', file: specPath, message: `Unknown type for parameter ${name}: ${schema.type}/${schema.format}, defaulting to string` });
|
|
@@ -254,7 +252,7 @@ function extractParameters(pathItem, operation, packConfig, specPath, diagnostic
|
|
|
254
252
|
location: param.in,
|
|
255
253
|
type,
|
|
256
254
|
required: param.required ?? false,
|
|
257
|
-
|
|
255
|
+
...(collection ? { collection } : {}),
|
|
258
256
|
};
|
|
259
257
|
}
|
|
260
258
|
return Object.keys(parameters).length > 0 ? parameters : undefined;
|
|
@@ -308,10 +306,10 @@ function createInlineSchema(schema, name, parentId, section, rootId, packConfig,
|
|
|
308
306
|
emitFields(schema, schemaId, 'fields', rootId, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas);
|
|
309
307
|
return localRef;
|
|
310
308
|
}
|
|
311
|
-
function resolveFieldRef(schemaName,
|
|
312
|
-
const extra = { nullable: !required
|
|
313
|
-
if (
|
|
314
|
-
extra.
|
|
309
|
+
function resolveFieldRef(schemaName, collection, required, rootId, readsSource, refSchema, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas) {
|
|
310
|
+
const extra = { nullable: !required };
|
|
311
|
+
if (collection !== 'one')
|
|
312
|
+
extra.collection = collection;
|
|
315
313
|
const globalId = sharedSchemas.get(schemaName);
|
|
316
314
|
if (globalId) {
|
|
317
315
|
emitReadsEdge(readsSource, globalId, edges);
|
|
@@ -336,26 +334,26 @@ function emitFields(schema, parentId, section, rootId, packConfig, specPath, nod
|
|
|
336
334
|
const fieldNode = makeNode(packConfig.constructs.schemaProperty?.template ?? 'Field', component, specPath, fieldId);
|
|
337
335
|
const required = Array.isArray(schema.required) && schema.required.includes(fieldName);
|
|
338
336
|
if (isRefSchema(fieldSchema)) {
|
|
339
|
-
fieldNode.properties = resolveFieldRef(refName(fieldSchema.$ref), 'one',
|
|
337
|
+
fieldNode.properties = resolveFieldRef(refName(fieldSchema.$ref), 'one', required, rootId, readsSource, fieldSchema, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas);
|
|
340
338
|
}
|
|
341
339
|
else {
|
|
342
340
|
const fs = fieldSchema;
|
|
343
341
|
if (fs.enum && fs.type !== 'object') {
|
|
344
342
|
const enumRef = sharedSchemas.get(fieldName);
|
|
345
|
-
fieldNode.properties = { ...(enumRef ? { $ref: enumRef } : { type: 'string' }), nullable: !required
|
|
343
|
+
fieldNode.properties = { ...(enumRef ? { $ref: enumRef } : { type: 'string' }), nullable: !required };
|
|
346
344
|
}
|
|
347
345
|
else if (fs.type === 'array') {
|
|
348
346
|
const rawItems = fs.items;
|
|
349
347
|
const items = rawItems ? resolveAllOfRef(rawItems) : undefined;
|
|
350
348
|
if (!items) {
|
|
351
|
-
fieldNode.properties = { type: 'string', nullable: !required,
|
|
349
|
+
fieldNode.properties = { type: 'string', nullable: !required, collection: 'array' };
|
|
352
350
|
}
|
|
353
351
|
else if (isRefSchema(items)) {
|
|
354
|
-
fieldNode.properties = resolveFieldRef(refName(items.$ref), '
|
|
352
|
+
fieldNode.properties = resolveFieldRef(refName(items.$ref), 'array', required, rootId, readsSource, items, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas);
|
|
355
353
|
}
|
|
356
354
|
else {
|
|
357
355
|
const itemType = deriveScalarType(items.type ?? 'string', items.format, packConfig.scalarTypes);
|
|
358
|
-
fieldNode.properties = { type: itemType ?? 'string', nullable: !required,
|
|
356
|
+
fieldNode.properties = { type: itemType ?? 'string', nullable: !required, collection: 'array' };
|
|
359
357
|
}
|
|
360
358
|
}
|
|
361
359
|
else if (fs.type === 'object' && fs.properties) {
|
|
@@ -363,34 +361,64 @@ function emitFields(schema, parentId, section, rootId, packConfig, specPath, nod
|
|
|
363
361
|
if (rootId) {
|
|
364
362
|
const localRef = emitSchemaNode(fs, fieldName, rootId, 'schemas', rootId, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas);
|
|
365
363
|
fieldNode.properties = localRef
|
|
366
|
-
? { $ref: localRef, nullable: !required
|
|
367
|
-
: { type: 'string', nullable: !required
|
|
364
|
+
? { $ref: localRef, nullable: !required }
|
|
365
|
+
: { type: 'string', nullable: !required };
|
|
368
366
|
}
|
|
369
367
|
else {
|
|
370
368
|
diagnostics.push({ severity: 'warning', file: specPath, message: `Inline object for field ${fieldId} has no endpoint context; treating as string` });
|
|
371
|
-
fieldNode.properties = { type: 'string', nullable: !required
|
|
369
|
+
fieldNode.properties = { type: 'string', nullable: !required };
|
|
372
370
|
}
|
|
373
371
|
}
|
|
374
372
|
else if (fs.type === 'object' && fs.additionalProperties) {
|
|
375
373
|
// Map/dictionary: keyed collection
|
|
376
374
|
const addlRaw = fs.additionalProperties;
|
|
377
375
|
if (typeof addlRaw === 'boolean') {
|
|
378
|
-
fieldNode.properties = { type: 'string', nullable: !required,
|
|
376
|
+
fieldNode.properties = { type: 'string', nullable: !required, collection: 'map' };
|
|
379
377
|
}
|
|
380
378
|
else {
|
|
381
379
|
const addlSchema = resolveAllOfRef(addlRaw);
|
|
382
380
|
if (isRefSchema(addlSchema)) {
|
|
383
|
-
fieldNode.properties = resolveFieldRef(refName(addlSchema.$ref), '
|
|
381
|
+
fieldNode.properties = resolveFieldRef(refName(addlSchema.$ref), 'map', required, rootId, readsSource, addlSchema, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas);
|
|
384
382
|
}
|
|
385
383
|
else {
|
|
386
384
|
const addlObj = addlSchema;
|
|
387
385
|
if (addlObj.type === 'object') {
|
|
388
|
-
|
|
389
|
-
|
|
386
|
+
const innerAddl = addlObj.additionalProperties;
|
|
387
|
+
if (!innerAddl || typeof innerAddl === 'boolean') {
|
|
388
|
+
fieldNode.properties = { type: 'string', nullable: !required, collection: 'map-of-map' };
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
const innerSchema = resolveAllOfRef(innerAddl);
|
|
392
|
+
if (isRefSchema(innerSchema)) {
|
|
393
|
+
fieldNode.properties = resolveFieldRef(refName(innerSchema.$ref), 'map-of-map', required, rootId, readsSource, innerSchema, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas);
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
const inner = innerSchema;
|
|
397
|
+
const scalarType = deriveScalarType(inner.type ?? 'string', inner.format, packConfig.scalarTypes);
|
|
398
|
+
if (scalarType) {
|
|
399
|
+
fieldNode.properties = { type: scalarType, nullable: !required, collection: 'map-of-map' };
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
diagnostics.push({ severity: 'warning', file: specPath, message: `[WARN] Double-nested map for field ${fieldId}; inner value type not representable, using string` });
|
|
403
|
+
fieldNode.properties = { type: 'string', nullable: !required, collection: 'map-of-map' };
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
else if (addlObj.type === 'array') {
|
|
409
|
+
const rawItems = addlObj.items;
|
|
410
|
+
const items = rawItems ? resolveAllOfRef(rawItems) : undefined;
|
|
411
|
+
if (items && isRefSchema(items)) {
|
|
412
|
+
fieldNode.properties = resolveFieldRef(refName(items.$ref), 'map-of-array', required, rootId, readsSource, items, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas, sourceSchemas, localSchemas);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
const scalarType = items ? deriveScalarType(items.type ?? 'string', items.format, packConfig.scalarTypes) : undefined;
|
|
416
|
+
fieldNode.properties = { type: scalarType ?? 'string', nullable: !required, collection: 'map-of-array' };
|
|
417
|
+
}
|
|
390
418
|
}
|
|
391
419
|
else {
|
|
392
420
|
const scalarType = deriveScalarType(addlObj.type ?? 'string', addlObj.format, packConfig.scalarTypes);
|
|
393
|
-
fieldNode.properties = { type: scalarType ?? 'string', nullable: !required,
|
|
421
|
+
fieldNode.properties = { type: scalarType ?? 'string', nullable: !required, collection: 'map' };
|
|
394
422
|
}
|
|
395
423
|
}
|
|
396
424
|
}
|
|
@@ -398,11 +426,11 @@ function emitFields(schema, parentId, section, rootId, packConfig, specPath, nod
|
|
|
398
426
|
else {
|
|
399
427
|
const scalarType = deriveScalarType(fs.type ?? 'string', fs.format, packConfig.scalarTypes);
|
|
400
428
|
if (scalarType) {
|
|
401
|
-
fieldNode.properties = { type: scalarType, nullable: !required
|
|
429
|
+
fieldNode.properties = { type: scalarType, nullable: !required };
|
|
402
430
|
}
|
|
403
431
|
else {
|
|
404
432
|
diagnostics.push({ severity: 'warning', file: specPath, message: `Unknown type for field ${fieldId}: ${fs.type}/${fs.format}` });
|
|
405
|
-
fieldNode.properties = { type: 'string', nullable: !required
|
|
433
|
+
fieldNode.properties = { type: 'string', nullable: !required };
|
|
406
434
|
}
|
|
407
435
|
}
|
|
408
436
|
}
|
package/package.json
CHANGED
package/web/app.jsx
CHANGED
|
@@ -451,7 +451,11 @@ function NodePage({ nodeId, templates, onNavigate, refreshToken, viewingRef, ove
|
|
|
451
451
|
<div className="card">
|
|
452
452
|
<div className="card-head">Properties</div>
|
|
453
453
|
<div className="card-body">
|
|
454
|
-
<PropertiesTable
|
|
454
|
+
<PropertiesTable
|
|
455
|
+
properties={root.properties}
|
|
456
|
+
onNavigate={handlePropertyNavigate}
|
|
457
|
+
propertyHints={template?.ui?.propertyDisplay ?? {}}
|
|
458
|
+
/>
|
|
455
459
|
</div>
|
|
456
460
|
</div>
|
|
457
461
|
)}
|
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
|
}
|
|
@@ -212,9 +241,8 @@ function refLocalSchemaName(ref) {
|
|
|
212
241
|
}
|
|
213
242
|
|
|
214
243
|
function fieldType(properties) {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
: '';
|
|
244
|
+
const c = properties?.collection;
|
|
245
|
+
const suffix = c === 'array' ? '[]' : c === 'map' ? '{}' : c === 'map-of-map' ? '{{}}' : c === 'map-of-array' ? '{[]}' : '';
|
|
218
246
|
if (properties?.type) return `${properties.type}${suffix}`;
|
|
219
247
|
const ref = properties?.['$ref'];
|
|
220
248
|
if (ref) return `${refName(ref)}${suffix}`;
|
|
@@ -228,7 +256,7 @@ function fieldRequirement(properties) {
|
|
|
228
256
|
}
|
|
229
257
|
|
|
230
258
|
function fieldCardinality(properties) {
|
|
231
|
-
return properties?.
|
|
259
|
+
return properties?.collection ?? 'one';
|
|
232
260
|
}
|
|
233
261
|
|
|
234
262
|
function fieldDetails(properties) {
|
|
@@ -336,7 +364,8 @@ function SchemaFieldRows({ schemaName, model, prefix = '', depth = 0, visited =
|
|
|
336
364
|
const canExpand = localRef !== null && model.schemasByName.has(localRef) && !visited.has(localRef);
|
|
337
365
|
const childSchemaNode = canExpand ? model.schemasByName.get(localRef) : null;
|
|
338
366
|
const childGhostFields = childSchemaNode ? overlayFieldsForSchema(overlayFields, childSchemaNode.id) : [];
|
|
339
|
-
const
|
|
367
|
+
const c = field.properties?.collection;
|
|
368
|
+
const childPrefix = `${prefix}${name}${c === 'map-of-map' || c === 'map-of-array' ? '[][].' : c === 'array' || c === 'map' ? '[].' : '.'}`;
|
|
340
369
|
const nextVisited = new Set(visited);
|
|
341
370
|
nextVisited.add(schemaName);
|
|
342
371
|
const links = edges.filter(e =>
|
|
@@ -552,7 +581,7 @@ function SchemaCard({ title, nodes, allNodes, edges, anchorIdForNode, overlayFie
|
|
|
552
581
|
<div />
|
|
553
582
|
<div className="label-xs">Name</div>
|
|
554
583
|
<div className="label-xs">Type</div>
|
|
555
|
-
<div className="label-xs">
|
|
584
|
+
<div className="label-xs">Collection</div>
|
|
556
585
|
<div className="label-xs">Req</div>
|
|
557
586
|
<div className="label-xs">State</div>
|
|
558
587
|
<div className="label-xs">Links</div>
|
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);
|