@dxos/echo-pipeline 0.1.56-main.ec96785 → 0.1.56-main.f2c137d
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/lib/browser/{chunk-7U2NXI2P.mjs → chunk-M66GL5HD.mjs} +537 -252
- package/dist/lib/browser/chunk-M66GL5HD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +14 -18
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +535 -250
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +532 -251
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/common/feeds.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/snapshot-manager.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/space/auth.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +2 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/common/feeds.ts +1 -2
- package/src/db-host/data-service-host.ts +1 -2
- package/src/db-host/data-service.ts +1 -2
- package/src/db-host/snapshot-manager.ts +0 -2
- package/src/metadata/metadata-store.ts +2 -2
- package/src/pipeline/message-selector.ts +1 -2
- package/src/pipeline/pipeline.test.ts +37 -1
- package/src/pipeline/pipeline.ts +36 -14
- package/src/space/auth.ts +1 -2
- package/src/space/data-pipeline.ts +3 -3
- package/src/space/space.test.ts +18 -17
- package/src/space/space.ts +6 -3
- package/src/testing/test-agent-builder.ts +2 -1
- package/dist/lib/browser/chunk-7U2NXI2P.mjs.map +0 -7
|
@@ -7,23 +7,40 @@ var codec = schema.getCodecForType("dxos.echo.feed.FeedMessage");
|
|
|
7
7
|
var valueEncoding = createCodecEncoding(codec);
|
|
8
8
|
|
|
9
9
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
10
|
-
import invariant from "
|
|
10
|
+
import { invariant } from "@dxos/invariant";
|
|
11
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
|
|
11
12
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
12
|
-
invariant(mapper
|
|
13
|
-
|
|
13
|
+
invariant(mapper, void 0, {
|
|
14
|
+
F: __dxlog_file,
|
|
15
|
+
L: 16,
|
|
16
|
+
S: void 0,
|
|
17
|
+
A: [
|
|
18
|
+
"mapper",
|
|
19
|
+
""
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
invariant(writer, void 0, {
|
|
23
|
+
F: __dxlog_file,
|
|
24
|
+
L: 17,
|
|
25
|
+
S: void 0,
|
|
26
|
+
A: [
|
|
27
|
+
"writer",
|
|
28
|
+
""
|
|
29
|
+
]
|
|
30
|
+
});
|
|
14
31
|
return {
|
|
15
32
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
16
33
|
};
|
|
17
34
|
};
|
|
18
35
|
|
|
19
36
|
// packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts
|
|
20
|
-
import invariant2 from "tiny-invariant";
|
|
21
37
|
import { Stream } from "@dxos/codec-protobuf";
|
|
22
38
|
import { Context } from "@dxos/context";
|
|
23
39
|
import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
|
|
40
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
24
41
|
import { log } from "@dxos/log";
|
|
25
42
|
import { ComplexMap } from "@dxos/util";
|
|
26
|
-
var
|
|
43
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
|
|
27
44
|
var DataServiceHost = class {
|
|
28
45
|
constructor(_itemManager, _itemDemuxer, _writeStream) {
|
|
29
46
|
this._itemManager = _itemManager;
|
|
@@ -50,15 +67,22 @@ var DataServiceHost = class {
|
|
|
50
67
|
}
|
|
51
68
|
});
|
|
52
69
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
53
|
-
var _a;
|
|
54
70
|
const { batch, meta } = message;
|
|
55
|
-
invariant2(!meta.clientTag, "Unexpected client tag in mutation message"
|
|
71
|
+
invariant2(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
72
|
+
F: __dxlog_file2,
|
|
73
|
+
L: 61,
|
|
74
|
+
S: this,
|
|
75
|
+
A: [
|
|
76
|
+
"!(meta as any).clientTag",
|
|
77
|
+
"'Unexpected client tag in mutation message'"
|
|
78
|
+
]
|
|
79
|
+
});
|
|
56
80
|
log("message", {
|
|
57
81
|
batch,
|
|
58
82
|
meta
|
|
59
83
|
}, {
|
|
60
|
-
F:
|
|
61
|
-
L:
|
|
84
|
+
F: __dxlog_file2,
|
|
85
|
+
L: 62,
|
|
62
86
|
S: this,
|
|
63
87
|
C: (f, a) => f(...a)
|
|
64
88
|
});
|
|
@@ -66,7 +90,7 @@ var DataServiceHost = class {
|
|
|
66
90
|
message.meta.feedKey,
|
|
67
91
|
message.meta.seq
|
|
68
92
|
]);
|
|
69
|
-
|
|
93
|
+
batch.objects?.forEach((object) => {
|
|
70
94
|
setMetadataOnObject(object, {
|
|
71
95
|
...meta
|
|
72
96
|
});
|
|
@@ -84,15 +108,30 @@ var DataServiceHost = class {
|
|
|
84
108
|
});
|
|
85
109
|
}
|
|
86
110
|
async write(request) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
111
|
+
invariant2(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
112
|
+
F: __dxlog_file2,
|
|
113
|
+
L: 88,
|
|
114
|
+
S: this,
|
|
115
|
+
A: [
|
|
116
|
+
"!this._ctx.disposed",
|
|
117
|
+
"'Cannot write to closed DataServiceHost'"
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
invariant2(this._writeStream, "Cannot write mutations in readonly mode", {
|
|
121
|
+
F: __dxlog_file2,
|
|
122
|
+
L: 89,
|
|
123
|
+
S: this,
|
|
124
|
+
A: [
|
|
125
|
+
"this._writeStream",
|
|
126
|
+
"'Cannot write mutations in readonly mode'"
|
|
127
|
+
]
|
|
128
|
+
});
|
|
90
129
|
log("write", {
|
|
91
130
|
clientTag: request.clientTag,
|
|
92
|
-
objectCount:
|
|
131
|
+
objectCount: request.batch.objects?.length ?? 0
|
|
93
132
|
}, {
|
|
94
|
-
F:
|
|
95
|
-
L:
|
|
133
|
+
F: __dxlog_file2,
|
|
134
|
+
L: 91,
|
|
96
135
|
S: this,
|
|
97
136
|
C: (f, a) => f(...a)
|
|
98
137
|
});
|
|
@@ -105,8 +144,8 @@ var DataServiceHost = class {
|
|
|
105
144
|
feedKey: receipt2.feedKey,
|
|
106
145
|
seq: receipt2.seq
|
|
107
146
|
}, {
|
|
108
|
-
F:
|
|
109
|
-
L:
|
|
147
|
+
F: __dxlog_file2,
|
|
148
|
+
L: 100,
|
|
110
149
|
S: this,
|
|
111
150
|
C: (f, a) => f(...a)
|
|
112
151
|
});
|
|
@@ -120,24 +159,18 @@ var DataServiceHost = class {
|
|
|
120
159
|
return receipt;
|
|
121
160
|
}
|
|
122
161
|
};
|
|
123
|
-
var createDataMessage = (batch) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
meta: void 0
|
|
136
|
-
};
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
};
|
|
162
|
+
var createDataMessage = (batch) => ({
|
|
163
|
+
batch: {
|
|
164
|
+
objects: batch.objects?.map((object) => ({
|
|
165
|
+
...object,
|
|
166
|
+
mutations: object.mutations?.map((mutation) => ({
|
|
167
|
+
...mutation,
|
|
168
|
+
meta: void 0
|
|
169
|
+
})),
|
|
170
|
+
meta: void 0
|
|
171
|
+
}))
|
|
172
|
+
}
|
|
173
|
+
});
|
|
141
174
|
|
|
142
175
|
// packages/core/echo/echo-pipeline/src/db-host/database-host.ts
|
|
143
176
|
import { ItemDemuxer } from "@dxos/echo-db";
|
|
@@ -166,15 +199,13 @@ var DatabaseHost = class {
|
|
|
166
199
|
return this._itemDemuxer.createSnapshot();
|
|
167
200
|
}
|
|
168
201
|
createDataServiceHost() {
|
|
169
|
-
|
|
170
|
-
return new DataServiceHost(this._itemManager, this._itemDemuxer, (_a = this._outboundStream) != null ? _a : void 0);
|
|
202
|
+
return new DataServiceHost(this._itemManager, this._itemDemuxer, this._outboundStream ?? void 0);
|
|
171
203
|
}
|
|
172
204
|
};
|
|
173
205
|
|
|
174
206
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
|
|
175
207
|
import { trackLeaks } from "@dxos/async";
|
|
176
208
|
import { cancelWithContext } from "@dxos/context";
|
|
177
|
-
import { timed } from "@dxos/debug";
|
|
178
209
|
import { PublicKey } from "@dxos/keys";
|
|
179
210
|
import { schema as schema2 } from "@dxos/protocols";
|
|
180
211
|
import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
|
|
@@ -219,9 +250,6 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
219
250
|
return PublicKey.from(id).toHex();
|
|
220
251
|
}
|
|
221
252
|
};
|
|
222
|
-
_ts_decorate([
|
|
223
|
-
timed(1e4)
|
|
224
|
-
], SnapshotManager.prototype, "load", null);
|
|
225
253
|
SnapshotManager = _ts_decorate([
|
|
226
254
|
trackLeaks("open", "close")
|
|
227
255
|
], SnapshotManager);
|
|
@@ -273,12 +301,12 @@ var SnapshotStore = class {
|
|
|
273
301
|
};
|
|
274
302
|
|
|
275
303
|
// packages/core/echo/echo-pipeline/src/db-host/data-service.ts
|
|
276
|
-
import invariant3 from "tiny-invariant";
|
|
277
304
|
import { raise } from "@dxos/debug";
|
|
305
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
278
306
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
279
307
|
import { log as log2 } from "@dxos/log";
|
|
280
308
|
import { ComplexMap as ComplexMap2 } from "@dxos/util";
|
|
281
|
-
var
|
|
309
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
|
|
282
310
|
var DataServiceSubscriptions = class {
|
|
283
311
|
constructor() {
|
|
284
312
|
this._spaces = new ComplexMap2(PublicKey2.hash);
|
|
@@ -290,12 +318,20 @@ var DataServiceSubscriptions = class {
|
|
|
290
318
|
log2("Registering space", {
|
|
291
319
|
spaceKey
|
|
292
320
|
}, {
|
|
293
|
-
F:
|
|
294
|
-
L:
|
|
321
|
+
F: __dxlog_file3,
|
|
322
|
+
L: 30,
|
|
295
323
|
S: this,
|
|
296
324
|
C: (f, a) => f(...a)
|
|
297
325
|
});
|
|
298
|
-
invariant3(!this._spaces.has(spaceKey)
|
|
326
|
+
invariant3(!this._spaces.has(spaceKey), void 0, {
|
|
327
|
+
F: __dxlog_file3,
|
|
328
|
+
L: 31,
|
|
329
|
+
S: this,
|
|
330
|
+
A: [
|
|
331
|
+
"!this._spaces.has(spaceKey)",
|
|
332
|
+
""
|
|
333
|
+
]
|
|
334
|
+
});
|
|
299
335
|
await host.open();
|
|
300
336
|
this._spaces.set(spaceKey, host);
|
|
301
337
|
}
|
|
@@ -303,13 +339,13 @@ var DataServiceSubscriptions = class {
|
|
|
303
339
|
log2("Unregistering space", {
|
|
304
340
|
spaceKey
|
|
305
341
|
}, {
|
|
306
|
-
F:
|
|
307
|
-
L:
|
|
342
|
+
F: __dxlog_file3,
|
|
343
|
+
L: 37,
|
|
308
344
|
S: this,
|
|
309
345
|
C: (f, a) => f(...a)
|
|
310
346
|
});
|
|
311
347
|
const host = this._spaces.get(spaceKey);
|
|
312
|
-
await
|
|
348
|
+
await host?.close();
|
|
313
349
|
this._spaces.delete(spaceKey);
|
|
314
350
|
}
|
|
315
351
|
getDataService(spaceKey) {
|
|
@@ -321,25 +357,47 @@ var DataServiceImpl = class {
|
|
|
321
357
|
this._subscriptions = _subscriptions;
|
|
322
358
|
}
|
|
323
359
|
subscribe(request) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
360
|
+
invariant3(request.spaceKey, void 0, {
|
|
361
|
+
F: __dxlog_file3,
|
|
362
|
+
L: 56,
|
|
363
|
+
S: this,
|
|
364
|
+
A: [
|
|
365
|
+
"request.spaceKey",
|
|
366
|
+
""
|
|
367
|
+
]
|
|
368
|
+
});
|
|
369
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
327
370
|
return host.subscribe();
|
|
328
371
|
}
|
|
329
372
|
write(request) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
373
|
+
invariant3(request.spaceKey, void 0, {
|
|
374
|
+
F: __dxlog_file3,
|
|
375
|
+
L: 63,
|
|
376
|
+
S: this,
|
|
377
|
+
A: [
|
|
378
|
+
"request.spaceKey",
|
|
379
|
+
""
|
|
380
|
+
]
|
|
381
|
+
});
|
|
382
|
+
invariant3(request.batch, void 0, {
|
|
383
|
+
F: __dxlog_file3,
|
|
384
|
+
L: 64,
|
|
385
|
+
S: this,
|
|
386
|
+
A: [
|
|
387
|
+
"request.batch",
|
|
388
|
+
""
|
|
389
|
+
]
|
|
390
|
+
});
|
|
391
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
334
392
|
return host.write(request);
|
|
335
393
|
}
|
|
336
394
|
};
|
|
337
395
|
|
|
338
396
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
339
397
|
import CRC32 from "crc-32";
|
|
340
|
-
import invariant4 from "tiny-invariant";
|
|
341
398
|
import { synchronized, Event } from "@dxos/async";
|
|
342
399
|
import { DataCorruptionError } from "@dxos/errors";
|
|
400
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
343
401
|
import { log as log3 } from "@dxos/log";
|
|
344
402
|
import { STORAGE_VERSION, schema as schema4 } from "@dxos/protocols";
|
|
345
403
|
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -354,12 +412,12 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
354
412
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
355
413
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
356
414
|
}
|
|
357
|
-
var
|
|
415
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
358
416
|
var emptyEchoMetadata = () => ({
|
|
359
417
|
version: STORAGE_VERSION,
|
|
360
418
|
spaces: [],
|
|
361
|
-
created: new Date(),
|
|
362
|
-
updated: new Date()
|
|
419
|
+
created: /* @__PURE__ */ new Date(),
|
|
420
|
+
updated: /* @__PURE__ */ new Date()
|
|
363
421
|
});
|
|
364
422
|
var EchoMetadata = schema4.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
365
423
|
var MetadataStore = class {
|
|
@@ -373,22 +431,19 @@ var MetadataStore = class {
|
|
|
373
431
|
return this._metadata;
|
|
374
432
|
}
|
|
375
433
|
get version() {
|
|
376
|
-
|
|
377
|
-
return (_a = this._metadata.version) != null ? _a : 0;
|
|
434
|
+
return this._metadata.version ?? 0;
|
|
378
435
|
}
|
|
379
436
|
/**
|
|
380
437
|
* Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and
|
|
381
438
|
* addSpaceFeed functions.
|
|
382
439
|
*/
|
|
383
440
|
get spaces() {
|
|
384
|
-
|
|
385
|
-
return (_a = this._metadata.spaces) != null ? _a : [];
|
|
441
|
+
return this._metadata.spaces ?? [];
|
|
386
442
|
}
|
|
387
443
|
/**
|
|
388
444
|
* Loads metadata from persistent storage.
|
|
389
445
|
*/
|
|
390
446
|
async load() {
|
|
391
|
-
var _a;
|
|
392
447
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
393
448
|
try {
|
|
394
449
|
const { size: fileLength } = await file.stat();
|
|
@@ -401,13 +456,16 @@ var MetadataStore = class {
|
|
|
401
456
|
size: dataSize,
|
|
402
457
|
checksum
|
|
403
458
|
}, {
|
|
404
|
-
F:
|
|
459
|
+
F: __dxlog_file4,
|
|
405
460
|
L: 72,
|
|
406
461
|
S: this,
|
|
407
462
|
C: (f, a) => f(...a)
|
|
408
463
|
});
|
|
409
464
|
if (fileLength < dataSize + 8) {
|
|
410
|
-
throw new DataCorruptionError("Metadata size is smaller than expected."
|
|
465
|
+
throw new DataCorruptionError("Metadata size is smaller than expected.", {
|
|
466
|
+
fileLength,
|
|
467
|
+
dataSize
|
|
468
|
+
});
|
|
411
469
|
}
|
|
412
470
|
const data = await file.read(8, dataSize);
|
|
413
471
|
const calculatedChecksum = CRC32.buf(data);
|
|
@@ -415,15 +473,14 @@ var MetadataStore = class {
|
|
|
415
473
|
throw new DataCorruptionError("Metadata checksum is invalid.");
|
|
416
474
|
}
|
|
417
475
|
this._metadata = EchoMetadata.decode(data);
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
(_a2 = space.state) != null ? _a2 : space.state = SpaceState.ACTIVE;
|
|
476
|
+
this._metadata.spaces?.forEach((space) => {
|
|
477
|
+
space.state ??= SpaceState.ACTIVE;
|
|
421
478
|
});
|
|
422
479
|
} catch (err) {
|
|
423
480
|
log3.error("failed to load metadata", {
|
|
424
481
|
err
|
|
425
482
|
}, {
|
|
426
|
-
F:
|
|
483
|
+
F: __dxlog_file4,
|
|
427
484
|
L: 92,
|
|
428
485
|
S: this,
|
|
429
486
|
C: (f, a) => f(...a)
|
|
@@ -434,12 +491,11 @@ var MetadataStore = class {
|
|
|
434
491
|
}
|
|
435
492
|
}
|
|
436
493
|
async _save() {
|
|
437
|
-
var _a;
|
|
438
494
|
const data = {
|
|
439
495
|
...this._metadata,
|
|
440
496
|
version: STORAGE_VERSION,
|
|
441
|
-
created:
|
|
442
|
-
updated: new Date()
|
|
497
|
+
created: this._metadata.created ?? /* @__PURE__ */ new Date(),
|
|
498
|
+
updated: /* @__PURE__ */ new Date()
|
|
443
499
|
};
|
|
444
500
|
this.update.emit(data);
|
|
445
501
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
@@ -455,7 +511,7 @@ var MetadataStore = class {
|
|
|
455
511
|
size: encoded.length,
|
|
456
512
|
checksum
|
|
457
513
|
}, {
|
|
458
|
-
F:
|
|
514
|
+
F: __dxlog_file4,
|
|
459
515
|
L: 124,
|
|
460
516
|
S: this,
|
|
461
517
|
C: (f, a) => f(...a)
|
|
@@ -465,12 +521,19 @@ var MetadataStore = class {
|
|
|
465
521
|
}
|
|
466
522
|
}
|
|
467
523
|
_getSpace(spaceKey) {
|
|
468
|
-
|
|
469
|
-
if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
|
|
524
|
+
if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
|
|
470
525
|
return this._metadata.identity.haloSpace;
|
|
471
526
|
}
|
|
472
527
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
473
|
-
invariant4(space, "Space not found"
|
|
528
|
+
invariant4(space, "Space not found", {
|
|
529
|
+
F: __dxlog_file4,
|
|
530
|
+
L: 137,
|
|
531
|
+
S: this,
|
|
532
|
+
A: [
|
|
533
|
+
"space",
|
|
534
|
+
"'Space not found'"
|
|
535
|
+
]
|
|
536
|
+
});
|
|
474
537
|
return space;
|
|
475
538
|
}
|
|
476
539
|
/**
|
|
@@ -478,7 +541,7 @@ var MetadataStore = class {
|
|
|
478
541
|
*/
|
|
479
542
|
async clear() {
|
|
480
543
|
log3("clearing all metadata", void 0, {
|
|
481
|
-
F:
|
|
544
|
+
F: __dxlog_file4,
|
|
482
545
|
L: 145,
|
|
483
546
|
S: this,
|
|
484
547
|
C: (f, a) => f(...a)
|
|
@@ -490,14 +553,29 @@ var MetadataStore = class {
|
|
|
490
553
|
return this._metadata.identity;
|
|
491
554
|
}
|
|
492
555
|
async setIdentityRecord(record) {
|
|
493
|
-
invariant4(!this._metadata.identity, "Cannot overwrite existing identity in metadata"
|
|
556
|
+
invariant4(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
|
|
557
|
+
F: __dxlog_file4,
|
|
558
|
+
L: 155,
|
|
559
|
+
S: this,
|
|
560
|
+
A: [
|
|
561
|
+
"!this._metadata.identity",
|
|
562
|
+
"'Cannot overwrite existing identity in metadata'"
|
|
563
|
+
]
|
|
564
|
+
});
|
|
494
565
|
this._metadata.identity = record;
|
|
495
566
|
await this._save();
|
|
496
567
|
}
|
|
497
568
|
async addSpace(record) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
569
|
+
invariant4(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
570
|
+
F: __dxlog_file4,
|
|
571
|
+
L: 162,
|
|
572
|
+
S: this,
|
|
573
|
+
A: [
|
|
574
|
+
"!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
|
|
575
|
+
"'Cannot overwrite existing space in metadata'"
|
|
576
|
+
]
|
|
577
|
+
});
|
|
578
|
+
(this._metadata.spaces ??= []).push(record);
|
|
501
579
|
await this._save();
|
|
502
580
|
}
|
|
503
581
|
async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
|
|
@@ -533,7 +611,7 @@ var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
|
533
611
|
|
|
534
612
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
535
613
|
import { Event as Event2 } from "@dxos/async";
|
|
536
|
-
import { timed
|
|
614
|
+
import { timed } from "@dxos/debug";
|
|
537
615
|
import { log as log4 } from "@dxos/log";
|
|
538
616
|
import { Timeframe } from "@dxos/timeframe";
|
|
539
617
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -546,7 +624,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
546
624
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
547
625
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
548
626
|
}
|
|
549
|
-
var
|
|
627
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
550
628
|
var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
551
629
|
feedKey,
|
|
552
630
|
index
|
|
@@ -605,7 +683,7 @@ var TimeframeClock = class {
|
|
|
605
683
|
target,
|
|
606
684
|
current: this._timeframe
|
|
607
685
|
}, {
|
|
608
|
-
F:
|
|
686
|
+
F: __dxlog_file5,
|
|
609
687
|
L: 73,
|
|
610
688
|
S: this,
|
|
611
689
|
C: (f, a) => f(...a)
|
|
@@ -616,7 +694,7 @@ var TimeframeClock = class {
|
|
|
616
694
|
current: this._timeframe,
|
|
617
695
|
deps: Timeframe.dependencies(target, this._timeframe)
|
|
618
696
|
}, {
|
|
619
|
-
F:
|
|
697
|
+
F: __dxlog_file5,
|
|
620
698
|
L: 75,
|
|
621
699
|
S: this,
|
|
622
700
|
C: (f, a) => f(...a)
|
|
@@ -626,36 +704,44 @@ var TimeframeClock = class {
|
|
|
626
704
|
}
|
|
627
705
|
};
|
|
628
706
|
_ts_decorate3([
|
|
629
|
-
|
|
707
|
+
timed(5e3)
|
|
630
708
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
631
709
|
|
|
632
710
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
633
|
-
import invariant6 from "tiny-invariant";
|
|
634
711
|
import { Event as Event3, sleep, synchronized as synchronized2, Trigger } from "@dxos/async";
|
|
635
712
|
import { Context as Context2, rejectOnDispose } from "@dxos/context";
|
|
636
713
|
import { failUndefined } from "@dxos/debug";
|
|
637
714
|
import { FeedSetIterator } from "@dxos/feed-store";
|
|
715
|
+
import { invariant as invariant6 } from "@dxos/invariant";
|
|
638
716
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
639
717
|
import { log as log6 } from "@dxos/log";
|
|
640
718
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
641
|
-
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
719
|
+
import { ComplexMap as ComplexMap3, getPrototypeSpecificInstanceId } from "@dxos/util";
|
|
642
720
|
|
|
643
721
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
644
|
-
import invariant5 from "
|
|
722
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
645
723
|
import { log as log5 } from "@dxos/log";
|
|
646
|
-
var
|
|
724
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
|
|
647
725
|
var createMessageSelector = (timeframeClock) => {
|
|
648
726
|
return (messages) => {
|
|
649
727
|
for (let i = 0; i < messages.length; i++) {
|
|
650
728
|
const { data: { timeframe } } = messages[i];
|
|
651
|
-
invariant5(timeframe
|
|
729
|
+
invariant5(timeframe, void 0, {
|
|
730
|
+
F: __dxlog_file6,
|
|
731
|
+
L: 25,
|
|
732
|
+
S: void 0,
|
|
733
|
+
A: [
|
|
734
|
+
"timeframe",
|
|
735
|
+
""
|
|
736
|
+
]
|
|
737
|
+
});
|
|
652
738
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
653
739
|
return i;
|
|
654
740
|
}
|
|
655
741
|
}
|
|
656
742
|
log5("Skipping...", void 0, {
|
|
657
|
-
F:
|
|
658
|
-
L:
|
|
743
|
+
F: __dxlog_file6,
|
|
744
|
+
L: 33,
|
|
659
745
|
S: void 0,
|
|
660
746
|
C: (f, a) => f(...a)
|
|
661
747
|
});
|
|
@@ -673,7 +759,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
673
759
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
674
760
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
675
761
|
}
|
|
676
|
-
var
|
|
762
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
677
763
|
var PipelineState = class {
|
|
678
764
|
// prettier-ignore
|
|
679
765
|
constructor(_feeds, _timeframeClock) {
|
|
@@ -724,18 +810,17 @@ var PipelineState = class {
|
|
|
724
810
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
725
811
|
*/
|
|
726
812
|
async waitUntilReachedTargetTimeframe({ ctx = new Context2(), timeout, breakOnStall = true } = {}) {
|
|
727
|
-
var _a;
|
|
728
813
|
log6("waitUntilReachedTargetTimeframe", {
|
|
729
814
|
timeout,
|
|
730
815
|
current: this.timeframe,
|
|
731
816
|
target: this.targetTimeframe
|
|
732
817
|
}, {
|
|
733
|
-
F:
|
|
734
|
-
L:
|
|
818
|
+
F: __dxlog_file7,
|
|
819
|
+
L: 125,
|
|
735
820
|
S: this,
|
|
736
821
|
C: (f, a) => f(...a)
|
|
737
822
|
});
|
|
738
|
-
|
|
823
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
739
824
|
this._timeframeClock.update.waitForCondition(() => {
|
|
740
825
|
return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
741
826
|
}),
|
|
@@ -761,8 +846,8 @@ var PipelineState = class {
|
|
|
761
846
|
target: this.targetTimeframe,
|
|
762
847
|
dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
|
|
763
848
|
}, {
|
|
764
|
-
F:
|
|
765
|
-
L:
|
|
849
|
+
F: __dxlog_file7,
|
|
850
|
+
L: 152,
|
|
766
851
|
S: this,
|
|
767
852
|
C: (f, a) => f(...a)
|
|
768
853
|
});
|
|
@@ -784,14 +869,22 @@ var Pipeline = class {
|
|
|
784
869
|
this._pauseTrigger = new Trigger().wake();
|
|
785
870
|
this._isStopping = false;
|
|
786
871
|
this._isStarted = false;
|
|
787
|
-
this.
|
|
872
|
+
this._isBeingConsumed = false;
|
|
788
873
|
this._isPaused = false;
|
|
789
874
|
}
|
|
790
875
|
get state() {
|
|
791
876
|
return this._state;
|
|
792
877
|
}
|
|
793
878
|
get writer() {
|
|
794
|
-
invariant6(this._writer, "Writer not set."
|
|
879
|
+
invariant6(this._writer, "Writer not set.", {
|
|
880
|
+
F: __dxlog_file7,
|
|
881
|
+
L: 230,
|
|
882
|
+
S: this,
|
|
883
|
+
A: [
|
|
884
|
+
"this._writer",
|
|
885
|
+
"'Writer not set.'"
|
|
886
|
+
]
|
|
887
|
+
});
|
|
795
888
|
return this._writer;
|
|
796
889
|
}
|
|
797
890
|
hasFeed(feedKey) {
|
|
@@ -807,20 +900,47 @@ var Pipeline = class {
|
|
|
807
900
|
if (this._feedSetIterator) {
|
|
808
901
|
await this._feedSetIterator.addFeed(feed);
|
|
809
902
|
}
|
|
810
|
-
this.
|
|
903
|
+
if (this._isStarted && !this._isPaused) {
|
|
904
|
+
this._setFeedDownloadState(feed);
|
|
905
|
+
}
|
|
811
906
|
}
|
|
812
907
|
setWriteFeed(feed) {
|
|
813
|
-
invariant6(!this._writer, "Writer already set."
|
|
814
|
-
|
|
908
|
+
invariant6(!this._writer, "Writer already set.", {
|
|
909
|
+
F: __dxlog_file7,
|
|
910
|
+
L: 257,
|
|
911
|
+
S: this,
|
|
912
|
+
A: [
|
|
913
|
+
"!this._writer",
|
|
914
|
+
"'Writer already set.'"
|
|
915
|
+
]
|
|
916
|
+
});
|
|
917
|
+
invariant6(feed.properties.writable, "Feed must be writable.", {
|
|
918
|
+
F: __dxlog_file7,
|
|
919
|
+
L: 258,
|
|
920
|
+
S: this,
|
|
921
|
+
A: [
|
|
922
|
+
"feed.properties.writable",
|
|
923
|
+
"'Feed must be writable.'"
|
|
924
|
+
]
|
|
925
|
+
});
|
|
815
926
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
816
927
|
timeframe: this._timeframeClock.timeframe,
|
|
817
928
|
payload
|
|
818
929
|
}), feed.createFeedWriter());
|
|
819
930
|
}
|
|
820
931
|
async start() {
|
|
932
|
+
invariant6(!this._isStarted, "Pipeline is already started.", {
|
|
933
|
+
F: __dxlog_file7,
|
|
934
|
+
L: 271,
|
|
935
|
+
S: this,
|
|
936
|
+
A: [
|
|
937
|
+
"!this._isStarted",
|
|
938
|
+
"'Pipeline is already started.'"
|
|
939
|
+
]
|
|
940
|
+
});
|
|
821
941
|
log6("starting...", void 0, {
|
|
822
|
-
F:
|
|
823
|
-
L:
|
|
942
|
+
F: __dxlog_file7,
|
|
943
|
+
L: 272,
|
|
824
944
|
S: this,
|
|
825
945
|
C: (f, a) => f(...a)
|
|
826
946
|
});
|
|
@@ -828,30 +948,34 @@ var Pipeline = class {
|
|
|
828
948
|
await this._feedSetIterator.open();
|
|
829
949
|
this._isStarted = true;
|
|
830
950
|
log6("started", void 0, {
|
|
831
|
-
F:
|
|
832
|
-
L:
|
|
951
|
+
F: __dxlog_file7,
|
|
952
|
+
L: 276,
|
|
833
953
|
S: this,
|
|
834
954
|
C: (f, a) => f(...a)
|
|
835
955
|
});
|
|
956
|
+
if (!this._isPaused) {
|
|
957
|
+
for (const feed of this._feeds.values()) {
|
|
958
|
+
this._setFeedDownloadState(feed);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
836
961
|
}
|
|
837
962
|
async stop() {
|
|
838
|
-
var _a;
|
|
839
963
|
log6("stopping...", void 0, {
|
|
840
|
-
F:
|
|
841
|
-
L:
|
|
964
|
+
F: __dxlog_file7,
|
|
965
|
+
L: 287,
|
|
842
966
|
S: this,
|
|
843
967
|
C: (f, a) => f(...a)
|
|
844
968
|
});
|
|
845
969
|
this._isStopping = true;
|
|
846
|
-
await
|
|
970
|
+
await this._feedSetIterator?.close();
|
|
847
971
|
await this._processingTrigger.wait();
|
|
848
972
|
await this._state._ctx.dispose();
|
|
849
973
|
this._state._ctx = new Context2();
|
|
850
974
|
this._state._reachedTargetPromise = void 0;
|
|
851
975
|
this._isStarted = false;
|
|
852
976
|
log6("stopped", void 0, {
|
|
853
|
-
F:
|
|
854
|
-
L:
|
|
977
|
+
F: __dxlog_file7,
|
|
978
|
+
L: 295,
|
|
855
979
|
S: this,
|
|
856
980
|
C: (f, a) => f(...a)
|
|
857
981
|
});
|
|
@@ -861,12 +985,17 @@ var Pipeline = class {
|
|
|
861
985
|
* The pipeline will start processing messages AFTER this timeframe.
|
|
862
986
|
*/
|
|
863
987
|
async setCursor(timeframe) {
|
|
864
|
-
invariant6(!this._isStarted || this._isPaused, "Invalid state."
|
|
988
|
+
invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
989
|
+
F: __dxlog_file7,
|
|
990
|
+
L: 304,
|
|
991
|
+
S: this,
|
|
992
|
+
A: [
|
|
993
|
+
"!this._isStarted || this._isPaused",
|
|
994
|
+
"'Invalid state.'"
|
|
995
|
+
]
|
|
996
|
+
});
|
|
865
997
|
this._state._startTimeframe = timeframe;
|
|
866
998
|
this._timeframeClock.setTimeframe(timeframe);
|
|
867
|
-
for (const feed of this._feeds.values()) {
|
|
868
|
-
this._setFeedDownloadState(feed);
|
|
869
|
-
}
|
|
870
999
|
if (this._feedSetIterator) {
|
|
871
1000
|
await this._feedSetIterator.close();
|
|
872
1001
|
await this._initIterator();
|
|
@@ -877,7 +1006,6 @@ var Pipeline = class {
|
|
|
877
1006
|
* Calling pause while processing will cause a deadlock.
|
|
878
1007
|
*/
|
|
879
1008
|
async pause() {
|
|
880
|
-
invariant6(this._isStarted, "Pipeline is not open.");
|
|
881
1009
|
if (this._isPaused) {
|
|
882
1010
|
return;
|
|
883
1011
|
}
|
|
@@ -886,31 +1014,65 @@ var Pipeline = class {
|
|
|
886
1014
|
this._isPaused = true;
|
|
887
1015
|
}
|
|
888
1016
|
async unpause() {
|
|
889
|
-
invariant6(this.
|
|
890
|
-
|
|
1017
|
+
invariant6(this._isPaused, "Pipeline is not paused.", {
|
|
1018
|
+
F: __dxlog_file7,
|
|
1019
|
+
L: 334,
|
|
1020
|
+
S: this,
|
|
1021
|
+
A: [
|
|
1022
|
+
"this._isPaused",
|
|
1023
|
+
"'Pipeline is not paused.'"
|
|
1024
|
+
]
|
|
1025
|
+
});
|
|
891
1026
|
this._pauseTrigger.wake();
|
|
892
1027
|
this._isPaused = false;
|
|
1028
|
+
for (const feed of this._feeds.values()) {
|
|
1029
|
+
this._setFeedDownloadState(feed);
|
|
1030
|
+
}
|
|
893
1031
|
}
|
|
894
1032
|
/**
|
|
895
1033
|
* Starts to iterate over the ordered messages from the added feeds.
|
|
896
1034
|
* Updates the timeframe clock after the message has bee processed.
|
|
897
1035
|
*/
|
|
898
1036
|
async *consume() {
|
|
899
|
-
invariant6(!this.
|
|
900
|
-
|
|
901
|
-
|
|
1037
|
+
invariant6(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
1038
|
+
F: __dxlog_file7,
|
|
1039
|
+
L: 349,
|
|
1040
|
+
S: this,
|
|
1041
|
+
A: [
|
|
1042
|
+
"!this._isBeingConsumed",
|
|
1043
|
+
"'Pipeline is already being consumed.'"
|
|
1044
|
+
]
|
|
1045
|
+
});
|
|
1046
|
+
this._isBeingConsumed = true;
|
|
1047
|
+
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1048
|
+
F: __dxlog_file7,
|
|
1049
|
+
L: 352,
|
|
1050
|
+
S: this,
|
|
1051
|
+
A: [
|
|
1052
|
+
"this._feedSetIterator",
|
|
1053
|
+
"'Iterator not initialized.'"
|
|
1054
|
+
]
|
|
1055
|
+
});
|
|
902
1056
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
903
1057
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
904
1058
|
while (!this._isStopping) {
|
|
905
1059
|
await this._pauseTrigger.wait();
|
|
906
1060
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
907
|
-
invariant6(this._feedSetIterator, "Iterator not initialized."
|
|
1061
|
+
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1062
|
+
F: __dxlog_file7,
|
|
1063
|
+
L: 361,
|
|
1064
|
+
S: this,
|
|
1065
|
+
A: [
|
|
1066
|
+
"this._feedSetIterator",
|
|
1067
|
+
"'Iterator not initialized.'"
|
|
1068
|
+
]
|
|
1069
|
+
});
|
|
908
1070
|
lastFeedSetIterator = this._feedSetIterator;
|
|
909
1071
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
910
1072
|
}
|
|
911
1073
|
const { done, value } = await iterable.next();
|
|
912
1074
|
if (!done) {
|
|
913
|
-
const block = value
|
|
1075
|
+
const block = value ?? failUndefined();
|
|
914
1076
|
this._processingTrigger.reset();
|
|
915
1077
|
this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
|
|
916
1078
|
yield block;
|
|
@@ -918,16 +1080,31 @@ var Pipeline = class {
|
|
|
918
1080
|
this._timeframeClock.updateTimeframe();
|
|
919
1081
|
}
|
|
920
1082
|
}
|
|
921
|
-
this.
|
|
1083
|
+
this._isBeingConsumed = false;
|
|
922
1084
|
}
|
|
923
1085
|
_setFeedDownloadState(feed) {
|
|
924
|
-
var _a;
|
|
925
1086
|
const timeframe = this._state._startTimeframe;
|
|
926
|
-
const seq =
|
|
1087
|
+
const seq = timeframe.get(feed.key) ?? -1;
|
|
1088
|
+
log6.info("setFeedDownloadState", {
|
|
1089
|
+
feed: feed.key,
|
|
1090
|
+
feedInstance: getPrototypeSpecificInstanceId(feed),
|
|
1091
|
+
seq,
|
|
1092
|
+
isBeingConsumed: this._isBeingConsumed,
|
|
1093
|
+
isStarted: this._isStarted,
|
|
1094
|
+
isPaused: this._isPaused
|
|
1095
|
+
}, {
|
|
1096
|
+
F: __dxlog_file7,
|
|
1097
|
+
L: 386,
|
|
1098
|
+
S: this,
|
|
1099
|
+
C: (f, a) => f(...a)
|
|
1100
|
+
});
|
|
1101
|
+
if (!this._isStarted || this._isPaused) {
|
|
1102
|
+
console.log(new Error().stack);
|
|
1103
|
+
}
|
|
927
1104
|
feed.undownload({
|
|
928
1105
|
callback: () => log6("undownload", void 0, {
|
|
929
|
-
F:
|
|
930
|
-
L:
|
|
1106
|
+
F: __dxlog_file7,
|
|
1107
|
+
L: 398,
|
|
931
1108
|
S: this,
|
|
932
1109
|
C: (f, a) => f(...a)
|
|
933
1110
|
})
|
|
@@ -939,8 +1116,8 @@ var Pipeline = class {
|
|
|
939
1116
|
log6("failed to download feed", {
|
|
940
1117
|
err
|
|
941
1118
|
}, {
|
|
942
|
-
F:
|
|
943
|
-
L:
|
|
1119
|
+
F: __dxlog_file7,
|
|
1120
|
+
L: 400,
|
|
944
1121
|
S: this,
|
|
945
1122
|
C: (f, a) => f(...a)
|
|
946
1123
|
});
|
|
@@ -953,8 +1130,8 @@ var Pipeline = class {
|
|
|
953
1130
|
});
|
|
954
1131
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
955
1132
|
log6.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
956
|
-
F:
|
|
957
|
-
L:
|
|
1133
|
+
F: __dxlog_file7,
|
|
1134
|
+
L: 411,
|
|
958
1135
|
S: this,
|
|
959
1136
|
C: (f, a) => f(...a)
|
|
960
1137
|
});
|
|
@@ -982,14 +1159,14 @@ _ts_decorate4([
|
|
|
982
1159
|
], Pipeline.prototype, "unpause", null);
|
|
983
1160
|
|
|
984
1161
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
985
|
-
import invariant7 from "tiny-invariant";
|
|
986
1162
|
import { runInContext, scheduleTask } from "@dxos/async";
|
|
987
1163
|
import { Context as Context3 } from "@dxos/context";
|
|
988
1164
|
import { randomBytes } from "@dxos/crypto";
|
|
1165
|
+
import { invariant as invariant7 } from "@dxos/invariant";
|
|
989
1166
|
import { log as log7 } from "@dxos/log";
|
|
990
1167
|
import { schema as schema5 } from "@dxos/protocols";
|
|
991
1168
|
import { RpcExtension } from "@dxos/teleport";
|
|
992
|
-
var
|
|
1169
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
993
1170
|
var AuthExtension = class extends RpcExtension {
|
|
994
1171
|
constructor(_authParams) {
|
|
995
1172
|
super({
|
|
@@ -1005,8 +1182,8 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1005
1182
|
this._ctx = new Context3({
|
|
1006
1183
|
onError: (err) => {
|
|
1007
1184
|
log7.catch(err, void 0, {
|
|
1008
|
-
F:
|
|
1009
|
-
L:
|
|
1185
|
+
F: __dxlog_file8,
|
|
1186
|
+
L: 28,
|
|
1010
1187
|
S: this,
|
|
1011
1188
|
C: (f, a) => f(...a)
|
|
1012
1189
|
});
|
|
@@ -1027,8 +1204,8 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1027
1204
|
};
|
|
1028
1205
|
} catch (err) {
|
|
1029
1206
|
log7.error("failed to generate auth credentials", err, {
|
|
1030
|
-
F:
|
|
1031
|
-
L:
|
|
1207
|
+
F: __dxlog_file8,
|
|
1208
|
+
L: 55,
|
|
1032
1209
|
S: this,
|
|
1033
1210
|
C: (f, a) => f(...a)
|
|
1034
1211
|
});
|
|
@@ -1046,14 +1223,30 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1046
1223
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1047
1224
|
challenge
|
|
1048
1225
|
});
|
|
1049
|
-
invariant7(
|
|
1226
|
+
invariant7(credential?.length > 0, "invalid credential", {
|
|
1227
|
+
F: __dxlog_file8,
|
|
1228
|
+
L: 69,
|
|
1229
|
+
S: this,
|
|
1230
|
+
A: [
|
|
1231
|
+
"credential?.length > 0",
|
|
1232
|
+
"'invalid credential'"
|
|
1233
|
+
]
|
|
1234
|
+
});
|
|
1050
1235
|
const success = await this._authParams.verifier(challenge, credential);
|
|
1051
|
-
invariant7(success, "credential not verified"
|
|
1236
|
+
invariant7(success, "credential not verified", {
|
|
1237
|
+
F: __dxlog_file8,
|
|
1238
|
+
L: 71,
|
|
1239
|
+
S: this,
|
|
1240
|
+
A: [
|
|
1241
|
+
"success",
|
|
1242
|
+
"'credential not verified'"
|
|
1243
|
+
]
|
|
1244
|
+
});
|
|
1052
1245
|
runInContext(this._ctx, () => this._authParams.onAuthSuccess());
|
|
1053
1246
|
} catch (err) {
|
|
1054
1247
|
log7("auth failed", err, {
|
|
1055
|
-
F:
|
|
1056
|
-
L:
|
|
1248
|
+
F: __dxlog_file8,
|
|
1249
|
+
L: 74,
|
|
1057
1250
|
S: this,
|
|
1058
1251
|
C: (f, a) => f(...a)
|
|
1059
1252
|
});
|
|
@@ -1069,12 +1262,12 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1069
1262
|
};
|
|
1070
1263
|
|
|
1071
1264
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1072
|
-
import invariant8 from "tiny-invariant";
|
|
1073
1265
|
import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1074
1266
|
import { Context as Context4 } from "@dxos/context";
|
|
1075
1267
|
import { checkCredentialType } from "@dxos/credentials";
|
|
1076
1268
|
import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
|
|
1077
1269
|
import { CancelledError } from "@dxos/errors";
|
|
1270
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
1078
1271
|
import { log as log8 } from "@dxos/log";
|
|
1079
1272
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1080
1273
|
import { tracer } from "@dxos/util";
|
|
@@ -1088,7 +1281,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1088
1281
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1089
1282
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1090
1283
|
}
|
|
1091
|
-
var
|
|
1284
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1092
1285
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1093
1286
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1094
1287
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
@@ -1114,13 +1307,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1114
1307
|
return this._pipeline;
|
|
1115
1308
|
}
|
|
1116
1309
|
get pipelineState() {
|
|
1117
|
-
|
|
1118
|
-
return (_a = this._pipeline) == null ? void 0 : _a.state;
|
|
1310
|
+
return this._pipeline?.state;
|
|
1119
1311
|
}
|
|
1120
1312
|
setTargetTimeframe(timeframe) {
|
|
1121
|
-
var _a;
|
|
1122
1313
|
this._targetTimeframe = timeframe;
|
|
1123
|
-
|
|
1314
|
+
this._pipeline?.state.setTargetTimeframe(timeframe);
|
|
1124
1315
|
}
|
|
1125
1316
|
async processCredential(credential) {
|
|
1126
1317
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -1137,15 +1328,31 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1137
1328
|
}
|
|
1138
1329
|
this._pipeline = new Pipeline();
|
|
1139
1330
|
await this._params.onPipelineCreated(this._pipeline);
|
|
1140
|
-
await this._pipeline.start();
|
|
1141
1331
|
await this._pipeline.pause();
|
|
1332
|
+
await this._pipeline.start();
|
|
1142
1333
|
if (this._targetTimeframe) {
|
|
1143
1334
|
this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
|
|
1144
1335
|
}
|
|
1145
1336
|
const feedWriter = {
|
|
1146
1337
|
write: (data, options) => {
|
|
1147
|
-
invariant8(this._pipeline, "Pipeline is not initialized."
|
|
1148
|
-
|
|
1338
|
+
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1339
|
+
F: __dxlog_file9,
|
|
1340
|
+
L: 146,
|
|
1341
|
+
S: this,
|
|
1342
|
+
A: [
|
|
1343
|
+
"this._pipeline",
|
|
1344
|
+
"'Pipeline is not initialized.'"
|
|
1345
|
+
]
|
|
1346
|
+
});
|
|
1347
|
+
invariant8(this.currentEpoch, "Epoch is not initialized.", {
|
|
1348
|
+
F: __dxlog_file9,
|
|
1349
|
+
L: 147,
|
|
1350
|
+
S: this,
|
|
1351
|
+
A: [
|
|
1352
|
+
"this.currentEpoch",
|
|
1353
|
+
"'Epoch is not initialized.'"
|
|
1354
|
+
]
|
|
1355
|
+
});
|
|
1149
1356
|
return this._pipeline.writer.write({
|
|
1150
1357
|
data
|
|
1151
1358
|
}, options);
|
|
@@ -1160,19 +1367,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1160
1367
|
this._isOpen = true;
|
|
1161
1368
|
}
|
|
1162
1369
|
async close() {
|
|
1163
|
-
var _a, _b, _c;
|
|
1164
1370
|
if (!this._isOpen) {
|
|
1165
1371
|
return;
|
|
1166
1372
|
}
|
|
1167
1373
|
log8("close", void 0, {
|
|
1168
|
-
F:
|
|
1374
|
+
F: __dxlog_file9,
|
|
1169
1375
|
L: 171,
|
|
1170
1376
|
S: this,
|
|
1171
1377
|
C: (f, a) => f(...a)
|
|
1172
1378
|
});
|
|
1173
1379
|
this._isOpen = false;
|
|
1174
1380
|
await this._ctx.dispose();
|
|
1175
|
-
await
|
|
1381
|
+
await this._pipeline?.stop();
|
|
1176
1382
|
try {
|
|
1177
1383
|
await this._saveCache();
|
|
1178
1384
|
if (this._pipeline) {
|
|
@@ -1180,14 +1386,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1180
1386
|
}
|
|
1181
1387
|
} catch (err) {
|
|
1182
1388
|
log8.catch(err, void 0, {
|
|
1183
|
-
F:
|
|
1389
|
+
F: __dxlog_file9,
|
|
1184
1390
|
L: 184,
|
|
1185
1391
|
S: this,
|
|
1186
1392
|
C: (f, a) => f(...a)
|
|
1187
1393
|
});
|
|
1188
1394
|
}
|
|
1189
|
-
await
|
|
1190
|
-
await
|
|
1395
|
+
await this.databaseHost?.close();
|
|
1396
|
+
await this.itemManager?.destroy();
|
|
1191
1397
|
this._ctx = new Context4();
|
|
1192
1398
|
this._pipeline = void 0;
|
|
1193
1399
|
this._targetTimeframe = void 0;
|
|
@@ -1203,14 +1409,22 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1203
1409
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1204
1410
|
await waitForOneEpoch;
|
|
1205
1411
|
}
|
|
1206
|
-
invariant8(this._pipeline, "Pipeline is not initialized."
|
|
1412
|
+
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1413
|
+
F: __dxlog_file9,
|
|
1414
|
+
L: 207,
|
|
1415
|
+
S: this,
|
|
1416
|
+
A: [
|
|
1417
|
+
"this._pipeline",
|
|
1418
|
+
"'Pipeline is not initialized.'"
|
|
1419
|
+
]
|
|
1420
|
+
});
|
|
1207
1421
|
for await (const msg of this._pipeline.consume()) {
|
|
1208
1422
|
const { feedKey, seq, data } = msg;
|
|
1209
1423
|
log8("processing message", {
|
|
1210
1424
|
feedKey,
|
|
1211
1425
|
seq
|
|
1212
1426
|
}, {
|
|
1213
|
-
F:
|
|
1427
|
+
F: __dxlog_file9,
|
|
1214
1428
|
L: 210,
|
|
1215
1429
|
S: this,
|
|
1216
1430
|
C: (f, a) => f(...a)
|
|
@@ -1222,7 +1436,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1222
1436
|
log8.warn("Could not find feed", {
|
|
1223
1437
|
feedKey
|
|
1224
1438
|
}, {
|
|
1225
|
-
F:
|
|
1439
|
+
F: __dxlog_file9,
|
|
1226
1440
|
L: 216,
|
|
1227
1441
|
S: this,
|
|
1228
1442
|
C: (f, a) => f(...a)
|
|
@@ -1245,7 +1459,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1245
1459
|
seq,
|
|
1246
1460
|
spaceKey: this._params.spaceKey.toHex()
|
|
1247
1461
|
}, {
|
|
1248
|
-
F:
|
|
1462
|
+
F: __dxlog_file9,
|
|
1249
1463
|
L: 233,
|
|
1250
1464
|
S: this,
|
|
1251
1465
|
C: (f, a) => f(...a)
|
|
@@ -1254,7 +1468,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1254
1468
|
}
|
|
1255
1469
|
} catch (err) {
|
|
1256
1470
|
log8.catch(err, void 0, {
|
|
1257
|
-
F:
|
|
1471
|
+
F: __dxlog_file9,
|
|
1258
1472
|
L: 243,
|
|
1259
1473
|
S: this,
|
|
1260
1474
|
C: (f, a) => f(...a)
|
|
@@ -1263,7 +1477,15 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1263
1477
|
}
|
|
1264
1478
|
}
|
|
1265
1479
|
_createSnapshot() {
|
|
1266
|
-
invariant8(this.databaseHost, "Database backend is not initialized."
|
|
1480
|
+
invariant8(this.databaseHost, "Database backend is not initialized.", {
|
|
1481
|
+
F: __dxlog_file9,
|
|
1482
|
+
L: 249,
|
|
1483
|
+
S: this,
|
|
1484
|
+
A: [
|
|
1485
|
+
"this.databaseHost",
|
|
1486
|
+
"'Database backend is not initialized.'"
|
|
1487
|
+
]
|
|
1488
|
+
});
|
|
1267
1489
|
return {
|
|
1268
1490
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1269
1491
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1271,25 +1493,21 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1271
1493
|
};
|
|
1272
1494
|
}
|
|
1273
1495
|
async _saveTargetTimeframe(timeframe) {
|
|
1274
|
-
|
|
1275
|
-
const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
|
|
1496
|
+
const newTimeframe = Timeframe3.merge(this._targetTimeframe ?? new Timeframe3(), timeframe);
|
|
1276
1497
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1277
1498
|
this._targetTimeframe = newTimeframe;
|
|
1278
1499
|
}
|
|
1279
1500
|
async _saveCache() {
|
|
1280
|
-
var _a;
|
|
1281
1501
|
const cache = {};
|
|
1282
1502
|
try {
|
|
1283
|
-
const propertiesItem = this.itemManager.items.find((item) =>
|
|
1284
|
-
|
|
1285
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
|
|
1286
|
-
});
|
|
1503
|
+
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1504
|
+
(getStateMachineFromItem(item)?.snapshot()).type === "dxos.sdk.client.Properties");
|
|
1287
1505
|
if (propertiesItem) {
|
|
1288
|
-
cache.properties =
|
|
1506
|
+
cache.properties = getStateMachineFromItem(propertiesItem)?.snapshot();
|
|
1289
1507
|
}
|
|
1290
1508
|
} catch (err) {
|
|
1291
1509
|
log8.warn("Failed to cache properties", err, {
|
|
1292
|
-
F:
|
|
1510
|
+
F: __dxlog_file9,
|
|
1293
1511
|
L: 278,
|
|
1294
1512
|
S: this,
|
|
1295
1513
|
C: (f, a) => f(...a)
|
|
@@ -1307,23 +1525,22 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1307
1525
|
}
|
|
1308
1526
|
}
|
|
1309
1527
|
async _processEpochInSeparateTask(epoch) {
|
|
1310
|
-
var _a;
|
|
1311
1528
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
1312
1529
|
return;
|
|
1313
1530
|
}
|
|
1314
|
-
await
|
|
1531
|
+
await this._epochCtx?.dispose();
|
|
1315
1532
|
const ctx = new Context4({
|
|
1316
1533
|
onError: (err) => {
|
|
1317
1534
|
if (err instanceof CancelledError) {
|
|
1318
1535
|
log8("Epoch processing cancelled.", void 0, {
|
|
1319
|
-
F:
|
|
1536
|
+
F: __dxlog_file9,
|
|
1320
1537
|
L: 310,
|
|
1321
1538
|
S: this,
|
|
1322
1539
|
C: (f, a) => f(...a)
|
|
1323
1540
|
});
|
|
1324
1541
|
} else {
|
|
1325
1542
|
log8.catch(err, void 0, {
|
|
1326
|
-
F:
|
|
1543
|
+
F: __dxlog_file9,
|
|
1327
1544
|
L: 312,
|
|
1328
1545
|
S: this,
|
|
1329
1546
|
C: (f, a) => f(...a)
|
|
@@ -1339,7 +1556,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1339
1556
|
log8("process epoch", {
|
|
1340
1557
|
epoch
|
|
1341
1558
|
}, {
|
|
1342
|
-
F:
|
|
1559
|
+
F: __dxlog_file9,
|
|
1343
1560
|
L: 322,
|
|
1344
1561
|
S: this,
|
|
1345
1562
|
C: (f, a) => f(...a)
|
|
@@ -1350,13 +1567,29 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1350
1567
|
});
|
|
1351
1568
|
}
|
|
1352
1569
|
async _processEpoch(ctx, epoch) {
|
|
1353
|
-
invariant8(this._isOpen, "Space is closed."
|
|
1354
|
-
|
|
1570
|
+
invariant8(this._isOpen, "Space is closed.", {
|
|
1571
|
+
F: __dxlog_file9,
|
|
1572
|
+
L: 332,
|
|
1573
|
+
S: this,
|
|
1574
|
+
A: [
|
|
1575
|
+
"this._isOpen",
|
|
1576
|
+
"'Space is closed.'"
|
|
1577
|
+
]
|
|
1578
|
+
});
|
|
1579
|
+
invariant8(this._pipeline, void 0, {
|
|
1580
|
+
F: __dxlog_file9,
|
|
1581
|
+
L: 333,
|
|
1582
|
+
S: this,
|
|
1583
|
+
A: [
|
|
1584
|
+
"this._pipeline",
|
|
1585
|
+
""
|
|
1586
|
+
]
|
|
1587
|
+
});
|
|
1355
1588
|
this._lastProcessedEpoch = epoch.number;
|
|
1356
1589
|
log8("Processing epoch", {
|
|
1357
1590
|
epoch
|
|
1358
1591
|
}, {
|
|
1359
|
-
F:
|
|
1592
|
+
F: __dxlog_file9,
|
|
1360
1593
|
L: 336,
|
|
1361
1594
|
S: this,
|
|
1362
1595
|
C: (f, a) => f(...a)
|
|
@@ -1366,7 +1599,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1366
1599
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1367
1600
|
}
|
|
1368
1601
|
log8("restarting pipeline for epoch", void 0, {
|
|
1369
|
-
F:
|
|
1602
|
+
F: __dxlog_file9,
|
|
1370
1603
|
L: 344,
|
|
1371
1604
|
S: this,
|
|
1372
1605
|
C: (f, a) => f(...a)
|
|
@@ -1376,12 +1609,36 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1376
1609
|
await this._pipeline.unpause();
|
|
1377
1610
|
}
|
|
1378
1611
|
async waitUntilTimeframe(timeframe) {
|
|
1379
|
-
invariant8(this._pipeline, "Pipeline is not initialized."
|
|
1612
|
+
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1613
|
+
F: __dxlog_file9,
|
|
1614
|
+
L: 352,
|
|
1615
|
+
S: this,
|
|
1616
|
+
A: [
|
|
1617
|
+
"this._pipeline",
|
|
1618
|
+
"'Pipeline is not initialized.'"
|
|
1619
|
+
]
|
|
1620
|
+
});
|
|
1380
1621
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1381
1622
|
}
|
|
1382
1623
|
async createEpoch() {
|
|
1383
|
-
invariant8(this._pipeline
|
|
1384
|
-
|
|
1624
|
+
invariant8(this._pipeline, void 0, {
|
|
1625
|
+
F: __dxlog_file9,
|
|
1626
|
+
L: 358,
|
|
1627
|
+
S: this,
|
|
1628
|
+
A: [
|
|
1629
|
+
"this._pipeline",
|
|
1630
|
+
""
|
|
1631
|
+
]
|
|
1632
|
+
});
|
|
1633
|
+
invariant8(this.currentEpoch, void 0, {
|
|
1634
|
+
F: __dxlog_file9,
|
|
1635
|
+
L: 359,
|
|
1636
|
+
S: this,
|
|
1637
|
+
A: [
|
|
1638
|
+
"this.currentEpoch",
|
|
1639
|
+
""
|
|
1640
|
+
]
|
|
1641
|
+
});
|
|
1385
1642
|
await this._pipeline.pause();
|
|
1386
1643
|
const snapshot = await this._createSnapshot();
|
|
1387
1644
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1415,10 +1672,11 @@ DataPipeline = _ts_decorate5([
|
|
|
1415
1672
|
], DataPipeline);
|
|
1416
1673
|
|
|
1417
1674
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1418
|
-
import invariant9 from "tiny-invariant";
|
|
1419
1675
|
import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
|
|
1676
|
+
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1420
1677
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1421
1678
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1679
|
+
import { trace } from "@dxos/tracing";
|
|
1422
1680
|
import { Callback as Callback2 } from "@dxos/util";
|
|
1423
1681
|
|
|
1424
1682
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
@@ -1428,7 +1686,7 @@ import { log as log9 } from "@dxos/log";
|
|
|
1428
1686
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1429
1687
|
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
1430
1688
|
import { Callback, tracer as tracer2 } from "@dxos/util";
|
|
1431
|
-
var
|
|
1689
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1432
1690
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1433
1691
|
var ControlPipeline = class {
|
|
1434
1692
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
@@ -1443,7 +1701,7 @@ var ControlPipeline = class {
|
|
|
1443
1701
|
log9("feed admitted", {
|
|
1444
1702
|
key: info.key
|
|
1445
1703
|
}, {
|
|
1446
|
-
F:
|
|
1704
|
+
F: __dxlog_file10,
|
|
1447
1705
|
L: 51,
|
|
1448
1706
|
S: this,
|
|
1449
1707
|
C: (f, a) => f(...a)
|
|
@@ -1454,7 +1712,7 @@ var ControlPipeline = class {
|
|
|
1454
1712
|
await this._pipeline.addFeed(feed);
|
|
1455
1713
|
} catch (err) {
|
|
1456
1714
|
log9.catch(err, void 0, {
|
|
1457
|
-
F:
|
|
1715
|
+
F: __dxlog_file10,
|
|
1458
1716
|
L: 59,
|
|
1459
1717
|
S: this,
|
|
1460
1718
|
C: (f, a) => f(...a)
|
|
@@ -1477,7 +1735,7 @@ var ControlPipeline = class {
|
|
|
1477
1735
|
}
|
|
1478
1736
|
async start() {
|
|
1479
1737
|
log9("starting...", void 0, {
|
|
1480
|
-
F:
|
|
1738
|
+
F: __dxlog_file10,
|
|
1481
1739
|
L: 83,
|
|
1482
1740
|
S: this,
|
|
1483
1741
|
C: (f, a) => f(...a)
|
|
@@ -1489,7 +1747,7 @@ var ControlPipeline = class {
|
|
|
1489
1747
|
key: msg.feedKey,
|
|
1490
1748
|
seq: msg.seq
|
|
1491
1749
|
}, {
|
|
1492
|
-
F:
|
|
1750
|
+
F: __dxlog_file10,
|
|
1493
1751
|
L: 88,
|
|
1494
1752
|
S: this,
|
|
1495
1753
|
C: (f, a) => f(...a)
|
|
@@ -1502,7 +1760,7 @@ var ControlPipeline = class {
|
|
|
1502
1760
|
log9.warn("processing failed", {
|
|
1503
1761
|
msg
|
|
1504
1762
|
}, {
|
|
1505
|
-
F:
|
|
1763
|
+
F: __dxlog_file10,
|
|
1506
1764
|
L: 98,
|
|
1507
1765
|
S: this,
|
|
1508
1766
|
C: (f, a) => f(...a)
|
|
@@ -1513,7 +1771,7 @@ var ControlPipeline = class {
|
|
|
1513
1771
|
}
|
|
1514
1772
|
} catch (err) {
|
|
1515
1773
|
log9.catch(err, void 0, {
|
|
1516
|
-
F:
|
|
1774
|
+
F: __dxlog_file10,
|
|
1517
1775
|
L: 104,
|
|
1518
1776
|
S: this,
|
|
1519
1777
|
C: (f, a) => f(...a)
|
|
@@ -1523,7 +1781,7 @@ var ControlPipeline = class {
|
|
|
1523
1781
|
});
|
|
1524
1782
|
await this._pipeline.start();
|
|
1525
1783
|
log9("started", void 0, {
|
|
1526
|
-
F:
|
|
1784
|
+
F: __dxlog_file10,
|
|
1527
1785
|
L: 110,
|
|
1528
1786
|
S: this,
|
|
1529
1787
|
C: (f, a) => f(...a)
|
|
@@ -1537,7 +1795,7 @@ var ControlPipeline = class {
|
|
|
1537
1795
|
}
|
|
1538
1796
|
async stop() {
|
|
1539
1797
|
log9("stopping...", void 0, {
|
|
1540
|
-
F:
|
|
1798
|
+
F: __dxlog_file10,
|
|
1541
1799
|
L: 124,
|
|
1542
1800
|
S: this,
|
|
1543
1801
|
C: (f, a) => f(...a)
|
|
@@ -1545,21 +1803,20 @@ var ControlPipeline = class {
|
|
|
1545
1803
|
await this._pipeline.stop();
|
|
1546
1804
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1547
1805
|
log9("stopped", void 0, {
|
|
1548
|
-
F:
|
|
1806
|
+
F: __dxlog_file10,
|
|
1549
1807
|
L: 127,
|
|
1550
1808
|
S: this,
|
|
1551
1809
|
C: (f, a) => f(...a)
|
|
1552
1810
|
});
|
|
1553
1811
|
}
|
|
1554
1812
|
async _saveTargetTimeframe(timeframe) {
|
|
1555
|
-
var _a;
|
|
1556
1813
|
try {
|
|
1557
|
-
const newTimeframe = Timeframe4.merge(
|
|
1814
|
+
const newTimeframe = Timeframe4.merge(this._targetTimeframe ?? new Timeframe4(), timeframe);
|
|
1558
1815
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1559
1816
|
this._targetTimeframe = newTimeframe;
|
|
1560
1817
|
} catch (err) {
|
|
1561
1818
|
log9(err, void 0, {
|
|
1562
|
-
F:
|
|
1819
|
+
F: __dxlog_file10,
|
|
1563
1820
|
L: 136,
|
|
1564
1821
|
S: this,
|
|
1565
1822
|
C: (f, a) => f(...a)
|
|
@@ -1579,14 +1836,22 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1579
1836
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1580
1837
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1581
1838
|
}
|
|
1582
|
-
var
|
|
1839
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1583
1840
|
var Space = class Space2 {
|
|
1584
1841
|
constructor(params) {
|
|
1585
1842
|
this._addFeedLock = new Lock();
|
|
1586
1843
|
this.onCredentialProcessed = new Callback2();
|
|
1587
1844
|
this.stateUpdate = new Event5();
|
|
1588
1845
|
this._isOpen = false;
|
|
1589
|
-
invariant9(params.spaceKey && params.feedProvider
|
|
1846
|
+
invariant9(params.spaceKey && params.feedProvider, void 0, {
|
|
1847
|
+
F: __dxlog_file11,
|
|
1848
|
+
L: 73,
|
|
1849
|
+
S: this,
|
|
1850
|
+
A: [
|
|
1851
|
+
"params.spaceKey && params.feedProvider",
|
|
1852
|
+
""
|
|
1853
|
+
]
|
|
1854
|
+
});
|
|
1590
1855
|
this._key = params.spaceKey;
|
|
1591
1856
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1592
1857
|
this._feedProvider = params.feedProvider;
|
|
@@ -1621,8 +1886,8 @@ var Space = class Space2 {
|
|
|
1621
1886
|
log10("onCredentialProcessed", {
|
|
1622
1887
|
credential
|
|
1623
1888
|
}, {
|
|
1624
|
-
F:
|
|
1625
|
-
L:
|
|
1889
|
+
F: __dxlog_file11,
|
|
1890
|
+
L: 109,
|
|
1626
1891
|
S: this,
|
|
1627
1892
|
C: (f, a) => f(...a)
|
|
1628
1893
|
});
|
|
@@ -1664,12 +1929,10 @@ var Space = class Space2 {
|
|
|
1664
1929
|
return this._genesisFeedKey;
|
|
1665
1930
|
}
|
|
1666
1931
|
get controlFeedKey() {
|
|
1667
|
-
|
|
1668
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
1932
|
+
return this._controlFeed?.key;
|
|
1669
1933
|
}
|
|
1670
1934
|
get dataFeedKey() {
|
|
1671
|
-
|
|
1672
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
1935
|
+
return this._dataFeed?.key;
|
|
1673
1936
|
}
|
|
1674
1937
|
get spaceState() {
|
|
1675
1938
|
return this._controlPipeline.spaceState;
|
|
@@ -1687,16 +1950,31 @@ var Space = class Space2 {
|
|
|
1687
1950
|
return this._snapshotManager;
|
|
1688
1951
|
}
|
|
1689
1952
|
setControlFeed(feed) {
|
|
1690
|
-
invariant9(!this._controlFeed, "Control feed already set."
|
|
1953
|
+
invariant9(!this._controlFeed, "Control feed already set.", {
|
|
1954
|
+
F: __dxlog_file11,
|
|
1955
|
+
L: 183,
|
|
1956
|
+
S: this,
|
|
1957
|
+
A: [
|
|
1958
|
+
"!this._controlFeed",
|
|
1959
|
+
"'Control feed already set.'"
|
|
1960
|
+
]
|
|
1961
|
+
});
|
|
1691
1962
|
this._controlFeed = feed;
|
|
1692
1963
|
this._controlPipeline.setWriteFeed(feed);
|
|
1693
1964
|
return this;
|
|
1694
1965
|
}
|
|
1695
1966
|
setDataFeed(feed) {
|
|
1696
|
-
|
|
1697
|
-
|
|
1967
|
+
invariant9(!this._dataFeed, "Data feed already set.", {
|
|
1968
|
+
F: __dxlog_file11,
|
|
1969
|
+
L: 190,
|
|
1970
|
+
S: this,
|
|
1971
|
+
A: [
|
|
1972
|
+
"!this._dataFeed",
|
|
1973
|
+
"'Data feed already set.'"
|
|
1974
|
+
]
|
|
1975
|
+
});
|
|
1698
1976
|
this._dataFeed = feed;
|
|
1699
|
-
|
|
1977
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1700
1978
|
return this;
|
|
1701
1979
|
}
|
|
1702
1980
|
/**
|
|
@@ -1711,10 +1989,10 @@ var Space = class Space2 {
|
|
|
1711
1989
|
// getDataFeeds(): FeedInfo[] {
|
|
1712
1990
|
// return this._dataPipeline?.getFeeds();
|
|
1713
1991
|
// }
|
|
1714
|
-
async open() {
|
|
1992
|
+
async open(ctx) {
|
|
1715
1993
|
log10("opening...", void 0, {
|
|
1716
|
-
F:
|
|
1717
|
-
L:
|
|
1994
|
+
F: __dxlog_file11,
|
|
1995
|
+
L: 212,
|
|
1718
1996
|
S: this,
|
|
1719
1997
|
C: (f, a) => f(...a)
|
|
1720
1998
|
});
|
|
@@ -1726,8 +2004,8 @@ var Space = class Space2 {
|
|
|
1726
2004
|
await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
|
|
1727
2005
|
this._isOpen = true;
|
|
1728
2006
|
log10("opened", void 0, {
|
|
1729
|
-
F:
|
|
1730
|
-
L:
|
|
2007
|
+
F: __dxlog_file11,
|
|
2008
|
+
L: 223,
|
|
1731
2009
|
S: this,
|
|
1732
2010
|
C: (f, a) => f(...a)
|
|
1733
2011
|
});
|
|
@@ -1736,8 +2014,8 @@ var Space = class Space2 {
|
|
|
1736
2014
|
log10("closing...", {
|
|
1737
2015
|
key: this._key
|
|
1738
2016
|
}, {
|
|
1739
|
-
F:
|
|
1740
|
-
L:
|
|
2017
|
+
F: __dxlog_file11,
|
|
2018
|
+
L: 228,
|
|
1741
2019
|
S: this,
|
|
1742
2020
|
C: (f, a) => f(...a)
|
|
1743
2021
|
});
|
|
@@ -1750,20 +2028,28 @@ var Space = class Space2 {
|
|
|
1750
2028
|
await this._controlPipeline.stop();
|
|
1751
2029
|
this._isOpen = false;
|
|
1752
2030
|
log10("closed", void 0, {
|
|
1753
|
-
F:
|
|
1754
|
-
L:
|
|
2031
|
+
F: __dxlog_file11,
|
|
2032
|
+
L: 241,
|
|
1755
2033
|
S: this,
|
|
1756
2034
|
C: (f, a) => f(...a)
|
|
1757
2035
|
});
|
|
1758
2036
|
}
|
|
1759
2037
|
async initializeDataPipeline() {
|
|
1760
2038
|
log10("initializeDataPipeline", void 0, {
|
|
1761
|
-
F:
|
|
1762
|
-
L:
|
|
2039
|
+
F: __dxlog_file11,
|
|
2040
|
+
L: 246,
|
|
1763
2041
|
S: this,
|
|
1764
2042
|
C: (f, a) => f(...a)
|
|
1765
2043
|
});
|
|
1766
|
-
invariant9(this._isOpen, "Space must be open to initialize data pipeline."
|
|
2044
|
+
invariant9(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2045
|
+
F: __dxlog_file11,
|
|
2046
|
+
L: 247,
|
|
2047
|
+
S: this,
|
|
2048
|
+
A: [
|
|
2049
|
+
"this._isOpen",
|
|
2050
|
+
"'Space must be open to initialize data pipeline.'"
|
|
2051
|
+
]
|
|
2052
|
+
});
|
|
1767
2053
|
await this._dataPipeline.open();
|
|
1768
2054
|
}
|
|
1769
2055
|
};
|
|
@@ -1771,7 +2057,8 @@ _ts_decorate6([
|
|
|
1771
2057
|
logInfo
|
|
1772
2058
|
], Space.prototype, "key", null);
|
|
1773
2059
|
_ts_decorate6([
|
|
1774
|
-
synchronized4
|
|
2060
|
+
synchronized4,
|
|
2061
|
+
trace.span()
|
|
1775
2062
|
], Space.prototype, "open", null);
|
|
1776
2063
|
_ts_decorate6([
|
|
1777
2064
|
synchronized4
|
|
@@ -1780,7 +2067,8 @@ _ts_decorate6([
|
|
|
1780
2067
|
synchronized4
|
|
1781
2068
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1782
2069
|
Space = _ts_decorate6([
|
|
1783
|
-
trackLeaks3("open", "close")
|
|
2070
|
+
trackLeaks3("open", "close"),
|
|
2071
|
+
trace.resource()
|
|
1784
2072
|
], Space);
|
|
1785
2073
|
|
|
1786
2074
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
@@ -1802,7 +2090,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1802
2090
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1803
2091
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1804
2092
|
}
|
|
1805
|
-
var
|
|
2093
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1806
2094
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1807
2095
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1808
2096
|
var SpaceProtocol = class {
|
|
@@ -1832,7 +2120,7 @@ var SpaceProtocol = class {
|
|
|
1832
2120
|
log11("addFeed", {
|
|
1833
2121
|
key: feed.key
|
|
1834
2122
|
}, {
|
|
1835
|
-
F:
|
|
2123
|
+
F: __dxlog_file12,
|
|
1836
2124
|
L: 95,
|
|
1837
2125
|
S: this,
|
|
1838
2126
|
C: (f, a) => f(...a)
|
|
@@ -1854,7 +2142,7 @@ var SpaceProtocol = class {
|
|
|
1854
2142
|
};
|
|
1855
2143
|
await this.blobSync.open();
|
|
1856
2144
|
log11("starting...", void 0, {
|
|
1857
|
-
F:
|
|
2145
|
+
F: __dxlog_file12,
|
|
1858
2146
|
L: 120,
|
|
1859
2147
|
S: this,
|
|
1860
2148
|
C: (f, a) => f(...a)
|
|
@@ -1868,7 +2156,7 @@ var SpaceProtocol = class {
|
|
|
1868
2156
|
label: `Protocol swarm: ${topic}`
|
|
1869
2157
|
});
|
|
1870
2158
|
log11("started", void 0, {
|
|
1871
|
-
F:
|
|
2159
|
+
F: __dxlog_file12,
|
|
1872
2160
|
L: 130,
|
|
1873
2161
|
S: this,
|
|
1874
2162
|
C: (f, a) => f(...a)
|
|
@@ -1878,14 +2166,14 @@ var SpaceProtocol = class {
|
|
|
1878
2166
|
await this.blobSync.close();
|
|
1879
2167
|
if (this._connection) {
|
|
1880
2168
|
log11("stopping...", void 0, {
|
|
1881
|
-
F:
|
|
2169
|
+
F: __dxlog_file12,
|
|
1882
2170
|
L: 137,
|
|
1883
2171
|
S: this,
|
|
1884
2172
|
C: (f, a) => f(...a)
|
|
1885
2173
|
});
|
|
1886
2174
|
await this._connection.close();
|
|
1887
2175
|
log11("stopped", void 0, {
|
|
1888
|
-
F:
|
|
2176
|
+
F: __dxlog_file12,
|
|
1889
2177
|
L: 139,
|
|
1890
2178
|
S: this,
|
|
1891
2179
|
C: (f, a) => f(...a)
|
|
@@ -1951,20 +2239,18 @@ var SpaceProtocolSession = class {
|
|
|
1951
2239
|
provider: this._swarmIdentity.credentialProvider,
|
|
1952
2240
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
1953
2241
|
onAuthSuccess: () => {
|
|
1954
|
-
var _a;
|
|
1955
2242
|
log11("Peer authenticated", void 0, {
|
|
1956
|
-
F:
|
|
2243
|
+
F: __dxlog_file12,
|
|
1957
2244
|
L: 236,
|
|
1958
2245
|
S: this,
|
|
1959
2246
|
C: (f, a) => f(...a)
|
|
1960
2247
|
});
|
|
1961
2248
|
this._authStatus = AuthStatus.SUCCESS;
|
|
1962
|
-
|
|
2249
|
+
this._onSessionAuth?.(this._teleport);
|
|
1963
2250
|
},
|
|
1964
2251
|
onAuthFailure: () => {
|
|
1965
|
-
var _a;
|
|
1966
2252
|
this._authStatus = AuthStatus.FAILURE;
|
|
1967
|
-
|
|
2253
|
+
this._onAuthFailure?.(this._teleport);
|
|
1968
2254
|
}
|
|
1969
2255
|
}));
|
|
1970
2256
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -1986,7 +2272,7 @@ import { synchronized as synchronized5, trackLeaks as trackLeaks4 } from "@dxos/
|
|
|
1986
2272
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
1987
2273
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1988
2274
|
import { log as log12 } from "@dxos/log";
|
|
1989
|
-
import { trace } from "@dxos/protocols";
|
|
2275
|
+
import { trace as trace2 } from "@dxos/protocols";
|
|
1990
2276
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1991
2277
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
1992
2278
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1998,7 +2284,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
1998
2284
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1999
2285
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2000
2286
|
}
|
|
2001
|
-
var
|
|
2287
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2002
2288
|
var SpaceManager = class SpaceManager2 {
|
|
2003
2289
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
2004
2290
|
this._spaces = new ComplexMap5(PublicKey6.hash);
|
|
@@ -2022,11 +2308,10 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2022
2308
|
].map((space) => space.close()));
|
|
2023
2309
|
}
|
|
2024
2310
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2025
|
-
|
|
2026
|
-
log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
|
|
2311
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace2.begin({
|
|
2027
2312
|
id: this._instanceId
|
|
2028
2313
|
}), {
|
|
2029
|
-
F:
|
|
2314
|
+
F: __dxlog_file13,
|
|
2030
2315
|
L: 97,
|
|
2031
2316
|
S: this,
|
|
2032
2317
|
C: (f, a) => f(...a)
|
|
@@ -2034,12 +2319,12 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2034
2319
|
log12("constructing space...", {
|
|
2035
2320
|
spaceKey: metadata.genesisFeedKey
|
|
2036
2321
|
}, {
|
|
2037
|
-
F:
|
|
2322
|
+
F: __dxlog_file13,
|
|
2038
2323
|
L: 98,
|
|
2039
2324
|
S: this,
|
|
2040
2325
|
C: (f, a) => f(...a)
|
|
2041
2326
|
});
|
|
2042
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2327
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
|
|
2043
2328
|
const spaceKey = metadata.key;
|
|
2044
2329
|
const protocol = new SpaceProtocol({
|
|
2045
2330
|
topic: spaceKey,
|
|
@@ -2061,10 +2346,10 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2061
2346
|
memberKey
|
|
2062
2347
|
});
|
|
2063
2348
|
this._spaces.set(space.key, space);
|
|
2064
|
-
log12.trace("dxos.echo.space-manager.construct-space",
|
|
2349
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace2.end({
|
|
2065
2350
|
id: this._instanceId
|
|
2066
2351
|
}), {
|
|
2067
|
-
F:
|
|
2352
|
+
F: __dxlog_file13,
|
|
2068
2353
|
L: 125,
|
|
2069
2354
|
S: this,
|
|
2070
2355
|
C: (f, a) => f(...a)
|
|
@@ -2108,4 +2393,4 @@ export {
|
|
|
2108
2393
|
SpaceProtocolSession,
|
|
2109
2394
|
SpaceManager
|
|
2110
2395
|
};
|
|
2111
|
-
//# sourceMappingURL=chunk-
|
|
2396
|
+
//# sourceMappingURL=chunk-M66GL5HD.mjs.map
|