@altopelago/sansa 0.11.0 → 0.12.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 +80 -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 +11 -8
- package/fixtures/query-inventory.aeon +7 -0
- package/fixtures/query-inventory.telex.aes +5 -0
- package/package.json +1 -1
- package/scripts/cts-value-semantics.mjs +1 -1
- package/scripts/query.mjs +17 -0
- package/src/index.d.ts +79 -4
- package/src/index.js +942 -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 +176 -13
|
@@ -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
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { resolve as resolvePath } from 'node:path';
|
|
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);
|
|
@@ -509,13 +509,12 @@ function aeonCoreCandidates() {
|
|
|
509
509
|
});
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
-
|
|
512
|
+
const installed = resolvePackageImportFromCwd('@altopelago/aeon-core');
|
|
513
|
+
if (installed) {
|
|
513
514
|
candidates.push({
|
|
514
515
|
label: '@altopelago/aeon-core',
|
|
515
|
-
href:
|
|
516
|
+
href: installed,
|
|
516
517
|
});
|
|
517
|
-
} catch {
|
|
518
|
-
// Optional integration. JSON fixtures and pure Query parsing do not need AEON Core.
|
|
519
518
|
}
|
|
520
519
|
|
|
521
520
|
const devPath = fileURLToPath(devAeonCoreUrl);
|
|
@@ -538,13 +537,12 @@ function aeonAesCandidates() {
|
|
|
538
537
|
});
|
|
539
538
|
}
|
|
540
539
|
|
|
541
|
-
|
|
540
|
+
const installed = resolvePackageImportFromCwd('@altopelago/aeon-aes');
|
|
541
|
+
if (installed) {
|
|
542
542
|
candidates.push({
|
|
543
543
|
label: '@altopelago/aeon-aes',
|
|
544
|
-
href:
|
|
544
|
+
href: installed,
|
|
545
545
|
});
|
|
546
|
-
} catch {
|
|
547
|
-
// Optional integration. AEON and JSON sources do not need the AES codec.
|
|
548
546
|
}
|
|
549
547
|
|
|
550
548
|
const devPath = fileURLToPath(devAeonAesUrl);
|
|
@@ -558,6 +556,77 @@ function aeonAesCandidates() {
|
|
|
558
556
|
return candidates;
|
|
559
557
|
}
|
|
560
558
|
|
|
559
|
+
function resolvePackageImportFromCwd(packageName) {
|
|
560
|
+
try {
|
|
561
|
+
return pathToFileURL(requireFromCwd.resolve(packageName)).href;
|
|
562
|
+
} catch {
|
|
563
|
+
// Import-only packages have no `require` export. Resolve their ESM entry
|
|
564
|
+
// from the calling project's node_modules tree instead.
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
const packageParts = packageName.split('/');
|
|
568
|
+
let directory = resolvePath(process.cwd());
|
|
569
|
+
while (true) {
|
|
570
|
+
const packageRoot = resolvePath(directory, 'node_modules', ...packageParts);
|
|
571
|
+
const manifestPath = resolvePath(packageRoot, 'package.json');
|
|
572
|
+
if (existsSync(manifestPath)) {
|
|
573
|
+
try {
|
|
574
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
575
|
+
const target = packageImportTarget(manifest);
|
|
576
|
+
if (typeof target !== 'string' || !target.startsWith('./')) return undefined;
|
|
577
|
+
const entryPath = resolvePath(packageRoot, target);
|
|
578
|
+
const relativeEntry = relative(packageRoot, entryPath);
|
|
579
|
+
if (!relativeEntry
|
|
580
|
+
|| relativeEntry === '..'
|
|
581
|
+
|| relativeEntry.startsWith(`..${sep}`)
|
|
582
|
+
|| isAbsolute(relativeEntry)
|
|
583
|
+
|| !existsSync(entryPath)) {
|
|
584
|
+
return undefined;
|
|
585
|
+
}
|
|
586
|
+
return pathToFileURL(entryPath).href;
|
|
587
|
+
} catch {
|
|
588
|
+
return undefined;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const parent = dirname(directory);
|
|
593
|
+
if (parent === directory) return undefined;
|
|
594
|
+
directory = parent;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function packageImportTarget(manifest) {
|
|
599
|
+
if (Object.hasOwn(manifest ?? {}, 'exports')) {
|
|
600
|
+
let target = manifest.exports;
|
|
601
|
+
if (target && typeof target === 'object' && !Array.isArray(target)) {
|
|
602
|
+
const keys = Object.keys(target);
|
|
603
|
+
if (keys.some((key) => key.startsWith('.'))) target = target['.'];
|
|
604
|
+
}
|
|
605
|
+
return conditionalImportTarget(target);
|
|
606
|
+
}
|
|
607
|
+
if (typeof manifest?.module === 'string') return manifest.module;
|
|
608
|
+
if (typeof manifest?.main === 'string') return manifest.main;
|
|
609
|
+
return undefined;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function conditionalImportTarget(target) {
|
|
613
|
+
if (typeof target === 'string') return target;
|
|
614
|
+
if (Array.isArray(target)) {
|
|
615
|
+
for (const candidate of target) {
|
|
616
|
+
const resolved = conditionalImportTarget(candidate);
|
|
617
|
+
if (resolved) return resolved;
|
|
618
|
+
}
|
|
619
|
+
return undefined;
|
|
620
|
+
}
|
|
621
|
+
if (!target || typeof target !== 'object') return undefined;
|
|
622
|
+
for (const [condition, candidate] of Object.entries(target)) {
|
|
623
|
+
if (!['node', 'import', 'default'].includes(condition)) continue;
|
|
624
|
+
const resolved = conditionalImportTarget(candidate);
|
|
625
|
+
if (resolved) return resolved;
|
|
626
|
+
}
|
|
627
|
+
return undefined;
|
|
628
|
+
}
|
|
629
|
+
|
|
561
630
|
function moduleHref(specifier) {
|
|
562
631
|
if (specifier.startsWith('file:')) return specifier;
|
|
563
632
|
if (specifier.startsWith('.') || specifier.startsWith('/')) {
|
|
@@ -639,6 +708,12 @@ function buildNamespaceFromEvents(events, formatPath) {
|
|
|
639
708
|
if (event.value?.type === 'NodeLiteral' && typeof event.value.tag === 'string') binding.nodeTag = event.value.tag;
|
|
640
709
|
const nullReason = nullReasonFromValue(event.value);
|
|
641
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;
|
|
642
717
|
|
|
643
718
|
const scalar = scalarFromAeonValue(event.value);
|
|
644
719
|
if (scalar.ok) binding.value = scalar.value;
|
|
@@ -692,6 +767,12 @@ function buildAttributeSpace(ownerAddress, annotations, parents, parent) {
|
|
|
692
767
|
binding.scalarKind = scalarKindFromValue(entry.value, binding.semanticType);
|
|
693
768
|
const nullReason = nullReasonFromValue(entry.value);
|
|
694
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;
|
|
695
776
|
const scalar = scalarFromAeonValue(entry.value);
|
|
696
777
|
if (scalar.ok) binding.value = scalar.value;
|
|
697
778
|
if (entry.annotations?.size) {
|
|
@@ -808,6 +889,15 @@ function portableBinding(record, finalSelector) {
|
|
|
808
889
|
};
|
|
809
890
|
const scalarKind = portableScalarKind(record.kind);
|
|
810
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
|
+
}
|
|
811
901
|
const scalar = scalarFromPortableRecord(record);
|
|
812
902
|
if (scalar.ok) binding.value = scalar.value;
|
|
813
903
|
if (record.kind === 'NullLiteral') binding.nullReason = record.value;
|
|
@@ -828,6 +918,7 @@ function portableSemanticType(kind) {
|
|
|
828
918
|
case 'RadixLiteral': return 'radix';
|
|
829
919
|
case 'EncodingLiteral': return 'encoding';
|
|
830
920
|
case 'SeparatorLiteral': return 'sep';
|
|
921
|
+
case 'SymbolicLiteral': return 'symbol';
|
|
831
922
|
case 'SansaAddressLiteral': return 'sansa';
|
|
832
923
|
case 'DateLiteral': return 'date';
|
|
833
924
|
case 'TimeLiteral': return 'time';
|
|
@@ -839,6 +930,7 @@ function portableSemanticType(kind) {
|
|
|
839
930
|
|
|
840
931
|
function portableScalarKind(kind) {
|
|
841
932
|
switch (kind) {
|
|
933
|
+
case 'NumberLiteral': return 'number';
|
|
842
934
|
case 'NullLiteral': return 'null';
|
|
843
935
|
case 'InfinityLiteral': return 'infinity';
|
|
844
936
|
case 'NaNLiteral': return 'nan';
|
|
@@ -847,6 +939,7 @@ function portableScalarKind(kind) {
|
|
|
847
939
|
case 'RadixLiteral': return 'radix';
|
|
848
940
|
case 'EncodingLiteral': return 'encoding';
|
|
849
941
|
case 'SeparatorLiteral': return 'separator';
|
|
942
|
+
case 'SymbolicLiteral': return 'symbol';
|
|
850
943
|
case 'SansaAddressLiteral': return 'sansaAddress';
|
|
851
944
|
case 'DateLiteral': return 'date';
|
|
852
945
|
case 'TimeLiteral': return 'time';
|
|
@@ -873,6 +966,7 @@ function portableRepresentationAlias(kind) {
|
|
|
873
966
|
case 'RadixLiteral': return 'radix';
|
|
874
967
|
case 'EncodingLiteral': return 'encoding';
|
|
875
968
|
case 'SeparatorLiteral': return 'separator';
|
|
969
|
+
case 'SymbolicLiteral': return 'symbol';
|
|
876
970
|
case 'SansaAddressLiteral': return 'sansa';
|
|
877
971
|
case 'DateLiteral': return 'date';
|
|
878
972
|
case 'TimeLiteral': return 'time';
|
|
@@ -895,6 +989,7 @@ function scalarFromPortableRecord(record) {
|
|
|
895
989
|
case 'RadixLiteral':
|
|
896
990
|
case 'EncodingLiteral':
|
|
897
991
|
case 'SeparatorLiteral':
|
|
992
|
+
case 'SymbolicLiteral':
|
|
898
993
|
case 'DateLiteral':
|
|
899
994
|
case 'TimeLiteral':
|
|
900
995
|
case 'DateTimeLiteral':
|
|
@@ -911,7 +1006,7 @@ function scalarFromPortableRecord(record) {
|
|
|
911
1006
|
},
|
|
912
1007
|
};
|
|
913
1008
|
case 'NumberLiteral':
|
|
914
|
-
return { ok: true, value:
|
|
1009
|
+
return { ok: true, value: record.value ?? '' };
|
|
915
1010
|
case 'InfinityLiteral':
|
|
916
1011
|
return { ok: true, value: record.value === '-Infinity' ? -Infinity : Infinity };
|
|
917
1012
|
case 'NaNLiteral':
|
|
@@ -963,6 +1058,8 @@ function semanticTypeFromValue(value) {
|
|
|
963
1058
|
return 'encoding';
|
|
964
1059
|
case 'SeparatorLiteral':
|
|
965
1060
|
return 'sep';
|
|
1061
|
+
case 'SymbolicLiteral':
|
|
1062
|
+
return 'symbol';
|
|
966
1063
|
case 'DateLiteral':
|
|
967
1064
|
return 'date';
|
|
968
1065
|
case 'TimeLiteral':
|
|
@@ -1003,6 +1100,8 @@ function representationKindFromValue(value, semanticType) {
|
|
|
1003
1100
|
return 'encoding';
|
|
1004
1101
|
case 'SeparatorLiteral':
|
|
1005
1102
|
return 'separator';
|
|
1103
|
+
case 'SymbolicLiteral':
|
|
1104
|
+
return 'symbol';
|
|
1006
1105
|
case 'SansaAddressLiteral':
|
|
1007
1106
|
return 'sansa';
|
|
1008
1107
|
case 'NumberLiteral':
|
|
@@ -1038,6 +1137,7 @@ function scalarFromAeonValue(value) {
|
|
|
1038
1137
|
case 'RadixLiteral':
|
|
1039
1138
|
case 'EncodingLiteral':
|
|
1040
1139
|
case 'SeparatorLiteral':
|
|
1140
|
+
case 'SymbolicLiteral':
|
|
1041
1141
|
return { ok: true, value: value.value };
|
|
1042
1142
|
case 'SansaAddressLiteral':
|
|
1043
1143
|
return {
|
|
@@ -1049,7 +1149,7 @@ function scalarFromAeonValue(value) {
|
|
|
1049
1149
|
},
|
|
1050
1150
|
};
|
|
1051
1151
|
case 'NumberLiteral':
|
|
1052
|
-
return { ok: true, value:
|
|
1152
|
+
return { ok: true, value: value.value };
|
|
1053
1153
|
case 'InfinityLiteral':
|
|
1054
1154
|
return { ok: true, value: value.value === '-Infinity' ? -Infinity : Infinity };
|
|
1055
1155
|
case 'NaNLiteral':
|
|
@@ -1069,6 +1169,45 @@ function scalarFromAeonValue(value) {
|
|
|
1069
1169
|
}
|
|
1070
1170
|
}
|
|
1071
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
|
+
|
|
1072
1211
|
function scalarKindFromValue(value, semanticType) {
|
|
1073
1212
|
switch (value.type) {
|
|
1074
1213
|
case 'TypedValue':
|
|
@@ -1089,8 +1228,12 @@ function scalarKindFromValue(value, semanticType) {
|
|
|
1089
1228
|
return 'encoding';
|
|
1090
1229
|
case 'SeparatorLiteral':
|
|
1091
1230
|
return 'separator';
|
|
1231
|
+
case 'SymbolicLiteral':
|
|
1232
|
+
return 'symbol';
|
|
1092
1233
|
case 'SansaAddressLiteral':
|
|
1093
1234
|
return 'sansaAddress';
|
|
1235
|
+
case 'NumberLiteral':
|
|
1236
|
+
return 'number';
|
|
1094
1237
|
case 'DateLiteral':
|
|
1095
1238
|
return 'date';
|
|
1096
1239
|
case 'DateTimeLiteral':
|
|
@@ -1214,8 +1357,10 @@ function renderAeonValue(value, metadata, fieldMetadata) {
|
|
|
1214
1357
|
if (value === null) return 'null';
|
|
1215
1358
|
if (metadata?.kind === 'hex') return `#${value}`;
|
|
1216
1359
|
if (metadata?.kind === 'radix') return `%${value}`;
|
|
1360
|
+
if (metadata?.kind === 'number') return metadata.numericLexeme ?? String(value);
|
|
1217
1361
|
if (metadata?.kind === 'encoding') return `&${value}`;
|
|
1218
1362
|
if (metadata?.kind === 'separator') return `^${value}`;
|
|
1363
|
+
if (metadata?.kind === 'symbol') return renderSymbolLiteral(value);
|
|
1219
1364
|
if (['date', 'time', 'datetime', 'wtc'].includes(metadata?.kind)) return String(value);
|
|
1220
1365
|
if (metadata?.kind === 'sansaAddress' || metadata?.kind === 'sansa') {
|
|
1221
1366
|
return value?.canonical ?? value?.address?.canonical ?? value?.address ?? String(value);
|
|
@@ -1242,6 +1387,9 @@ function scalarMetadataFromBinding(binding) {
|
|
|
1242
1387
|
const kind = binding.scalarKind ?? binding.valueKind ?? binding.literalKind ?? binding.representationKind ?? binding.kind ?? binding.type;
|
|
1243
1388
|
if (typeof kind === 'string') metadata.kind = lowerFirst(kind);
|
|
1244
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;
|
|
1245
1393
|
return Object.keys(metadata).length > 0 ? metadata : undefined;
|
|
1246
1394
|
}
|
|
1247
1395
|
|
|
@@ -1249,6 +1397,18 @@ function lowerFirst(value) {
|
|
|
1249
1397
|
return value ? value[0].toLowerCase() + value.slice(1) : value;
|
|
1250
1398
|
}
|
|
1251
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
|
+
|
|
1252
1412
|
function renderQueryValueInspectLines(value) {
|
|
1253
1413
|
switch (value.type) {
|
|
1254
1414
|
case 'scalar':
|
|
@@ -1333,6 +1493,9 @@ function summarizeBinding(binding) {
|
|
|
1333
1493
|
...(binding.representationKind === undefined ? {} : { representationKind: binding.representationKind }),
|
|
1334
1494
|
...(binding.scalarKind === undefined ? {} : { scalarKind: binding.scalarKind }),
|
|
1335
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 }),
|
|
1336
1499
|
...(scalar.ok ? { value: sanitizeJsonValue(scalar.value) } : {}),
|
|
1337
1500
|
};
|
|
1338
1501
|
}
|