@dxos/echo-pipeline 0.1.52 → 0.1.53-main.01cbc6b
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-AXGWKSM3.mjs → chunk-RFRZMQ5T.mjs} +444 -392
- package/dist/lib/browser/chunk-RFRZMQ5T.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2 -2
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +3 -3
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node/index.cjs +512 -460
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +502 -450
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/dbhost/data-service-host.d.ts +3 -0
- package/dist/types/src/dbhost/data-service-host.d.ts.map +1 -1
- package/dist/types/src/dbhost/data-service.d.ts +2 -2
- package/dist/types/src/dbhost/data-service.d.ts.map +1 -1
- package/dist/types/src/dbhost/snapshot-store.d.ts +3 -0
- package/dist/types/src/dbhost/snapshot-store.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts +4 -0
- 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 +0 -1
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts +3 -3
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts +3 -0
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +0 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/package.json +31 -32
- package/src/common/feeds.ts +3 -3
- package/src/dbhost/data-service-host.ts +17 -4
- package/src/dbhost/data-service.ts +10 -6
- package/src/dbhost/snapshot-store.ts +3 -0
- package/src/metadata/metadata-store.ts +20 -6
- package/src/pipeline/message-selector.ts +3 -5
- package/src/pipeline/pipeline.ts +24 -12
- package/src/space/auth.ts +3 -3
- package/src/space/data-pipeline.ts +36 -29
- package/src/space/space-protocol.browser.test.ts +2 -2
- package/src/space/space-protocol.test.ts +2 -2
- package/src/space/space-protocol.ts +10 -4
- package/src/space/space.test.ts +46 -5
- package/src/space/space.ts +8 -17
- package/src/testing/util.ts +1 -1
- package/src/tests/database.test.ts +1 -1
- package/dist/lib/browser/chunk-AXGWKSM3.mjs.map +0 -7
|
@@ -52,26 +52,35 @@ var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials")
|
|
|
52
52
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
53
53
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
54
54
|
var import_teleport_extension_object_sync2 = require("@dxos/teleport-extension-object-sync");
|
|
55
|
-
var
|
|
55
|
+
var import_util9 = require("@dxos/util");
|
|
56
56
|
|
|
57
57
|
// packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
|
|
58
|
-
var
|
|
58
|
+
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
59
59
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
60
|
+
var import_context = require("@dxos/context");
|
|
60
61
|
var import_echo_db = require("@dxos/echo-db");
|
|
61
62
|
var import_log = require("@dxos/log");
|
|
62
63
|
var import_util = require("@dxos/util");
|
|
64
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts";
|
|
63
65
|
var DataServiceHost = class {
|
|
64
66
|
constructor(_itemManager, _itemDemuxer, _writeStream) {
|
|
65
67
|
this._itemManager = _itemManager;
|
|
66
68
|
this._itemDemuxer = _itemDemuxer;
|
|
67
69
|
this._writeStream = _writeStream;
|
|
70
|
+
this._ctx = new import_context.Context();
|
|
68
71
|
this._clientTagMap = new import_util.ComplexMap(([feedKey, seq]) => `${feedKey.toHex()}:${seq}`);
|
|
69
72
|
}
|
|
73
|
+
async open() {
|
|
74
|
+
}
|
|
75
|
+
async close() {
|
|
76
|
+
await this._ctx.dispose();
|
|
77
|
+
}
|
|
70
78
|
/**
|
|
71
79
|
* Real-time subscription to data objects in a space.
|
|
72
80
|
*/
|
|
73
81
|
subscribe() {
|
|
74
|
-
return new import_codec_protobuf.Stream(({ next, ctx }) => {
|
|
82
|
+
return new import_codec_protobuf.Stream(({ next, close, ctx }) => {
|
|
83
|
+
ctx.onDispose(this._ctx.onDispose(close));
|
|
75
84
|
const objects = Array.from(this._itemManager.entities.values()).map((entity) => entity.createSnapshot());
|
|
76
85
|
next({
|
|
77
86
|
batch: {
|
|
@@ -81,15 +90,15 @@ var DataServiceHost = class {
|
|
|
81
90
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
82
91
|
var _a;
|
|
83
92
|
const { batch, meta } = message;
|
|
84
|
-
(0,
|
|
93
|
+
(0, import_tiny_invariant.default)(!meta.clientTag, "Unexpected client tag in mutation message");
|
|
85
94
|
(0, import_log.log)("message", {
|
|
86
95
|
batch,
|
|
87
96
|
meta
|
|
88
97
|
}, {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
F: __dxlog_file,
|
|
99
|
+
L: 63,
|
|
100
|
+
S: this,
|
|
101
|
+
C: (f, a) => f(...a)
|
|
93
102
|
});
|
|
94
103
|
const clientTag = this._clientTagMap.get([
|
|
95
104
|
message.meta.feedKey,
|
|
@@ -114,15 +123,16 @@ var DataServiceHost = class {
|
|
|
114
123
|
}
|
|
115
124
|
async write(request) {
|
|
116
125
|
var _a, _b;
|
|
117
|
-
(0,
|
|
126
|
+
(0, import_tiny_invariant.default)(!this._ctx.disposed, "Cannot write to closed DataServiceHost");
|
|
127
|
+
(0, import_tiny_invariant.default)(this._writeStream, "Cannot write mutations in readonly mode");
|
|
118
128
|
(0, import_log.log)("write", {
|
|
119
129
|
clientTag: request.clientTag,
|
|
120
130
|
objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
|
|
121
131
|
}, {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
F: __dxlog_file,
|
|
133
|
+
L: 92,
|
|
134
|
+
S: this,
|
|
135
|
+
C: (f, a) => f(...a)
|
|
126
136
|
});
|
|
127
137
|
const message = createDataMessage(request.batch);
|
|
128
138
|
const receipt = await this._writeStream.write(message, {
|
|
@@ -133,10 +143,10 @@ var DataServiceHost = class {
|
|
|
133
143
|
feedKey: receipt2.feedKey,
|
|
134
144
|
seq: receipt2.seq
|
|
135
145
|
}, {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
146
|
+
F: __dxlog_file,
|
|
147
|
+
L: 101,
|
|
148
|
+
S: this,
|
|
149
|
+
C: (f, a) => f(...a)
|
|
140
150
|
});
|
|
141
151
|
this._clientTagMap.set([
|
|
142
152
|
receipt2.feedKey,
|
|
@@ -201,12 +211,12 @@ var DatabaseHost = class {
|
|
|
201
211
|
|
|
202
212
|
// packages/core/echo/echo-pipeline/src/dbhost/snapshot-manager.ts
|
|
203
213
|
var import_async = require("@dxos/async");
|
|
204
|
-
var
|
|
214
|
+
var import_context2 = require("@dxos/context");
|
|
205
215
|
var import_debug = require("@dxos/debug");
|
|
206
216
|
var import_keys = require("@dxos/keys");
|
|
207
217
|
var import_protocols = require("@dxos/protocols");
|
|
208
218
|
var import_blob = require("@dxos/protocols/proto/dxos/echo/blob");
|
|
209
|
-
|
|
219
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
210
220
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
211
221
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
212
222
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -215,7 +225,7 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
215
225
|
if (d = decorators[i])
|
|
216
226
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
217
227
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
218
|
-
}
|
|
228
|
+
}
|
|
219
229
|
var SnapshotManager = class SnapshotManager2 {
|
|
220
230
|
// prettier-ignore
|
|
221
231
|
constructor(_snapshotStore, _blobStore, _blobSync) {
|
|
@@ -233,7 +243,7 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
233
243
|
if (blobMeta && blobMeta.state === import_blob.BlobMeta.State.FULLY_PRESENT) {
|
|
234
244
|
return this._getBlob(blobId);
|
|
235
245
|
}
|
|
236
|
-
const fallbackStore = await (0,
|
|
246
|
+
const fallbackStore = await (0, import_context2.cancelWithContext)(ctx, this._snapshotStore.loadSnapshot(id));
|
|
237
247
|
if (fallbackStore) {
|
|
238
248
|
return fallbackStore;
|
|
239
249
|
}
|
|
@@ -246,10 +256,10 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
246
256
|
return import_keys.PublicKey.from(id).toHex();
|
|
247
257
|
}
|
|
248
258
|
};
|
|
249
|
-
|
|
259
|
+
_ts_decorate([
|
|
250
260
|
(0, import_debug.timed)(1e4)
|
|
251
261
|
], SnapshotManager.prototype, "load", null);
|
|
252
|
-
SnapshotManager =
|
|
262
|
+
SnapshotManager = _ts_decorate([
|
|
253
263
|
(0, import_async.trackLeaks)("open", "close")
|
|
254
264
|
], SnapshotManager);
|
|
255
265
|
|
|
@@ -299,11 +309,12 @@ var SnapshotStore = class {
|
|
|
299
309
|
};
|
|
300
310
|
|
|
301
311
|
// packages/core/echo/echo-pipeline/src/dbhost/data-service.ts
|
|
302
|
-
var
|
|
312
|
+
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
303
313
|
var import_debug2 = require("@dxos/debug");
|
|
304
314
|
var import_keys2 = require("@dxos/keys");
|
|
305
315
|
var import_log2 = require("@dxos/log");
|
|
306
316
|
var import_util2 = require("@dxos/util");
|
|
317
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service.ts";
|
|
307
318
|
var DataServiceSubscriptions = class {
|
|
308
319
|
constructor() {
|
|
309
320
|
this._spaces = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
|
|
@@ -311,26 +322,30 @@ var DataServiceSubscriptions = class {
|
|
|
311
322
|
clear() {
|
|
312
323
|
this._spaces.clear();
|
|
313
324
|
}
|
|
314
|
-
registerSpace(spaceKey, host) {
|
|
325
|
+
async registerSpace(spaceKey, host) {
|
|
315
326
|
(0, import_log2.log)("Registering space", {
|
|
316
327
|
spaceKey
|
|
317
328
|
}, {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
329
|
+
F: __dxlog_file2,
|
|
330
|
+
L: 31,
|
|
331
|
+
S: this,
|
|
332
|
+
C: (f, a) => f(...a)
|
|
322
333
|
});
|
|
334
|
+
(0, import_tiny_invariant2.default)(!this._spaces.has(spaceKey));
|
|
335
|
+
await host.open();
|
|
323
336
|
this._spaces.set(spaceKey, host);
|
|
324
337
|
}
|
|
325
|
-
unregisterSpace(spaceKey) {
|
|
338
|
+
async unregisterSpace(spaceKey) {
|
|
326
339
|
(0, import_log2.log)("Unregistering space", {
|
|
327
340
|
spaceKey
|
|
328
341
|
}, {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
342
|
+
F: __dxlog_file2,
|
|
343
|
+
L: 38,
|
|
344
|
+
S: this,
|
|
345
|
+
C: (f, a) => f(...a)
|
|
333
346
|
});
|
|
347
|
+
const host = this._spaces.get(spaceKey);
|
|
348
|
+
await (host == null ? void 0 : host.close());
|
|
334
349
|
this._spaces.delete(spaceKey);
|
|
335
350
|
}
|
|
336
351
|
getDataService(spaceKey) {
|
|
@@ -343,14 +358,14 @@ var DataServiceImpl = class {
|
|
|
343
358
|
}
|
|
344
359
|
subscribe(request) {
|
|
345
360
|
var _a;
|
|
346
|
-
(0,
|
|
361
|
+
(0, import_tiny_invariant2.default)(request.spaceKey);
|
|
347
362
|
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : (0, import_debug2.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
348
363
|
return host.subscribe();
|
|
349
364
|
}
|
|
350
365
|
write(request) {
|
|
351
366
|
var _a;
|
|
352
|
-
(0,
|
|
353
|
-
(0,
|
|
367
|
+
(0, import_tiny_invariant2.default)(request.spaceKey);
|
|
368
|
+
(0, import_tiny_invariant2.default)(request.batch);
|
|
354
369
|
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : (0, import_debug2.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
355
370
|
return host.write(request);
|
|
356
371
|
}
|
|
@@ -358,12 +373,14 @@ var DataServiceImpl = class {
|
|
|
358
373
|
|
|
359
374
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
360
375
|
var import_crc_32 = __toESM(require("crc-32"));
|
|
361
|
-
var
|
|
376
|
+
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
362
377
|
var import_async2 = require("@dxos/async");
|
|
363
378
|
var import_errors = require("@dxos/errors");
|
|
364
379
|
var import_log3 = require("@dxos/log");
|
|
365
380
|
var import_protocols3 = require("@dxos/protocols");
|
|
366
|
-
var
|
|
381
|
+
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
382
|
+
var import_util3 = require("@dxos/util");
|
|
383
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
367
384
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
368
385
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
369
386
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -372,13 +389,15 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
372
389
|
if (d = decorators[i])
|
|
373
390
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
374
391
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
375
|
-
}
|
|
392
|
+
}
|
|
393
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
376
394
|
var emptyEchoMetadata = () => ({
|
|
377
395
|
version: import_protocols3.STORAGE_VERSION,
|
|
378
396
|
spaces: [],
|
|
379
397
|
created: new Date(),
|
|
380
398
|
updated: new Date()
|
|
381
399
|
});
|
|
400
|
+
var EchoMetadata = import_protocols3.schema.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
382
401
|
var MetadataStore = class {
|
|
383
402
|
// prettier-ignore
|
|
384
403
|
constructor(_directory) {
|
|
@@ -405,6 +424,7 @@ var MetadataStore = class {
|
|
|
405
424
|
* Loads metadata from persistent storage.
|
|
406
425
|
*/
|
|
407
426
|
async load() {
|
|
427
|
+
var _a;
|
|
408
428
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
409
429
|
try {
|
|
410
430
|
const { size: fileLength } = await file.stat();
|
|
@@ -417,10 +437,10 @@ var MetadataStore = class {
|
|
|
417
437
|
size: dataSize,
|
|
418
438
|
checksum
|
|
419
439
|
}, {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
440
|
+
F: __dxlog_file3,
|
|
441
|
+
L: 72,
|
|
442
|
+
S: this,
|
|
443
|
+
C: (f, a) => f(...a)
|
|
424
444
|
});
|
|
425
445
|
if (fileLength < dataSize + 8) {
|
|
426
446
|
throw new import_errors.DataCorruptionError("Metadata size is smaller than expected.");
|
|
@@ -430,15 +450,19 @@ var MetadataStore = class {
|
|
|
430
450
|
if (calculatedChecksum !== checksum) {
|
|
431
451
|
throw new import_errors.DataCorruptionError("Metadata checksum is invalid.");
|
|
432
452
|
}
|
|
433
|
-
this._metadata =
|
|
453
|
+
this._metadata = EchoMetadata.decode(data);
|
|
454
|
+
(_a = this._metadata.spaces) == null ? void 0 : _a.forEach((space) => {
|
|
455
|
+
var _a2;
|
|
456
|
+
(_a2 = space.state) != null ? _a2 : space.state = import_services.SpaceState.ACTIVE;
|
|
457
|
+
});
|
|
434
458
|
} catch (err) {
|
|
435
459
|
import_log3.log.error("failed to load metadata", {
|
|
436
460
|
err
|
|
437
461
|
}, {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
462
|
+
F: __dxlog_file3,
|
|
463
|
+
L: 92,
|
|
464
|
+
S: this,
|
|
465
|
+
C: (f, a) => f(...a)
|
|
442
466
|
});
|
|
443
467
|
this._metadata = emptyEchoMetadata();
|
|
444
468
|
} finally {
|
|
@@ -456,7 +480,7 @@ var MetadataStore = class {
|
|
|
456
480
|
this.update.emit(data);
|
|
457
481
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
458
482
|
try {
|
|
459
|
-
const encoded =
|
|
483
|
+
const encoded = (0, import_util3.arrayToBuffer)(EchoMetadata.encode(data));
|
|
460
484
|
const checksum = import_crc_32.default.buf(encoded);
|
|
461
485
|
const result = Buffer.alloc(8 + encoded.length);
|
|
462
486
|
result.writeInt32LE(encoded.length, 0);
|
|
@@ -467,10 +491,10 @@ var MetadataStore = class {
|
|
|
467
491
|
size: encoded.length,
|
|
468
492
|
checksum
|
|
469
493
|
}, {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
494
|
+
F: __dxlog_file3,
|
|
495
|
+
L: 124,
|
|
496
|
+
S: this,
|
|
497
|
+
C: (f, a) => f(...a)
|
|
474
498
|
});
|
|
475
499
|
} finally {
|
|
476
500
|
await file.close();
|
|
@@ -482,18 +506,18 @@ var MetadataStore = class {
|
|
|
482
506
|
return this._metadata.identity.haloSpace;
|
|
483
507
|
}
|
|
484
508
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
485
|
-
(0,
|
|
509
|
+
(0, import_tiny_invariant3.default)(space, "Space not found");
|
|
486
510
|
return space;
|
|
487
511
|
}
|
|
488
512
|
/**
|
|
489
513
|
* Clears storage - doesn't work for now.
|
|
490
514
|
*/
|
|
491
515
|
async clear() {
|
|
492
|
-
(0, import_log3.log)("clearing all metadata",
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
516
|
+
(0, import_log3.log)("clearing all metadata", void 0, {
|
|
517
|
+
F: __dxlog_file3,
|
|
518
|
+
L: 145,
|
|
519
|
+
S: this,
|
|
520
|
+
C: (f, a) => f(...a)
|
|
497
521
|
});
|
|
498
522
|
await this._directory.delete();
|
|
499
523
|
this._metadata = emptyEchoMetadata();
|
|
@@ -502,13 +526,13 @@ var MetadataStore = class {
|
|
|
502
526
|
return this._metadata.identity;
|
|
503
527
|
}
|
|
504
528
|
async setIdentityRecord(record) {
|
|
505
|
-
(0,
|
|
529
|
+
(0, import_tiny_invariant3.default)(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
|
|
506
530
|
this._metadata.identity = record;
|
|
507
531
|
await this._save();
|
|
508
532
|
}
|
|
509
533
|
async addSpace(record) {
|
|
510
534
|
var _a, _b, _c;
|
|
511
|
-
(0,
|
|
535
|
+
(0, import_tiny_invariant3.default)(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
|
|
512
536
|
((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
|
|
513
537
|
await this._save();
|
|
514
538
|
}
|
|
@@ -530,23 +554,28 @@ var MetadataStore = class {
|
|
|
530
554
|
space.dataFeedKey = dataFeedKey;
|
|
531
555
|
await this._save();
|
|
532
556
|
}
|
|
557
|
+
async setSpaceState(spaceKey, state) {
|
|
558
|
+
this._getSpace(spaceKey).state = state;
|
|
559
|
+
await this._save();
|
|
560
|
+
}
|
|
533
561
|
};
|
|
534
|
-
|
|
562
|
+
_ts_decorate2([
|
|
535
563
|
import_async2.synchronized
|
|
536
564
|
], MetadataStore.prototype, "load", null);
|
|
537
|
-
|
|
565
|
+
_ts_decorate2([
|
|
538
566
|
import_async2.synchronized
|
|
539
567
|
], MetadataStore.prototype, "_save", null);
|
|
540
568
|
var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
541
569
|
|
|
542
570
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
543
|
-
var
|
|
571
|
+
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
544
572
|
var import_async3 = require("@dxos/async");
|
|
545
|
-
var
|
|
573
|
+
var import_context3 = require("@dxos/context");
|
|
546
574
|
var import_crypto2 = require("@dxos/crypto");
|
|
547
575
|
var import_log4 = require("@dxos/log");
|
|
548
576
|
var import_protocols4 = require("@dxos/protocols");
|
|
549
577
|
var import_teleport = require("@dxos/teleport");
|
|
578
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
550
579
|
var AuthExtension = class extends import_teleport.RpcExtension {
|
|
551
580
|
constructor(_authParams) {
|
|
552
581
|
super({
|
|
@@ -559,13 +588,13 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
559
588
|
timeout: 60 * 1e3
|
|
560
589
|
});
|
|
561
590
|
this._authParams = _authParams;
|
|
562
|
-
this._ctx = new
|
|
591
|
+
this._ctx = new import_context3.Context({
|
|
563
592
|
onError: (err) => {
|
|
564
|
-
import_log4.log.catch(err,
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
593
|
+
import_log4.log.catch(err, void 0, {
|
|
594
|
+
F: __dxlog_file4,
|
|
595
|
+
L: 29,
|
|
596
|
+
S: this,
|
|
597
|
+
C: (f, a) => f(...a)
|
|
569
598
|
});
|
|
570
599
|
}
|
|
571
600
|
});
|
|
@@ -584,10 +613,10 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
584
613
|
};
|
|
585
614
|
} catch (err) {
|
|
586
615
|
import_log4.log.error("failed to generate auth credentials", err, {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
616
|
+
F: __dxlog_file4,
|
|
617
|
+
L: 56,
|
|
618
|
+
S: this,
|
|
619
|
+
C: (f, a) => f(...a)
|
|
591
620
|
});
|
|
592
621
|
throw new Error("auth rejected");
|
|
593
622
|
}
|
|
@@ -603,16 +632,16 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
603
632
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
604
633
|
challenge
|
|
605
634
|
});
|
|
606
|
-
(0,
|
|
635
|
+
(0, import_tiny_invariant4.default)((credential == null ? void 0 : credential.length) > 0, "invalid credential");
|
|
607
636
|
const success = await this._authParams.verifier(challenge, credential);
|
|
608
|
-
(0,
|
|
637
|
+
(0, import_tiny_invariant4.default)(success, "credential not verified");
|
|
609
638
|
(0, import_async3.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
|
|
610
639
|
} catch (err) {
|
|
611
640
|
(0, import_log4.log)("auth failed", err, {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
641
|
+
F: __dxlog_file4,
|
|
642
|
+
L: 75,
|
|
643
|
+
S: this,
|
|
644
|
+
C: (f, a) => f(...a)
|
|
616
645
|
});
|
|
617
646
|
this.close();
|
|
618
647
|
this._authParams.onAuthFailure();
|
|
@@ -626,30 +655,30 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
626
655
|
};
|
|
627
656
|
|
|
628
657
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
629
|
-
var
|
|
658
|
+
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
630
659
|
var import_async7 = require("@dxos/async");
|
|
631
|
-
var
|
|
660
|
+
var import_log10 = require("@dxos/log");
|
|
632
661
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
633
|
-
var
|
|
662
|
+
var import_util6 = require("@dxos/util");
|
|
634
663
|
|
|
635
664
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
636
665
|
var import_credentials = require("@dxos/credentials");
|
|
637
666
|
var import_keys4 = require("@dxos/keys");
|
|
638
|
-
var
|
|
667
|
+
var import_log8 = require("@dxos/log");
|
|
639
668
|
var import_credentials2 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
640
669
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
641
|
-
var
|
|
670
|
+
var import_util5 = require("@dxos/util");
|
|
642
671
|
|
|
643
672
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
644
|
-
var
|
|
673
|
+
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
645
674
|
var import_async5 = require("@dxos/async");
|
|
646
|
-
var
|
|
647
|
-
var
|
|
675
|
+
var import_context4 = require("@dxos/context");
|
|
676
|
+
var import_debug4 = require("@dxos/debug");
|
|
648
677
|
var import_feed_store = require("@dxos/feed-store");
|
|
649
678
|
var import_keys3 = require("@dxos/keys");
|
|
650
|
-
var
|
|
679
|
+
var import_log7 = require("@dxos/log");
|
|
651
680
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
652
|
-
var
|
|
681
|
+
var import_util4 = require("@dxos/util");
|
|
653
682
|
|
|
654
683
|
// packages/core/echo/echo-pipeline/src/common/codec.ts
|
|
655
684
|
var import_hypercore = require("@dxos/hypercore");
|
|
@@ -658,38 +687,43 @@ var codec = import_protocols5.schema.getCodecForType("dxos.echo.feed.FeedMessage
|
|
|
658
687
|
var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
|
|
659
688
|
|
|
660
689
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
661
|
-
var
|
|
690
|
+
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
662
691
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
663
|
-
(0,
|
|
664
|
-
(0,
|
|
692
|
+
(0, import_tiny_invariant5.default)(mapper);
|
|
693
|
+
(0, import_tiny_invariant5.default)(writer);
|
|
665
694
|
return {
|
|
666
695
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
667
696
|
};
|
|
668
697
|
};
|
|
669
698
|
|
|
670
699
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
671
|
-
var
|
|
672
|
-
var
|
|
673
|
-
var
|
|
700
|
+
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
701
|
+
var import_log5 = require("@dxos/log");
|
|
702
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
|
|
674
703
|
var createMessageSelector = (timeframeClock) => {
|
|
675
704
|
return (messages) => {
|
|
676
705
|
for (let i = 0; i < messages.length; i++) {
|
|
677
706
|
const { data: { timeframe } } = messages[i];
|
|
678
|
-
(0,
|
|
707
|
+
(0, import_tiny_invariant6.default)(timeframe);
|
|
679
708
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
680
709
|
return i;
|
|
681
710
|
}
|
|
682
711
|
}
|
|
683
|
-
|
|
712
|
+
(0, import_log5.log)("Skipping...", void 0, {
|
|
713
|
+
F: __dxlog_file5,
|
|
714
|
+
L: 34,
|
|
715
|
+
S: void 0,
|
|
716
|
+
C: (f, a) => f(...a)
|
|
717
|
+
});
|
|
684
718
|
};
|
|
685
719
|
};
|
|
686
720
|
|
|
687
721
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
688
722
|
var import_async4 = require("@dxos/async");
|
|
689
|
-
var
|
|
690
|
-
var
|
|
723
|
+
var import_debug3 = require("@dxos/debug");
|
|
724
|
+
var import_log6 = require("@dxos/log");
|
|
691
725
|
var import_timeframe = require("@dxos/timeframe");
|
|
692
|
-
|
|
726
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
693
727
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
694
728
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
695
729
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -698,7 +732,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
698
732
|
if (d = decorators[i])
|
|
699
733
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
700
734
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
701
|
-
}
|
|
735
|
+
}
|
|
736
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
702
737
|
var mapFeedIndexesToTimeframe = (indexes) => new import_timeframe.Timeframe(indexes.map(({ feedKey, index }) => [
|
|
703
738
|
feedKey,
|
|
704
739
|
index
|
|
@@ -749,36 +784,36 @@ var TimeframeClock = class {
|
|
|
749
784
|
return !gaps.isEmpty();
|
|
750
785
|
}
|
|
751
786
|
async waitUntilReached(target) {
|
|
752
|
-
(0,
|
|
787
|
+
(0, import_log6.log)("waitUntilReached", {
|
|
753
788
|
target,
|
|
754
789
|
current: this._timeframe
|
|
755
790
|
}, {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
791
|
+
F: __dxlog_file6,
|
|
792
|
+
L: 73,
|
|
793
|
+
S: this,
|
|
794
|
+
C: (f, a) => f(...a)
|
|
760
795
|
});
|
|
761
796
|
await this.update.waitForCondition(() => {
|
|
762
|
-
(0,
|
|
797
|
+
(0, import_log6.log)("check if reached", {
|
|
763
798
|
target,
|
|
764
799
|
current: this._timeframe,
|
|
765
800
|
deps: import_timeframe.Timeframe.dependencies(target, this._timeframe)
|
|
766
801
|
}, {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
802
|
+
F: __dxlog_file6,
|
|
803
|
+
L: 75,
|
|
804
|
+
S: this,
|
|
805
|
+
C: (f, a) => f(...a)
|
|
771
806
|
});
|
|
772
807
|
return import_timeframe.Timeframe.dependencies(target, this._timeframe).isEmpty();
|
|
773
808
|
});
|
|
774
809
|
}
|
|
775
810
|
};
|
|
776
|
-
|
|
777
|
-
(0,
|
|
811
|
+
_ts_decorate3([
|
|
812
|
+
(0, import_debug3.timed)(5e3)
|
|
778
813
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
779
814
|
|
|
780
815
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
781
|
-
|
|
816
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
782
817
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
783
818
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
784
819
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -787,12 +822,14 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
787
822
|
if (d = decorators[i])
|
|
788
823
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
789
824
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
790
|
-
}
|
|
825
|
+
}
|
|
826
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
791
827
|
var PipelineState = class {
|
|
792
828
|
// prettier-ignore
|
|
793
829
|
constructor(_feeds, _timeframeClock) {
|
|
794
830
|
this._feeds = _feeds;
|
|
795
831
|
this._timeframeClock = _timeframeClock;
|
|
832
|
+
this._ctx = new import_context4.Context();
|
|
796
833
|
this.timeframeUpdate = this._timeframeClock.update;
|
|
797
834
|
this.stalled = new import_async5.Event();
|
|
798
835
|
this._startTimeframe = new import_timeframe2.Timeframe();
|
|
@@ -836,17 +873,17 @@ var PipelineState = class {
|
|
|
836
873
|
*
|
|
837
874
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
838
875
|
*/
|
|
839
|
-
async waitUntilReachedTargetTimeframe({ ctx = new
|
|
876
|
+
async waitUntilReachedTargetTimeframe({ ctx = new import_context4.Context(), timeout, breakOnStall = true } = {}) {
|
|
840
877
|
var _a;
|
|
841
|
-
(0,
|
|
878
|
+
(0, import_log7.log)("waitUntilReachedTargetTimeframe", {
|
|
842
879
|
timeout,
|
|
843
880
|
current: this.timeframe,
|
|
844
881
|
target: this.targetTimeframe
|
|
845
882
|
}, {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
883
|
+
F: __dxlog_file7,
|
|
884
|
+
L: 126,
|
|
885
|
+
S: this,
|
|
886
|
+
C: (f, a) => f(...a)
|
|
850
887
|
});
|
|
851
888
|
(_a = this._reachedTargetPromise) != null ? _a : this._reachedTargetPromise = Promise.race([
|
|
852
889
|
this._timeframeClock.update.waitForCondition(() => {
|
|
@@ -859,7 +896,8 @@ var PipelineState = class {
|
|
|
859
896
|
let done = false;
|
|
860
897
|
if (timeout) {
|
|
861
898
|
return Promise.race([
|
|
862
|
-
(0,
|
|
899
|
+
(0, import_context4.rejectOnDispose)(ctx),
|
|
900
|
+
(0, import_context4.rejectOnDispose)(this._ctx),
|
|
863
901
|
this._reachedTargetPromise.then(() => {
|
|
864
902
|
done = true;
|
|
865
903
|
}),
|
|
@@ -867,16 +905,16 @@ var PipelineState = class {
|
|
|
867
905
|
if (done) {
|
|
868
906
|
return;
|
|
869
907
|
}
|
|
870
|
-
|
|
908
|
+
import_log7.log.warn("waitUntilReachedTargetTimeframe timed out", {
|
|
871
909
|
timeout,
|
|
872
910
|
current: this.timeframe,
|
|
873
911
|
target: this.targetTimeframe,
|
|
874
912
|
dependencies: import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe)
|
|
875
913
|
}, {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
914
|
+
F: __dxlog_file7,
|
|
915
|
+
L: 153,
|
|
916
|
+
S: this,
|
|
917
|
+
C: (f, a) => f(...a)
|
|
880
918
|
});
|
|
881
919
|
})
|
|
882
920
|
]);
|
|
@@ -888,7 +926,7 @@ var PipelineState = class {
|
|
|
888
926
|
var Pipeline = class {
|
|
889
927
|
constructor() {
|
|
890
928
|
this._timeframeClock = new TimeframeClock(new import_timeframe2.Timeframe());
|
|
891
|
-
this._feeds = new
|
|
929
|
+
this._feeds = new import_util4.ComplexMap(import_keys3.PublicKey.hash);
|
|
892
930
|
// External state accessor.
|
|
893
931
|
this._state = new PipelineState(this._feeds, this._timeframeClock);
|
|
894
932
|
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
@@ -903,7 +941,7 @@ var Pipeline = class {
|
|
|
903
941
|
return this._state;
|
|
904
942
|
}
|
|
905
943
|
get writer() {
|
|
906
|
-
(0,
|
|
944
|
+
(0, import_tiny_invariant7.default)(this._writer, "Writer not set.");
|
|
907
945
|
return this._writer;
|
|
908
946
|
}
|
|
909
947
|
getFeeds() {
|
|
@@ -922,46 +960,49 @@ var Pipeline = class {
|
|
|
922
960
|
return this._feeds.has(feedKey);
|
|
923
961
|
}
|
|
924
962
|
setWriteFeed(feed) {
|
|
925
|
-
(0,
|
|
926
|
-
(0,
|
|
963
|
+
(0, import_tiny_invariant7.default)(!this._writer, "Writer already set.");
|
|
964
|
+
(0, import_tiny_invariant7.default)(feed.properties.writable, "Feed must be writable.");
|
|
927
965
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
928
966
|
timeframe: this._timeframeClock.timeframe,
|
|
929
967
|
payload
|
|
930
968
|
}), feed.createFeedWriter());
|
|
931
969
|
}
|
|
932
970
|
async start() {
|
|
933
|
-
(0,
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
971
|
+
(0, import_log7.log)("starting...", {}, {
|
|
972
|
+
F: __dxlog_file7,
|
|
973
|
+
L: 273,
|
|
974
|
+
S: this,
|
|
975
|
+
C: (f, a) => f(...a)
|
|
938
976
|
});
|
|
939
977
|
await this._initIterator();
|
|
940
978
|
await this._feedSetIterator.open();
|
|
941
|
-
(0,
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
979
|
+
(0, import_log7.log)("started", void 0, {
|
|
980
|
+
F: __dxlog_file7,
|
|
981
|
+
L: 276,
|
|
982
|
+
S: this,
|
|
983
|
+
C: (f, a) => f(...a)
|
|
946
984
|
});
|
|
947
985
|
this._isStarted = true;
|
|
948
986
|
}
|
|
949
987
|
async stop() {
|
|
950
988
|
var _a;
|
|
951
|
-
(0,
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
989
|
+
(0, import_log7.log)("stopping...", {}, {
|
|
990
|
+
F: __dxlog_file7,
|
|
991
|
+
L: 282,
|
|
992
|
+
S: this,
|
|
993
|
+
C: (f, a) => f(...a)
|
|
956
994
|
});
|
|
957
995
|
this._isStopping = true;
|
|
958
996
|
await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
|
|
959
997
|
await this._processingTrigger.wait();
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
998
|
+
await this._state._ctx.dispose();
|
|
999
|
+
this._state._ctx = new import_context4.Context();
|
|
1000
|
+
this._state._reachedTargetPromise = void 0;
|
|
1001
|
+
(0, import_log7.log)("stopped", void 0, {
|
|
1002
|
+
F: __dxlog_file7,
|
|
1003
|
+
L: 289,
|
|
1004
|
+
S: this,
|
|
1005
|
+
C: (f, a) => f(...a)
|
|
965
1006
|
});
|
|
966
1007
|
this._isStarted = false;
|
|
967
1008
|
}
|
|
@@ -969,7 +1010,7 @@ var Pipeline = class {
|
|
|
969
1010
|
* @param timeframe Timeframe of already processed messages. The pipeline will start processing messages AFTER this timeframe.
|
|
970
1011
|
*/
|
|
971
1012
|
async setCursor(timeframe) {
|
|
972
|
-
(0,
|
|
1013
|
+
(0, import_tiny_invariant7.default)(!this._isStarted || this._isPaused, "Invalid state.");
|
|
973
1014
|
this._state._startTimeframe = timeframe;
|
|
974
1015
|
this._timeframeClock.setTimeframe(timeframe);
|
|
975
1016
|
for (const feed of this._feeds.values()) {
|
|
@@ -985,7 +1026,7 @@ var Pipeline = class {
|
|
|
985
1026
|
* Calling pause while processing will cause a deadlock.
|
|
986
1027
|
*/
|
|
987
1028
|
async pause() {
|
|
988
|
-
(0,
|
|
1029
|
+
(0, import_tiny_invariant7.default)(this._isStarted, "Pipeline is not open.");
|
|
989
1030
|
if (this._isPaused) {
|
|
990
1031
|
return;
|
|
991
1032
|
}
|
|
@@ -994,8 +1035,8 @@ var Pipeline = class {
|
|
|
994
1035
|
this._isPaused = true;
|
|
995
1036
|
}
|
|
996
1037
|
async unpause() {
|
|
997
|
-
(0,
|
|
998
|
-
(0,
|
|
1038
|
+
(0, import_tiny_invariant7.default)(this._isStarted, "Pipeline is not open.");
|
|
1039
|
+
(0, import_tiny_invariant7.default)(this._isPaused, "Pipeline is not paused.");
|
|
999
1040
|
this._pauseTrigger.wake();
|
|
1000
1041
|
this._isPaused = false;
|
|
1001
1042
|
}
|
|
@@ -1004,15 +1045,15 @@ var Pipeline = class {
|
|
|
1004
1045
|
* Updates the timeframe clock after the message has bee processed.
|
|
1005
1046
|
*/
|
|
1006
1047
|
async *consume() {
|
|
1007
|
-
(0,
|
|
1048
|
+
(0, import_tiny_invariant7.default)(!this._isOpen, "Pipeline is already being consumed.");
|
|
1008
1049
|
this._isOpen = true;
|
|
1009
|
-
(0,
|
|
1050
|
+
(0, import_tiny_invariant7.default)(this._feedSetIterator, "Iterator not initialized.");
|
|
1010
1051
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
1011
1052
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
1012
1053
|
while (!this._isStopping) {
|
|
1013
1054
|
await this._pauseTrigger.wait();
|
|
1014
1055
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
1015
|
-
(0,
|
|
1056
|
+
(0, import_tiny_invariant7.default)(this._feedSetIterator, "Iterator not initialized.");
|
|
1016
1057
|
lastFeedSetIterator = this._feedSetIterator;
|
|
1017
1058
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
1018
1059
|
}
|
|
@@ -1020,7 +1061,7 @@ var Pipeline = class {
|
|
|
1020
1061
|
if (done) {
|
|
1021
1062
|
continue;
|
|
1022
1063
|
}
|
|
1023
|
-
const block = value != null ? value : (0,
|
|
1064
|
+
const block = value != null ? value : (0, import_debug4.failUndefined)();
|
|
1024
1065
|
this._processingTrigger.reset();
|
|
1025
1066
|
this._timeframeClock.updatePendingTimeframe(import_keys3.PublicKey.from(block.feedKey), block.seq);
|
|
1026
1067
|
yield block;
|
|
@@ -1034,24 +1075,24 @@ var Pipeline = class {
|
|
|
1034
1075
|
const timeframe = this._state._startTimeframe;
|
|
1035
1076
|
const seq = (_a = timeframe.get(feed.key)) != null ? _a : 0;
|
|
1036
1077
|
feed.undownload({
|
|
1037
|
-
callback: () => (0,
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1078
|
+
callback: () => (0, import_log7.log)("Undownloaded", void 0, {
|
|
1079
|
+
F: __dxlog_file7,
|
|
1080
|
+
L: 383,
|
|
1081
|
+
S: this,
|
|
1082
|
+
C: (f, a) => f(...a)
|
|
1042
1083
|
})
|
|
1043
1084
|
});
|
|
1044
1085
|
feed.download({
|
|
1045
1086
|
start: seq + 1,
|
|
1046
1087
|
linear: true
|
|
1047
1088
|
}).catch((err) => {
|
|
1048
|
-
(0,
|
|
1089
|
+
(0, import_log7.log)("failed to download feed", {
|
|
1049
1090
|
err
|
|
1050
1091
|
}, {
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1092
|
+
F: __dxlog_file7,
|
|
1093
|
+
L: 386,
|
|
1094
|
+
S: this,
|
|
1095
|
+
C: (f, a) => f(...a)
|
|
1055
1096
|
});
|
|
1056
1097
|
});
|
|
1057
1098
|
}
|
|
@@ -1061,11 +1102,11 @@ var Pipeline = class {
|
|
|
1061
1102
|
stallTimeout: 1e3
|
|
1062
1103
|
});
|
|
1063
1104
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1105
|
+
import_log7.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
1106
|
+
F: __dxlog_file7,
|
|
1107
|
+
L: 396,
|
|
1108
|
+
S: this,
|
|
1109
|
+
C: (f, a) => f(...a)
|
|
1069
1110
|
});
|
|
1070
1111
|
this._state.stalled.emit();
|
|
1071
1112
|
});
|
|
@@ -1074,52 +1115,53 @@ var Pipeline = class {
|
|
|
1074
1115
|
}
|
|
1075
1116
|
}
|
|
1076
1117
|
};
|
|
1077
|
-
|
|
1118
|
+
_ts_decorate4([
|
|
1078
1119
|
import_async5.synchronized
|
|
1079
1120
|
], Pipeline.prototype, "start", null);
|
|
1080
|
-
|
|
1121
|
+
_ts_decorate4([
|
|
1081
1122
|
import_async5.synchronized
|
|
1082
1123
|
], Pipeline.prototype, "stop", null);
|
|
1083
|
-
|
|
1124
|
+
_ts_decorate4([
|
|
1084
1125
|
import_async5.synchronized
|
|
1085
1126
|
], Pipeline.prototype, "setCursor", null);
|
|
1086
|
-
|
|
1127
|
+
_ts_decorate4([
|
|
1087
1128
|
import_async5.synchronized
|
|
1088
1129
|
], Pipeline.prototype, "pause", null);
|
|
1089
|
-
|
|
1130
|
+
_ts_decorate4([
|
|
1090
1131
|
import_async5.synchronized
|
|
1091
1132
|
], Pipeline.prototype, "unpause", null);
|
|
1092
1133
|
|
|
1093
1134
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1135
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1094
1136
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
1095
1137
|
var ControlPipeline = class {
|
|
1096
1138
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1097
1139
|
this._lastTimeframeSaveTime = Date.now();
|
|
1098
|
-
this.onFeedAdmitted = new
|
|
1140
|
+
this.onFeedAdmitted = new import_util5.Callback();
|
|
1099
1141
|
this._spaceKey = spaceKey;
|
|
1100
1142
|
this._metadata = metadataStore;
|
|
1101
1143
|
this._pipeline = new Pipeline();
|
|
1102
1144
|
void this._pipeline.addFeed(genesisFeed);
|
|
1103
1145
|
this._spaceStateMachine = new import_credentials.SpaceStateMachine(spaceKey);
|
|
1104
1146
|
this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
|
|
1105
|
-
(0,
|
|
1147
|
+
(0, import_log8.log)("feed admitted", {
|
|
1106
1148
|
key: info.key
|
|
1107
1149
|
}, {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1150
|
+
F: __dxlog_file8,
|
|
1151
|
+
L: 51,
|
|
1152
|
+
S: this,
|
|
1153
|
+
C: (f, a) => f(...a)
|
|
1112
1154
|
});
|
|
1113
1155
|
if (info.assertion.designation === import_credentials2.AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
|
|
1114
1156
|
try {
|
|
1115
1157
|
const feed = await feedProvider(info.key);
|
|
1116
1158
|
await this._pipeline.addFeed(feed);
|
|
1117
1159
|
} catch (err) {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1160
|
+
import_log8.log.catch(err, void 0, {
|
|
1161
|
+
F: __dxlog_file8,
|
|
1162
|
+
L: 59,
|
|
1163
|
+
S: this,
|
|
1164
|
+
C: (f, a) => f(...a)
|
|
1123
1165
|
});
|
|
1124
1166
|
}
|
|
1125
1167
|
}
|
|
@@ -1138,55 +1180,55 @@ var ControlPipeline = class {
|
|
|
1138
1180
|
this._pipeline.setWriteFeed(feed);
|
|
1139
1181
|
}
|
|
1140
1182
|
async start() {
|
|
1141
|
-
(0,
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1183
|
+
(0, import_log8.log)("starting...", void 0, {
|
|
1184
|
+
F: __dxlog_file8,
|
|
1185
|
+
L: 83,
|
|
1186
|
+
S: this,
|
|
1187
|
+
C: (f, a) => f(...a)
|
|
1146
1188
|
});
|
|
1147
1189
|
setTimeout(async () => {
|
|
1148
1190
|
for await (const msg of this._pipeline.consume()) {
|
|
1149
1191
|
try {
|
|
1150
|
-
(0,
|
|
1192
|
+
(0, import_log8.log)("processing", {
|
|
1151
1193
|
key: msg.feedKey,
|
|
1152
1194
|
seq: msg.seq
|
|
1153
1195
|
}, {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1196
|
+
F: __dxlog_file8,
|
|
1197
|
+
L: 88,
|
|
1198
|
+
S: this,
|
|
1199
|
+
C: (f, a) => f(...a)
|
|
1158
1200
|
});
|
|
1159
1201
|
if (msg.data.payload.credential) {
|
|
1160
1202
|
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys4.PublicKey.from(msg.feedKey));
|
|
1161
1203
|
if (!result) {
|
|
1162
|
-
|
|
1204
|
+
import_log8.log.warn("processing failed", {
|
|
1163
1205
|
msg
|
|
1164
1206
|
}, {
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1207
|
+
F: __dxlog_file8,
|
|
1208
|
+
L: 95,
|
|
1209
|
+
S: this,
|
|
1210
|
+
C: (f, a) => f(...a)
|
|
1169
1211
|
});
|
|
1170
1212
|
} else {
|
|
1171
1213
|
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1172
1214
|
}
|
|
1173
1215
|
}
|
|
1174
1216
|
} catch (err) {
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1217
|
+
import_log8.log.catch(err, void 0, {
|
|
1218
|
+
F: __dxlog_file8,
|
|
1219
|
+
L: 101,
|
|
1220
|
+
S: this,
|
|
1221
|
+
C: (f, a) => f(...a)
|
|
1180
1222
|
});
|
|
1181
1223
|
}
|
|
1182
1224
|
}
|
|
1183
1225
|
});
|
|
1184
1226
|
await this._pipeline.start();
|
|
1185
|
-
(0,
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1227
|
+
(0, import_log8.log)("started", void 0, {
|
|
1228
|
+
F: __dxlog_file8,
|
|
1229
|
+
L: 107,
|
|
1230
|
+
S: this,
|
|
1231
|
+
C: (f, a) => f(...a)
|
|
1190
1232
|
});
|
|
1191
1233
|
}
|
|
1192
1234
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
@@ -1196,19 +1238,19 @@ var ControlPipeline = class {
|
|
|
1196
1238
|
}
|
|
1197
1239
|
}
|
|
1198
1240
|
async stop() {
|
|
1199
|
-
(0,
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1241
|
+
(0, import_log8.log)("stopping...", void 0, {
|
|
1242
|
+
F: __dxlog_file8,
|
|
1243
|
+
L: 121,
|
|
1244
|
+
S: this,
|
|
1245
|
+
C: (f, a) => f(...a)
|
|
1204
1246
|
});
|
|
1205
1247
|
await this._pipeline.stop();
|
|
1206
1248
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1207
|
-
(0,
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1249
|
+
(0, import_log8.log)("stopped", void 0, {
|
|
1250
|
+
F: __dxlog_file8,
|
|
1251
|
+
L: 124,
|
|
1252
|
+
S: this,
|
|
1253
|
+
C: (f, a) => f(...a)
|
|
1212
1254
|
});
|
|
1213
1255
|
}
|
|
1214
1256
|
async _saveTargetTimeframe(timeframe) {
|
|
@@ -1218,26 +1260,26 @@ var ControlPipeline = class {
|
|
|
1218
1260
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1219
1261
|
this._targetTimeframe = newTimeframe;
|
|
1220
1262
|
} catch (err) {
|
|
1221
|
-
(0,
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1263
|
+
(0, import_log8.log)(err, void 0, {
|
|
1264
|
+
F: __dxlog_file8,
|
|
1265
|
+
L: 133,
|
|
1266
|
+
S: this,
|
|
1267
|
+
C: (f, a) => f(...a)
|
|
1226
1268
|
});
|
|
1227
1269
|
}
|
|
1228
1270
|
}
|
|
1229
1271
|
};
|
|
1230
1272
|
|
|
1231
1273
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1232
|
-
var
|
|
1274
|
+
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
1233
1275
|
var import_async6 = require("@dxos/async");
|
|
1234
|
-
var
|
|
1276
|
+
var import_context5 = require("@dxos/context");
|
|
1235
1277
|
var import_credentials3 = require("@dxos/credentials");
|
|
1236
1278
|
var import_echo_db3 = require("@dxos/echo-db");
|
|
1237
1279
|
var import_errors2 = require("@dxos/errors");
|
|
1238
|
-
var
|
|
1280
|
+
var import_log9 = require("@dxos/log");
|
|
1239
1281
|
var import_timeframe4 = require("@dxos/timeframe");
|
|
1240
|
-
|
|
1282
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1241
1283
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1242
1284
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1243
1285
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1246,18 +1288,23 @@ var __decorate5 = function(decorators, target, key, desc) {
|
|
|
1246
1288
|
if (d = decorators[i])
|
|
1247
1289
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1248
1290
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1249
|
-
}
|
|
1291
|
+
}
|
|
1292
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1250
1293
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1251
1294
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1252
1295
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1253
1296
|
var DataPipeline = class DataPipeline2 {
|
|
1254
1297
|
constructor(_params) {
|
|
1255
1298
|
this._params = _params;
|
|
1256
|
-
this._ctx = new
|
|
1299
|
+
this._ctx = new import_context5.Context();
|
|
1300
|
+
this._pipeline = void 0;
|
|
1301
|
+
this._targetTimeframe = void 0;
|
|
1257
1302
|
this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
|
|
1258
1303
|
this._isOpen = false;
|
|
1259
1304
|
this._lastTimeframeSaveTime = 0;
|
|
1260
1305
|
this._lastSnapshotSaveTime = 0;
|
|
1306
|
+
this.currentEpoch = void 0;
|
|
1307
|
+
this.appliedEpoch = void 0;
|
|
1261
1308
|
this._lastProcessedEpoch = -1;
|
|
1262
1309
|
this.onNewEpoch = new import_async6.Event();
|
|
1263
1310
|
}
|
|
@@ -1276,18 +1323,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1276
1323
|
this._targetTimeframe = timeframe;
|
|
1277
1324
|
(_a = this._pipeline) == null ? void 0 : _a.state.setTargetTimeframe(timeframe);
|
|
1278
1325
|
}
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
await this._processEpochInSeparateTask(credential);
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
};
|
|
1326
|
+
async processCredential(credential) {
|
|
1327
|
+
if (!(0, import_credentials3.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
this.currentEpoch = credential;
|
|
1331
|
+
if (this._isOpen) {
|
|
1332
|
+
await this._processEpochInSeparateTask(credential);
|
|
1333
|
+
}
|
|
1291
1334
|
}
|
|
1292
1335
|
async open() {
|
|
1293
1336
|
if (this._isOpen) {
|
|
@@ -1302,8 +1345,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1302
1345
|
}
|
|
1303
1346
|
const feedWriter = {
|
|
1304
1347
|
write: (data, options) => {
|
|
1305
|
-
(0,
|
|
1306
|
-
(0,
|
|
1348
|
+
(0, import_tiny_invariant8.default)(this._pipeline, "Pipeline is not initialized.");
|
|
1349
|
+
(0, import_tiny_invariant8.default)(this.currentEpoch, "Epoch is not initialized.");
|
|
1307
1350
|
return this._pipeline.writer.write({
|
|
1308
1351
|
data
|
|
1309
1352
|
}, options);
|
|
@@ -1322,11 +1365,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1322
1365
|
if (!this._isOpen) {
|
|
1323
1366
|
return;
|
|
1324
1367
|
}
|
|
1325
|
-
(0,
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1368
|
+
(0, import_log9.log)("close", void 0, {
|
|
1369
|
+
F: __dxlog_file9,
|
|
1370
|
+
L: 171,
|
|
1371
|
+
S: this,
|
|
1372
|
+
C: (f, a) => f(...a)
|
|
1330
1373
|
});
|
|
1331
1374
|
this._isOpen = false;
|
|
1332
1375
|
await this._ctx.dispose();
|
|
@@ -1337,15 +1380,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1337
1380
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1338
1381
|
}
|
|
1339
1382
|
} catch (err) {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1383
|
+
import_log9.log.catch(err, void 0, {
|
|
1384
|
+
F: __dxlog_file9,
|
|
1385
|
+
L: 184,
|
|
1386
|
+
S: this,
|
|
1387
|
+
C: (f, a) => f(...a)
|
|
1345
1388
|
});
|
|
1346
1389
|
}
|
|
1347
1390
|
await ((_b = this.databaseHost) == null ? void 0 : _b.close());
|
|
1348
1391
|
await ((_c = this.itemManager) == null ? void 0 : _c.destroy());
|
|
1392
|
+
this._ctx = new import_context5.Context();
|
|
1393
|
+
this._pipeline = void 0;
|
|
1394
|
+
this._targetTimeframe = void 0;
|
|
1395
|
+
this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
|
|
1396
|
+
this.currentEpoch = void 0;
|
|
1397
|
+
this.appliedEpoch = void 0;
|
|
1398
|
+
this._lastProcessedEpoch = -1;
|
|
1399
|
+
this._epochCtx = void 0;
|
|
1349
1400
|
}
|
|
1350
1401
|
async _consumePipeline() {
|
|
1351
1402
|
if (this.currentEpoch) {
|
|
@@ -1353,29 +1404,29 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1353
1404
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1354
1405
|
await waitForOneEpoch;
|
|
1355
1406
|
}
|
|
1356
|
-
(0,
|
|
1407
|
+
(0, import_tiny_invariant8.default)(this._pipeline, "Pipeline is not initialized.");
|
|
1357
1408
|
for await (const msg of this._pipeline.consume()) {
|
|
1358
1409
|
const { feedKey, seq, data } = msg;
|
|
1359
|
-
(0,
|
|
1410
|
+
(0, import_log9.log)("processing message", {
|
|
1360
1411
|
feedKey,
|
|
1361
1412
|
seq
|
|
1362
1413
|
}, {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1414
|
+
F: __dxlog_file9,
|
|
1415
|
+
L: 210,
|
|
1416
|
+
S: this,
|
|
1417
|
+
C: (f, a) => f(...a)
|
|
1367
1418
|
});
|
|
1368
1419
|
try {
|
|
1369
1420
|
if (data.payload.data) {
|
|
1370
1421
|
const feedInfo = this._params.feedInfoProvider(feedKey);
|
|
1371
1422
|
if (!feedInfo) {
|
|
1372
|
-
|
|
1423
|
+
import_log9.log.error("Could not find feed.", {
|
|
1373
1424
|
feedKey
|
|
1374
1425
|
}, {
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1426
|
+
F: __dxlog_file9,
|
|
1427
|
+
L: 216,
|
|
1428
|
+
S: this,
|
|
1429
|
+
C: (f, a) => f(...a)
|
|
1379
1430
|
});
|
|
1380
1431
|
continue;
|
|
1381
1432
|
}
|
|
@@ -1388,30 +1439,30 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1388
1439
|
memberKey: feedInfo.assertion.identityKey
|
|
1389
1440
|
}
|
|
1390
1441
|
});
|
|
1391
|
-
|
|
1442
|
+
import_log9.log.trace("dxos.echo.data-pipeline.processed", {
|
|
1392
1443
|
feedKey: feedKey.toHex(),
|
|
1393
1444
|
seq,
|
|
1394
1445
|
spaceKey: this._params.spaceKey.toHex()
|
|
1395
1446
|
}, {
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1447
|
+
F: __dxlog_file9,
|
|
1448
|
+
L: 230,
|
|
1449
|
+
S: this,
|
|
1450
|
+
C: (f, a) => f(...a)
|
|
1400
1451
|
});
|
|
1401
1452
|
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1402
1453
|
}
|
|
1403
1454
|
} catch (err) {
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1455
|
+
import_log9.log.catch(err, void 0, {
|
|
1456
|
+
F: __dxlog_file9,
|
|
1457
|
+
L: 240,
|
|
1458
|
+
S: this,
|
|
1459
|
+
C: (f, a) => f(...a)
|
|
1409
1460
|
});
|
|
1410
1461
|
}
|
|
1411
1462
|
}
|
|
1412
1463
|
}
|
|
1413
1464
|
_createSnapshot() {
|
|
1414
|
-
(0,
|
|
1465
|
+
(0, import_tiny_invariant8.default)(this.databaseHost, "Database backend is not initialized.");
|
|
1415
1466
|
return {
|
|
1416
1467
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1417
1468
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1430,17 +1481,17 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1430
1481
|
try {
|
|
1431
1482
|
const propertiesItem = this.itemManager.items.find((item) => {
|
|
1432
1483
|
var _a2, _b;
|
|
1433
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = (0, import_echo_db3.getStateMachineFromItem)(item)) == null ? void 0 : _b.snapshot().type
|
|
1484
|
+
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = (0, import_echo_db3.getStateMachineFromItem)(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
|
|
1434
1485
|
});
|
|
1435
1486
|
if (propertiesItem) {
|
|
1436
1487
|
cache.properties = (_a = (0, import_echo_db3.getStateMachineFromItem)(propertiesItem)) == null ? void 0 : _a.snapshot();
|
|
1437
1488
|
}
|
|
1438
1489
|
} catch (err) {
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1490
|
+
import_log9.log.warn("Failed to cache properties", err, {
|
|
1491
|
+
F: __dxlog_file9,
|
|
1492
|
+
L: 275,
|
|
1493
|
+
S: this,
|
|
1494
|
+
C: (f, a) => f(...a)
|
|
1444
1495
|
});
|
|
1445
1496
|
}
|
|
1446
1497
|
await this._params.metadataStore.setCache(this._params.spaceKey, cache);
|
|
@@ -1460,21 +1511,21 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1460
1511
|
return;
|
|
1461
1512
|
}
|
|
1462
1513
|
await ((_a = this._epochCtx) == null ? void 0 : _a.dispose());
|
|
1463
|
-
const ctx = new
|
|
1514
|
+
const ctx = new import_context5.Context({
|
|
1464
1515
|
onError: (err) => {
|
|
1465
1516
|
if (err instanceof import_errors2.CancelledError) {
|
|
1466
|
-
(0,
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1517
|
+
(0, import_log9.log)("Epoch processing cancelled.", void 0, {
|
|
1518
|
+
F: __dxlog_file9,
|
|
1519
|
+
L: 307,
|
|
1520
|
+
S: this,
|
|
1521
|
+
C: (f, a) => f(...a)
|
|
1471
1522
|
});
|
|
1472
1523
|
} else {
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1524
|
+
import_log9.log.catch(err, void 0, {
|
|
1525
|
+
F: __dxlog_file9,
|
|
1526
|
+
L: 309,
|
|
1527
|
+
S: this,
|
|
1528
|
+
C: (f, a) => f(...a)
|
|
1478
1529
|
});
|
|
1479
1530
|
}
|
|
1480
1531
|
}
|
|
@@ -1484,13 +1535,13 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1484
1535
|
if (!this._isOpen) {
|
|
1485
1536
|
return;
|
|
1486
1537
|
}
|
|
1487
|
-
(0,
|
|
1538
|
+
(0, import_log9.log)("process epoch", {
|
|
1488
1539
|
epoch
|
|
1489
1540
|
}, {
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1541
|
+
F: __dxlog_file9,
|
|
1542
|
+
L: 319,
|
|
1543
|
+
S: this,
|
|
1544
|
+
C: (f, a) => f(...a)
|
|
1494
1545
|
});
|
|
1495
1546
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1496
1547
|
this.appliedEpoch = epoch;
|
|
@@ -1498,38 +1549,38 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1498
1549
|
});
|
|
1499
1550
|
}
|
|
1500
1551
|
async _processEpoch(ctx, epoch) {
|
|
1501
|
-
(0,
|
|
1502
|
-
(0,
|
|
1552
|
+
(0, import_tiny_invariant8.default)(this._isOpen, "Space is closed.");
|
|
1553
|
+
(0, import_tiny_invariant8.default)(this._pipeline);
|
|
1503
1554
|
this._lastProcessedEpoch = epoch.number;
|
|
1504
|
-
(0,
|
|
1555
|
+
(0, import_log9.log)("Processing epoch", {
|
|
1505
1556
|
epoch
|
|
1506
1557
|
}, {
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1558
|
+
F: __dxlog_file9,
|
|
1559
|
+
L: 333,
|
|
1560
|
+
S: this,
|
|
1561
|
+
C: (f, a) => f(...a)
|
|
1511
1562
|
});
|
|
1512
1563
|
if (epoch.snapshotCid) {
|
|
1513
1564
|
const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
|
|
1514
1565
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1515
1566
|
}
|
|
1516
|
-
(0,
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1567
|
+
(0, import_log9.log)("restarting pipeline for epoch", void 0, {
|
|
1568
|
+
F: __dxlog_file9,
|
|
1569
|
+
L: 341,
|
|
1570
|
+
S: this,
|
|
1571
|
+
C: (f, a) => f(...a)
|
|
1521
1572
|
});
|
|
1522
1573
|
await this._pipeline.pause();
|
|
1523
1574
|
await this._pipeline.setCursor(epoch.timeframe);
|
|
1524
1575
|
await this._pipeline.unpause();
|
|
1525
1576
|
}
|
|
1526
1577
|
async waitUntilTimeframe(timeframe) {
|
|
1527
|
-
(0,
|
|
1578
|
+
(0, import_tiny_invariant8.default)(this._pipeline, "Pipeline is not initialized.");
|
|
1528
1579
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1529
1580
|
}
|
|
1530
1581
|
async createEpoch() {
|
|
1531
|
-
(0,
|
|
1532
|
-
(0,
|
|
1582
|
+
(0, import_tiny_invariant8.default)(this._pipeline);
|
|
1583
|
+
(0, import_tiny_invariant8.default)(this.currentEpoch);
|
|
1533
1584
|
await this._pipeline.pause();
|
|
1534
1585
|
const snapshot = await this._createSnapshot();
|
|
1535
1586
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1546,24 +1597,24 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1546
1597
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1547
1598
|
}
|
|
1548
1599
|
};
|
|
1549
|
-
|
|
1600
|
+
_ts_decorate5([
|
|
1550
1601
|
import_async6.synchronized
|
|
1551
1602
|
], DataPipeline.prototype, "open", null);
|
|
1552
|
-
|
|
1603
|
+
_ts_decorate5([
|
|
1553
1604
|
import_async6.synchronized
|
|
1554
1605
|
], DataPipeline.prototype, "close", null);
|
|
1555
|
-
|
|
1606
|
+
_ts_decorate5([
|
|
1556
1607
|
import_async6.synchronized
|
|
1557
1608
|
], DataPipeline.prototype, "_processEpoch", null);
|
|
1558
|
-
|
|
1609
|
+
_ts_decorate5([
|
|
1559
1610
|
import_async6.synchronized
|
|
1560
1611
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1561
|
-
DataPipeline =
|
|
1612
|
+
DataPipeline = _ts_decorate5([
|
|
1562
1613
|
(0, import_async6.trackLeaks)("open", "close")
|
|
1563
1614
|
], DataPipeline);
|
|
1564
1615
|
|
|
1565
1616
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1566
|
-
|
|
1617
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1567
1618
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1568
1619
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1569
1620
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1572,16 +1623,15 @@ var __decorate6 = function(decorators, target, key, desc) {
|
|
|
1572
1623
|
if (d = decorators[i])
|
|
1573
1624
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1574
1625
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1575
|
-
}
|
|
1626
|
+
}
|
|
1627
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1576
1628
|
var Space = class Space2 {
|
|
1577
1629
|
constructor(params) {
|
|
1578
1630
|
this._addFeedLock = new import_async7.Lock();
|
|
1579
|
-
this.onCredentialProcessed = new
|
|
1631
|
+
this.onCredentialProcessed = new import_util6.Callback();
|
|
1580
1632
|
this.stateUpdate = new import_async7.Event();
|
|
1581
|
-
// Processes epoch credentials.
|
|
1582
|
-
this._dataPipelineCredentialConsumer = void 0;
|
|
1583
1633
|
this._isOpen = false;
|
|
1584
|
-
(0,
|
|
1634
|
+
(0, import_tiny_invariant9.default)(params.spaceKey && params.feedProvider);
|
|
1585
1635
|
this._key = params.spaceKey;
|
|
1586
1636
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1587
1637
|
this._feedProvider = params.feedProvider;
|
|
@@ -1613,13 +1663,13 @@ var Space = class Space2 {
|
|
|
1613
1663
|
});
|
|
1614
1664
|
this._controlPipeline.onCredentialProcessed.set(async (credential) => {
|
|
1615
1665
|
await this.onCredentialProcessed.callIfSet(credential);
|
|
1616
|
-
(0,
|
|
1666
|
+
(0, import_log10.log)("onCredentialProcessed", {
|
|
1617
1667
|
credential
|
|
1618
1668
|
}, {
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1669
|
+
F: __dxlog_file10,
|
|
1670
|
+
L: 107,
|
|
1671
|
+
S: this,
|
|
1672
|
+
C: (f, a) => f(...a)
|
|
1623
1673
|
});
|
|
1624
1674
|
this.stateUpdate.emit();
|
|
1625
1675
|
});
|
|
@@ -1682,14 +1732,14 @@ var Space = class Space2 {
|
|
|
1682
1732
|
return this._snapshotManager;
|
|
1683
1733
|
}
|
|
1684
1734
|
setControlFeed(feed) {
|
|
1685
|
-
(0,
|
|
1735
|
+
(0, import_tiny_invariant9.default)(!this._controlFeed, "Control feed already set.");
|
|
1686
1736
|
this._controlFeed = feed;
|
|
1687
1737
|
this._controlPipeline.setWriteFeed(feed);
|
|
1688
1738
|
return this;
|
|
1689
1739
|
}
|
|
1690
1740
|
setDataFeed(feed) {
|
|
1691
1741
|
var _a;
|
|
1692
|
-
(0,
|
|
1742
|
+
(0, import_tiny_invariant9.default)(!this._dataFeed, "Data feed already set.");
|
|
1693
1743
|
this._dataFeed = feed;
|
|
1694
1744
|
(_a = this._dataPipeline.pipeline) == null ? void 0 : _a.setWriteFeed(feed);
|
|
1695
1745
|
return this;
|
|
@@ -1707,98 +1757,95 @@ var Space = class Space2 {
|
|
|
1707
1757
|
// return this._dataPipeline?.getFeeds();
|
|
1708
1758
|
// }
|
|
1709
1759
|
async open() {
|
|
1710
|
-
(0,
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1760
|
+
(0, import_log10.log)("opening...", void 0, {
|
|
1761
|
+
F: __dxlog_file10,
|
|
1762
|
+
L: 209,
|
|
1763
|
+
S: this,
|
|
1764
|
+
C: (f, a) => f(...a)
|
|
1715
1765
|
});
|
|
1716
1766
|
if (this._isOpen) {
|
|
1717
1767
|
return;
|
|
1718
1768
|
}
|
|
1719
1769
|
await this._controlPipeline.start();
|
|
1720
1770
|
await this.protocol.start();
|
|
1721
|
-
|
|
1722
|
-
await this._dataPipelineCredentialConsumer.open();
|
|
1771
|
+
await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
|
|
1723
1772
|
this._isOpen = true;
|
|
1724
|
-
(0,
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1773
|
+
(0, import_log10.log)("opened", void 0, {
|
|
1774
|
+
F: __dxlog_file10,
|
|
1775
|
+
L: 220,
|
|
1776
|
+
S: this,
|
|
1777
|
+
C: (f, a) => f(...a)
|
|
1729
1778
|
});
|
|
1730
1779
|
}
|
|
1731
1780
|
async close() {
|
|
1732
|
-
|
|
1733
|
-
(0, import_log9.log)("closing...", {
|
|
1781
|
+
(0, import_log10.log)("closing...", {
|
|
1734
1782
|
key: this._key
|
|
1735
1783
|
}, {
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1784
|
+
F: __dxlog_file10,
|
|
1785
|
+
L: 225,
|
|
1786
|
+
S: this,
|
|
1787
|
+
C: (f, a) => f(...a)
|
|
1740
1788
|
});
|
|
1741
1789
|
if (!this._isOpen) {
|
|
1742
1790
|
return;
|
|
1743
1791
|
}
|
|
1744
|
-
await
|
|
1745
|
-
this._dataPipelineCredentialConsumer = void 0;
|
|
1792
|
+
await this._controlPipeline.spaceState.removeCredentialProcessor(this._dataPipeline);
|
|
1746
1793
|
await this._dataPipeline.close();
|
|
1747
1794
|
await this.protocol.stop();
|
|
1748
1795
|
await this._controlPipeline.stop();
|
|
1749
1796
|
this._isOpen = false;
|
|
1750
|
-
(0,
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1797
|
+
(0, import_log10.log)("closed", void 0, {
|
|
1798
|
+
F: __dxlog_file10,
|
|
1799
|
+
L: 238,
|
|
1800
|
+
S: this,
|
|
1801
|
+
C: (f, a) => f(...a)
|
|
1755
1802
|
});
|
|
1756
1803
|
}
|
|
1757
1804
|
async initializeDataPipeline() {
|
|
1758
|
-
(0,
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1805
|
+
(0, import_log10.log)("initializeDataPipeline", void 0, {
|
|
1806
|
+
F: __dxlog_file10,
|
|
1807
|
+
L: 243,
|
|
1808
|
+
S: this,
|
|
1809
|
+
C: (f, a) => f(...a)
|
|
1763
1810
|
});
|
|
1764
|
-
(0,
|
|
1811
|
+
(0, import_tiny_invariant9.default)(this._isOpen, "Space must be open to initialize data pipeline.");
|
|
1765
1812
|
await this._dataPipeline.open();
|
|
1766
1813
|
}
|
|
1767
1814
|
};
|
|
1768
|
-
|
|
1769
|
-
|
|
1815
|
+
_ts_decorate6([
|
|
1816
|
+
import_log10.logInfo
|
|
1770
1817
|
], Space.prototype, "key", null);
|
|
1771
|
-
|
|
1818
|
+
_ts_decorate6([
|
|
1772
1819
|
import_async7.synchronized
|
|
1773
1820
|
], Space.prototype, "open", null);
|
|
1774
|
-
|
|
1821
|
+
_ts_decorate6([
|
|
1775
1822
|
import_async7.synchronized
|
|
1776
1823
|
], Space.prototype, "close", null);
|
|
1777
|
-
|
|
1824
|
+
_ts_decorate6([
|
|
1778
1825
|
import_async7.synchronized
|
|
1779
1826
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1780
|
-
Space =
|
|
1827
|
+
Space = _ts_decorate6([
|
|
1781
1828
|
(0, import_async7.trackLeaks)("open", "close")
|
|
1782
1829
|
], Space);
|
|
1783
1830
|
|
|
1784
1831
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
1785
1832
|
var import_async8 = require("@dxos/async");
|
|
1786
|
-
var
|
|
1833
|
+
var import_debug5 = require("@dxos/debug");
|
|
1787
1834
|
var import_keys6 = require("@dxos/keys");
|
|
1788
|
-
var
|
|
1835
|
+
var import_log12 = require("@dxos/log");
|
|
1789
1836
|
var import_protocols6 = require("@dxos/protocols");
|
|
1790
|
-
var
|
|
1837
|
+
var import_util8 = require("@dxos/util");
|
|
1791
1838
|
|
|
1792
1839
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
1793
1840
|
var import_crypto3 = require("@dxos/crypto");
|
|
1794
1841
|
var import_keys5 = require("@dxos/keys");
|
|
1795
|
-
var
|
|
1842
|
+
var import_log11 = require("@dxos/log");
|
|
1796
1843
|
var import_network_manager = require("@dxos/network-manager");
|
|
1797
1844
|
var import_teleport2 = require("@dxos/teleport");
|
|
1798
1845
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
1799
1846
|
var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
|
|
1800
|
-
var
|
|
1801
|
-
|
|
1847
|
+
var import_util7 = require("@dxos/util");
|
|
1848
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1802
1849
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1803
1850
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1804
1851
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1807,13 +1854,14 @@ var __decorate7 = function(decorators, target, key, desc) {
|
|
|
1807
1854
|
if (d = decorators[i])
|
|
1808
1855
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1809
1856
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1810
|
-
}
|
|
1857
|
+
}
|
|
1858
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1811
1859
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1812
1860
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1813
1861
|
var SpaceProtocol = class {
|
|
1814
1862
|
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore }) {
|
|
1815
1863
|
this._feeds = /* @__PURE__ */ new Set();
|
|
1816
|
-
this._sessions = new
|
|
1864
|
+
this._sessions = new import_util7.ComplexMap(import_keys5.PublicKey.hash);
|
|
1817
1865
|
this._networkManager = networkManager;
|
|
1818
1866
|
this._swarmIdentity = swarmIdentity;
|
|
1819
1867
|
this._onSessionAuth = onSessionAuth;
|
|
@@ -1821,7 +1869,7 @@ var SpaceProtocol = class {
|
|
|
1821
1869
|
this.blobSync = new import_teleport_extension_object_sync.BlobSync({
|
|
1822
1870
|
blobStore
|
|
1823
1871
|
});
|
|
1824
|
-
this._topic =
|
|
1872
|
+
this._topic = import_crypto3.subtleCrypto.digest("SHA-256", topic.asBuffer()).then(import_crypto3.discoveryKey).then(import_keys5.PublicKey.from);
|
|
1825
1873
|
}
|
|
1826
1874
|
get sessions() {
|
|
1827
1875
|
return this._sessions;
|
|
@@ -1834,13 +1882,13 @@ var SpaceProtocol = class {
|
|
|
1834
1882
|
}
|
|
1835
1883
|
// TODO(burdon): Create abstraction for Space (e.g., add keys and have provider).
|
|
1836
1884
|
addFeed(feed) {
|
|
1837
|
-
(0,
|
|
1885
|
+
(0, import_log11.log)("addFeed", {
|
|
1838
1886
|
key: feed.key
|
|
1839
1887
|
}, {
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1888
|
+
F: __dxlog_file11,
|
|
1889
|
+
L: 96,
|
|
1890
|
+
S: this,
|
|
1891
|
+
C: (f, a) => f(...a)
|
|
1844
1892
|
});
|
|
1845
1893
|
this._feeds.add(feed);
|
|
1846
1894
|
for (const session of this._sessions.values()) {
|
|
@@ -1858,41 +1906,41 @@ var SpaceProtocol = class {
|
|
|
1858
1906
|
sampleSize: 20
|
|
1859
1907
|
};
|
|
1860
1908
|
await this.blobSync.open();
|
|
1861
|
-
(0,
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1909
|
+
(0, import_log11.log)("starting...", void 0, {
|
|
1910
|
+
F: __dxlog_file11,
|
|
1911
|
+
L: 121,
|
|
1912
|
+
S: this,
|
|
1913
|
+
C: (f, a) => f(...a)
|
|
1866
1914
|
});
|
|
1867
1915
|
this._connection = await this._networkManager.joinSwarm({
|
|
1868
1916
|
protocolProvider: this._createProtocolProvider(credentials),
|
|
1869
1917
|
peerId: this._swarmIdentity.peerKey,
|
|
1870
|
-
topic: this._topic,
|
|
1918
|
+
topic: await this._topic,
|
|
1871
1919
|
topology: new import_network_manager.MMSTTopology(topologyConfig),
|
|
1872
1920
|
label: `Protocol swarm: ${this._topic}`
|
|
1873
1921
|
});
|
|
1874
|
-
(0,
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1922
|
+
(0, import_log11.log)("started", void 0, {
|
|
1923
|
+
F: __dxlog_file11,
|
|
1924
|
+
L: 130,
|
|
1925
|
+
S: this,
|
|
1926
|
+
C: (f, a) => f(...a)
|
|
1879
1927
|
});
|
|
1880
1928
|
}
|
|
1881
1929
|
async stop() {
|
|
1882
1930
|
await this.blobSync.close();
|
|
1883
1931
|
if (this._connection) {
|
|
1884
|
-
(0,
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1932
|
+
(0, import_log11.log)("stopping...", void 0, {
|
|
1933
|
+
F: __dxlog_file11,
|
|
1934
|
+
L: 137,
|
|
1935
|
+
S: this,
|
|
1936
|
+
C: (f, a) => f(...a)
|
|
1889
1937
|
});
|
|
1890
1938
|
await this._connection.close();
|
|
1891
|
-
(0,
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1939
|
+
(0, import_log11.log)("stopped", void 0, {
|
|
1940
|
+
F: __dxlog_file11,
|
|
1941
|
+
L: 139,
|
|
1942
|
+
S: this,
|
|
1943
|
+
C: (f, a) => f(...a)
|
|
1896
1944
|
});
|
|
1897
1945
|
}
|
|
1898
1946
|
}
|
|
@@ -1913,11 +1961,11 @@ var SpaceProtocol = class {
|
|
|
1913
1961
|
};
|
|
1914
1962
|
}
|
|
1915
1963
|
};
|
|
1916
|
-
|
|
1917
|
-
|
|
1964
|
+
_ts_decorate7([
|
|
1965
|
+
import_log11.logInfo
|
|
1918
1966
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
1919
|
-
|
|
1920
|
-
|
|
1967
|
+
_ts_decorate7([
|
|
1968
|
+
import_log11.logInfo
|
|
1921
1969
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
1922
1970
|
var AuthStatus;
|
|
1923
1971
|
(function(AuthStatus2) {
|
|
@@ -1943,6 +1991,9 @@ var SpaceProtocolSession = class {
|
|
|
1943
1991
|
get authStatus() {
|
|
1944
1992
|
return this._authStatus;
|
|
1945
1993
|
}
|
|
1994
|
+
get stats() {
|
|
1995
|
+
return this._teleport.stats;
|
|
1996
|
+
}
|
|
1946
1997
|
get stream() {
|
|
1947
1998
|
return this._teleport.stream;
|
|
1948
1999
|
}
|
|
@@ -1953,11 +2004,11 @@ var SpaceProtocolSession = class {
|
|
|
1953
2004
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
1954
2005
|
onAuthSuccess: () => {
|
|
1955
2006
|
var _a;
|
|
1956
|
-
(0,
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2007
|
+
(0, import_log11.log)("Peer authenticated", void 0, {
|
|
2008
|
+
F: __dxlog_file11,
|
|
2009
|
+
L: 236,
|
|
2010
|
+
S: this,
|
|
2011
|
+
C: (f, a) => f(...a)
|
|
1961
2012
|
});
|
|
1962
2013
|
this._authStatus = AuthStatus.SUCCESS;
|
|
1963
2014
|
(_a = this._onSessionAuth) == null ? void 0 : _a.call(this, this._teleport);
|
|
@@ -1975,15 +2026,15 @@ var SpaceProtocolSession = class {
|
|
|
1975
2026
|
await this._teleport.close();
|
|
1976
2027
|
}
|
|
1977
2028
|
};
|
|
1978
|
-
|
|
1979
|
-
|
|
2029
|
+
_ts_decorate7([
|
|
2030
|
+
import_log11.logInfo
|
|
1980
2031
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
1981
|
-
|
|
1982
|
-
|
|
2032
|
+
_ts_decorate7([
|
|
2033
|
+
import_log11.logInfo
|
|
1983
2034
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
1984
2035
|
|
|
1985
2036
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
1986
|
-
|
|
2037
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1987
2038
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1988
2039
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1989
2040
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1992,10 +2043,11 @@ var __decorate8 = function(decorators, target, key, desc) {
|
|
|
1992
2043
|
if (d = decorators[i])
|
|
1993
2044
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1994
2045
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1995
|
-
}
|
|
2046
|
+
}
|
|
2047
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
1996
2048
|
var SpaceManager = class SpaceManager2 {
|
|
1997
2049
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
1998
|
-
this._spaces = new
|
|
2050
|
+
this._spaces = new import_util8.ComplexMap(import_keys6.PublicKey.hash);
|
|
1999
2051
|
this._instanceId = import_keys6.PublicKey.random().toHex();
|
|
2000
2052
|
this._feedStore = feedStore;
|
|
2001
2053
|
this._networkManager = networkManager;
|
|
@@ -2017,23 +2069,23 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2017
2069
|
}
|
|
2018
2070
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2019
2071
|
var _a;
|
|
2020
|
-
|
|
2072
|
+
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.begin({
|
|
2021
2073
|
id: this._instanceId
|
|
2022
2074
|
}), {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2075
|
+
F: __dxlog_file12,
|
|
2076
|
+
L: 97,
|
|
2077
|
+
S: this,
|
|
2078
|
+
C: (f, a) => f(...a)
|
|
2027
2079
|
});
|
|
2028
|
-
(0,
|
|
2080
|
+
(0, import_log12.log)("constructing space...", {
|
|
2029
2081
|
spaceKey: metadata.genesisFeedKey
|
|
2030
2082
|
}, {
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2083
|
+
F: __dxlog_file12,
|
|
2084
|
+
L: 98,
|
|
2085
|
+
S: this,
|
|
2086
|
+
C: (f, a) => f(...a)
|
|
2035
2087
|
});
|
|
2036
|
-
const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : (0,
|
|
2088
|
+
const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : (0, import_debug5.failUndefined)());
|
|
2037
2089
|
const spaceKey = metadata.key;
|
|
2038
2090
|
const protocol = new SpaceProtocol({
|
|
2039
2091
|
topic: spaceKey,
|
|
@@ -2055,24 +2107,24 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2055
2107
|
memberKey
|
|
2056
2108
|
});
|
|
2057
2109
|
this._spaces.set(space.key, space);
|
|
2058
|
-
|
|
2110
|
+
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.end({
|
|
2059
2111
|
id: this._instanceId
|
|
2060
2112
|
}), {
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2113
|
+
F: __dxlog_file12,
|
|
2114
|
+
L: 125,
|
|
2115
|
+
S: this,
|
|
2116
|
+
C: (f, a) => f(...a)
|
|
2065
2117
|
});
|
|
2066
2118
|
return space;
|
|
2067
2119
|
}
|
|
2068
2120
|
};
|
|
2069
|
-
|
|
2121
|
+
_ts_decorate8([
|
|
2070
2122
|
import_async8.synchronized
|
|
2071
2123
|
], SpaceManager.prototype, "open", null);
|
|
2072
|
-
|
|
2124
|
+
_ts_decorate8([
|
|
2073
2125
|
import_async8.synchronized
|
|
2074
2126
|
], SpaceManager.prototype, "close", null);
|
|
2075
|
-
SpaceManager =
|
|
2127
|
+
SpaceManager = _ts_decorate8([
|
|
2076
2128
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2077
2129
|
], SpaceManager);
|
|
2078
2130
|
|
|
@@ -2101,7 +2153,7 @@ var WebsocketNetworkManagerProvider = (signalUrl) => () => new import_network_ma
|
|
|
2101
2153
|
});
|
|
2102
2154
|
var TestAgentBuilder = class {
|
|
2103
2155
|
constructor({ storage, networkManagerProvider } = {}) {
|
|
2104
|
-
this._agents = new
|
|
2156
|
+
this._agents = new import_util9.ComplexMap(import_keys7.PublicKey.hash);
|
|
2105
2157
|
this._storage = storage != null ? storage : (0, import_random_access_storage.createStorage)({
|
|
2106
2158
|
type: import_random_access_storage.StorageType.RAM
|
|
2107
2159
|
});
|
|
@@ -2143,7 +2195,7 @@ var TestAgent = class {
|
|
|
2143
2195
|
this._feedBuilder = _feedBuilder;
|
|
2144
2196
|
this.identityKey = identityKey;
|
|
2145
2197
|
this.deviceKey = deviceKey;
|
|
2146
|
-
this._spaces = new
|
|
2198
|
+
this._spaces = new import_util9.ComplexMap(import_keys7.PublicKey.hash);
|
|
2147
2199
|
this.modelFactory = new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel);
|
|
2148
2200
|
this.storage = this._feedBuilder.storage;
|
|
2149
2201
|
this.keyring = this._feedBuilder.keyring;
|
|
@@ -2298,7 +2350,7 @@ var createRemoteDatabaseFromDataServiceHost = async (modelFactory, dataServiceHo
|
|
|
2298
2350
|
const dataServiceSubscriptions = new DataServiceSubscriptions();
|
|
2299
2351
|
const dataService = new DataServiceImpl(dataServiceSubscriptions);
|
|
2300
2352
|
const spaceKey = import_keys8.PublicKey.random();
|
|
2301
|
-
dataServiceSubscriptions.registerSpace(spaceKey, dataServiceHost);
|
|
2353
|
+
await dataServiceSubscriptions.registerSpace(spaceKey, dataServiceHost);
|
|
2302
2354
|
const itemManager = new import_echo_db4.ItemManager(modelFactory);
|
|
2303
2355
|
const backend = new import_echo_db4.DatabaseProxy(dataService, itemManager, spaceKey);
|
|
2304
2356
|
await backend.open(new import_model_factory2.ModelFactory().registerModel(import_document_model2.DocumentModel));
|