@elaraai/e3-api-tests 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 +1 -2
- package/dist/src/fixtures.d.ts +145 -14
- package/dist/src/fixtures.d.ts.map +1 -1
- package/dist/src/fixtures.js +305 -160
- package/dist/src/fixtures.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -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/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.map +1 -1
- package/dist/src/suites/records-area.js +53 -46
- package/dist/src/suites/records-area.js.map +1 -1
- package/dist/src/suites/records-keyed.d.ts.map +1 -1
- package/dist/src/suites/records-keyed.js +34 -36
- package/dist/src/suites/records-keyed.js.map +1 -1
- package/dist/src/suites/records-place.d.ts.map +1 -1
- package/dist/src/suites/records-place.js +50 -46
- package/dist/src/suites/records-place.js.map +1 -1
- package/dist/src/suites/records-series.d.ts.map +1 -1
- package/dist/src/suites/records-series.js +533 -104
- package/dist/src/suites/records-series.js.map +1 -1
- 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, DateTimeType, DictType, FloatType, FunctionType, IntegerType, NullType, SetType, 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,49 @@ 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);
|
|
174
187
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
175
188
|
await e3.export(pkg, zipPath);
|
|
176
189
|
return zipPath;
|
|
@@ -208,26 +221,36 @@ export const ItemNotesType = DictType(StringType, ItemNoteRowType);
|
|
|
208
221
|
*/
|
|
209
222
|
export async function createBatchReadsPackageZip(tempDir, name, version) {
|
|
210
223
|
mkdirSync(tempDir, { recursive: true });
|
|
211
|
-
const items = e3.record('items', ItemsType,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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);
|
|
231
254
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
232
255
|
await e3.export(pkg, zipPath);
|
|
233
256
|
return zipPath;
|
|
@@ -262,10 +285,10 @@ export const RackRowType = StructType({ hall: StringType, x: OptionType(FloatTyp
|
|
|
262
285
|
export const RacksType = DictType(StringType, RackRowType);
|
|
263
286
|
/** The finest cell of the area fixture's indexes: their declared 0.01, rounded down to a power of two. */
|
|
264
287
|
export const RACK_CELL = 2 ** -7;
|
|
265
|
-
/** The key of the area fixture's `racks_by_area`: a rack's cell and level
|
|
266
|
-
export const RackAreaKeyType = StructType({
|
|
267
|
-
/** The key of its `racks_by_hall_area`: a rack's hall
|
|
268
|
-
export const RackHallAreaKeyType = StructType({ hall: StringType,
|
|
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 });
|
|
269
292
|
/**
|
|
270
293
|
* Create a package whose record is read by area (#1385): a window over a
|
|
271
294
|
* floor's racks, read through an area index from the index alone.
|
|
@@ -288,26 +311,33 @@ export const RackHallAreaKeyType = StructType({ hall: StringType, __area: Intege
|
|
|
288
311
|
*/
|
|
289
312
|
export async function createAreaRecordPackageZip(tempDir, name, version) {
|
|
290
313
|
mkdirSync(tempDir, { recursive: true });
|
|
291
|
-
const racks = e3.record('racks', RacksType,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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);
|
|
311
341
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
312
342
|
await e3.export(pkg, zipPath);
|
|
313
343
|
return zipPath;
|
|
@@ -346,38 +376,44 @@ export const OrdersType = DictType(StringType, OrderRowType);
|
|
|
346
376
|
*/
|
|
347
377
|
export async function createPlaceRecordPackageZip(tempDir, name, version) {
|
|
348
378
|
mkdirSync(tempDir, { recursive: true });
|
|
349
|
-
const orders = e3.record('orders', OrdersType,
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
$.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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);
|
|
381
417
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
382
418
|
await e3.export(pkg, zipPath);
|
|
383
419
|
return zipPath;
|
|
@@ -388,8 +424,14 @@ export const JOBS_FROM = new Date(Date.UTC(2026, 9, 5));
|
|
|
388
424
|
export const JobRowType = StructType({ press: StringType, start: DateTimeType, end: DateTimeType, title: StringType });
|
|
389
425
|
/** The series fixture's record: jobs by key. */
|
|
390
426
|
export const JobsType = DictType(StringType, JobRowType);
|
|
391
|
-
/**
|
|
392
|
-
|
|
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 });
|
|
393
435
|
/**
|
|
394
436
|
* Create a package whose record is read in two dimensions (#1039): a block of
|
|
395
437
|
* presses over a span of weeks, through a series index from the index alone,
|
|
@@ -401,10 +443,12 @@ export const JobWeekPressKeyType = StructType({ __tile: DateTimeType, press: Str
|
|
|
401
443
|
* forty presses (`P-1001`…`P-1040`, by `i` mod 40), starting `i` × 7 mod 1,680
|
|
402
444
|
* hours after {@link JOBS_FROM} — over ten weeks — and running `i` mod 50 + 1
|
|
403
445
|
* hours, so many run into the next week
|
|
404
|
-
* - Index: "jobs_by_press_week", each job under
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
* {@link
|
|
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}
|
|
408
452
|
*
|
|
409
453
|
* @param tempDir - Directory to write the zip file
|
|
410
454
|
* @param name - Package name
|
|
@@ -413,20 +457,108 @@ export const JobWeekPressKeyType = StructType({ __tile: DateTimeType, press: Str
|
|
|
413
457
|
*/
|
|
414
458
|
export async function createSeriesRecordPackageZip(tempDir, name, version) {
|
|
415
459
|
mkdirSync(tempDir, { recursive: true });
|
|
416
|
-
const jobs = e3.record('jobs', JobsType,
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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);
|
|
430
562
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
431
563
|
await e3.export(pkg, zipPath);
|
|
432
564
|
return zipPath;
|
|
@@ -461,26 +593,32 @@ export async function createMigrationPackageZip(tempDir, name, version) {
|
|
|
461
593
|
const note = e3.input('note', StringType, variant('value', version));
|
|
462
594
|
let pkg;
|
|
463
595
|
if (version === '1.0.0') {
|
|
464
|
-
const tasks = e3.record('tasks', TasksV1Type,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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);
|
|
471
607
|
}
|
|
472
608
|
else if (version === '4.0.0') {
|
|
473
609
|
pkg = e3.package(name, version, note);
|
|
474
610
|
}
|
|
475
611
|
else {
|
|
476
|
-
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
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);
|
|
484
622
|
}
|
|
485
623
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
486
624
|
await e3.export(pkg, zipPath);
|
|
@@ -507,24 +645,31 @@ export async function createPendingRecordPackageZip(tempDir, name, version) {
|
|
|
507
645
|
mkdirSync(tempDir, { recursive: true });
|
|
508
646
|
let pkg;
|
|
509
647
|
if (version === '1.0.0') {
|
|
510
|
-
const customers = e3.record('customers', TasksV1Type,
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
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
|
+
});
|
|
516
658
|
const count = e3.task('count', [customers], East.function([TasksV1Type], IntegerType, ($, rows) => rows.size()));
|
|
517
|
-
pkg = e3.package(name, version, customers,
|
|
659
|
+
pkg = e3.package(name, version, customers, count);
|
|
518
660
|
}
|
|
519
661
|
else {
|
|
520
|
-
const customers = e3.record('customers', TasksV2Type
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
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
|
+
});
|
|
526
671
|
const count = e3.task('count', [customers], East.function([TasksV2Type], IntegerType, ($, rows) => rows.size()));
|
|
527
|
-
pkg = e3.package(name, version, customers,
|
|
672
|
+
pkg = e3.package(name, version, customers, count);
|
|
528
673
|
}
|
|
529
674
|
const zipPath = join(tempDir, `${name}-${version}.zip`);
|
|
530
675
|
await e3.export(pkg, zipPath);
|