@altopelago/sansa 0.9.1 → 0.10.1

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.
@@ -41,11 +41,11 @@ $.result:number|nan
41
41
  ---
42
42
  $.inventory:list<string>
43
43
  ---
44
- $.version:sep[.]
44
+ $.version:sep["."]
45
45
  ---
46
46
  $.inventory:csv[","]
47
47
  ---
48
- $.claim:type<type>[arg]
48
+ $.claim:type<type>["arg"]
49
49
  ---
50
50
  $#record%object
51
51
  ---
@@ -61,7 +61,7 @@ $:document<invoice>
61
61
  ---
62
62
  $.["list"][2]:rule["+"]
63
63
  ---
64
- $.key:string[","]["."]
64
+ $.key:string[",","."]
65
65
  ---
66
66
  $.["list"][2][2]
67
67
  ---
@@ -1,5 +1,6 @@
1
1
  import { defaultPolicy, firstMutateExampleId, mutateExampleGroups, mutateExamples as examples } from './examples.mjs';
2
2
  const sourceInput = document.querySelector('#sourceInput');
3
+ const sourceKindInput = document.querySelector('#sourceKind');
3
4
  const sourceResultOutput = document.querySelector('#sourceResultOutput');
4
5
  const requestInput = document.querySelector('#requestInput');
5
6
  const requestInputLabel = document.querySelector('#requestInputLabel');
@@ -29,7 +30,7 @@ const sourceTabButtons = Array.from(document.querySelectorAll('[data-source-tab]
29
30
  const detailTabButtons = Array.from(document.querySelectorAll('[data-detail-tab]'));
30
31
  const requestKindInputs = Array.from(document.querySelectorAll('input[name="requestKind"]'));
31
32
 
32
- let defaultSource = '';
33
+ const defaultSources = { aeon: '', telex: '' };
33
34
  let lastPayload = null;
34
35
  let activeSourceTab = 'input';
35
36
  let activeDetailTab = 'diagnostics';
@@ -48,12 +49,20 @@ exampleSelect.addEventListener('change', () => {
48
49
  });
49
50
 
50
51
  resetButton.addEventListener('click', () => {
51
- sourceInput.value = defaultSource;
52
- sourceStatus.textContent = 'default aeon';
52
+ sourceInput.value = defaultSources[sourceKind()];
53
+ sourceStatus.textContent = `default ${sourceKind()}`;
53
54
  setExample(exampleSelect.value);
54
55
  void runMutation('plan');
55
56
  });
56
57
 
58
+ sourceKindInput.addEventListener('change', () => {
59
+ sourceInput.value = defaultSources[sourceKind()];
60
+ targetFormatInput.value = sourceKind();
61
+ sourceStatus.textContent = `default ${sourceKind()}`;
62
+ sourceResultOutput.textContent = 'Run Plan or Apply to render the current source result.';
63
+ void runMutation('plan');
64
+ });
65
+
57
66
  planButton.addEventListener('click', () => {
58
67
  void runMutation('plan');
59
68
  });
@@ -121,7 +130,7 @@ requestInput.addEventListener('keydown', (event) => {
121
130
  });
122
131
 
123
132
  async function loadDefaults() {
124
- defaultSource = await fetchText('/fixtures/query-inventory.aeon', [
133
+ defaultSources.aeon = await fetchText('/fixtures/query-inventory.aeon', [
125
134
  'inventory = {',
126
135
  ' items:list<object> = [',
127
136
  ' { sku:string = "A-100" name:string = "Adapter" qty:int = 1 }',
@@ -129,7 +138,13 @@ async function loadDefaults() {
129
138
  ' ]',
130
139
  '}',
131
140
  ].join('\n'));
132
- sourceInput.value = defaultSource;
141
+ defaultSources.telex = await fetchText('/fixtures/query-inventory.telex.aes', [
142
+ 'telex.aes=1',
143
+ '',
144
+ 'path=$.inventory',
145
+ 'kind=ObjectNode',
146
+ ].join('\n'));
147
+ sourceInput.value = defaultSources.aeon;
133
148
  sourceStatus.textContent = 'default aeon';
134
149
  }
135
150
 
@@ -171,6 +186,7 @@ async function runMutation(mode) {
171
186
  resultStatus.textContent = mode === 'apply' ? 'applying' : 'planning';
172
187
  resultStatus.dataset.phase = mode === 'apply' ? 'apply' : 'plan';
173
188
  const payload = await mutateApi({
189
+ sourceKind: sourceKind(),
174
190
  source: sourceInput.value,
175
191
  requestSource: requestInput.value,
176
192
  requestKind: requestKind(),
@@ -282,6 +298,10 @@ function requestKind() {
282
298
  return document.querySelector('input[name="requestKind"]:checked')?.value ?? 'structured';
283
299
  }
284
300
 
301
+ function sourceKind() {
302
+ return sourceKindInput.value === 'telex' ? 'telex' : 'aeon';
303
+ }
304
+
285
305
  function currentExample() {
286
306
  return examples.find((entry) => entry.id === exampleSelect.value) ?? examples[0];
287
307
  }
@@ -334,7 +354,7 @@ function requestKindLabel() {
334
354
  }
335
355
 
336
356
  function setOptionInputs(options) {
337
- targetFormatInput.value = options.targetFormat ?? 'aeon';
357
+ targetFormatInput.value = options.targetFormat ?? sourceKind();
338
358
  if (options.policySource !== undefined) {
339
359
  enforcePolicyInput.checked = true;
340
360
  policyInput.value = options.policySource;
@@ -23,7 +23,11 @@
23
23
  <section class="workspace" aria-label="SANSA Mutate workspace">
24
24
  <section class="panel source-panel">
25
25
  <div class="panel-head">
26
- <label for="sourceInput">AEON Source</label>
26
+ <label for="sourceInput">Source</label>
27
+ <select id="sourceKind" aria-label="Source format">
28
+ <option value="aeon" selected>AEON</option>
29
+ <option value="telex">Telex AES</option>
30
+ </select>
27
31
  <span id="sourceStatus">default aeon</span>
28
32
  </div>
29
33
  <div class="source-tabs" role="tablist" aria-label="Source views">
@@ -68,6 +72,7 @@
68
72
  <select id="targetFormat" aria-label="Target format">
69
73
  <option value="aeon" selected>AEON</option>
70
74
  <option value="json">JSON</option>
75
+ <option value="telex">Telex AES</option>
71
76
  </select>
72
77
  </label>
73
78
  </div>
@@ -1,5 +1,5 @@
1
1
  import { applyMutationPlan, planInstruction, planMutation, resolveAddress, validateMutationPlanTarget } from '../../src/index.js';
2
- import { namespaceFromAeonSource } from '../query-web/runtime.mjs';
2
+ import { loadAeonAesRuntime, namespaceFromAeonSource, namespaceFromTelexSource } from '../query-web/runtime.mjs';
3
3
 
4
4
  const HANDLE_PROPERTY = '__sansaMutateWorkbenchHandle';
5
5
  const HANDLE_PREFIX = 'mutate-workbench';
@@ -26,23 +26,52 @@ const WORKBENCH_POLICY_RULE_FIELDS = new Set([
26
26
 
27
27
  export async function runMutationForWorkbench({
28
28
  source,
29
+ sourceKind = 'aeon',
29
30
  requestSource,
30
31
  requestKind = 'structured',
31
32
  mode = 'plan',
32
33
  options = {},
33
34
  }) {
34
- const targetProfile = describeMutationTargetProfile(options.targetFormat);
35
- const namespaceResult = await namespaceFromAeonSource(source);
35
+ const normalizedSourceKind = sourceKind === 'telex' ? 'telex' : 'aeon';
36
+ const targetProfile = describeMutationTargetProfile(options.targetFormat ?? normalizedSourceKind);
37
+ const namespaceResult = normalizedSourceKind === 'telex'
38
+ ? await namespaceFromTelexSource(source)
39
+ : await namespaceFromAeonSource(source);
36
40
  if (!namespaceResult.ok) {
41
+ const errors = normalizeDiagnostics(namespaceResult.errors ?? []).map((error) => ({
42
+ ...error,
43
+ code: String(error.code ?? 'SANSA_MUTATE_WORKBENCH_SOURCE_ERROR').replace(
44
+ 'SANSA_QUERY_WORKBENCH_',
45
+ 'SANSA_MUTATE_WORKBENCH_',
46
+ ),
47
+ phase: 'parse',
48
+ }));
37
49
  return {
38
- ...namespaceResult,
50
+ ok: false,
39
51
  mode,
52
+ sourceKind: normalizedSourceKind,
53
+ phase: 'parse',
54
+ text: renderDiagnosticText(errors),
55
+ errors,
40
56
  };
41
57
  }
42
58
 
43
59
  const root = getRoot(namespaceResult.namespace);
44
60
  assignStableHandles(root);
45
- const namespace = mutableNamespace(namespaceResult.namespace);
61
+ let telexState;
62
+ let namespace;
63
+ if (normalizedSourceKind === 'telex') {
64
+ const loaded = await loadAeonAesRuntime();
65
+ if (!loaded.ok) {
66
+ const errors = [{ code: 'SANSA_MUTATE_WORKBENCH_TELEX_RUNTIME_UNAVAILABLE', message: loaded.message, phase: 'parse' }];
67
+ return { ok: false, mode, sourceKind: normalizedSourceKind, phase: 'parse', text: renderDiagnosticText(errors), errors };
68
+ }
69
+ telexState = createTelexMutationState(namespaceResult.telex, loaded.module);
70
+ namespace = mutableTelexNamespace(namespaceResult.namespace, telexState);
71
+ } else {
72
+ namespace = mutableNamespace(namespaceResult.namespace);
73
+ }
74
+ const renderSource = () => telexState ? renderTelexMutationState(telexState) : renderBindingTree(root);
46
75
  const planOptions = mutationPlanOptions(options);
47
76
  const applyOptions = mutationApplyOptions(options);
48
77
  const planResult = requestKind === 'instruction'
@@ -60,7 +89,8 @@ export async function runMutationForWorkbench({
60
89
  text: renderDiagnosticText(planResult.errors, { fallbackPhase: planResult.phase ?? 'plan' }),
61
90
  errors,
62
91
  targetProfile,
63
- source: renderBindingTree(root),
92
+ sourceKind: normalizedSourceKind,
93
+ source: renderSource(),
64
94
  };
65
95
  }
66
96
 
@@ -76,7 +106,8 @@ export async function runMutationForWorkbench({
76
106
  errors: normalizeDiagnostics(policyResult.errors),
77
107
  plan: summarizePlan(planResult.plan),
78
108
  targetProfile,
79
- source: renderBindingTree(root),
109
+ sourceKind: normalizedSourceKind,
110
+ source: renderSource(),
80
111
  };
81
112
  }
82
113
 
@@ -92,7 +123,8 @@ export async function runMutationForWorkbench({
92
123
  errors: normalizeDiagnostics(targetResult.errors),
93
124
  plan: summarizePlan(planResult.plan),
94
125
  targetProfile,
95
- source: renderBindingTree(root),
126
+ sourceKind: normalizedSourceKind,
127
+ source: renderSource(),
96
128
  };
97
129
  }
98
130
 
@@ -106,7 +138,8 @@ export async function runMutationForWorkbench({
106
138
  plan,
107
139
  ...(planResult.loweredRequest === undefined ? {} : { loweredRequest: planResult.loweredRequest }),
108
140
  targetProfile,
109
- source: renderBindingTree(root),
141
+ sourceKind: normalizedSourceKind,
142
+ source: renderSource(),
110
143
  diagnostics: normalizeDiagnostics(planResult.diagnostics ?? []),
111
144
  };
112
145
  }
@@ -121,7 +154,30 @@ export async function runMutationForWorkbench({
121
154
  errors: normalizeDiagnostics(applied.errors),
122
155
  operationResults: summarizeOperationResults(applied.operationResults ?? []),
123
156
  targetProfile,
124
- source: renderBindingTree(root),
157
+ sourceKind: normalizedSourceKind,
158
+ source: renderSource(),
159
+ };
160
+ }
161
+
162
+ let renderedSource;
163
+ try {
164
+ renderedSource = renderSource();
165
+ } catch (error) {
166
+ const errors = [{
167
+ code: 'SANSA_MUTATE_APPLY_FAILED',
168
+ message: error instanceof Error ? error.message : String(error),
169
+ phase: 'apply',
170
+ }];
171
+ return {
172
+ ok: false,
173
+ mode: 'apply',
174
+ sourceKind: normalizedSourceKind,
175
+ text: renderDiagnosticText(errors),
176
+ plan,
177
+ errors,
178
+ operationResults: summarizeOperationResults(applied.operationResults ?? []),
179
+ targetProfile,
180
+ source: String(source),
125
181
  };
126
182
  }
127
183
 
@@ -133,6 +189,7 @@ export async function runMutationForWorkbench({
133
189
  plan,
134
190
  ...(planResult.loweredRequest === undefined ? {} : { loweredRequest: planResult.loweredRequest }),
135
191
  targetProfile,
192
+ sourceKind: normalizedSourceKind,
136
193
  result: {
137
194
  planId: applied.planId,
138
195
  stateBefore: sanitizeJsonValue(applied.stateBefore),
@@ -140,7 +197,7 @@ export async function runMutationForWorkbench({
140
197
  operationResults: summarizeOperationResults(applied.operationResults),
141
198
  diagnostics: normalizeDiagnostics(applied.diagnostics ?? []),
142
199
  },
143
- source: renderBindingTree(root),
200
+ source: renderedSource,
144
201
  };
145
202
  }
146
203
 
@@ -178,7 +235,11 @@ function enforceTargetSurfaceForWorkbench(plan, targetFormat) {
178
235
  }
179
236
 
180
237
  function describeMutationTargetProfile(targetFormat) {
181
- const id = targetFormat === 'json' || targetFormat === 'json-compatible' ? 'json' : 'aeon';
238
+ const id = targetFormat === 'json' || targetFormat === 'json-compatible'
239
+ ? 'json'
240
+ : targetFormat === 'telex' || targetFormat === 'telex.aes'
241
+ ? 'telex'
242
+ : 'aeon';
182
243
  if (id === 'json') {
183
244
  return {
184
245
  id,
@@ -186,6 +247,13 @@ function describeMutationTargetProfile(targetFormat) {
186
247
  summary: 'JSON-compatible target surface: accepts ordinary JSON-compatible values and rejects AEON-only representation features.',
187
248
  };
188
249
  }
250
+ if (id === 'telex') {
251
+ return {
252
+ id,
253
+ boundary: 'representability',
254
+ summary: 'Telex target surface: currently permits deterministic replacement of an existing portable scalar event.',
255
+ };
256
+ }
189
257
  return {
190
258
  id,
191
259
  boundary: 'representability',
@@ -501,6 +569,230 @@ function mutableNamespace(namespace) {
501
569
  };
502
570
  }
503
571
 
572
+ function createTelexMutationState(telex, aes) {
573
+ return {
574
+ aes,
575
+ version: telex.version,
576
+ profile: telex.profile,
577
+ profileExplicit: telex.profileExplicit === true,
578
+ projection: telex.projection,
579
+ projectionExplicit: telex.projectionExplicit === true,
580
+ records: telex.records.map((record) => ({
581
+ ...record,
582
+ ...(Array.isArray(record.generics) ? { generics: structuredClone(record.generics) } : {}),
583
+ ...(Array.isArray(record.clarifiers) ? { clarifiers: structuredClone(record.clarifiers) } : {}),
584
+ })),
585
+ };
586
+ }
587
+
588
+ function mutableTelexNamespace(namespace, state) {
589
+ const recordsByPath = new Map();
590
+ for (let index = 0; index < state.records.length; index += 1) {
591
+ const path = state.records[index].path;
592
+ if (typeof path === 'string') recordsByPath.set(path, index);
593
+ }
594
+ return {
595
+ ...namespace,
596
+ root: getRoot(namespace),
597
+ mutate: {
598
+ supportsReplace: true,
599
+ supportsStableBindingIdentity: true,
600
+ supportsAtomicApply: true,
601
+ bindingHandle: (binding) => binding[HANDLE_PROPERTY],
602
+ observedState: (binding) => binding.revision ?? 0,
603
+ sameBinding: (left, right) => left === right || left?.[HANDLE_PROPERTY] === right?.[HANDLE_PROPERTY],
604
+ replace(target, value, operation) {
605
+ const recordIndex = recordsByPath.get(target.address);
606
+ if (recordIndex === undefined) {
607
+ return { ok: false, message: `Portable AES event '${target.address}' was not found.` };
608
+ }
609
+ const current = state.records[recordIndex];
610
+ const replacement = telexScalarReplacementRecord(current, value, operation, state.aes);
611
+ if (!replacement.ok) return replacement;
612
+ const candidateRecords = [...state.records];
613
+ candidateRecords[recordIndex] = replacement.record;
614
+ const validation = state.aes.validateTelexRecords(candidateRecords, {
615
+ profile: state.profile,
616
+ projection: state.projection,
617
+ });
618
+ if (!validation.valid) {
619
+ return {
620
+ ok: false,
621
+ message: validation.diagnostics.map((diagnostic) => `${diagnostic.code}: ${diagnostic.message}`).join('; '),
622
+ };
623
+ }
624
+ state.records = candidateRecords;
625
+ applyPortableScalarRecordToBinding(target, replacement.record);
626
+ bump(target);
627
+ return { binding: target, resultingAddress: target.address };
628
+ },
629
+ },
630
+ };
631
+ }
632
+
633
+ function telexScalarReplacementRecord(current, value, operation, aes) {
634
+ if (!current || typeof current.path !== 'string') {
635
+ return { ok: false, message: 'Telex scalar replacement requires a body event.' };
636
+ }
637
+ let descriptor;
638
+ if (operation.datatype !== undefined) {
639
+ try {
640
+ descriptor = aes.parseDatatypeDescriptor(operation.datatype);
641
+ } catch (error) {
642
+ return { ok: false, message: error instanceof Error ? error.message : String(error) };
643
+ }
644
+ }
645
+ const kind = portableKindForMutation(operation.kind, descriptor?.datatype, current.kind);
646
+ if (kind === undefined || !PORTABLE_MUTABLE_SCALAR_KINDS.has(kind)) {
647
+ return { ok: false, message: `Telex scalar replacement cannot represent kind '${kind ?? operation.kind ?? current.kind}'.` };
648
+ }
649
+ const payload = portableScalarPayload(kind, value, current);
650
+ if (!payload.ok) return payload;
651
+ const record = {
652
+ ...current,
653
+ kind,
654
+ value: payload.value,
655
+ ...(descriptor === undefined ? {} : {
656
+ datatype: descriptor.datatype,
657
+ generics: descriptor.generics,
658
+ clarifiers: descriptor.clarifiers,
659
+ }),
660
+ };
661
+ // Source coordinates describe the pre-mutation artifact and cannot be
662
+ // claimed by the newly produced value. Unchanged events retain theirs.
663
+ delete record.origin;
664
+ delete record.span;
665
+ return { ok: true, record };
666
+ }
667
+
668
+ const PORTABLE_MUTABLE_SCALAR_KINDS = new Set([
669
+ 'StringLiteral', 'NumberLiteral', 'InfinityLiteral', 'NaNLiteral', 'NullLiteral',
670
+ 'BooleanLiteral', 'ToggleLiteral', 'HexLiteral', 'RadixLiteral', 'EncodingLiteral',
671
+ 'SeparatorLiteral', 'SansaAddressLiteral', 'DateLiteral', 'TimeLiteral',
672
+ 'DateTimeLiteral', 'WTCDateTimeLiteral',
673
+ ]);
674
+
675
+ const PORTABLE_KIND_ALIASES = new Map([
676
+ ['string', 'StringLiteral'], ['trimtick', 'StringLiteral'], ['prose', 'StringLiteral'],
677
+ ['number', 'NumberLiteral'], ['n', 'NumberLiteral'], ['integer', 'NumberLiteral'],
678
+ ['boolean', 'BooleanLiteral'], ['bool', 'BooleanLiteral'], ['toggle', 'ToggleLiteral'],
679
+ ['null', 'NullLiteral'], ['nan', 'NaNLiteral'], ['infinity', 'InfinityLiteral'],
680
+ ['hex', 'HexLiteral'], ['radix', 'RadixLiteral'], ['encoding', 'EncodingLiteral'],
681
+ ['base64', 'EncodingLiteral'], ['embed', 'EncodingLiteral'], ['inline', 'EncodingLiteral'],
682
+ ['separator', 'SeparatorLiteral'], ['sep', 'SeparatorLiteral'], ['csv', 'SeparatorLiteral'],
683
+ ['sansa', 'SansaAddressLiteral'], ['sansaaddress', 'SansaAddressLiteral'],
684
+ ['date', 'DateLiteral'], ['time', 'TimeLiteral'], ['datetime', 'DateTimeLiteral'], ['wtc', 'WTCDateTimeLiteral'],
685
+ ]);
686
+
687
+ function portableKindForMutation(kind, datatype, fallback) {
688
+ if (PORTABLE_MUTABLE_SCALAR_KINDS.has(kind)) return kind;
689
+ const kindAlias = typeof kind === 'string' ? PORTABLE_KIND_ALIASES.get(kind.toLowerCase()) : undefined;
690
+ if (kindAlias !== undefined) return kindAlias;
691
+ if (typeof datatype === 'string') {
692
+ const base = datatype.toLowerCase();
693
+ const datatypeAlias = PORTABLE_KIND_ALIASES.get(base);
694
+ if (datatypeAlias !== undefined) return datatypeAlias;
695
+ if (/^(?:u?int|float|decimal)\d*$/u.test(base)) return 'NumberLiteral';
696
+ if (/^radix\d+$/u.test(base)) return 'RadixLiteral';
697
+ }
698
+ return PORTABLE_MUTABLE_SCALAR_KINDS.has(fallback) ? fallback : undefined;
699
+ }
700
+
701
+ function portableScalarPayload(kind, value, current) {
702
+ switch (kind) {
703
+ case 'NumberLiteral':
704
+ return typeof value === 'number' && Number.isFinite(value)
705
+ ? { ok: true, value: String(value) }
706
+ : invalidPortableScalar(kind, 'a finite JSON number');
707
+ case 'BooleanLiteral':
708
+ return typeof value === 'boolean'
709
+ ? { ok: true, value: String(value) }
710
+ : invalidPortableScalar(kind, 'a JSON boolean');
711
+ case 'NullLiteral':
712
+ if (typeof value === 'string' && value.length > 0) return { ok: true, value };
713
+ if (value === null && current.kind === 'NullLiteral' && typeof current.value === 'string') {
714
+ return { ok: true, value: current.value };
715
+ }
716
+ return invalidPortableScalar(kind, 'a non-empty null-reason string, or null when replacing an existing null event');
717
+ case 'NaNLiteral':
718
+ return value === null || value === 'NaN'
719
+ ? { ok: true, value: 'NaN' }
720
+ : invalidPortableScalar(kind, 'null or "NaN"');
721
+ case 'InfinityLiteral':
722
+ if (value === Infinity || value === 'Infinity' || value === '+Infinity') return { ok: true, value: 'Infinity' };
723
+ if (value === -Infinity || value === '-Infinity') return { ok: true, value: '-Infinity' };
724
+ return invalidPortableScalar(kind, '"Infinity", "+Infinity", or "-Infinity"');
725
+ default:
726
+ return typeof value === 'string'
727
+ ? { ok: true, value }
728
+ : invalidPortableScalar(kind, 'a JSON string');
729
+ }
730
+ }
731
+
732
+ function invalidPortableScalar(kind, expected) {
733
+ return { ok: false, message: `${kind} replacement requires ${expected}.` };
734
+ }
735
+
736
+ function applyPortableScalarRecordToBinding(binding, record) {
737
+ binding.representationKind = record.kind;
738
+ binding.datatype = record.datatype;
739
+ binding.semanticType = record.datatype ?? portableScalarSemanticTypeForWorkbench(record.kind);
740
+ binding.generics = record.generics;
741
+ binding.clarifiers = record.clarifiers;
742
+ binding.scalarKind = portableScalarKindForWorkbench(record.kind);
743
+ binding.value = portableScalarValueForWorkbench(record);
744
+ if (record.kind === 'NullLiteral') binding.nullReason = record.value;
745
+ else delete binding.nullReason;
746
+ delete binding.origin;
747
+ delete binding.span;
748
+ }
749
+
750
+ function portableScalarSemanticTypeForWorkbench(kind) {
751
+ return {
752
+ StringLiteral: 'string', NumberLiteral: 'number', BooleanLiteral: 'boolean',
753
+ NullLiteral: 'null', InfinityLiteral: 'infinity', NaNLiteral: 'nan', ToggleLiteral: 'toggle',
754
+ HexLiteral: 'hex', RadixLiteral: 'radix', EncodingLiteral: 'encoding', SeparatorLiteral: 'sep',
755
+ SansaAddressLiteral: 'sansa', DateLiteral: 'date', TimeLiteral: 'time',
756
+ DateTimeLiteral: 'datetime', WTCDateTimeLiteral: 'wtc',
757
+ }[kind];
758
+ }
759
+
760
+ function portableScalarKindForWorkbench(kind) {
761
+ return {
762
+ StringLiteral: 'string', NumberLiteral: 'number', BooleanLiteral: 'boolean',
763
+ NullLiteral: 'null', InfinityLiteral: 'infinity', NaNLiteral: 'nan', ToggleLiteral: 'toggle',
764
+ HexLiteral: 'hex', RadixLiteral: 'radix', EncodingLiteral: 'encoding', SeparatorLiteral: 'separator',
765
+ SansaAddressLiteral: 'sansaAddress', DateLiteral: 'date', TimeLiteral: 'time',
766
+ DateTimeLiteral: 'datetime', WTCDateTimeLiteral: 'wtc',
767
+ }[kind];
768
+ }
769
+
770
+ function portableScalarValueForWorkbench(record) {
771
+ if (record.kind === 'NumberLiteral') return Number(record.value);
772
+ if (record.kind === 'BooleanLiteral') return record.value === 'true';
773
+ if (record.kind === 'NullLiteral') return null;
774
+ if (record.kind === 'NaNLiteral') return Number.NaN;
775
+ if (record.kind === 'InfinityLiteral') return record.value === '-Infinity' ? -Infinity : Infinity;
776
+ if (record.kind === 'SansaAddressLiteral') {
777
+ return { type: 'SansaAddressLiteral', address: record.value, canonical: record.value };
778
+ }
779
+ return record.value;
780
+ }
781
+
782
+ function renderTelexMutationState(state) {
783
+ const validation = state.aes.validateTelexRecords(state.records, {
784
+ profile: state.profile,
785
+ projection: state.projection,
786
+ });
787
+ if (!validation.valid) {
788
+ throw new Error(validation.diagnostics.map((diagnostic) => `${diagnostic.code}: ${diagnostic.message}`).join('; '));
789
+ }
790
+ return state.aes.encodeTelex(state.records, {
791
+ ...(state.profileExplicit ? { profile: state.profile } : {}),
792
+ ...(state.projectionExplicit && state.projection !== null ? { projection: state.projection } : {}),
793
+ });
794
+ }
795
+
504
796
  function getRoot(namespace) {
505
797
  return typeof namespace.root === 'function' ? namespace.root() : namespace.root;
506
798
  }
@@ -666,7 +958,7 @@ function validateAeonWorkbenchScalarValue(value, representation, path) {
666
958
  case 'date':
667
959
  case 'time':
668
960
  case 'datetime':
669
- case 'zrut':
961
+ case 'wtc':
670
962
  return typeof value === 'string' && value.length > 0
671
963
  ? { ok: true }
672
964
  : invalidAeonWorkbenchValue(`${representation} literals must be non-empty text`, path);
@@ -955,13 +1247,19 @@ function summarizeOperationResults(results) {
955
1247
  function summarizeBinding(binding) {
956
1248
  return {
957
1249
  address: binding.address,
1250
+ identity: binding.identity,
958
1251
  name: binding.name,
959
1252
  index: binding.index,
960
1253
  semanticType: binding.semanticType,
1254
+ datatype: binding.datatype,
1255
+ generics: sanitizeJsonValue(binding.generics),
1256
+ clarifiers: sanitizeJsonValue(binding.clarifiers),
961
1257
  representationKind: binding.representationKind,
962
1258
  scalarKind: binding.scalarKind,
963
1259
  nullReason: binding.nullReason,
964
1260
  nodeTag: binding.nodeTag,
1261
+ origin: binding.origin,
1262
+ span: binding.span,
965
1263
  value: sanitizeJsonValue(binding.value),
966
1264
  };
967
1265
  }
@@ -1110,7 +1408,7 @@ function renderScalarValue(binding) {
1110
1408
  if (kind === 'radix') return `%${value}`;
1111
1409
  if (kind === 'encoding') return `&${value}`;
1112
1410
  if (kind === 'separator') return `^${value}`;
1113
- if (['date', 'time', 'datetime', 'zrut'].includes(kind)) return String(value);
1411
+ if (['date', 'time', 'datetime', 'wtc'].includes(kind)) return String(value);
1114
1412
  if (kind === 'sansaAddress' || kind === 'sansa') {
1115
1413
  return value?.canonical ?? value?.address?.canonical ?? value?.address ?? String(value);
1116
1414
  }
@@ -1240,7 +1538,7 @@ function semanticTypeFromRepresentationKind(kind) {
1240
1538
  case 'date':
1241
1539
  case 'time':
1242
1540
  case 'datetime':
1243
- case 'zrut':
1541
+ case 'wtc':
1244
1542
  case 'null':
1245
1543
  case 'nan':
1246
1544
  case 'infinity':
@@ -1278,7 +1576,7 @@ function representationKindFromName(name, { allowUnknown = false } = {}) {
1278
1576
  if (base === 'sep' || base === 'separator' || base === 'kadot') return 'separator';
1279
1577
  if (base === 'sansa') return 'sansa';
1280
1578
  if (base === 'encoding' || ['base64', 'embed', 'inline'].includes(base)) return 'encoding';
1281
- if (['date', 'time', 'datetime', 'zrut'].includes(base)) return base;
1579
+ if (['date', 'time', 'datetime', 'wtc'].includes(base)) return base;
1282
1580
  if (['cloneReference', 'pointerReference', 'referenceForm'].includes(base)) return base;
1283
1581
  return allowUnknown ? base : undefined;
1284
1582
  }
@@ -20,6 +20,7 @@ const budgetInputs = Array.from(document.querySelectorAll('.budget-row input'));
20
20
  let defaultFixtureSource = '';
21
21
  let defaultJsonSource = '';
22
22
  let defaultAeonSource = '';
23
+ let defaultTelexSource = '';
23
24
  let defaultParamsSource = '';
24
25
  let lastAction = 'evaluate';
25
26
 
@@ -34,10 +35,10 @@ exampleSelect.addEventListener('change', () => {
34
35
  });
35
36
 
36
37
  resetButton.addEventListener('click', () => {
37
- fixtureInput.value = sourceKind() === 'json' ? defaultJsonSource : defaultAeonSource;
38
+ fixtureInput.value = defaultSourceForKind(sourceKind());
38
39
  paramsInput.value = defaultParamsSource;
39
40
  setExample(exampleSelect.value);
40
- fixtureStatus.textContent = sourceKind() === 'json' ? 'default json' : 'default aeon';
41
+ fixtureStatus.textContent = `default ${sourceKind()}`;
41
42
  paramsStatus.textContent = 'default params';
42
43
  void runQuery();
43
44
  });
@@ -75,9 +76,11 @@ budgetInputs.forEach((input) => {
75
76
  });
76
77
  document.querySelectorAll('input[name="sourceKind"]').forEach((input) => {
77
78
  input.addEventListener('change', () => {
78
- fixtureInput.value = sourceKind() === 'json' ? defaultJsonSource : defaultAeonSource;
79
- sourceLabel.textContent = sourceKind() === 'json' ? 'Fixture JSON' : 'AEON Source';
80
- fixtureStatus.textContent = sourceKind() === 'json' ? 'default json' : 'default aeon';
79
+ fixtureInput.value = defaultSourceForKind(sourceKind());
80
+ sourceLabel.textContent = sourceKind() === 'json'
81
+ ? 'Fixture JSON'
82
+ : sourceKind() === 'telex' ? 'Telex AES' : 'AEON Source';
83
+ fixtureStatus.textContent = `default ${sourceKind()}`;
81
84
  void runQuery();
82
85
  });
83
86
  });
@@ -126,6 +129,16 @@ async function loadDefaultSources() {
126
129
  '}',
127
130
  ].join('\n'));
128
131
  defaultJsonSource = await fetchText('/fixtures/query-inventory.json', '{\n "root": {\n "address": "$",\n "children": []\n }\n}');
132
+ defaultTelexSource = await fetchText('/fixtures/query-inventory.telex.aes', [
133
+ 'telex.aes=1',
134
+ '',
135
+ 'path=$.inventory',
136
+ 'kind=ObjectNode',
137
+ '',
138
+ 'path=$.inventory.items',
139
+ 'kind=ListNode',
140
+ '',
141
+ ].join('\n'));
129
142
  defaultParamsSource = [
130
143
  'source:sansa = $.inventory.items.*',
131
144
  'field:sansa = ?.sku',
@@ -140,6 +153,12 @@ async function loadDefaultSources() {
140
153
  paramsStatus.textContent = 'default params';
141
154
  }
142
155
 
156
+ function defaultSourceForKind(kind) {
157
+ if (kind === 'json') return defaultJsonSource;
158
+ if (kind === 'telex') return defaultTelexSource;
159
+ return defaultAeonSource;
160
+ }
161
+
143
162
  async function fetchText(path, fallback) {
144
163
  try {
145
164
  const response = await fetch(path);
@@ -31,6 +31,10 @@
31
31
  <input type="radio" name="sourceKind" value="aeon" checked>
32
32
  AEON
33
33
  </label>
34
+ <label>
35
+ <input type="radio" name="sourceKind" value="telex">
36
+ Telex AES
37
+ </label>
34
38
  <label>
35
39
  <input type="radio" name="sourceKind" value="json">
36
40
  JSON fixture