@altopelago/sansa 0.14.2 → 0.15.0-rc.2
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 +118 -1
- package/README.md +96 -1
- package/conformance/README.md +8 -0
- package/conformance/aeonic-anchor-claims.json +133 -0
- package/conformance/aeonic-arithmetic-claims.json +60 -0
- package/conformance/aeonic-clock-claims.json +123 -0
- package/conformance/aeonic-comparison-claims.json +37 -0
- package/conformance/aeonic-datetime-claims.json +110 -0
- package/conformance/aeonic-rational-arithmetic-claims.json +72 -0
- package/conformance/aeonic-temporal-claims.json +105 -0
- package/conformance/cts-claims.json +17 -3
- package/conformance/results/aeonic-anchor-capacity.json +452 -0
- package/conformance/results/aeonic-anchor-snapshot-0.1.json +39 -0
- package/conformance/results/aeonic-arithmetic-snapshot-0.1.json +28 -0
- package/conformance/results/aeonic-clock-all-snapshot-0.1.json +49 -0
- package/conformance/results/aeonic-clock-arithmetic-snapshot-0.1.json +48 -0
- package/conformance/results/aeonic-clock-capacity.json +326 -0
- package/conformance/results/aeonic-clock-relations-snapshot-0.1.json +48 -0
- package/conformance/results/aeonic-comparison-snapshot-0.1.json +19 -0
- package/conformance/results/aeonic-datetime-all-snapshot-0.1.json +47 -0
- package/conformance/results/aeonic-datetime-arithmetic-snapshot-0.1.json +46 -0
- package/conformance/results/aeonic-datetime-capacity.json +302 -0
- package/conformance/results/aeonic-datetime-relations-snapshot-0.1.json +46 -0
- package/conformance/results/aeonic-rational-arithmetic-capacity.json +100 -0
- package/conformance/results/aeonic-rational-arithmetic-snapshot-0.2.json +30 -0
- package/conformance/results/aeonic-temporal-all-property-addressing-2026-11-16.json +39 -0
- package/conformance/results/aeonic-temporal-all-snapshot-0.1.json +39 -0
- package/conformance/results/aeonic-temporal-calendar-property-addressing-2026-11-16.json +38 -0
- package/conformance/results/aeonic-temporal-calendar-snapshot-0.1.json +38 -0
- package/conformance/results/aeonic-temporal-capacity-property-addressing-2026-11-16.json +136 -0
- package/conformance/results/aeonic-temporal-capacity.json +136 -0
- package/conformance/results/aeonic-temporal-relations-property-addressing-2026-11-16.json +38 -0
- package/conformance/results/aeonic-temporal-relations-snapshot-0.1.json +38 -0
- package/docs/aeonic-arithmetic.md +126 -0
- package/docs/aeonic-comparison.md +123 -0
- package/docs/aeonic-rational-arithmetic.md +167 -0
- package/docs/aeonic-temporal-civil-anchor.md +89 -0
- package/docs/aeonic-temporal-civil-clock.md +100 -0
- package/docs/aeonic-temporal-civil-date.md +124 -0
- package/docs/aeonic-temporal-civil-datetime.md +122 -0
- package/docs/api-contract.md +130 -3
- package/docs/capabilities.json +106 -2
- package/docs/child-identity-activation.md +93 -0
- package/docs/child-identity-candidate.md +60 -0
- package/docs/child-identity-tooling.md +31 -0
- package/docs/child-identity-workflows.md +102 -0
- package/docs/empty-keys-candidate.md +29 -0
- package/docs/migration-0.15.0.md +75 -0
- package/docs/property-addressing-implementation.md +118 -0
- package/docs/property-resolve-implementation.md +105 -0
- package/docs/property-selector-support.md +65 -0
- package/docs/property-selectors-api.d.ts +43 -0
- package/docs/property-selectors-api.pyi +27 -0
- package/docs/property-selectors-api.rs +48 -0
- package/docs/property-selectors-contract.md +168 -0
- package/docs/query-tool.md +32 -1
- package/docs/selector-cursor.md +45 -0
- package/docs/unicode-hardening.md +41 -0
- package/fixtures/address-v1.json +4 -3
- package/fixtures/child-identity-workflows/README.md +9 -0
- package/fixtures/child-identity-workflows/moved.aeon +10 -0
- package/fixtures/child-identity-workflows/original.aeon +10 -0
- package/fixtures/child-identity-workflows/reordered.aeon +10 -0
- package/fixtures/child-identity-workflows/replacement.aeon +10 -0
- package/fixtures/child-identity-workflows/workflows.json +89 -0
- package/fixtures/property-namespace-candidate-v1.json +336 -0
- package/fixtures/property-parser-candidate-v1.json +705 -0
- package/fixtures/property-query-candidate-v1.json +398 -0
- package/fixtures/property-resolve-candidate-v1.json +2702 -0
- package/fixtures/unicode-hardening-v1.json +401 -0
- package/package.json +30 -3
- package/scripts/calibrate-aeonic-anchor-capacity.py +294 -0
- package/scripts/calibrate-aeonic-clock-capacity.py +62 -0
- package/scripts/calibrate-aeonic-datetime-capacity.py +76 -0
- package/scripts/calibrate-aeonic-rational-capacity.py +85 -0
- package/scripts/calibrate-aeonic-temporal-capacity.py +95 -0
- package/scripts/cts-address.mjs +6 -2
- package/scripts/cts-aeonic-anchor.mjs +21 -0
- package/scripts/cts-aeonic-arithmetic-adapter.mjs +25 -0
- package/scripts/cts-aeonic-arithmetic.mjs +24 -0
- package/scripts/cts-aeonic-clock.mjs +24 -0
- package/scripts/cts-aeonic-comparison-adapter.mjs +30 -0
- package/scripts/cts-aeonic-comparison.mjs +25 -0
- package/scripts/cts-aeonic-datetime.mjs +24 -0
- package/scripts/cts-aeonic-rational-arithmetic-adapter.mjs +25 -0
- package/scripts/cts-aeonic-rational-arithmetic.mjs +24 -0
- package/scripts/cts-aeonic-temporal-civil-anchor-adapter.mjs +26 -0
- package/scripts/cts-aeonic-temporal-civil-clock-adapter.mjs +28 -0
- package/scripts/cts-aeonic-temporal-civil-date-adapter.mjs +28 -0
- package/scripts/cts-aeonic-temporal-civil-datetime-adapter.mjs +28 -0
- package/scripts/cts-aeonic-temporal.mjs +24 -0
- package/scripts/cts-instruction.mjs +4 -2
- package/scripts/cts-mutate.mjs +3 -2
- package/scripts/cts-resolve.mjs +17 -2
- package/scripts/playground.mjs +110 -0
- package/src/aeonic-arithmetic-binding.js +61 -0
- package/src/aeonic-arithmetic.d.ts +84 -0
- package/src/aeonic-arithmetic.js +276 -0
- package/src/aeonic-comparison.d.ts +86 -0
- package/src/aeonic-comparison.js +274 -0
- package/src/aeonic-convenience.d.ts +30 -0
- package/src/aeonic-convenience.js +45 -0
- package/src/aeonic-exact-number.js +34 -0
- package/src/aeonic-json.js +45 -0
- package/src/aeonic-rational-arithmetic.d.ts +86 -0
- package/src/aeonic-rational-arithmetic.js +417 -0
- package/src/aeonic-rational-json.js +51 -0
- package/src/aeonic-temporal-civil-anchor.d.ts +54 -0
- package/src/aeonic-temporal-civil-anchor.js +316 -0
- package/src/aeonic-temporal-civil-clock.d.ts +124 -0
- package/src/aeonic-temporal-civil-clock.js +388 -0
- package/src/aeonic-temporal-civil-date.d.ts +123 -0
- package/src/aeonic-temporal-civil-date.js +310 -0
- package/src/aeonic-temporal-civil-datetime.d.ts +138 -0
- package/src/aeonic-temporal-civil-datetime.js +501 -0
- package/src/index.d.ts +84 -1
- package/src/index.js +828 -183
- package/src/property-address.js +196 -0
- package/src/property-resolve.js +132 -0
- package/src/query-metadata.d.ts +16 -0
- package/src/query-metadata.js +25 -0
- package/src/selector-cursor.d.ts +19 -0
- package/src/selector-cursor.js +79 -0
- package/stress-tests/address/invalid.sansa-cases +0 -2
- package/stress-tests/address/valid.sansa-cases +3 -0
- package/tools/mutate-web/examples.mjs +1 -1
- package/tools/mutate-web/runtime.mjs +0 -2
- package/tools/playground/README.md +165 -0
- package/tools/playground/accessibility.js +91 -0
- package/tools/playground/aeon-highlight.js +77 -0
- package/tools/playground/aeon-source-composer.js +1077 -0
- package/tools/playground/anchor-examples.mjs +16 -0
- package/tools/playground/arithmetic-evaluator.mjs +28 -0
- package/tools/playground/arithmetic-model.mjs +187 -0
- package/tools/playground/arithmetic-worker.mjs +14 -0
- package/tools/playground/arithmetic.css +1 -0
- package/tools/playground/arithmetic.html +29 -0
- package/tools/playground/arithmetic.mjs +110 -0
- package/tools/playground/clock-examples.mjs +16 -0
- package/tools/playground/datetime-examples.mjs +22 -0
- package/tools/playground/examples.mjs +46 -0
- package/tools/playground/index.html +174 -0
- package/tools/playground/local.css +25 -0
- package/tools/playground/namespace.mjs +39 -0
- package/tools/playground/sansa-playground.js +1565 -0
- package/tools/playground/site.css +3914 -0
- package/tools/playground/temporal-examples.mjs +20 -0
- package/tools/playground/walkthrough.js +90 -0
- package/tools/playground/website-origin.json +16 -0
- package/tools/query-web/IDENTITY_SELECTORS.md +44 -0
- package/tools/query-web/app.js +4 -0
- package/tools/query-web/index.html +4 -0
- package/tools/query-web/runtime.mjs +70 -19
- package/tools/workflows/property-playground-assertions.mjs +33 -0
- package/tools/workflows/verify-child-identities.mjs +137 -0
- package/tools/workflows/verify-property-playground.mjs +48 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const date = value => ({ temporal: { category: 'civilDate', value } });
|
|
2
|
+
const clock = value => ({ temporal: { category: 'civilClock', value } });
|
|
3
|
+
const derived = pieces => ({ temporal: { category: 'civilClockSet', pieces }, originClockForm: 'second', history: 'none-declared' });
|
|
4
|
+
const point = (day, time) => ({ kind: 'point', at: { day, time } });
|
|
5
|
+
const request = (anchor, value) => ({ operation: 'anchor', input: { anchor, clock: value, context: { profile: 'aeonic.operations.temporal.civil-anchor.v1' } } });
|
|
6
|
+
export const ANCHOR_EXAMPLES = [
|
|
7
|
+
{ id: 'anchor-leap', lane: 'anchor', title: 'Carry into leap day', detail: 'Day +1 at 01:30 anchored to February 28, 2024 becomes February 29 at 01:30.', request: request(date('2024-02-28'), derived([point('1', '01:30:00')])) },
|
|
8
|
+
{ id: 'anchor-borrow', lane: 'anchor', title: 'Borrow into the previous day', detail: 'Relative day −1 remains part of the exact translation.', request: request(date('2024-03-01'), derived([point('-1', '23:30:00')])) },
|
|
9
|
+
{ id: 'anchor-minute', lane: 'anchor', title: 'A whole minute', detail: 'An authored minute keeps its inclusive start and excluded end.', request: request(date('2024-02-28'), clock('23:59')) },
|
|
10
|
+
{ id: 'anchor-history', lane: 'anchor', title: 'Two independent histories', detail: 'Date clamping and clock approximation histories travel into the date-time bundle separately.', request: request({ temporal: { category: 'civilDateSet', ranges: [{ start: '2024-02-29', end: '2024-02-29' }] }, originGranularity: 'month', history: 'clamping-declared' }, { ...derived([point('0', '09:30:00.125')]), history: 'approximation-declared' }) },
|
|
11
|
+
{ id: 'anchor-gap', lane: 'anchor', title: 'Keep a missing midnight', detail: 'Two intervals exclude their shared midnight coordinate. Anchoring never fills the gap.', request: request(date('2024-02-28'), derived([{ kind: 'interval', start: { day: '0', time: '23:59:59' }, end: { day: '1', time: '00:00:00' }, includeStart: true, includeEnd: false }, { kind: 'interval', start: { day: '1', time: '00:00:00' }, end: { day: '1', time: '00:00:01' }, includeStart: false, includeEnd: true }])) },
|
|
12
|
+
{ id: 'anchor-long', lane: 'anchor', title: 'One interval across 100 days', detail: 'A continuous interval translates as one piece without enumerating its days or seconds.', request: request(date('2024-01-01'), derived([{ kind: 'interval', start: { day: '0', time: '00:00:00' }, end: { day: '100', time: '00:00:00' }, includeStart: true, includeEnd: false }])) },
|
|
13
|
+
{ id: 'anchor-upper', lane: 'anchor', title: 'The excluded domain boundary', detail: 'The last minute of year 9999 keeps its excluded end-of-domain marker.', request: request(date('9999-12-31'), clock('23:59')) },
|
|
14
|
+
{ id: 'anchor-month', lane: 'anchor', title: 'A month is not one anchor day', detail: 'A valid month fails single-day eligibility with a diagnostic and no value.', request: request(date('2024-02'), clock('09:30:00')) },
|
|
15
|
+
{ id: 'anchor-outside', lane: 'anchor', title: 'Carry outside the date domain', detail: 'An out-of-domain translated coordinate produces a diagnostic with no partial result.', request: request(date('9999-12-31'), derived([point('1', '00:00:00')])) },
|
|
16
|
+
];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
evaluateAeonicCivilAnchorText, evaluateAeonicCivilClockText, evaluateAeonicCivilDateTimeText, evaluateAeonicTemporalText, evaluateAeonicArithmeticText, evaluateAeonicRationalArithmeticText,
|
|
3
|
+
evaluateAeonicArithmeticAndMaterializeText, evaluateAeonicRationalArithmeticAndMaterializeText,
|
|
4
|
+
} from '../../src/index.js';
|
|
5
|
+
import { parseStrictJson, exceedsJsonDepth } from '../../src/aeonic-json.js';
|
|
6
|
+
import { parseRationalArithmeticEnvelope } from '../../src/aeonic-rational-json.js';
|
|
7
|
+
import { validateArithmeticInput, ARITHMETIC_LIMITS } from './arithmetic-model.mjs';
|
|
8
|
+
|
|
9
|
+
export function evaluateArithmeticPlayground(input) {
|
|
10
|
+
validateArithmeticInput(input);
|
|
11
|
+
if (input.lane === 'anchor') return evaluateAeonicCivilAnchorText(input.requestText);
|
|
12
|
+
if (input.lane === 'clock') return evaluateAeonicCivilClockText(input.requestText);
|
|
13
|
+
if (input.lane === 'datetime') return evaluateAeonicCivilDateTimeText(input.requestText);
|
|
14
|
+
if (input.lane === 'temporal') return evaluateAeonicTemporalText(input.requestText);
|
|
15
|
+
const rational = input.lane === 'rational';
|
|
16
|
+
if (!Object.hasOwn(input, 'outputPolicyText')) {
|
|
17
|
+
return (rational ? evaluateAeonicRationalArithmeticText : evaluateAeonicArithmeticText)(input.requestText);
|
|
18
|
+
}
|
|
19
|
+
const text = input.outputPolicyText;
|
|
20
|
+
if (/[\uD800-\uDFFF]/u.test(text) || exceedsJsonDepth(text, ARITHMETIC_LIMITS.policyDepth)) {
|
|
21
|
+
throw new TypeError('Output policy must be scalar JSON text within depth 8.');
|
|
22
|
+
}
|
|
23
|
+
// Standalone validation prevents escaping the synthetic wrapper. Preserve raw
|
|
24
|
+
// numeric tokens so invalid policy values reach the owning policy validator.
|
|
25
|
+
parseStrictJson(text);
|
|
26
|
+
const output = parseRationalArithmeticEnvelope('{"fixture":{"request":' + text + '}}').fixture.request;
|
|
27
|
+
return (rational ? evaluateAeonicRationalArithmeticAndMaterializeText : evaluateAeonicArithmeticAndMaterializeText)(input.requestText, output);
|
|
28
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { ANCHOR_EXAMPLES } from './anchor-examples.mjs';
|
|
2
|
+
import { CLOCK_EXAMPLES } from './clock-examples.mjs';
|
|
3
|
+
import { DATETIME_EXAMPLES } from './datetime-examples.mjs';
|
|
4
|
+
import { TEMPORAL_EXAMPLES } from './temporal-examples.mjs';
|
|
5
|
+
import { parseStrictJson, exceedsJsonDepth } from '../../src/aeonic-json.js';
|
|
6
|
+
export const ARITHMETIC_LIMITS = Object.freeze({ requestBytes: 262144, outputPolicyBytes: 16384, policyDepth: 8, resultBytes: 1048576, timeoutMs: 4000 });
|
|
7
|
+
export const ARITHMETIC_LANES = Object.freeze({
|
|
8
|
+
anchor: { title: 'Date anchoring', snapshot: '0.1', profile: 'aeonic.operations.temporal.civil-anchor.v1' },
|
|
9
|
+
clock: { title: 'Civil clocks', snapshot: '0.1', profile: 'aeonic.operations.temporal.civil-clock.v1' },
|
|
10
|
+
datetime: { title: 'Civil date-times', snapshot: '0.1', profile: 'aeonic.operations.temporal.civil-datetime.v1' },
|
|
11
|
+
temporal: { title: 'Civil dates', snapshot: '0.1', profile: 'aeonic.operations.temporal.civil-date.v1' },
|
|
12
|
+
finite: { title: 'Finite arithmetic', snapshot: '0.1', profile: 'aeonic.operations.arithmetic.exact.v1' },
|
|
13
|
+
rational: { title: 'Rational & rounding', snapshot: '0.2', profile: 'aeonic.operations.arithmetic.rational.v1' },
|
|
14
|
+
});
|
|
15
|
+
export function utf8Bytes(text, allowance) {
|
|
16
|
+
let bytes = 0;
|
|
17
|
+
for (const character of text) {
|
|
18
|
+
const point = character.codePointAt(0);
|
|
19
|
+
bytes += point <= 0x7f ? 1 : point <= 0x7ff ? 2 : point <= 0xffff ? 3 : 4;
|
|
20
|
+
if (bytes > allowance) break;
|
|
21
|
+
}
|
|
22
|
+
return bytes;
|
|
23
|
+
}
|
|
24
|
+
export function validateArithmeticInput(input, limits = ARITHMETIC_LIMITS) {
|
|
25
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)
|
|
26
|
+
|| Object.keys(input).some(key => !['lane', 'requestText', 'outputPolicyText'].includes(key))
|
|
27
|
+
|| !Object.hasOwn(input, 'lane') || !Object.hasOwn(input, 'requestText')
|
|
28
|
+
|| typeof input.lane !== 'string' || !Object.hasOwn(ARITHMETIC_LANES, input.lane) || typeof input.requestText !== 'string') {
|
|
29
|
+
throw new TypeError('Expected a finite/rational/civil-date/civil-date-time/civil-clock/anchoring capability and logical JSON request text.');
|
|
30
|
+
}
|
|
31
|
+
if (['temporal', 'datetime', 'clock', 'anchor'].includes(input.lane) && Object.hasOwn(input, 'outputPolicyText')) throw new TypeError('Temporal capabilities require explicit separate operations; numerical convenience policy is unavailable.');
|
|
32
|
+
const policy = Object.hasOwn(input, 'outputPolicyText') ? input.outputPolicyText : '';
|
|
33
|
+
if (typeof policy !== 'string') throw new TypeError('Output policy must be JSON text.');
|
|
34
|
+
if (policy.length > limits.outputPolicyBytes || utf8Bytes(policy, limits.outputPolicyBytes) > limits.outputPolicyBytes) {
|
|
35
|
+
throw new RangeError('Playground output policy exceeds 16 KiB.');
|
|
36
|
+
}
|
|
37
|
+
if (input.requestText.length + policy.length > limits.requestBytes
|
|
38
|
+
|| utf8Bytes(input.requestText, limits.requestBytes) + utf8Bytes(policy, limits.outputPolicyBytes) > limits.requestBytes) {
|
|
39
|
+
throw new RangeError('Playground request and output policy exceed 256 KiB.');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const authored = value => ({ number: { category: 'finiteNumber', value } });
|
|
43
|
+
const exact = (coefficient, exponent = '0', denominator) => ({ number: {
|
|
44
|
+
category: denominator ? 'exactRational' : 'exactNumber', coefficient, exponent,
|
|
45
|
+
...(denominator ? { denominator } : {}),
|
|
46
|
+
}, history: 'none-declared' });
|
|
47
|
+
const context = lane => ({ profile: ARITHMETIC_LANES[lane].profile });
|
|
48
|
+
const binary = (lane, operation, left, right) => ({ operation, input: { left, right, context: context(lane) } });
|
|
49
|
+
const grid = { increment: { category: 'exactNumber', coefficient: '1', exponent: '-2' }, rounding: 'half-even' };
|
|
50
|
+
export const ARITHMETIC_EXAMPLES = [
|
|
51
|
+
{ id: 'finite-sum', lane: 'finite', title: 'An exact decimal sum', detail: 'Calculate 0.1 + 0.2, then choose a Number representation.', request: binary('finite', 'add', authored('0.1'), authored('0.2')) },
|
|
52
|
+
{ id: 'finite-combined', lane: 'finite', title: 'A Number in one call', detail: 'Calculate and materialize decimal 0.3. Both steps keep their metadata.', request: binary('finite', 'add', authored('0.1'), authored('0.2')), output: { family: 'decimal' } },
|
|
53
|
+
{ id: 'third', lane: 'rational', title: 'One third, exactly', detail: 'Keep 1/3 exact. Multiply the returned bundle by 3 to recover 1.', request: binary('rational', 'divide', authored('1'), authored('3')) },
|
|
54
|
+
{ id: 'cancel', lane: 'rational', title: 'A rational becomes whole', detail: '(1/3) × 3 normalizes to an exact decimal result before materialization.', request: binary('rational', 'multiply', exact('1', '0', '3'), authored('3')) },
|
|
55
|
+
{ id: 'half', lane: 'rational', title: 'Add a third and a sixth', detail: 'All four binary operations accept rational operands. The sum is exact 0.5.', request: binary('rational', 'add', exact('1', '0', '3'), exact('5', '-1', '3')) },
|
|
56
|
+
{ id: 'combined-third', lane: 'rational', title: 'An explicitly rounded third', detail: 'Calculate, quantize to 0.01 using half-even, then materialize 0.33 in one call.', request: binary('rational', 'divide', authored('1'), authored('3')), output: { family: 'decimal', quantize: grid } },
|
|
57
|
+
{ id: 'negative-tie', lane: 'rational', title: 'Half-even at a negative tie', detail: 'At increment 0.1, -1.25 rounds to -1.2. Try any of the seven explicit modes.', request: { operation: 'quantize', input: { value: authored('-1.25'), context: context('rational'), policy: { ...grid, increment: { category: 'exactNumber', coefficient: '1', exponent: '-1' } } } } },
|
|
58
|
+
{ id: 'nickel', lane: 'rational', title: 'A 0.05 rounding grid', detail: 'The increment defines integer multiples through zero; it does not prescribe output scale.', request: { operation: 'quantize', input: { value: authored('0.175'), context: context('rational'), policy: { ...grid, increment: { category: 'exactNumber', coefficient: '5', exponent: '-2' } } } } },
|
|
59
|
+
{ id: 'zero-divisor', lane: 'rational', title: 'Division by zero', detail: 'The selected exact profile returns a diagnostic with no value.', request: binary('rational', 'divide', authored('1'), authored('0')) },
|
|
60
|
+
{ id: 'unrepresentable', lane: 'rational', title: 'A rational is not a Number literal', detail: 'Exact 1/3 cannot be materialized as a finite Number. Explicit quantization is a separate decision.', request: { operation: 'materialize', input: { value: exact('1', '0', '3'), context: context('rational'), policy: { family: 'decimal' } } } },
|
|
61
|
+
{ id: 'compact', lane: 'rational', title: 'A compact million-place exponent', detail: 'An already-on-grid value stays compact instead of expanding a million digits.', request: { operation: 'quantize', input: { value: authored('1e1000000'), context: context('rational'), policy: { ...grid, increment: { category: 'exactNumber', coefficient: '1', exponent: '0' } } } } },
|
|
62
|
+
];
|
|
63
|
+
export const VALUE_EXAMPLES = [...ARITHMETIC_EXAMPLES, ...TEMPORAL_EXAMPLES, ...DATETIME_EXAMPLES, ...CLOCK_EXAMPLES, ...ANCHOR_EXAMPLES];
|
|
64
|
+
export function continueArithmetic(value, lane, operation) {
|
|
65
|
+
if (lane === 'clock') {
|
|
66
|
+
if (!value?.temporal || !['civilClock', 'civilClockSet'].includes(value.temporal.category) || !['shiftClock', 'step', 'materialize'].includes(operation)) throw new TypeError('A clock continuation needs a complete civil-clock bundle.');
|
|
67
|
+
const input = { value: structuredClone(value), context: context(lane) };
|
|
68
|
+
if (operation === 'shiftClock') input.amount = authored('0.2');
|
|
69
|
+
else input.policy = operation === 'step' ? { clockForm: 'hour', count: '1' } : { clockForm: 'second' };
|
|
70
|
+
return { operation, input };
|
|
71
|
+
}
|
|
72
|
+
if (lane === 'datetime') {
|
|
73
|
+
if (!value?.temporal || !['civilDateTime', 'civilDateTimeSet'].includes(value.temporal.category) || !['shift', 'shiftClock', 'step', 'materialize'].includes(operation)) throw new TypeError('A date-time continuation needs a complete date-time bundle.');
|
|
74
|
+
const input = { value: structuredClone(value), context: context(lane) };
|
|
75
|
+
if (operation === 'shiftClock') input.amount = authored('0.2');
|
|
76
|
+
else input.policy = operation === 'shift' ? { unit: 'month', count: '1' } : { dateGranularity: 'month', clockForm: 'minute', ...(operation === 'step' ? { count: '1' } : {}) };
|
|
77
|
+
return { operation, input };
|
|
78
|
+
}
|
|
79
|
+
if (lane === 'temporal') {
|
|
80
|
+
if (!value?.temporal || !['shift', 'step', 'materialize'].includes(operation)) throw new TypeError('A temporal continuation needs a complete date bundle.');
|
|
81
|
+
return { operation, input: { value: structuredClone(value), context: context(lane), policy:
|
|
82
|
+
operation === 'shift' ? { unit: 'month', count: '1' } : { granularity: 'month', ...(operation === 'step' ? { count: '1' } : {}) } } };
|
|
83
|
+
}
|
|
84
|
+
if (!Object.hasOwn(ARITHMETIC_LANES, lane) || !['multiply', 'quantize', 'materialize'].includes(operation)
|
|
85
|
+
|| (operation === 'quantize' && lane !== 'rational')) throw new TypeError('Unsupported continuation.');
|
|
86
|
+
const bundle = structuredClone(value);
|
|
87
|
+
if (operation === 'multiply') return binary(lane, 'multiply', bundle, authored('3'));
|
|
88
|
+
return { operation, input: { value: bundle, context: context(lane), policy: operation === 'quantize' ? structuredClone(grid) : { family: 'decimal' } } };
|
|
89
|
+
}
|
|
90
|
+
export function arithmeticDisplay(number) {
|
|
91
|
+
if (number.category === 'finiteNumber') return number.value;
|
|
92
|
+
return number.coefficient + ' × 10^' + number.exponent + (number.category === 'exactRational' ? ' / ' + number.denominator : '');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function temporalDisplay(value) {
|
|
96
|
+
if (value.category === 'symbol') return '|' + value.value + '|';
|
|
97
|
+
if (value.temporal.category === 'civilDate') return value.temporal.value;
|
|
98
|
+
const ranges = value.temporal.ranges;
|
|
99
|
+
return ranges.slice(0, 4).map(r => r.start === r.end ? r.start : r.start + ' … ' + r.end).join(' ∪ ')
|
|
100
|
+
+ (ranges.length > 4 ? ' … (' + ranges.length + ' ranges)' : '');
|
|
101
|
+
}
|
|
102
|
+
export function describeArithmeticInput(lane, requestText) {
|
|
103
|
+
try {
|
|
104
|
+
validateArithmeticInput({ lane, requestText });
|
|
105
|
+
if (exceedsJsonDepth(requestText, 32)) return 'Review the request. The selected API validates it when run.';
|
|
106
|
+
const request = parseStrictJson(requestText), input = request?.input, policy = input?.policy;
|
|
107
|
+
const label = bundle => {
|
|
108
|
+
const v = ['temporal', 'datetime', 'clock', 'anchor'].includes(lane) ? bundle?.temporal ?? bundle?.number : bundle?.number;
|
|
109
|
+
if (['civilDate', 'civilDateTime', 'civilClock'].includes(v?.category) || v?.category === 'finiteNumber') return typeof v.value === 'string' ? v.value.slice(0, 60) : 'the operand';
|
|
110
|
+
if (['civilDateTimeSet', 'civilClockSet'].includes(v?.category)) return 'the exact point/interval bundle';
|
|
111
|
+
if (v?.category === 'civilDateSet') return 'the exact date-range bundle';
|
|
112
|
+
return 'the derived value';
|
|
113
|
+
};
|
|
114
|
+
if (!input || typeof request.operation !== 'string') return 'Review the request. The selected API validates it when run.';
|
|
115
|
+
const op = request.operation, text = v => typeof v === 'string' ? v.slice(0, 60) : 'unspecified';
|
|
116
|
+
if (lane === 'anchor' && op === 'anchor') return 'Anchor ' + label(input.clock) + ' to ' + label(input.anchor) + '. Day 0 uses that date; preserve carry, exact boundaries and both histories.';
|
|
117
|
+
if (lane === 'clock') {
|
|
118
|
+
if (op === 'shiftClock') return 'Shift ' + label(input.value) + ' by ' + label(input.amount) + ' civil-coordinate seconds. Preserve relative days, exact fractions and history.';
|
|
119
|
+
if (op === 'step') return 'Step ' + label(input.value) + ' by ' + text(policy?.count) + ' complete ' + text(policy?.clockForm) + ' forms, retaining relative days.';
|
|
120
|
+
if (op === 'materialize') return 'Materialize ' + label(input.value) + ' as an exact day-zero ' + text(policy?.clockForm) + ' clock. Carry cannot be discarded.';
|
|
121
|
+
}
|
|
122
|
+
if (lane === 'datetime') {
|
|
123
|
+
if (op === 'shiftClock') return 'Shift ' + label(input.value) + ' by ' + label(input.amount) + ' civil-coordinate seconds. Preserve exact fractions and history.';
|
|
124
|
+
if (op === 'shift') return 'Shift ' + label(input.value) + ' by ' + text(policy?.count) + ' ' + text(policy?.unit) + ', preserving every clock subset.';
|
|
125
|
+
if (op === 'step') return 'Step ' + label(input.value) + ' by ' + text(policy?.count) + ' complete ' + text(policy?.dateGranularity) + '/' + text(policy?.clockForm) + ' forms.';
|
|
126
|
+
if (op === 'materialize') return 'Materialize ' + label(input.value) + ' as an exact ' + text(policy?.dateGranularity) + '/' + text(policy?.clockForm) + ' form.';
|
|
127
|
+
}
|
|
128
|
+
if (lane === 'temporal') {
|
|
129
|
+
if (op === 'shift') return 'Shift ' + label(input.value) + ' by ' + text(policy?.count) + ' ' + text(policy?.unit) + '. Preserve exact coverage for chaining.';
|
|
130
|
+
if (op === 'step') return 'Step ' + label(input.value) + ' by ' + text(policy?.count) + ' complete ' + text(policy?.granularity) + ' periods.';
|
|
131
|
+
if (op === 'materialize') return 'Materialize ' + label(input.value) + ' as an exact ' + text(policy?.granularity) + ' date.';
|
|
132
|
+
}
|
|
133
|
+
if (['equal', 'compare', 'relate', 'add', 'subtract', 'multiply', 'divide'].includes(op)) return text(op) + ': ' + label(input.left) + ' and ' + label(input.right) + '. The selected API determines the result.';
|
|
134
|
+
return text(op) + ': ' + label(input.value) + '. Review the explicit policy before running.';
|
|
135
|
+
} catch { return 'Review the request. The selected API validates it when run.'; }
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function dateTimeDisplay(value) {
|
|
139
|
+
if (value.category === 'symbol') return '|' + value.value + '|';
|
|
140
|
+
if (value.temporal.category === 'civilDateTime') return value.temporal.value;
|
|
141
|
+
const pieces = value.temporal.pieces;
|
|
142
|
+
return pieces.slice(0, 3).map(p => p.kind === 'point' ? p.at
|
|
143
|
+
: (p.includeStart ? '[' : '(') + p.start + ' … ' + (typeof p.end === 'string' ? p.end : 'end of domain') + (p.includeEnd ? ']' : ')')).join(' ∪ ')
|
|
144
|
+
+ (pieces.length > 3 ? ' … (' + pieces.length + ' pieces)' : '');
|
|
145
|
+
}
|
|
146
|
+
export function dateTimeFacts(result) {
|
|
147
|
+
const rows = [['Current clamping', result.metadata.clamping]];
|
|
148
|
+
const add = (prefix, history, origin) => rows.push([prefix + 'date origin', origin.dateGranularity], [prefix + 'clock origin', origin.clockForm],
|
|
149
|
+
[prefix + 'clamping history', history.clamping], [prefix + 'approximation history', history.approximation]);
|
|
150
|
+
if (result.value.category === 'symbol') for (const side of ['left', 'right']) {
|
|
151
|
+
add(side === 'left' ? 'Left ' : 'Right ', result.metadata.operandHistory[side], result.metadata.operandOrigin[side]);
|
|
152
|
+
} else add('', result.value.history, { dateGranularity: result.value.originDateGranularity, clockForm: result.value.originClockForm });
|
|
153
|
+
return rows;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
export function clockDisplay(value) {
|
|
158
|
+
if (value.category === 'symbol') return '|' + value.value + '|';
|
|
159
|
+
if (value.temporal.category === 'civilClock') return value.temporal.value;
|
|
160
|
+
const coordinate = c => 'day ' + (c.day === '0' || c.day.startsWith('-') ? c.day : '+' + c.day) + ' · ' + c.time;
|
|
161
|
+
const pieces = value.temporal.pieces;
|
|
162
|
+
return pieces.slice(0, 3).map(p => p.kind === 'point' ? coordinate(p.at)
|
|
163
|
+
: (p.includeStart ? '[' : '(') + coordinate(p.start) + ' … ' + coordinate(p.end) + (p.includeEnd ? ']' : ')')).join(' ∪ ')
|
|
164
|
+
+ (pieces.length > 3 ? ' … (' + pieces.length + ' pieces)' : '');
|
|
165
|
+
}
|
|
166
|
+
export function clockFacts(result) {
|
|
167
|
+
if (result.value.category === 'symbol') return ['left', 'right'].flatMap(side => {
|
|
168
|
+
const prefix = side === 'left' ? 'Left ' : 'Right ';
|
|
169
|
+
return [[prefix + 'clock origin', result.metadata.operandOrigin[side]], [prefix + 'approximation history', result.metadata.operandHistory[side]]];
|
|
170
|
+
});
|
|
171
|
+
return [['Clock origin', result.value.originClockForm], ['Approximation history', result.value.history]];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Cross-lane actions prepare requests only. Each receiving API still validates
|
|
175
|
+
// exact coverage and requires its own explicitly selected profile.
|
|
176
|
+
export function prepareAnchoring(value) {
|
|
177
|
+
const category = value?.temporal?.category;
|
|
178
|
+
const anchor = { temporal: { category: 'civilDate', value: '2024-02-28' } };
|
|
179
|
+
const clock = { temporal: { category: 'civilClock', value: '09:30:00' } };
|
|
180
|
+
if (['civilDate', 'civilDateSet'].includes(category)) return { operation: 'anchor', input: { anchor: structuredClone(value), clock, context: context('anchor') } };
|
|
181
|
+
if (['civilClock', 'civilClockSet'].includes(category)) return { operation: 'anchor', input: { anchor, clock: structuredClone(value), context: context('anchor') } };
|
|
182
|
+
throw new TypeError('Anchoring needs a complete date or clock bundle.');
|
|
183
|
+
}
|
|
184
|
+
export function continueAnchoredDateTime(value) {
|
|
185
|
+
if (value?.temporal?.category !== 'civilDateTimeSet') throw new TypeError('Continue with a complete anchored date-time bundle.');
|
|
186
|
+
return continueArithmetic(value, 'datetime', 'shiftClock');
|
|
187
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { evaluateArithmeticPlayground } from './arithmetic-evaluator.mjs';
|
|
2
|
+
import { ARITHMETIC_LIMITS, utf8Bytes } from './arithmetic-model.mjs';
|
|
3
|
+
self.onmessage = ({ data }) => {
|
|
4
|
+
try {
|
|
5
|
+
const result = evaluateArithmeticPlayground(data);
|
|
6
|
+
const text = JSON.stringify(result);
|
|
7
|
+
if (text.length > ARITHMETIC_LIMITS.resultBytes || utf8Bytes(text, ARITHMETIC_LIMITS.resultBytes) > ARITHMETIC_LIMITS.resultBytes) {
|
|
8
|
+
throw new RangeError('Playground result exceeds 1 MiB.');
|
|
9
|
+
}
|
|
10
|
+
self.postMessage({ status: 'completed', result });
|
|
11
|
+
} catch (error) {
|
|
12
|
+
self.postMessage({ status: 'error', error: error instanceof Error ? error.message : String(error) });
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{color-scheme:light;--paper:#fffdf8;--wash:#f1eee7;--ink:#28362c;--muted:#636c62;--line:#d1d4c8;--green:#315640;--soft:#dfe9da;font-family:system-ui,sans-serif;color:var(--ink);background:var(--wash)}*{box-sizing:border-box}body{margin:0}a{color:inherit;text-underline-offset:4px}.skip{position:absolute;top:-100px}.skip:focus{top:8px;left:12px;z-index:2;background:var(--paper);padding:10px}header{display:flex;align-items:center;gap:22px;min-height:68px;padding:14px max(24px,calc((100vw - 1440px)/2));border-bottom:1px solid var(--line);background:var(--paper)}header>a{font:700 23px Georgia,serif;letter-spacing:-.04em;text-decoration:none}header>span{font-size:11px;color:var(--muted)}nav{display:flex;gap:20px;margin-left:auto;font-size:12px}main{max-width:1488px;margin:auto;padding:30px 24px 20px}.intro{display:flex;justify-content:space-between;gap:30px;align-items:center;margin-bottom:28px}.eyebrow,aside h2{font-size:10px;letter-spacing:.18em;text-transform:uppercase}h1{font:500 clamp(29px,3vw,42px)/1.12 Georgia,serif;letter-spacing:-.045em;margin:8px 0 16px}.intro p:last-child{font-size:13px;color:var(--muted)}.intro label{width:275px;flex-shrink:0}.workspace{display:grid;grid-template-columns:210px minmax(0,1.15fr) minmax(0,1fr);gap:20px;align-items:start}aside,.panel{min-width:0}.panel{padding:22px;background:var(--paper);border:1px solid var(--line);border-radius:7px}.panel h2{font:500 26px Georgia,serif;letter-spacing:-.03em;margin:0 0 18px;padding-bottom:14px;border-bottom:1px solid var(--line)}aside h2{margin:6px 0 18px}.example{display:block;text-align:left;width:100%;background:transparent;color:var(--ink);border:1px solid transparent;border-radius:4px;padding:12px 10px;font:12px/1.5 system-ui,sans-serif;cursor:pointer}.example[aria-pressed=true]{background:var(--soft);border-color:#c1d1bc}.aside-note{font-size:11px;line-height:1.7;color:var(--muted);border-top:1px solid var(--line);margin-top:24px;padding-top:18px}label{display:block;font-size:12px;font-weight:600;margin-bottom:18px}select,textarea{display:block;width:100%;margin-top:8px;border:1px solid #c4cabc;border-radius:3px;background:#fff;color:var(--ink);padding:11px;font:12px/1.6 ui-monospace,SFMono-Regular,Consolas,monospace}select{font:12px/1.5 system-ui,sans-serif}textarea{min-height:285px;resize:vertical;tab-size:2}#output-policy{min-height:135px}#description,.help,#result-state{font-size:12px;line-height:1.65;color:var(--muted)}#description{min-height:38px;margin:0 0 22px}.help{margin:8px 0 18px}button{font:12px/1.5 system-ui,sans-serif;cursor:pointer}button:disabled{opacity:.55;cursor:default}.actions{display:flex;align-items:center;flex-wrap:wrap;gap:12px;border-top:1px solid var(--line);padding:20px 0}#run{background:var(--green);border:1px solid var(--green);color:#fff;border-radius:4px;padding:12px 14px}kbd{font:10px system-ui,sans-serif;opacity:.65;margin-left:12px}#cancel,.continuations button{background:var(--paper);color:var(--ink);border:1px solid var(--line);border-radius:4px;padding:8px 10px}#run-state{font-size:11px;color:var(--muted)}details{border-top:1px solid var(--line);padding-top:16px;margin-top:18px}summary{font-size:11px;cursor:pointer;color:var(--muted)}code,pre{font:11px/1.65 ui-monospace,SFMono-Regular,Consolas,monospace}code{display:block;margin-top:12px;overflow-wrap:anywhere}pre{white-space:pre-wrap;overflow-wrap:anywhere;max-height:430px;overflow:auto}.number{font:500 30px/1.4 Georgia,serif;overflow-wrap:anywhere;letter-spacing:-.03em;margin:22px 0 8px}.kind{font-size:11px;color:var(--muted);margin-bottom:24px}dl{display:grid;grid-template-columns:minmax(85px,auto) minmax(0,1fr);gap:10px 15px;font-size:11px;line-height:1.6}dt{color:var(--muted)}dd{margin:0;overflow-wrap:anywhere}.continuations{display:flex;gap:6px;flex-wrap:wrap}#continue{border-top:1px solid var(--line);margin-top:22px;padding-top:10px}footer{margin-top:30px;font-size:10px;color:var(--muted)}[hidden]{display:none!important}:focus-visible{outline:2px solid #517956;outline-offset:3px}@media(max-width:1100px){.workspace{grid-template-columns:180px minmax(0,1fr)}.result{grid-column:2}.intro{gap:20px}.intro label{width:240px}}@media(max-width:760px){header{padding:16px;gap:12px;flex-wrap:wrap}header>span{display:none}nav{font-size:11px;gap:14px}.intro{display:block}.intro label{width:100%;margin-top:22px}main{padding:24px 14px}.workspace{grid-template-columns:minmax(0,1fr)}.result{grid-column:auto}#examples{display:flex;gap:6px;overflow-x:auto;max-width:100%;padding-bottom:8px}.example{flex:0 0 160px}.aside-note{display:none}.panel{padding:18px}textarea{min-height:260px}.number{font-size:27px}}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
5
|
+
<title>SANSA value operations playground</title><link rel="stylesheet" href="./arithmetic.css">
|
|
6
|
+
<script type="module" src="./arithmetic.mjs"></script>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<a class="skip" href="#workspace">Skip to operation</a>
|
|
10
|
+
<header><a href="./">SANSA Playground</a><span>Local source</span><nav><a href="./">Resolve & Query</a><a href="https://github.com/AltoPelago/sansa">Repository ↗</a></nav></header>
|
|
11
|
+
<main>
|
|
12
|
+
<section class="intro"><div><p class="eyebrow">AEONIC OPERATIONS IN SANSA</p><h1>Exact values. Explicit decisions.</h1><p>Calculate exact numbers or civil-date, date-time and standalone clock sets, anchor clocks to exact dates, preserve their history, and materialize explicitly.</p></div><label>Capability<select id="lane"><option value="anchor">Date anchoring · snapshot 0.1</option><option value="clock">Civil clocks · snapshot 0.1</option><option value="datetime">Civil date-times · snapshot 0.1</option><option value="temporal">Civil dates · snapshot 0.1</option><option value="finite">Finite arithmetic · snapshot 0.1</option><option value="rational">Rational & rounding · snapshot 0.2</option></select></label></section>
|
|
13
|
+
<div class="workspace" id="workspace">
|
|
14
|
+
<aside><h2>Starting points</h2><div id="examples"></div><p class="aside-note">Keep complete returned bundles for chaining. Materialization selects a representation only when the exact value fits.</p></aside>
|
|
15
|
+
<section class="panel" aria-labelledby="input-title"><h2 id="input-title">Your operation</h2><p id="description"></p><details><summary>Starting example</summary><p id="starting-point"></p></details>
|
|
16
|
+
<label id="result-mode-field">Result mode<select id="result-mode"><option value="exact">Exact result · separate materialization</option><option value="combined">Calculate and materialize · one call</option></select></label>
|
|
17
|
+
<label>Logical request JSON<textarea id="request" spellcheck="false" maxlength="262144" aria-describedby="request-help"></textarea></label><p class="help" id="request-help">Sent verbatim to the selected text API. Date ranges and point/interval sets carry origins and histories; clocks also retain signed relative days. numbers use exact numerical text. Duplicate keys remain visible to validation.</p>
|
|
18
|
+
<div id="output-editor" hidden><label>Combined output policy JSON<textarea id="output-policy" spellcheck="false" maxlength="16384"></textarea></label><p class="help">Select an output family. Rational quantization also requires an increment and rounding mode.</p></div>
|
|
19
|
+
<div class="actions"><button id="run" type="button">Run operation <kbd>⌘/Ctrl ↵</kbd></button><button id="cancel" type="button" hidden>Cancel</button><span id="run-state" role="status" aria-live="polite">Ready</span></div>
|
|
20
|
+
<details><summary>Capability profile</summary><code id="profile"></code></details>
|
|
21
|
+
</section>
|
|
22
|
+
<section class="panel result" aria-labelledby="result-title"><h2 id="result-title">Result</h2><p id="result-state" role="status" aria-live="polite">Run an operation to see its value or diagnostic.</p><div id="result"></div>
|
|
23
|
+
<div id="continue" hidden><p class="help">Continue with the complete returned bundle</p><div class="continuations"><button type="button" id="anchor-result" hidden>Anchor this value</button><button type="button" id="datetime-result" hidden>Shift as date-time</button><button type="button" data-continue="shift">Shift one month</button><button type="button" data-continue="shiftClock">Shift 0.2 clock seconds</button><button type="button" data-continue="step">Step one month</button><button type="button" data-continue="multiply">Multiply by 3</button><button type="button" data-continue="quantize">Quantize result</button><button type="button" data-continue="materialize">Materialize result</button></div></div>
|
|
24
|
+
<details id="raw-result" hidden><summary>Complete API response</summary><pre id="response"></pre></details>
|
|
25
|
+
<p class="help">Diagnostics produce no value. Saving bare Number, date or clock text discards separate metadata. A containing-period display never widens exact date ranges or point/interval sets. Civil clock shifts do not resolve timezone or elapsed time.</p>
|
|
26
|
+
</section></div>
|
|
27
|
+
<footer>JavaScript from this SANSA checkout · 256 KiB input · 4s per run · source API defaults</footer>
|
|
28
|
+
</main>
|
|
29
|
+
</body></html>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { ARITHMETIC_LANES, VALUE_EXAMPLES, ARITHMETIC_LIMITS,
|
|
2
|
+
validateArithmeticInput, continueArithmetic, prepareAnchoring, continueAnchoredDateTime, arithmeticDisplay, temporalDisplay, dateTimeDisplay, dateTimeFacts, clockDisplay, clockFacts, describeArithmeticInput } from './arithmetic-model.mjs';
|
|
3
|
+
const $ = id => document.getElementById(id);
|
|
4
|
+
const state = { worker: null, timer: null, value: null };
|
|
5
|
+
const element = (tag, text) => { const item = document.createElement(tag); item.textContent = text; return item; };
|
|
6
|
+
function stop() {
|
|
7
|
+
if (state.worker) state.worker.terminate();
|
|
8
|
+
state.worker = null; clearTimeout(state.timer); state.timer = null;
|
|
9
|
+
$('run').disabled = false; $('cancel').hidden = true;
|
|
10
|
+
}
|
|
11
|
+
function clear(message = 'Inputs changed. Run the operation again.') {
|
|
12
|
+
stop(); state.value = null; $('continue').hidden = true; $('raw-result').hidden = true;
|
|
13
|
+
$('response').textContent = ''; $('result').replaceChildren(); $('result-state').textContent = message;
|
|
14
|
+
}
|
|
15
|
+
function controls() {
|
|
16
|
+
const temporal = ['temporal', 'datetime', 'clock', 'anchor'].includes($('lane').value);
|
|
17
|
+
if (temporal) $('result-mode').value = 'exact';
|
|
18
|
+
$('result-mode-field').hidden = temporal;
|
|
19
|
+
$('output-editor').hidden = $('result-mode').value !== 'combined';
|
|
20
|
+
$('profile').textContent = ARITHMETIC_LANES[$('lane').value].profile;
|
|
21
|
+
for (const button of document.querySelectorAll('[data-continue]')) {
|
|
22
|
+
const op = button.dataset.continue;
|
|
23
|
+
if (op === 'step') button.textContent = $('lane').value === 'clock' ? 'Step one hour' : 'Step one month';
|
|
24
|
+
button.hidden = temporal ? !($('lane').value === 'anchor' ? [] : $('lane').value === 'clock' ? ['shiftClock', 'step', 'materialize'] : ['shift', 'step', 'materialize', ...($('lane').value === 'datetime' ? ['shiftClock'] : [])]).includes(op) : !['multiply', 'materialize', ...($('lane').value === 'rational' ? ['quantize'] : [])].includes(op);
|
|
25
|
+
}
|
|
26
|
+
$('anchor-result').hidden = !['temporal', 'clock'].includes($('lane').value);
|
|
27
|
+
$('anchor-result').textContent = $('lane').value === 'clock' ? 'Anchor this clock' : 'Use as anchor date';
|
|
28
|
+
$('datetime-result').hidden = $('lane').value !== 'anchor';
|
|
29
|
+
$('description').textContent = describeArithmeticInput($('lane').value, $('request').value);
|
|
30
|
+
}
|
|
31
|
+
function load(example) {
|
|
32
|
+
clear('Run an operation to see its value or diagnostic.');
|
|
33
|
+
$('lane').value = example.lane; $('starting-point').textContent = example.detail;
|
|
34
|
+
$('request').value = JSON.stringify(example.request, null, 2);
|
|
35
|
+
$('result-mode').value = example.output ? 'combined' : 'exact';
|
|
36
|
+
$('output-policy').value = JSON.stringify(example.output ?? { family: 'decimal' }, null, 2);
|
|
37
|
+
$('examples').replaceChildren(...VALUE_EXAMPLES.filter(item => item.lane === example.lane).map(item => {
|
|
38
|
+
const button = element('button', item.title); button.type = 'button'; button.className = 'example';
|
|
39
|
+
button.setAttribute('aria-pressed', String(item.id === example.id)); button.addEventListener('click', () => load(item)); return button;
|
|
40
|
+
}));
|
|
41
|
+
controls(); $('run-state').textContent = 'Ready';
|
|
42
|
+
}
|
|
43
|
+
function facts(rows) {
|
|
44
|
+
const list = document.createElement('dl');
|
|
45
|
+
for (const [name, value] of rows) {
|
|
46
|
+
const text = String(value);
|
|
47
|
+
list.append(element('dt', name), element('dd', text.length > 300 ? text.slice(0, 300) + '…' : text));
|
|
48
|
+
}
|
|
49
|
+
return list;
|
|
50
|
+
}
|
|
51
|
+
function render(result) {
|
|
52
|
+
const box = $('result');
|
|
53
|
+
if (result.outcome === 'diagnostic') {
|
|
54
|
+
const reason = element('p', result.reason); reason.className = 'number'; box.append(reason, element('p', 'Diagnostic · no value produced'));
|
|
55
|
+
box.append(facts([...(result.step ? [['Failed step', result.step]] : []), ['Stage', String(result.context.stage)], ['Path', result.context.path ?? 'Operation root']]));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const temporal = ['temporal', 'datetime', 'clock', 'anchor'].includes($('lane').value);
|
|
59
|
+
const symbol = result.value.category === 'symbol';
|
|
60
|
+
state.value = symbol ? null : result.value;
|
|
61
|
+
const display = temporal ? ($('lane').value === 'clock' ? clockDisplay(result.value) : ['datetime', 'anchor'].includes($('lane').value) ? dateTimeDisplay(result.value) : temporalDisplay(result.value)) : arithmeticDisplay(result.value.number), number = element('p', display.length > 300 ? display.slice(0, 300) + '…' : display);
|
|
62
|
+
number.className = 'number'; box.append(number);
|
|
63
|
+
const kind = element('p', temporal ? (symbol ? ($('lane').value === 'clock' ? 'Symbolic clock-set outcome' : 'Symbolic date-set outcome') : ($('lane').value === 'clock' ? 'Exact civil-clock bundle' : ['datetime', 'anchor'].includes($('lane').value) ? 'Exact civil-date-time bundle' : 'Exact civil-date bundle')) : { finiteNumber: 'Materialized AEON Number', exactNumber: 'Exact derived decimal', exactRational: 'Exact derived rational · no fraction literal' }[result.value.number.category]); kind.className = 'kind'; box.append(kind);
|
|
64
|
+
const steps = result.metadata.steps;
|
|
65
|
+
box.append(facts([...(steps ? steps.map(step => [step.step, step.metadata.evaluation]) : [['Current operation', result.metadata.evaluation]]), ...($('lane').value === 'clock' ? clockFacts(result) : ['datetime', 'anchor'].includes($('lane').value) ? dateTimeFacts(result) : temporal ? [['Current clamping', result.metadata.clamping], ...(symbol ? [['Left history', result.metadata.operandHistory.left], ['Right history', result.metadata.operandHistory.right]] : [['Origin granularity', result.value.originGranularity], ['Clamping history', result.value.history]])] : [['Approximation history', result.value.history]])]));
|
|
66
|
+
const details = document.createElement('details'); details.append(element('summary', steps ? 'Step policies & evaluation' : 'Effective policy'), element('pre', JSON.stringify(steps ?? result.metadata.effectivePolicy, null, 2))); box.append(details);
|
|
67
|
+
$('continue').hidden = symbol;
|
|
68
|
+
}
|
|
69
|
+
function run() {
|
|
70
|
+
clear('Running the selected source API…'); $('run-state').textContent = 'Running…';
|
|
71
|
+
const input = { lane: $('lane').value, requestText: $('request').value,
|
|
72
|
+
...($('result-mode').value === 'combined' ? { outputPolicyText: $('output-policy').value } : {}) };
|
|
73
|
+
try {
|
|
74
|
+
validateArithmeticInput(input);
|
|
75
|
+
const worker = new Worker(new URL('./arithmetic-worker.mjs', import.meta.url), { type: 'module' });
|
|
76
|
+
state.worker = worker; $('run').disabled = true; $('cancel').hidden = false;
|
|
77
|
+
const failed = message => { if (state.worker !== worker) return; clear(message); $('run-state').textContent = 'Playground error'; };
|
|
78
|
+
worker.onerror = event => { event.preventDefault(); failed('Worker could not complete: ' + event.message); };
|
|
79
|
+
worker.onmessage = ({ data }) => {
|
|
80
|
+
if (state.worker !== worker) return;
|
|
81
|
+
if (data.status !== 'completed') { failed(data.error); return; }
|
|
82
|
+
stop(); render(data.result); $('result-state').textContent = 'Completed · result comes directly from the SANSA source API.';
|
|
83
|
+
$('run-state').textContent = 'Completed'; $('response').textContent = JSON.stringify(data.result, null, 2); $('raw-result').hidden = false;
|
|
84
|
+
};
|
|
85
|
+
state.timer = setTimeout(() => failed('Playground execution exceeded 4 seconds. No value retained.'), ARITHMETIC_LIMITS.timeoutMs);
|
|
86
|
+
worker.postMessage(input);
|
|
87
|
+
} catch (error) { clear(error instanceof Error ? error.message : String(error)); $('run-state').textContent = 'Playground input error'; }
|
|
88
|
+
}
|
|
89
|
+
for (const id of ['request', 'output-policy', 'result-mode']) $(id).addEventListener('input', () => { clear(); controls(); $('run-state').textContent = 'Ready · inputs changed'; });
|
|
90
|
+
$('lane').addEventListener('change', () => load(VALUE_EXAMPLES.find(item => item.lane === $('lane').value)));
|
|
91
|
+
$('run').addEventListener('click', run);
|
|
92
|
+
$('cancel').addEventListener('click', () => { clear('Cancelled. No value retained.'); $('run-state').textContent = 'Cancelled'; });
|
|
93
|
+
// Prepared requests stay compact so indentation cannot consume an API's
|
|
94
|
+
// logical request allowance. Full bundles and explicit policies are retained.
|
|
95
|
+
for (const button of document.querySelectorAll('[data-continue]')) button.addEventListener('click', () => {
|
|
96
|
+
if (!state.value) return;
|
|
97
|
+
const request = continueArithmetic(state.value, $('lane').value, button.dataset.continue);
|
|
98
|
+
clear('Continuation prepared. Review its explicit policy, then run.'); $('request').value = JSON.stringify(request);
|
|
99
|
+
$('result-mode').value = 'exact'; controls(); $('run-state').textContent = 'Ready · using returned bundle'; $('request').focus();
|
|
100
|
+
});
|
|
101
|
+
for (const [id, lane, prepare] of [['anchor-result', 'anchor', prepareAnchoring], ['datetime-result', 'datetime', continueAnchoredDateTime]]) $(id).addEventListener('click', () => {
|
|
102
|
+
if (!state.value) return;
|
|
103
|
+
const request = prepare(state.value);
|
|
104
|
+
load(VALUE_EXAMPLES.find(item => item.lane === lane));
|
|
105
|
+
$('request').value = JSON.stringify(request);
|
|
106
|
+
clear('Continuation prepared. Review the receiving profile and request, then run.');
|
|
107
|
+
controls(); $('run-state').textContent = 'Ready · using returned bundle'; $('request').focus();
|
|
108
|
+
});
|
|
109
|
+
document.addEventListener('keydown', event => { if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') { event.preventDefault(); if (!state.worker) run(); } });
|
|
110
|
+
load(VALUE_EXAMPLES.find(item => item.id === 'third'));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const b = value => ({ number: { category: 'finiteNumber', value } });
|
|
2
|
+
const clock = value => ({ temporal: { category: 'civilClock', value } });
|
|
3
|
+
const clockSet = (day, time) => ({ temporal: { category: 'civilClockSet', pieces: [{ kind: 'point', at: { day, time } }] }, originClockForm: 'second', history: 'none-declared' });
|
|
4
|
+
const clockRequest = (operation, value, other, policy) => ({ operation, input: { context: { profile: 'aeonic.operations.temporal.civil-clock.v1' },
|
|
5
|
+
...(['equal', 'compare', 'relate'].includes(operation) ? { left: value, right: other } : { value, ...(operation === 'shiftClock' ? { amount: other } : {}) }), ...(policy ? { policy } : {}) } });
|
|
6
|
+
export const CLOCK_EXAMPLES = [
|
|
7
|
+
{ id: 'clock-midnight', lane: 'clock', title: 'Keep the midnight carry', detail: '23:30 plus two civil hours gives day +1 at 01:30. Reuse the exact bundle to reverse the shift.', request: clockRequest('shiftClock', clock('23:30:00'), b('7200')) },
|
|
8
|
+
{ id: 'clock-borrow', lane: 'clock', title: 'Before reference midnight', detail: 'Subtract half a second from midnight: day −1 at 23:59:59.5. Negative coordinates use mathematical floor.', request: clockRequest('shiftClock', clock('00:00:00'), b('-0.5')) },
|
|
9
|
+
{ id: 'clock-minute', lane: 'clock', title: 'A minute crossing midnight', detail: 'A half-second shift keeps an exact interval crossing into day +1, preserving its excluded end.', request: clockRequest('shiftClock', clock('23:59'), b('0.5')) },
|
|
10
|
+
{ id: 'clock-step', lane: 'clock', title: 'Step one complete hour', detail: 'Stepping the 23: hour gives the 00: hour on day +1. It is not wrapped to day zero.', request: clockRequest('step', clock('23:'), undefined, { clockForm: 'hour', count: '1' }) },
|
|
11
|
+
{ id: 'clock-last-hour', lane: 'clock', title: 'Materialize the last hour', detail: 'The last hour begins on day 0 and ends at excluded day +1 midnight. It materializes exactly.', request: clockRequest('materialize', clock('23:'), undefined, { clockForm: 'hour' }) },
|
|
12
|
+
{ id: 'clock-output-carry', lane: 'clock', title: 'Materialization keeps day meaning', detail: 'A day +1 point cannot become a bare day-zero clock. The result is a diagnostic with no value.', request: clockRequest('materialize', clockSet('1', '01:30:00'), undefined, { clockForm: 'second' }) },
|
|
13
|
+
{ id: 'clock-day-equality', lane: 'clock', title: 'Same face, different day', detail: '01:30 on day +1 is not equal to authored 01:30 on day 0.', request: clockRequest('equal', clockSet('1', '01:30:00'), clock('01:30:00')) },
|
|
14
|
+
{ id: 'clock-containment', lane: 'clock', title: 'Minute contains its first point', detail: 'Relate an exact minute to its included starting second. Relations return symbols.', request: clockRequest('relate', clock('09:30'), clock('09:30:00')) },
|
|
15
|
+
{ id: 'clock-history', lane: 'clock', title: 'Keep approximation history', detail: 'The shift is exact for the supplied amount. Its declared earlier approximation remains attached to the result.', request: clockRequest('shiftClock', clock('23:59:59.9'), { number: { category: 'exactNumber', coefficient: '2', exponent: '-1' }, history: 'approximation-declared' }) },
|
|
16
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const b = value => ({ number: { category: 'finiteNumber', value } });
|
|
2
|
+
const dt = value => ({ temporal: { category: 'civilDateTime', value } });
|
|
3
|
+
const points = pieces => ({ temporal: { category: 'civilDateTimeSet', pieces }, originDateGranularity: 'undeclared', originClockForm: 'undeclared', history: { clamping: 'none-declared', approximation: 'none-declared' } });
|
|
4
|
+
const interval = (start, end, includeStart = true, includeEnd = false) => ({ kind: 'interval', start, end, includeStart, includeEnd });
|
|
5
|
+
const datetimeRequest = (operation, value, other, policy) => ({ operation, input: {
|
|
6
|
+
context: { profile: 'aeonic.operations.temporal.civil-datetime.v1' },
|
|
7
|
+
...(['shift', 'shiftClock', 'step', 'materialize'].includes(operation) ? { value, ...(operation === 'shiftClock' ? { amount: other } : {}) } : { left: value, right: other }),
|
|
8
|
+
...(policy ? { policy } : {}),
|
|
9
|
+
} });
|
|
10
|
+
export const DATETIME_EXAMPLES = [
|
|
11
|
+
{ id: 'datetime-clock-carry', lane: 'datetime', title: 'Exact clock carry', detail: 'Add 0.2 civil-coordinate seconds across midnight, preserving exact fractional seconds.', request: datetimeRequest('shiftClock', dt('2024-03-01T23:59:59.9'), b('0.2')) },
|
|
12
|
+
{ id: 'datetime-month-shift', lane: 'datetime', title: 'Shift February’s minutes', detail: 'February’s daily 09:30 minutes shift to March 1–29. Later calculations retain those exact intervals.', request: datetimeRequest('shift', dt('2024-02T09:30'), undefined, { unit: 'month', count: '1' }) },
|
|
13
|
+
{ id: 'datetime-month-step', lane: 'datetime', title: 'Step the complete month form', detail: 'Stepping the February form produces the daily 09:30 minutes on every date of March, including March 30–31.', request: datetimeRequest('step', dt('2024-02T09:30'), undefined, { dateGranularity: 'month', clockForm: 'minute', count: '1' }) },
|
|
14
|
+
{ id: 'datetime-reordered-clamp', lane: 'datetime', title: 'Clamping preserves clock gaps', detail: 'Two source days clamp to February 28. The early and late clock windows remain disconnected after reordering.', request: datetimeRequest('shift', points([interval('2023-01-30T23:00:00', '2023-01-31T01:00:00')]), undefined, { unit: 'month', count: '1' }) },
|
|
15
|
+
{ id: 'datetime-open-boundary', lane: 'datetime', title: 'Excluded endpoint', detail: 'The 09:30 minute excludes 09:31:00. The two exact sets are disjoint.', request: datetimeRequest('relate', dt('2024-03-01T09:30'), dt('2024-03-01T09:31:00')) },
|
|
16
|
+
{ id: 'datetime-reduced-date', lane: 'datetime', title: 'A point on every date', detail: 'Reduced dates preserve every compatible date. Authored .1 and .10 cover identical second coordinates.', request: datetimeRequest('equal', dt('2024-T09:30:00.1'), dt('2024-T09:30:00.10')) },
|
|
17
|
+
{ id: 'datetime-history', lane: 'datetime', title: 'A previously rounded amount', detail: 'A derived finite-decimal amount feeds the clock shift directly. Its approximation marker remains attached to the exact result.', request: datetimeRequest('shiftClock', dt('2023-01-31T09:30:00'), { number: { category: 'exactNumber', coefficient: '2', exponent: '-1' }, history: 'approximation-declared' }) },
|
|
18
|
+
{ id: 'datetime-final-minute', lane: 'datetime', title: 'Last minute in the domain', detail: 'The excluded end-of-domain marker preserves the complete last minute without admitting year 10000 as a value.', request: datetimeRequest('shiftClock', dt('9999-12-31T23:59'), b('0')) },
|
|
19
|
+
{ id: 'datetime-materialize', lane: 'datetime', title: 'Materialize an exact form', detail: 'Exact coverage matches the requested month/minute form. Both origin markers and both histories remain in the envelope.', request: datetimeRequest('materialize', dt('2024-03T09:30'), undefined, { dateGranularity: 'month', clockForm: 'minute' }) },
|
|
20
|
+
{ id: 'datetime-partial-output', lane: 'datetime', title: 'No widening into a month', detail: 'March 1–29 at 09:30 cannot materialize as the complete March form. It produces a diagnostic and no value.', request: datetimeRequest('materialize', points(Array.from({ length: 29 }, (_, i) => interval(`2024-03-${String(i + 1).padStart(2, '0')}T09:30:00`, `2024-03-${String(i + 1).padStart(2, '0')}T09:31:00`))), undefined, { dateGranularity: 'month', clockForm: 'minute' }) },
|
|
21
|
+
{ id: 'datetime-fine-fraction', lane: 'datetime', title: 'Beyond nanoseconds', detail: 'An exact picosecond shift is admitted within resource limits. No automatic rounding occurs.', request: datetimeRequest('shiftClock', dt('2024-03-01T09:30:00'), b('1e-12')) },
|
|
22
|
+
];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const inventory = String.raw`inventory:object = {
|
|
2
|
+
items:list<object> = [
|
|
3
|
+
\item1\ = { sku = "A-100", name\name1\ = "Widget", qty = 12 }
|
|
4
|
+
\item2\ = { sku = "B-200", name\name2\ = "Bracket", qty = 5 }
|
|
5
|
+
]
|
|
6
|
+
}`;
|
|
7
|
+
const propertySource = String.raw`group = { "" = "empty", "a*" = "literal", "😀" = "Unicode" }
|
|
8
|
+
value = <widget("hello")>
|
|
9
|
+
plain = { tag = "widget" }
|
|
10
|
+
reading@{"" = "unit"} = 42`;
|
|
11
|
+
const examples = {
|
|
12
|
+
identity: {label: 'Child identities', source: inventory, address: "$.inventory.items.\\item1\\.\\name1\\"},
|
|
13
|
+
reordered: {label: 'Reordered list', source: String.raw`items = [
|
|
14
|
+
\item2\ = { name = "Bracket" }
|
|
15
|
+
\item1\ = { name = "Widget" }
|
|
16
|
+
]`, address: "$.items.\\item1\\.name"},
|
|
17
|
+
children: {label: 'Scope children', source: String.raw`group\a\ = { nested\b\ = "world" }`, scope: '$.group', address: "$.\\b\\"},
|
|
18
|
+
root: {label: 'Scope root is excluded', source: String.raw`group\a\ = { nested\b\ = "world" }`, scope: '$.group', address: "$.\\a\\"},
|
|
19
|
+
missing: {label: 'Missing identity', source: inventory, address: "$.inventory.items.\\missing\\"},
|
|
20
|
+
budget: {label: 'Inspection limit', source: inventory, inspections: 1, address: "$.inventory.items.\\item1\\"},
|
|
21
|
+
exact: {label: 'Exact path', source: inventory, address: '$.inventory.items[0].sku'},
|
|
22
|
+
expansion: {label: 'List expansion', source: inventory, address: '$.inventory.items.*.sku'},
|
|
23
|
+
attributes: {label: 'Attribute identity', source: String.raw`reading@{unit\unit1\ = "cm"}:number = 42`, address: "$.reading.@.\\unit1\\"},
|
|
24
|
+
propertyKey: {label: 'Property: empty key', source: propertySource, address: '$.group.*&key("")', expectedPaths: ['$.group.[""]']},
|
|
25
|
+
propertyLiteral: {label: 'Property: literal key', source: propertySource, address: '$.group.*&key("a*")', expectedPaths: ['$.group.["a*"]']},
|
|
26
|
+
propertyUnicode: {label: 'Property: Unicode key', source: propertySource, address: '$.group.*&key("😀")', expectedPaths: ['$.group.["😀"]']},
|
|
27
|
+
propertyTag: {label: 'Property: node tag', source: propertySource, address: '$.*&key("value")&tag("widget")', expectedPaths: ['$.value']},
|
|
28
|
+
propertyHead: {label: 'Property: direct head', source: propertySource, address: '$.value[0]&headTag("widget")', expectedPaths: ['$.value[0]']},
|
|
29
|
+
propertyRecursive: {label: 'Property: recursive containers', source: propertySource, address: '$.**&tag("widget")', expectedPaths: ['$.value']},
|
|
30
|
+
propertyRecursiveHeads: {label: 'Property: recursive heads', source: propertySource, address: '$.**&headTag("widget")', expectedPaths: ['$.value[0]']},
|
|
31
|
+
propertyWrongKind: {label: 'Property: heads are not containers', source: propertySource, address: '$.value[0]&tag("widget")', expectedPaths: []},
|
|
32
|
+
propertyNoField: {label: 'Property: fields are not tags', source: propertySource, address: '$.plain&tag("widget")', expectedPaths: []},
|
|
33
|
+
propertyRoot: {label: 'Property: root key hidden', source: propertySource, scope: '$.value', address: '$&key("value")', expectedPaths: []},
|
|
34
|
+
propertyRootTag: {label: 'Property: root tag', source: propertySource, scope: '$.value', address: '$&tag("widget")', expectedPaths: ['$.value']},
|
|
35
|
+
propertyAttribute: {label: 'Property: attribute space', source: propertySource, address: '$.reading.@.*&key("")', expectedPaths: ['$.reading.@.[""]']},
|
|
36
|
+
propertyBudget: {label: 'Property: inspection limit', source: propertySource, propertyInspections: 1, address: '$.value&tag("widget")', expectedCode: 'SANSA_RESOLVE_PROPERTY_LIMIT_EXCEEDED'},
|
|
37
|
+
propertyQuery: {label: 'Property Query: current row', source: propertySource, address: '$', view: 'query', query: 'from $.*&key("value")\nselect .&tag("widget")', expectedCandidatePaths: ['$.value'], expectedQueryPaths: ['$.value']},
|
|
38
|
+
propertyQueryContext: {label: 'Property Query: scope root', source: propertySource, address: '$', view: 'query', query: 'from $.value\nselect ?&key("value")', expectedCandidatePaths: ['$.value'], expectedQueryPaths: []},
|
|
39
|
+
query: {label: 'Query', source: inventory, address: '$.inventory.items', view: 'query', query: 'from $.inventory.items.*\nwhere .qty >= 6\nselect .name'},
|
|
40
|
+
queryIdentity: {label: 'Query child identities', source: inventory, address: '$.inventory.items', view: 'query', query: "from $.inventory.items.\\item1\\\nselect .\\name1\\"},
|
|
41
|
+
};
|
|
42
|
+
window.SansaPlaygroundExamples = Object.fromEntries(Object.entries(examples).map(([key, value]) => [key, {
|
|
43
|
+
mode: 'transport', view: 'resolve', scope: '$', inspections: 10000, propertyInspections: 10000, query: '', addressKind: 'selector', ...value,
|
|
44
|
+
}]));
|
|
45
|
+
document.querySelector('[data-example-tabs]').innerHTML = Object.entries(examples).map(([key, value], i) =>
|
|
46
|
+
`<button class="playground-example-tab${i === 0 ? ' is-active' : ''}" type="button" data-sansa-example-key="${key}" aria-pressed="${i === 0}">${value.label}</button>`).join('');
|