@elaraai/e3 1.0.98 → 1.0.100
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 +4 -5
- package/dist/src/browser.d.ts +2 -0
- package/dist/src/browser.d.ts.map +1 -1
- package/dist/src/browser.js +6 -0
- package/dist/src/browser.js.map +1 -1
- package/dist/src/environment-capture.d.ts +21 -0
- package/dist/src/environment-capture.d.ts.map +1 -1
- package/dist/src/environment-capture.js +48 -0
- package/dist/src/environment-capture.js.map +1 -1
- package/dist/src/export.d.ts +10 -5
- package/dist/src/export.d.ts.map +1 -1
- package/dist/src/export.js +31 -47
- package/dist/src/export.js.map +1 -1
- package/dist/src/export.spec.js +27 -16
- package/dist/src/export.spec.js.map +1 -1
- package/dist/src/function.d.ts.map +1 -1
- package/dist/src/function.js.map +1 -1
- package/dist/src/functions-cache.d.ts +60 -0
- package/dist/src/functions-cache.d.ts.map +1 -0
- package/dist/src/functions-cache.js +165 -0
- package/dist/src/functions-cache.js.map +1 -0
- package/dist/src/functions-link.spec.js +191 -12
- package/dist/src/functions-link.spec.js.map +1 -1
- package/dist/src/functions-resolve.d.ts +52 -23
- package/dist/src/functions-resolve.d.ts.map +1 -1
- package/dist/src/functions-resolve.js +244 -96
- package/dist/src/functions-resolve.js.map +1 -1
- package/dist/src/index.d.ts +8 -61
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal.d.ts +53 -0
- package/dist/src/internal.d.ts.map +1 -0
- package/dist/src/internal.js +29 -0
- package/dist/src/internal.js.map +1 -0
- package/dist/src/lazy-build.d.ts +25 -0
- package/dist/src/lazy-build.d.ts.map +1 -0
- package/dist/src/lazy-build.js +56 -0
- package/dist/src/lazy-build.js.map +1 -0
- package/dist/src/lazy-build.spec.d.ts +6 -0
- package/dist/src/lazy-build.spec.d.ts.map +1 -0
- package/dist/src/lazy-build.spec.js +153 -0
- package/dist/src/lazy-build.spec.js.map +1 -0
- package/dist/src/migration.d.ts +20 -163
- package/dist/src/migration.d.ts.map +1 -1
- package/dist/src/migration.js +37 -34
- package/dist/src/migration.js.map +1 -1
- package/dist/src/migration.spec.js +83 -78
- package/dist/src/migration.spec.js.map +1 -1
- package/dist/src/mutation-programs.spec.js +211 -118
- package/dist/src/mutation-programs.spec.js.map +1 -1
- package/dist/src/mutation.d.ts +37 -141
- package/dist/src/mutation.d.ts.map +1 -1
- package/dist/src/mutation.js +66 -28
- package/dist/src/mutation.js.map +1 -1
- package/dist/src/open-beast-link.spec.js +1 -1
- package/dist/src/open-beast-link.spec.js.map +1 -1
- package/dist/src/output.js.map +1 -1
- package/dist/src/package.d.ts +2 -38
- package/dist/src/package.d.ts.map +1 -1
- package/dist/src/package.js +42 -175
- package/dist/src/package.js.map +1 -1
- package/dist/src/record-area.d.ts +49 -37
- package/dist/src/record-area.d.ts.map +1 -1
- package/dist/src/record-area.js +211 -131
- package/dist/src/record-area.js.map +1 -1
- package/dist/src/record-area.spec.js +79 -62
- package/dist/src/record-area.spec.js.map +1 -1
- package/dist/src/record-arguments.d.ts +55 -0
- package/dist/src/record-arguments.d.ts.map +1 -0
- package/dist/src/record-arguments.js +72 -0
- package/dist/src/record-arguments.js.map +1 -0
- package/dist/src/record-builders.d.ts +547 -0
- package/dist/src/record-builders.d.ts.map +1 -0
- package/dist/src/record-builders.js +112 -0
- package/dist/src/record-builders.js.map +1 -0
- package/dist/src/record-declared.spec.d.ts +6 -0
- package/dist/src/record-declared.spec.d.ts.map +1 -0
- package/dist/src/record-declared.spec.js +251 -0
- package/dist/src/record-declared.spec.js.map +1 -0
- package/dist/src/record-guards.d.ts +114 -1
- package/dist/src/record-guards.d.ts.map +1 -1
- package/dist/src/record-guards.js +153 -2
- package/dist/src/record-guards.js.map +1 -1
- package/dist/src/record-index.d.ts +128 -350
- package/dist/src/record-index.d.ts.map +1 -1
- package/dist/src/record-index.js +44 -481
- package/dist/src/record-index.js.map +1 -1
- package/dist/src/record-index.spec.js +124 -90
- package/dist/src/record-index.spec.js.map +1 -1
- package/dist/src/record-interval.d.ts +57 -36
- package/dist/src/record-interval.d.ts.map +1 -1
- package/dist/src/record-interval.js +136 -94
- package/dist/src/record-interval.js.map +1 -1
- package/dist/src/record-interval.spec.js +48 -27
- package/dist/src/record-interval.spec.js.map +1 -1
- package/dist/src/record-keys.d.ts +146 -0
- package/dist/src/record-keys.d.ts.map +1 -0
- package/dist/src/record-keys.js +178 -0
- package/dist/src/record-keys.js.map +1 -0
- package/dist/src/record-nested-programs.d.ts +1457 -0
- package/dist/src/record-nested-programs.d.ts.map +1 -0
- package/dist/src/record-nested-programs.js +1974 -0
- package/dist/src/record-nested-programs.js.map +1 -0
- package/dist/src/record-nested.d.ts +284 -0
- package/dist/src/record-nested.d.ts.map +1 -0
- package/dist/src/record-nested.js +304 -0
- package/dist/src/record-nested.js.map +1 -0
- package/dist/src/record-nested.spec.d.ts +6 -0
- package/dist/src/record-nested.spec.d.ts.map +1 -0
- package/dist/src/record-nested.spec.js +1032 -0
- package/dist/src/record-nested.spec.js.map +1 -0
- package/dist/src/record-patches.d.ts +25 -0
- package/dist/src/record-patches.d.ts.map +1 -0
- package/dist/src/record-patches.js +27 -0
- package/dist/src/record-patches.js.map +1 -0
- package/dist/src/record-programs.d.ts +192 -26
- package/dist/src/record-programs.d.ts.map +1 -1
- package/dist/src/record-programs.js +858 -350
- package/dist/src/record-programs.js.map +1 -1
- package/dist/src/record-programs.spec.d.ts +6 -0
- package/dist/src/record-programs.spec.d.ts.map +1 -0
- package/dist/src/record-programs.spec.js +242 -0
- package/dist/src/record-programs.spec.js.map +1 -0
- package/dist/src/record-series.d.ts +101 -97
- package/dist/src/record-series.d.ts.map +1 -1
- package/dist/src/record-series.js +198 -149
- package/dist/src/record-series.js.map +1 -1
- package/dist/src/record-series.spec.js +241 -120
- package/dist/src/record-series.spec.js.map +1 -1
- package/dist/src/record-tiles.d.ts +328 -37
- package/dist/src/record-tiles.d.ts.map +1 -1
- package/dist/src/record-tiles.js +289 -100
- package/dist/src/record-tiles.js.map +1 -1
- package/dist/src/record.d.ts +66 -12
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/record.js +103 -34
- package/dist/src/record.js.map +1 -1
- package/dist/src/record.spec.js +48 -63
- package/dist/src/record.spec.js.map +1 -1
- package/dist/src/task.d.ts.map +1 -1
- package/dist/src/task.js +4 -1
- package/dist/src/task.js.map +1 -1
- package/dist/src/types.d.ts +103 -37
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +7 -3
|
@@ -3,111 +3,153 @@
|
|
|
3
3
|
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
5
|
/** Centred interval-tree keys for ordinary maintained record indexes. */
|
|
6
|
-
import { DateTimeType, East,
|
|
6
|
+
import { DateTimeType, East, IntegerType, NullType, OptionType, SetType, StructType, none, some } from '@elaraai/east';
|
|
7
|
+
import { INDEX_PURITY, checkEntryParams, checkPure, indexRunner, indexedEntry, onlyOptions, signatureOf } from './record-guards.js';
|
|
8
|
+
import { checkLeading, checkTimeField, fieldReader, leadingValues } from './record-keys.js';
|
|
9
|
+
import { lazyBuilds } from './lazy-build.js';
|
|
7
10
|
/** The signed millisecond domain containing every valid JavaScript Date. */
|
|
8
11
|
const BIAS = 1n << 53n;
|
|
9
12
|
const LEAVES = 1n << 54n;
|
|
10
13
|
/** Internal millisecond key before the row's declared DateTime type is restored. */
|
|
11
14
|
export const IntervalEntryType = StructType({ node: IntegerType, at: IntegerType });
|
|
12
15
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
+
* An interval index's definition (`index.interval`): its key
|
|
17
|
+
* function, `{ on: { …on }, node, at }` an entry, filing each event under at
|
|
18
|
+
* most three entries a combination of its leading values — a Set among them
|
|
19
|
+
* fanning out — and the backlog's, with no start, under node 0. It stays an
|
|
20
|
+
* ordinary multi-entry index: mutation, rebuild, storage and transport are
|
|
21
|
+
* shared.
|
|
16
22
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
23
|
+
* @param constructor - The declaration, as a refusal names it
|
|
24
|
+
* @param name - The index
|
|
25
|
+
* @param rec - Its record
|
|
26
|
+
* @param spec - `from` and `to`, and the optional leading `on`
|
|
27
|
+
* @param config - Its runner selection
|
|
28
|
+
* @returns The definition
|
|
29
|
+
* @throws {Error} When a field is not of its option's type, when the start leads the index, or on any guard every index applies
|
|
23
30
|
*/
|
|
24
|
-
export
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
$.if(start.less(-BIAS).or(() => start.greaterEqual(BIAS)).or(() => end.less(-BIAS)).or(() => end.greaterEqual(BIAS)), ($) => {
|
|
28
|
-
$.error('Interval endpoints must be valid DateTime milliseconds');
|
|
29
|
-
});
|
|
30
|
-
// Instants and one-millisecond intervals cannot carry into another
|
|
31
|
-
// millisecond. A missing or non-positive end keeps instant semantics.
|
|
32
|
-
$.if(end.greater(start.add(1n)), ($) => {
|
|
33
|
-
const left = $.let(start.add(BIAS + LEAVES));
|
|
34
|
-
const right = $.let(end.subtract(1n).add(BIAS + LEAVES));
|
|
35
|
-
$.while(left.notEqual(right), ($) => {
|
|
36
|
-
$.assign(left, left.divide(2n));
|
|
37
|
-
$.assign(right, right.divide(2n));
|
|
38
|
-
});
|
|
39
|
-
$(entries.insert({ node: left.multiply(2n), at: start }));
|
|
40
|
-
$(entries.insert({ node: left.multiply(2n).add(1n), at: end }));
|
|
41
|
-
});
|
|
42
|
-
return entries;
|
|
43
|
-
});
|
|
44
|
-
/**
|
|
45
|
-
* Generate the pure key function, using the existing field-index function for
|
|
46
|
-
* all leading fields (including Set membership). This stays an ordinary
|
|
47
|
-
* multi-entry index: mutation, rebuild, storage and transport are shared.
|
|
48
|
-
* @param name - Index name for authoring errors.
|
|
49
|
-
* @param keyType - Primary key type.
|
|
50
|
-
* @param valueType - Record row type.
|
|
51
|
-
* @param on - Exact leading fields.
|
|
52
|
-
* @param interval - Start and end row fields.
|
|
53
|
-
* @param prefix - The standard generated field-index key function.
|
|
54
|
-
* @returns The generated keys and its fan-out flag.
|
|
55
|
-
*/
|
|
56
|
-
export function intervalKey(name, keyType, valueType, on, interval, prefix) {
|
|
31
|
+
export function intervalDefinition(constructor, name, rec, spec, config) {
|
|
32
|
+
const { keyType, valueType } = indexedEntry(constructor, name, rec);
|
|
33
|
+
onlyOptions(constructor, name, spec, ['on', 'from', 'to']);
|
|
57
34
|
if (valueType.type !== 'Struct')
|
|
58
|
-
throw new Error(
|
|
35
|
+
throw new Error(`${constructor} '${name}' indexes a record with Struct rows`);
|
|
59
36
|
const rowType = valueType;
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
throw new Error(`e3.recordIndex.interval '${name}' ${option} names '${field}', of type ${printType(type)}: ${option} is a DateTime or an Option<DateTime> field`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (on.includes(interval.from) || on.includes('__interval') || interval.from === '__interval') {
|
|
70
|
-
throw new Error(`e3.recordIndex.interval '${name}': its start '${interval.from}' and the reserved '__interval' cannot be leading fields`);
|
|
37
|
+
const start = checkTimeField(constructor, name, rowType, 'from', spec.from);
|
|
38
|
+
const end = checkTimeField(constructor, name, rowType, 'to', spec.to);
|
|
39
|
+
const on = spec.on ?? [];
|
|
40
|
+
// Led by its start and ordered by it again, the index would answer nothing the interval does not.
|
|
41
|
+
if (on.includes(spec.from)) {
|
|
42
|
+
throw new Error(`${constructor} '${name}': its start '${spec.from}' cannot be a leading field — the index orders by it already`);
|
|
71
43
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
$.match(start, { some: ($, from) => {
|
|
86
|
-
const to = $.let(end.match({ some: (_$, to) => to, none: () => from }));
|
|
87
|
-
$.assign(entries, locate(from.toEpochMilliseconds(), to.toEpochMilliseconds()));
|
|
88
|
-
} });
|
|
89
|
-
const keys = $.let(new Set(), SetType(indexType));
|
|
90
|
-
const append = ($, values) => {
|
|
91
|
-
const leading = Object.fromEntries(on.map(field => [field, on.length === 1 ? values : values[field]]));
|
|
92
|
-
$.for(entries, ($, entry) => {
|
|
93
|
-
const date = $.let(East.DateTime.fromEpochMilliseconds(entry.at));
|
|
94
|
-
const at = startType.type === 'DateTime' ? date
|
|
95
|
-
: start.match({ some: () => some(date), none: () => none });
|
|
96
|
-
$(keys.insert({ ...leading, __interval: entry.node, [interval.from]: at }));
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
if (prefix === undefined)
|
|
100
|
-
append($, undefined);
|
|
101
|
-
else {
|
|
102
|
-
const make = $.const(prefix.fn);
|
|
103
|
-
const values = $.let(make(key, row), prefixType.output);
|
|
104
|
-
if (prefix.multi)
|
|
105
|
-
$.for(values, ($, value) => append($, value));
|
|
106
|
-
else
|
|
107
|
-
append($, values);
|
|
108
|
-
}
|
|
109
|
-
return keys;
|
|
44
|
+
const leading = checkLeading(constructor, name, rowType, on);
|
|
45
|
+
// The row's leading fields under `on`, and e3's own parts beside them (#1432): the tree node an entry is filed at,
|
|
46
|
+
// and the instant it is ordered by, at the start field's type.
|
|
47
|
+
const indexType = StructType({ on: leading.onType, node: IntegerType, at: rowType.fields[spec.from] });
|
|
48
|
+
const readStart = fieldReader(keyType, rowType, { option: start });
|
|
49
|
+
const readEnd = fieldReader(keyType, rowType, { option: end });
|
|
50
|
+
const leads = leadingValues(keyType, rowType, leading);
|
|
51
|
+
// An entry's instant at the start field's type.
|
|
52
|
+
const instant = start.optional ? INTERVAL_FNS.optionInstantAt : INTERVAL_FNS.instantAt;
|
|
53
|
+
// An event's entries under one combination of its leading values.
|
|
54
|
+
const entriesUnder = East.function([leading.onType, OptionType(DateTimeType), SetType(IntervalEntryType)], SetType(indexType), ($, on, from, entries) => {
|
|
55
|
+
const at = $.const(instant);
|
|
56
|
+
return entries.toSet((_$, entry) => ({ on, node: entry.node, at: at(from, entry.at) }));
|
|
110
57
|
});
|
|
111
|
-
|
|
58
|
+
const keyFn = East.function([keyType, rowType], SetType(indexType), ($, key, row) => {
|
|
59
|
+
const startOf = $.const(readStart);
|
|
60
|
+
const endOf = $.const(readEnd);
|
|
61
|
+
const locate = $.const(INTERVAL_FNS.eventEntries);
|
|
62
|
+
const combinations = $.const(leads);
|
|
63
|
+
const under = $.const(entriesUnder);
|
|
64
|
+
const from = $.let(startOf(key, row));
|
|
65
|
+
const entries = $.let(locate(from, endOf(key, row)));
|
|
66
|
+
return combinations(key, row).flattenToSet((_$, on) => under(on, from, entries));
|
|
67
|
+
});
|
|
68
|
+
const runner = indexRunner(config);
|
|
69
|
+
checkPure(`${constructor} '${name}' 'keys' function`, keyFn, INDEX_PURITY);
|
|
70
|
+
checkEntryParams(constructor, name, "'keys' function", keyType, valueType, signatureOf(keyFn).inputs);
|
|
71
|
+
return {
|
|
72
|
+
kind: 'recordIndex',
|
|
73
|
+
name,
|
|
74
|
+
record: rec,
|
|
75
|
+
on: Object.freeze([...on]),
|
|
76
|
+
interval: Object.freeze({ from: spec.from, to: spec.to }),
|
|
77
|
+
keyFn,
|
|
78
|
+
multi: true,
|
|
79
|
+
keyType: indexType,
|
|
80
|
+
valueType: NullType,
|
|
81
|
+
runner,
|
|
82
|
+
};
|
|
112
83
|
}
|
|
84
|
+
// ── The functions, each built the first time it is read ──────────────────────
|
|
85
|
+
/**
|
|
86
|
+
* The interval index's East functions, each built the first time it is read,
|
|
87
|
+
* with no location captured ({@link lazyBuilds}, #1466): importing the SDK
|
|
88
|
+
* builds none of them.
|
|
89
|
+
*/
|
|
90
|
+
export const INTERVAL_FNS = lazyBuilds({
|
|
91
|
+
/**
|
|
92
|
+
* Node zero stores the start. A positive-duration event is stored at the
|
|
93
|
+
* lowest common ancestor of its first and last included milliseconds, once
|
|
94
|
+
* ordered by start (even node code), once by end (odd node code).
|
|
95
|
+
*
|
|
96
|
+
* Every interval at a node crosses its centre. A carry-in query walks the
|
|
97
|
+
* ancestors of its lower bound: to the left of a centre it needs start < from;
|
|
98
|
+
* to the right it needs end > from. Each event lives at just one ancestor,
|
|
99
|
+
* and these carry-in results are disjoint from starts inside the window.
|
|
100
|
+
* At most 54 iterations and THREE entries, independent of event duration.
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
get intervalEntries() {
|
|
104
|
+
return East.function([IntegerType, IntegerType], SetType(IntervalEntryType), ($, start, end) => {
|
|
105
|
+
$.if(start.less(-BIAS).or(() => start.greaterEqual(BIAS)).or(() => end.less(-BIAS)).or(() => end.greaterEqual(BIAS)), ($) => {
|
|
106
|
+
$.error('Interval endpoints must be valid DateTime milliseconds');
|
|
107
|
+
});
|
|
108
|
+
// Instants and one-millisecond intervals cannot carry into another
|
|
109
|
+
// millisecond. A missing or non-positive end keeps instant semantics.
|
|
110
|
+
$.if(end.lessEqual(start.add(1n)), ($) => {
|
|
111
|
+
$.return(new Set([{ node: 0n, at: start }]));
|
|
112
|
+
});
|
|
113
|
+
const left = $.let(start.add(BIAS + LEAVES));
|
|
114
|
+
const right = $.let(end.subtract(1n).add(BIAS + LEAVES));
|
|
115
|
+
$.while(left.notEqual(right), ($) => {
|
|
116
|
+
$.assign(left, left.divide(2n));
|
|
117
|
+
$.assign(right, right.divide(2n));
|
|
118
|
+
});
|
|
119
|
+
return new Set([{ node: 0n, at: start }, { node: left.multiply(2n), at: start }, { node: left.multiply(2n).add(1n), at: end }]);
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
/**
|
|
123
|
+
* The entries an event is filed under (`intervalEntries`): with no start, the
|
|
124
|
+
* backlog's one, at node 0; with no end, an instant's.
|
|
125
|
+
*
|
|
126
|
+
* `(start, end) → Set<{ node, at }>`
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
get eventEntries() {
|
|
130
|
+
return East.function([OptionType(DateTimeType), OptionType(DateTimeType)], SetType(IntervalEntryType), ($, start, end) => {
|
|
131
|
+
const locate = $.const(INTERVAL_FNS.intervalEntries);
|
|
132
|
+
$.match(start, {
|
|
133
|
+
some: ($, from) => { $.return(locate(from.toEpochMilliseconds(), end.unwrap('some', () => from).toEpochMilliseconds())); },
|
|
134
|
+
none: () => { },
|
|
135
|
+
});
|
|
136
|
+
// No start: the backlog's one entry, at node 0.
|
|
137
|
+
return new Set([{ node: 0n, at: 0n }]);
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
/** `(start, at) → an entry's instant`, at a DateTime start's type. */
|
|
141
|
+
get instantAt() {
|
|
142
|
+
return East.function([OptionType(DateTimeType), IntegerType], DateTimeType, (_$, _start, at) => East.DateTime.fromEpochMilliseconds(at));
|
|
143
|
+
},
|
|
144
|
+
/** `(start, at) → an entry's instant`, at an Option<DateTime> start's type: `none` for the backlog's, an event with no start. */
|
|
145
|
+
get optionInstantAt() {
|
|
146
|
+
return East.function([OptionType(DateTimeType), IntegerType], OptionType(DateTimeType), ($, start, at) => {
|
|
147
|
+
$.match(start, {
|
|
148
|
+
some: ($) => { $.return(some(East.DateTime.fromEpochMilliseconds(at))); },
|
|
149
|
+
none: () => { },
|
|
150
|
+
});
|
|
151
|
+
return none;
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
});
|
|
113
155
|
//# sourceMappingURL=record-interval.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-interval.js","sourceRoot":"","sources":["../../src/record-interval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,yEAAyE;AACzE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"record-interval.js","sourceRoot":"","sources":["../../src/record-interval.ts"],"names":[],"mappings":"AAAA;;;G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AE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3I,CAAC;IACD,iIAAiI;IACjI,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;YACvG,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE;gBACb,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzE,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;aACf,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -6,9 +6,9 @@ import { test } from 'node:test';
|
|
|
6
6
|
import assert from 'node:assert/strict';
|
|
7
7
|
import { DateTimeType, DictType, East, IntegerType, OptionType, SetType, StringType, StructType, decodeBeast2For, encodeBeast2For, none, some } from '@elaraai/east';
|
|
8
8
|
import { record } from './record.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
const entriesOf = East.compile(intervalEntries, []);
|
|
9
|
+
import { INTERVAL_FNS, IntervalEntryType } from './record-interval.js';
|
|
10
|
+
import { functionAt } from './record-guards.js';
|
|
11
|
+
const entriesOf = East.compile(INTERVAL_FNS.intervalEntries, []);
|
|
12
12
|
const leaf = 3n * (1n << 53n);
|
|
13
13
|
// Compare real, decoded generated keys against the direct interval oracle.
|
|
14
14
|
// Include the full supported domain, carry-in, epoch crossing and instants.
|
|
@@ -41,51 +41,72 @@ test('interval index preserves half-open overlap with at most three entries', ()
|
|
|
41
41
|
});
|
|
42
42
|
test('interval indexes retain declared fields, optional backlog and Set-member prefixes through real East IR', () => {
|
|
43
43
|
const Row = StructType({ resources: SetType(StringType), start: OptionType(DateTimeType), end: OptionType(DateTimeType) });
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
44
|
+
const Rows = DictType(StringType, Row);
|
|
45
|
+
const records = record('interval_events', Rows, {
|
|
46
|
+
initial: new Map(),
|
|
47
|
+
indexes: (index) => ({
|
|
48
|
+
by_resource_time: index.interval({ on: ['resources'], from: 'start', to: 'end' }),
|
|
49
|
+
by_time: index.interval({ from: 'start', to: 'end' }),
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
const index = records.indexes.by_resource_time;
|
|
53
|
+
// Its definition is led by its row fields alone; its own parts are the key's `node` and `at` (#1432).
|
|
54
|
+
assert.deepEqual(index.on, ['resources']);
|
|
47
55
|
assert.deepEqual(index.interval, { from: 'start', to: 'end' });
|
|
48
56
|
assert.equal(index.multi, true);
|
|
49
|
-
const fn = East.compile(index.keyFn, []);
|
|
57
|
+
const fn = East.compile(functionAt(index.keyFn, [StringType, Row], SetType(index.keyType)), []);
|
|
50
58
|
const start = new Date('2026-10-01T22:00:00Z');
|
|
51
59
|
const end = new Date('2026-10-03T06:00:00Z');
|
|
52
60
|
const decode = decodeBeast2For(Row);
|
|
53
61
|
const encode = encodeBeast2For(Row);
|
|
54
62
|
const scheduled = fn('night', decode(encode({ resources: new Set(['A', 'B']), start: some(start), end: some(end) })));
|
|
55
|
-
assert.equal([...scheduled].filter(key => key.
|
|
63
|
+
assert.equal([...scheduled].filter(key => key.node === 0n).length, 2);
|
|
56
64
|
assert.equal(scheduled.size, 6);
|
|
57
65
|
const from = BigInt(new Date('2026-10-02T00:00:00Z').getTime());
|
|
58
66
|
for (const resource of ['A', 'B']) {
|
|
59
67
|
let hits = 0;
|
|
60
68
|
for (let child = leaf + from; child > 1n; child /= 2n) {
|
|
61
69
|
const right = child % 2n === 1n;
|
|
62
|
-
hits += [...scheduled].filter(key => key.resources === resource && key.
|
|
63
|
-
&& key.
|
|
70
|
+
hits += [...scheduled].filter(key => key.on.resources === resource && key.node === 2n * (child / 2n) + (right ? 1n : 0n)
|
|
71
|
+
&& key.at.type === 'some' && (right ? BigInt(key.at.value.getTime()) > from : BigInt(key.at.value.getTime()) < from)).length;
|
|
64
72
|
}
|
|
65
73
|
assert.equal(hits, 1);
|
|
66
74
|
}
|
|
67
75
|
const backlog = fn('backlog', decode(encode({ resources: new Set(['A']), start: none, end: none })));
|
|
68
|
-
assert.deepEqual([...backlog], [{ resources: 'A',
|
|
69
|
-
const simple =
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
assert.deepEqual([...backlog], [{ on: { resources: 'A' }, node: 0n, at: none }]);
|
|
77
|
+
const simple = records.indexes.by_time;
|
|
78
|
+
// Led by no field: `on` is there, with none (#1432).
|
|
79
|
+
assert.deepEqual(simple.on, []);
|
|
80
|
+
const simpleFn = East.compile(functionAt(simple.keyFn, [StringType, Row], SetType(simple.keyType)), []);
|
|
72
81
|
assert.equal(simpleFn('instant', { resources: new Set(), start: some(start), end: none }).size, 1);
|
|
73
|
-
assert.throws(() =>
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
assert.throws(() => record('interval_events', Rows, {
|
|
83
|
+
indexes: (index) => ({
|
|
84
|
+
bad_interval: index.interval({
|
|
85
|
+
// @ts-expect-error Only DateTime fields are interval endpoints.
|
|
86
|
+
from: 'resources', to: 'end',
|
|
87
|
+
}),
|
|
88
|
+
}),
|
|
76
89
|
}), /from names 'resources', of type .+: from is a DateTime or an Option<DateTime> field/);
|
|
77
|
-
assert.throws(() =>
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
assert.throws(() => record('interval_events', Rows, {
|
|
91
|
+
indexes: (index) => ({
|
|
92
|
+
bad_end: index.interval({
|
|
93
|
+
// @ts-expect-error Only DateTime fields are interval endpoints.
|
|
94
|
+
from: 'start', to: 'missing',
|
|
95
|
+
}),
|
|
96
|
+
}),
|
|
80
97
|
}), /to names unknown row field 'missing'/);
|
|
81
|
-
assert.throws(() =>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
98
|
+
assert.throws(() => record('interval_events', Rows, {
|
|
99
|
+
indexes: (index) => ({
|
|
100
|
+
valued: index.interval({
|
|
101
|
+
from: 'start', to: 'end',
|
|
102
|
+
// @ts-expect-error An interval index carries no projection.
|
|
103
|
+
value: East.function([StringType, Row], StringType, ($, k, _v) => k),
|
|
104
|
+
}),
|
|
105
|
+
}),
|
|
85
106
|
}), /takes on, from, to, not value/);
|
|
86
|
-
const on = ['resources'
|
|
87
|
-
const key = StructType({ resources: StringType,
|
|
88
|
-
assert.ok(on.length ===
|
|
107
|
+
const on = ['resources'];
|
|
108
|
+
const key = StructType({ on: StructType({ resources: StringType }), node: IntegerType, at: OptionType(DateTimeType) });
|
|
109
|
+
assert.ok(on.length === 1 && key.type === 'Struct');
|
|
89
110
|
const declared = index.keyType;
|
|
90
111
|
assert.equal(declared.type, 'Struct');
|
|
91
112
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-interval.spec.js","sourceRoot":"","sources":["../../src/record-interval.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAC7F,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"record-interval.spec.js","sourceRoot":"","sources":["../../src/record-interval.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EA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,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
* Reading a record's row by the names a declaration gives.
|
|
7
|
+
*
|
|
8
|
+
* East names a struct's fields where its code is written; a generated index
|
|
9
|
+
* reads the fields its declaration names — its leading fields, an event's
|
|
10
|
+
* start and end, a box's place — which it holds as values. So every generated
|
|
11
|
+
* program reads its row through East's own builders for names held as values
|
|
12
|
+
* (`East.field`, `East.fields`, `East.struct`), which check each name against
|
|
13
|
+
* the row's type as the program is built: a reader a field, the leading
|
|
14
|
+
* values as the key's `on`, and their combinations where a Set field fans a
|
|
15
|
+
* row out.
|
|
16
|
+
*
|
|
17
|
+
* @packageDocumentation
|
|
18
|
+
*/
|
|
19
|
+
import { DateTimeType, OptionType, SetType, StructType, type EastType, type FunctionExpr } from '@elaraai/east';
|
|
20
|
+
/** A record's Struct row type, its fields named at run time. */
|
|
21
|
+
export type RowType = StructType<Record<string, EastType>>;
|
|
22
|
+
/** One leading field: its name, its type in the key (a Set field's element), and whether it fans a row out. */
|
|
23
|
+
export interface LeadingField {
|
|
24
|
+
readonly field: string;
|
|
25
|
+
readonly type: EastType;
|
|
26
|
+
readonly set: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** An index's leading fields, checked: each field, the key's `on` struct, and whether a Set among them fans a row out. */
|
|
29
|
+
export interface Leading {
|
|
30
|
+
readonly fields: readonly LeadingField[];
|
|
31
|
+
readonly onType: RowType;
|
|
32
|
+
readonly multi: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Checks an index's leading fields against the record's row.
|
|
36
|
+
*
|
|
37
|
+
* @param constructor - The declaration, for the refusals
|
|
38
|
+
* @param name - The index, for the refusals
|
|
39
|
+
* @param rowType - The record's row type
|
|
40
|
+
* @param on - The leading fields, in key order; none for an index led by none
|
|
41
|
+
* @returns The fields, the key's `on`, and whether a row fans out
|
|
42
|
+
* @throws {Error} When a field is named twice, or is not one of the row's
|
|
43
|
+
*/
|
|
44
|
+
export declare function checkLeading(constructor: string, name: string, rowType: RowType, on: readonly string[]): Leading;
|
|
45
|
+
/**
|
|
46
|
+
* A field read as an Option: its name, whether the row holds an Option of it —
|
|
47
|
+
* which a row may leave `none` — or the value itself, and the type inside.
|
|
48
|
+
*
|
|
49
|
+
* @typeParam T - The type inside the Option
|
|
50
|
+
*/
|
|
51
|
+
export interface OptionField<T extends EastType = EastType> {
|
|
52
|
+
readonly field: string;
|
|
53
|
+
readonly optional: boolean;
|
|
54
|
+
readonly type: T;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks a field read as an Option of a type: the type itself, or an Option of
|
|
58
|
+
* it.
|
|
59
|
+
*
|
|
60
|
+
* @param rowType - The record's row type
|
|
61
|
+
* @param field - The field
|
|
62
|
+
* @param type - The type inside the Option
|
|
63
|
+
* @returns The field, and whether it is an Option; `undefined` for a field of another type, or none
|
|
64
|
+
*/
|
|
65
|
+
export declare function optionField<T extends EastType>(rowType: RowType, field: string, type: T): OptionField<T> | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Checks a field an event starts or ends at: a DateTime, or an Option of one.
|
|
68
|
+
*
|
|
69
|
+
* @param constructor - The constructor, as a refusal names it
|
|
70
|
+
* @param name - The index
|
|
71
|
+
* @param rowType - The record's row type
|
|
72
|
+
* @param option - The option naming the field, as a refusal names it
|
|
73
|
+
* @param field - The field
|
|
74
|
+
* @returns The field, and whether it is an Option
|
|
75
|
+
* @throws {Error} When the row has no such field, or it is of another type, naming the option, the field and its type
|
|
76
|
+
*/
|
|
77
|
+
export declare function checkTimeField(constructor: string, name: string, rowType: RowType, option: string, field: string): OptionField<DateTimeType>;
|
|
78
|
+
/**
|
|
79
|
+
* A reader of a row's field, as an index reads it: `(K, V) → T`, the field as
|
|
80
|
+
* it is — East reads it by its name, checked against the row's type as the
|
|
81
|
+
* program is built.
|
|
82
|
+
*
|
|
83
|
+
* @param keyType - The record's key type
|
|
84
|
+
* @param rowType - The record's row type
|
|
85
|
+
* @param read - The field and its type
|
|
86
|
+
* @returns The reader
|
|
87
|
+
*/
|
|
88
|
+
export declare function fieldReader<T extends EastType>(keyType: EastType, rowType: RowType, read: {
|
|
89
|
+
readonly field: string;
|
|
90
|
+
readonly type: T;
|
|
91
|
+
}): FunctionExpr<[EastType, RowType], T>;
|
|
92
|
+
/**
|
|
93
|
+
* A reader of a row's field as an Option, as an index reads an event's times
|
|
94
|
+
* and a box's place: `(K, V) → Option<T>`, a field holding an Option as it
|
|
95
|
+
* is, and one holding the value itself as its `some`.
|
|
96
|
+
*
|
|
97
|
+
* @param keyType - The record's key type
|
|
98
|
+
* @param rowType - The record's row type
|
|
99
|
+
* @param read - The field, checked to be a `T` or an Option of one ({@link optionField})
|
|
100
|
+
* @returns The reader
|
|
101
|
+
*/
|
|
102
|
+
export declare function fieldReader<T extends EastType>(keyType: EastType, rowType: RowType, read: {
|
|
103
|
+
readonly option: OptionField<T>;
|
|
104
|
+
}): FunctionExpr<[EastType, RowType], OptionType<T>>;
|
|
105
|
+
/**
|
|
106
|
+
* A row's leading values where no Set among them fans it out: `(K, V) -> On`,
|
|
107
|
+
* its leading fields' values as the key's `on` — the empty struct where none
|
|
108
|
+
* lead.
|
|
109
|
+
*
|
|
110
|
+
* @param keyType - The record's key type
|
|
111
|
+
* @param rowType - The record's row type
|
|
112
|
+
* @param leading - The checked leading fields, no Set among them
|
|
113
|
+
* @returns The function
|
|
114
|
+
* @throws {Error} When a Set field leads: its row has a combination per element ({@link leadingValues})
|
|
115
|
+
*/
|
|
116
|
+
export declare function leadingValue(keyType: EastType, rowType: RowType, leading: Leading): FunctionExpr<[EastType, RowType], RowType>;
|
|
117
|
+
/**
|
|
118
|
+
* A row's leading values: `(K, V) -> Set<On>`, every combination of its
|
|
119
|
+
* leading fields' values as the key's `on` — each Set field fanned out over
|
|
120
|
+
* its elements — and the one combination where no Set leads, the empty struct
|
|
121
|
+
* where none do.
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* The leading fields are read as one struct, each Set field still a Set; then
|
|
125
|
+
* each Set field in turn is fanned out over its elements, a step each, each
|
|
126
|
+
* step calling the one before it — so the combinations are built by ordinary
|
|
127
|
+
* East, whatever the fields.
|
|
128
|
+
*
|
|
129
|
+
* @param keyType - The record's key type
|
|
130
|
+
* @param rowType - The record's row type
|
|
131
|
+
* @param leading - The checked leading fields
|
|
132
|
+
* @returns The function
|
|
133
|
+
*/
|
|
134
|
+
export declare function leadingValues(keyType: EastType, rowType: RowType, leading: Leading): FunctionExpr<[EastType, RowType], SetType<RowType>>;
|
|
135
|
+
/**
|
|
136
|
+
* A plain index's key, `on` its row fields: `(K, V) -> IK` — the one field's
|
|
137
|
+
* value, or a struct of several — or `(K, V) -> Set<IK>` where a Set among
|
|
138
|
+
* them fans a row out: the one field's elements, or the struct's combinations.
|
|
139
|
+
*
|
|
140
|
+
* @param keyType - The record's key type
|
|
141
|
+
* @param rowType - The record's row type
|
|
142
|
+
* @param leading - The checked fields
|
|
143
|
+
* @returns The key function
|
|
144
|
+
*/
|
|
145
|
+
export declare function fieldKeyOf(keyType: EastType, rowType: RowType, leading: Leading): FunctionExpr<[EastType, RowType], EastType>;
|
|
146
|
+
//# sourceMappingURL=record-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-keys.d.ts","sourceRoot":"","sources":["../../src/record-keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AACH,OAAO,EACM,YAAY,EAAQ,UAAU,EAAE,OAAO,EAAE,UAAU,EAC9D,KAAK,QAAQ,EAAE,KAAK,YAAY,EACjC,MAAM,eAAe,CAAC;AAGv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