@praxisui/core 10.0.0-rc.40 → 10.0.0-rc.42
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/README.md +82 -6
- package/ai/component-registry.json +2 -2
- package/fesm2022/praxisui-core-schema.mjs +443 -4
- package/fesm2022/praxisui-core.mjs +2911 -872
- package/package.json +1 -1
- package/theming/_theming.scss +1 -1
- package/types/praxisui-core-schema.d.ts +59 -0
- package/types/praxisui-core.d.ts +507 -34
|
@@ -1180,6 +1180,18 @@ function validateResourceQuickViewBinding(value) {
|
|
|
1180
1180
|
diagnostics.push('Quick View recordOpen cannot declare "popover" presentation.');
|
|
1181
1181
|
}
|
|
1182
1182
|
}
|
|
1183
|
+
let previewSurfaceId;
|
|
1184
|
+
const rawPreviewSurfaceId = record['previewSurfaceId'];
|
|
1185
|
+
if (rawPreviewSurfaceId !== undefined && rawPreviewSurfaceId !== null) {
|
|
1186
|
+
if (typeof rawPreviewSurfaceId === 'string' &&
|
|
1187
|
+
rawPreviewSurfaceId.trim().length > 0 &&
|
|
1188
|
+
rawPreviewSurfaceId.trim().length <= 200) {
|
|
1189
|
+
previewSurfaceId = rawPreviewSurfaceId.trim();
|
|
1190
|
+
}
|
|
1191
|
+
else {
|
|
1192
|
+
diagnostics.push('Quick View previewSurfaceId must be a non-empty string up to 200 characters.');
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1183
1195
|
let detailPresentation;
|
|
1184
1196
|
const rawDetailPresentation = record['detailPresentation'];
|
|
1185
1197
|
if (rawDetailPresentation !== undefined && rawDetailPresentation !== null) {
|
|
@@ -1246,6 +1258,7 @@ function validateResourceQuickViewBinding(value) {
|
|
|
1246
1258
|
valid: true,
|
|
1247
1259
|
binding: {
|
|
1248
1260
|
recordOpen: normalizedRecordOpen,
|
|
1261
|
+
...(previewSurfaceId ? { previewSurfaceId } : {}),
|
|
1249
1262
|
...(normalizedContentRef ? { contentRef: normalizedContentRef } : {}),
|
|
1250
1263
|
...(detailPresentation ? { detailPresentation } : {}),
|
|
1251
1264
|
},
|
|
@@ -1255,6 +1268,176 @@ function validateResourceQuickViewBinding(value) {
|
|
|
1255
1268
|
function normalizeResourceQuickViewBinding(value) {
|
|
1256
1269
|
return validateResourceQuickViewBinding(value).binding;
|
|
1257
1270
|
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Resolve ou sintetiza de forma determinística o `ResourceQuickViewBinding` de um campo
|
|
1273
|
+
* (`FieldDefinition` ou `FieldMetadata`), priorizando:
|
|
1274
|
+
* 1. `field.quickView` explícito;
|
|
1275
|
+
* 2. `field.presentation.interactions.quickView` explícito;
|
|
1276
|
+
* 3. síntese automática a partir de `field.resourceReference` ou `field.optionSource.detail`.
|
|
1277
|
+
*
|
|
1278
|
+
* Protege contra colisão de `valueField`/`optionSource.valuePropertyPath` (`'id'` da opção)
|
|
1279
|
+
* com o identificador da própria entidade pai quando o campo de origem possui outro nome
|
|
1280
|
+
* (ex.: `cargoId`, `fornecedorId`).
|
|
1281
|
+
*/
|
|
1282
|
+
function resolveFieldQuickViewBinding(candidate) {
|
|
1283
|
+
if (!candidate || typeof candidate !== 'object') {
|
|
1284
|
+
return null;
|
|
1285
|
+
}
|
|
1286
|
+
const explicitQuickView = normalizeResourceQuickViewBinding(candidate.quickView);
|
|
1287
|
+
if (explicitQuickView) {
|
|
1288
|
+
return explicitQuickView;
|
|
1289
|
+
}
|
|
1290
|
+
const presentationQuickView = normalizeResourceQuickViewBinding(candidate.presentation?.interactions?.quickView);
|
|
1291
|
+
if (presentationQuickView) {
|
|
1292
|
+
return presentationQuickView;
|
|
1293
|
+
}
|
|
1294
|
+
const fieldName = typeof candidate.name === 'string' ? candidate.name.trim() : '';
|
|
1295
|
+
const rawValueField = typeof candidate.valueField === 'string' ? candidate.valueField.trim() : '';
|
|
1296
|
+
const optionValueProperty = typeof candidate.optionSource?.valuePropertyPath === 'string' &&
|
|
1297
|
+
candidate.optionSource.valuePropertyPath.trim().length > 0
|
|
1298
|
+
? candidate.optionSource.valuePropertyPath.trim()
|
|
1299
|
+
: 'id';
|
|
1300
|
+
// Quando o campo possui optionSource e seu nome não é 'id', um valueField igual a
|
|
1301
|
+
// optionValueProperty (tipicamente 'id') refere-se à chave do OptionDTO e não ao
|
|
1302
|
+
// campo irmão no registro pai.
|
|
1303
|
+
const effectiveSiblingValueField = rawValueField &&
|
|
1304
|
+
(!candidate.optionSource ||
|
|
1305
|
+
fieldName === optionValueProperty ||
|
|
1306
|
+
rawValueField !== optionValueProperty)
|
|
1307
|
+
? rawValueField
|
|
1308
|
+
: '';
|
|
1309
|
+
const refCandidate = candidate.resourceReference?.resourceKey
|
|
1310
|
+
? {
|
|
1311
|
+
resourceKey: candidate.resourceReference.resourceKey,
|
|
1312
|
+
sourceIdentityField: (typeof candidate.resourceReference.valueField === 'string'
|
|
1313
|
+
? candidate.resourceReference.valueField.trim()
|
|
1314
|
+
: '') ||
|
|
1315
|
+
effectiveSiblingValueField ||
|
|
1316
|
+
fieldName,
|
|
1317
|
+
surfaceId: candidate.resourceReference.surfaceId || 'detail',
|
|
1318
|
+
previewSurfaceId: candidate.resourceReference.previewSurfaceId,
|
|
1319
|
+
detailPresentation: candidate.resourceReference.detailPresentation === 'drawer' ||
|
|
1320
|
+
candidate.resourceReference.detailPresentation === 'modal'
|
|
1321
|
+
? candidate.resourceReference.detailPresentation
|
|
1322
|
+
: undefined,
|
|
1323
|
+
}
|
|
1324
|
+
: candidate.optionSource?.detail?.resourceKey
|
|
1325
|
+
? {
|
|
1326
|
+
resourceKey: candidate.optionSource.detail.resourceKey,
|
|
1327
|
+
sourceIdentityField: effectiveSiblingValueField || fieldName,
|
|
1328
|
+
surfaceId: candidate.optionSource.detail.surfaceId || 'detail',
|
|
1329
|
+
previewSurfaceId: candidate.optionSource.detail.previewSurfaceId,
|
|
1330
|
+
detailPresentation: candidate.optionSource.detail.presentation === 'drawer' ||
|
|
1331
|
+
candidate.optionSource.detail.presentation === 'modal'
|
|
1332
|
+
? candidate.optionSource.detail.presentation
|
|
1333
|
+
: undefined,
|
|
1334
|
+
}
|
|
1335
|
+
: undefined;
|
|
1336
|
+
if (!refCandidate || !refCandidate.sourceIdentityField) {
|
|
1337
|
+
return null;
|
|
1338
|
+
}
|
|
1339
|
+
return normalizeResourceQuickViewBinding({
|
|
1340
|
+
recordOpen: {
|
|
1341
|
+
sourceIdentityField: refCandidate.sourceIdentityField,
|
|
1342
|
+
target: {
|
|
1343
|
+
resourceKey: refCandidate.resourceKey,
|
|
1344
|
+
surfaceId: refCandidate.surfaceId || 'detail',
|
|
1345
|
+
},
|
|
1346
|
+
},
|
|
1347
|
+
...(refCandidate.previewSurfaceId
|
|
1348
|
+
? { previewSurfaceId: refCandidate.previewSurfaceId }
|
|
1349
|
+
: {}),
|
|
1350
|
+
...(refCandidate.detailPresentation
|
|
1351
|
+
? { detailPresentation: refCandidate.detailPresentation }
|
|
1352
|
+
: {}),
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* Reconcilia o `ResourceQuickViewBinding` entre a definição base do servidor e uma
|
|
1357
|
+
* customização local persistida:
|
|
1358
|
+
* - Um `local` indefinido, nulo ou inválido nunca apaga o binding canônico do servidor (`base`).
|
|
1359
|
+
* - Quando o campo possui binding canônico do servidor (`base`), `base.recordOpen`
|
|
1360
|
+
* (recurso de destino, `surfaceId` e `sourceIdentityField`) permanece autoritativo
|
|
1361
|
+
* do servidor, permitindo que o `local` customize apenas preferências visuais de UX
|
|
1362
|
+
* (`trigger`, `previewSurfaceId`, `detailPresentation`).
|
|
1363
|
+
*/
|
|
1364
|
+
function reconcileFieldQuickViewBinding(base, local) {
|
|
1365
|
+
const normalizedBase = normalizeResourceQuickViewBinding(base);
|
|
1366
|
+
const normalizedLocal = normalizeResourceQuickViewBinding(local);
|
|
1367
|
+
if (normalizedBase && normalizedLocal) {
|
|
1368
|
+
return {
|
|
1369
|
+
...normalizedBase,
|
|
1370
|
+
...normalizedLocal,
|
|
1371
|
+
recordOpen: normalizedBase.recordOpen,
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
return normalizedLocal ?? normalizedBase ?? undefined;
|
|
1375
|
+
}
|
|
1376
|
+
function readQuickViewFieldOrPath(target, path) {
|
|
1377
|
+
if (Object.prototype.hasOwnProperty.call(target, path)) {
|
|
1378
|
+
return target[path];
|
|
1379
|
+
}
|
|
1380
|
+
if (!path.includes('.')) {
|
|
1381
|
+
return undefined;
|
|
1382
|
+
}
|
|
1383
|
+
return path.split('.').reduce((acc, segment) => {
|
|
1384
|
+
if (!acc || typeof acc !== 'object' || Array.isArray(acc)) {
|
|
1385
|
+
return undefined;
|
|
1386
|
+
}
|
|
1387
|
+
return Object.prototype.hasOwnProperty.call(acc, segment)
|
|
1388
|
+
? acc[segment]
|
|
1389
|
+
: undefined;
|
|
1390
|
+
}, target);
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Resolve de forma determinística o alvo (`resourceKey`, `surfaceId`, `previewSurfaceId`, `identity`)
|
|
1394
|
+
* a partir de um `ResourceQuickViewBinding` e de um registro candidato (`sourceRecord`).
|
|
1395
|
+
*/
|
|
1396
|
+
function resolveResourceQuickViewTarget(binding, sourceRecord) {
|
|
1397
|
+
const normalized = normalizeResourceQuickViewBinding(binding);
|
|
1398
|
+
if (!normalized ||
|
|
1399
|
+
!sourceRecord ||
|
|
1400
|
+
typeof sourceRecord !== 'object' ||
|
|
1401
|
+
Array.isArray(sourceRecord)) {
|
|
1402
|
+
return null;
|
|
1403
|
+
}
|
|
1404
|
+
const record = sourceRecord;
|
|
1405
|
+
const sourceField = normalized.recordOpen.sourceIdentityField;
|
|
1406
|
+
let candidate = readQuickViewFieldOrPath(record, sourceField);
|
|
1407
|
+
if (candidate === undefined) {
|
|
1408
|
+
for (const envelopeKey of ['row', 'item', 'values']) {
|
|
1409
|
+
const nested = record[envelopeKey];
|
|
1410
|
+
if (nested && typeof nested === 'object' && !Array.isArray(nested)) {
|
|
1411
|
+
candidate = readQuickViewFieldOrPath(nested, sourceField);
|
|
1412
|
+
if (candidate !== undefined) {
|
|
1413
|
+
break;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
if (candidate && typeof candidate === 'object' && !Array.isArray(candidate)) {
|
|
1419
|
+
const candidateObj = candidate;
|
|
1420
|
+
candidate =
|
|
1421
|
+
candidateObj['id'] ?? candidateObj['value'] ?? candidateObj['key'];
|
|
1422
|
+
}
|
|
1423
|
+
if (typeof candidate === 'number' && Number.isFinite(candidate)) {
|
|
1424
|
+
return {
|
|
1425
|
+
resourceKey: normalized.recordOpen.target.resourceKey,
|
|
1426
|
+
surfaceId: normalized.recordOpen.target.surfaceId,
|
|
1427
|
+
previewSurfaceId: normalized.previewSurfaceId || normalized.recordOpen.target.surfaceId,
|
|
1428
|
+
identity: candidate,
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
if (typeof candidate === 'string' && candidate.trim().length > 0) {
|
|
1432
|
+
return {
|
|
1433
|
+
resourceKey: normalized.recordOpen.target.resourceKey,
|
|
1434
|
+
surfaceId: normalized.recordOpen.target.surfaceId,
|
|
1435
|
+
previewSurfaceId: normalized.previewSurfaceId || normalized.recordOpen.target.surfaceId,
|
|
1436
|
+
identity: candidate.trim(),
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
return null;
|
|
1440
|
+
}
|
|
1258
1441
|
/**
|
|
1259
1442
|
* Verifica se a âncora efêmera de runtime permanece conectada e visível na viewport.
|
|
1260
1443
|
*/
|
|
@@ -1474,6 +1657,103 @@ function normalizeInteractions(value) {
|
|
|
1474
1657
|
};
|
|
1475
1658
|
}
|
|
1476
1659
|
|
|
1660
|
+
/** Converts UI tokens only under declared scalar items; invalid input is never dropped or partially converted. */
|
|
1661
|
+
function normalizeScalarArrayValue(value, items) {
|
|
1662
|
+
if (items.enum !== undefined && !isScalarEnum(items.enum))
|
|
1663
|
+
return { valid: false, invalidIndices: [-1] };
|
|
1664
|
+
if (value == null)
|
|
1665
|
+
return { valid: true, value };
|
|
1666
|
+
if (!Array.isArray(value))
|
|
1667
|
+
return { valid: false, invalidIndices: [-1] };
|
|
1668
|
+
const converted = [];
|
|
1669
|
+
const invalidIndices = [];
|
|
1670
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
1671
|
+
const item = normalizeItem(value[index], items);
|
|
1672
|
+
if (item === undefined || items.enum && !items.enum.some(candidate => candidate === item))
|
|
1673
|
+
invalidIndices.push(index);
|
|
1674
|
+
else
|
|
1675
|
+
converted.push(item);
|
|
1676
|
+
}
|
|
1677
|
+
return invalidIndices.length ? { valid: false, invalidIndices } : { valid: true, value: converted };
|
|
1678
|
+
}
|
|
1679
|
+
function normalizeItem(value, items) {
|
|
1680
|
+
if (value == null)
|
|
1681
|
+
return undefined;
|
|
1682
|
+
if (items.type === 'boolean') {
|
|
1683
|
+
if (typeof value === 'boolean')
|
|
1684
|
+
return value;
|
|
1685
|
+
return value === 'true' ? true : value === 'false' ? false : undefined;
|
|
1686
|
+
}
|
|
1687
|
+
if (items.type === 'integer' || items.type === 'number') {
|
|
1688
|
+
const number = typeof value === 'number' ? value : typeof value === 'string' &&
|
|
1689
|
+
/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(value) ? Number(value) : NaN;
|
|
1690
|
+
if (!Number.isFinite(number) || items.type === 'integer' && !Number.isSafeInteger(number))
|
|
1691
|
+
return undefined;
|
|
1692
|
+
return number;
|
|
1693
|
+
}
|
|
1694
|
+
if (items.type !== 'string')
|
|
1695
|
+
return undefined;
|
|
1696
|
+
if (items.format === 'date') {
|
|
1697
|
+
if (value instanceof Date) {
|
|
1698
|
+
if (Number.isNaN(value.getTime()))
|
|
1699
|
+
return undefined;
|
|
1700
|
+
const date = `${String(value.getFullYear()).padStart(4, '0')}-${String(value.getMonth() + 1).padStart(2, '0')}-${String(value.getDate()).padStart(2, '0')}`;
|
|
1701
|
+
return isIsoDate(date) ? date : undefined;
|
|
1702
|
+
}
|
|
1703
|
+
return typeof value === 'string' && isIsoDate(value) ? value : undefined;
|
|
1704
|
+
}
|
|
1705
|
+
if (items.format === 'date-time') {
|
|
1706
|
+
if (value instanceof Date)
|
|
1707
|
+
return Number.isNaN(value.getTime()) ? undefined : value.toISOString();
|
|
1708
|
+
return typeof value === 'string' && isIsoDateTime(value) ? value : undefined;
|
|
1709
|
+
}
|
|
1710
|
+
return typeof value === 'string' ? value : undefined;
|
|
1711
|
+
}
|
|
1712
|
+
function isIsoDate(value) {
|
|
1713
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
1714
|
+
if (!match)
|
|
1715
|
+
return false;
|
|
1716
|
+
const year = Number(match[1]), month = Number(match[2]), day = Number(match[3]);
|
|
1717
|
+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
1718
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
1719
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= days[month - 1];
|
|
1720
|
+
}
|
|
1721
|
+
function isIsoDateTime(value) {
|
|
1722
|
+
const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(?:Z|([+-])(\d{2}):(\d{2}))?$/.exec(value);
|
|
1723
|
+
if (!match || !isIsoDate(match[1]))
|
|
1724
|
+
return false;
|
|
1725
|
+
if (Number(match[2]) > 23 || Number(match[3]) > 59 || Number(match[4] ?? 0) > 59)
|
|
1726
|
+
return false;
|
|
1727
|
+
const offsetHours = Number(match[7] ?? 0), offsetMinutes = Number(match[8] ?? 0);
|
|
1728
|
+
return offsetHours <= 18 && offsetMinutes <= 59 && (offsetHours !== 18 || offsetMinutes === 0);
|
|
1729
|
+
}
|
|
1730
|
+
/** Internal admission of the scalar subset already published in JSON Schema items. */
|
|
1731
|
+
function normalizeScalarItemsSchema(value) {
|
|
1732
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
1733
|
+
return undefined;
|
|
1734
|
+
const record = value;
|
|
1735
|
+
if (typeof record['type'] !== 'string' || !['string', 'integer', 'number', 'boolean'].includes(record['type']))
|
|
1736
|
+
return undefined;
|
|
1737
|
+
const result = { type: record['type'] };
|
|
1738
|
+
if (typeof record['format'] === 'string')
|
|
1739
|
+
result.format = record['format'];
|
|
1740
|
+
if (record['enum'] !== undefined) {
|
|
1741
|
+
if (!isScalarEnum(record['enum']))
|
|
1742
|
+
throw new TypeError('Scalar items enum must contain JSON scalar values.');
|
|
1743
|
+
result.enum = [...record['enum']];
|
|
1744
|
+
}
|
|
1745
|
+
return result;
|
|
1746
|
+
}
|
|
1747
|
+
function isScalarEnum(value) {
|
|
1748
|
+
return Array.isArray(value) && value.length > 0 && value.every(item => item === null || typeof item === 'string' || typeof item === 'boolean' || typeof item === 'number' && Number.isFinite(item));
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// Mirrors the backend custom-field key policy. Ordinary static field names are
|
|
1752
|
+
// outside this boundary; custom keys must be safe across all runtime consumers.
|
|
1753
|
+
const RESERVED_CUSTOM_FIELD_KEYS = new Set([
|
|
1754
|
+
'constructor', 'prototype', 'hasOwnProperty', 'isPrototypeOf',
|
|
1755
|
+
'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf',
|
|
1756
|
+
]);
|
|
1477
1757
|
const VALUE_PRESENTATION_TYPES = new Set([
|
|
1478
1758
|
'string',
|
|
1479
1759
|
'number',
|
|
@@ -1852,9 +2132,15 @@ class SchemaNormalizationKernel {
|
|
|
1852
2132
|
if (value.kind !== undefined) {
|
|
1853
2133
|
detail.kind = String(value.kind);
|
|
1854
2134
|
}
|
|
2135
|
+
if (value.resourceKey !== undefined && String(value.resourceKey).trim().length > 0) {
|
|
2136
|
+
detail.resourceKey = String(value.resourceKey).trim();
|
|
2137
|
+
}
|
|
1855
2138
|
if (value.surfaceId !== undefined) {
|
|
1856
2139
|
detail.surfaceId = String(value.surfaceId);
|
|
1857
2140
|
}
|
|
2141
|
+
if (value.previewSurfaceId !== undefined && String(value.previewSurfaceId).trim().length > 0) {
|
|
2142
|
+
detail.previewSurfaceId = String(value.previewSurfaceId).trim();
|
|
2143
|
+
}
|
|
1858
2144
|
if (value.presentation !== undefined) {
|
|
1859
2145
|
detail.presentation = String(value.presentation);
|
|
1860
2146
|
}
|
|
@@ -1879,6 +2165,11 @@ class SchemaNormalizationKernel {
|
|
|
1879
2165
|
'resultLayout',
|
|
1880
2166
|
'primaryPropertyPath',
|
|
1881
2167
|
'avatarPropertyPath',
|
|
2168
|
+
'detailActionLabel',
|
|
2169
|
+
'quickViewActionLabel',
|
|
2170
|
+
'copyCodeActionLabel',
|
|
2171
|
+
'copyIdActionLabel',
|
|
2172
|
+
'createActionLabel',
|
|
1882
2173
|
];
|
|
1883
2174
|
stringKeys.forEach((key) => {
|
|
1884
2175
|
if (value[key] !== undefined) {
|
|
@@ -1916,6 +2207,10 @@ class SchemaNormalizationKernel {
|
|
|
1916
2207
|
if (value.maxVisibleBadges !== undefined && !Number.isNaN(Number(value.maxVisibleBadges))) {
|
|
1917
2208
|
display.maxVisibleBadges = Number(value.maxVisibleBadges);
|
|
1918
2209
|
}
|
|
2210
|
+
const actions = this.parseLookupActions(value.actions);
|
|
2211
|
+
if (actions) {
|
|
2212
|
+
display.actions = actions;
|
|
2213
|
+
}
|
|
1919
2214
|
return Object.keys(display).length ? display : undefined;
|
|
1920
2215
|
}
|
|
1921
2216
|
parseLookupDisplayField(value) {
|
|
@@ -1930,6 +2225,28 @@ class SchemaNormalizationKernel {
|
|
|
1930
2225
|
});
|
|
1931
2226
|
return Object.keys(field).length ? field : undefined;
|
|
1932
2227
|
}
|
|
2228
|
+
parseLookupActions(value) {
|
|
2229
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
2230
|
+
return undefined;
|
|
2231
|
+
}
|
|
2232
|
+
const actions = {};
|
|
2233
|
+
if (value.showDetail !== undefined) {
|
|
2234
|
+
actions.showDetail = this.parseBoolean(value.showDetail);
|
|
2235
|
+
}
|
|
2236
|
+
if (value.showQuickView !== undefined) {
|
|
2237
|
+
actions.showQuickView = this.parseBoolean(value.showQuickView);
|
|
2238
|
+
}
|
|
2239
|
+
if (value.showCopyCode !== undefined) {
|
|
2240
|
+
actions.showCopyCode = this.parseBoolean(value.showCopyCode);
|
|
2241
|
+
}
|
|
2242
|
+
if (value.showCopyId !== undefined) {
|
|
2243
|
+
actions.showCopyId = this.parseBoolean(value.showCopyId);
|
|
2244
|
+
}
|
|
2245
|
+
if (value.showCreate !== undefined) {
|
|
2246
|
+
actions.showCreate = this.parseBoolean(value.showCreate);
|
|
2247
|
+
}
|
|
2248
|
+
return Object.keys(actions).length ? actions : undefined;
|
|
2249
|
+
}
|
|
1933
2250
|
parseLookupCreate(value) {
|
|
1934
2251
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
1935
2252
|
return undefined;
|
|
@@ -2385,6 +2702,34 @@ class SchemaNormalizationKernel {
|
|
|
2385
2702
|
const normalized = String(value ?? '').trim();
|
|
2386
2703
|
return OPTION_SOURCE_INVALID_SORT_POLICIES.has(normalized) ? normalized : undefined;
|
|
2387
2704
|
}
|
|
2705
|
+
parseResourceReference(value) {
|
|
2706
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
2707
|
+
return undefined;
|
|
2708
|
+
}
|
|
2709
|
+
const raw = value;
|
|
2710
|
+
const resourceKey = String(raw['resourceKey'] ?? '').trim();
|
|
2711
|
+
if (!resourceKey) {
|
|
2712
|
+
return undefined;
|
|
2713
|
+
}
|
|
2714
|
+
const ref = { resourceKey };
|
|
2715
|
+
const valueField = String(raw['valueField'] ?? '').trim();
|
|
2716
|
+
if (valueField) {
|
|
2717
|
+
ref.valueField = valueField;
|
|
2718
|
+
}
|
|
2719
|
+
const surfaceId = String(raw['surfaceId'] ?? '').trim();
|
|
2720
|
+
if (surfaceId) {
|
|
2721
|
+
ref.surfaceId = surfaceId;
|
|
2722
|
+
}
|
|
2723
|
+
const previewSurfaceId = String(raw['previewSurfaceId'] ?? '').trim();
|
|
2724
|
+
if (previewSurfaceId) {
|
|
2725
|
+
ref.previewSurfaceId = previewSurfaceId;
|
|
2726
|
+
}
|
|
2727
|
+
const detailPresentation = String(raw['detailPresentation'] ?? '').trim();
|
|
2728
|
+
if (detailPresentation === 'drawer' || detailPresentation === 'modal') {
|
|
2729
|
+
ref.detailPresentation = detailPresentation;
|
|
2730
|
+
}
|
|
2731
|
+
return ref;
|
|
2732
|
+
}
|
|
2388
2733
|
parseLookupOpenDetailMode(value) {
|
|
2389
2734
|
const normalized = String(value ?? '').trim();
|
|
2390
2735
|
return LOOKUP_OPEN_DETAIL_MODES.has(normalized) ? normalized : undefined;
|
|
@@ -2697,16 +3042,62 @@ class SchemaNormalizationKernel {
|
|
|
2697
3042
|
!Array.isArray(prop['x-ui'])
|
|
2698
3043
|
? prop['x-ui']
|
|
2699
3044
|
: undefined;
|
|
3045
|
+
const hasChildProperties = prop?.properties &&
|
|
3046
|
+
typeof prop.properties === 'object' &&
|
|
3047
|
+
!Array.isArray(prop.properties);
|
|
3048
|
+
const isCustomFieldsContainer = ui?.customFieldsContainer === true ||
|
|
3049
|
+
(name === 'customFields' && prop?.type === 'object' && hasChildProperties);
|
|
3050
|
+
if (isCustomFieldsContainer) {
|
|
3051
|
+
if (hasChildProperties) {
|
|
3052
|
+
for (const key of Object.keys(prop.properties)) {
|
|
3053
|
+
if (RESERVED_CUSTOM_FIELD_KEYS.has(key)) {
|
|
3054
|
+
throw new Error(`Unsupported custom field key "${name}.${key}". Publish a key admitted by the canonical backend custom-field policy.`);
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
const parentAccess = normalizeFieldAccessMetadata(ui?.fieldAccess);
|
|
3058
|
+
for (const childField of this.normalizeSchemaWithRoot(prop, rootSchema)) {
|
|
3059
|
+
const originalKey = childField.name;
|
|
3060
|
+
if (parentAccess && childField.fieldAccess &&
|
|
3061
|
+
!this.haveEquivalentFieldAccess(parentAccess, childField.fieldAccess)) {
|
|
3062
|
+
throw new Error(`Conflicting fieldAccess on custom-field container "${name}" and child "${originalKey}". Publish the effective access policy on each leaf field.`);
|
|
3063
|
+
}
|
|
3064
|
+
fields.push({
|
|
3065
|
+
...childField,
|
|
3066
|
+
name: `${name}.${originalKey}`,
|
|
3067
|
+
customField: true,
|
|
3068
|
+
customFieldKey: childField.customFieldKey ?? originalKey,
|
|
3069
|
+
customFieldScope: childField.customFieldScope ?? 'tenant',
|
|
3070
|
+
...(ui?.disabled !== undefined && this.parseBoolean(ui.disabled) ? { disabled: true } : {}),
|
|
3071
|
+
...(ui?.readOnly !== undefined && this.parseBoolean(ui.readOnly) ? { readOnly: true } : {}),
|
|
3072
|
+
...(ui?.formHidden !== undefined && this.parseBoolean(ui.formHidden) ? { formHidden: true } : {}),
|
|
3073
|
+
...(parentAccess && !childField.fieldAccess ? { fieldAccess: normalizeFieldAccessMetadata(parentAccess) } : {}),
|
|
3074
|
+
});
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
// The container is wire structure, never an independent field control.
|
|
3078
|
+
continue;
|
|
3079
|
+
}
|
|
2700
3080
|
// Skip properties without x-ui metadata
|
|
2701
3081
|
if (!ui || Object.keys(ui).length === 0) {
|
|
2702
3082
|
continue;
|
|
2703
3083
|
}
|
|
2704
3084
|
const field = { name };
|
|
3085
|
+
if (ui.customField !== undefined) {
|
|
3086
|
+
field.customField = this.parseBoolean(ui.customField);
|
|
3087
|
+
}
|
|
3088
|
+
if (ui.customFieldKey != null) {
|
|
3089
|
+
field.customFieldKey = String(ui.customFieldKey);
|
|
3090
|
+
}
|
|
3091
|
+
if (ui.customFieldScope != null) {
|
|
3092
|
+
field.customFieldScope = String(ui.customFieldScope);
|
|
3093
|
+
}
|
|
2705
3094
|
// -------------------------------------------------------------------
|
|
2706
3095
|
// Basic information
|
|
2707
3096
|
// -------------------------------------------------------------------
|
|
2708
3097
|
field.label = ui.label ?? prop.title ?? name;
|
|
2709
3098
|
field.type = this.resolveFieldType(prop, ui);
|
|
3099
|
+
if (field.type === 'array')
|
|
3100
|
+
field.items = normalizeScalarItemsSchema(prop?.items);
|
|
2710
3101
|
const numericFormat = this.resolveNumericFormatToken(prop, ui, field.type);
|
|
2711
3102
|
if (numericFormat) {
|
|
2712
3103
|
field.numericFormat = numericFormat;
|
|
@@ -2833,6 +3224,18 @@ class SchemaNormalizationKernel {
|
|
|
2833
3224
|
if (ui.formHidden !== undefined) {
|
|
2834
3225
|
field.formHidden = this.parseBoolean(ui.formHidden);
|
|
2835
3226
|
}
|
|
3227
|
+
if (ui.quickViewVisible !== undefined) {
|
|
3228
|
+
const quickViewVisible = this.parseOptionalBoolean(ui.quickViewVisible);
|
|
3229
|
+
if (quickViewVisible !== undefined) {
|
|
3230
|
+
field.quickViewVisible = quickViewVisible;
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
if (ui.quickViewOrder !== undefined) {
|
|
3234
|
+
const quickViewOrder = this.parseOptionalFiniteNumber(ui.quickViewOrder);
|
|
3235
|
+
if (quickViewOrder !== undefined) {
|
|
3236
|
+
field.quickViewOrder = quickViewOrder;
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
2836
3239
|
if (ui.width !== undefined) {
|
|
2837
3240
|
field.width = ui.width;
|
|
2838
3241
|
}
|
|
@@ -2957,6 +3360,24 @@ class SchemaNormalizationKernel {
|
|
|
2957
3360
|
if (ui.filterField !== undefined) {
|
|
2958
3361
|
field.filterField = ui.filterField;
|
|
2959
3362
|
}
|
|
3363
|
+
if (ui.resourceReference !== undefined) {
|
|
3364
|
+
const resourceReference = this.parseResourceReference(ui.resourceReference);
|
|
3365
|
+
if (resourceReference) {
|
|
3366
|
+
field.resourceReference = resourceReference;
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
if (ui.quickView !== undefined) {
|
|
3370
|
+
const explicitQuickView = normalizeResourceQuickViewBinding(ui.quickView);
|
|
3371
|
+
if (explicitQuickView) {
|
|
3372
|
+
field.quickView = explicitQuickView;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
if (!field.quickView) {
|
|
3376
|
+
const synthesized = resolveFieldQuickViewBinding(field);
|
|
3377
|
+
if (synthesized) {
|
|
3378
|
+
field.quickView = synthesized;
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
2960
3381
|
if (ui.multiple !== undefined) {
|
|
2961
3382
|
field.multiple = this.parseBoolean(ui.multiple);
|
|
2962
3383
|
}
|
|
@@ -2981,6 +3402,12 @@ class SchemaNormalizationKernel {
|
|
|
2981
3402
|
field.detailActionLabel = detailActionLabel;
|
|
2982
3403
|
}
|
|
2983
3404
|
}
|
|
3405
|
+
if (ui.quickViewActionLabel !== undefined) {
|
|
3406
|
+
const quickViewActionLabel = String(ui.quickViewActionLabel).trim();
|
|
3407
|
+
if (quickViewActionLabel) {
|
|
3408
|
+
field.quickViewActionLabel = quickViewActionLabel;
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
2984
3411
|
if (ui.copyCodeActionLabel !== undefined) {
|
|
2985
3412
|
const copyCodeActionLabel = String(ui.copyCodeActionLabel).trim();
|
|
2986
3413
|
if (copyCodeActionLabel) {
|
|
@@ -3004,6 +3431,9 @@ class SchemaNormalizationKernel {
|
|
|
3004
3431
|
if (ui.actions.showDetail !== undefined) {
|
|
3005
3432
|
actions.showDetail = this.parseBoolean(ui.actions.showDetail);
|
|
3006
3433
|
}
|
|
3434
|
+
if (ui.actions.showQuickView !== undefined) {
|
|
3435
|
+
actions.showQuickView = this.parseBoolean(ui.actions.showQuickView);
|
|
3436
|
+
}
|
|
3007
3437
|
if (ui.actions.showCopyCode !== undefined) {
|
|
3008
3438
|
actions.showCopyCode = this.parseBoolean(ui.actions.showCopyCode);
|
|
3009
3439
|
}
|
|
@@ -3284,6 +3714,13 @@ class SchemaNormalizationKernel {
|
|
|
3284
3714
|
});
|
|
3285
3715
|
return fields;
|
|
3286
3716
|
}
|
|
3717
|
+
haveEquivalentFieldAccess(left, right) {
|
|
3718
|
+
const identity = (access) => JSON.stringify([
|
|
3719
|
+
[...(access.visibleForAuthorities ?? [])].sort(),
|
|
3720
|
+
[...(access.editableForAuthorities ?? [])].sort(),
|
|
3721
|
+
]);
|
|
3722
|
+
return identity(left) === identity(right);
|
|
3723
|
+
}
|
|
3287
3724
|
resolveFieldType(prop, ui) {
|
|
3288
3725
|
if (ui?.type !== undefined && ui?.type !== null && String(ui.type).trim() !== '') {
|
|
3289
3726
|
return String(ui.type);
|
|
@@ -3291,6 +3728,10 @@ class SchemaNormalizationKernel {
|
|
|
3291
3728
|
if (String(ui?.controlType ?? '').trim() === 'array') {
|
|
3292
3729
|
return 'array';
|
|
3293
3730
|
}
|
|
3731
|
+
if (Array.isArray(prop?.type)) {
|
|
3732
|
+
const types = [...new Set(prop.type.filter((type) => typeof type === 'string' && type !== 'null'))];
|
|
3733
|
+
return types.length === 1 ? types[0] : undefined;
|
|
3734
|
+
}
|
|
3294
3735
|
if (prop?.type) {
|
|
3295
3736
|
return String(prop.type);
|
|
3296
3737
|
}
|
|
@@ -3461,8 +3902,7 @@ function applyLocalCustomizations(baseCol, localCol) {
|
|
|
3461
3902
|
result.headerStyle = localCol.headerStyle ?? baseCol.headerStyle;
|
|
3462
3903
|
result.cssClass = localCol.cssClass ?? baseCol.cssClass;
|
|
3463
3904
|
result.headerCssClass = localCol.headerCssClass ?? baseCol.headerCssClass;
|
|
3464
|
-
const resolvedQuickView =
|
|
3465
|
-
normalizeResourceQuickViewBinding(baseCol.quickView);
|
|
3905
|
+
const resolvedQuickView = reconcileFieldQuickViewBinding(baseCol.quickView, localCol.quickView);
|
|
3466
3906
|
if (resolvedQuickView) {
|
|
3467
3907
|
result.quickView = resolvedQuickView;
|
|
3468
3908
|
}
|
|
@@ -3719,8 +4159,7 @@ function humanizeSchemaEnumValue(value) {
|
|
|
3719
4159
|
.join(' ');
|
|
3720
4160
|
}
|
|
3721
4161
|
function resolveQuickViewFromFieldDefinition(def) {
|
|
3722
|
-
return (
|
|
3723
|
-
normalizeResourceQuickViewBinding(def.presentation?.interactions?.quickView) ??
|
|
4162
|
+
return (resolveFieldQuickViewBinding(def) ??
|
|
3724
4163
|
normalizeResourceQuickViewBinding(def['extraProperties'] && typeof def['extraProperties'] === 'object' ? def['extraProperties']['quickView'] : undefined) ??
|
|
3725
4164
|
undefined);
|
|
3726
4165
|
}
|