@elaraai/e3-types 1.0.79 → 1.0.81
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 -1
- package/dist/src/api.d.ts +829 -36
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/api.js +301 -32
- package/dist/src/api.js.map +1 -1
- package/dist/src/collection-manifest.d.ts +37 -0
- package/dist/src/collection-manifest.d.ts.map +1 -0
- package/dist/src/collection-manifest.js +37 -0
- package/dist/src/collection-manifest.js.map +1 -0
- package/dist/src/dataflow.d.ts +264 -19
- package/dist/src/dataflow.d.ts.map +1 -1
- package/dist/src/dataflow.js +156 -15
- package/dist/src/dataflow.js.map +1 -1
- package/dist/src/dataflow.spec.js +184 -27
- package/dist/src/dataflow.spec.js.map +1 -1
- package/dist/src/dataset-blob.d.ts +75 -15
- package/dist/src/dataset-blob.d.ts.map +1 -1
- package/dist/src/dataset-blob.js +95 -28
- package/dist/src/dataset-blob.js.map +1 -1
- package/dist/src/dataset-blob.spec.d.ts +6 -0
- package/dist/src/dataset-blob.spec.d.ts.map +1 -0
- package/dist/src/dataset-blob.spec.js +92 -0
- package/dist/src/dataset-blob.spec.js.map +1 -0
- package/dist/src/dataset-ref.d.ts +5 -4
- package/dist/src/dataset-ref.d.ts.map +1 -1
- package/dist/src/dataset-ref.js +5 -4
- package/dist/src/dataset-ref.js.map +1 -1
- package/dist/src/environment.d.ts +3 -2
- package/dist/src/environment.d.ts.map +1 -1
- package/dist/src/environment.js +3 -2
- package/dist/src/environment.js.map +1 -1
- package/dist/src/execution.d.ts +112 -18
- package/dist/src/execution.d.ts.map +1 -1
- package/dist/src/execution.js +174 -45
- package/dist/src/execution.js.map +1 -1
- package/dist/src/execution.spec.d.ts +6 -0
- package/dist/src/execution.spec.d.ts.map +1 -0
- package/dist/src/execution.spec.js +108 -0
- package/dist/src/execution.spec.js.map +1 -0
- package/dist/src/function.d.ts +14 -12
- package/dist/src/function.d.ts.map +1 -1
- package/dist/src/function.js +17 -32
- package/dist/src/function.js.map +1 -1
- package/dist/src/index.d.ts +17 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +28 -20
- package/dist/src/index.js.map +1 -1
- package/dist/src/intake.d.ts +75 -0
- package/dist/src/intake.d.ts.map +1 -0
- package/dist/src/intake.js +46 -0
- package/dist/src/intake.js.map +1 -0
- package/dist/src/lock.d.ts +253 -21
- package/dist/src/lock.d.ts.map +1 -1
- package/dist/src/lock.js +55 -21
- package/dist/src/lock.js.map +1 -1
- package/dist/src/names.d.ts +21 -0
- package/dist/src/names.d.ts.map +1 -0
- package/dist/src/names.js +31 -0
- package/dist/src/names.js.map +1 -0
- package/dist/src/package.d.ts +11 -78
- package/dist/src/package.d.ts.map +1 -1
- package/dist/src/package.js +13 -66
- package/dist/src/package.js.map +1 -1
- package/dist/src/record.d.ts +582 -18
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/record.js +405 -7
- package/dist/src/record.js.map +1 -1
- package/dist/src/{stream.spec.d.ts → record.spec.d.ts} +1 -1
- package/dist/src/record.spec.d.ts.map +1 -0
- package/dist/src/record.spec.js +143 -0
- package/dist/src/record.spec.js.map +1 -0
- package/dist/src/release.d.ts +36 -0
- package/dist/src/release.d.ts.map +1 -0
- package/dist/src/release.js +71 -0
- package/dist/src/release.js.map +1 -0
- package/dist/src/release.spec.d.ts +6 -0
- package/dist/src/release.spec.d.ts.map +1 -0
- package/dist/src/release.spec.js +42 -0
- package/dist/src/release.spec.js.map +1 -0
- package/dist/src/repository.d.ts +64 -0
- package/dist/src/repository.d.ts.map +1 -0
- package/dist/src/repository.js +49 -0
- package/dist/src/repository.js.map +1 -0
- package/dist/src/runner.d.ts +16 -62
- package/dist/src/runner.d.ts.map +1 -1
- package/dist/src/runner.js +16 -79
- package/dist/src/runner.js.map +1 -1
- package/dist/src/runner.spec.js +11 -85
- package/dist/src/runner.spec.js.map +1 -1
- package/dist/src/structure.d.ts +0 -57
- package/dist/src/structure.d.ts.map +1 -1
- package/dist/src/structure.js +0 -3
- package/dist/src/structure.js.map +1 -1
- package/dist/src/task.d.ts +210 -318
- package/dist/src/task.d.ts.map +1 -1
- package/dist/src/task.js +117 -472
- package/dist/src/task.js.map +1 -1
- package/dist/src/task.spec.js +62 -154
- package/dist/src/task.spec.js.map +1 -1
- package/dist/src/transfer.d.ts +38 -26
- package/dist/src/transfer.d.ts.map +1 -1
- package/dist/src/transfer.js +22 -26
- package/dist/src/transfer.js.map +1 -1
- package/dist/src/transfer.spec.js +4 -34
- package/dist/src/transfer.spec.js.map +1 -1
- package/dist/src/unit-plan.d.ts +130 -0
- package/dist/src/unit-plan.d.ts.map +1 -0
- package/dist/src/unit-plan.js +107 -0
- package/dist/src/unit-plan.js.map +1 -0
- package/dist/src/unit-plan.spec.d.ts +6 -0
- package/dist/src/unit-plan.spec.d.ts.map +1 -0
- package/dist/src/unit-plan.spec.js +29 -0
- package/dist/src/unit-plan.spec.js.map +1 -0
- package/dist/src/workspace.d.ts +22 -11
- package/dist/src/workspace.d.ts.map +1 -1
- package/dist/src/workspace.js +10 -11
- package/dist/src/workspace.js.map +1 -1
- package/package.json +3 -3
- package/src/api.ts +326 -32
- package/src/collection-manifest.ts +53 -0
- package/src/dataflow.spec.ts +223 -31
- package/src/dataflow.ts +183 -26
- package/src/dataset-blob.spec.ts +117 -0
- package/src/dataset-blob.ts +157 -21
- package/src/dataset-ref.ts +5 -4
- package/src/environment.ts +3 -2
- package/src/execution.spec.ts +114 -0
- package/src/execution.ts +175 -51
- package/src/function.ts +19 -32
- package/src/index.ts +141 -39
- package/src/intake.ts +53 -0
- package/src/lock.ts +67 -21
- package/src/names.ts +39 -0
- package/src/package.ts +15 -71
- package/src/record.spec.ts +195 -0
- package/src/record.ts +489 -7
- package/src/release.spec.ts +47 -0
- package/src/release.ts +69 -0
- package/src/repository.ts +67 -0
- package/src/runner.spec.ts +11 -94
- package/src/runner.ts +16 -80
- package/src/structure.ts +0 -8
- package/src/task.spec.ts +67 -188
- package/src/task.ts +140 -522
- package/src/transfer.spec.ts +4 -51
- package/src/transfer.ts +22 -26
- package/src/unit-plan.spec.ts +31 -0
- package/src/unit-plan.ts +121 -0
- package/src/workspace.ts +13 -11
- package/dist/src/stream.d.ts +0 -97
- package/dist/src/stream.d.ts.map +0 -1
- package/dist/src/stream.js +0 -134
- package/dist/src/stream.js.map +0 -1
- package/dist/src/stream.spec.d.ts.map +0 -1
- package/dist/src/stream.spec.js +0 -60
- package/dist/src/stream.spec.js.map +0 -1
- package/src/stream.spec.ts +0 -88
- package/src/stream.ts +0 -170
package/dist/src/task.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/task.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/task.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAe,eAAe,EAAE,MAAM,eAAe,CAAC;AACnI,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;qBACqB;AACrB,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAExC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;IACtC,IAAI,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACzC,OAAO,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;CAC/C,CAAC,CAAC;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,C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AkE;IAClE,MAAM,EAAE,SAAS,CAAC,aAAa,CAAC;IAChC,iDAAiD;IACjD,MAAM,EAAE,cAAc;IACtB,8BAA8B;IAC9B,IAAI,EAAE,YAAY;IAClB;uCACmC;IACnC,WAAW,EAAE,UAAU,CAAC,UAAU,CAAC;CACpC,CAAC,CAAC;AAKH,MAAM,iBAAiB,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAgB;IAC/C,IAAI,IAAgB,CAAC;IACrB,IAAI,CAAC;QACH,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,mHAAmH;YACnH,IAAI,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CACxD,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,iDAAiD,IAAI,CAAC,IAAI,WAAW,gBAAgB,GAAG,CAAC,CAAC;IAC5G,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/src/task.spec.js
CHANGED
|
@@ -3,167 +3,75 @@
|
|
|
3
3
|
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* metadata's merge fields and its triple decoder, the stream metadata's
|
|
8
|
-
* `merge` mode and its dual decoder, the partition plan round trip, and the
|
|
9
|
-
* `by` projection shapes the orchestrator evaluates by reading key fields
|
|
10
|
-
* instead of compiling the projection.
|
|
6
|
+
* Task object wire: the typed task object's round trip and its refusals.
|
|
11
7
|
*/
|
|
12
8
|
import { describe, it } from 'node:test';
|
|
13
9
|
import assert from 'node:assert/strict';
|
|
14
|
-
import { ArrayType, BlobType,
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
it('throws for bytes of no known metadata shape', () => {
|
|
64
|
-
assert.throws(() => decodeStreamTaskMetadata(encodeBeast2For(IntegerType)(7n)));
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
describe('PartitionPlanType', () => {
|
|
68
|
-
it('round-trips a plan, before and after its slices are carved and its merge ranges planned', () => {
|
|
69
|
-
const plan = {
|
|
70
|
-
partitions: ['a'.repeat(64), 'b'.repeat(64)],
|
|
71
|
-
boundaries: [0n, 4n, 9n],
|
|
72
|
-
splits: [[{ seg: 0n, offset: 0n }, { seg: 3n, offset: 17n }, { seg: 8n, offset: 0n }, { seg: 12n, offset: 0n }]],
|
|
73
|
-
slices: [],
|
|
74
|
-
merges: [],
|
|
75
|
-
};
|
|
76
|
-
assert.deepEqual(decodePartitionPlan(encodePartitionPlan(plan)), plan);
|
|
77
|
-
const carved = { ...plan, slices: [['c'.repeat(64), 'd'.repeat(64), 'e'.repeat(64)], ['f'.repeat(64), '0'.repeat(64), '1'.repeat(64)]] };
|
|
78
|
-
assert.deepEqual(decodePartitionPlan(encodePartitionPlan(carved)), carved);
|
|
79
|
-
const merged = {
|
|
80
|
-
...carved,
|
|
81
|
-
merges: [{ partials: ['2'.repeat(64), '3'.repeat(64)], ranges: ['4'.repeat(64), '5'.repeat(64)] }],
|
|
82
|
-
};
|
|
83
|
-
assert.deepEqual(decodePartitionPlan(encodePartitionPlan(merged)), merged);
|
|
84
|
-
});
|
|
85
|
-
it('decodes a plan recorded before merge ranges existed, with none', () => {
|
|
86
|
-
// The pre-`merges` wire shape, encoded directly.
|
|
87
|
-
const PreMergesPlanType = StructType({
|
|
88
|
-
partitions: ArrayType(StringType),
|
|
89
|
-
boundaries: ArrayType(IntegerType),
|
|
90
|
-
splits: ArrayType(ArrayType(StructType({ seg: IntegerType, offset: IntegerType }))),
|
|
91
|
-
slices: ArrayType(ArrayType(StringType)),
|
|
10
|
+
import { ArrayType, BlobType, IntegerType, OptionType, StringType, StructType, encodeBeast2For, none, some, variant } from '@elaraai/east';
|
|
11
|
+
import { TASK_OBJECT_KIND, TaskObjectType, decodeTaskObject, } from './task.js';
|
|
12
|
+
import { RunnerType } from './runner.js';
|
|
13
|
+
import { TreePathType } from './structure.js';
|
|
14
|
+
describe('TaskObjectType', () => {
|
|
15
|
+
const sales = [variant('field', 'inputs'), variant('field', 'sales')];
|
|
16
|
+
const rates = [variant('field', 'inputs'), variant('field', 'rates')];
|
|
17
|
+
const totals = [variant('field', 'tasks'), variant('field', 'totals'), variant('field', 'output')];
|
|
18
|
+
const base = {
|
|
19
|
+
kind: TASK_OBJECT_KIND,
|
|
20
|
+
body: variant('east', { program: 'a'.repeat(64) }),
|
|
21
|
+
runner: variant('east_node', { platforms: ['@elaraai/east-node-std'] }),
|
|
22
|
+
inputs: [{ path: sales, partition: none }],
|
|
23
|
+
output: { path: totals, kind: variant('value', null) },
|
|
24
|
+
role: variant('data', null),
|
|
25
|
+
environment: none,
|
|
26
|
+
};
|
|
27
|
+
it('round-trips every body, output kind and role', () => {
|
|
28
|
+
const tasks = [
|
|
29
|
+
base,
|
|
30
|
+
{
|
|
31
|
+
...base,
|
|
32
|
+
body: variant('command', { commandIr: 'b'.repeat(64) }),
|
|
33
|
+
runner: variant('custom', { command: [] }),
|
|
34
|
+
environment: some('c'.repeat(64)),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
...base,
|
|
38
|
+
inputs: [{ path: sales, partition: some({ by: ['account', 'at.day'] }) }, { path: rates, partition: none }],
|
|
39
|
+
output: { path: totals, kind: variant('dict', { merge: some('d'.repeat(64)) }) },
|
|
40
|
+
},
|
|
41
|
+
{ ...base, output: { path: totals, kind: variant('fold', { zero: 'e'.repeat(64), combine: 'f'.repeat(64) }) } },
|
|
42
|
+
{ ...base, output: { path: totals, kind: variant('set', null) } },
|
|
43
|
+
{ ...base, role: variant('ui', { paths: [sales], functions: ['forecast'], records: ['plans'], pages: [rates] }) },
|
|
44
|
+
];
|
|
45
|
+
const encode = encodeBeast2For(TaskObjectType);
|
|
46
|
+
for (const original of tasks)
|
|
47
|
+
assert.deepEqual(decodeTaskObject(encode(original)), original);
|
|
48
|
+
});
|
|
49
|
+
it('refuses a task object an older SDK exported, saying to re-export the package', () => {
|
|
50
|
+
const PreCutoverTaskObjectType = StructType({
|
|
51
|
+
commandIr: StringType,
|
|
52
|
+
inputs: ArrayType(TreePathType),
|
|
53
|
+
output: TreePathType,
|
|
54
|
+
kind: OptionType(StringType),
|
|
55
|
+
metadata: OptionType(BlobType),
|
|
56
|
+
runner: RunnerType,
|
|
57
|
+
environment: OptionType(StringType),
|
|
92
58
|
});
|
|
93
|
-
const older = encodeBeast2For(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
59
|
+
const older = encodeBeast2For(PreCutoverTaskObjectType)({
|
|
60
|
+
commandIr: 'a'.repeat(64),
|
|
61
|
+
inputs: [[variant('field', 'tasks'), variant('field', 'totals'), variant('field', 'function_ir')], sales],
|
|
62
|
+
output: totals,
|
|
63
|
+
kind: none,
|
|
64
|
+
metadata: none,
|
|
65
|
+
runner: variant('east_node', { platforms: [] }),
|
|
66
|
+
environment: none,
|
|
98
67
|
});
|
|
99
|
-
assert.
|
|
100
|
-
partitions: ['a'.repeat(64)],
|
|
101
|
-
boundaries: [0n, 2n],
|
|
102
|
-
splits: [],
|
|
103
|
-
slices: [['b'.repeat(64), 'c'.repeat(64)]],
|
|
104
|
-
merges: [],
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
describe('partition projections', () => {
|
|
109
|
-
const AtType = StructType({ day: IntegerType, hour: IntegerType });
|
|
110
|
-
const KeyType = StructType({ region: StringType, at: AtType, sku: StringType });
|
|
111
|
-
const keyTypeValue = toEastTypeValue(KeyType);
|
|
112
|
-
const keys = [
|
|
113
|
-
{ region: 'eu', at: { day: 2n, hour: 7n }, sku: 'b' },
|
|
114
|
-
{ region: 'eu', at: { day: 2n, hour: 7n }, sku: 'a' },
|
|
115
|
-
{ region: 'eu', at: { day: 1n, hour: 9n }, sku: 'c' },
|
|
116
|
-
{ region: 'ap', at: { day: 3n, hour: 0n }, sku: 'a' },
|
|
117
|
-
];
|
|
118
|
-
/** A `by` projection over the key, compiled, and its shape. */
|
|
119
|
-
function projection(by) {
|
|
120
|
-
const bundle = East.function([KeyType], undefined, by).toIR();
|
|
121
|
-
return {
|
|
122
|
-
compiled: bundle.compile([]),
|
|
123
|
-
shape: partitionProjectionShape(bundle.ir),
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/** Whether two comparisons agree in sign. */
|
|
127
|
-
const sameSign = (a, b) => Math.sign(a) === Math.sign(b);
|
|
128
|
-
it('reads the identity, a leading field, a struct literal of leading fields and a nested first-field path', () => {
|
|
129
|
-
assert.deepEqual(projection(($, key) => key).shape, { kind: 'fields', names: [] });
|
|
130
|
-
assert.deepEqual(projection(($, key) => key.region).shape, { kind: 'fields', names: ['region'] });
|
|
131
|
-
assert.deepEqual(projection(($, key) => ({ region: key.region, at: key.at })).shape, { kind: 'fields', names: ['region', 'at'] });
|
|
132
|
-
assert.deepEqual(projection(($, key) => key.at.day).shape, { kind: 'path', names: ['at', 'day'] });
|
|
133
|
-
});
|
|
134
|
-
it('returns null for a projection that computes', () => {
|
|
135
|
-
assert.equal(projection(($, key) => key.region.concat('-')).shape, null);
|
|
136
|
-
});
|
|
137
|
-
it('projects the identity to the key itself', () => {
|
|
138
|
-
const shape = { kind: 'fields', names: [] };
|
|
139
|
-
assert.ok(isTypeValueEqual(projectedKeyType(shape, keyTypeValue), keyTypeValue));
|
|
140
|
-
assert.equal(projectKey(shape, keys[0]), keys[0]);
|
|
141
|
-
});
|
|
142
|
-
it('projects a struct literal of leading fields exactly as the compiled projection does', () => {
|
|
143
|
-
const { compiled, shape } = projection(($, key) => ({ region: key.region, at: key.at }));
|
|
144
|
-
assert.ok(isTypeValueEqual(projectedKeyType(shape, keyTypeValue), toEastTypeValue(StructType({ region: StringType, at: AtType }))));
|
|
145
|
-
for (const key of keys)
|
|
146
|
-
assert.deepEqual(projectKey(shape, key), compiled(key));
|
|
147
|
-
});
|
|
148
|
-
it('projects a nested first-field path exactly as the compiled projection does', () => {
|
|
149
|
-
const { compiled, shape } = projection(($, key) => key.at.day);
|
|
150
|
-
assert.ok(isTypeValueEqual(projectedKeyType(shape, keyTypeValue), toEastTypeValue(IntegerType)));
|
|
151
|
-
for (const key of keys)
|
|
152
|
-
assert.equal(projectKey(shape, key), compiled(key));
|
|
68
|
+
assert.throws(() => decodeTaskObject(older), /exported by an older e3 SDK — re-export it with the current one/);
|
|
153
69
|
});
|
|
154
|
-
it('
|
|
155
|
-
|
|
156
|
-
const cmp = compareFor(projectedKeyType(shape, keyTypeValue));
|
|
157
|
-
const cmpCompiled = compareFor(StringType);
|
|
158
|
-
for (const a of keys) {
|
|
159
|
-
for (const b of keys) {
|
|
160
|
-
assert.ok(sameSign(cmp(projectKey(shape, a), projectKey(shape, b)), cmpCompiled(compiled(a), compiled(b))));
|
|
161
|
-
}
|
|
162
|
-
}
|
|
70
|
+
it('refuses an object of the task shape that carries another kind tag', () => {
|
|
71
|
+
assert.throws(() => decodeTaskObject(encodeBeast2For(TaskObjectType)({ ...base, kind: '$plan' })), /its kind is '\$plan', not '\$task'/);
|
|
163
72
|
});
|
|
164
|
-
it('throws
|
|
165
|
-
assert.throws(() =>
|
|
166
|
-
assert.throws(() => projectedKeyType({ kind: 'path', names: ['at', 'minute'] }, keyTypeValue), /field 'minute'/);
|
|
73
|
+
it('throws for bytes of no known task shape', () => {
|
|
74
|
+
assert.throws(() => decodeTaskObject(encodeBeast2For(IntegerType)(7n)), /re-export/);
|
|
167
75
|
});
|
|
168
76
|
});
|
|
169
77
|
//# sourceMappingURL=task.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.spec.js","sourceRoot":"","sources":["../../src/task.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE3N,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,UAAU,EACV,gBAAgB,GAKjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,MAAM,OAAO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AAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,iEAAiE,CAAC,CAAC;IAClH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,oCAAoC,CAAC,CAAC;IAC3I,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/src/transfer.d.ts
CHANGED
|
@@ -8,24 +8,24 @@
|
|
|
8
8
|
* Used by both the API server and client for large dataset uploads
|
|
9
9
|
* that exceed inline body size limits.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* A client names the protocol version it speaks with `?protocol=N` on the init
|
|
12
|
+
* and commit requests, and its release beside it (`&release=`). A server
|
|
13
|
+
* refuses a request that names another version, or none, naming both
|
|
14
|
+
* releases and the fix. The release decides nothing, so an older client and a
|
|
15
|
+
* newer server that speak one version work together.
|
|
16
16
|
*/
|
|
17
|
-
import { VariantType, StructType, StringType, IntegerType, NullType, DictType, type ValueTypeOf } from '@elaraai/east';
|
|
17
|
+
import { VariantType, StructType, StringType, IntegerType, NullType, DictType, OptionType, type ValueTypeOf } from '@elaraai/east';
|
|
18
18
|
/**
|
|
19
|
-
* The dataset transfer protocol version this build speaks.
|
|
19
|
+
* The dataset transfer protocol version this build speaks, and the only one.
|
|
20
20
|
*
|
|
21
21
|
* @remarks
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
22
|
+
* The server plans an upload as parts — each sent to its own URL with the
|
|
23
|
+
* request headers the server names, so an object store can bind a checksum to
|
|
24
|
+
* a single PUT or take a multipart upload larger than one PUT allows — and a
|
|
25
|
+
* commit may answer `processing` while the server verifies the bytes and takes
|
|
26
|
+
* them in, with how far it has got, for the client to poll.
|
|
27
27
|
*/
|
|
28
|
-
export declare const TRANSFER_PROTOCOL_VERSION =
|
|
28
|
+
export declare const TRANSFER_PROTOCOL_VERSION = 3;
|
|
29
29
|
/**
|
|
30
30
|
* How many parts an upload of `size` bytes has when planned with `partBytes`.
|
|
31
31
|
*
|
|
@@ -64,11 +64,9 @@ export type TransferUploadRequest = ValueTypeOf<typeof TransferUploadRequestType
|
|
|
64
64
|
* Transfer upload init response.
|
|
65
65
|
*
|
|
66
66
|
* - `completed`: Object already exists (dedup), dataset ref updated
|
|
67
|
-
* - `
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* `partBytes` bytes each (the last part holds the remainder, and an upload no
|
|
71
|
-
* larger than `partBytes` is one part). Part `n` (1-based) is the byte range
|
|
67
|
+
* - `upload_parts`: the client sends the bytes as parts of `partBytes` bytes
|
|
68
|
+
* each (the last part holds the remainder, and an upload no larger than
|
|
69
|
+
* `partBytes` is one part). Part `n` (1-based) is the byte range
|
|
72
70
|
* `[(n - 1) * partBytes, min(size, n * partBytes))`; its URL and required
|
|
73
71
|
* headers come from `GET …/upload/<id>/parts/<n>`. Parts may be sent in any
|
|
74
72
|
* order and concurrently, and re-sending a part replaces it. The client
|
|
@@ -76,10 +74,6 @@ export type TransferUploadRequest = ValueTypeOf<typeof TransferUploadRequestType
|
|
|
76
74
|
*/
|
|
77
75
|
export declare const TransferUploadResponseType: VariantType<{
|
|
78
76
|
readonly completed: NullType;
|
|
79
|
-
readonly upload: StructType<{
|
|
80
|
-
readonly id: StringType;
|
|
81
|
-
readonly uploadUrl: StringType;
|
|
82
|
-
}>;
|
|
83
77
|
readonly upload_parts: StructType<{
|
|
84
78
|
readonly id: StringType;
|
|
85
79
|
readonly partBytes: IntegerType;
|
|
@@ -87,7 +81,7 @@ export declare const TransferUploadResponseType: VariantType<{
|
|
|
87
81
|
}>;
|
|
88
82
|
export type TransferUploadResponse = ValueTypeOf<typeof TransferUploadResponseType>;
|
|
89
83
|
/**
|
|
90
|
-
* Where and how to send one part of
|
|
84
|
+
* Where and how to send one part of an upload.
|
|
91
85
|
*
|
|
92
86
|
* @property url - The URL the client PUTs the part's bytes to, without an
|
|
93
87
|
* `Authorization` header (it may be a presigned object-store URL)
|
|
@@ -105,15 +99,33 @@ export type TransferPartResponse = ValueTypeOf<typeof TransferPartResponseType>;
|
|
|
105
99
|
*
|
|
106
100
|
* - `completed`: Hash verified, object stored, dataset ref updated
|
|
107
101
|
* - `error`: Hash mismatch or other failure
|
|
108
|
-
* - `processing
|
|
109
|
-
* `GET …/upload/<id>` until
|
|
102
|
+
* - `processing`: the server is still verifying the bytes or taking them in,
|
|
103
|
+
* with how far it has got once it has said; poll `GET …/upload/<id>` until
|
|
104
|
+
* it answers `completed` or `error`
|
|
110
105
|
*/
|
|
111
106
|
export declare const TransferDoneResponseType: VariantType<{
|
|
112
107
|
readonly completed: NullType;
|
|
113
108
|
readonly error: StructType<{
|
|
114
109
|
readonly message: StringType;
|
|
115
110
|
}>;
|
|
116
|
-
readonly processing:
|
|
111
|
+
readonly processing: OptionType<StructType<{
|
|
112
|
+
readonly path: StringType;
|
|
113
|
+
readonly step: VariantType<{
|
|
114
|
+
readonly waiting: NullType;
|
|
115
|
+
readonly hashing: NullType;
|
|
116
|
+
readonly taking_in: StructType<{
|
|
117
|
+
readonly pieces: IntegerType;
|
|
118
|
+
readonly done: IntegerType;
|
|
119
|
+
}>;
|
|
120
|
+
readonly done: VariantType<{
|
|
121
|
+
readonly known: NullType;
|
|
122
|
+
readonly carried: NullType;
|
|
123
|
+
readonly taken: import("@elaraai/east").ArrayType<StringType>;
|
|
124
|
+
}>;
|
|
125
|
+
}>;
|
|
126
|
+
readonly bytes: IntegerType;
|
|
127
|
+
readonly total: IntegerType;
|
|
128
|
+
}>>;
|
|
117
129
|
}>;
|
|
118
130
|
export type TransferDoneResponse = ValueTypeOf<typeof TransferDoneResponseType>;
|
|
119
131
|
//# sourceMappingURL=transfer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../src/transfer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../src/transfer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAGnI;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAI3F;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAKvC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB;;;EAGpC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B;;;;;;EAMrC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEpF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB;;;EAGnC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;EAMnC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
package/dist/src/transfer.js
CHANGED
|
@@ -8,24 +8,25 @@
|
|
|
8
8
|
* Used by both the API server and client for large dataset uploads
|
|
9
9
|
* that exceed inline body size limits.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* A client names the protocol version it speaks with `?protocol=N` on the init
|
|
12
|
+
* and commit requests, and its release beside it (`&release=`). A server
|
|
13
|
+
* refuses a request that names another version, or none, naming both
|
|
14
|
+
* releases and the fix. The release decides nothing, so an older client and a
|
|
15
|
+
* newer server that speak one version work together.
|
|
16
16
|
*/
|
|
17
|
-
import { VariantType, StructType, StringType, IntegerType, NullType, DictType } from '@elaraai/east';
|
|
17
|
+
import { VariantType, StructType, StringType, IntegerType, NullType, DictType, OptionType } from '@elaraai/east';
|
|
18
|
+
import { IntakeFileType } from './intake.js';
|
|
18
19
|
/**
|
|
19
|
-
* The dataset transfer protocol version this build speaks.
|
|
20
|
+
* The dataset transfer protocol version this build speaks, and the only one.
|
|
20
21
|
*
|
|
21
22
|
* @remarks
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* The server plans an upload as parts — each sent to its own URL with the
|
|
24
|
+
* request headers the server names, so an object store can bind a checksum to
|
|
25
|
+
* a single PUT or take a multipart upload larger than one PUT allows — and a
|
|
26
|
+
* commit may answer `processing` while the server verifies the bytes and takes
|
|
27
|
+
* them in, with how far it has got, for the client to poll.
|
|
27
28
|
*/
|
|
28
|
-
export const TRANSFER_PROTOCOL_VERSION =
|
|
29
|
+
export const TRANSFER_PROTOCOL_VERSION = 3;
|
|
29
30
|
/**
|
|
30
31
|
* How many parts an upload of `size` bytes has when planned with `partBytes`.
|
|
31
32
|
*
|
|
@@ -70,11 +71,9 @@ export const TransferUploadRequestType = StructType({
|
|
|
70
71
|
* Transfer upload init response.
|
|
71
72
|
*
|
|
72
73
|
* - `completed`: Object already exists (dedup), dataset ref updated
|
|
73
|
-
* - `
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* `partBytes` bytes each (the last part holds the remainder, and an upload no
|
|
77
|
-
* larger than `partBytes` is one part). Part `n` (1-based) is the byte range
|
|
74
|
+
* - `upload_parts`: the client sends the bytes as parts of `partBytes` bytes
|
|
75
|
+
* each (the last part holds the remainder, and an upload no larger than
|
|
76
|
+
* `partBytes` is one part). Part `n` (1-based) is the byte range
|
|
78
77
|
* `[(n - 1) * partBytes, min(size, n * partBytes))`; its URL and required
|
|
79
78
|
* headers come from `GET …/upload/<id>/parts/<n>`. Parts may be sent in any
|
|
80
79
|
* order and concurrently, and re-sending a part replaces it. The client
|
|
@@ -82,17 +81,13 @@ export const TransferUploadRequestType = StructType({
|
|
|
82
81
|
*/
|
|
83
82
|
export const TransferUploadResponseType = VariantType({
|
|
84
83
|
completed: NullType,
|
|
85
|
-
upload: StructType({
|
|
86
|
-
id: StringType,
|
|
87
|
-
uploadUrl: StringType,
|
|
88
|
-
}),
|
|
89
84
|
upload_parts: StructType({
|
|
90
85
|
id: StringType,
|
|
91
86
|
partBytes: IntegerType,
|
|
92
87
|
}),
|
|
93
88
|
});
|
|
94
89
|
/**
|
|
95
|
-
* Where and how to send one part of
|
|
90
|
+
* Where and how to send one part of an upload.
|
|
96
91
|
*
|
|
97
92
|
* @property url - The URL the client PUTs the part's bytes to, without an
|
|
98
93
|
* `Authorization` header (it may be a presigned object-store URL)
|
|
@@ -109,14 +104,15 @@ export const TransferPartResponseType = StructType({
|
|
|
109
104
|
*
|
|
110
105
|
* - `completed`: Hash verified, object stored, dataset ref updated
|
|
111
106
|
* - `error`: Hash mismatch or other failure
|
|
112
|
-
* - `processing
|
|
113
|
-
* `GET …/upload/<id>` until
|
|
107
|
+
* - `processing`: the server is still verifying the bytes or taking them in,
|
|
108
|
+
* with how far it has got once it has said; poll `GET …/upload/<id>` until
|
|
109
|
+
* it answers `completed` or `error`
|
|
114
110
|
*/
|
|
115
111
|
export const TransferDoneResponseType = VariantType({
|
|
116
112
|
completed: NullType,
|
|
117
113
|
error: StructType({
|
|
118
114
|
message: StringType,
|
|
119
115
|
}),
|
|
120
|
-
processing:
|
|
116
|
+
processing: OptionType(IntakeFileType),
|
|
121
117
|
});
|
|
122
118
|
//# sourceMappingURL=transfer.js.map
|
package/dist/src/transfer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../src/transfer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAoB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../src/transfer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAA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BAAyB,GAAG,UAAU,CAAC;IAClD,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,WAAW;CAClB,CAAC,CAAC;AAGH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,WAAW,CAAC;IACpD,SAAS,EAAE,QAAQ;IACnB,YAAY,EAAE,UAAU,CAAC;QACvB,EAAE,EAAE,UAAU;QACd,SAAS,EAAE,WAAW;KACvB,CAAC;CACH,CAAC,CAAC;AAGH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAAC;IACjD,GAAG,EAAE,UAAU;IACf,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CAC1C,CAAC,CAAC;AAGH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,CAAC;IAClD,SAAS,EAAE,QAAQ;IACnB,KAAK,EAAE,UAAU,CAAC;QAChB,OAAO,EAAE,UAAU;KACpB,CAAC;IACF,UAAU,EAAE,UAAU,CAAC,cAAc,CAAC;CACvC,CAAC,CAAC"}
|
|
@@ -3,19 +3,13 @@
|
|
|
3
3
|
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* The dataset transfer protocol's
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* that places them, so an off-by-one on either side would corrupt uploads
|
|
10
|
-
* silently until the commit's hash check. And protocol 2 only adds variant
|
|
11
|
-
* cases: a version-1 client decodes a version-1 answer from a new server, and a
|
|
12
|
-
* new client decodes an old server's answers, only while every added case sorts
|
|
13
|
-
* after the version-1 cases and so leaves their tags unchanged.
|
|
6
|
+
* The dataset transfer protocol's part arithmetic, which the client that cuts
|
|
7
|
+
* the bytes and the server that places them share, so an off-by-one on either
|
|
8
|
+
* side would corrupt uploads silently until the commit's hash check.
|
|
14
9
|
*/
|
|
15
10
|
import { describe, it } from 'node:test';
|
|
16
11
|
import * as assert from 'node:assert';
|
|
17
|
-
import {
|
|
18
|
-
import { TransferDoneResponseType, TransferUploadResponseType, transferPartCount, transferPartRange, } from './transfer.js';
|
|
12
|
+
import { transferPartCount, transferPartRange } from './transfer.js';
|
|
19
13
|
describe('transferPartCount / transferPartRange', () => {
|
|
20
14
|
it('cuts an upload into full parts and a remainder', () => {
|
|
21
15
|
assert.strictEqual(transferPartCount(10, 4), 3);
|
|
@@ -48,28 +42,4 @@ describe('transferPartCount / transferPartRange', () => {
|
|
|
48
42
|
});
|
|
49
43
|
});
|
|
50
44
|
});
|
|
51
|
-
describe('transfer wire compatibility across protocol versions', () => {
|
|
52
|
-
// The version-1 shapes, as a client and server built before protocol 2 hold them.
|
|
53
|
-
const UploadResponseV1 = VariantType({
|
|
54
|
-
completed: NullType,
|
|
55
|
-
upload: StructType({ id: StringType, uploadUrl: StringType }),
|
|
56
|
-
});
|
|
57
|
-
const DoneResponseV1 = VariantType({
|
|
58
|
-
completed: NullType,
|
|
59
|
-
error: StructType({ message: StringType }),
|
|
60
|
-
});
|
|
61
|
-
it('keeps the init answers a version-1 client decodes', () => {
|
|
62
|
-
const upload = variant('upload', { id: 'abc', uploadUrl: 'http://h/api/uploads/abc' });
|
|
63
|
-
assert.deepStrictEqual(decodeBeast2For(UploadResponseV1)(encodeBeast2For(TransferUploadResponseType)(upload)), upload);
|
|
64
|
-
assert.deepStrictEqual(decodeBeast2For(TransferUploadResponseType)(encodeBeast2For(UploadResponseV1)(upload)), upload);
|
|
65
|
-
const completed = variant('completed', null);
|
|
66
|
-
assert.deepStrictEqual(decodeBeast2For(UploadResponseV1)(encodeBeast2For(TransferUploadResponseType)(completed)), completed);
|
|
67
|
-
});
|
|
68
|
-
it('keeps the commit answers a version-1 client decodes', () => {
|
|
69
|
-
for (const done of [variant('completed', null), variant('error', { message: 'hash mismatch' })]) {
|
|
70
|
-
assert.deepStrictEqual(decodeBeast2For(DoneResponseV1)(encodeBeast2For(TransferDoneResponseType)(done)), done);
|
|
71
|
-
assert.deepStrictEqual(decodeBeast2For(TransferDoneResponseType)(encodeBeast2For(DoneResponseV1)(done)), done);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
45
|
//# sourceMappingURL=transfer.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.spec.js","sourceRoot":"","sources":["../../src/transfer.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"transfer.spec.js","sourceRoot":"","sources":["../../src/transfer.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAErE,QAAQ,CAAC,uCAAuC,EAAE,GAAG,EAAE;IACrD,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAChD,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC1E,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC1E,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC,C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