@altopelago/sansa 0.11.1 → 0.13.0
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/CHANGELOG.md +94 -0
- package/CONTRIBUTING.md +1 -0
- package/README.md +23 -2
- package/conformance/cts-claims.json +9 -2
- package/docs/api-contract.md +101 -13
- package/docs/capabilities.json +3 -1
- package/docs/query-tool.md +42 -2
- package/docs/releasing.md +69 -17
- package/fixtures/query-inventory.aeon +7 -0
- package/fixtures/query-inventory.telex.aes +5 -0
- package/package.json +3 -2
- package/scripts/cts-value-semantics.mjs +1 -1
- package/scripts/query.mjs +17 -0
- package/scripts/version.mjs +54 -3
- package/src/index.d.ts +79 -4
- package/src/index.js +952 -53
- package/tools/mutate-web/runtime.mjs +30 -1
- package/tools/query-web/examples.mjs +44 -1
- package/tools/query-web/index.html +2 -0
- package/tools/query-web/runtime.mjs +97 -3
|
@@ -668,7 +668,7 @@ function telexScalarReplacementRecord(current, value, operation, aes) {
|
|
|
668
668
|
const PORTABLE_MUTABLE_SCALAR_KINDS = new Set([
|
|
669
669
|
'StringLiteral', 'NumberLiteral', 'InfinityLiteral', 'NaNLiteral', 'NullLiteral',
|
|
670
670
|
'BooleanLiteral', 'ToggleLiteral', 'HexLiteral', 'RadixLiteral', 'EncodingLiteral',
|
|
671
|
-
'SeparatorLiteral', 'SansaAddressLiteral', 'DateLiteral', 'TimeLiteral',
|
|
671
|
+
'SeparatorLiteral', 'SymbolicLiteral', 'SansaAddressLiteral', 'DateLiteral', 'TimeLiteral',
|
|
672
672
|
'DateTimeLiteral', 'WTCDateTimeLiteral',
|
|
673
673
|
]);
|
|
674
674
|
|
|
@@ -680,6 +680,7 @@ const PORTABLE_KIND_ALIASES = new Map([
|
|
|
680
680
|
['hex', 'HexLiteral'], ['radix', 'RadixLiteral'], ['encoding', 'EncodingLiteral'],
|
|
681
681
|
['base64', 'EncodingLiteral'], ['embed', 'EncodingLiteral'], ['inline', 'EncodingLiteral'],
|
|
682
682
|
['separator', 'SeparatorLiteral'], ['sep', 'SeparatorLiteral'], ['csv', 'SeparatorLiteral'],
|
|
683
|
+
['symbol', 'SymbolicLiteral'], ['symbolicliteral', 'SymbolicLiteral'],
|
|
683
684
|
['sansa', 'SansaAddressLiteral'], ['sansaaddress', 'SansaAddressLiteral'],
|
|
684
685
|
['date', 'DateLiteral'], ['time', 'TimeLiteral'], ['datetime', 'DateTimeLiteral'], ['wtc', 'WTCDateTimeLiteral'],
|
|
685
686
|
]);
|
|
@@ -752,6 +753,7 @@ function portableScalarSemanticTypeForWorkbench(kind) {
|
|
|
752
753
|
StringLiteral: 'string', NumberLiteral: 'number', BooleanLiteral: 'boolean',
|
|
753
754
|
NullLiteral: 'null', InfinityLiteral: 'infinity', NaNLiteral: 'nan', ToggleLiteral: 'toggle',
|
|
754
755
|
HexLiteral: 'hex', RadixLiteral: 'radix', EncodingLiteral: 'encoding', SeparatorLiteral: 'sep',
|
|
756
|
+
SymbolicLiteral: 'symbol',
|
|
755
757
|
SansaAddressLiteral: 'sansa', DateLiteral: 'date', TimeLiteral: 'time',
|
|
756
758
|
DateTimeLiteral: 'datetime', WTCDateTimeLiteral: 'wtc',
|
|
757
759
|
}[kind];
|
|
@@ -762,6 +764,7 @@ function portableScalarKindForWorkbench(kind) {
|
|
|
762
764
|
StringLiteral: 'string', NumberLiteral: 'number', BooleanLiteral: 'boolean',
|
|
763
765
|
NullLiteral: 'null', InfinityLiteral: 'infinity', NaNLiteral: 'nan', ToggleLiteral: 'toggle',
|
|
764
766
|
HexLiteral: 'hex', RadixLiteral: 'radix', EncodingLiteral: 'encoding', SeparatorLiteral: 'separator',
|
|
767
|
+
SymbolicLiteral: 'symbol',
|
|
765
768
|
SansaAddressLiteral: 'sansaAddress', DateLiteral: 'date', TimeLiteral: 'time',
|
|
766
769
|
DateTimeLiteral: 'datetime', WTCDateTimeLiteral: 'wtc',
|
|
767
770
|
}[kind];
|
|
@@ -910,6 +913,10 @@ function validateAeonWorkbenchScalarValue(value, representation, path) {
|
|
|
910
913
|
return typeof value === 'string'
|
|
911
914
|
? { ok: true }
|
|
912
915
|
: invalidAeonWorkbenchValue('String literals must use JSON string payloads', path);
|
|
916
|
+
case 'symbol':
|
|
917
|
+
return typeof value === 'string' && value.length > 0
|
|
918
|
+
? { ok: true }
|
|
919
|
+
: invalidAeonWorkbenchValue('Symbol literals must use non-empty JSON string payloads', path);
|
|
913
920
|
case 'number':
|
|
914
921
|
return typeof value === 'number' && Number.isFinite(value)
|
|
915
922
|
? { ok: true }
|
|
@@ -934,6 +941,10 @@ function validateAeonWorkbenchScalarValue(value, representation, path) {
|
|
|
934
941
|
return typeof value === 'string' && value.length > 0
|
|
935
942
|
? { ok: true }
|
|
936
943
|
: invalidAeonWorkbenchValue('Separator literals must be non-empty text without the ^ prefix', path);
|
|
944
|
+
case 'symbol':
|
|
945
|
+
return typeof value === 'string' && value.length > 0
|
|
946
|
+
? { ok: true }
|
|
947
|
+
: invalidAeonWorkbenchValue('Symbol literals must be non-empty text', path);
|
|
937
948
|
case 'sansa':
|
|
938
949
|
case 'sansaAddress':
|
|
939
950
|
return typeof value === 'string' && value.length > 0
|
|
@@ -1406,8 +1417,12 @@ function renderScalarValue(binding) {
|
|
|
1406
1417
|
if (kind === 'toggle') return String(value);
|
|
1407
1418
|
if (kind === 'hex') return `#${value}`;
|
|
1408
1419
|
if (kind === 'radix') return `%${value}`;
|
|
1420
|
+
if (kind === 'number' || kind === 'NumberLiteral' || binding.numericLexeme !== undefined) {
|
|
1421
|
+
return binding.numericLexeme ?? String(value);
|
|
1422
|
+
}
|
|
1409
1423
|
if (kind === 'encoding') return `&${value}`;
|
|
1410
1424
|
if (kind === 'separator') return `^${value}`;
|
|
1425
|
+
if (kind === 'symbol') return renderSymbolLiteral(value);
|
|
1411
1426
|
if (['date', 'time', 'datetime', 'wtc'].includes(kind)) return String(value);
|
|
1412
1427
|
if (kind === 'sansaAddress' || kind === 'sansa') {
|
|
1413
1428
|
return value?.canonical ?? value?.address?.canonical ?? value?.address ?? String(value);
|
|
@@ -1424,6 +1439,18 @@ function renderBlockString(value) {
|
|
|
1424
1439
|
return `>\`${text}\``;
|
|
1425
1440
|
}
|
|
1426
1441
|
|
|
1442
|
+
function renderSymbolLiteral(value) {
|
|
1443
|
+
const text = String(value ?? '')
|
|
1444
|
+
.replace(/\\/g, '\\\\')
|
|
1445
|
+
.replace(/\|/g, '\\|')
|
|
1446
|
+
.replace(/\n/g, '\\n')
|
|
1447
|
+
.replace(/\r/g, '\\r')
|
|
1448
|
+
.replace(/\t/g, '\\t')
|
|
1449
|
+
.replace(/\u0008/g, '\\b')
|
|
1450
|
+
.replace(/\f/g, '\\f');
|
|
1451
|
+
return `|${text}|`;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1427
1454
|
function renderDiagnosticText(errors, options = {}) {
|
|
1428
1455
|
if (!Array.isArray(errors) || errors.length === 0) return '(no diagnostics)';
|
|
1429
1456
|
const lines = [];
|
|
@@ -1534,6 +1561,7 @@ function semanticTypeFromRepresentationKind(kind) {
|
|
|
1534
1561
|
case 'radix':
|
|
1535
1562
|
case 'encoding':
|
|
1536
1563
|
case 'separator':
|
|
1564
|
+
case 'symbol':
|
|
1537
1565
|
case 'sansa':
|
|
1538
1566
|
case 'date':
|
|
1539
1567
|
case 'time':
|
|
@@ -1574,6 +1602,7 @@ function representationKindFromName(name, { allowUnknown = false } = {}) {
|
|
|
1574
1602
|
if (base === 'infinity') return 'infinity';
|
|
1575
1603
|
if (base === 'null') return 'null';
|
|
1576
1604
|
if (base === 'sep' || base === 'separator' || base === 'kadot') return 'separator';
|
|
1605
|
+
if (base === 'symbol' || lowered === 'symbolicliteral') return 'symbol';
|
|
1577
1606
|
if (base === 'sansa') return 'sansa';
|
|
1578
1607
|
if (base === 'encoding' || ['base64', 'embed', 'inline'].includes(base)) return 'encoding';
|
|
1579
1608
|
if (['date', 'time', 'datetime', 'wtc'].includes(base)) return base;
|
|
@@ -378,7 +378,7 @@ export const queryExampleGroups = [
|
|
|
378
378
|
),
|
|
379
379
|
expected: {
|
|
380
380
|
ok: true,
|
|
381
|
-
count:
|
|
381
|
+
count: 23,
|
|
382
382
|
includes: '$.types.selector = $.inventory.items.*.sku',
|
|
383
383
|
},
|
|
384
384
|
},
|
|
@@ -459,6 +459,49 @@ export const queryExampleGroups = [
|
|
|
459
459
|
includes: '$.parts[1].value = "part-2"',
|
|
460
460
|
},
|
|
461
461
|
},
|
|
462
|
+
{
|
|
463
|
+
name: 'profileRadixNumericEquality',
|
|
464
|
+
label: 'Radix numeric equality',
|
|
465
|
+
valueSemantics: 'aeon.value.radix.numeric.same-base.v1',
|
|
466
|
+
query: lines(
|
|
467
|
+
'from $.prices.display',
|
|
468
|
+
'where . == %19.99',
|
|
469
|
+
'select .',
|
|
470
|
+
),
|
|
471
|
+
expected: {
|
|
472
|
+
ok: true,
|
|
473
|
+
count: 1,
|
|
474
|
+
includes: '$.prices.display = %19.9900',
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
name: 'profileCrossBaseRadixEquality',
|
|
479
|
+
label: 'Cross-base radix equality',
|
|
480
|
+
valueSemantics: 'aeon.value.radix.numeric.cross-base.v1',
|
|
481
|
+
query: lines(
|
|
482
|
+
'from $.prices.binaryTwo',
|
|
483
|
+
'where . == $.prices.decimalTwo',
|
|
484
|
+
'select .',
|
|
485
|
+
),
|
|
486
|
+
expected: {
|
|
487
|
+
ok: true,
|
|
488
|
+
count: 1,
|
|
489
|
+
includes: '$.prices.binaryTwo = %10',
|
|
490
|
+
},
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
name: 'radixFractionalScale',
|
|
494
|
+
label: 'Radix fractional scale',
|
|
495
|
+
query: lines(
|
|
496
|
+
'from $.prices.display',
|
|
497
|
+
'select { value = . scale = radixScale(.) }',
|
|
498
|
+
),
|
|
499
|
+
expected: {
|
|
500
|
+
ok: true,
|
|
501
|
+
count: 1,
|
|
502
|
+
includes: '"scale":4',
|
|
503
|
+
},
|
|
504
|
+
},
|
|
462
505
|
],
|
|
463
506
|
},
|
|
464
507
|
{
|
|
@@ -95,6 +95,8 @@
|
|
|
95
95
|
<option value="aeon.value.string.codepoint.v1">Codepoint</option>
|
|
96
96
|
<option value="aeon.value.string.natural.ascii.v1">Natural ASCII</option>
|
|
97
97
|
<option value="aeon.value.string.locale.fr.v1">French</option>
|
|
98
|
+
<option value="aeon.value.radix.numeric.same-base.v1">Radix numeric</option>
|
|
99
|
+
<option value="aeon.value.radix.numeric.cross-base.v1">Radix cross-base</option>
|
|
98
100
|
</select>
|
|
99
101
|
</div>
|
|
100
102
|
|
|
@@ -2,7 +2,7 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { dirname, isAbsolute, relative, resolve as resolvePath, sep } from 'node:path';
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
5
|
-
import { evaluateQuery, parseAddress, parseQuery } from '../../src/index.js';
|
|
5
|
+
import { evaluateQuery, parseAddress, parseQuery, radixScaleOf } from '../../src/index.js';
|
|
6
6
|
|
|
7
7
|
const devAeonCoreUrl = new URL('../../../aeon/implementations/typescript/packages/core/dist/index.js', import.meta.url);
|
|
8
8
|
const devAeonAesUrl = new URL('../../../aeon/implementations/typescript/packages/aes/dist/index.js', import.meta.url);
|
|
@@ -708,6 +708,12 @@ function buildNamespaceFromEvents(events, formatPath) {
|
|
|
708
708
|
if (event.value?.type === 'NodeLiteral' && typeof event.value.tag === 'string') binding.nodeTag = event.value.tag;
|
|
709
709
|
const nullReason = nullReasonFromValue(event.value);
|
|
710
710
|
if (nullReason !== undefined) binding.nullReason = nullReason;
|
|
711
|
+
const numericLexeme = numericLexemeFromAeonValue(event.value);
|
|
712
|
+
if (numericLexeme !== undefined) binding.numericLexeme = numericLexeme;
|
|
713
|
+
const radixBase = radixBaseFromAeonValue(event.value, binding.semanticType);
|
|
714
|
+
if (radixBase !== undefined) binding.radixBase = radixBase;
|
|
715
|
+
const radixScale = radixScaleFromAeonValue(event.value, radixBase);
|
|
716
|
+
if (radixScale !== undefined) binding.radixScale = radixScale;
|
|
711
717
|
|
|
712
718
|
const scalar = scalarFromAeonValue(event.value);
|
|
713
719
|
if (scalar.ok) binding.value = scalar.value;
|
|
@@ -761,6 +767,12 @@ function buildAttributeSpace(ownerAddress, annotations, parents, parent) {
|
|
|
761
767
|
binding.scalarKind = scalarKindFromValue(entry.value, binding.semanticType);
|
|
762
768
|
const nullReason = nullReasonFromValue(entry.value);
|
|
763
769
|
if (nullReason !== undefined) binding.nullReason = nullReason;
|
|
770
|
+
const numericLexeme = numericLexemeFromAeonValue(entry.value);
|
|
771
|
+
if (numericLexeme !== undefined) binding.numericLexeme = numericLexeme;
|
|
772
|
+
const radixBase = radixBaseFromAeonValue(entry.value, binding.semanticType);
|
|
773
|
+
if (radixBase !== undefined) binding.radixBase = radixBase;
|
|
774
|
+
const radixScale = radixScaleFromAeonValue(entry.value, radixBase);
|
|
775
|
+
if (radixScale !== undefined) binding.radixScale = radixScale;
|
|
764
776
|
const scalar = scalarFromAeonValue(entry.value);
|
|
765
777
|
if (scalar.ok) binding.value = scalar.value;
|
|
766
778
|
if (entry.annotations?.size) {
|
|
@@ -877,6 +889,15 @@ function portableBinding(record, finalSelector) {
|
|
|
877
889
|
};
|
|
878
890
|
const scalarKind = portableScalarKind(record.kind);
|
|
879
891
|
if (scalarKind !== undefined) binding.scalarKind = scalarKind;
|
|
892
|
+
if (record.kind === 'NumberLiteral' && typeof record.value === 'string') {
|
|
893
|
+
binding.numericLexeme = record.value;
|
|
894
|
+
}
|
|
895
|
+
const radixBase = radixBaseFromPortableRecord(record);
|
|
896
|
+
if (radixBase !== undefined) binding.radixBase = radixBase;
|
|
897
|
+
if (record.kind === 'RadixLiteral' && typeof record.value === 'string') {
|
|
898
|
+
const radixScale = radixScaleOf(record.value, radixBase);
|
|
899
|
+
if (radixScale !== null) binding.radixScale = radixScale;
|
|
900
|
+
}
|
|
880
901
|
const scalar = scalarFromPortableRecord(record);
|
|
881
902
|
if (scalar.ok) binding.value = scalar.value;
|
|
882
903
|
if (record.kind === 'NullLiteral') binding.nullReason = record.value;
|
|
@@ -897,6 +918,7 @@ function portableSemanticType(kind) {
|
|
|
897
918
|
case 'RadixLiteral': return 'radix';
|
|
898
919
|
case 'EncodingLiteral': return 'encoding';
|
|
899
920
|
case 'SeparatorLiteral': return 'sep';
|
|
921
|
+
case 'SymbolicLiteral': return 'symbol';
|
|
900
922
|
case 'SansaAddressLiteral': return 'sansa';
|
|
901
923
|
case 'DateLiteral': return 'date';
|
|
902
924
|
case 'TimeLiteral': return 'time';
|
|
@@ -908,6 +930,7 @@ function portableSemanticType(kind) {
|
|
|
908
930
|
|
|
909
931
|
function portableScalarKind(kind) {
|
|
910
932
|
switch (kind) {
|
|
933
|
+
case 'NumberLiteral': return 'number';
|
|
911
934
|
case 'NullLiteral': return 'null';
|
|
912
935
|
case 'InfinityLiteral': return 'infinity';
|
|
913
936
|
case 'NaNLiteral': return 'nan';
|
|
@@ -916,6 +939,7 @@ function portableScalarKind(kind) {
|
|
|
916
939
|
case 'RadixLiteral': return 'radix';
|
|
917
940
|
case 'EncodingLiteral': return 'encoding';
|
|
918
941
|
case 'SeparatorLiteral': return 'separator';
|
|
942
|
+
case 'SymbolicLiteral': return 'symbol';
|
|
919
943
|
case 'SansaAddressLiteral': return 'sansaAddress';
|
|
920
944
|
case 'DateLiteral': return 'date';
|
|
921
945
|
case 'TimeLiteral': return 'time';
|
|
@@ -942,6 +966,7 @@ function portableRepresentationAlias(kind) {
|
|
|
942
966
|
case 'RadixLiteral': return 'radix';
|
|
943
967
|
case 'EncodingLiteral': return 'encoding';
|
|
944
968
|
case 'SeparatorLiteral': return 'separator';
|
|
969
|
+
case 'SymbolicLiteral': return 'symbol';
|
|
945
970
|
case 'SansaAddressLiteral': return 'sansa';
|
|
946
971
|
case 'DateLiteral': return 'date';
|
|
947
972
|
case 'TimeLiteral': return 'time';
|
|
@@ -964,6 +989,7 @@ function scalarFromPortableRecord(record) {
|
|
|
964
989
|
case 'RadixLiteral':
|
|
965
990
|
case 'EncodingLiteral':
|
|
966
991
|
case 'SeparatorLiteral':
|
|
992
|
+
case 'SymbolicLiteral':
|
|
967
993
|
case 'DateLiteral':
|
|
968
994
|
case 'TimeLiteral':
|
|
969
995
|
case 'DateTimeLiteral':
|
|
@@ -980,7 +1006,7 @@ function scalarFromPortableRecord(record) {
|
|
|
980
1006
|
},
|
|
981
1007
|
};
|
|
982
1008
|
case 'NumberLiteral':
|
|
983
|
-
return { ok: true, value:
|
|
1009
|
+
return { ok: true, value: record.value ?? '' };
|
|
984
1010
|
case 'InfinityLiteral':
|
|
985
1011
|
return { ok: true, value: record.value === '-Infinity' ? -Infinity : Infinity };
|
|
986
1012
|
case 'NaNLiteral':
|
|
@@ -1032,6 +1058,8 @@ function semanticTypeFromValue(value) {
|
|
|
1032
1058
|
return 'encoding';
|
|
1033
1059
|
case 'SeparatorLiteral':
|
|
1034
1060
|
return 'sep';
|
|
1061
|
+
case 'SymbolicLiteral':
|
|
1062
|
+
return 'symbol';
|
|
1035
1063
|
case 'DateLiteral':
|
|
1036
1064
|
return 'date';
|
|
1037
1065
|
case 'TimeLiteral':
|
|
@@ -1072,6 +1100,8 @@ function representationKindFromValue(value, semanticType) {
|
|
|
1072
1100
|
return 'encoding';
|
|
1073
1101
|
case 'SeparatorLiteral':
|
|
1074
1102
|
return 'separator';
|
|
1103
|
+
case 'SymbolicLiteral':
|
|
1104
|
+
return 'symbol';
|
|
1075
1105
|
case 'SansaAddressLiteral':
|
|
1076
1106
|
return 'sansa';
|
|
1077
1107
|
case 'NumberLiteral':
|
|
@@ -1107,6 +1137,7 @@ function scalarFromAeonValue(value) {
|
|
|
1107
1137
|
case 'RadixLiteral':
|
|
1108
1138
|
case 'EncodingLiteral':
|
|
1109
1139
|
case 'SeparatorLiteral':
|
|
1140
|
+
case 'SymbolicLiteral':
|
|
1110
1141
|
return { ok: true, value: value.value };
|
|
1111
1142
|
case 'SansaAddressLiteral':
|
|
1112
1143
|
return {
|
|
@@ -1118,7 +1149,7 @@ function scalarFromAeonValue(value) {
|
|
|
1118
1149
|
},
|
|
1119
1150
|
};
|
|
1120
1151
|
case 'NumberLiteral':
|
|
1121
|
-
return { ok: true, value:
|
|
1152
|
+
return { ok: true, value: value.value };
|
|
1122
1153
|
case 'InfinityLiteral':
|
|
1123
1154
|
return { ok: true, value: value.value === '-Infinity' ? -Infinity : Infinity };
|
|
1124
1155
|
case 'NaNLiteral':
|
|
@@ -1138,6 +1169,45 @@ function scalarFromAeonValue(value) {
|
|
|
1138
1169
|
}
|
|
1139
1170
|
}
|
|
1140
1171
|
|
|
1172
|
+
function numericLexemeFromAeonValue(value) {
|
|
1173
|
+
if (value.type === 'TypedValue') return numericLexemeFromAeonValue(value.value);
|
|
1174
|
+
return value.type === 'NumberLiteral' ? value.value : undefined;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
function radixBaseFromAeonValue(value, semanticType) {
|
|
1178
|
+
if (value.type === 'TypedValue') return radixBaseFromAeonValue(value.value, semanticType ?? value.datatype);
|
|
1179
|
+
return value.type === 'RadixLiteral' ? radixBaseFromSemanticType(semanticType) : undefined;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
function radixScaleFromAeonValue(value, radixBase) {
|
|
1183
|
+
if (value.type === 'TypedValue') return radixScaleFromAeonValue(value.value, radixBase);
|
|
1184
|
+
if (value.type !== 'RadixLiteral') return undefined;
|
|
1185
|
+
return radixScaleOf(value.value, radixBase) ?? undefined;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
function radixBaseFromPortableRecord(record) {
|
|
1189
|
+
if (record.kind !== 'RadixLiteral') return undefined;
|
|
1190
|
+
const fromType = radixBaseFromSemanticType(record.datatype);
|
|
1191
|
+
if (fromType !== undefined) return fromType;
|
|
1192
|
+
if (record.datatype !== 'radix' || !Array.isArray(record.clarifiers) || record.clarifiers.length !== 1) return undefined;
|
|
1193
|
+
const clarifier = record.clarifiers[0];
|
|
1194
|
+
if (clarifier?.kind !== 'NumberLiteral') return undefined;
|
|
1195
|
+
const base = Number(clarifier.value);
|
|
1196
|
+
return Number.isInteger(base) && base >= 2 && base <= 64 ? base : undefined;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
function radixBaseFromSemanticType(semanticType) {
|
|
1200
|
+
if (typeof semanticType !== 'string') return undefined;
|
|
1201
|
+
const normalized = semanticType.trim().toLowerCase();
|
|
1202
|
+
if (normalized === 'decimal') return 10;
|
|
1203
|
+
const alias = /^radix(2|6|8|12)$/u.exec(normalized);
|
|
1204
|
+
if (alias !== null) return Number(alias[1]);
|
|
1205
|
+
const clarified = /^radix\[(\d+)\]$/u.exec(normalized);
|
|
1206
|
+
if (clarified === null) return undefined;
|
|
1207
|
+
const base = Number(clarified[1]);
|
|
1208
|
+
return Number.isInteger(base) && base >= 2 && base <= 64 ? base : undefined;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1141
1211
|
function scalarKindFromValue(value, semanticType) {
|
|
1142
1212
|
switch (value.type) {
|
|
1143
1213
|
case 'TypedValue':
|
|
@@ -1158,8 +1228,12 @@ function scalarKindFromValue(value, semanticType) {
|
|
|
1158
1228
|
return 'encoding';
|
|
1159
1229
|
case 'SeparatorLiteral':
|
|
1160
1230
|
return 'separator';
|
|
1231
|
+
case 'SymbolicLiteral':
|
|
1232
|
+
return 'symbol';
|
|
1161
1233
|
case 'SansaAddressLiteral':
|
|
1162
1234
|
return 'sansaAddress';
|
|
1235
|
+
case 'NumberLiteral':
|
|
1236
|
+
return 'number';
|
|
1163
1237
|
case 'DateLiteral':
|
|
1164
1238
|
return 'date';
|
|
1165
1239
|
case 'DateTimeLiteral':
|
|
@@ -1283,8 +1357,10 @@ function renderAeonValue(value, metadata, fieldMetadata) {
|
|
|
1283
1357
|
if (value === null) return 'null';
|
|
1284
1358
|
if (metadata?.kind === 'hex') return `#${value}`;
|
|
1285
1359
|
if (metadata?.kind === 'radix') return `%${value}`;
|
|
1360
|
+
if (metadata?.kind === 'number') return metadata.numericLexeme ?? String(value);
|
|
1286
1361
|
if (metadata?.kind === 'encoding') return `&${value}`;
|
|
1287
1362
|
if (metadata?.kind === 'separator') return `^${value}`;
|
|
1363
|
+
if (metadata?.kind === 'symbol') return renderSymbolLiteral(value);
|
|
1288
1364
|
if (['date', 'time', 'datetime', 'wtc'].includes(metadata?.kind)) return String(value);
|
|
1289
1365
|
if (metadata?.kind === 'sansaAddress' || metadata?.kind === 'sansa') {
|
|
1290
1366
|
return value?.canonical ?? value?.address?.canonical ?? value?.address ?? String(value);
|
|
@@ -1311,6 +1387,9 @@ function scalarMetadataFromBinding(binding) {
|
|
|
1311
1387
|
const kind = binding.scalarKind ?? binding.valueKind ?? binding.literalKind ?? binding.representationKind ?? binding.kind ?? binding.type;
|
|
1312
1388
|
if (typeof kind === 'string') metadata.kind = lowerFirst(kind);
|
|
1313
1389
|
if (binding.nullReason !== undefined) metadata.nullReason = binding.nullReason;
|
|
1390
|
+
if (binding.numericLexeme !== undefined) metadata.numericLexeme = binding.numericLexeme;
|
|
1391
|
+
if (binding.radixBase !== undefined) metadata.radixBase = binding.radixBase;
|
|
1392
|
+
if (binding.radixScale !== undefined) metadata.radixScale = binding.radixScale;
|
|
1314
1393
|
return Object.keys(metadata).length > 0 ? metadata : undefined;
|
|
1315
1394
|
}
|
|
1316
1395
|
|
|
@@ -1318,6 +1397,18 @@ function lowerFirst(value) {
|
|
|
1318
1397
|
return value ? value[0].toLowerCase() + value.slice(1) : value;
|
|
1319
1398
|
}
|
|
1320
1399
|
|
|
1400
|
+
function renderSymbolLiteral(value) {
|
|
1401
|
+
const text = String(value ?? '')
|
|
1402
|
+
.replace(/\\/g, '\\\\')
|
|
1403
|
+
.replace(/\|/g, '\\|')
|
|
1404
|
+
.replace(/\n/g, '\\n')
|
|
1405
|
+
.replace(/\r/g, '\\r')
|
|
1406
|
+
.replace(/\t/g, '\\t')
|
|
1407
|
+
.replace(/\u0008/g, '\\b')
|
|
1408
|
+
.replace(/\f/g, '\\f');
|
|
1409
|
+
return `|${text}|`;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1321
1412
|
function renderQueryValueInspectLines(value) {
|
|
1322
1413
|
switch (value.type) {
|
|
1323
1414
|
case 'scalar':
|
|
@@ -1402,6 +1493,9 @@ function summarizeBinding(binding) {
|
|
|
1402
1493
|
...(binding.representationKind === undefined ? {} : { representationKind: binding.representationKind }),
|
|
1403
1494
|
...(binding.scalarKind === undefined ? {} : { scalarKind: binding.scalarKind }),
|
|
1404
1495
|
...(binding.nullReason === undefined ? {} : { nullReason: binding.nullReason }),
|
|
1496
|
+
...(binding.numericLexeme === undefined ? {} : { numericLexeme: binding.numericLexeme }),
|
|
1497
|
+
...(binding.radixBase === undefined ? {} : { radixBase: binding.radixBase }),
|
|
1498
|
+
...(binding.radixScale === undefined ? {} : { radixScale: binding.radixScale }),
|
|
1405
1499
|
...(scalar.ok ? { value: sanitizeJsonValue(scalar.value) } : {}),
|
|
1406
1500
|
};
|
|
1407
1501
|
}
|