@elaraai/e3-types 1.0.96 → 1.0.98
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/dist/src/api.d.ts +15 -4
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/api.js +15 -4
- package/dist/src/api.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/record.d.ts +111 -13
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/record.js +90 -3
- package/dist/src/record.js.map +1 -1
- package/dist/src/record.spec.js +47 -9
- package/dist/src/record.spec.js.map +1 -1
- package/dist/src/release.d.ts +1 -1
- package/dist/src/release.js +1 -1
- package/package.json +2 -2
- package/src/api.ts +15 -4
- package/src/index.ts +7 -0
- package/src/record.spec.ts +59 -8
- package/src/record.ts +104 -4
- package/src/release.ts +1 -1
package/src/record.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
|
-
ArrayType, BooleanType, DateTimeType, DictType, EastTypeType, FunctionType, NullType,
|
|
22
|
+
ArrayType, BooleanType, DateTimeType, DictType, EastTypeType, FunctionType, IntegerType, NullType,
|
|
23
23
|
OptionType, PatchType, StringType, StructType, VariantType,
|
|
24
24
|
decodeBeast2For, dictPatchOpsType, setPatchOpsType, toEastTypeValue,
|
|
25
25
|
type EastType, type EastTypeValue, type PatchTypeOf, type ValueTypeOf,
|
|
@@ -163,6 +163,50 @@ export function decodeMutationObject(data: Uint8Array): MutationObject {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
/**
|
|
167
|
+
* What a summary index holds for one of its keys (#1039): how many rows touch
|
|
168
|
+
* the key's period, and the milliseconds of the period they cover between
|
|
169
|
+
* them.
|
|
170
|
+
*
|
|
171
|
+
* @remarks
|
|
172
|
+
* Both are Integers, so a total kept write by write is exactly the total a
|
|
173
|
+
* rebuild sums: Integer addition is associative, where a Float sum depends on
|
|
174
|
+
* the order of its additions. A key is held only while its count is positive,
|
|
175
|
+
* so an emptied period leaves the summary as a rebuild would, and the count
|
|
176
|
+
* is what tells e3 a period has emptied.
|
|
177
|
+
*
|
|
178
|
+
* @property count - How many rows touch the period
|
|
179
|
+
* @property ms - The milliseconds of the period they cover, summed over them
|
|
180
|
+
*/
|
|
181
|
+
export const RecordSummaryTotalsType = StructType({
|
|
182
|
+
count: IntegerType,
|
|
183
|
+
ms: IntegerType,
|
|
184
|
+
});
|
|
185
|
+
export type RecordSummaryTotalsType = typeof RecordSummaryTotalsType;
|
|
186
|
+
export type RecordSummaryTotals = ValueTypeOf<typeof RecordSummaryTotalsType>;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Which collection an index builds (#1039).
|
|
190
|
+
*
|
|
191
|
+
* - `entries` — an entry per index key a row has, `Dict<{ik, k}, P>`: the
|
|
192
|
+
* index every constructor but the summary's declares.
|
|
193
|
+
* - `summary` — one entry per index key, standing for every row that has it,
|
|
194
|
+
* `Dict<{ik, k: Null}, Totals>` ({@link RecordSummaryTotalsType}): the
|
|
195
|
+
* rows' totals per period, which a write changes by adding to them. Its
|
|
196
|
+
* build's pieces hold the same keys, so it names the merge that sums them,
|
|
197
|
+
* `mergeIr`, a `({ik, k}, Totals, Totals) -> Totals` IR bundle.
|
|
198
|
+
*
|
|
199
|
+
* @remarks
|
|
200
|
+
* A variant, so an index object decodes only with one of these: a collection
|
|
201
|
+
* this e3 does not know is refused where the object is read.
|
|
202
|
+
*/
|
|
203
|
+
export const RecordIndexFormType = VariantType({
|
|
204
|
+
entries: NullType,
|
|
205
|
+
summary: StructType({ mergeIr: StringType }),
|
|
206
|
+
});
|
|
207
|
+
export type RecordIndexFormType = typeof RecordIndexFormType;
|
|
208
|
+
export type RecordIndexForm = ValueTypeOf<typeof RecordIndexFormType>;
|
|
209
|
+
|
|
166
210
|
/**
|
|
167
211
|
* A secondary index over a record: an East function of an entry, and the
|
|
168
212
|
* collection it builds.
|
|
@@ -196,6 +240,11 @@ export const RecordIndexObjectType = StructType({
|
|
|
196
240
|
buildIr: StringType,
|
|
197
241
|
/** Author-chosen runtime the index's functions run on. */
|
|
198
242
|
runner: RunnerType,
|
|
243
|
+
/** Which collection it builds: an entry per key a row has, or a summary's
|
|
244
|
+
* totals per key ({@link RecordIndexFormType}). A summary's `keyIr` is
|
|
245
|
+
* `(K, V) -> Dict<IK, Totals>`, a row's contribution to each of its keys,
|
|
246
|
+
* and its `valueType` is {@link RecordSummaryTotalsType}. */
|
|
247
|
+
form: RecordIndexFormType,
|
|
199
248
|
});
|
|
200
249
|
export type RecordIndexObjectType = typeof RecordIndexObjectType;
|
|
201
250
|
export type RecordIndexObject = ValueTypeOf<typeof RecordIndexObjectType>;
|
|
@@ -424,7 +473,9 @@ export function isRecordStateType(typeValue: EastTypeValue, value?: unknown): bo
|
|
|
424
473
|
* @remarks
|
|
425
474
|
* `ik` first, so every entry with one index key is a contiguous run — ordered
|
|
426
475
|
* by primary key inside it — and a RANGE of index keys is one contiguous run
|
|
427
|
-
* too. `k` makes the entry unique and gives the run its inner order.
|
|
476
|
+
* too. `k` makes the entry unique and gives the run its inner order. A
|
|
477
|
+
* summary's entry stands for every row of its key, so its `k` is Null and its
|
|
478
|
+
* value its totals: `indexCollectionType(NullType, IK, RecordSummaryTotalsType)`.
|
|
428
479
|
*
|
|
429
480
|
* @param keyType - the record's primary key type, `K`
|
|
430
481
|
* @param indexKeyType - the index key the function computes, `IK`
|
|
@@ -459,15 +510,36 @@ export function patchOpsType(collectionType: EastType): EastType {
|
|
|
459
510
|
);
|
|
460
511
|
}
|
|
461
512
|
|
|
513
|
+
/**
|
|
514
|
+
* The op a summary index's arm of a mutation delta carries for one of its keys
|
|
515
|
+
* (#1039): `add`, the change to the key's totals — what the write's rows took
|
|
516
|
+
* away from it and gave it, summed.
|
|
517
|
+
*
|
|
518
|
+
* @remarks
|
|
519
|
+
* A write's program reads the record, never its indexes, so it cannot say
|
|
520
|
+
* what a summary's total becomes; it says what changed, and the apply adds it
|
|
521
|
+
* to the total the summary holds. Its parts may be negative. A key the summary
|
|
522
|
+
* does not hold is inserted with it, and a total whose count it brings to zero
|
|
523
|
+
* is deleted (see `e3-core`'s `record-apply.ts`).
|
|
524
|
+
*
|
|
525
|
+
* @property add - The change to the key's totals
|
|
526
|
+
*/
|
|
527
|
+
export const RecordSummaryOpType = VariantType({ add: RecordSummaryTotalsType });
|
|
528
|
+
export type RecordSummaryOpType = typeof RecordSummaryOpType;
|
|
529
|
+
export type RecordSummaryOp = ValueTypeOf<typeof RecordSummaryOpType>;
|
|
530
|
+
|
|
462
531
|
/** One target of a mutation delta: its name, its key and its op type. */
|
|
463
532
|
export interface DeltaTarget {
|
|
464
533
|
/** `primary`, or an index name. */
|
|
465
534
|
name: string;
|
|
466
535
|
/** The key the target is addressed by — `K` for the primary, `{ik, k}` for
|
|
467
|
-
* an index. */
|
|
536
|
+
* an index, `{ik, k: Null}` for a summary. */
|
|
468
537
|
keyType: EastType;
|
|
469
538
|
/** The target's own collection type, whose patch ops the arm carries. */
|
|
470
539
|
collectionType: EastType;
|
|
540
|
+
/** Whether the target is a summary index, whose arm carries
|
|
541
|
+
* {@link RecordSummaryOpType}'s `add` rather than its collection's patch ops. */
|
|
542
|
+
summary?: boolean;
|
|
471
543
|
}
|
|
472
544
|
|
|
473
545
|
/**
|
|
@@ -511,7 +583,7 @@ export function mutationDeltaType(targets: readonly DeltaTarget[]): EastType {
|
|
|
511
583
|
const ops: Record<string, EastType> = { [DELTA_CONFLICT]: NullType };
|
|
512
584
|
for (const target of targets) {
|
|
513
585
|
keys[target.name] = target.keyType;
|
|
514
|
-
ops[target.name] = patchOpsType(target.collectionType);
|
|
586
|
+
ops[target.name] = target.summary === true ? RecordSummaryOpType : patchOpsType(target.collectionType);
|
|
515
587
|
}
|
|
516
588
|
return DictType(VariantType(keys), VariantType(ops));
|
|
517
589
|
}
|
|
@@ -585,3 +657,31 @@ export function indexWindowType(keyType: EastType, indexKeyType: EastType, value
|
|
|
585
657
|
row: OptionType(rowType),
|
|
586
658
|
}));
|
|
587
659
|
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* What a read of a Dict's rows by key answers (#1351): one entry per key
|
|
663
|
+
* asked, in the order asked — an ORDERED array, as an index window is.
|
|
664
|
+
*
|
|
665
|
+
* @remarks
|
|
666
|
+
* Each entry says whether the Dict holds the key — its row, or none — and
|
|
667
|
+
* where the key sits in the Dict's canonical order: the row's position, the
|
|
668
|
+
* same row space a page's element windows address, or, for a key it does not
|
|
669
|
+
* hold, the position the key would take. So a client holds each row at its
|
|
670
|
+
* position, and answers a later search by the key, and a one-row page there,
|
|
671
|
+
* from what it holds.
|
|
672
|
+
*
|
|
673
|
+
* @param keyType - The Dict's key type, `K`
|
|
674
|
+
* @param rowType - Its value type, `V`
|
|
675
|
+
* @returns The answer's East type
|
|
676
|
+
*/
|
|
677
|
+
export function datasetRowsType(keyType: EastType, rowType: EastType): EastType {
|
|
678
|
+
return ArrayType(StructType({
|
|
679
|
+
/** The key asked: the stored key when the Dict holds it. */
|
|
680
|
+
key: keyType,
|
|
681
|
+
/** The row the Dict holds under it, or none. */
|
|
682
|
+
row: OptionType(rowType),
|
|
683
|
+
/** Its position in the Dict's canonical order: the row's, or the one the
|
|
684
|
+
* key would take. */
|
|
685
|
+
position: IntegerType,
|
|
686
|
+
}));
|
|
687
|
+
}
|
package/src/release.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/** The release of e3 this build is. */
|
|
20
|
-
export const E3_RELEASE = '1.0.
|
|
20
|
+
export const E3_RELEASE = '1.0.98';
|
|
21
21
|
|
|
22
22
|
/** A semantic version: its core, a pre-release, and build metadata. */
|
|
23
23
|
const RELEASE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|