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