@altopelago/aeon-aes 0.11.0 → 0.12.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/README.md +26 -2
- package/dist/candidate.d.ts +26 -0
- package/dist/candidate.d.ts.map +1 -0
- package/dist/candidate.js +2 -0
- package/dist/candidate.js.map +1 -0
- package/dist/datatype.d.ts.map +1 -1
- package/dist/datatype.js +6 -6
- package/dist/datatype.js.map +1 -1
- package/dist/events.d.ts +7 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +4 -0
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/modes.d.ts +0 -6
- package/dist/modes.d.ts.map +1 -1
- package/dist/modes.js +35 -138
- package/dist/modes.js.map +1 -1
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +34 -29
- package/dist/paths.js.map +1 -1
- package/dist/portable.d.ts +98 -0
- package/dist/portable.d.ts.map +1 -0
- package/dist/portable.js +524 -0
- package/dist/portable.js.map +1 -0
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +9 -4
- package/dist/references.js.map +1 -1
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +52 -2
- package/dist/resolve.js.map +1 -1
- package/dist/sha256.d.ts +3 -0
- package/dist/sha256.d.ts.map +1 -0
- package/dist/sha256.js +82 -0
- package/dist/sha256.js.map +1 -0
- package/dist/telex-datatype-internal.d.ts +12 -0
- package/dist/telex-datatype-internal.d.ts.map +1 -0
- package/dist/telex-datatype-internal.js +323 -0
- package/dist/telex-datatype-internal.js.map +1 -0
- package/dist/telex-internal.d.ts +60 -0
- package/dist/telex-internal.d.ts.map +1 -0
- package/dist/telex-internal.js +1101 -0
- package/dist/telex-internal.js.map +1 -0
- package/dist/telex-limits-internal.d.ts +35 -0
- package/dist/telex-limits-internal.d.ts.map +1 -0
- package/dist/telex-limits-internal.js +70 -0
- package/dist/telex-limits-internal.js.map +1 -0
- package/dist/telex.d.ts +128 -0
- package/dist/telex.d.ts.map +1 -0
- package/dist/telex.js +46 -0
- package/dist/telex.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @altopelago/aeon-aes
|
|
2
2
|
|
|
3
|
-
Assignment Event Stream emission and
|
|
3
|
+
Assignment Event Stream emission, portable projection, and Telex v1 codec.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -25,21 +25,45 @@ if (result.errors.length === 0) {
|
|
|
25
25
|
- emits Assignment Events from AEON source or parsed syntax
|
|
26
26
|
- formats and works with canonical AEON paths
|
|
27
27
|
- exposes event-level data used by AEOS validation, finalization, and tooling
|
|
28
|
+
- parses, validates, encodes, and canonicalizes `telex.aes` v1 streams
|
|
29
|
+
- splits compact Telex datatypes into `datatype`, `generics`, and `clarifiers`
|
|
28
30
|
|
|
29
31
|
## API
|
|
30
32
|
|
|
31
33
|
- `emitAssignmentEvents(input, options?)`
|
|
34
|
+
- `projectPortableEvents(events)` emits the default body-only portable
|
|
35
|
+
projection
|
|
36
|
+
- `adaptTypeScriptAssignmentEventsToPortableAes(events, options?)` returns the
|
|
37
|
+
named `aeon.typescript.assignment-events.v0-to-aes.events.v1` compatibility
|
|
38
|
+
result and its conversion report; optional exact `sourceBytes` derive a
|
|
39
|
+
SHA-256 origin and convert native UTF-16 ranges to UTF-8 byte spans;
|
|
40
|
+
`includeHeaders: true` selects `aeon.document.v1`
|
|
41
|
+
- `parseTelex(input, options?)`
|
|
42
|
+
- `encodeTelex(records, options?)`
|
|
43
|
+
- `canonicalizeTelex(input, options?)`
|
|
44
|
+
- `validateTelex(input, options?)`
|
|
45
|
+
- `validateTelexRecords(records, options?)`
|
|
32
46
|
- canonical path helpers
|
|
33
47
|
- Assignment Event Stream types
|
|
48
|
+
- emitted native events carry `sourcePlane: 'header' | 'body'`; consumers
|
|
49
|
+
must not infer control-plane identity from an `aeon:` key prefix
|
|
50
|
+
- reconstructed candidate AES types:
|
|
51
|
+
- `CandidateAES`
|
|
52
|
+
- `CandidateAssignmentEvent`
|
|
53
|
+
- `CandidateAttributeEntry`
|
|
54
|
+
- `CandidateValue`
|
|
34
55
|
|
|
35
56
|
## When To Use It
|
|
36
57
|
|
|
37
|
-
Use this package when you need direct access to
|
|
58
|
+
Use this package when you need direct access to assignment events or the
|
|
59
|
+
encoding-neutral portable AES/Telex boundary.
|
|
38
60
|
If you want the stable application-facing entry point, prefer `@altopelago/aeon-core`.
|
|
39
61
|
|
|
40
62
|
## Notes
|
|
41
63
|
|
|
42
64
|
- AES is the structural event layer between parsing and downstream validation.
|
|
65
|
+
- Candidate AES types describe reconstructed validation input for speculative
|
|
66
|
+
post-commit state. They do not define substrate materialization policy.
|
|
43
67
|
- This package does not materialize application objects.
|
|
44
68
|
- Schema validation belongs in `@altopelago/aeos-core`.
|
|
45
69
|
- JSON or map materialization belongs in `@altopelago/aeon-finalize`.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Span } from '@altopelago/aeon-lexer';
|
|
2
|
+
import type { AssignmentEvent, AttributeEntry } from './events.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reconstructed AES candidate input.
|
|
5
|
+
*
|
|
6
|
+
* Candidate events are used by storage engines and orchestrators that need to
|
|
7
|
+
* validate a speculative post-commit state but do not have source-document
|
|
8
|
+
* lexer spans for every reconstructed binding. The shape intentionally mirrors
|
|
9
|
+
* AssignmentEvent while allowing tuple spans and candidate-local value nodes.
|
|
10
|
+
*/
|
|
11
|
+
export type CandidateSpan = Span | readonly [number, number];
|
|
12
|
+
export type CandidateValue = AssignmentEvent['value'] | (Readonly<Record<string, unknown>> & {
|
|
13
|
+
readonly type: string;
|
|
14
|
+
readonly span?: CandidateSpan;
|
|
15
|
+
});
|
|
16
|
+
export interface CandidateAttributeEntry extends Omit<AttributeEntry, 'value' | 'annotations'> {
|
|
17
|
+
readonly value: CandidateValue;
|
|
18
|
+
readonly annotations?: ReadonlyMap<string, CandidateAttributeEntry>;
|
|
19
|
+
}
|
|
20
|
+
export interface CandidateAssignmentEvent extends Omit<AssignmentEvent, 'value' | 'span' | 'annotations'> {
|
|
21
|
+
readonly value: CandidateValue;
|
|
22
|
+
readonly span: CandidateSpan;
|
|
23
|
+
readonly annotations?: ReadonlyMap<string, CandidateAttributeEntry>;
|
|
24
|
+
}
|
|
25
|
+
export type CandidateAES = readonly CandidateAssignmentEvent[];
|
|
26
|
+
//# sourceMappingURL=candidate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate.d.ts","sourceRoot":"","sources":["../src/candidate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE7D,MAAM,MAAM,cAAc,GACpB,eAAe,CAAC,OAAO,CAAC,GACxB,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;CACjC,CAAC,CAAC;AAEP,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,aAAa,CAAC;IAC1F,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CACvE;AAED,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,MAAM,GAAG,aAAa,CAAC;IACrG,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CACvE;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidate.js","sourceRoot":"","sources":["../src/candidate.ts"],"names":[],"mappings":""}
|
package/dist/datatype.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datatype.d.ts","sourceRoot":"","sources":["../src/datatype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"datatype.d.ts","sourceRoot":"","sources":["../src/datatype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CASzE"}
|
package/dist/datatype.js
CHANGED
|
@@ -3,12 +3,12 @@ export function formatDatatypeAnnotation(datatype) {
|
|
|
3
3
|
const generics = datatype.genericArgs.length > 0
|
|
4
4
|
? `<${datatype.genericArgs.join(', ')}>`
|
|
5
5
|
: '';
|
|
6
|
-
const
|
|
7
|
-
? `[${datatype.
|
|
6
|
+
const clarifiers = datatype.clarifiers.length > 0
|
|
7
|
+
? `[${datatype.clarifiers.map(formatClarifierValue).join(', ')}]`
|
|
8
8
|
: '';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
9
|
+
return `${name}${generics}${clarifiers}`;
|
|
10
|
+
}
|
|
11
|
+
function formatClarifierValue(value) {
|
|
12
|
+
return typeof value === 'string' ? JSON.stringify(value) : String(value);
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=datatype.js.map
|
package/dist/datatype.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datatype.js","sourceRoot":"","sources":["../src/datatype.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,wBAAwB,CAAC,QAAwB;IAC7D,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC3B,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;QAC5C,CAAC,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QACxC,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,
|
|
1
|
+
{"version":3,"file":"datatype.js","sourceRoot":"","sources":["../src/datatype.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,wBAAwB,CAAC,QAAwB;IAC7D,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC3B,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;QAC5C,CAAC,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QACxC,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;QAC7C,CAAC,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QACjE,CAAC,CAAC,EAAE,CAAC;IACT,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,EAAE,CAAC;AAC7C,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAsB;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/events.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export interface AssignmentEvent {
|
|
|
15
15
|
readonly normalizedPath?: string;
|
|
16
16
|
/** Local key name (e.g., "host") */
|
|
17
17
|
readonly key: string;
|
|
18
|
+
/** Source document plane; independent of the textual key prefix. */
|
|
19
|
+
readonly sourcePlane?: 'header' | 'body';
|
|
20
|
+
/** Optional structural occurrence identity from the source binding. */
|
|
21
|
+
readonly structuralId?: string | null;
|
|
18
22
|
/** Original AST value node - NOT evaluated or transformed */
|
|
19
23
|
readonly value: Value;
|
|
20
24
|
/** Source location of the binding */
|
|
@@ -28,9 +32,12 @@ export interface AssignmentEvent {
|
|
|
28
32
|
* Attribute entry
|
|
29
33
|
*/
|
|
30
34
|
export interface AttributeEntry {
|
|
35
|
+
readonly structuralId?: string | null;
|
|
31
36
|
readonly value: Value;
|
|
32
37
|
readonly datatype?: string;
|
|
33
38
|
readonly annotations?: ReadonlyMap<string, AttributeEntry>;
|
|
39
|
+
/** Native UTF-16 source range retained for explicit portable conversion. */
|
|
40
|
+
readonly span?: Span;
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
36
43
|
* Event emission result
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAa,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACH,KAAK,aAAa,EAElB,KAAK,oBAAoB,EACzB,mBAAmB,EAEtB,MAAM,YAAY,CAAC;AAGpB;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,I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ED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACtB,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,GAAE,oBAAyB,GACnC,mBAAmB,CAyBrB;AA6DD,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/events.js
CHANGED
|
@@ -58,6 +58,8 @@ function createEvent(cb) {
|
|
|
58
58
|
path: cb.path,
|
|
59
59
|
normalizedPath: formatNormalizedPath(cb.path),
|
|
60
60
|
key: binding.key,
|
|
61
|
+
sourcePlane: cb.sourcePlane,
|
|
62
|
+
...(binding.structuralId !== null ? { structuralId: binding.structuralId } : {}),
|
|
61
63
|
value: binding.value,
|
|
62
64
|
span: cb.span,
|
|
63
65
|
};
|
|
@@ -80,7 +82,9 @@ function buildAnnotations(attributes) {
|
|
|
80
82
|
for (const attr of attributes) {
|
|
81
83
|
for (const [key, entry] of attr.entries) {
|
|
82
84
|
const attrEntry = {
|
|
85
|
+
...(entry.structuralId !== null ? { structuralId: entry.structuralId } : {}),
|
|
83
86
|
value: entry.value,
|
|
87
|
+
...(entry.span !== undefined ? { span: entry.span } : {}),
|
|
84
88
|
};
|
|
85
89
|
if (entry.datatype) {
|
|
86
90
|
attrEntry.datatype = formatDatatypeAnnotation(entry.datatype);
|
package/dist/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAEA,OAAO,EAKH,oBAAoB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAEA,OAAO,EAKH,oBAAoB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAqDzD;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAChC,IAAI,CAAO;IAC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CAAC,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC5F,CAAC;YACD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YAC7D,IAAI,iBAAiB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBAC5B,SAAkE,CAAC,WAAW,GAAG,iBAAiB,CAAC;YACxG,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export * from './paths.js';
|
|
7
7
|
export * from './events.js';
|
|
8
|
+
export * from './candidate.js';
|
|
8
9
|
export * from './references.js';
|
|
9
10
|
export * from './modes.js';
|
|
10
11
|
export * from './resolve.js';
|
|
12
|
+
export * from './portable.js';
|
|
13
|
+
export * from './telex.js';
|
|
11
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export * from './paths.js';
|
|
7
7
|
export * from './events.js';
|
|
8
|
+
export * from './candidate.js';
|
|
8
9
|
export * from './references.js';
|
|
9
10
|
export * from './modes.js';
|
|
10
11
|
export * from './resolve.js';
|
|
12
|
+
export * from './portable.js';
|
|
13
|
+
export * from './telex.js';
|
|
11
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
package/dist/modes.d.ts
CHANGED
|
@@ -60,12 +60,6 @@ export declare class HeaderConflictError extends ModeEnforcementError {
|
|
|
60
60
|
export declare class DatatypeLiteralMismatchError extends ModeEnforcementError {
|
|
61
61
|
constructor(span: Span, path: string, datatype: string, actualKind: string, expectedKinds: readonly string[]);
|
|
62
62
|
}
|
|
63
|
-
export declare class InvalidCustomDatatypeBracketShapeError extends ModeEnforcementError {
|
|
64
|
-
constructor(span: Span, path: string, datatype: string, actualKind: string);
|
|
65
|
-
}
|
|
66
|
-
export declare class IncompatibleCustomDatatypeAdornmentsError extends ModeEnforcementError {
|
|
67
|
-
constructor(span: Span, path: string, datatype: string, actualKind: string);
|
|
68
|
-
}
|
|
69
63
|
/**
|
|
70
64
|
* Error: Custom datatype is not permitted by typed-mode datatype policy
|
|
71
65
|
*/
|
package/dist/modes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modes.d.ts","sourceRoot":"","sources":["../src/modes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAA0C,MAAM,yBAAyB,CAAC;AAC9F,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"modes.d.ts","sourceRoot":"","sources":["../src/modes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAA0C,MAAM,yBAAyB,CAAC;AAC9F,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;AAKnE;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,cAAc,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAC9B,8BAA8B,GAC9B,wBAAwB,GACxB,iCAAiC,GACjC,2BAA2B,GAC3B,6BAA6B,GAC7B,4BAA4B,GAC5B,iBAAiB,CAAC;AAExB;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YACI,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,IAAI,EACV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C;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAC5C,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACpD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAkBvD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CACvB,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,OAAO,GAAE,sBAA2B,GACrC,qBAAqB,CAqGvB;AAqBD,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,oBAAoB,EAAE,CAEzE;AAweD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA2BhE"}
|
package/dist/modes.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* - No reference resolution
|
|
13
13
|
* - Fail-closed by default
|
|
14
14
|
*/
|
|
15
|
+
import { formatDatatypeAnnotation } from './datatype.js';
|
|
15
16
|
import { formatPath } from './paths.js';
|
|
16
17
|
import { formatReferenceTargetPath } from './reference-target.js';
|
|
17
18
|
/**
|
|
@@ -71,18 +72,6 @@ export class DatatypeLiteralMismatchError extends ModeEnforcementError {
|
|
|
71
72
|
this.name = 'DatatypeLiteralMismatchError';
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
export class InvalidCustomDatatypeBracketShapeError extends ModeEnforcementError {
|
|
75
|
-
constructor(span, path, datatype, actualKind) {
|
|
76
|
-
super(`Datatype/literal mismatch at '${path}': datatype ':${datatype}' has bracket specs incompatible with both SeparatorLiteral and RadixLiteral, got ${actualKind}`, span, 'DATATYPE_LITERAL_MISMATCH', path);
|
|
77
|
-
this.name = 'InvalidCustomDatatypeBracketShapeError';
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
export class IncompatibleCustomDatatypeAdornmentsError extends ModeEnforcementError {
|
|
81
|
-
constructor(span, path, datatype, actualKind) {
|
|
82
|
-
super(`Datatype/literal mismatch at '${path}': datatype ':${datatype}' combines incompatible generic and bracket constraints, got ${actualKind}`, span, 'DATATYPE_LITERAL_MISMATCH', path);
|
|
83
|
-
this.name = 'IncompatibleCustomDatatypeAdornmentsError';
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
75
|
/**
|
|
87
76
|
* Error: Custom datatype is not permitted by typed-mode datatype policy
|
|
88
77
|
*/
|
|
@@ -187,18 +176,9 @@ export function enforceMode(events, header, options = {}) {
|
|
|
187
176
|
errors.push(new DatatypeLiteralMismatchError(event.span, formatPath(event.path), event.datatype, actualKind, expectedKinds));
|
|
188
177
|
}
|
|
189
178
|
if (!expectedKinds) {
|
|
190
|
-
const
|
|
191
|
-
if (
|
|
192
|
-
errors.push(new
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
const customExpectedKinds = expectedKindsForCustomDatatype(event.datatype, customShape);
|
|
196
|
-
if (customExpectedKinds && customExpectedKinds.length === 0) {
|
|
197
|
-
errors.push(new IncompatibleCustomDatatypeAdornmentsError(event.span, formatPath(event.path), event.datatype, actualKind));
|
|
198
|
-
}
|
|
199
|
-
else if (customExpectedKinds && !customExpectedKinds.includes(actualKind)) {
|
|
200
|
-
errors.push(new DatatypeLiteralMismatchError(event.span, formatPath(event.path), event.datatype, actualKind, customExpectedKinds));
|
|
201
|
-
}
|
|
179
|
+
const customExpectedKinds = expectedKindsForCustomDatatype(event.datatype);
|
|
180
|
+
if (customExpectedKinds && !customExpectedKinds.includes(actualKind)) {
|
|
181
|
+
errors.push(new DatatypeLiteralMismatchError(event.span, formatPath(event.path), event.datatype, actualKind, customExpectedKinds));
|
|
202
182
|
}
|
|
203
183
|
}
|
|
204
184
|
errors.push(...validateAnnotationEntries(event.annotations, formatPath(event.path), event.span, events, pathToIndex, mode, datatypePolicy));
|
|
@@ -215,16 +195,17 @@ function defaultDatatypePolicyForMode(mode) {
|
|
|
215
195
|
return mode === 'strict' ? 'reserved_only' : 'allow_custom';
|
|
216
196
|
}
|
|
217
197
|
function shouldSkipHeaderEvent(event, header) {
|
|
198
|
+
if (event.sourcePlane !== undefined) {
|
|
199
|
+
return event.sourcePlane === 'header';
|
|
200
|
+
}
|
|
218
201
|
if (!header) {
|
|
219
202
|
return false;
|
|
220
203
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
&&
|
|
226
|
-
&& event.path.segments[1]?.type === 'member'
|
|
227
|
-
&& event.path.segments[1].key.startsWith('aeon:');
|
|
204
|
+
const segment = event.path.segments[1];
|
|
205
|
+
return event.path.segments[0]?.type === 'root'
|
|
206
|
+
&& segment?.type === 'member'
|
|
207
|
+
&& segment.key.startsWith('aeon:')
|
|
208
|
+
&& header.fields.has(segment.key.slice('aeon:'.length));
|
|
228
209
|
}
|
|
229
210
|
// Legacy export for backward compatibility
|
|
230
211
|
export function validateMode(_mode) {
|
|
@@ -259,7 +240,7 @@ function resolvedValueKind(value) {
|
|
|
259
240
|
return value.trimticks ? 'TrimtickStringLiteral' : 'StringLiteral';
|
|
260
241
|
}
|
|
261
242
|
if (value.type === 'DateTimeLiteral') {
|
|
262
|
-
return value.raw.includes('&') ? '
|
|
243
|
+
return value.raw.includes('&') ? 'WTCDateTimeLiteral' : 'DateTimeLiteral';
|
|
263
244
|
}
|
|
264
245
|
if (value.type === 'SeparatorLiteral') {
|
|
265
246
|
return 'SeparatorLiteral';
|
|
@@ -297,18 +278,9 @@ function validateAnonymousTypedValues(value, ownerPath, span, events, pathToInde
|
|
|
297
278
|
errors.push(new DatatypeLiteralMismatchError(value.span, ownerPath, datatype, actualKind, expectedKinds));
|
|
298
279
|
}
|
|
299
280
|
else if (!expectedKinds) {
|
|
300
|
-
const
|
|
301
|
-
if (
|
|
302
|
-
errors.push(new
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
const customExpectedKinds = expectedKindsForCustomDatatype(datatype, customShape);
|
|
306
|
-
if (customExpectedKinds && customExpectedKinds.length === 0) {
|
|
307
|
-
errors.push(new IncompatibleCustomDatatypeAdornmentsError(value.span, ownerPath, datatype, actualKind));
|
|
308
|
-
}
|
|
309
|
-
else if (customExpectedKinds && !customExpectedKinds.includes(actualKind)) {
|
|
310
|
-
errors.push(new DatatypeLiteralMismatchError(value.span, ownerPath, datatype, actualKind, customExpectedKinds));
|
|
311
|
-
}
|
|
281
|
+
const customExpectedKinds = expectedKindsForCustomDatatype(datatype);
|
|
282
|
+
if (customExpectedKinds && !customExpectedKinds.includes(actualKind)) {
|
|
283
|
+
errors.push(new DatatypeLiteralMismatchError(value.span, ownerPath, datatype, actualKind, customExpectedKinds));
|
|
312
284
|
}
|
|
313
285
|
}
|
|
314
286
|
}
|
|
@@ -422,18 +394,9 @@ function validateAnnotationEntries(annotations, ownerPath, span, events, pathToI
|
|
|
422
394
|
errors.push(new DatatypeLiteralMismatchError(span, attrPath, entry.datatype, actualKind, expectedKinds));
|
|
423
395
|
}
|
|
424
396
|
if (!expectedKinds) {
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
427
|
-
errors.push(new
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
const customExpectedKinds = expectedKindsForCustomDatatype(entry.datatype, customShape);
|
|
431
|
-
if (customExpectedKinds && customExpectedKinds.length === 0) {
|
|
432
|
-
errors.push(new IncompatibleCustomDatatypeAdornmentsError(span, attrPath, entry.datatype, actualKind));
|
|
433
|
-
}
|
|
434
|
-
else if (customExpectedKinds && !customExpectedKinds.includes(actualKind)) {
|
|
435
|
-
errors.push(new DatatypeLiteralMismatchError(span, attrPath, entry.datatype, actualKind, customExpectedKinds));
|
|
436
|
-
}
|
|
397
|
+
const customExpectedKinds = expectedKindsForCustomDatatype(entry.datatype);
|
|
398
|
+
if (customExpectedKinds && !customExpectedKinds.includes(actualKind)) {
|
|
399
|
+
errors.push(new DatatypeLiteralMismatchError(span, attrPath, entry.datatype, actualKind, customExpectedKinds));
|
|
437
400
|
}
|
|
438
401
|
}
|
|
439
402
|
}
|
|
@@ -475,9 +438,10 @@ function validateNodeHeadDatatypes(value, ownerPath, span, mode) {
|
|
|
475
438
|
function formatTypeAnnotation(datatype) {
|
|
476
439
|
const name = datatype.name;
|
|
477
440
|
const generics = datatype.genericArgs.length > 0 ? `<${datatype.genericArgs.join(', ')}>` : '';
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
441
|
+
const clarifiers = datatype.clarifiers.length > 0
|
|
442
|
+
? `[${datatype.clarifiers.map((value) => typeof value === 'string' ? JSON.stringify(value) : String(value)).join(', ')}]`
|
|
443
|
+
: '';
|
|
444
|
+
return `${name}${generics}${clarifiers}`;
|
|
481
445
|
}
|
|
482
446
|
function isAttrSegment(segment) {
|
|
483
447
|
return typeof segment === 'object' && segment !== null && segment.type === 'attr';
|
|
@@ -589,7 +553,11 @@ function buildAnnotationMap(attributes) {
|
|
|
589
553
|
const result = new Map();
|
|
590
554
|
for (const attribute of attributes) {
|
|
591
555
|
for (const [key, entry] of attribute.entries) {
|
|
592
|
-
const mapped = {
|
|
556
|
+
const mapped = {
|
|
557
|
+
...(entry.structuralId !== null ? { structuralId: entry.structuralId } : {}),
|
|
558
|
+
value: entry.value,
|
|
559
|
+
...(entry.datatype ? { datatype: formatDatatypeAnnotation(entry.datatype) } : {}),
|
|
560
|
+
};
|
|
593
561
|
const nested = buildAnnotationMap(entry.attributes);
|
|
594
562
|
if (nested) {
|
|
595
563
|
mapped.annotations = nested;
|
|
@@ -629,13 +597,13 @@ function expectedKindsForReservedDatatype(datatype) {
|
|
|
629
597
|
return ['TimeLiteral'];
|
|
630
598
|
if (base === 'datetime')
|
|
631
599
|
return ['DateTimeLiteral'];
|
|
632
|
-
if (base === '
|
|
633
|
-
return ['
|
|
600
|
+
if (base === 'wtc')
|
|
601
|
+
return ['WTCDateTimeLiteral'];
|
|
634
602
|
if (SEPARATOR_TYPES.has(base))
|
|
635
603
|
return ['SeparatorLiteral'];
|
|
636
604
|
if (base === 'sansa')
|
|
637
605
|
return ['SansaAddressLiteral'];
|
|
638
|
-
if (base === 'tuple')
|
|
606
|
+
if (base === 'tuple' || base === 'triple')
|
|
639
607
|
return ['TupleLiteral'];
|
|
640
608
|
if (base === 'list')
|
|
641
609
|
return ['ListNode'];
|
|
@@ -681,83 +649,11 @@ export function datatypeHasGenericArgs(datatype) {
|
|
|
681
649
|
}
|
|
682
650
|
return false;
|
|
683
651
|
}
|
|
684
|
-
function expectedKindsForCustomDatatype(datatype
|
|
685
|
-
let expectedKinds = null;
|
|
652
|
+
function expectedKindsForCustomDatatype(datatype) {
|
|
686
653
|
if (datatypeHasGenericArgs(datatype)) {
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
const bracketKinds = expectedKindsForCustomDatatypeShape(customShape);
|
|
690
|
-
if (bracketKinds === null) {
|
|
691
|
-
return expectedKinds;
|
|
692
|
-
}
|
|
693
|
-
if (expectedKinds === null) {
|
|
694
|
-
return bracketKinds;
|
|
654
|
+
return ['ListNode', 'TupleLiteral'];
|
|
695
655
|
}
|
|
696
|
-
|
|
697
|
-
return combined;
|
|
698
|
-
}
|
|
699
|
-
function expectedKindsForCustomDatatypeShape(customShape) {
|
|
700
|
-
if (customShape === 'none' || customShape === 'invalid_both')
|
|
701
|
-
return null;
|
|
702
|
-
if (customShape === 'both')
|
|
703
|
-
return ['SeparatorLiteral', 'RadixLiteral'];
|
|
704
|
-
if (customShape === 'separator')
|
|
705
|
-
return ['SeparatorLiteral'];
|
|
706
|
-
return ['RadixLiteral'];
|
|
707
|
-
}
|
|
708
|
-
function classifyCustomDatatypeShape(datatype) {
|
|
709
|
-
const specs = bracketSpecs(datatype);
|
|
710
|
-
if (specs.length === 0)
|
|
711
|
-
return 'none';
|
|
712
|
-
const separatorOk = specs.every(isValidSeparatorSpec);
|
|
713
|
-
const radixOk = specs.length === 1 && isValidRadixBaseSpec(specs[0]);
|
|
714
|
-
if (separatorOk && radixOk)
|
|
715
|
-
return 'both';
|
|
716
|
-
if (separatorOk)
|
|
717
|
-
return 'separator';
|
|
718
|
-
if (radixOk)
|
|
719
|
-
return 'radix';
|
|
720
|
-
return 'invalid_both';
|
|
721
|
-
}
|
|
722
|
-
function bracketSpecs(datatype) {
|
|
723
|
-
const specs = [];
|
|
724
|
-
let genericDepth = 0;
|
|
725
|
-
let bracketStart = -1;
|
|
726
|
-
for (let index = 0; index < datatype.length; index += 1) {
|
|
727
|
-
const char = datatype[index];
|
|
728
|
-
if (char === '<') {
|
|
729
|
-
genericDepth += 1;
|
|
730
|
-
continue;
|
|
731
|
-
}
|
|
732
|
-
if (char === '>') {
|
|
733
|
-
genericDepth = Math.max(0, genericDepth - 1);
|
|
734
|
-
continue;
|
|
735
|
-
}
|
|
736
|
-
if (genericDepth > 0) {
|
|
737
|
-
continue;
|
|
738
|
-
}
|
|
739
|
-
if (char === '[') {
|
|
740
|
-
bracketStart = index + 1;
|
|
741
|
-
continue;
|
|
742
|
-
}
|
|
743
|
-
if (char === ']' && bracketStart >= 0) {
|
|
744
|
-
specs.push(datatype.slice(bracketStart, index));
|
|
745
|
-
bracketStart = -1;
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
if (datatypeBase(datatype) === 'radix' && specs.length > 0) {
|
|
749
|
-
return specs.slice(1);
|
|
750
|
-
}
|
|
751
|
-
return specs;
|
|
752
|
-
}
|
|
753
|
-
function isValidSeparatorSpec(spec) {
|
|
754
|
-
return /^[A-Za-z0-9!#$%&*+\-.:;=?@^_|~<>]$/.test(spec);
|
|
755
|
-
}
|
|
756
|
-
function isValidRadixBaseSpec(spec) {
|
|
757
|
-
if (!/^[1-9]\d*$/.test(spec))
|
|
758
|
-
return false;
|
|
759
|
-
const value = Number(spec);
|
|
760
|
-
return Number.isInteger(value) && value >= 2 && value <= 64;
|
|
656
|
+
return null;
|
|
761
657
|
}
|
|
762
658
|
const NUMERIC_TYPES = new Set([
|
|
763
659
|
'number',
|
|
@@ -778,6 +674,7 @@ const NUMERIC_TYPES = new Set([
|
|
|
778
674
|
]);
|
|
779
675
|
const RADIX_TYPES = new Set([
|
|
780
676
|
'radix',
|
|
677
|
+
'decimal',
|
|
781
678
|
'radix2',
|
|
782
679
|
'radix6',
|
|
783
680
|
'radix8',
|