@elaraai/east 1.0.103 → 1.0.105
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/dist/src/compile/builtins/primitives.d.ts +1 -1
- package/dist/src/compile/control.d.ts.map +1 -1
- package/dist/src/compile/control.js +10 -5
- package/dist/src/compile/control.js.map +1 -1
- package/dist/src/compile.open_beast.spec.js +7 -3
- package/dist/src/compile.open_beast.spec.js.map +1 -1
- package/dist/src/location.d.ts.map +1 -1
- package/dist/src/location.js +38 -9
- package/dist/src/location.js.map +1 -1
- package/dist/src/location.spec.js +24 -1
- package/dist/src/location.spec.js.map +1 -1
- package/dist/src/query/jq/narrow.d.ts +68 -0
- package/dist/src/query/jq/narrow.d.ts.map +1 -0
- package/dist/src/query/jq/narrow.js +691 -0
- package/dist/src/query/jq/narrow.js.map +1 -0
- package/dist/src/query/jq/split.d.ts +35 -11
- package/dist/src/query/jq/split.d.ts.map +1 -1
- package/dist/src/query/jq/split.js +205 -35
- package/dist/src/query/jq/split.js.map +1 -1
- package/dist/src/query/jq/translate-builtins.d.ts.map +1 -1
- package/dist/src/query/jq/translate-builtins.js +43 -8
- package/dist/src/query/jq/translate-builtins.js.map +1 -1
- package/dist/src/query/jq/translate.d.ts +55 -4
- package/dist/src/query/jq/translate.d.ts.map +1 -1
- package/dist/src/query/jq/translate.js +174 -21
- package/dist/src/query/jq/translate.js.map +1 -1
- package/dist/src/runner_exec.d.ts +10 -0
- package/dist/src/runner_exec.d.ts.map +1 -1
- package/dist/src/runner_exec.js +11 -3
- package/dist/src/runner_exec.js.map +1 -1
- package/dist/src/runner_exec.spec.js +40 -2
- package/dist/src/runner_exec.spec.js.map +1 -1
- package/dist/src/serialization/beast2/index.d.ts +2 -1
- package/dist/src/serialization/beast2/index.d.ts.map +1 -1
- package/dist/src/serialization/beast2/index.js +2 -1
- package/dist/src/serialization/beast2/index.js.map +1 -1
- package/dist/src/serialization/beast2/v5/codec.d.ts +30 -1
- package/dist/src/serialization/beast2/v5/codec.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/codec.js +24 -3
- package/dist/src/serialization/beast2/v5/codec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.d.ts +23 -4
- package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.js +84 -19
- package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
- package/dist/src/serialization/beast2/v5/project.d.ts +156 -0
- package/dist/src/serialization/beast2/v5/project.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/project.js +830 -0
- package/dist/src/serialization/beast2/v5/project.js.map +1 -0
- package/dist/src/serialization/beast2/v5/project.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/project.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/project.spec.js +273 -0
- package/dist/src/serialization/beast2/v5/project.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/runs.d.ts +78 -7
- package/dist/src/serialization/beast2/v5/runs.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/runs.js +218 -7
- package/dist/src/serialization/beast2/v5/runs.js.map +1 -1
- package/dist/src/serialization/beast2/v5/runs.spec.js +223 -6
- package/dist/src/serialization/beast2/v5/runs.spec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/stream.d.ts +30 -2
- package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/stream.js +30 -5
- package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
- package/dist/src/serialization/east-inferred.spec.js +23 -0
- package/dist/src/serialization/east-inferred.spec.js.map +1 -1
- package/dist/src/serialization/east.d.ts.map +1 -1
- package/dist/src/serialization/east.js +5 -2
- package/dist/src/serialization/east.js.map +1 -1
- package/dist/src/serialization/index.d.ts +1 -1
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/index.js +1 -1
- package/dist/src/serialization/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* BEAST2 v5 projected decoding: the TypeScript port of east-c's
|
|
7
|
+
* `v5/project.c` (#599, #1112).
|
|
8
|
+
*
|
|
9
|
+
* A projection maps the WIRE type — what the bytes hold — to a PROJECTED type
|
|
10
|
+
* that keeps a subset of it: struct fields by name, and within variant
|
|
11
|
+
* payloads, array elements, ref contents and dict values. Decoding walks the
|
|
12
|
+
* wire byte-exactly: a dropped field is parsed past without being built. The
|
|
13
|
+
* same bytes decode whole or projected; nothing on the wire changes.
|
|
14
|
+
*
|
|
15
|
+
* Two rules keep a projection sound, as they do east-c's:
|
|
16
|
+
* - Dict keys and Set elements never project: they order the container, and
|
|
17
|
+
* dropping a field would change how they compare.
|
|
18
|
+
* - A container met in a dropped field still takes a definition, so the
|
|
19
|
+
* back-references after it stay aligned with the encoder's numbering. Each
|
|
20
|
+
* definition records the shape it was decoded to, and a back-reference to a
|
|
21
|
+
* container decoded to another shape throws
|
|
22
|
+
* {@link Beast2ProjectionAliasError}: the caller decodes whole instead.
|
|
23
|
+
*
|
|
24
|
+
* A compiled `$.for` over a lazy input infers its projection from the loop's
|
|
25
|
+
* body ({@link loopProjectionType}): the struct fields it reads of the loop
|
|
26
|
+
* variable, through chains of field accesses. Each segment it walks is then
|
|
27
|
+
* decoded to those fields alone, and counted ({@link beast2PagedLoopStats}).
|
|
28
|
+
*
|
|
29
|
+
* @packageDocumentation
|
|
30
|
+
*/
|
|
31
|
+
import type { EastTypeValue } from "../../../type_of_type.js";
|
|
32
|
+
import type { IR } from "../../../ir.js";
|
|
33
|
+
import { type V5Decoder } from "./codec.js";
|
|
34
|
+
import type { SegmentDecoder } from "./stream.js";
|
|
35
|
+
/**
|
|
36
|
+
* Builds a decoder that reads a value of the wire type `wire` as its
|
|
37
|
+
* projection `projected`: the struct fields `projected` keeps, by name, and
|
|
38
|
+
* within variant payloads, array elements, ref contents and dict values, each
|
|
39
|
+
* projected in turn. Any other part of `projected` must equal the wire's.
|
|
40
|
+
*
|
|
41
|
+
* The bytes are read as a whole decode reads them, so a value decodes to the
|
|
42
|
+
* kept fields of its whole decode. A dropped field is parsed past without
|
|
43
|
+
* being built; a container in it still takes a definition, and a
|
|
44
|
+
* back-reference that names a container decoded to another shape than its own
|
|
45
|
+
* throws {@link Beast2ProjectionAliasError}, after which the caller decodes
|
|
46
|
+
* whole.
|
|
47
|
+
*
|
|
48
|
+
* @param wire - the type the bytes hold
|
|
49
|
+
* @param projected - the type to decode them as
|
|
50
|
+
* @returns the decoder, which sets up the projection's state on the context
|
|
51
|
+
* it is given
|
|
52
|
+
* @throws {TypeError} When `projected` does not narrow `wire` so: a field it
|
|
53
|
+
* keeps that the wire lacks, a variant whose cases differ, a Set or a Dict's
|
|
54
|
+
* key narrowed, a function-typed field dropped, or a part of another kind
|
|
55
|
+
* that differs.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const Row = StructType({ id: IntegerType, lines: ArrayType(StringType) });
|
|
60
|
+
* const decode = buildV5ProjectedDecoder(asTypeValue(Row), asTypeValue(StructType({ id: IntegerType })));
|
|
61
|
+
* // At a row's bytes in a segment: `lines` is parsed past, never built.
|
|
62
|
+
* decode(reader, ctx); // { id: 1n }
|
|
63
|
+
* ```
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export declare function buildV5ProjectedDecoder(wire: EastTypeValue, projected: EastTypeValue): V5Decoder;
|
|
67
|
+
/**
|
|
68
|
+
* A segment decoder that decodes each element of an Array root, or each value
|
|
69
|
+
* of a Dict root, as `projected` narrows it: what `Beast2Pages` decodes a
|
|
70
|
+
* projected segment with. A Dict's keys decode whole and are checked to
|
|
71
|
+
* ascend, as a whole segment's are.
|
|
72
|
+
*
|
|
73
|
+
* @param wire - the root type the bytes hold: an Array or a Dict
|
|
74
|
+
* @param projected - the root type to decode them as
|
|
75
|
+
* @returns the decoder of a segment's `n` elements
|
|
76
|
+
* @throws {TypeError} When `projected` does not narrow `wire` (see
|
|
77
|
+
* {@link buildV5ProjectedDecoder}), or the root is a Set.
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
export declare function buildProjectedSegmentDecoder(wire: EastTypeValue, projected: EastTypeValue): SegmentDecoder;
|
|
81
|
+
/**
|
|
82
|
+
* The projection a `$.for` over a lazy collection decodes its segments to:
|
|
83
|
+
* the struct fields its body reads of the loop's value variable — an Array's
|
|
84
|
+
* element, a Dict's value — through chains of field accesses, following inner
|
|
85
|
+
* loops into nested Arrays and Dicts and inline calls into their bodies. Any
|
|
86
|
+
* other use of the variable, a binder that shadows it, or an IR node the walk
|
|
87
|
+
* has not been taught declines, and the loop decodes whole. Dict keys and Set
|
|
88
|
+
* elements never narrow.
|
|
89
|
+
*
|
|
90
|
+
* This is east-c's `east_beast2_projection_for_loop`, rule for rule, so every
|
|
91
|
+
* runtime decodes a loop's segments to the same fields.
|
|
92
|
+
*
|
|
93
|
+
* @param body - the loop's body
|
|
94
|
+
* @param target - the name of the loop's value variable
|
|
95
|
+
* @param root - the type of the collection the loop walks
|
|
96
|
+
* @returns the root type narrowed to what the body reads, or `null` when the
|
|
97
|
+
* loop decodes whole: it declined, it reads every field, the row is not a
|
|
98
|
+
* struct, or the narrowing would drop a function-typed field
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
export declare function loopProjectionType(body: IR, target: string, root: EastTypeValue): EastTypeValue | null;
|
|
102
|
+
/**
|
|
103
|
+
* What a compiled loop decodes a lazy collection's segments with, given the
|
|
104
|
+
* type its bytes hold: the decoder of its projection, or `null` to decode
|
|
105
|
+
* whole.
|
|
106
|
+
*
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
export type LoopProjector = (wire: EastTypeValue) => SegmentDecoder | null;
|
|
110
|
+
/**
|
|
111
|
+
* The projector of a compiled `$.for`: for each type the collections it walks
|
|
112
|
+
* hold, the projection {@link loopProjectionType} infers from its body, built
|
|
113
|
+
* the first time the loop meets that type. As east-c's, the projection follows
|
|
114
|
+
* the type the bytes hold, not the type the program declared.
|
|
115
|
+
*
|
|
116
|
+
* @param body - the loop's body
|
|
117
|
+
* @param target - the name of the loop's value variable
|
|
118
|
+
* @returns the loop's projector
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
export declare function loopProjectorFor(body: IR, target: string): LoopProjector;
|
|
122
|
+
/**
|
|
123
|
+
* What the compiled loops over lazy collections have decoded: the account
|
|
124
|
+
* {@link beast2PagedLoopStats} gives.
|
|
125
|
+
*/
|
|
126
|
+
export type Beast2PagedLoopStats = {
|
|
127
|
+
/** The segments decoded to the fields their loops' bodies read. */
|
|
128
|
+
segmentsProjected: number;
|
|
129
|
+
/** The segments decoded whole: by a loop that infers no projection, a
|
|
130
|
+
* Set's, or one whose projected decode fell back. */
|
|
131
|
+
segmentsWhole: number;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Counts one segment a compiled loop over a lazy collection decoded:
|
|
135
|
+
* projected, or whole — a loop that infers no projection, a Set's, or a
|
|
136
|
+
* segment whose projected decode fell back.
|
|
137
|
+
*
|
|
138
|
+
* @param projected - whether the segment was decoded projected
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
export declare function countPagedLoopSegment(projected: boolean): void;
|
|
142
|
+
/**
|
|
143
|
+
* What the compiled loops over lazy collections have decoded in this process:
|
|
144
|
+
* how many segments to the fields their bodies read, and how many whole. A
|
|
145
|
+
* runner's `-v` reports it beside its account of each lazy input, as east-c's
|
|
146
|
+
* runners report theirs, so a unit's log says whether projection applied.
|
|
147
|
+
*
|
|
148
|
+
* @returns the segments decoded projected and whole, since the process began
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* const { segmentsProjected, segmentsWhole } = beast2PagedLoopStats();
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare function beast2PagedLoopStats(): Beast2PagedLoopStats;
|
|
156
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/project.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAO9D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAA4E,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACtH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAuSlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,GAAG,SAAS,CAMhG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,GAAG,cAAc,CAqC1G;AAkXD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,aAAa,GAAG,IAAI,CAEtG;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,aAAa,KAAK,cAAc,GAAG,IAAI,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAUxE;AAMD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,mEAAmE;IACnE,iBAAiB,EAAE,MAAM,CAAC;IAC1B;0DACsD;IACtD,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAKF;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAG9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,IAAI,oBAAoB,CAE3D"}
|