@elaraai/e3-types 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 +3 -1
- package/dist/src/api.d.ts +88 -66
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/api.js +45 -30
- package/dist/src/api.js.map +1 -1
- package/dist/src/bundle.d.ts +366 -0
- package/dist/src/bundle.d.ts.map +1 -0
- package/dist/src/bundle.js +66 -0
- package/dist/src/bundle.js.map +1 -0
- package/dist/src/dataset-type.d.ts +5 -5
- package/dist/src/dataset-type.js +5 -5
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/record.d.ts +449 -20
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/record.js +270 -16
- package/dist/src/record.js.map +1 -1
- package/dist/src/record.spec.js +48 -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/dist/src/structure.d.ts.map +1 -1
- package/dist/src/structure.js +1 -8
- package/dist/src/structure.js.map +1 -1
- package/package.json +2 -2
- package/src/api.ts +45 -30
- package/src/bundle.ts +76 -0
- package/src/dataset-type.ts +5 -5
- package/src/index.ts +36 -0
- package/src/record.spec.ts +60 -8
- package/src/record.ts +310 -17
- package/src/release.ts +1 -1
- package/src/structure.ts +1 -7
package/src/api.ts
CHANGED
|
@@ -51,7 +51,7 @@ export const WorkspaceNotDeployedErrorType = StructType({ workspace: StringType
|
|
|
51
51
|
export const WorkspaceExistsErrorType = StructType({ workspace: StringType });
|
|
52
52
|
export const LockHolderType = StructType({
|
|
53
53
|
pid: IntegerType,
|
|
54
|
-
acquiredAt:
|
|
54
|
+
acquiredAt: DateTimeType,
|
|
55
55
|
bootId: OptionType(StringType),
|
|
56
56
|
command: OptionType(StringType),
|
|
57
57
|
});
|
|
@@ -65,6 +65,9 @@ export const PackageNotFoundErrorType = StructType({
|
|
|
65
65
|
});
|
|
66
66
|
export const PackageExistsErrorType = StructType({ packageName: StringType, version: StringType });
|
|
67
67
|
export const PackageInvalidErrorType = StructType({ reason: StringType });
|
|
68
|
+
/** A workspace bundle refused: it is not one, it is cut short, or it does not
|
|
69
|
+
* hold every object its workspace names. */
|
|
70
|
+
export const BundleInvalidErrorType = StructType({ reason: StringType });
|
|
68
71
|
export const DatasetNotFoundErrorType = StructType({ workspace: StringType, path: StringType });
|
|
69
72
|
export const TaskNotFoundErrorType = StructType({ task: StringType });
|
|
70
73
|
export const ExecutionNotFoundErrorType = StructType({ task: StringType });
|
|
@@ -99,6 +102,7 @@ export const ErrorType = VariantType({
|
|
|
99
102
|
package_not_found: PackageNotFoundErrorType,
|
|
100
103
|
package_exists: PackageExistsErrorType,
|
|
101
104
|
package_invalid: PackageInvalidErrorType,
|
|
105
|
+
bundle_invalid: BundleInvalidErrorType,
|
|
102
106
|
dataset_not_found: DatasetNotFoundErrorType,
|
|
103
107
|
task_not_found: TaskNotFoundErrorType,
|
|
104
108
|
execution_not_found: ExecutionNotFoundErrorType,
|
|
@@ -591,32 +595,32 @@ export const TaskStatusWaitingType = StructType({ reason: StringType });
|
|
|
591
595
|
export const TaskStatusInProgressType = StructType({
|
|
592
596
|
/** Process ID of the running task */
|
|
593
597
|
pid: OptionType(IntegerType),
|
|
594
|
-
/**
|
|
595
|
-
startedAt: OptionType(
|
|
598
|
+
/** When execution started */
|
|
599
|
+
startedAt: OptionType(DateTimeType),
|
|
596
600
|
});
|
|
597
601
|
|
|
598
602
|
/** Task exited with non-zero code. */
|
|
599
603
|
export const TaskStatusFailedType = StructType({
|
|
600
604
|
/** Process exit code */
|
|
601
605
|
exitCode: IntegerType,
|
|
602
|
-
/**
|
|
603
|
-
completedAt: OptionType(
|
|
606
|
+
/** When the task completed */
|
|
607
|
+
completedAt: OptionType(DateTimeType),
|
|
604
608
|
});
|
|
605
609
|
|
|
606
610
|
/** Task encountered an internal error. */
|
|
607
611
|
export const TaskStatusErrorType = StructType({
|
|
608
612
|
/** Error message */
|
|
609
613
|
message: StringType,
|
|
610
|
-
/**
|
|
611
|
-
completedAt: OptionType(
|
|
614
|
+
/** When the error occurred */
|
|
615
|
+
completedAt: OptionType(DateTimeType),
|
|
612
616
|
});
|
|
613
617
|
|
|
614
618
|
/** Task was running but process is no longer alive. */
|
|
615
619
|
export const TaskStatusStaleRunningType = StructType({
|
|
616
620
|
/** Last known process ID */
|
|
617
621
|
pid: OptionType(IntegerType),
|
|
618
|
-
/**
|
|
619
|
-
startedAt: OptionType(
|
|
622
|
+
/** When execution started */
|
|
623
|
+
startedAt: OptionType(DateTimeType),
|
|
620
624
|
});
|
|
621
625
|
|
|
622
626
|
/**
|
|
@@ -889,37 +893,37 @@ export const DataflowResultType = StructType({
|
|
|
889
893
|
export const DataflowEventType = VariantType({
|
|
890
894
|
start: StructType({
|
|
891
895
|
task: StringType,
|
|
892
|
-
timestamp:
|
|
896
|
+
timestamp: DateTimeType,
|
|
893
897
|
}),
|
|
894
898
|
complete: StructType({
|
|
895
899
|
task: StringType,
|
|
896
|
-
timestamp:
|
|
900
|
+
timestamp: DateTimeType,
|
|
897
901
|
duration: FloatType,
|
|
898
902
|
peakBytes: OptionType(IntegerType),
|
|
899
903
|
}),
|
|
900
904
|
cached: StructType({
|
|
901
905
|
task: StringType,
|
|
902
|
-
timestamp:
|
|
906
|
+
timestamp: DateTimeType,
|
|
903
907
|
}),
|
|
904
908
|
failed: StructType({
|
|
905
909
|
task: StringType,
|
|
906
|
-
timestamp:
|
|
910
|
+
timestamp: DateTimeType,
|
|
907
911
|
duration: FloatType,
|
|
908
912
|
exitCode: IntegerType,
|
|
909
913
|
}),
|
|
910
914
|
error: StructType({
|
|
911
915
|
task: StringType,
|
|
912
|
-
timestamp:
|
|
916
|
+
timestamp: DateTimeType,
|
|
913
917
|
message: StringType,
|
|
914
918
|
}),
|
|
915
919
|
input_unavailable: StructType({
|
|
916
920
|
task: StringType,
|
|
917
|
-
timestamp:
|
|
921
|
+
timestamp: DateTimeType,
|
|
918
922
|
reason: StringType,
|
|
919
923
|
}),
|
|
920
924
|
requeued: StructType({
|
|
921
925
|
task: StringType,
|
|
922
|
-
timestamp:
|
|
926
|
+
timestamp: DateTimeType,
|
|
923
927
|
unit: StageUnitType,
|
|
924
928
|
reason: RequeueReasonType,
|
|
925
929
|
peak: IntegerType,
|
|
@@ -931,12 +935,16 @@ export const DataflowEventType = VariantType({
|
|
|
931
935
|
* Execution status for API polling responses.
|
|
932
936
|
*
|
|
933
937
|
* - `running`: Execution is in progress
|
|
934
|
-
* - `stopping`: Execution
|
|
935
|
-
*
|
|
938
|
+
* - `stopping`: Execution holds its workspace and is letting it go: it was
|
|
939
|
+
* asked to stop and its tasks have not all stopped yet, or it has ended —
|
|
940
|
+
* its summary given — and has not yet let the workspace go
|
|
936
941
|
* - `completed`: Execution finished successfully
|
|
937
942
|
* - `failed`: Execution finished with failures
|
|
938
943
|
* - `aborted`: Execution was cancelled
|
|
939
944
|
*
|
|
945
|
+
* A run answered `completed`, `failed` or `aborted` has let its workspace go,
|
|
946
|
+
* so a gc, a deploy or a run asked of next takes it.
|
|
947
|
+
*
|
|
940
948
|
* `stopping` is named to sort after every case before it, so its tag is the
|
|
941
949
|
* last and a poll a server answered before it read as itself.
|
|
942
950
|
*
|
|
@@ -997,13 +1005,13 @@ export const DataflowBudgetType = StructType({
|
|
|
997
1005
|
* @property unit - The unit, for a split task's; `none` for a task run as one
|
|
998
1006
|
* @property needs - The memory, in bytes, it waits to reserve; 0 when it
|
|
999
1007
|
* waits for a core alone
|
|
1000
|
-
* @property since -
|
|
1008
|
+
* @property since - When it began waiting
|
|
1001
1009
|
*/
|
|
1002
1010
|
export const UnitWaitType = StructType({
|
|
1003
1011
|
task: StringType,
|
|
1004
1012
|
unit: OptionType(StageUnitType),
|
|
1005
1013
|
needs: IntegerType,
|
|
1006
|
-
since:
|
|
1014
|
+
since: DateTimeType,
|
|
1007
1015
|
});
|
|
1008
1016
|
|
|
1009
1017
|
/**
|
|
@@ -1047,8 +1055,8 @@ export const SplitProgressType = StructType({
|
|
|
1047
1055
|
*
|
|
1048
1056
|
* @property runId - The run's id, a UUIDv7
|
|
1049
1057
|
* @property status - Current execution status
|
|
1050
|
-
* @property startedAt -
|
|
1051
|
-
* @property completedAt -
|
|
1058
|
+
* @property startedAt - When execution started
|
|
1059
|
+
* @property completedAt - When execution finished (if done)
|
|
1052
1060
|
* @property summary - Execution summary (available when complete)
|
|
1053
1061
|
* @property events - The run's task events past the poll's cursor, at most
|
|
1054
1062
|
* its limit, in the order they happened
|
|
@@ -1067,8 +1075,8 @@ export const SplitProgressType = StructType({
|
|
|
1067
1075
|
export const ApiDataflowExecutionStateType = StructType({
|
|
1068
1076
|
runId: StringType,
|
|
1069
1077
|
status: ApiExecutionStatusType,
|
|
1070
|
-
startedAt:
|
|
1071
|
-
completedAt: OptionType(
|
|
1078
|
+
startedAt: DateTimeType,
|
|
1079
|
+
completedAt: OptionType(DateTimeType),
|
|
1072
1080
|
summary: OptionType(DataflowExecutionSummaryType),
|
|
1073
1081
|
events: ArrayType(DataflowEventType),
|
|
1074
1082
|
nextSeq: IntegerType,
|
|
@@ -1114,8 +1122,8 @@ export const ExecutionHistoryStatusType = VariantType({
|
|
|
1114
1122
|
* before the last one's
|
|
1115
1123
|
* @property inputHashes - Individual input object hashes
|
|
1116
1124
|
* @property status - Execution outcome
|
|
1117
|
-
* @property startedAt -
|
|
1118
|
-
* @property completedAt -
|
|
1125
|
+
* @property startedAt - When execution started
|
|
1126
|
+
* @property completedAt - When execution finished (if done)
|
|
1119
1127
|
* @property duration - Execution duration in milliseconds (if done)
|
|
1120
1128
|
* @property exitCode - Process exit code (if failed)
|
|
1121
1129
|
* @property peakBytes - The highest peak resident memory, in bytes, a runner
|
|
@@ -1127,8 +1135,8 @@ export const ExecutionListItemType = StructType({
|
|
|
1127
1135
|
executionId: StringType,
|
|
1128
1136
|
inputHashes: ArrayType(StringType),
|
|
1129
1137
|
status: ExecutionHistoryStatusType,
|
|
1130
|
-
startedAt:
|
|
1131
|
-
completedAt: OptionType(
|
|
1138
|
+
startedAt: DateTimeType,
|
|
1139
|
+
completedAt: OptionType(DateTimeType),
|
|
1132
1140
|
duration: OptionType(IntegerType),
|
|
1133
1141
|
exitCode: OptionType(IntegerType),
|
|
1134
1142
|
peakBytes: OptionType(IntegerType),
|
|
@@ -1470,16 +1478,23 @@ export const RecordSignatureType = StructType({
|
|
|
1470
1478
|
})),
|
|
1471
1479
|
/** The indexes the record declares. A page read through one is decoded by
|
|
1472
1480
|
* `indexWindowType(K, keyType, valueType, V)` over the record's
|
|
1473
|
-
* `Dict<K, V
|
|
1481
|
+
* `Dict<K, V>` — a summary's by `indexWindowType(Null, keyType, valueType,
|
|
1482
|
+
* V)`, its entries naming no row — and a key search through one takes a
|
|
1483
|
+
* `keyType` key. */
|
|
1474
1484
|
indexes: ArrayType(StructType({
|
|
1475
1485
|
name: StringType,
|
|
1476
1486
|
/** The index key's type. */
|
|
1477
1487
|
keyType: EastTypeType,
|
|
1478
1488
|
/** The covering projection's type: `Null` when the index projects
|
|
1479
|
-
* nothing, and a read joins the rows instead
|
|
1489
|
+
* nothing, and a read joins the rows instead; a summary's totals,
|
|
1490
|
+
* `{ count, ms }`. */
|
|
1480
1491
|
valueType: EastTypeType,
|
|
1481
1492
|
/** Whether a row may hold several index keys. */
|
|
1482
1493
|
multi: BooleanType,
|
|
1494
|
+
/** Whether it is a summary (#1039): each entry stands for every row of
|
|
1495
|
+
* its key, its `k` Null and its value the totals, so a read through it
|
|
1496
|
+
* is never joined. */
|
|
1497
|
+
summary: BooleanType,
|
|
1483
1498
|
/** Whether the record's head state holds the index, built under the
|
|
1484
1499
|
* declaration the deployed package carries. A deploy, a reindex and a
|
|
1485
1500
|
* system commit build what the state lacks; a read through an index the
|
package/src/bundle.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A workspace bundle: a workspace as it is, in one stream of beast2, which a
|
|
8
|
+
* repository in any store makes a workspace from — the package deployed to
|
|
9
|
+
* it, every dataset's ref, the executions its tasks' outputs come from, and
|
|
10
|
+
* every object they reach.
|
|
11
|
+
*
|
|
12
|
+
* A bundle is a {@link WorkspaceBundleType}, written an entry at a time and
|
|
13
|
+
* read a segment at a time (East's `Beast2ElementWriter` and
|
|
14
|
+
* `decodeBeast2ElementsFor`), so a bundle of any size is written and read in
|
|
15
|
+
* the memory of a few entries. Its first entry is the workspace's, and every
|
|
16
|
+
* entry after it is an object, or a piece of one. Its type is in its header,
|
|
17
|
+
* as every beast2 value's is, so a reader refuses a bundle of another form
|
|
18
|
+
* naming both, and a new kind of entry is one more case.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { ArrayType, BlobType, DateTimeType, DictType, StringType, StructType, VariantType, type ValueTypeOf } from '@elaraai/east';
|
|
22
|
+
import { DatasetRefType } from './dataset-ref.js';
|
|
23
|
+
import { ExecutionStatusType } from './execution.js';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* What a bundle says of its workspace, ahead of any object.
|
|
27
|
+
*/
|
|
28
|
+
export const WorkspaceBundleHeadType = StructType({
|
|
29
|
+
/** The package deployed to the workspace: its name and version, and its
|
|
30
|
+
* object */
|
|
31
|
+
package: StructType({
|
|
32
|
+
name: StringType,
|
|
33
|
+
version: StringType,
|
|
34
|
+
hash: StringType,
|
|
35
|
+
}),
|
|
36
|
+
/** When the package was deployed */
|
|
37
|
+
deployedAt: DateTimeType,
|
|
38
|
+
/** Every dataset's ref, by the path its store keys it by (`inputs/sales`):
|
|
39
|
+
* a record's state and the head of its history among them */
|
|
40
|
+
datasets: DictType(StringType, DatasetRefType),
|
|
41
|
+
/** The executions the tasks' outputs come from: each task's latest attempt
|
|
42
|
+
* over its current inputs, where it succeeded and made the output the
|
|
43
|
+
* workspace holds */
|
|
44
|
+
executions: ArrayType(StructType({
|
|
45
|
+
/** The task object's hash */
|
|
46
|
+
taskHash: StringType,
|
|
47
|
+
/** The hash of the inputs it ran over */
|
|
48
|
+
inputsHash: StringType,
|
|
49
|
+
/** Its record, which names its id */
|
|
50
|
+
status: ExecutionStatusType,
|
|
51
|
+
})),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export type WorkspaceBundleHead = ValueTypeOf<typeof WorkspaceBundleHeadType>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* An entry of a bundle.
|
|
58
|
+
*/
|
|
59
|
+
export const WorkspaceBundleEntryType = VariantType({
|
|
60
|
+
/** The workspace: a bundle's first entry, and its only one of this kind */
|
|
61
|
+
workspace: WorkspaceBundleHeadType,
|
|
62
|
+
/** An object's bytes: the whole object, or the last of its pieces */
|
|
63
|
+
object: BlobType,
|
|
64
|
+
/** A piece of an object too large for one entry: the object goes on in the
|
|
65
|
+
* entries after it, and ends at an `object` */
|
|
66
|
+
piece: BlobType,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export type WorkspaceBundleEntry = ValueTypeOf<typeof WorkspaceBundleEntryType>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A workspace bundle: its entries, in order.
|
|
73
|
+
*/
|
|
74
|
+
export const WorkspaceBundleType = ArrayType(WorkspaceBundleEntryType);
|
|
75
|
+
|
|
76
|
+
export type WorkspaceBundle = ValueTypeOf<typeof WorkspaceBundleType>;
|
package/src/dataset-type.ts
CHANGED
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
*
|
|
29
29
|
* **Read by structure.** The bytes may come from another build than the
|
|
30
30
|
* package's — an app's UI deployed apart from its package, any client — and
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* id
|
|
34
|
-
*
|
|
35
|
-
* component's.
|
|
31
|
+
* the package may be an earlier release's, which numbered its recursive types
|
|
32
|
+
* by its process's counter, so a recursive type edited between two of its
|
|
33
|
+
* exports could keep its id. `isTypeValueEqual` takes one id as one type
|
|
34
|
+
* without reading it; `isTypeValueStructurallyEqual`, the relation here, reads
|
|
35
|
+
* it, at under a millisecond for a type as large as a UI component's.
|
|
36
36
|
*
|
|
37
37
|
* @packageDocumentation
|
|
38
38
|
*/
|
package/src/index.ts
CHANGED
|
@@ -124,12 +124,37 @@ export {
|
|
|
124
124
|
RecordIndexObjectType,
|
|
125
125
|
type RecordIndexObject,
|
|
126
126
|
decodeRecordIndexObject,
|
|
127
|
+
RecordIndexFormType,
|
|
128
|
+
type RecordIndexForm,
|
|
129
|
+
RecordSummaryTotalsType,
|
|
130
|
+
type RecordSummaryTotals,
|
|
131
|
+
RecordLevelType,
|
|
132
|
+
type RecordLevel,
|
|
133
|
+
RecordRollupType,
|
|
134
|
+
type RecordRollup,
|
|
135
|
+
RecordNestedRunType,
|
|
136
|
+
type RecordNestedRun,
|
|
137
|
+
RecordNestedPathType,
|
|
138
|
+
type RecordNestedPath,
|
|
139
|
+
RecordNestedItemType,
|
|
140
|
+
type RecordNestedItem,
|
|
141
|
+
NestedEntryKeyType,
|
|
142
|
+
NestedSpanKeyType,
|
|
143
|
+
nestedSpanName,
|
|
144
|
+
RecordNestedTotalsType,
|
|
145
|
+
type RecordNestedTotals,
|
|
146
|
+
NestedEntryType,
|
|
147
|
+
RecordNestedDeclType,
|
|
148
|
+
type RecordNestedDecl,
|
|
149
|
+
RecordSummaryOpType,
|
|
150
|
+
type RecordSummaryOp,
|
|
127
151
|
RECORD_STATE_KIND,
|
|
128
152
|
RecordStateType,
|
|
129
153
|
type RecordState,
|
|
130
154
|
isRecordStateType,
|
|
131
155
|
indexCollectionType,
|
|
132
156
|
indexWindowType,
|
|
157
|
+
datasetRowsType,
|
|
133
158
|
decodeRecordCommit,
|
|
134
159
|
decodeMutationObject,
|
|
135
160
|
MutationFormType,
|
|
@@ -184,6 +209,16 @@ export {
|
|
|
184
209
|
type WorkspaceRecord,
|
|
185
210
|
} from './workspace.js';
|
|
186
211
|
|
|
212
|
+
// A workspace as it is, in one stream
|
|
213
|
+
export {
|
|
214
|
+
WorkspaceBundleHeadType,
|
|
215
|
+
type WorkspaceBundleHead,
|
|
216
|
+
WorkspaceBundleEntryType,
|
|
217
|
+
type WorkspaceBundleEntry,
|
|
218
|
+
WorkspaceBundleType,
|
|
219
|
+
type WorkspaceBundle,
|
|
220
|
+
} from './bundle.js';
|
|
221
|
+
|
|
187
222
|
// Execution status
|
|
188
223
|
export {
|
|
189
224
|
StopReasonType,
|
|
@@ -310,6 +345,7 @@ export {
|
|
|
310
345
|
PackageNotFoundErrorType,
|
|
311
346
|
PackageExistsErrorType,
|
|
312
347
|
PackageInvalidErrorType,
|
|
348
|
+
BundleInvalidErrorType,
|
|
313
349
|
DatasetNotFoundErrorType,
|
|
314
350
|
TaskNotFoundErrorType,
|
|
315
351
|
ExecutionNotFoundErrorType,
|
package/src/record.spec.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { describe, it } from 'node:test';
|
|
14
14
|
import assert from 'node:assert/strict';
|
|
15
|
-
import { BooleanType, DateTimeType, DictType, IntegerType, OptionType, StringType, StructType, ArrayType, EastTypeType, VariantType, encodeBeast2For, isTypeValueEqual, some, toEastTypeValue, variant } from '@elaraai/east';
|
|
15
|
+
import { BooleanType, DateTimeType, DictType, IntegerType, NullType, OptionType, StringType, StructType, ArrayType, EastTypeType, VariantType, dictPatchOpsType, encodeBeast2For, isTypeEqual, isTypeValueEqual, none, some, toEastTypeValue, variant, type EastType } from '@elaraai/east';
|
|
16
16
|
import { RunnerType } from './runner.js';
|
|
17
17
|
import {
|
|
18
18
|
MigrationObjectType,
|
|
@@ -20,11 +20,15 @@ import {
|
|
|
20
20
|
RecordCommitType,
|
|
21
21
|
RecordIndexObjectType,
|
|
22
22
|
RecordObjectType,
|
|
23
|
+
RecordSummaryOpType,
|
|
24
|
+
RecordSummaryTotalsType,
|
|
23
25
|
decodeMigrationObject,
|
|
24
26
|
decodeMutationObject,
|
|
25
27
|
decodeRecordCommit,
|
|
26
28
|
decodeRecordIndexObject,
|
|
27
29
|
decodeRecordObject,
|
|
30
|
+
indexCollectionType,
|
|
31
|
+
mutationDeltaType,
|
|
28
32
|
type MigrationObject,
|
|
29
33
|
type MutationObject,
|
|
30
34
|
type RecordCommit,
|
|
@@ -125,17 +129,47 @@ describe('decodeRecordIndexObject', () => {
|
|
|
125
129
|
valueType: toEastTypeValue(IntegerType),
|
|
126
130
|
buildIr: 'c'.repeat(64),
|
|
127
131
|
runner: variant('east_node', { platforms: ['@elaraai/east-node-std'], decode: variant('whole', null) }),
|
|
132
|
+
form: variant('entries', null),
|
|
128
133
|
};
|
|
129
134
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
assert.ok(isTypeValueEqual(decoded.
|
|
135
|
+
/** A decoded index object with its types checked off separately: a decoded
|
|
136
|
+
* type value carries no memoized identity, so only the East comparison
|
|
137
|
+
* says whether two of them are the same type. */
|
|
138
|
+
function read(bytes: Uint8Array, as: RecordIndexObject): Omit<RecordIndexObject, 'keyType' | 'valueType'> {
|
|
139
|
+
const decoded = decodeRecordIndexObject(bytes);
|
|
140
|
+
assert.ok(isTypeValueEqual(decoded.keyType, as.keyType));
|
|
141
|
+
assert.ok(isTypeValueEqual(decoded.valueType, as.valueType));
|
|
136
142
|
const { keyType: _keyType, valueType: _valueType, ...rest } = decoded;
|
|
143
|
+
return rest;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
it('round-trips a current index object, its types among it', () => {
|
|
137
147
|
const { keyType: _k, valueType: _v, ...expected } = index;
|
|
138
|
-
assert.deepEqual(
|
|
148
|
+
assert.deepEqual(read(encodeBeast2For(RecordIndexObjectType)(index), index), expected);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('round-trips a summary index object, the merge its build sums by among it (#1039)', () => {
|
|
152
|
+
const summary: RecordIndexObject = {
|
|
153
|
+
...index,
|
|
154
|
+
multi: true,
|
|
155
|
+
valueIr: none,
|
|
156
|
+
valueType: toEastTypeValue(RecordSummaryTotalsType),
|
|
157
|
+
form: variant('summary', { mergeIr: 'd'.repeat(64) }),
|
|
158
|
+
};
|
|
159
|
+
const { keyType: _k, valueType: _v, ...expected } = summary;
|
|
160
|
+
assert.deepEqual(read(encodeBeast2For(RecordIndexObjectType)(summary), summary), expected);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('refuses an index object an older SDK exported before it named its collection, naming the fix (#1039)', () => {
|
|
164
|
+
const PreFormIndexType = StructType({
|
|
165
|
+
keyIr: StringType, multi: BooleanType, valueIr: OptionType(StringType), keyType: EastTypeType,
|
|
166
|
+
valueType: EastTypeType, buildIr: StringType, runner: RunnerType,
|
|
167
|
+
});
|
|
168
|
+
const { form: _form, ...older } = index;
|
|
169
|
+
assert.throws(
|
|
170
|
+
() => decodeRecordIndexObject(encodeBeast2For(PreFormIndexType)(older)),
|
|
171
|
+
/^Error: the index object does not decode: the package was exported by an older e3 SDK — re-export it with the current one \(/,
|
|
172
|
+
);
|
|
139
173
|
});
|
|
140
174
|
|
|
141
175
|
it('refuses an index object whose runner predates its decode, naming the fix', () => {
|
|
@@ -159,6 +193,24 @@ describe('decodeRecordIndexObject', () => {
|
|
|
159
193
|
});
|
|
160
194
|
});
|
|
161
195
|
|
|
196
|
+
describe('mutationDeltaType', () => {
|
|
197
|
+
// A summary index's key: its leading fields under `on`, then a tile and a key (#1432).
|
|
198
|
+
const ik = StructType({ on: StructType({}), tile: DateTimeType, key: StringType });
|
|
199
|
+
const caseOf = (delta: EastType, part: 'key' | 'value', name: string): EastType =>
|
|
200
|
+
((delta as unknown as Record<'key' | 'value', { cases: Record<string, EastType> }>)[part]).cases[name]!;
|
|
201
|
+
|
|
202
|
+
it("carries a summary's changes as add ops, under its `{ik, k: Null}` keys, beside an index's patch ops (#1039)", () => {
|
|
203
|
+
const delta = mutationDeltaType([
|
|
204
|
+
{ name: 'primary', keyType: StringType, collectionType: DictType(StringType, IntegerType) },
|
|
205
|
+
{ name: 'jobs_by_press_month', keyType: StructType({ ik, k: NullType }), collectionType: indexCollectionType(NullType, ik, RecordSummaryTotalsType), summary: true },
|
|
206
|
+
{ name: 'jobs_by_press_week', keyType: StructType({ ik, k: StringType }), collectionType: indexCollectionType(StringType, ik, IntegerType) },
|
|
207
|
+
]);
|
|
208
|
+
assert.ok(isTypeEqual(caseOf(delta, 'value', 'jobs_by_press_month'), RecordSummaryOpType));
|
|
209
|
+
assert.ok(isTypeEqual(caseOf(delta, 'key', 'jobs_by_press_month'), StructType({ ik, k: NullType })));
|
|
210
|
+
assert.ok(isTypeEqual(caseOf(delta, 'value', 'jobs_by_press_week'), dictPatchOpsType(IntegerType)));
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
162
214
|
describe('decodeMigrationObject', () => {
|
|
163
215
|
const RowV1Type = StructType({ name: StringType });
|
|
164
216
|
const RowV2Type = StructType({ name: StringType, shift: IntegerType });
|