@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
package/dist/src/package.js
CHANGED
|
@@ -5,45 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Package definitions for e3.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import { nameProblem } from '@elaraai/e3-types';
|
|
10
|
-
import { sameEastType } from './record-guards.js';
|
|
11
|
-
/**
|
|
12
|
-
* Creates a package definition from items.
|
|
13
|
-
*
|
|
14
|
-
* Automatically collects all dependencies from the provided items.
|
|
15
|
-
* You only need to pass the "top-level" items - all inputs, intermediate
|
|
16
|
-
* tasks, and datasets they depend on are included automatically.
|
|
17
|
-
*
|
|
18
|
-
* Organizes items into a discoverable structure:
|
|
19
|
-
* - `pkg.datasets.inputs.*` - Input datasets
|
|
20
|
-
* - `pkg.datasets.outputs.*` - Output datasets
|
|
21
|
-
* - `pkg.tasks.*` - Tasks
|
|
22
|
-
*
|
|
23
|
-
* @param name - Package name
|
|
24
|
-
* @param version - Package version
|
|
25
|
-
* @param items - Items to include (datasets, tasks)
|
|
26
|
-
* @returns A PackageDef with typed access to contents
|
|
27
|
-
* @throws {Error} When the name or the version cannot be a file name — a
|
|
28
|
-
* repository keeps the package at `packages/<name>/<version>` — when a
|
|
29
|
-
* record is given two different mutations, indexes or migrations of one
|
|
30
|
-
* name, or when a record's migrations are not one chain that leaves it as
|
|
31
|
-
* its declared type
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* const input_name = e3.input('name', StringType, variant('value', 'World'));
|
|
36
|
-
* const say_hello = e3.task('say_hello', [input_name], ...);
|
|
37
|
-
*
|
|
38
|
-
* // Only need to pass the final task - input_name is included automatically
|
|
39
|
-
* const pkg = e3.package('hello_world', '1.0.0', say_hello);
|
|
40
|
-
*
|
|
41
|
-
* // Typed access to contents
|
|
42
|
-
* const nameInput = pkg.datasets.inputs.name;
|
|
43
|
-
* const helloOutput = pkg.datasets.outputs.say_hello;
|
|
44
|
-
* const helloTask = pkg.tasks.say_hello;
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
8
|
+
import { nameProblem, pathToString } from '@elaraai/e3-types';
|
|
47
9
|
// NOTE: the return is deliberately `PackageDef<Record<string, unknown>>`, NOT
|
|
48
10
|
// `PackageDef<MergeDatasets<TItems>>`. The precise merged-datasets map (used only
|
|
49
11
|
// for the optional `pkg.datasets.tasks.x.output` typed-access convenience) inlines
|
|
@@ -63,16 +25,8 @@ export function package_(name, version, ...items) {
|
|
|
63
25
|
// Functions have no deps and never enter the data tree — collected by
|
|
64
26
|
// name, separately from all_items.
|
|
65
27
|
const functions = {};
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
// ride `all_items` and only need a separate RecordObject channel.
|
|
69
|
-
const mutationsByRecord = new Map();
|
|
70
|
-
// Indexes are collected onto their record the same way, and for the same
|
|
71
|
-
// reason: an index is declared beside the record and belongs to it.
|
|
72
|
-
const indexesByRecord = new Map();
|
|
73
|
-
// Migrations are collected onto their record too, each with the steps before
|
|
74
|
-
// it, which its `after` names: passing a chain's last step passes the chain.
|
|
75
|
-
const migrationsByRecord = new Map();
|
|
28
|
+
// Records are datasets, so they ride `all_items`, each whole with its parts;
|
|
29
|
+
// an imported package's records arrive here as well.
|
|
76
30
|
const importedRecords = {};
|
|
77
31
|
function collect(item) {
|
|
78
32
|
if (visited.has(item))
|
|
@@ -96,160 +50,73 @@ export function package_(name, version, ...items) {
|
|
|
96
50
|
else if (item.kind === "function") {
|
|
97
51
|
functions[item.name] = item;
|
|
98
52
|
}
|
|
99
|
-
else if (item.kind === "mutation") {
|
|
100
|
-
// Pull in the owning record's dataset and register the mutation onto it.
|
|
101
|
-
collect(item.record);
|
|
102
|
-
mutationsByRecord.set(item.record.name, [...(mutationsByRecord.get(item.record.name) ?? []), item]);
|
|
103
|
-
}
|
|
104
|
-
else if (item.kind === "recordIndex") {
|
|
105
|
-
collect(item.record);
|
|
106
|
-
indexesByRecord.set(item.record.name, [...(indexesByRecord.get(item.record.name) ?? []), item]);
|
|
107
|
-
}
|
|
108
|
-
else if (item.kind === "migration") {
|
|
109
|
-
collect(item.record);
|
|
110
|
-
const steps = migrationsByRecord.get(item.record.name) ?? [];
|
|
111
|
-
for (let step = item; step !== undefined; step = step.after)
|
|
112
|
-
steps.push(step);
|
|
113
|
-
migrationsByRecord.set(item.record.name, steps);
|
|
114
|
-
}
|
|
115
53
|
else {
|
|
54
|
+
refusePart(name, item);
|
|
116
55
|
collect(item);
|
|
117
56
|
}
|
|
118
57
|
}
|
|
58
|
+
// The package's datasets as a tree, each under its path's names; each tree
|
|
59
|
+
// kept by its path too, the root's ''.
|
|
119
60
|
const datasets = {};
|
|
61
|
+
const trees = new Map([['', datasets]]);
|
|
120
62
|
const tasks = {};
|
|
121
|
-
// all_items is in topological order by construction
|
|
63
|
+
// all_items is in topological order by construction: a tree before what it holds
|
|
122
64
|
for (const item of all_items) {
|
|
123
|
-
if (item.kind === 'datatree') {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
current = current[segment.value];
|
|
129
|
-
if (current === undefined) {
|
|
130
|
-
throw new Error(`Parent tree not found in package(): ${segment.value}`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
throw new Error(`Unsupported path segment type in package(): ${segment.type}`);
|
|
135
|
-
}
|
|
65
|
+
if (item.kind === 'datatree' || item.kind === 'dataset') {
|
|
66
|
+
const parentPath = pathToString(item.path.slice(0, -1));
|
|
67
|
+
const parent = trees.get(parentPath);
|
|
68
|
+
if (parent === undefined) {
|
|
69
|
+
throw new Error(`Parent tree not found in package(): '${parentPath}'`);
|
|
136
70
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
current = current[segment.value];
|
|
146
|
-
if (current === undefined) {
|
|
147
|
-
throw new Error(`Parent tree not found in package(): ${segment.value}`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
throw new Error(`Unsupported path segment type in package(): ${segment.type}`);
|
|
152
|
-
}
|
|
71
|
+
if (item.kind === 'datatree') {
|
|
72
|
+
// the only tree type is struct for now
|
|
73
|
+
const tree = {};
|
|
74
|
+
parent[item.name] = tree;
|
|
75
|
+
trees.set(pathToString(item.path), tree);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
parent[item.name] = item;
|
|
153
79
|
}
|
|
154
|
-
current[item.name] = item;
|
|
155
80
|
}
|
|
156
81
|
else if (item.kind === 'task') {
|
|
157
82
|
// TODO - check task inputs and output exist with correct types?
|
|
158
83
|
tasks[item.name] = item;
|
|
159
84
|
}
|
|
160
85
|
}
|
|
161
|
-
//
|
|
162
|
-
// two different indexes, under one name, the record would keep whichever
|
|
163
|
-
// came last.
|
|
164
|
-
const byName = (record, kind, defs) => {
|
|
165
|
-
const named = {};
|
|
166
|
-
for (const def of defs) {
|
|
167
|
-
const taken = named[def.name];
|
|
168
|
-
if (taken !== undefined && taken !== def) {
|
|
169
|
-
throw new Error(`e3.package '${name}': record '${record}' declares two ${kind} named '${def.name}' — pass each declaration once`);
|
|
170
|
-
}
|
|
171
|
-
named[def.name] = def;
|
|
172
|
-
}
|
|
173
|
-
return named;
|
|
174
|
-
};
|
|
175
|
-
// A record's migrations in the order they run. They are one chain: exactly
|
|
176
|
-
// one step has no `after`, no two name the same one, and the last leaves the
|
|
177
|
-
// record as it is declared, since a deploy leaves a migrated record at the
|
|
178
|
-
// package's type.
|
|
179
|
-
const chainOf = (rec, steps) => {
|
|
180
|
-
const all = Object.values(byName(rec.name, 'migrations', steps));
|
|
181
|
-
if (all.length === 0)
|
|
182
|
-
return [];
|
|
183
|
-
const where = `e3.package '${name}': record '${rec.name}'`;
|
|
184
|
-
const firsts = all.filter((step) => step.after === undefined);
|
|
185
|
-
if (firsts.length !== 1) {
|
|
186
|
-
throw new Error(`${where} has ${firsts.length} migrations with no 'after' (${firsts.map((step) => `'${step.name}'`).join(', ')}) — ` +
|
|
187
|
-
`its migrations are one chain, and only the first step names none`);
|
|
188
|
-
}
|
|
189
|
-
const next = new Map();
|
|
190
|
-
for (const step of all) {
|
|
191
|
-
if (step.after === undefined)
|
|
192
|
-
continue;
|
|
193
|
-
const taken = next.get(step.after.name);
|
|
194
|
-
if (taken !== undefined) {
|
|
195
|
-
throw new Error(`${where} has two migrations after '${step.after.name}', '${taken.name}' and '${step.name}' — ` +
|
|
196
|
-
`its migrations are one chain`);
|
|
197
|
-
}
|
|
198
|
-
next.set(step.after.name, step);
|
|
199
|
-
}
|
|
200
|
-
const chain = [firsts[0]];
|
|
201
|
-
for (let step = next.get(firsts[0].name); step !== undefined; step = next.get(step.name))
|
|
202
|
-
chain.push(step);
|
|
203
|
-
const last = chain[chain.length - 1];
|
|
204
|
-
if (!sameEastType(last.to, rec.type)) {
|
|
205
|
-
throw new Error(`${where} is declared as ${printType(rec.type)}, but its last migration, '${last.name}', ` +
|
|
206
|
-
`leaves it as ${printType(last.to)}`);
|
|
207
|
-
}
|
|
208
|
-
return chain;
|
|
209
|
-
};
|
|
210
|
-
// Assemble records: a record's dataset rides `all_items`; fold in any
|
|
211
|
-
// mutations collected for it. A record imported via a package arrives twice —
|
|
212
|
-
// its bare dataset (mutations `{}`) in `all_items` and its already-assembled
|
|
213
|
-
// form in `importedRecords` — so merge the existing entry's mutations rather
|
|
214
|
-
// than rebuilding from the bare `rec.mutations`, or the import's folded
|
|
215
|
-
// mutations would be clobbered to empty.
|
|
86
|
+
// Each record whole, as `e3.record` declared it.
|
|
216
87
|
const records = { ...importedRecords };
|
|
217
88
|
for (const item of all_items) {
|
|
218
89
|
if (item.kind === 'dataset' && 'recordKind' in item && item.recordKind === 'record') {
|
|
219
90
|
const rec = item;
|
|
220
|
-
records[rec.name] =
|
|
221
|
-
...rec,
|
|
222
|
-
mutations: byName(rec.name, 'mutations', [
|
|
223
|
-
...Object.values(records[rec.name]?.mutations ?? {}),
|
|
224
|
-
...Object.values(rec.mutations),
|
|
225
|
-
...(mutationsByRecord.get(rec.name) ?? []),
|
|
226
|
-
]),
|
|
227
|
-
indexes: byName(rec.name, 'indexes', [
|
|
228
|
-
...Object.values(records[rec.name]?.indexes ?? {}),
|
|
229
|
-
...Object.values(rec.indexes),
|
|
230
|
-
...(indexesByRecord.get(rec.name) ?? []),
|
|
231
|
-
]),
|
|
232
|
-
migrations: chainOf(rec, [
|
|
233
|
-
...(records[rec.name]?.migrations ?? []),
|
|
234
|
-
...rec.migrations,
|
|
235
|
-
...(migrationsByRecord.get(rec.name) ?? []),
|
|
236
|
-
]),
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
for (const recName of mutationsByRecord.keys()) {
|
|
241
|
-
if (!records[recName]) {
|
|
242
|
-
throw new Error(`Mutation references record '${recName}' which is not in the package`);
|
|
91
|
+
records[rec.name] = rec;
|
|
243
92
|
}
|
|
244
93
|
}
|
|
245
94
|
return {
|
|
246
95
|
kind: 'package',
|
|
247
96
|
name,
|
|
248
97
|
version,
|
|
249
|
-
datasets
|
|
98
|
+
datasets,
|
|
250
99
|
contents: [...all_items],
|
|
251
100
|
functions,
|
|
252
101
|
records,
|
|
253
102
|
};
|
|
254
103
|
}
|
|
104
|
+
/** What each part of a record is called, by its kind. */
|
|
105
|
+
const PART_WORDS = { recordIndex: 'index', mutation: 'mutation', migration: 'migration' };
|
|
106
|
+
/**
|
|
107
|
+
* Refuses a record's part given apart from its record, naming the record: its
|
|
108
|
+
* parts are declared in `e3.record`, and a package takes the record whole.
|
|
109
|
+
*
|
|
110
|
+
* @param name - The package
|
|
111
|
+
* @param item - What it was given
|
|
112
|
+
* @throws {Error} When the item is an index, a mutation or a migration
|
|
113
|
+
*/
|
|
114
|
+
function refusePart(name, item) {
|
|
115
|
+
const part = item;
|
|
116
|
+
const words = PART_WORDS[part.kind];
|
|
117
|
+
if (words === undefined)
|
|
118
|
+
return;
|
|
119
|
+
throw new Error(`e3.package '${name}': the ${words} '${part.name}' is part of record '${part.record?.name}' — a record is declared ` +
|
|
120
|
+
`whole, its ${words === 'index' ? 'indexes' : `${words}s`} in e3.record, so pass the record`);
|
|
121
|
+
}
|
|
255
122
|
//# sourceMappingURL=package.js.map
|
package/dist/src/package.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAkD9D,8EAA8E;AAC9E,kFAAkF;AAClF,mFAAmF;AACnF,gFAAgF;AAChF,mFAAmF;AACnF,wEAAwE;AACxE,6EAA6E;AAC7E,MAAM,UAAU,QAAQ,CACtB,IAAY,EACZ,OAAe,EACf,GAAG,KAA0E;IAE7E,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAU,EAAE,CAAC;QACvF,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACzC,IAAI,OAAO,KAAK,IA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|
22
22
|
* what lets a maintained index equal its rebuild byte for byte.
|
|
23
23
|
*/
|
|
24
|
-
import { FloatType, IntegerType
|
|
25
|
-
import type {
|
|
24
|
+
import { FloatType, IntegerType } from '@elaraai/east';
|
|
25
|
+
import type { RecordDef, RecordIndexDef } from './types.js';
|
|
26
|
+
import { type IndexConstructor } from './record-guards.js';
|
|
26
27
|
/** The finest level: a level-28 cell is `cell` wide. */
|
|
27
28
|
export declare const AREA_FINEST_LEVEL = 28;
|
|
28
29
|
/** The key of a row with no place: its `x` or its `y` is `none`. */
|
|
29
30
|
export declare const AREA_UNPLACED = -1n;
|
|
30
|
-
/** The reserved name of the area index's generated key field. */
|
|
31
|
-
export declare const AREA_FIELD = "__area";
|
|
32
31
|
/** How an area index reads a row's box: the fields naming it, and whether `x`, `y` is its centre or its minimum corner. */
|
|
33
32
|
export interface AreaBox {
|
|
34
33
|
/** The field holding the box's `x`: its minimum corner's, or its centre's. */
|
|
@@ -46,49 +45,62 @@ export interface AreaBox {
|
|
|
46
45
|
* The exponent of the largest power of two at most `cell`: the finest cell's
|
|
47
46
|
* side, as the index files rows by it.
|
|
48
47
|
*
|
|
48
|
+
* @param constructor - The declaration, for the refusal
|
|
49
49
|
* @param name - The index, for the refusal
|
|
50
50
|
* @param cell - The finest cell's side the author declared, in world units
|
|
51
51
|
* @returns `e`, with `2^e ≤ cell < 2^(e+1)`
|
|
52
52
|
* @throws {Error} When `cell` is not a positive finite number, or is so large or
|
|
53
53
|
* small that the domain, `2^(e+27)` either side of zero, is not a finite Float
|
|
54
54
|
*/
|
|
55
|
-
export declare function areaCellExponent(name: string, cell: number): number;
|
|
55
|
+
export declare function areaCellExponent(constructor: IndexConstructor, name: string, cell: number): number;
|
|
56
|
+
/** What an area index's declaration names (`index.area`). */
|
|
57
|
+
export interface AreaSpec {
|
|
58
|
+
readonly on?: readonly string[];
|
|
59
|
+
readonly x: string;
|
|
60
|
+
readonly y: string;
|
|
61
|
+
readonly width?: string;
|
|
62
|
+
readonly height?: string;
|
|
63
|
+
readonly at?: 'corner' | 'centre';
|
|
64
|
+
readonly cell: number;
|
|
65
|
+
}
|
|
56
66
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
67
|
+
* An area index's definition (`index.area`): its key function, one
|
|
68
|
+
* entry per row — one per combination of its leading values where a Set among
|
|
69
|
+
* them fans out — `{ on: { …on }, area }`, the row's leading fields under `on`
|
|
70
|
+
* and the cell's code beside them (#1432); and its projection, the whole row,
|
|
71
|
+
* so a window reads the index alone and no record segment (D29). It stays an
|
|
72
|
+
* ordinary maintained index: mutation, rebuild, storage and transport are
|
|
73
|
+
* shared.
|
|
59
74
|
*
|
|
60
|
-
* @param
|
|
61
|
-
* @
|
|
62
|
-
*
|
|
63
|
-
*
|
|
75
|
+
* @param constructor - The declaration, as a refusal names it
|
|
76
|
+
* @param name - The index
|
|
77
|
+
* @param rec - Its record
|
|
78
|
+
* @param spec - The box's fields, whether `x`, `y` is its centre or its corner, the finest cell, and the optional leading `on`
|
|
79
|
+
* @param config - Its runner selection
|
|
80
|
+
* @returns The definition
|
|
81
|
+
* @throws {Error} When a field is not of its option's type, naming the option, the field and its type; when `x` and `y`
|
|
82
|
+
* are not both Options or neither; when `width` and `height` are not given together; or on any guard every index applies
|
|
64
83
|
*/
|
|
65
|
-
export declare function
|
|
84
|
+
export declare function areaDefinition(constructor: IndexConstructor, name: string, rec: RecordDef, spec: AreaSpec, config: {
|
|
85
|
+
runner?: RecordIndexDef['runner'];
|
|
86
|
+
} | undefined): RecordIndexDef;
|
|
66
87
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* interval index does. It stays an ordinary maintained index: mutation,
|
|
71
|
-
* rebuild, storage and transport are shared.
|
|
72
|
-
*
|
|
73
|
-
* @param name - The index, for the refusals
|
|
74
|
-
* @param keyType - The record's key type
|
|
75
|
-
* @param valueType - The record's row type
|
|
76
|
-
* @param on - The exact leading fields
|
|
77
|
-
* @param box - How the row's box is read
|
|
78
|
-
* @param exponent - The finest cell's side is `2^exponent`
|
|
79
|
-
* @param prefix - The leading fields' generated key function
|
|
80
|
-
* @returns The key function, whether it fans out, and whether `x` and `y` are Options
|
|
81
|
-
* @throws {Error} When a field is not of its option's type, naming the option,
|
|
82
|
-
* the field and its type; when `x` and `y` are not both Options or neither;
|
|
83
|
-
* when `width` and `height` are not given together; or when the row has a
|
|
84
|
-
* field named `__area`, which is reserved
|
|
88
|
+
* The area index's East functions, each built the first time it is read, with
|
|
89
|
+
* no location captured ({@link lazyBuilds}, #1466): importing the SDK builds
|
|
90
|
+
* none of them.
|
|
85
91
|
*/
|
|
86
|
-
export declare
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
export declare const AREA_FNS: {
|
|
93
|
+
/**
|
|
94
|
+
* The `area` part of a box's key, from its centre, its larger side and the
|
|
95
|
+
* finest cell's side, a power of two: the level-28 Morton code of the box's
|
|
96
|
+
* cell, times 32, plus its level; `0`, the root, for a box outside the domain,
|
|
97
|
+
* not finite, or larger than half the domain. Every step is exact, so every
|
|
98
|
+
* runtime computes it alike.
|
|
99
|
+
*
|
|
100
|
+
* `(cx, cy, side, cell) → Integer`
|
|
101
|
+
*/
|
|
102
|
+
readonly areaCode: import("@elaraai/east").CallableFunctionExpr<[FloatType, FloatType, FloatType, FloatType], IntegerType>;
|
|
103
|
+
/** `(width, height) → the larger of their sizes`: a box's larger side. */
|
|
104
|
+
readonly largerSide: import("@elaraai/east").CallableFunctionExpr<[FloatType, FloatType], FloatType>;
|
|
93
105
|
};
|
|
94
106
|
//# sourceMappingURL=record-area.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-area.d.ts","sourceRoot":"","sources":["../../src/record-area.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"record-area.d.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