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