@elaraai/e3-api-tests 1.0.97 → 1.0.99
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 +1 -2
- package/dist/src/assertions.d.ts +11 -0
- package/dist/src/assertions.d.ts.map +1 -1
- package/dist/src/assertions.js +19 -3
- package/dist/src/assertions.js.map +1 -1
- package/dist/src/fixtures.d.ts +332 -1
- package/dist/src/fixtures.d.ts.map +1 -1
- package/dist/src/fixtures.js +465 -64
- package/dist/src/fixtures.js.map +1 -1
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/suites/bundles.d.ts +13 -0
- package/dist/src/suites/bundles.d.ts.map +1 -0
- package/dist/src/suites/bundles.js +96 -0
- package/dist/src/suites/bundles.js.map +1 -0
- package/dist/src/suites/dataset-batches.d.ts +8 -0
- package/dist/src/suites/dataset-batches.d.ts.map +1 -0
- package/dist/src/suites/dataset-batches.js +346 -0
- package/dist/src/suites/dataset-batches.js.map +1 -0
- package/dist/src/suites/datasets.d.ts.map +1 -1
- package/dist/src/suites/datasets.js +1 -2
- package/dist/src/suites/datasets.js.map +1 -1
- package/dist/src/suites/package-transfer.d.ts.map +1 -1
- package/dist/src/suites/package-transfer.js +3 -2
- package/dist/src/suites/package-transfer.js.map +1 -1
- package/dist/src/suites/platform.js +4 -4
- package/dist/src/suites/platform.js.map +1 -1
- package/dist/src/suites/records-area.d.ts +8 -0
- package/dist/src/suites/records-area.d.ts.map +1 -0
- package/dist/src/suites/records-area.js +346 -0
- package/dist/src/suites/records-area.js.map +1 -0
- package/dist/src/suites/records-keyed.d.ts.map +1 -1
- package/dist/src/suites/records-keyed.js +41 -40
- package/dist/src/suites/records-keyed.js.map +1 -1
- package/dist/src/suites/records-place.d.ts +8 -0
- package/dist/src/suites/records-place.d.ts.map +1 -0
- package/dist/src/suites/records-place.js +345 -0
- package/dist/src/suites/records-place.js.map +1 -0
- package/dist/src/suites/records-series.d.ts +8 -0
- package/dist/src/suites/records-series.d.ts.map +1 -0
- package/dist/src/suites/records-series.js +709 -0
- package/dist/src/suites/records-series.js.map +1 -0
- package/dist/src/suites/repository.js +9 -9
- package/dist/src/suites/repository.js.map +1 -1
- package/dist/src/template.d.ts +35 -0
- package/dist/src/template.d.ts.map +1 -0
- package/dist/src/template.js +51 -0
- package/dist/src/template.js.map +1 -0
- package/package.json +10 -10
package/dist/src/fixtures.js
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
import { mkdirSync } from 'node:fs';
|
|
12
12
|
import { join } from 'node:path';
|
|
13
13
|
import e3 from '@elaraai/e3';
|
|
14
|
-
import { ArrayType, DictType, FunctionType, IntegerType, NullType, StringType, StructType, OptionType, East, variant, some, none } from '@elaraai/east';
|
|
14
|
+
import { ArrayType, DateTimeType, DictType, FloatType, FunctionType, IntegerType, NullType, RecursiveType, SetType, StringType, StructType, OptionType, East, variant, some, none, } from '@elaraai/east';
|
|
15
15
|
import { Console, Time } from '@elaraai/east-node-std';
|
|
16
|
+
import { RecordLevelType } from '@elaraai/e3-types';
|
|
16
17
|
/**
|
|
17
18
|
* Create a simple compute package for testing.
|
|
18
19
|
*
|
|
@@ -106,10 +107,14 @@ export async function createFunctionPackageZip(tempDir, name, version) {
|
|
|
106
107
|
*/
|
|
107
108
|
export async function createRecordPackageZip(tempDir, name, version) {
|
|
108
109
|
mkdirSync(tempDir, { recursive: true });
|
|
109
|
-
const counter = e3.record('counter', IntegerType,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
const counter = e3.record('counter', IntegerType, {
|
|
111
|
+
initial: 0n,
|
|
112
|
+
mutations: (mutation) => ({
|
|
113
|
+
increment: mutation.reduce(East.function([IntegerType, IntegerType], IntegerType, ($, state, by) => state.add(by))),
|
|
114
|
+
add_positive: mutation.reduce(East.function([IntegerType, IntegerType], IntegerType, ($, state, by) => East.less(by, 1n).ifElse(($) => $.error('amount must be positive'), ($) => state.add(by)))),
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
const pkg = e3.package(name, version, counter);
|
|
113
118
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
114
119
|
await e3.export(pkg, zipPath);
|
|
115
120
|
return zipPath;
|
|
@@ -136,41 +141,424 @@ export const PlanStatusKeyType = StructType({ status: StringType, due: IntegerTy
|
|
|
136
141
|
*/
|
|
137
142
|
export async function createKeyedRecordPackageZip(tempDir, name, version) {
|
|
138
143
|
mkdirSync(tempDir, { recursive: true });
|
|
139
|
-
const plans = e3.record('plans', PlansType,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
144
|
+
const plans = e3.record('plans', PlansType, {
|
|
145
|
+
initial: new Map(),
|
|
146
|
+
indexes: (index) => ({
|
|
147
|
+
by_status: index.key(East.function([StringType, PlanRowType], PlanStatusKeyType, ($, _k, v) => ({ status: v.status, due: v.due })), { value: East.function([StringType, PlanRowType], StringType, ($, _k, v) => v.title) }),
|
|
148
|
+
}),
|
|
149
|
+
mutations: (mutation) => ({
|
|
150
|
+
seed: mutation.reduce(East.function([PlansType, IntegerType], PlansType, ($, _state, rows) => {
|
|
151
|
+
const out = $.let(new Map(), PlansType);
|
|
152
|
+
$.for(East.Array.range(0n, rows), ($, i) => {
|
|
153
|
+
const status = $.let('ok');
|
|
154
|
+
$.if(East.equal(i.remainder(3n), 0n), ($) => {
|
|
155
|
+
$.assign(status, 'late');
|
|
156
|
+
});
|
|
157
|
+
$(out.insert(East.str `p-${i}`, { status, due: i, title: East.str `Plan ${i}` }));
|
|
158
|
+
});
|
|
159
|
+
return out;
|
|
160
|
+
})),
|
|
161
|
+
retitle: mutation.edit(East.function([PlansType, StringType, e3.mutation.editType(PlansType)], NullType, ($, state, key, edit) => {
|
|
162
|
+
const row = $.let(state.get(key));
|
|
163
|
+
$(edit.set(key, { status: row.status, due: row.due, title: 'RETITLED' }));
|
|
164
|
+
})),
|
|
165
|
+
patch: mutation.patch(),
|
|
166
|
+
}),
|
|
158
167
|
});
|
|
159
168
|
// Nullable String paths must support the same bounded prefix search as
|
|
160
169
|
// String paths. This small companion record leaves the segmented plans
|
|
161
170
|
// fixture's row type and index-count assertions unchanged.
|
|
162
171
|
const Contact = StructType({ group: StringType, name: OptionType(StringType) });
|
|
163
|
-
const contacts = e3.record('contacts', DictType(StringType, Contact),
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
const contacts = e3.record('contacts', DictType(StringType, Contact), {
|
|
173
|
+
initial: new Map([
|
|
174
|
+
['a', { group: 'east', name: none }],
|
|
175
|
+
['b', { group: 'east', name: some('Ada') }],
|
|
176
|
+
['c', { group: 'east', name: some('Adam') }],
|
|
177
|
+
['d', { group: 'east', name: some('Bea') }],
|
|
178
|
+
['e', { group: 'west', name: some('Ada') }],
|
|
179
|
+
['f', { group: 'east', name: some('Élodie') }],
|
|
180
|
+
]),
|
|
181
|
+
indexes: (index) => ({
|
|
182
|
+
by_name: index.on(['name']),
|
|
183
|
+
by_group_name: index.on(['group', 'name']),
|
|
184
|
+
}),
|
|
185
|
+
});
|
|
186
|
+
const pkg = e3.package(name, version, plans, contacts);
|
|
187
|
+
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
188
|
+
await e3.export(pkg, zipPath);
|
|
189
|
+
return zipPath;
|
|
190
|
+
}
|
|
191
|
+
/** The row of the batch-read fixture's record. */
|
|
192
|
+
export const ItemRowType = StructType({ group: StringType, rank: IntegerType, label: StringType });
|
|
193
|
+
/** The batch-read fixture's record: a Dict of items. */
|
|
194
|
+
export const ItemsType = DictType(StringType, ItemRowType);
|
|
195
|
+
/** The `by_group` index key: a group, then a rank inside it. */
|
|
196
|
+
export const ItemGroupKeyType = StructType({ group: StringType, rank: IntegerType });
|
|
197
|
+
/** The row of the batch-read fixture's second record: a note on an item. */
|
|
198
|
+
export const ItemNoteRowType = StructType({ note: StringType });
|
|
199
|
+
/** The batch-read fixture's second record: notes, keyed as the items are. */
|
|
200
|
+
export const ItemNotesType = DictType(StringType, ItemNoteRowType);
|
|
201
|
+
/**
|
|
202
|
+
* Create a package whose record a dataset's batch reads are run over (#1351):
|
|
203
|
+
* several key searches in one request, the rows of several keys — or of the
|
|
204
|
+
* keys some runs of another record's index name (#1393) — the entries of
|
|
205
|
+
* several runs.
|
|
206
|
+
*
|
|
207
|
+
* Creates a package with:
|
|
208
|
+
* - Record: "items" (Dict<String, {group, rank, label}>, empty), and Mutation
|
|
209
|
+
* "seed" (rows) => `rows` items keyed `item-<i>`, in five groups
|
|
210
|
+
* (`g0`…`g4`, by `i` mod 5), each ranked `i`
|
|
211
|
+
* - Index: "by_group" on `group` then `rank`, one entry per row, so a group is
|
|
212
|
+
* one run of it
|
|
213
|
+
* - Record: "item_notes" (Dict<String, {note}>, empty), keyed as the items
|
|
214
|
+
* are, and Mutation "seed_notes" (rows) => a note on every third of `rows`
|
|
215
|
+
* items, `item-<i>` for `i` a multiple of 3, `Note <i>`
|
|
216
|
+
*
|
|
217
|
+
* @param tempDir - Directory to write the zip file
|
|
218
|
+
* @param name - Package name
|
|
219
|
+
* @param version - Package version
|
|
220
|
+
* @returns Path to the created zip file
|
|
221
|
+
*/
|
|
222
|
+
export async function createBatchReadsPackageZip(tempDir, name, version) {
|
|
223
|
+
mkdirSync(tempDir, { recursive: true });
|
|
224
|
+
const items = e3.record('items', ItemsType, {
|
|
225
|
+
initial: new Map(),
|
|
226
|
+
indexes: (index) => ({
|
|
227
|
+
by_group: index.on(['group', 'rank']),
|
|
228
|
+
}),
|
|
229
|
+
mutations: (mutation) => ({
|
|
230
|
+
seed: mutation.reduce(East.function([ItemsType, IntegerType], ItemsType, ($, _state, rows) => {
|
|
231
|
+
const out = $.let(new Map(), ItemsType);
|
|
232
|
+
$.for(East.Array.range(0n, rows), ($, i) => {
|
|
233
|
+
$(out.insert(East.str `item-${i}`, { group: East.str `g${i.remainder(5n)}`, rank: i, label: East.str `Item ${i}` }));
|
|
234
|
+
});
|
|
235
|
+
return out;
|
|
236
|
+
})),
|
|
237
|
+
}),
|
|
238
|
+
});
|
|
239
|
+
const notes = e3.record('item_notes', ItemNotesType, {
|
|
240
|
+
initial: new Map(),
|
|
241
|
+
mutations: (mutation) => ({
|
|
242
|
+
seed_notes: mutation.reduce(East.function([ItemNotesType, IntegerType], ItemNotesType, ($, _state, rows) => {
|
|
243
|
+
const out = $.let(new Map(), ItemNotesType);
|
|
244
|
+
$.for(East.Array.range(0n, rows), ($, i) => {
|
|
245
|
+
$.if(East.equal(i.remainder(3n), 0n), ($) => {
|
|
246
|
+
$(out.insert(East.str `item-${i}`, { note: East.str `Note ${i}` }));
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
return out;
|
|
250
|
+
})),
|
|
251
|
+
}),
|
|
252
|
+
});
|
|
253
|
+
const pkg = e3.package(name, version, items, notes);
|
|
254
|
+
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
255
|
+
await e3.export(pkg, zipPath);
|
|
256
|
+
return zipPath;
|
|
257
|
+
}
|
|
258
|
+
/** The upload-named fixture's input: counts by name. */
|
|
259
|
+
export const CountsType = DictType(StringType, IntegerType);
|
|
260
|
+
/**
|
|
261
|
+
* Create a package whose dataset is named as an upload's route ends: a
|
|
262
|
+
* dataset's batch reads are POSTs to its own path, and an upload's init is a
|
|
263
|
+
* POST to `<path>/upload`, so a batch read of `inputs.upload` is a POST to the
|
|
264
|
+
* path an upload of `inputs` would begin at.
|
|
265
|
+
*
|
|
266
|
+
* Creates a package with:
|
|
267
|
+
* - Input: "upload" (Dict<String, Integer>, default {a: 1, b: 2, c: 3})
|
|
268
|
+
*
|
|
269
|
+
* @param tempDir - Directory to write the zip file
|
|
270
|
+
* @param name - Package name
|
|
271
|
+
* @param version - Package version
|
|
272
|
+
* @returns Path to the created zip file
|
|
273
|
+
*/
|
|
274
|
+
export async function createUploadNamedPackageZip(tempDir, name, version) {
|
|
275
|
+
mkdirSync(tempDir, { recursive: true });
|
|
276
|
+
const upload = e3.input('upload', CountsType, variant('value', new Map([['a', 1n], ['b', 2n], ['c', 3n]])));
|
|
277
|
+
const pkg = e3.package(name, version, upload);
|
|
278
|
+
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
279
|
+
await e3.export(pkg, zipPath);
|
|
280
|
+
return zipPath;
|
|
281
|
+
}
|
|
282
|
+
/** The row of the area fixture's record: a rack's hall, where it stands — by its centre — if anywhere yet, and its footprint. */
|
|
283
|
+
export const RackRowType = StructType({ hall: StringType, x: OptionType(FloatType), y: OptionType(FloatType), w: FloatType, h: FloatType });
|
|
284
|
+
/** The area fixture's record: racks by key. */
|
|
285
|
+
export const RacksType = DictType(StringType, RackRowType);
|
|
286
|
+
/** The finest cell of the area fixture's indexes: their declared 0.01, rounded down to a power of two. */
|
|
287
|
+
export const RACK_CELL = 2 ** -7;
|
|
288
|
+
/** The key of the area fixture's `racks_by_area`: led by no field, its `on` holds none, then a rack's cell and level (#1432). */
|
|
289
|
+
export const RackAreaKeyType = StructType({ on: StructType({}), area: IntegerType });
|
|
290
|
+
/** The key of its `racks_by_hall_area`: a rack's hall under `on`, then its cell and level (#1432). */
|
|
291
|
+
export const RackHallAreaKeyType = StructType({ on: StructType({ hall: StringType }), area: IntegerType });
|
|
292
|
+
/**
|
|
293
|
+
* Create a package whose record is read by area (#1385): a window over a
|
|
294
|
+
* floor's racks, read through an area index from the index alone.
|
|
295
|
+
*
|
|
296
|
+
* Creates a package with:
|
|
297
|
+
* - Record: "racks" (Dict<String, {hall, x, y, w, h}>, empty), its patch door,
|
|
298
|
+
* and Mutation "seed" (count) => `count` racks keyed `rack-<i>`: in three
|
|
299
|
+
* halls (`H0`…`H2`, by `i` mod 3), centred on a grid of 37 columns 1.7 apart
|
|
300
|
+
* from x = −30 and rows 1.3 apart from y = −20, some a cell or two off their
|
|
301
|
+
* column; of footprints from 0.3 × 0.2 to 1.9 × 2.0; every eleventh not yet
|
|
302
|
+
* placed
|
|
303
|
+
* - Index: "racks_by_area", each rack's box by its centre, at a 0.01 cell, led
|
|
304
|
+
* by no field ({@link RackAreaKeyType}); and "racks_by_hall_area", the same
|
|
305
|
+
* led by the hall ({@link RackHallAreaKeyType}). Each carries its rows whole
|
|
306
|
+
*
|
|
307
|
+
* @param tempDir - Directory to write the zip file
|
|
308
|
+
* @param name - Package name
|
|
309
|
+
* @param version - Package version
|
|
310
|
+
* @returns Path to the created zip file
|
|
311
|
+
*/
|
|
312
|
+
export async function createAreaRecordPackageZip(tempDir, name, version) {
|
|
313
|
+
mkdirSync(tempDir, { recursive: true });
|
|
314
|
+
const racks = e3.record('racks', RacksType, {
|
|
315
|
+
initial: new Map(),
|
|
316
|
+
indexes: (index) => ({
|
|
317
|
+
racks_by_area: index.area({ x: 'x', y: 'y', width: 'w', height: 'h', at: 'centre', cell: 0.01 }),
|
|
318
|
+
racks_by_hall_area: index.area({ on: ['hall'], x: 'x', y: 'y', width: 'w', height: 'h', at: 'centre', cell: 0.01 }),
|
|
319
|
+
}),
|
|
320
|
+
mutations: (mutation) => ({
|
|
321
|
+
seed: mutation.reduce(East.function([RacksType, IntegerType], RacksType, ($, _state, count) => {
|
|
322
|
+
const out = $.let(new Map(), RacksType);
|
|
323
|
+
$.for(East.Array.range(0n, count), ($, i) => {
|
|
324
|
+
const hall = $.let(East.str `H${i.remainder(3n)}`);
|
|
325
|
+
const x = $.let(i.remainder(37n).toFloat().multiply(1.7).subtract(30.0).add(i.remainder(3n).toFloat().multiply(RACK_CELL)));
|
|
326
|
+
const y = $.let(i.divide(37n).toFloat().multiply(1.3).subtract(20.0));
|
|
327
|
+
const w = $.let(i.remainder(5n).toFloat().multiply(0.4).add(0.3));
|
|
328
|
+
const h = $.let(i.remainder(7n).toFloat().multiply(0.3).add(0.2));
|
|
329
|
+
$.if(East.equal(i.remainder(11n), 0n), ($) => {
|
|
330
|
+
$(out.insert(East.str `rack-${i}`, { hall, x: none, y: none, w, h }));
|
|
331
|
+
}).else(($) => {
|
|
332
|
+
$(out.insert(East.str `rack-${i}`, { hall, x: some(x), y: some(y), w, h }));
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
return out;
|
|
336
|
+
})),
|
|
337
|
+
patch: mutation.patch(),
|
|
338
|
+
}),
|
|
339
|
+
});
|
|
340
|
+
const pkg = e3.package(name, version, racks);
|
|
341
|
+
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
342
|
+
await e3.export(pkg, zipPath);
|
|
343
|
+
return zipPath;
|
|
344
|
+
}
|
|
345
|
+
/** When the place fixture's first order starts: midnight UTC on 1 January 2026. */
|
|
346
|
+
export const ORDERS_FROM = new Date(Date.UTC(2026, 0, 1));
|
|
347
|
+
/** The row of the place fixture's record: an order's status, its name, its due rank, its tags, and when it runs. */
|
|
348
|
+
export const OrderRowType = StructType({
|
|
349
|
+
status: StringType, name: StringType, due: IntegerType, tags: SetType(StringType), start: DateTimeType, end: DateTimeType,
|
|
350
|
+
});
|
|
351
|
+
/** The place fixture's record: orders by key. */
|
|
352
|
+
export const OrdersType = DictType(StringType, OrderRowType);
|
|
353
|
+
/**
|
|
354
|
+
* Create a package whose record a narrowing's rows are placed in (#1349): in
|
|
355
|
+
* which of the record's segments the rows of a narrowing sit, from its runs of
|
|
356
|
+
* one of the record's indexes, and which index entries those runs hold.
|
|
357
|
+
*
|
|
358
|
+
* Creates a package with:
|
|
359
|
+
* - Record: "orders" (Dict<String, {status, name, due, tags, start, end}>,
|
|
360
|
+
* empty), and Mutation "seed" (count) => `count` orders keyed `order-<i>`:
|
|
361
|
+
* `open`, `late`, `done` or `held` by `i` mod 4; named `Ash`, `Birch`,
|
|
362
|
+
* `Cedar` or `Fir` by `i` div 3 mod 4, then `i`; due `i` × 7919 mod `count`,
|
|
363
|
+
* a rank of its own whenever `count` shares no factor with 7919; tagged
|
|
364
|
+
* `t<i mod 5>` and `t<i mod 7>`; starting `i` mod 97 hours after
|
|
365
|
+
* {@link ORDERS_FROM}, and running 30 days when `i` is a multiple of 13, else
|
|
366
|
+
* `i` mod 5 hours, which is no time at all when it is 0
|
|
367
|
+
* - Indexes: "orders_by_status", "orders_by_name", "orders_by_due" and
|
|
368
|
+
* "orders_by_tag", each on its one field (the tags' files an order under each
|
|
369
|
+
* of its tags), and "orders_by_time", the interval index from `start` to
|
|
370
|
+
* `end`
|
|
371
|
+
*
|
|
372
|
+
* @param tempDir - Directory to write the zip file
|
|
373
|
+
* @param name - Package name
|
|
374
|
+
* @param version - Package version
|
|
375
|
+
* @returns Path to the created zip file
|
|
376
|
+
*/
|
|
377
|
+
export async function createPlaceRecordPackageZip(tempDir, name, version) {
|
|
378
|
+
mkdirSync(tempDir, { recursive: true });
|
|
379
|
+
const orders = e3.record('orders', OrdersType, {
|
|
380
|
+
initial: new Map(),
|
|
381
|
+
indexes: (index) => ({
|
|
382
|
+
orders_by_status: index.on(['status']),
|
|
383
|
+
orders_by_name: index.on(['name']),
|
|
384
|
+
orders_by_due: index.on(['due']),
|
|
385
|
+
orders_by_tag: index.on(['tags']),
|
|
386
|
+
orders_by_time: index.interval({ from: 'start', to: 'end' }),
|
|
387
|
+
}),
|
|
388
|
+
mutations: (mutation) => ({
|
|
389
|
+
seed: mutation.reduce(East.function([OrdersType, IntegerType], OrdersType, ($, _state, count) => {
|
|
390
|
+
const statuses = $.const(['open', 'late', 'done', 'held'], ArrayType(StringType));
|
|
391
|
+
const names = $.const(['Ash', 'Birch', 'Cedar', 'Fir'], ArrayType(StringType));
|
|
392
|
+
const from = $.const(ORDERS_FROM, DateTimeType);
|
|
393
|
+
const out = $.let(new Map(), OrdersType);
|
|
394
|
+
$.for(East.Array.range(0n, count), ($, i) => {
|
|
395
|
+
const tags = $.let(new Set(), SetType(StringType));
|
|
396
|
+
$(tags.tryInsert(East.str `t${i.remainder(5n)}`));
|
|
397
|
+
$(tags.tryInsert(East.str `t${i.remainder(7n)}`));
|
|
398
|
+
const start = $.let(from.addHours(i.remainder(97n)));
|
|
399
|
+
const end = $.let(start.addHours(i.remainder(5n)));
|
|
400
|
+
$.if(East.equal(i.remainder(13n), 0n), ($) => {
|
|
401
|
+
$.assign(end, start.addDays(30n));
|
|
402
|
+
});
|
|
403
|
+
$(out.insert(East.str `order-${i}`, {
|
|
404
|
+
status: statuses.get(i.remainder(4n)),
|
|
405
|
+
name: East.str `${names.get(i.divide(3n).remainder(4n))} ${i}`,
|
|
406
|
+
due: i.multiply(7919n).remainder(count),
|
|
407
|
+
tags,
|
|
408
|
+
start,
|
|
409
|
+
end,
|
|
410
|
+
}));
|
|
411
|
+
});
|
|
412
|
+
return out;
|
|
413
|
+
})),
|
|
414
|
+
}),
|
|
415
|
+
});
|
|
416
|
+
const pkg = e3.package(name, version, orders);
|
|
417
|
+
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
418
|
+
await e3.export(pkg, zipPath);
|
|
419
|
+
return zipPath;
|
|
420
|
+
}
|
|
421
|
+
/** When the series fixture's first job may start: midnight UTC on Monday 5 October 2026, a week's start. */
|
|
422
|
+
export const JOBS_FROM = new Date(Date.UTC(2026, 9, 5));
|
|
423
|
+
/** The row of the series fixture's record: a print job's press, when it runs, and its title. */
|
|
424
|
+
export const JobRowType = StructType({ press: StringType, start: DateTimeType, end: DateTimeType, title: StringType });
|
|
425
|
+
/** The series fixture's record: jobs by key. */
|
|
426
|
+
export const JobsType = DictType(StringType, JobRowType);
|
|
427
|
+
/**
|
|
428
|
+
* The key of the series fixture's series index (#1433): led by no field, its
|
|
429
|
+
* `on` holds none (#1432), then a press, the level a job is filed at and the
|
|
430
|
+
* start of that level's tile.
|
|
431
|
+
*/
|
|
432
|
+
export const JobPressLevelTileKeyType = StructType({ on: StructType({}), key: StringType, level: RecordLevelType, tile: DateTimeType });
|
|
433
|
+
/** The key of the series fixture's summary index: its `on`, then a press and a week's start (#1433). */
|
|
434
|
+
export const JobPressWeekKeyType = StructType({ on: StructType({}), key: StringType, tile: DateTimeType });
|
|
435
|
+
/**
|
|
436
|
+
* Create a package whose record is read in two dimensions (#1039): a block of
|
|
437
|
+
* presses over a span of weeks, through a series index from the index alone,
|
|
438
|
+
* and, zoomed out, through a summary index's totals.
|
|
439
|
+
*
|
|
440
|
+
* Creates a package with:
|
|
441
|
+
* - Record: "jobs" (Dict<String, {press, start, end, title}>, empty), its patch
|
|
442
|
+
* door, and Mutation "seed" (count) => `count` jobs keyed `job-<i>`: on one of
|
|
443
|
+
* forty presses (`P-1001`…`P-1040`, by `i` mod 40), starting `i` × 7 mod 1,680
|
|
444
|
+
* hours after {@link JOBS_FROM} — over ten weeks — and running `i` mod 50 + 1
|
|
445
|
+
* hours, so many run into the next week
|
|
446
|
+
* - Index: "jobs_by_press_week", each job under its press, filed once at the
|
|
447
|
+
* level its length fits — a week, a month, a quarter or a year, from the
|
|
448
|
+
* week up — or once a year past a year, carrying its row, keyed
|
|
449
|
+
* {@link JobPressLevelTileKeyType}; and "jobs_by_press_week_totals", how many
|
|
450
|
+
* jobs touch each week on each press and the time of it they cover, keyed
|
|
451
|
+
* {@link JobPressWeekKeyType}
|
|
452
|
+
*
|
|
453
|
+
* @param tempDir - Directory to write the zip file
|
|
454
|
+
* @param name - Package name
|
|
455
|
+
* @param version - Package version
|
|
456
|
+
* @returns Path to the created zip file
|
|
457
|
+
*/
|
|
458
|
+
export async function createSeriesRecordPackageZip(tempDir, name, version) {
|
|
459
|
+
mkdirSync(tempDir, { recursive: true });
|
|
460
|
+
const jobs = e3.record('jobs', JobsType, {
|
|
461
|
+
initial: new Map(),
|
|
462
|
+
indexes: (index) => ({
|
|
463
|
+
jobs_by_press_week: index.series({ key: 'press', from: 'start', to: 'end', tile: 'week' }),
|
|
464
|
+
jobs_by_press_week_totals: index.summary({ key: 'press', from: 'start', to: 'end', tile: 'week' }),
|
|
465
|
+
}),
|
|
466
|
+
mutations: (mutation) => ({
|
|
467
|
+
seed: mutation.reduce(East.function([JobsType, IntegerType], JobsType, ($, _state, count) => {
|
|
468
|
+
const from = $.const(JOBS_FROM, DateTimeType);
|
|
469
|
+
const out = $.let(new Map(), JobsType);
|
|
470
|
+
$.for(East.Array.range(0n, count), ($, i) => {
|
|
471
|
+
const start = $.let(from.addHours(i.multiply(7n).remainder(1680n)));
|
|
472
|
+
const end = $.let(start.addHours(i.remainder(50n).add(1n)));
|
|
473
|
+
$(out.insert(East.str `job-${i}`, { press: East.str `P-${i.remainder(40n).add(1001n)}`, start, end, title: East.str `Job ${i}` }));
|
|
474
|
+
});
|
|
475
|
+
return out;
|
|
476
|
+
})),
|
|
477
|
+
patch: mutation.patch(),
|
|
478
|
+
}),
|
|
479
|
+
});
|
|
480
|
+
const pkg = e3.package(name, version, jobs);
|
|
481
|
+
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
482
|
+
await e3.export(pkg, zipPath);
|
|
483
|
+
return zipPath;
|
|
484
|
+
}
|
|
485
|
+
/** A job a nested record's rows hold (#1434): a product, from its start to its end. */
|
|
486
|
+
export const NestedJobType = StructType({ product: StringType, start: DateTimeType, end: DateTimeType });
|
|
487
|
+
/** A machine: where it stands, its jobs by id, and its load a day at a time. */
|
|
488
|
+
export const MachineType = StructType({
|
|
489
|
+
name: StringType, site: StringType, status: StringType, jobs: DictType(StringType, NestedJobType), load: DictType(DateTimeType, FloatType),
|
|
490
|
+
});
|
|
491
|
+
/** The nested fixture's machines. */
|
|
492
|
+
export const MachinesType = DictType(StringType, MachineType);
|
|
493
|
+
/** A hall's member, its load a day at a time. */
|
|
494
|
+
export const MemberType = StructType({ name: StringType, load: DictType(DateTimeType, FloatType) });
|
|
495
|
+
/** A hall: where it stands, and its members by id. */
|
|
496
|
+
export const HallType = StructType({ name: StringType, site: StringType, members: DictType(StringType, MemberType) });
|
|
497
|
+
/** The nested fixture's halls. */
|
|
498
|
+
export const HallsType = DictType(StringType, HallType);
|
|
499
|
+
/** A part: its jobs, and more parts beneath it, to any depth. */
|
|
500
|
+
export const PartType = RecursiveType((self) => StructType({ name: StringType, jobs: DictType(StringType, NestedJobType), parts: DictType(StringType, self) }));
|
|
501
|
+
/** An assembly: its parts by id. */
|
|
502
|
+
export const AssemblyType = StructType({ name: StringType, parts: DictType(StringType, PartType) });
|
|
503
|
+
/** The nested fixture's assemblies. */
|
|
504
|
+
export const AssembliesType = DictType(StringType, AssemblyType);
|
|
505
|
+
/**
|
|
506
|
+
* Create a package of records whose rows nest what a series files (#1434).
|
|
507
|
+
*
|
|
508
|
+
* Creates a package with, each record empty and with its patch door:
|
|
509
|
+
* - Record "machines", and its nested series index "machines_in_time": each
|
|
510
|
+
* machine's jobs, things people drag, and its load, a value a day, filed
|
|
511
|
+
* from the week up and totalled a month at a time; beside it
|
|
512
|
+
* "machines_by_site", which carries each machine without them
|
|
513
|
+
* - Record "halls", and "halls_in_time": each member's load, rolled up by its
|
|
514
|
+
* mean, so each hall keeps its members' mean at every level from the day up
|
|
515
|
+
* - Record "assemblies", and "assemblies_in_time": each part's jobs, rolled
|
|
516
|
+
* up, so each part files its subtree's jobs too
|
|
517
|
+
*
|
|
518
|
+
* @param tempDir - Directory to write the zip file
|
|
519
|
+
* @param name - Package name
|
|
520
|
+
* @param version - Package version
|
|
521
|
+
* @returns Path to the created zip file
|
|
522
|
+
*/
|
|
523
|
+
export async function createNestedSeriesPackageZip(tempDir, name, version) {
|
|
524
|
+
mkdirSync(tempDir, { recursive: true });
|
|
525
|
+
const machines = e3.record('machines', MachinesType, {
|
|
526
|
+
initial: new Map(),
|
|
527
|
+
indexes: (index) => ({
|
|
528
|
+
machines_in_time: index.nested({
|
|
529
|
+
collections: { jobs: index.nested.items({ from: 'start', to: 'end' }), load: index.nested.values() }, tile: 'week', summary: 'month',
|
|
530
|
+
}),
|
|
531
|
+
machines_by_site: index.on(['site']),
|
|
532
|
+
}),
|
|
533
|
+
mutations: (mutation) => ({
|
|
534
|
+
patch: mutation.patch(),
|
|
535
|
+
}),
|
|
536
|
+
});
|
|
537
|
+
const halls = e3.record('halls', HallsType, {
|
|
538
|
+
initial: new Map(),
|
|
539
|
+
indexes: (index) => ({
|
|
540
|
+
halls_in_time: index.nested({
|
|
541
|
+
collections: { members: index.nested.rows({ load: index.nested.values({ rollup: 'mean' }) }) }, tile: 'day', summary: 'month',
|
|
542
|
+
}),
|
|
543
|
+
}),
|
|
544
|
+
mutations: (mutation) => ({
|
|
545
|
+
patch: mutation.patch(),
|
|
546
|
+
}),
|
|
547
|
+
});
|
|
548
|
+
const assemblies = e3.record('assemblies', AssembliesType, {
|
|
549
|
+
initial: new Map(),
|
|
550
|
+
indexes: (index) => ({
|
|
551
|
+
assemblies_in_time: index.nested({
|
|
552
|
+
collections: { parts: index.nested.rows({ jobs: index.nested.items({ from: 'start', to: 'end' }, { rollup: true }), parts: index.nested.recursive() }) },
|
|
553
|
+
tile: 'week',
|
|
554
|
+
summary: 'month',
|
|
555
|
+
}),
|
|
556
|
+
}),
|
|
557
|
+
mutations: (mutation) => ({
|
|
558
|
+
patch: mutation.patch(),
|
|
559
|
+
}),
|
|
560
|
+
});
|
|
561
|
+
const pkg = e3.package(name, version, machines, halls, assemblies);
|
|
174
562
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
175
563
|
await e3.export(pkg, zipPath);
|
|
176
564
|
return zipPath;
|
|
@@ -205,26 +593,32 @@ export async function createMigrationPackageZip(tempDir, name, version) {
|
|
|
205
593
|
const note = e3.input('note', StringType, variant('value', version));
|
|
206
594
|
let pkg;
|
|
207
595
|
if (version === '1.0.0') {
|
|
208
|
-
const tasks = e3.record('tasks', TasksV1Type,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
596
|
+
const tasks = e3.record('tasks', TasksV1Type, {
|
|
597
|
+
initial: new Map([['a', { title: 'A' }]]),
|
|
598
|
+
mutations: (mutation) => ({
|
|
599
|
+
add: mutation.reduce(East.function([TasksV1Type, StringType, StringType], TasksV1Type, ($, state, id, title) => {
|
|
600
|
+
const next = $.let(state.copy());
|
|
601
|
+
$(next.insert(id, { title }));
|
|
602
|
+
return next;
|
|
603
|
+
})),
|
|
604
|
+
}),
|
|
605
|
+
});
|
|
606
|
+
pkg = e3.package(name, version, tasks);
|
|
215
607
|
}
|
|
216
608
|
else if (version === '4.0.0') {
|
|
217
609
|
pkg = e3.package(name, version, note);
|
|
218
610
|
}
|
|
219
611
|
else {
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
612
|
+
// 3.0.0 declares the record's new type with no step from the old one: the deploy that finds the old state refuses it.
|
|
613
|
+
const tasks = version === '3.0.0'
|
|
614
|
+
? e3.record('tasks', TasksV2Type, { initial: new Map() })
|
|
615
|
+
: e3.record('tasks', TasksV2Type, {
|
|
616
|
+
initial: new Map(),
|
|
617
|
+
migrations: (migration) => [
|
|
618
|
+
migration.rows('add_owner', East.function([StringType, TaskRowV1Type], TaskRowV2Type, ($, _id, row) => ({ title: row.title, owner: 'nobody' }))),
|
|
619
|
+
],
|
|
620
|
+
});
|
|
621
|
+
pkg = version === '2.1.0' ? e3.package(name, version, tasks, note) : e3.package(name, version, tasks);
|
|
228
622
|
}
|
|
229
623
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
230
624
|
await e3.export(pkg, zipPath);
|
|
@@ -251,24 +645,31 @@ export async function createPendingRecordPackageZip(tempDir, name, version) {
|
|
|
251
645
|
mkdirSync(tempDir, { recursive: true });
|
|
252
646
|
let pkg;
|
|
253
647
|
if (version === '1.0.0') {
|
|
254
|
-
const customers = e3.record('customers', TasksV1Type,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
648
|
+
const customers = e3.record('customers', TasksV1Type, {
|
|
649
|
+
initial: new Map([['a', { title: 'A' }]]),
|
|
650
|
+
mutations: (mutation) => ({
|
|
651
|
+
add: mutation.reduce(East.function([TasksV1Type, StringType, StringType], TasksV1Type, ($, state, id, title) => {
|
|
652
|
+
const next = $.let(state.copy());
|
|
653
|
+
$(next.insert(id, { title }));
|
|
654
|
+
return next;
|
|
655
|
+
})),
|
|
656
|
+
}),
|
|
657
|
+
});
|
|
260
658
|
const count = e3.task('count', [customers], East.function([TasksV1Type], IntegerType, ($, rows) => rows.size()));
|
|
261
|
-
pkg = e3.package(name, version, customers,
|
|
659
|
+
pkg = e3.package(name, version, customers, count);
|
|
262
660
|
}
|
|
263
661
|
else {
|
|
264
|
-
const customers = e3.record('customers', TasksV2Type
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
662
|
+
const customers = e3.record('customers', TasksV2Type, {
|
|
663
|
+
mutations: (mutation) => ({
|
|
664
|
+
add: mutation.reduce(East.function([TasksV2Type, StringType, StringType], TasksV2Type, ($, state, id, title) => {
|
|
665
|
+
const next = $.let(state.copy());
|
|
666
|
+
$(next.insert(id, { title, owner: 'nobody' }));
|
|
667
|
+
return next;
|
|
668
|
+
})),
|
|
669
|
+
}),
|
|
670
|
+
});
|
|
270
671
|
const count = e3.task('count', [customers], East.function([TasksV2Type], IntegerType, ($, rows) => rows.size()));
|
|
271
|
-
pkg = e3.package(name, version, customers,
|
|
672
|
+
pkg = e3.package(name, version, customers, count);
|
|
272
673
|
}
|
|
273
674
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
274
675
|
await e3.export(pkg, zipPath);
|