@altopelago/sansa 0.13.0 → 0.14.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.
- package/CHANGELOG.md +61 -0
- package/conformance/cts-claims.json +1 -1
- package/docs/api-contract.md +43 -1
- package/docs/capabilities.json +1 -1
- package/docs/releasing.md +4 -1
- package/package.json +1 -1
- package/src/index.js +77 -50
- package/tools/mutate-web/runtime.mjs +13 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,67 @@ versions may still include breaking changes when the SANSA specifications move.
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 0.14.1 - 2026-10-16
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Aligned JavaScript and Rust temporal literals and AEON target validation with
|
|
15
|
+
AEON 0.14.0's year/month date ticks composed with clocks. Exact authored
|
|
16
|
+
fractional seconds, second 60, offset anchors and opaque WTC contexts remain
|
|
17
|
+
intact; GP/schema limits are not imposed by the parser.
|
|
18
|
+
- Rejected malformed clock/date fields, noncanonical `Local` case variants,
|
|
19
|
+
and comment-looking suffixes inside WTC contexts, including nested expressions.
|
|
20
|
+
Rust target validation checks the complete payload rather than parsing away
|
|
21
|
+
trailing trivia. Temporal relation helpers fail closed on malformed descriptors
|
|
22
|
+
and unsupported disjoint date/clock completion sets without panicking or
|
|
23
|
+
inventing omitted calendar fields.
|
|
24
|
+
- Updated AEON mutation target validation for the recent reserved `base64`
|
|
25
|
+
decodability rule, while retaining opaque `encoding`, `inline` and `embed`
|
|
26
|
+
payload semantics. Clone/pointer reference addresses are validated as addresses,
|
|
27
|
+
including native Rust descriptors, not decoded as literal Base64URL data.
|
|
28
|
+
- Protected decoded multiline prose/trimtick gutters when the mutation
|
|
29
|
+
workbench writes AEON source. AEON target validation rejects payloads whose
|
|
30
|
+
trailing newlines or whitespace-only content lines cannot survive trimtick
|
|
31
|
+
normalization; ordinary string and Telex payloads are not narrowed.
|
|
32
|
+
|
|
33
|
+
### Tests
|
|
34
|
+
|
|
35
|
+
- Added one shared JavaScript/Rust value fixture and a 1,109-case valid
|
|
36
|
+
calendar/clock matrix, plus malformed boundaries, Base64URL and symbol probes.
|
|
37
|
+
Tests exercise Query, JavaScript Instruction, native Rust scalar descriptors,
|
|
38
|
+
target validation and round trips through an available AEON Core runtime.
|
|
39
|
+
|
|
40
|
+
## 0.14.0 - 2026-10-15
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
- Added a proposal-stage Rust SANSA.Mutate type shell and a side-effect-free
|
|
45
|
+
planner covering all 28 cases assigned to the pinned experimental plan
|
|
46
|
+
surface. The planner retains opaque exact bindings, evaluates Query
|
|
47
|
+
preconditions, enforces conservative container/conflict/budget rules, and
|
|
48
|
+
preserves provenance and portability warnings.
|
|
49
|
+
- Added post-plan Rust SANSA.Mutate target-surface validation covering all 36
|
|
50
|
+
pinned experimental AEON and JSON cases. Built-in validation remains
|
|
51
|
+
representability-only, and a host-neutral trait permits separate custom
|
|
52
|
+
validators without granting authority or exposing mutation hooks. Apply and
|
|
53
|
+
policy remain independent unimplemented surfaces.
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
|
|
57
|
+
- JSON mutation target validation in Rust and JavaScript now distinguishes
|
|
58
|
+
actual attribute-space selectors from quoted property names containing
|
|
59
|
+
`.@`, including contextual aliases and attribute descendants.
|
|
60
|
+
- Corrected Rust target-validator dispatch so JSON's container and attribute
|
|
61
|
+
restrictions run in the JSON validator, while AEON accepts those targets.
|
|
62
|
+
Public API regression coverage now exercises every mutation operation across
|
|
63
|
+
AEON, JSON, and their default/alias spellings.
|
|
64
|
+
- Hardened the Rust mutation planner so every resolved alias of the namespace
|
|
65
|
+
root is protected from removal, pre-parsed targets are revalidated under the
|
|
66
|
+
planner's Address ceiling, and non-portable Address warnings inside Query
|
|
67
|
+
preconditions are retained on the plan. Precondition resolution now has a
|
|
68
|
+
finite default binding ceiling and reports exhaustion through the normalized
|
|
69
|
+
mutation budget diagnostic.
|
|
70
|
+
|
|
10
71
|
## 0.13.0 - 2026-10-06
|
|
11
72
|
|
|
12
73
|
### Added
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"claim_format": "aeonite.cts-claims.v1",
|
|
3
3
|
"repository": "AltoPelago/sansa",
|
|
4
4
|
"implementation": "@altopelago/sansa",
|
|
5
|
-
"implementation_version": "0.
|
|
5
|
+
"implementation_version": "0.14.1",
|
|
6
6
|
"cts_repository": "aeonite-org/aeonite-cts",
|
|
7
7
|
"cts_protocol": "cts.protocol.v1",
|
|
8
8
|
"claims": [
|
package/docs/api-contract.md
CHANGED
|
@@ -453,7 +453,7 @@ planMutation({
|
|
|
453
453
|
}, namespace)
|
|
454
454
|
```
|
|
455
455
|
|
|
456
|
-
If mutation targets parse successfully but produce SANSA portability warnings, successful planning preserves those diagnostics on `plan.portabilityWarnings`. For example, a caller may raise the local position-index limit above the SANSA portable ceiling; if the
|
|
456
|
+
If mutation targets or addresses embedded in precondition expressions parse successfully but produce SANSA portability warnings, successful planning preserves those diagnostics on `plan.portabilityWarnings`. For example, a caller may raise the local position-index limit above the SANSA portable ceiling; if the address resolves successfully, the plan remains inspectable but carries the non-portability warning. Pre-parsed target addresses are rendered and revalidated under the planner's configured Address ceiling, so they cannot bypass its limit or warning behavior.
|
|
457
457
|
|
|
458
458
|
Mutation plans are current-process execution artifacts, not portable serialized plan documents. A plan retains live binding objects supplied by the resolver, along with local adapter artifacts such as `bindingHandle` and `observedState`. These fields are for same-process continuity checks and diagnostics. Do not `JSON.stringify` a plan and replay it later or in another implementation; cloned or serialized plans cannot prove live binding continuity and should fail apply-time stale-target checks. A portable mutation-plan serialization format may be defined by a later profile.
|
|
459
459
|
|
|
@@ -490,10 +490,24 @@ applyMutationPlan(plan, namespace, {
|
|
|
490
490
|
|
|
491
491
|
Budget exhaustion returns `SANSA_MUTATE_BUDGET_EXCEEDED` with `phase`, `budget`, `limit`, and `observed`. It does not produce a partial plan and does not apply partial mutations.
|
|
492
492
|
|
|
493
|
+
Query preconditions also inherit the planner's Resolve `maxBindings` ceiling.
|
|
494
|
+
The Rust planner applies a fail-closed default of `100000` bindings when the
|
|
495
|
+
caller does not provide a stricter ceiling. Exhausting this resolution budget
|
|
496
|
+
is normalized as `SANSA_MUTATE_BUDGET_EXCEEDED` with `budget: "maxBindings"`
|
|
497
|
+
and the failing precondition index.
|
|
498
|
+
|
|
493
499
|
`maxValueNodes`, `maxValueDepth`, and `maxStringLength` are budgets over supplied values for `create`, `replace`, and `insert`. They are honored during planning and again during apply when callers provide a prebuilt plan. `maxValueNodes` counts all supplied value nodes across the request or plan; arrays and objects count as one node plus their entries. `maxValueDepth` is the deepest supplied value tree, with scalar values at depth `1`. `maxStringLength` is the longest supplied string payload observed by this implementation.
|
|
494
500
|
|
|
495
501
|
Planning is side-effect free. Every executable target is resolved exactly at planning time. Expanded selectors such as `$.items.*`, ranges such as `$.items[0..2]`, filters, name patterns, and parent traversal are not accepted as mutation targets in this initial slice. `create` targets an existing exact parent and carries the new child name separately.
|
|
496
502
|
|
|
503
|
+
The Rust runtime exposes post-plan target validation separately through
|
|
504
|
+
`mutate_target::validate_mutation_plan_target`. Its built-in proposal-stage
|
|
505
|
+
surfaces cover AEON and JSON representability and are exercised directly by all
|
|
506
|
+
36 target-validation cases in the pinned experimental CTS snapshot.
|
|
507
|
+
`MutationTargetValidator` permits a host-defined immutable plan validator, but
|
|
508
|
+
successful representability does not imply schema validity, authorization, or
|
|
509
|
+
permission to apply the plan.
|
|
510
|
+
|
|
497
511
|
`applyMutationPlan` applies an already planned mutation only when the namespace exposes matching mutation hooks:
|
|
498
512
|
|
|
499
513
|
```js
|
|
@@ -1085,6 +1099,34 @@ literals compare through the active temporal profile; the default profile uses
|
|
|
1085
1099
|
canonical payload order.
|
|
1086
1100
|
Explicit null literals are tested through null predicates rather than equality.
|
|
1087
1101
|
|
|
1102
|
+
The temporal literal boundary follows Core rather than the general-purpose
|
|
1103
|
+
schema: year/month date ticks can compose with clocks (`2024-T10:Z`,
|
|
1104
|
+
`2024-02T10:&Europe`), second `60` remains structurally valid, and arbitrary
|
|
1105
|
+
authored fractional digits are preserved. WTC `local` is case-sensitive; named
|
|
1106
|
+
contexts remain opaque ASCII payloads. Invalid fields and comment-looking
|
|
1107
|
+
punctuation inside a contiguous WTC token are not reinterpreted as trivia.
|
|
1108
|
+
|
|
1109
|
+
The built-in temporal relation helper handles contiguous date extents and
|
|
1110
|
+
complete-date clock extents. Clock-bearing year/month ticks can denote disjoint
|
|
1111
|
+
daily sets; those comparisons currently return `incomparable` rather than
|
|
1112
|
+
inventing a month/day or flattening the sets into a single interval. This
|
|
1113
|
+
conservative comparison limitation does not reject the literal or its AEON
|
|
1114
|
+
target representation. Default representation equality/order is unchanged.
|
|
1115
|
+
|
|
1116
|
+
AEON target validation also distinguishes reserved `base64` (decodable
|
|
1117
|
+
Base64URL, including valid padding and zero unused tail bits) from opaque
|
|
1118
|
+
`encoding`, `inline` and `embed` payloads. For `prose`/`trimtick`, exact multiline
|
|
1119
|
+
values must survive Core gutter normalization: trailing newlines and nonempty
|
|
1120
|
+
whitespace-only content lines cannot be preserved and produce a target-phase
|
|
1121
|
+
diagnostic before apply. The workbench protects representable leading empty
|
|
1122
|
+
lines and mixed payload indentation when re-emitting trimticks. Ordinary
|
|
1123
|
+
quoted-string values and direct Telex string payloads retain their full domain.
|
|
1124
|
+
|
|
1125
|
+
These datatype-specific literal checks do not decode reference addresses as
|
|
1126
|
+
payload data. Clone/pointer references (including native Rust reference-form
|
|
1127
|
+
descriptors) retain address validation; `base64` describes the referred value,
|
|
1128
|
+
not the bytes or Base64URL tail bits of its address.
|
|
1129
|
+
|
|
1088
1130
|
Current comparison policy:
|
|
1089
1131
|
|
|
1090
1132
|
| Operands | Equality | Ordering | Result |
|
package/docs/capabilities.json
CHANGED
package/docs/releasing.md
CHANGED
|
@@ -77,7 +77,10 @@ are published by the workflow using short-lived OIDC credentials.
|
|
|
77
77
|
3. Add the dated `X.Y.Z` release section and human-authored notes to
|
|
78
78
|
`CHANGELOG.md`.
|
|
79
79
|
4. Run `npm run version:check`, the test suite, CTS, stress tests, and package
|
|
80
|
-
dry-run.
|
|
80
|
+
dry-run. Keep the CTS checkout pinned to the same reviewed commit in CI and
|
|
81
|
+
both publish workflows. CI and npm publication also run the Query and Mutate
|
|
82
|
+
`next` manifests as supplemental AEON value-alignment checks; these do not
|
|
83
|
+
promote development snapshots into stable conformance claims.
|
|
81
84
|
5. Merge the release-prep PR into `main`.
|
|
82
85
|
6. Confirm CI passes on `main`.
|
|
83
86
|
7. Create tag `vX.Y.Z` from the checked `main` commit.
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2049,6 +2049,16 @@ function validateAeonTargetValue(value, hints, path, operationIndex) {
|
|
|
2049
2049
|
if (representation === 'node') return validateAeonTargetNodeValue(value, path, operationIndex);
|
|
2050
2050
|
const scalarValidation = validateAeonTargetScalarValue(value, representation, path, operationIndex);
|
|
2051
2051
|
if (!scalarValidation.ok) return scalarValidation;
|
|
2052
|
+
// A reference payload is an address, not the referred value's literal data.
|
|
2053
|
+
if (['cloneReference', 'pointerReference', 'referenceForm'].includes(representation)) return { ok: true };
|
|
2054
|
+
if (typeof hints.datatype === 'string' && ['prose', 'trimtick'].includes(datatypeBaseName(hints.datatype))
|
|
2055
|
+
&& typeof value === 'string' && !isRepresentableTrimtickPayload(value)) {
|
|
2056
|
+
return invalidAeonTargetValue('Trimtick normalization cannot preserve trailing newlines or whitespace-only content lines', path, operationIndex);
|
|
2057
|
+
}
|
|
2058
|
+
if (typeof hints.datatype === 'string' && datatypeBaseName(hints.datatype) === 'base64'
|
|
2059
|
+
&& (typeof value !== 'string' || !isDecodableBase64UrlPayload(value))) {
|
|
2060
|
+
return invalidAeonTargetValue('base64 requires decodable Base64URL with zero unused tail bits', path, operationIndex);
|
|
2061
|
+
}
|
|
2052
2062
|
if (Array.isArray(value)) {
|
|
2053
2063
|
for (let index = 0; index < value.length; index += 1) {
|
|
2054
2064
|
const result = validateAeonTargetValue(value[index], {}, `${path}[${index}]`, operationIndex);
|
|
@@ -2121,7 +2131,7 @@ function validateAeonTargetScalarValue(value, representation, path, operationInd
|
|
|
2121
2131
|
? { ok: true }
|
|
2122
2132
|
: invalidAeonTargetValue('Boolean literals must use boolean payloads', path, operationIndex);
|
|
2123
2133
|
case 'hex':
|
|
2124
|
-
return typeof value === 'string' && /^[0-9A-Fa-f]+$/.test(value)
|
|
2134
|
+
return typeof value === 'string' && value.trim() === value && /^[0-9A-Fa-f]+$/.test(value)
|
|
2125
2135
|
? { ok: true }
|
|
2126
2136
|
: invalidAeonTargetValue('Hex literals must be non-empty hexadecimal text without the # prefix', path, operationIndex);
|
|
2127
2137
|
case 'radix':
|
|
@@ -2420,7 +2430,13 @@ function validateJsonTargetAddresses(operation, operationIndex) {
|
|
|
2420
2430
|
for (const role of ['target', 'parent', 'source', 'container']) {
|
|
2421
2431
|
const target = operation[role];
|
|
2422
2432
|
if (!target) continue;
|
|
2423
|
-
|
|
2433
|
+
// A quoted member can contain literal .@ text. Classify selectors in both
|
|
2434
|
+
// paths so contextual aliases still reveal canonical attribute ancestors.
|
|
2435
|
+
// Do not reimpose the portable index ceiling on an already planned path.
|
|
2436
|
+
const canonical = parseAddress(String(target.canonicalAddress ?? ''), { maxPositionIndex: Number.MAX_SAFE_INTEGER });
|
|
2437
|
+
const hasAttributeSelector = target.address?.selectors?.some((selector) => selector.type === 'attributeSpace')
|
|
2438
|
+
|| (canonical.ok && canonical.address.selectors.some((selector) => selector.type === 'attributeSpace'));
|
|
2439
|
+
if (target.binding?.representationKind === 'attributeSpace' || hasAttributeSelector) {
|
|
2424
2440
|
return {
|
|
2425
2441
|
ok: false,
|
|
2426
2442
|
error: mutationTargetSurfaceError(
|
|
@@ -5382,6 +5398,7 @@ export function compareTemporalClaims(left, right) {
|
|
|
5382
5398
|
function parseTemporalCompletionSet(input) {
|
|
5383
5399
|
const semanticType = String(input?.semanticType ?? 'temporal');
|
|
5384
5400
|
const payload = String(input?.payload ?? input?.value ?? '');
|
|
5401
|
+
if (!isQueryTemporalLiteral(payload, semanticType)) return null;
|
|
5385
5402
|
if (semanticType === 'date') {
|
|
5386
5403
|
const date = parseTemporalDate(payload);
|
|
5387
5404
|
if (date === null) return null;
|
|
@@ -5419,7 +5436,10 @@ function parseTemporalCompletionSet(input) {
|
|
|
5419
5436
|
const marker = base.indexOf('T');
|
|
5420
5437
|
if (marker === -1) return null;
|
|
5421
5438
|
date = parseTemporalDate(base.slice(0, marker));
|
|
5422
|
-
|
|
5439
|
+
// Clock-bearing year/month ticks have disjoint daily completion sets. This
|
|
5440
|
+
// conservative interval comparator must not invent a month/day or flatten
|
|
5441
|
+
// those sets into one interval. Rust returns incomparable for these too.
|
|
5442
|
+
if (date === null || date.month === null || date.day === null) return null;
|
|
5423
5443
|
clockText = base.slice(marker + 1);
|
|
5424
5444
|
}
|
|
5425
5445
|
const clock = parseTemporalClock(clockText, semanticType === 'time');
|
|
@@ -5465,6 +5485,7 @@ function temporalCompletionDomain(semanticType, anchor, context) {
|
|
|
5465
5485
|
}
|
|
5466
5486
|
|
|
5467
5487
|
function parseTemporalDate(value) {
|
|
5488
|
+
if (value.trim() !== value) return null;
|
|
5468
5489
|
const yearOnly = /^(\d{4})-$/.exec(value);
|
|
5469
5490
|
if (yearOnly !== null) {
|
|
5470
5491
|
const year = Number(yearOnly[1]);
|
|
@@ -5484,9 +5505,10 @@ function parseTemporalDate(value) {
|
|
|
5484
5505
|
}
|
|
5485
5506
|
|
|
5486
5507
|
function parseTemporalClock(value, requireColon) {
|
|
5508
|
+
if (value.trim() !== value) return null;
|
|
5487
5509
|
const pattern = requireColon
|
|
5488
|
-
? /^(\d{2}):(?:(\d{2})
|
|
5489
|
-
: /^(\d{2})(?::(\d{2})
|
|
5510
|
+
? /^(\d{2}):(?:(\d{2})(?::(\d{2})(?:\.(\d+))?)?)?(Z|[+-]\d{2}:\d{2})?$/
|
|
5511
|
+
: /^(\d{2})(?::(?:(\d{2})(?::(\d{2})(?:\.(\d+))?)?)?)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
5490
5512
|
const match = pattern.exec(value);
|
|
5491
5513
|
if (match === null) return null;
|
|
5492
5514
|
const hour = Number(match[1]);
|
|
@@ -8266,7 +8288,7 @@ class QueryExpressionParser {
|
|
|
8266
8288
|
|
|
8267
8289
|
startsTemporalLiteral() {
|
|
8268
8290
|
const rest = this.input.slice(this.index);
|
|
8269
|
-
return /^\d{4}
|
|
8291
|
+
return /^\d{4}-/.test(rest)
|
|
8270
8292
|
|| /^\d{2}:/.test(rest);
|
|
8271
8293
|
}
|
|
8272
8294
|
|
|
@@ -8489,7 +8511,17 @@ function stripQueryComments(input) {
|
|
|
8489
8511
|
output += char;
|
|
8490
8512
|
continue;
|
|
8491
8513
|
}
|
|
8492
|
-
if (char === '/' && next === '/' &&
|
|
8514
|
+
if (char === '/' && (next === '/' || next === '*') && isTemporalZoneCommentContext(input, index)) {
|
|
8515
|
+
// Preserve the rest of this invalid zone token once, avoiding repeated
|
|
8516
|
+
// backwards scans for a long run of comment-looking slashes.
|
|
8517
|
+
while (index < input.length && !isLayout(input[index]) && ![',', ')', '}', ']'].includes(input[index])) {
|
|
8518
|
+
output += input[index];
|
|
8519
|
+
index += 1;
|
|
8520
|
+
}
|
|
8521
|
+
index -= 1;
|
|
8522
|
+
continue;
|
|
8523
|
+
}
|
|
8524
|
+
if (char === '/' && next === '/') {
|
|
8493
8525
|
output += ' ';
|
|
8494
8526
|
index += 1;
|
|
8495
8527
|
while (index + 1 < input.length && input[index + 1] !== '\n' && input[index + 1] !== '\r') {
|
|
@@ -8498,7 +8530,7 @@ function stripQueryComments(input) {
|
|
|
8498
8530
|
}
|
|
8499
8531
|
continue;
|
|
8500
8532
|
}
|
|
8501
|
-
if (char === '/' && next === '*'
|
|
8533
|
+
if (char === '/' && next === '*') {
|
|
8502
8534
|
const start = index;
|
|
8503
8535
|
output += ' ';
|
|
8504
8536
|
index += 1;
|
|
@@ -8527,13 +8559,11 @@ function stripQueryComments(input) {
|
|
|
8527
8559
|
|
|
8528
8560
|
function isTemporalZoneCommentContext(input, index) {
|
|
8529
8561
|
let cursor = index - 1;
|
|
8530
|
-
while (cursor >= 0 && !isLayout(input[cursor]) && ![',', ')', '}', ']'].includes(input[cursor])) {
|
|
8562
|
+
while (cursor >= 0 && !isLayout(input[cursor]) && ![',', '(', ')', '{', '}', '[', ']', '=', '<', '>', '!'].includes(input[cursor])) {
|
|
8531
8563
|
cursor -= 1;
|
|
8532
8564
|
}
|
|
8533
8565
|
const tokenPrefix = input.slice(cursor + 1, index);
|
|
8534
|
-
|
|
8535
|
-
const datetimeTime = String.raw`\d{2}(?::(?:\d{2})?)?(?::\d{2})?(?:Z|[+-]\d{2}:\d{2})?`;
|
|
8536
|
-
return new RegExp(`^${date}T${datetimeTime}&[A-Za-z0-9_+\\-/]*$`).test(tokenPrefix);
|
|
8566
|
+
return /^\d{4}-/.test(tokenPrefix) && tokenPrefix.includes('T') && tokenPrefix.includes('&');
|
|
8537
8567
|
}
|
|
8538
8568
|
|
|
8539
8569
|
function renderInstruction(instruction) {
|
|
@@ -9045,30 +9075,24 @@ function isQueryCurrentPositionalShorthand(source) {
|
|
|
9045
9075
|
}
|
|
9046
9076
|
|
|
9047
9077
|
function isQueryTemporalLiteral(source, kind) {
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
const zone = String.raw`[A-Za-z0-9_+.\-]+(?:/[A-Za-z0-9_+.\-]+)*`;
|
|
9052
|
-
if (kind === 'date') {
|
|
9053
|
-
return parseTemporalDate(source) !== null;
|
|
9054
|
-
}
|
|
9055
|
-
if (kind === 'time') {
|
|
9056
|
-
const match = new RegExp(`^${time}$`).exec(source);
|
|
9057
|
-
return Boolean(match) && isValidTimeMatch(match);
|
|
9058
|
-
}
|
|
9059
|
-
if (kind === 'datetime') {
|
|
9060
|
-
const match = new RegExp(`^${date}T${datetimeTime}$`).exec(source);
|
|
9061
|
-
return Boolean(match)
|
|
9062
|
-
&& isValidDateParts(match[1], match[2], match[3])
|
|
9063
|
-
&& isValidTimeMatch(match, 4);
|
|
9064
|
-
}
|
|
9078
|
+
if (kind === 'date') return parseTemporalDate(source) !== null;
|
|
9079
|
+
if (kind === 'time') return parseTemporalClock(source, true) !== null;
|
|
9080
|
+
let datetime = source;
|
|
9065
9081
|
if (kind === 'wtc') {
|
|
9066
|
-
const
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9082
|
+
const marker = source.indexOf('&');
|
|
9083
|
+
if (marker === -1) return false;
|
|
9084
|
+
datetime = source.slice(0, marker);
|
|
9085
|
+
const zone = source.slice(marker + 1);
|
|
9086
|
+
if (!zone || zone.trim() !== zone
|
|
9087
|
+
|| (zone.toLowerCase() === 'local' && zone !== 'local')
|
|
9088
|
+
|| !/^[A-Za-z0-9_+.\-]+(?:\/[A-Za-z0-9_+.\-]+)*$/.test(zone)) return false;
|
|
9089
|
+
} else if (kind !== 'datetime') {
|
|
9090
|
+
return false;
|
|
9070
9091
|
}
|
|
9071
|
-
|
|
9092
|
+
const marker = datetime.indexOf('T');
|
|
9093
|
+
return marker !== -1
|
|
9094
|
+
&& parseTemporalDate(datetime.slice(0, marker)) !== null
|
|
9095
|
+
&& parseTemporalClock(datetime.slice(marker + 1), false) !== null;
|
|
9072
9096
|
}
|
|
9073
9097
|
|
|
9074
9098
|
function isValidDateParts(yearText, monthText, dayText) {
|
|
@@ -9084,26 +9108,29 @@ function isLeapYear(year) {
|
|
|
9084
9108
|
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
9085
9109
|
}
|
|
9086
9110
|
|
|
9087
|
-
function isValidTimeMatch(match, offset = 1) {
|
|
9088
|
-
const hour = Number(match[offset]);
|
|
9089
|
-
const minute = match[offset + 1] === undefined ? null : Number(match[offset + 1]);
|
|
9090
|
-
const second = match[offset + 2] === undefined ? null : Number(match[offset + 2]);
|
|
9091
|
-
const zoneHour = match[offset + 5] === undefined ? null : Number(match[offset + 5]);
|
|
9092
|
-
const zoneMinute = match[offset + 6] === undefined ? null : Number(match[offset + 6]);
|
|
9093
|
-
if (hour < 0 || hour > 23) return false;
|
|
9094
|
-
if (minute !== null && (minute < 0 || minute > 59)) return false;
|
|
9095
|
-
if (second !== null && (second < 0 || second > 60)) return false;
|
|
9096
|
-
if (zoneHour !== null && (zoneHour < 0 || zoneHour > 23)) return false;
|
|
9097
|
-
if (zoneMinute !== null && (zoneMinute < 0 || zoneMinute > 59)) return false;
|
|
9098
|
-
return true;
|
|
9099
|
-
}
|
|
9100
|
-
|
|
9101
9111
|
function isAeonRadixPayload(payload) {
|
|
9102
|
-
return
|
|
9112
|
+
return payload.trim() === payload
|
|
9113
|
+
&& /^[+-]?(?:[0-9A-Za-z&!](?:_?[0-9A-Za-z&!])*)(?:\.(?:[0-9A-Za-z&!](?:_?[0-9A-Za-z&!])*))?$|^[+-]?\.(?:[0-9A-Za-z&!](?:_?[0-9A-Za-z&!])*)$/.test(payload);
|
|
9103
9114
|
}
|
|
9104
9115
|
|
|
9105
9116
|
function isAeonEncodingPayload(payload) {
|
|
9106
|
-
return /^[A-Za-z0-9_-]+={0,2}$/.test(payload);
|
|
9117
|
+
return payload.trim() === payload && /^[A-Za-z0-9_-]+={0,2}$/.test(payload);
|
|
9118
|
+
}
|
|
9119
|
+
|
|
9120
|
+
function isRepresentableTrimtickPayload(payload) {
|
|
9121
|
+
return !payload.includes('\n') || (!payload.endsWith('\n')
|
|
9122
|
+
&& payload.split('\n').every((line) => line.length === 0 || !/^[ \t]+$/.test(line)));
|
|
9123
|
+
}
|
|
9124
|
+
|
|
9125
|
+
function isDecodableBase64UrlPayload(payload) {
|
|
9126
|
+
if (!isAeonEncodingPayload(payload)) return false;
|
|
9127
|
+
const body = payload.replace(/=+$/, '');
|
|
9128
|
+
const padding = payload.length - body.length;
|
|
9129
|
+
const remainder = body.length % 4;
|
|
9130
|
+
if (remainder === 1 || (padding !== 0 && payload.length % 4 !== 0)
|
|
9131
|
+
|| (padding === 1 && remainder !== 3) || (padding === 2 && remainder !== 2)) return false;
|
|
9132
|
+
const last = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'.indexOf(body.at(-1));
|
|
9133
|
+
return remainder === 2 ? (last & 15) === 0 : remainder === 3 ? (last & 3) === 0 : true;
|
|
9107
9134
|
}
|
|
9108
9135
|
|
|
9109
9136
|
function isAeonSeparatorPayload(payload) {
|
|
@@ -1435,7 +1435,19 @@ function renderScalarValue(binding) {
|
|
|
1435
1435
|
}
|
|
1436
1436
|
|
|
1437
1437
|
function renderBlockString(value) {
|
|
1438
|
-
|
|
1438
|
+
let text = String(value ?? '');
|
|
1439
|
+
if (text.includes('\n')) {
|
|
1440
|
+
// Core trims after escape decoding. Protect nonblank lines with an opposite
|
|
1441
|
+
// gutter so one common character is removed without touching payload indent.
|
|
1442
|
+
const first = text.split('\n').find((line) => line.length > 0) ?? '';
|
|
1443
|
+
const gutter = first.startsWith(' ') ? '\t' : ' ';
|
|
1444
|
+
const leadingNewline = text.startsWith('\n');
|
|
1445
|
+
text = text.split('\n').map((line) => line.length === 0 ? '' : gutter + line).join('\n');
|
|
1446
|
+
if (leadingNewline) text = '\n' + text;
|
|
1447
|
+
}
|
|
1448
|
+
text = text
|
|
1449
|
+
.replace(/\\/g, '\\\\').replace(/`/g, '\\`')
|
|
1450
|
+
.replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t');
|
|
1439
1451
|
return `>\`${text}\``;
|
|
1440
1452
|
}
|
|
1441
1453
|
|