@elaraai/east 1.0.108 → 1.0.110

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.
Files changed (102) hide show
  1. package/dist/src/analyze.d.ts.map +1 -1
  2. package/dist/src/analyze.js +58 -0
  3. package/dist/src/analyze.js.map +1 -1
  4. package/dist/src/builtins.d.ts +1 -1
  5. package/dist/src/builtins.d.ts.map +1 -1
  6. package/dist/src/builtins.js +25 -0
  7. package/dist/src/builtins.js.map +1 -1
  8. package/dist/src/codegen/codegen.spec.js +66 -0
  9. package/dist/src/codegen/codegen.spec.js.map +1 -1
  10. package/dist/src/codegen/printer.d.ts.map +1 -1
  11. package/dist/src/codegen/printer.js +47 -2
  12. package/dist/src/codegen/printer.js.map +1 -1
  13. package/dist/src/codegen/spellings.d.ts +7 -5
  14. package/dist/src/codegen/spellings.d.ts.map +1 -1
  15. package/dist/src/codegen/spellings.js +4 -0
  16. package/dist/src/codegen/spellings.js.map +1 -1
  17. package/dist/src/codegen/spellings.spec.js +2 -1
  18. package/dist/src/codegen/spellings.spec.js.map +1 -1
  19. package/dist/src/compile/builtins/dict.d.ts +2 -0
  20. package/dist/src/compile/builtins/dict.d.ts.map +1 -1
  21. package/dist/src/compile/builtins/dict.js +6 -0
  22. package/dist/src/compile/builtins/dict.js.map +1 -1
  23. package/dist/src/compile/builtins/key_range.d.ts +63 -0
  24. package/dist/src/compile/builtins/key_range.d.ts.map +1 -0
  25. package/dist/src/compile/builtins/key_range.js +80 -0
  26. package/dist/src/compile/builtins/key_range.js.map +1 -0
  27. package/dist/src/compile/builtins/primitives.d.ts +1 -1
  28. package/dist/src/compile/builtins/set.d.ts +2 -0
  29. package/dist/src/compile/builtins/set.d.ts.map +1 -1
  30. package/dist/src/compile/builtins/set.js +6 -0
  31. package/dist/src/compile/builtins/set.js.map +1 -1
  32. package/dist/src/containers/range.d.ts +77 -0
  33. package/dist/src/containers/range.d.ts.map +1 -0
  34. package/dist/src/containers/range.js +68 -0
  35. package/dist/src/containers/range.js.map +1 -0
  36. package/dist/src/containers/range.spec.d.ts +6 -0
  37. package/dist/src/containers/range.spec.d.ts.map +1 -0
  38. package/dist/src/containers/range.spec.js +254 -0
  39. package/dist/src/containers/range.spec.js.map +1 -0
  40. package/dist/src/containers/sortedmap.d.ts +25 -0
  41. package/dist/src/containers/sortedmap.d.ts.map +1 -1
  42. package/dist/src/containers/sortedmap.js +29 -0
  43. package/dist/src/containers/sortedmap.js.map +1 -1
  44. package/dist/src/containers/sortedset.d.ts +26 -0
  45. package/dist/src/containers/sortedset.d.ts.map +1 -1
  46. package/dist/src/containers/sortedset.js +30 -0
  47. package/dist/src/containers/sortedset.js.map +1 -1
  48. package/dist/src/expr/dict.d.ts +86 -0
  49. package/dist/src/expr/dict.d.ts.map +1 -1
  50. package/dist/src/expr/dict.js +106 -0
  51. package/dist/src/expr/dict.js.map +1 -1
  52. package/dist/src/expr/key_range.d.ts +105 -0
  53. package/dist/src/expr/key_range.d.ts.map +1 -0
  54. package/dist/src/expr/key_range.js +124 -0
  55. package/dist/src/expr/key_range.js.map +1 -0
  56. package/dist/src/expr/set.d.ts +74 -0
  57. package/dist/src/expr/set.d.ts.map +1 -1
  58. package/dist/src/expr/set.js +94 -0
  59. package/dist/src/expr/set.js.map +1 -1
  60. package/dist/src/fuzz.d.ts +13 -0
  61. package/dist/src/fuzz.d.ts.map +1 -1
  62. package/dist/src/fuzz.js +26 -11
  63. package/dist/src/fuzz.js.map +1 -1
  64. package/dist/src/fuzz.spec.d.ts +6 -0
  65. package/dist/src/fuzz.spec.d.ts.map +1 -0
  66. package/dist/src/fuzz.spec.js +45 -0
  67. package/dist/src/fuzz.spec.js.map +1 -0
  68. package/dist/src/index.d.ts +3 -0
  69. package/dist/src/index.d.ts.map +1 -1
  70. package/dist/src/index.js +1 -0
  71. package/dist/src/index.js.map +1 -1
  72. package/dist/src/internal.d.ts +1 -0
  73. package/dist/src/internal.d.ts.map +1 -1
  74. package/dist/src/internal.js +2 -0
  75. package/dist/src/internal.js.map +1 -1
  76. package/dist/src/key_bound.d.ts +94 -0
  77. package/dist/src/key_bound.d.ts.map +1 -0
  78. package/dist/src/key_bound.js +183 -0
  79. package/dist/src/key_bound.js.map +1 -0
  80. package/dist/src/key_bound.spec.d.ts +6 -0
  81. package/dist/src/key_bound.spec.d.ts.map +1 -0
  82. package/dist/src/key_bound.spec.js +158 -0
  83. package/dist/src/key_bound.spec.js.map +1 -0
  84. package/dist/src/serialization/beast2/v5/lazy.d.ts +4 -0
  85. package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
  86. package/dist/src/serialization/beast2/v5/lazy.js +36 -11
  87. package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
  88. package/dist/src/serialization/beast2/v5/project.spec.js +2 -12
  89. package/dist/src/serialization/beast2/v5/project.spec.js.map +1 -1
  90. package/dist/src/serialization/beast2/v5/stream.d.ts +138 -1
  91. package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
  92. package/dist/src/serialization/beast2/v5/stream.js +224 -1
  93. package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
  94. package/dist/src/serialization/beast2/v5/view.d.ts +108 -0
  95. package/dist/src/serialization/beast2/v5/view.d.ts.map +1 -0
  96. package/dist/src/serialization/beast2/v5/view.js +227 -0
  97. package/dist/src/serialization/beast2/v5/view.js.map +1 -0
  98. package/dist/src/serialization/beast2/v5/view.spec.d.ts +6 -0
  99. package/dist/src/serialization/beast2/v5/view.spec.d.ts.map +1 -0
  100. package/dist/src/serialization/beast2/v5/view.spec.js +509 -0
  101. package/dist/src/serialization/beast2/v5/view.spec.js.map +1 -0
  102. package/package.json +1 -1
@@ -0,0 +1,94 @@
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
+ import { type EastTypeValue } from "./type_of_type.js";
6
+ import type { EastType } from "./types.js";
7
+ /** One leaf of a key type: the field path that reaches it, and its type. */
8
+ export interface KeyLeaf {
9
+ /** The field names from the key to the leaf, outermost first; empty for a key that is not a struct. */
10
+ readonly path: readonly string[];
11
+ /** The leaf's type. */
12
+ readonly type: EastTypeValue;
13
+ }
14
+ /**
15
+ * A key type's leaves, in the key's sort order: its fields in declaration
16
+ * order, through nested structs.
17
+ *
18
+ * @param keyType - A Dict's key type or a Set's element type
19
+ * @returns The leaves; one, with an empty path, for a key that is not a struct
20
+ */
21
+ export declare function keyLeaves(keyType: EastTypeValue | EastType): KeyLeaf[];
22
+ /**
23
+ * The value of one leaf of a key.
24
+ *
25
+ * @param key - The key, or a bound of it
26
+ * @param path - The leaf's path, as {@link keyLeaves} gives it
27
+ * @returns The value at the path
28
+ */
29
+ export declare function keyLeafAt(key: unknown, path: readonly string[]): unknown;
30
+ /**
31
+ * Whether a type is a key's type cut short: the key's own type, or — for a
32
+ * struct key — a struct of its first fields in order, each of the key's own
33
+ * type but the last, which may be cut short the same way.
34
+ *
35
+ * @param keyType - The key's type
36
+ * @param boundType - The bound's type
37
+ * @returns Whether a value of `boundType` gives a leading part of the key
38
+ */
39
+ export declare function isKeyBoundType(keyType: EastTypeValue | EastType, boundType: EastTypeValue | EastType): boolean;
40
+ /** Which bound a refusal names: a range's `from` or `to`, or a prefix. */
41
+ export type KeyBoundName = "from" | "to" | "prefix";
42
+ /**
43
+ * Why a bound's type is refused, in the words every runtime says: `undefined`
44
+ * for a type that is a leading part of the key.
45
+ *
46
+ * @remarks
47
+ * A bound's type is a type parameter of the range builtins, so an IR can name
48
+ * one that is no leading part of the key. It is refused wherever an IR is
49
+ * checked — where the function is built, in `analyze`, and where east-c makes
50
+ * the builtin — and never trusted.
51
+ *
52
+ * A prefix is the first fields of a struct key: on any other key it could name
53
+ * one key only, and it is not a String's starts-with, so it is refused naming
54
+ * the reads that say what was meant.
55
+ *
56
+ * @param name - Which bound: a range's `from` or `to`, or a prefix
57
+ * @param keyType - The key's type
58
+ * @param boundType - The bound's type; `undefined` for a bound written as fields that are not the key's first, which has no type to give
59
+ * @returns The refusal's words, or `undefined`
60
+ */
61
+ export declare function keyBoundRefusal(name: KeyBoundName, keyType: EastTypeValue | EastType, boundType: EastTypeValue | EastType | undefined): string | undefined;
62
+ /**
63
+ * The leaves a bound gives: the values of its type's leaves, in order — as
64
+ * many of the key's first leaves.
65
+ *
66
+ * @param boundType - The bound's type, a leading part of the key ({@link isKeyBoundType})
67
+ * @param bound - The bound
68
+ * @returns The bound's leaf values, in the key's leaf order
69
+ */
70
+ export declare function keyBoundValues(boundType: EastTypeValue | EastType, bound: unknown): unknown[];
71
+ /**
72
+ * How a key stands to a bound: before it (-1), at it — equal on every leaf the
73
+ * bound gives (0) — or past it (1).
74
+ *
75
+ * @remarks
76
+ * Monotone over the keys in order, because it reads only the leading leaves,
77
+ * which are the ones the order sorts by first.
78
+ *
79
+ * @param leaves - The key's leaves ({@link keyLeaves})
80
+ * @param count - How many leading leaves a bound gives
81
+ * @returns A comparison of a key with a bound's leaf values
82
+ */
83
+ export declare function compareKeyToBoundFor(leaves: readonly KeyLeaf[], count: number): (key: unknown, values: readonly unknown[]) => 1 | 0 | -1;
84
+ /**
85
+ * The monotone test "is this key at or past the bound?": false, then true,
86
+ * over the keys in order. A key equal to the bound on every leaf the bound
87
+ * gives is at it.
88
+ *
89
+ * @param leaves - The key's leaves ({@link keyLeaves})
90
+ * @param values - The bound's leaf values, as many of the key's first leaves ({@link keyBoundValues})
91
+ * @returns The test
92
+ */
93
+ export declare function keyAtOrPast(leaves: readonly KeyLeaf[], values: readonly unknown[]): (key: unknown) => boolean;
94
+ //# sourceMappingURL=key_bound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key_bound.d.ts","sourceRoot":"","sources":["../../src/key_bound.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8BH,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CA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AAM,EAAE,SAAS,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAG7G"}
@@ -0,0 +1,183 @@
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
+ * A bound of a key range (#1616, D2): a leading part of a Dict's key or a
7
+ * Set's element.
8
+ *
9
+ * A key's fields, in the key type's order and through nested structs, are its
10
+ * **leaves**: `{ press, day, job }` has three, and an index's
11
+ * `{ ik: { on, key }, k }` has `on`'s, then `key`, then `k`'s. A field that is
12
+ * not a struct is one leaf, whatever it holds. Struct keys compare field by
13
+ * field in declaration order, so the leaves in order ARE the key's sort order.
14
+ *
15
+ * A **bound** gives the first leaves and stops. Its type is the key's type cut
16
+ * short: for a struct key, a struct of its first fields in order, each of the
17
+ * key's own type but the last, which may be cut short the same way; for any
18
+ * other key, the key's type.
19
+ *
20
+ * A key is **at or past** a bound when its first leaves, compared in order by
21
+ * East's order for each, are greater than or equal to the bound's. That test
22
+ * is false, then true, over the keys in order, so a bound names one row of a
23
+ * sorted collection and a pair of them one run of rows.
24
+ *
25
+ * One copy of the rule for TypeScript: the range builtins, the API's key
26
+ * search and east-ui's key search all read it here.
27
+ *
28
+ * @packageDocumentation
29
+ */
30
+ import { compareFor } from "./comparison.js";
31
+ import { isVariant } from "./containers/variant.js";
32
+ import { toEastTypeValue } from "./type_of_type.js";
33
+ import { isTypeValueEqual } from "./type_value_equal.js";
34
+ /** A type as a type value. */
35
+ function typeValueOf(type) {
36
+ return isVariant(type) ? type : toEastTypeValue(type);
37
+ }
38
+ /**
39
+ * A key type's leaves, in the key's sort order: its fields in declaration
40
+ * order, through nested structs.
41
+ *
42
+ * @param keyType - A Dict's key type or a Set's element type
43
+ * @returns The leaves; one, with an empty path, for a key that is not a struct
44
+ */
45
+ export function keyLeaves(keyType) {
46
+ const type = typeValueOf(keyType);
47
+ if (type.type !== "Struct")
48
+ return [{ path: [], type }];
49
+ const out = [];
50
+ for (const field of type.value) {
51
+ for (const leaf of keyLeaves(field.type))
52
+ out.push({ path: [field.name, ...leaf.path], type: leaf.type });
53
+ }
54
+ return out;
55
+ }
56
+ /**
57
+ * The value of one leaf of a key.
58
+ *
59
+ * @param key - The key, or a bound of it
60
+ * @param path - The leaf's path, as {@link keyLeaves} gives it
61
+ * @returns The value at the path
62
+ */
63
+ export function keyLeafAt(key, path) {
64
+ let value = key;
65
+ for (const name of path)
66
+ value = value[name];
67
+ return value;
68
+ }
69
+ /**
70
+ * Whether a type is a key's type cut short: the key's own type, or — for a
71
+ * struct key — a struct of its first fields in order, each of the key's own
72
+ * type but the last, which may be cut short the same way.
73
+ *
74
+ * @param keyType - The key's type
75
+ * @param boundType - The bound's type
76
+ * @returns Whether a value of `boundType` gives a leading part of the key
77
+ */
78
+ export function isKeyBoundType(keyType, boundType) {
79
+ const key = typeValueOf(keyType);
80
+ const bound = typeValueOf(boundType);
81
+ if (isTypeValueEqual(key, bound))
82
+ return true;
83
+ if (key.type !== "Struct" || bound.type !== "Struct")
84
+ return false;
85
+ const keyFields = key.value;
86
+ const boundFields = bound.value;
87
+ if (boundFields.length === 0 || boundFields.length > keyFields.length)
88
+ return false;
89
+ for (let i = 0; i < boundFields.length; i++) {
90
+ const of = keyFields[i];
91
+ const given = boundFields[i];
92
+ if (given.name !== of.name)
93
+ return false;
94
+ const last = i === boundFields.length - 1;
95
+ if (last ? !isKeyBoundType(of.type, given.type) : !isTypeValueEqual(of.type, given.type))
96
+ return false;
97
+ }
98
+ return true;
99
+ }
100
+ /** How a refusal names a bound. */
101
+ const boundWords = (name) => (name === "prefix" ? "a prefix" : `a range's \`${name}\``);
102
+ /** A key's leaves by name, in order: `press, day, job`. */
103
+ const leafNames = (keyType) => keyLeaves(keyType).map((leaf) => leaf.path.join(".")).join(", ");
104
+ /**
105
+ * Why a bound's type is refused, in the words every runtime says: `undefined`
106
+ * for a type that is a leading part of the key.
107
+ *
108
+ * @remarks
109
+ * A bound's type is a type parameter of the range builtins, so an IR can name
110
+ * one that is no leading part of the key. It is refused wherever an IR is
111
+ * checked — where the function is built, in `analyze`, and where east-c makes
112
+ * the builtin — and never trusted.
113
+ *
114
+ * A prefix is the first fields of a struct key: on any other key it could name
115
+ * one key only, and it is not a String's starts-with, so it is refused naming
116
+ * the reads that say what was meant.
117
+ *
118
+ * @param name - Which bound: a range's `from` or `to`, or a prefix
119
+ * @param keyType - The key's type
120
+ * @param boundType - The bound's type; `undefined` for a bound written as fields that are not the key's first, which has no type to give
121
+ * @returns The refusal's words, or `undefined`
122
+ */
123
+ export function keyBoundRefusal(name, keyType, boundType) {
124
+ const key = typeValueOf(keyType);
125
+ const leading = boundType !== undefined && isKeyBoundType(key, boundType);
126
+ if (key.type !== "Struct") {
127
+ if (name === "prefix") {
128
+ return `a prefix gives the first fields of a struct key, and this key is a ${key.type}: read one key with \`get\`, or the keys between two with \`range\``;
129
+ }
130
+ return leading ? undefined : `${boundWords(name)} is not the key's type: a bound of a ${key.type} key is a ${key.type}`;
131
+ }
132
+ return leading ? undefined
133
+ : `${boundWords(name)} is no leading part of the key: a bound gives the key's first fields in order — ${leafNames(key)}`;
134
+ }
135
+ /**
136
+ * The leaves a bound gives: the values of its type's leaves, in order — as
137
+ * many of the key's first leaves.
138
+ *
139
+ * @param boundType - The bound's type, a leading part of the key ({@link isKeyBoundType})
140
+ * @param bound - The bound
141
+ * @returns The bound's leaf values, in the key's leaf order
142
+ */
143
+ export function keyBoundValues(boundType, bound) {
144
+ return keyLeaves(boundType).map((leaf) => keyLeafAt(bound, leaf.path));
145
+ }
146
+ /**
147
+ * How a key stands to a bound: before it (-1), at it — equal on every leaf the
148
+ * bound gives (0) — or past it (1).
149
+ *
150
+ * @remarks
151
+ * Monotone over the keys in order, because it reads only the leading leaves,
152
+ * which are the ones the order sorts by first.
153
+ *
154
+ * @param leaves - The key's leaves ({@link keyLeaves})
155
+ * @param count - How many leading leaves a bound gives
156
+ * @returns A comparison of a key with a bound's leaf values
157
+ */
158
+ export function compareKeyToBoundFor(leaves, count) {
159
+ const given = leaves.slice(0, count);
160
+ const comparators = given.map((leaf) => compareFor(leaf.type));
161
+ return (key, values) => {
162
+ for (let i = 0; i < given.length; i++) {
163
+ const order = comparators[i](keyLeafAt(key, given[i].path), values[i]);
164
+ if (order !== 0)
165
+ return order;
166
+ }
167
+ return 0;
168
+ };
169
+ }
170
+ /**
171
+ * The monotone test "is this key at or past the bound?": false, then true,
172
+ * over the keys in order. A key equal to the bound on every leaf the bound
173
+ * gives is at it.
174
+ *
175
+ * @param leaves - The key's leaves ({@link keyLeaves})
176
+ * @param values - The bound's leaf values, as many of the key's first leaves ({@link keyBoundValues})
177
+ * @returns The test
178
+ */
179
+ export function keyAtOrPast(leaves, values) {
180
+ const compare = compareKeyToBoundFor(leaves, values.length);
181
+ return (key) => compare(key, values) >= 0;
182
+ }
183
+ //# sourceMappingURL=key_bound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key_bound.js","sourceRoot":"","sources":["../../src/key_bound.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAsB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAczD,8BAA8B;AAC9B,SAAS,WAAW,CAAC,IAA8B;IACjD,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAqB,CAAC,CAAC,CAAC,eAAe,CAAC,IAAgB,CAAC,CAAC;AACrF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,OAAiC;IACzD,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,I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CAAC,CAAC,CAAE,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACzE,IAAI,KAAK,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;QAChC,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,MAA0B,EAAE,MAA0B;IAChF,MAAM,OAAO,GAAG,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,6 @@
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
+ export {};
6
+ //# sourceMappingURL=key_bound.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key_bound.spec.d.ts","sourceRoot":"","sources":["../../src/key_bound.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,158 @@
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
+ * A bound of a key range (#1616, D2): a key's leaves in its sort order, the
7
+ * types that are a key's type cut short, the words a bound of any other type
8
+ * is refused in, and the test "at or past the bound" — false, then true, over
9
+ * the keys in order, for the orders that are easy to get wrong: floats with
10
+ * NaN, both zeros and both infinities, options, variants and nested structs.
11
+ */
12
+ import { describe, test } from "node:test";
13
+ import assert from "node:assert/strict";
14
+ import { compareFor } from "./comparison.js";
15
+ import { none, some, variant } from "./containers/variant.js";
16
+ import { randomStream } from "./fuzz.js";
17
+ import { compareKeyToBoundFor, isKeyBoundType, keyAtOrPast, keyBoundRefusal, keyBoundValues, keyLeafAt, keyLeaves } from "./key_bound.js";
18
+ import { toEastTypeValue } from "./type_of_type.js";
19
+ import { ArrayType, DateTimeType, FloatType, IntegerType, NullType, OptionType, StringType, StructType, VariantType, } from "./types.js";
20
+ /** Sheets printed, keyed by press, day and job. */
21
+ const Sheets = StructType({ press: StringType, day: DateTimeType, job: StringType });
22
+ /** An index's key: the index key, its parts a struct of their own, then the row's key. */
23
+ const Level = VariantType({ day: NullType, week: NullType });
24
+ const Indexed = StructType({
25
+ ik: StructType({ on: StructType({ hall: StringType, press: StringType }), key: StringType, level: Level, tile: IntegerType }),
26
+ k: StringType,
27
+ });
28
+ /** The paths of a key's leaves, as text. */
29
+ const paths = (type) => keyLeaves(type).map((leaf) => leaf.path.join("."));
30
+ describe("a key's leaves (#1616)", () => {
31
+ test("a key that is not a struct is one leaf, with no path, whatever it holds", () => {
32
+ for (const type of [StringType, IntegerType, OptionType(StringType), Level, ArrayType(StringType)]) {
33
+ const leaves = keyLeaves(type);
34
+ assert.deepEqual(leaves.map((leaf) => leaf.path), [[]]);
35
+ assert.equal(leaves[0].type.type, toEastTypeValue(type).type);
36
+ }
37
+ });
38
+ test("a struct key's fields in declaration order, through nested structs, are its leaves", () => {
39
+ assert.deepEqual(paths(Sheets), ["press", "day", "job"]);
40
+ assert.deepEqual(paths(Indexed), ["ik.on.hall", "ik.on.press", "ik.key", "ik.level", "ik.tile", "k"]);
41
+ // A field that holds a struct inside something else is one leaf: only a struct field is walked into.
42
+ assert.deepEqual(paths(StructType({ at: OptionType(StructType({ x: IntegerType })), id: StringType })), ["at", "id"]);
43
+ assert.deepEqual(keyLeaves(Indexed).map((leaf) => leaf.type.type), ["String", "String", "String", "Variant", "Integer", "String"]);
44
+ });
45
+ test("a type and its type value give the same leaves, and a leaf is read by its path", () => {
46
+ assert.deepEqual(paths(toEastTypeValue(Indexed)), paths(Indexed));
47
+ const key = { ik: { on: { hall: "H1", press: "P3" }, key: "j", level: variant("week", null), tile: 4n }, k: "row" };
48
+ assert.deepEqual(keyLeaves(Indexed).map((leaf) => keyLeafAt(key, leaf.path)), ["H1", "P3", "j", variant("week", null), 4n, "row"]);
49
+ });
50
+ });
51
+ describe("a bound's type is the key's type cut short (#1616)", () => {
52
+ test("the whole key, its first fields in order, and its last field given cut short the same way", () => {
53
+ assert.ok(isKeyBoundType(Sheets, Sheets));
54
+ assert.ok(isKeyBoundType(Sheets, StructType({ press: StringType })));
55
+ assert.ok(isKeyBoundType(Sheets, StructType({ press: StringType, day: DateTimeType })));
56
+ assert.ok(isKeyBoundType(Indexed, StructType({ ik: StructType({ on: StructType({ hall: StringType }) }) })));
57
+ assert.ok(isKeyBoundType(Indexed, StructType({ ik: StructType({ on: StructType({ hall: StringType, press: StringType }), key: StringType }) })));
58
+ assert.ok(isKeyBoundType(Indexed, StructType({ ik: Indexed.fields.ik })));
59
+ // A key that is not a struct is bounded by its own type.
60
+ assert.ok(isKeyBoundType(StringType, StringType));
61
+ assert.ok(isKeyBoundType(OptionType(IntegerType), OptionType(IntegerType)));
62
+ });
63
+ test("no other type: a later field alone, fields out of order, a field of another type, an earlier field cut short, no field at all, another key type", () => {
64
+ assert.equal(isKeyBoundType(Sheets, StructType({ day: DateTimeType })), false);
65
+ assert.equal(isKeyBoundType(Sheets, StructType({ day: DateTimeType, press: StringType })), false);
66
+ assert.equal(isKeyBoundType(Sheets, StructType({ press: IntegerType })), false);
67
+ assert.equal(isKeyBoundType(Sheets, StructType({ press: StringType, day: StringType })), false);
68
+ assert.equal(isKeyBoundType(Sheets, StructType({ press: StringType, day: DateTimeType, job: StringType, more: StringType })), false);
69
+ // Only the last field a bound gives may be cut short.
70
+ assert.equal(isKeyBoundType(Indexed, StructType({ ik: StructType({ on: StructType({ hall: StringType }), key: StringType }) })), false);
71
+ assert.equal(isKeyBoundType(Sheets, StructType({})), false);
72
+ assert.equal(isKeyBoundType(StringType, IntegerType), false);
73
+ assert.equal(isKeyBoundType(StringType, StructType({ press: StringType })), false);
74
+ });
75
+ test("a bound of another type is refused in one set of words, naming the key's fields in order", () => {
76
+ assert.equal(keyBoundRefusal("from", Sheets, StructType({ press: StringType, day: DateTimeType })), undefined);
77
+ assert.equal(keyBoundRefusal("from", Sheets, StructType({ day: DateTimeType })), "a range's `from` is no leading part of the key: a bound gives the key's first fields in order — press, day, job");
78
+ assert.equal(keyBoundRefusal("to", Indexed, StructType({ k: StringType })), "a range's `to` is no leading part of the key: a bound gives the key's first fields in order — ik.on.hall, ik.on.press, ik.key, ik.level, ik.tile, k");
79
+ assert.equal(keyBoundRefusal("prefix", Sheets, StructType({ job: StringType })), "a prefix is no leading part of the key: a bound gives the key's first fields in order — press, day, job");
80
+ assert.equal(keyBoundRefusal("to", StringType, IntegerType), "a range's `to` is not the key's type: a bound of a String key is a String");
81
+ assert.equal(keyBoundRefusal("from", StringType, StringType), undefined);
82
+ });
83
+ test("a prefix of a key that is not a struct is refused whatever its type, naming `get` and `range`", () => {
84
+ assert.equal(keyBoundRefusal("prefix", StringType, StringType), "a prefix gives the first fields of a struct key, and this key is a String: read one key with `get`, or the keys between two with `range`");
85
+ assert.equal(keyBoundRefusal("prefix", Level, Level), "a prefix gives the first fields of a struct key, and this key is a Variant: read one key with `get`, or the keys between two with `range`");
86
+ });
87
+ });
88
+ describe("at or past a bound (#1616)", () => {
89
+ /** A key whose leaves hold the orders that are easy to get wrong. */
90
+ const Odd = StructType({
91
+ x: FloatType,
92
+ tag: OptionType(StringType),
93
+ what: VariantType({ a: IntegerType, b: NullType }),
94
+ at: StructType({ day: DateTimeType, n: IntegerType }),
95
+ });
96
+ const floats = [NaN, -Infinity, Infinity, -0, 0, -1.5, 2.25, 1e300];
97
+ const tags = [none, some(""), some("a"), some("b\u{1F600}"), some("￿")];
98
+ const whats = [variant("a", -1n), variant("a", 7n), variant("b", null)];
99
+ const days = [new Date(0), new Date("2026-06-01T00:00:00Z"), new Date("2026-06-01T00:00:00.001Z")];
100
+ const random = randomStream(1616);
101
+ const pick = (values) => values[Math.floor(random() * values.length)];
102
+ const key = () => ({ x: pick(floats), tag: pick(tags), what: pick(whats), at: { day: pick(days), n: BigInt(Math.floor(random() * 3)) } });
103
+ const keys = Array.from({ length: 400 }, key).sort(compareFor(Odd));
104
+ const leaves = keyLeaves(Odd);
105
+ test("the key's leaves are x, tag, what, at.day and at.n", () => {
106
+ assert.deepEqual(leaves.map((leaf) => leaf.path.join(".")), ["x", "tag", "what", "at.day", "at.n"]);
107
+ });
108
+ test("a bound of every length is false, then true, over the keys in order, and holds what comparing the leading leaves holds", () => {
109
+ for (let count = 0; count <= leaves.length; count++) {
110
+ const compares = leaves.slice(0, count).map((leaf) => compareFor(leaf.type));
111
+ for (let trial = 0; trial < 60; trial++) {
112
+ const values = keyBoundValues(Odd, key()).slice(0, count);
113
+ const atOrPast = keyAtOrPast(leaves, values);
114
+ const held = keys.map(atOrPast);
115
+ // False, then true: never false again once it has held.
116
+ const first = held.indexOf(true);
117
+ assert.ok(first === -1 || held.slice(first).every((at) => at), `a bound of ${count} leaves is false, then true`);
118
+ // The oracle: the leading leaves compared one at a time, by each leaf's own order.
119
+ const oracle = keys.map((k) => {
120
+ for (let i = 0; i < count; i++) {
121
+ const order = compares[i](keyLeafAt(k, leaves[i].path), values[i]);
122
+ if (order !== 0)
123
+ return order > 0;
124
+ }
125
+ return true;
126
+ });
127
+ assert.deepEqual(held, oracle);
128
+ }
129
+ }
130
+ });
131
+ test("a key equal to a bound on every leaf the bound gives is at it; a bound of no leaf holds for every key", () => {
132
+ const compare = compareKeyToBoundFor(leaves, 2);
133
+ const at = { x: -0, tag: some("a"), what: variant("b", null), at: { day: days[0], n: 0n } };
134
+ assert.equal(compare(at, [-0, some("a")]), 0);
135
+ // The zeros and NaN order as East orders them: -0 before 0, NaN after every number.
136
+ assert.equal(compare(at, [0, some("a")]), -1);
137
+ assert.equal(compare({ ...at, x: NaN }, [Infinity, some("a")]), 1);
138
+ assert.equal(compare({ ...at, x: NaN }, [NaN, some("a")]), 0);
139
+ // An option's none is before every some.
140
+ assert.equal(compare({ ...at, tag: none }, [-0, some("")]), -1);
141
+ assert.equal(keys.every(keyAtOrPast(leaves, [])), true);
142
+ });
143
+ test("a bound that is the whole key is at or past exactly the keys the key's own order puts at or after it", () => {
144
+ const order = compareFor(Odd);
145
+ for (let trial = 0; trial < 40; trial++) {
146
+ const bound = key();
147
+ const atOrPast = keyAtOrPast(leaves, keyBoundValues(Odd, bound));
148
+ assert.deepEqual(keys.map(atOrPast), keys.map((k) => order(k, bound) >= 0));
149
+ }
150
+ });
151
+ test("a bound's values are read by its own type, a cut-short struct among them", () => {
152
+ const Cut = StructType({ x: FloatType, tag: OptionType(StringType), what: Odd.fields.what, at: StructType({ day: DateTimeType }) });
153
+ assert.ok(isKeyBoundType(Odd, Cut));
154
+ const bound = { x: 2.25, tag: some("a"), what: variant("a", 7n), at: { day: days[1] } };
155
+ assert.deepEqual(keyBoundValues(Cut, bound), [2.25, some("a"), variant("a", 7n), days[1]]);
156
+ });
157
+ });
158
+ //# sourceMappingURL=key_bound.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key_bound.spec.js","sourceRoot":"","sources":["../../src/key_bound.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC1I,OAAO,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AI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,0EAA0E,EAAE,GAAG,EAAE;QACpF,MAAM,GAAG,GAAG,UAAU,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC;QACpI,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QACpC,MAAM,KAAK,GAA4B,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAE,EAAE,EAAE,CAAC;QAClH,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -16,6 +16,10 @@
16
16
  * the owning segment through the fences and streams from there,
17
17
  * - keyed lookups (`get` / `has`, Array index reads) decode one segment via
18
18
  * the fence index,
19
+ * - a key range of a Set or Dict (`range`) is a lazy value of its own, read
20
+ * through the same pager ({@link Beast2PagesView}): making it reads
21
+ * nothing, its size places its two ends, a keyed read tests its bounds
22
+ * first, and iterating it reads its segments, each once,
19
23
  *
20
24
  * and every other operation — mutation, set algebra — transparently
21
25
  * hydrates the container (the whole-decode that would have happened anyway)
@@ -1 +1 @@
1
- {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/lazy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAS/D,OAAO,EAAe,KAAK,kBAAkB,EAAuB,MAAM,aAAa,CAAC;AACxF,OAAO,EAAyB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAqE1D;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG;IACnD;;;;wEAIoE;IACpE,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB;;oDAEgD;IAChD,eAAe,EAAE,MAAM,CAAC;IACxB,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,QAAQ,EAAE,OAAO,CAAC;IAClB;;0CAEsC;IACtC,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AA4hBF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,GAAE,aAAa,GAAG,IAAW,GAAG,QAAQ,CAAC,CAAC,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H,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,aAAa,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,qBAAqB,GAAG,oBAAoB,KAAK,WAAW,CAAC,CAAC,CAAC,CA0BjM;AAiED,oDAAoD;AACpD,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;mEAG+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,aAAa,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CASzG"}
@@ -16,6 +16,10 @@
16
16
  * the owning segment through the fences and streams from there,
17
17
  * - keyed lookups (`get` / `has`, Array index reads) decode one segment via
18
18
  * the fence index,
19
+ * - a key range of a Set or Dict (`range`) is a lazy value of its own, read
20
+ * through the same pager ({@link Beast2PagesView}): making it reads
21
+ * nothing, its size places its two ends, a keyed read tests its bounds
22
+ * first, and iterating it reads its segments, each once,
19
23
  *
20
24
  * and every other operation — mutation, set algebra — transparently
21
25
  * hydrates the container (the whole-decode that would have happened anyway)
@@ -50,6 +54,7 @@ import { Beast2Pages } from "./stream.js";
50
54
  import { countPagedLoopSegment } from "./project.js";
51
55
  import {} from "./range.js";
52
56
  import {} from "./manifest.js";
57
+ import { Beast2PagesView } from "./view.js";
53
58
  /** The canonical-order violation error, in the eager decoders' words —
54
59
  * the same sentence on every runtime for the same blob. */
55
60
  function orderError(kind) {
@@ -117,8 +122,10 @@ const READ_WHOLE = Symbol("east.lazy.readWhole");
117
122
  * ({@link beast2LazyStats}). */
118
123
  const LAZY_STATS = Symbol("east.lazy.stats");
119
124
  /** A lazy value's account of its reads: its pager's, and what reading it
120
- * whole added — `undefined` until an operation the pager cannot serve has. */
121
- function statsOf(pages, wholeBytes) {
125
+ * whole added — `undefined` until an operation the pager cannot serve has. A
126
+ * range's reads are its source's pager's, and counted there. */
127
+ function statsOf(read, wholeBytes) {
128
+ const pages = read instanceof Beast2PagesView ? read.source : read;
122
129
  return {
123
130
  segments: pages.segmentCount,
124
131
  segmentsDecoded: pages.segmentsDecoded,
@@ -133,12 +140,14 @@ function grownSince(resident, before) {
133
140
  return resident === undefined ? 0 : Math.max(0, resident() - before);
134
141
  }
135
142
  /** Decodes segment `i` for a compiled loop, and counts it
136
- * ({@link countPagedLoopSegment}): by `projection` when the loop has one,
137
- * and by `whole` when it has none or the projected decode fails — as east-c's
138
- * paged loop retries one, so a back-reference that crosses the projection
139
- * decodes whole, and a corrupt segment fails in the whole decode's words. */
143
+ * ({@link countPagedLoopSegment}): by `projection` when the loop has one and
144
+ * the pager can decode the segment to it — a range's end segment it cannot,
145
+ * and says so, so none is attempted — and by `whole` otherwise or when the
146
+ * projected decode fails, as east-c's paged loop retries one, so a
147
+ * back-reference that crosses the projection decodes whole, and a corrupt
148
+ * segment fails in the whole decode's words. */
140
149
  function loopSegment(pages, i, projection, whole) {
141
- if (projection !== null) {
150
+ if (projection !== null && pages.projects(i)) {
142
151
  try {
143
152
  const segment = pages.segmentProjected(i, projection);
144
153
  countPagedLoopSegment(true);
@@ -232,8 +241,6 @@ class LazySortedMap extends SortedMap {
232
241
  get(key) {
233
242
  if (this.hydrated)
234
243
  return super.get(key);
235
- if (this.pages.elementCount === 0)
236
- return undefined;
237
244
  return served(() => this.pages.get(key));
238
245
  }
239
246
  has(key) {
@@ -320,6 +327,18 @@ class LazySortedMap extends SortedMap {
320
327
  }
321
328
  return super.entries(firstKey);
322
329
  }
330
+ /** A range of a map still read from its pager is a lazy map of its own,
331
+ * read through the same pager: a new collection, not frozen whatever this
332
+ * one is, whose entries decode as this one's do. It holds what the pager
333
+ * holds, so reading this map whole afterwards, or changing it, changes no
334
+ * range taken before. A map already read whole gives the range of what it
335
+ * holds now. */
336
+ range(from, to) {
337
+ if (this.hydrated)
338
+ return super.range(from, to);
339
+ const view = new Beast2PagesView(this.pages, from, to);
340
+ return new LazySortedMap(view, this.wire, this.cmp, false, this.resident);
341
+ }
323
342
  [Symbol.iterator]() {
324
343
  return this.entries();
325
344
  }
@@ -394,8 +413,6 @@ class LazySortedSet extends SortedSet {
394
413
  has(key) {
395
414
  if (this.hydrated)
396
415
  return super.has(key);
397
- if (this.pages.elementCount === 0)
398
- return false;
399
416
  return served(() => this.pages.get(key)) !== undefined;
400
417
  }
401
418
  add(key) {
@@ -448,6 +465,14 @@ class LazySortedSet extends SortedSet {
448
465
  this.hydrate();
449
466
  return super.symmetricDifference(other);
450
467
  }
468
+ /** A range of a set still read from its pager is a lazy set of its own,
469
+ * read through the same pager, as a lazy map's range is. */
470
+ range(from, to) {
471
+ if (this.hydrated)
472
+ return super.range(from, to);
473
+ const view = new Beast2PagesView(this.pages, from, to);
474
+ return new LazySortedSet(view, this.cmp, false, this.resident);
475
+ }
451
476
  isSubsetOf(other) {
452
477
  this.hydrate();
453
478
  return super.isSubsetOf(other);