@altopelago/sansa 0.9.0 → 0.10.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 +150 -0
- package/README.md +107 -4
- package/conformance/README.md +19 -0
- package/conformance/cts-claims.json +53 -0
- package/docs/api-contract.md +541 -14
- package/docs/capabilities.json +210 -4
- package/docs/instruction-tool.md +345 -0
- package/docs/mutate-policy.md +148 -0
- package/docs/query-tool.md +123 -11
- package/docs/releasing.md +2 -2
- package/fixtures/address-v1.json +9 -9
- package/fixtures/query-inventory.aeon +65 -3
- package/fixtures/query-inventory.json +194 -3
- package/package.json +9 -2
- package/scripts/cts-instruction.mjs +284 -0
- package/scripts/cts-mutate.mjs +476 -0
- package/scripts/cts-resolve.mjs +9 -0
- package/scripts/instruction.mjs +423 -0
- package/scripts/query-web.mjs +56 -0
- package/scripts/query.mjs +34 -2
- package/scripts/validate-cts-claims.mjs +133 -0
- package/src/index.d.ts +954 -3
- package/src/index.js +5505 -393
- package/stress-tests/address/valid.sansa-cases +3 -3
- package/tools/mutate-web/app.js +370 -0
- package/tools/mutate-web/examples.mjs +1280 -0
- package/tools/mutate-web/index.html +138 -0
- package/tools/mutate-web/runtime.mjs +1308 -0
- package/tools/mutate-web/styles.css +354 -0
- package/tools/query-web/app.js +8 -1
- package/tools/query-web/examples.mjs +131 -5
- package/tools/query-web/index.html +10 -0
- package/tools/query-web/runtime.mjs +100 -9
- package/tools/query-web/styles.css +1 -1
|
@@ -37,6 +37,7 @@ export async function evaluateQueryForWorkbench({
|
|
|
37
37
|
paramsSource = '',
|
|
38
38
|
policy = '',
|
|
39
39
|
transformExtensions = true,
|
|
40
|
+
valueSemantics = '',
|
|
40
41
|
budget = {},
|
|
41
42
|
}) {
|
|
42
43
|
const namespaceResult = sourceKind === 'json'
|
|
@@ -61,8 +62,10 @@ export async function evaluateQueryForWorkbench({
|
|
|
61
62
|
];
|
|
62
63
|
|
|
63
64
|
const options = {
|
|
65
|
+
addressActivation: 'trusted',
|
|
64
66
|
...(policy === 'validation' ? { policy: 'validation' } : {}),
|
|
65
67
|
...(transformExtensions === false ? { extensions: { transform: false } } : {}),
|
|
68
|
+
...(valueSemantics ? { valueSemantics } : {}),
|
|
66
69
|
...queryBudgetOption(budget),
|
|
67
70
|
};
|
|
68
71
|
const result = evaluateQuery(query, mounted.namespace, options);
|
|
@@ -75,6 +78,7 @@ export async function evaluateQueryForWorkbench({
|
|
|
75
78
|
text: renderDiagnosticText(errors),
|
|
76
79
|
errors,
|
|
77
80
|
sourceDiagnostics,
|
|
81
|
+
valueSemantics: valueSemantics || 'default',
|
|
78
82
|
};
|
|
79
83
|
}
|
|
80
84
|
|
|
@@ -85,6 +89,7 @@ export async function evaluateQueryForWorkbench({
|
|
|
85
89
|
count: result.results.length,
|
|
86
90
|
text: renderTextResults(result.results),
|
|
87
91
|
inspect: renderInspectResults(result.results),
|
|
92
|
+
valueSemantics: valueSemantics || 'default',
|
|
88
93
|
results: result.results.map((entry) => ({
|
|
89
94
|
type: entry.type,
|
|
90
95
|
...(entry.address === undefined ? {} : { address: entry.address }),
|
|
@@ -361,8 +366,9 @@ function buildNamespaceFromEvents(events, formatPath) {
|
|
|
361
366
|
if (segment?.type === 'member') binding.name = segment.key;
|
|
362
367
|
if (segment?.type === 'index') binding.index = segment.index;
|
|
363
368
|
binding.semanticType = event.datatype ?? semanticTypeFromValue(event.value);
|
|
364
|
-
binding.representationKind = representationKindFromValue(event.value);
|
|
365
|
-
binding.scalarKind = scalarKindFromValue(event.value);
|
|
369
|
+
binding.representationKind = representationKindFromValue(event.value, binding.semanticType);
|
|
370
|
+
binding.scalarKind = scalarKindFromValue(event.value, binding.semanticType);
|
|
371
|
+
if (event.value?.type === 'NodeLiteral' && typeof event.value.tag === 'string') binding.nodeTag = event.value.tag;
|
|
366
372
|
const nullReason = nullReasonFromValue(event.value);
|
|
367
373
|
if (nullReason !== undefined) binding.nullReason = nullReason;
|
|
368
374
|
|
|
@@ -406,10 +412,10 @@ function buildAttributeSpace(ownerAddress, annotations, parents, parent) {
|
|
|
406
412
|
name,
|
|
407
413
|
address: appendMember(`${ownerAddress}.@`, name),
|
|
408
414
|
semanticType: entry.datatype ?? semanticTypeFromValue(entry.value),
|
|
409
|
-
representationKind: representationKindFromValue(entry.value),
|
|
410
|
-
scalarKind: scalarKindFromValue(entry.value),
|
|
411
415
|
children: [],
|
|
412
416
|
};
|
|
417
|
+
binding.representationKind = representationKindFromValue(entry.value, binding.semanticType);
|
|
418
|
+
binding.scalarKind = scalarKindFromValue(entry.value, binding.semanticType);
|
|
413
419
|
const nullReason = nullReasonFromValue(entry.value);
|
|
414
420
|
if (nullReason !== undefined) binding.nullReason = nullReason;
|
|
415
421
|
const scalar = scalarFromAeonValue(entry.value);
|
|
@@ -431,6 +437,8 @@ function appendMember(base, name) {
|
|
|
431
437
|
|
|
432
438
|
function semanticTypeFromValue(value) {
|
|
433
439
|
switch (value.type) {
|
|
440
|
+
case 'TypedValue':
|
|
441
|
+
return value.datatype ?? semanticTypeFromValue(value.value);
|
|
434
442
|
case 'StringLiteral':
|
|
435
443
|
return 'string';
|
|
436
444
|
case 'NumberLiteral':
|
|
@@ -443,6 +451,22 @@ function semanticTypeFromValue(value) {
|
|
|
443
451
|
return 'boolean';
|
|
444
452
|
case 'NullLiteral':
|
|
445
453
|
return 'null';
|
|
454
|
+
case 'ToggleLiteral':
|
|
455
|
+
return 'toggle';
|
|
456
|
+
case 'HexLiteral':
|
|
457
|
+
return 'hex';
|
|
458
|
+
case 'RadixLiteral':
|
|
459
|
+
return 'radix';
|
|
460
|
+
case 'EncodingLiteral':
|
|
461
|
+
return 'encoding';
|
|
462
|
+
case 'SeparatorLiteral':
|
|
463
|
+
return 'sep';
|
|
464
|
+
case 'DateLiteral':
|
|
465
|
+
return 'date';
|
|
466
|
+
case 'TimeLiteral':
|
|
467
|
+
return 'time';
|
|
468
|
+
case 'DateTimeLiteral':
|
|
469
|
+
return 'datetime';
|
|
446
470
|
case 'SansaAddressLiteral':
|
|
447
471
|
return 'sansa';
|
|
448
472
|
default:
|
|
@@ -450,10 +474,10 @@ function semanticTypeFromValue(value) {
|
|
|
450
474
|
}
|
|
451
475
|
}
|
|
452
476
|
|
|
453
|
-
function representationKindFromValue(value) {
|
|
477
|
+
function representationKindFromValue(value, semanticType) {
|
|
454
478
|
switch (value.type) {
|
|
455
479
|
case 'TypedValue':
|
|
456
|
-
return representationKindFromValue(value.value);
|
|
480
|
+
return representationKindFromValue(value.value, value.datatype ?? semanticType);
|
|
457
481
|
case 'ObjectNode':
|
|
458
482
|
return 'object';
|
|
459
483
|
case 'ListNode':
|
|
@@ -463,15 +487,22 @@ function representationKindFromValue(value) {
|
|
|
463
487
|
case 'NodeLiteral':
|
|
464
488
|
return 'node';
|
|
465
489
|
case 'StringLiteral':
|
|
490
|
+
return 'string';
|
|
466
491
|
case 'DateLiteral':
|
|
492
|
+
return 'date';
|
|
467
493
|
case 'DateTimeLiteral':
|
|
468
494
|
case 'TimeLiteral':
|
|
495
|
+
return temporalKindFromSemanticType(semanticType);
|
|
469
496
|
case 'HexLiteral':
|
|
497
|
+
return 'hex';
|
|
470
498
|
case 'RadixLiteral':
|
|
499
|
+
return 'radix';
|
|
471
500
|
case 'EncodingLiteral':
|
|
501
|
+
return 'encoding';
|
|
472
502
|
case 'SeparatorLiteral':
|
|
503
|
+
return 'separator';
|
|
473
504
|
case 'SansaAddressLiteral':
|
|
474
|
-
return '
|
|
505
|
+
return 'sansa';
|
|
475
506
|
case 'NumberLiteral':
|
|
476
507
|
return 'number';
|
|
477
508
|
case 'InfinityLiteral':
|
|
@@ -525,6 +556,10 @@ function scalarFromAeonValue(value) {
|
|
|
525
556
|
return { ok: true, value: value.value };
|
|
526
557
|
case 'ToggleLiteral':
|
|
527
558
|
return { ok: true, value: value.value };
|
|
559
|
+
case 'CloneReference':
|
|
560
|
+
return { ok: true, value: referenceFormValue('CloneReference', value.path) };
|
|
561
|
+
case 'PointerReference':
|
|
562
|
+
return { ok: true, value: referenceFormValue('PointerReference', value.path) };
|
|
528
563
|
case 'NullLiteral':
|
|
529
564
|
return { ok: true, value: null };
|
|
530
565
|
default:
|
|
@@ -532,21 +567,67 @@ function scalarFromAeonValue(value) {
|
|
|
532
567
|
}
|
|
533
568
|
}
|
|
534
569
|
|
|
535
|
-
function scalarKindFromValue(value) {
|
|
570
|
+
function scalarKindFromValue(value, semanticType) {
|
|
536
571
|
switch (value.type) {
|
|
537
572
|
case 'TypedValue':
|
|
538
|
-
return scalarKindFromValue(value.value);
|
|
573
|
+
return scalarKindFromValue(value.value, value.datatype ?? semanticType);
|
|
539
574
|
case 'NullLiteral':
|
|
540
575
|
return 'null';
|
|
541
576
|
case 'InfinityLiteral':
|
|
542
577
|
return 'infinity';
|
|
543
578
|
case 'NaNLiteral':
|
|
544
579
|
return 'nan';
|
|
580
|
+
case 'ToggleLiteral':
|
|
581
|
+
return 'toggle';
|
|
582
|
+
case 'HexLiteral':
|
|
583
|
+
return 'hex';
|
|
584
|
+
case 'RadixLiteral':
|
|
585
|
+
return 'radix';
|
|
586
|
+
case 'EncodingLiteral':
|
|
587
|
+
return 'encoding';
|
|
588
|
+
case 'SeparatorLiteral':
|
|
589
|
+
return 'separator';
|
|
590
|
+
case 'SansaAddressLiteral':
|
|
591
|
+
return 'sansaAddress';
|
|
592
|
+
case 'DateLiteral':
|
|
593
|
+
return 'date';
|
|
594
|
+
case 'DateTimeLiteral':
|
|
595
|
+
case 'TimeLiteral':
|
|
596
|
+
return temporalKindFromSemanticType(semanticType);
|
|
597
|
+
case 'CloneReference':
|
|
598
|
+
case 'PointerReference':
|
|
599
|
+
return 'referenceForm';
|
|
545
600
|
default:
|
|
546
601
|
return undefined;
|
|
547
602
|
}
|
|
548
603
|
}
|
|
549
604
|
|
|
605
|
+
function temporalKindFromSemanticType(semanticType) {
|
|
606
|
+
const base = typeof semanticType === 'string' ? semanticType.split(/[<\[]/, 1)[0] : undefined;
|
|
607
|
+
return ['date', 'time', 'datetime', 'wtc'].includes(base) ? base : 'datetime';
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
function referenceFormValue(type, path) {
|
|
611
|
+
const canonicalPath = renderReferencePath(path);
|
|
612
|
+
return {
|
|
613
|
+
type,
|
|
614
|
+
path,
|
|
615
|
+
canonical: `${type === 'PointerReference' ? '~>' : '~'}${canonicalPath}`,
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function renderReferencePath(path) {
|
|
620
|
+
if (typeof path === 'string') return path;
|
|
621
|
+
if (!Array.isArray(path)) return String(path ?? '');
|
|
622
|
+
return path.map((segment, index) => {
|
|
623
|
+
if (typeof segment === 'number') return `[${segment}]`;
|
|
624
|
+
if (typeof segment === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(segment)) {
|
|
625
|
+
return index === 0 ? segment : `.${segment}`;
|
|
626
|
+
}
|
|
627
|
+
return `${index === 0 ? '' : '.'}[${JSON.stringify(String(segment))}]`;
|
|
628
|
+
}).join('');
|
|
629
|
+
}
|
|
630
|
+
|
|
550
631
|
function nullReasonFromValue(value) {
|
|
551
632
|
switch (value.type) {
|
|
552
633
|
case 'TypedValue':
|
|
@@ -626,8 +707,18 @@ function renderAeonValue(value, metadata, fieldMetadata) {
|
|
|
626
707
|
}
|
|
627
708
|
if (metadata?.kind === 'nan' || (typeof value === 'number' && Number.isNaN(value))) return 'NaN';
|
|
628
709
|
if (metadata?.kind === 'infinity' || value === Infinity) return 'Infinity';
|
|
710
|
+
if (metadata?.kind === 'toggle' || metadata?.category === 'toggle') return String(value);
|
|
629
711
|
if (value === -Infinity) return '-Infinity';
|
|
630
712
|
if (value === null) return 'null';
|
|
713
|
+
if (metadata?.kind === 'hex') return `#${value}`;
|
|
714
|
+
if (metadata?.kind === 'radix') return `%${value}`;
|
|
715
|
+
if (metadata?.kind === 'encoding') return `&${value}`;
|
|
716
|
+
if (metadata?.kind === 'separator') return `^${value}`;
|
|
717
|
+
if (['date', 'time', 'datetime', 'wtc'].includes(metadata?.kind)) return String(value);
|
|
718
|
+
if (metadata?.kind === 'sansaAddress' || metadata?.kind === 'sansa') {
|
|
719
|
+
return value?.canonical ?? value?.address?.canonical ?? value?.address ?? String(value);
|
|
720
|
+
}
|
|
721
|
+
if (metadata?.kind === 'referenceForm') return value?.canonical ?? JSON.stringify(value);
|
|
631
722
|
if (typeof value === 'string') return JSON.stringify(value);
|
|
632
723
|
if (typeof value === 'number' || typeof value === 'boolean') return String(value);
|
|
633
724
|
if (value?.type === 'SansaAddressLiteral') {
|
|
@@ -114,7 +114,7 @@ button {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
.query-panel {
|
|
117
|
-
grid-template-rows: auto minmax(140px, 0.55fr) auto auto auto minmax(180px, 0.45fr);
|
|
117
|
+
grid-template-rows: auto minmax(140px, 0.55fr) auto auto auto auto auto auto minmax(180px, 0.45fr);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
.panel-head {
|