@dxos/echo-pipeline 0.1.52 → 0.1.53-main.00be1a9
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-SCMKAWNW.mjs} +386 -366
- package/dist/lib/browser/chunk-SCMKAWNW.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 +2 -2
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/node/index.cjs +452 -432
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +436 -416
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/dbhost/snapshot-store.d.ts +3 -0
- package/dist/types/src/dbhost/snapshot-store.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
- 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/package.json +31 -32
- package/src/common/feeds.ts +3 -3
- package/src/dbhost/data-service-host.ts +3 -3
- package/src/dbhost/data-service.ts +4 -4
- package/src/dbhost/snapshot-store.ts +3 -0
- package/src/metadata/metadata-store.ts +6 -5
- package/src/pipeline/message-selector.ts +3 -5
- package/src/pipeline/pipeline.ts +11 -11
- package/src/space/auth.ts +3 -3
- package/src/space/data-pipeline.ts +11 -10
- 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.ts +5 -5
- package/dist/lib/browser/chunk-AXGWKSM3.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -115,12 +115,13 @@ var UnknownModelError = class extends DBError {
|
|
|
115
115
|
|
|
116
116
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
117
117
|
var import_crc_32 = __toESM(require("crc-32"));
|
|
118
|
-
var
|
|
118
|
+
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
119
119
|
var import_async = require("@dxos/async");
|
|
120
120
|
var import_errors = require("@dxos/errors");
|
|
121
121
|
var import_log = require("@dxos/log");
|
|
122
122
|
var import_protocols = require("@dxos/protocols");
|
|
123
|
-
var
|
|
123
|
+
var import_util = require("@dxos/util");
|
|
124
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
124
125
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
125
126
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
126
127
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -129,7 +130,8 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
129
130
|
if (d = decorators[i])
|
|
130
131
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
131
132
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
132
|
-
}
|
|
133
|
+
}
|
|
134
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
133
135
|
var emptyEchoMetadata = () => ({
|
|
134
136
|
version: import_protocols.STORAGE_VERSION,
|
|
135
137
|
spaces: [],
|
|
@@ -174,10 +176,10 @@ var MetadataStore = class {
|
|
|
174
176
|
size: dataSize,
|
|
175
177
|
checksum
|
|
176
178
|
}, {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
F: __dxlog_file,
|
|
180
|
+
L: 69,
|
|
181
|
+
S: this,
|
|
182
|
+
C: (f, a) => f(...a)
|
|
181
183
|
});
|
|
182
184
|
if (fileLength < dataSize + 8) {
|
|
183
185
|
throw new import_errors.DataCorruptionError("Metadata size is smaller than expected.");
|
|
@@ -192,10 +194,10 @@ var MetadataStore = class {
|
|
|
192
194
|
import_log.log.error("failed to load metadata", {
|
|
193
195
|
err
|
|
194
196
|
}, {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
F: __dxlog_file,
|
|
198
|
+
L: 84,
|
|
199
|
+
S: this,
|
|
200
|
+
C: (f, a) => f(...a)
|
|
199
201
|
});
|
|
200
202
|
this._metadata = emptyEchoMetadata();
|
|
201
203
|
} finally {
|
|
@@ -213,7 +215,7 @@ var MetadataStore = class {
|
|
|
213
215
|
this.update.emit(data);
|
|
214
216
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
215
217
|
try {
|
|
216
|
-
const encoded =
|
|
218
|
+
const encoded = (0, import_util.arrayToBuffer)(import_protocols.schema.getCodecForType("dxos.echo.metadata.EchoMetadata").encode(data));
|
|
217
219
|
const checksum = import_crc_32.default.buf(encoded);
|
|
218
220
|
const result = Buffer.alloc(8 + encoded.length);
|
|
219
221
|
result.writeInt32LE(encoded.length, 0);
|
|
@@ -224,10 +226,10 @@ var MetadataStore = class {
|
|
|
224
226
|
size: encoded.length,
|
|
225
227
|
checksum
|
|
226
228
|
}, {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
F: __dxlog_file,
|
|
230
|
+
L: 116,
|
|
231
|
+
S: this,
|
|
232
|
+
C: (f, a) => f(...a)
|
|
231
233
|
});
|
|
232
234
|
} finally {
|
|
233
235
|
await file.close();
|
|
@@ -239,18 +241,18 @@ var MetadataStore = class {
|
|
|
239
241
|
return this._metadata.identity.haloSpace;
|
|
240
242
|
}
|
|
241
243
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
242
|
-
(0,
|
|
244
|
+
(0, import_tiny_invariant.default)(space, "Space not found");
|
|
243
245
|
return space;
|
|
244
246
|
}
|
|
245
247
|
/**
|
|
246
248
|
* Clears storage - doesn't work for now.
|
|
247
249
|
*/
|
|
248
250
|
async clear() {
|
|
249
|
-
(0, import_log.log)("clearing all metadata",
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
(0, import_log.log)("clearing all metadata", void 0, {
|
|
252
|
+
F: __dxlog_file,
|
|
253
|
+
L: 137,
|
|
254
|
+
S: this,
|
|
255
|
+
C: (f, a) => f(...a)
|
|
254
256
|
});
|
|
255
257
|
await this._directory.delete();
|
|
256
258
|
this._metadata = emptyEchoMetadata();
|
|
@@ -259,13 +261,13 @@ var MetadataStore = class {
|
|
|
259
261
|
return this._metadata.identity;
|
|
260
262
|
}
|
|
261
263
|
async setIdentityRecord(record) {
|
|
262
|
-
(0,
|
|
264
|
+
(0, import_tiny_invariant.default)(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
|
|
263
265
|
this._metadata.identity = record;
|
|
264
266
|
await this._save();
|
|
265
267
|
}
|
|
266
268
|
async addSpace(record) {
|
|
267
269
|
var _a, _b, _c;
|
|
268
|
-
(0,
|
|
270
|
+
(0, import_tiny_invariant.default)(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
|
|
269
271
|
((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
|
|
270
272
|
await this._save();
|
|
271
273
|
}
|
|
@@ -288,24 +290,24 @@ var MetadataStore = class {
|
|
|
288
290
|
await this._save();
|
|
289
291
|
}
|
|
290
292
|
};
|
|
291
|
-
|
|
293
|
+
_ts_decorate([
|
|
292
294
|
import_async.synchronized
|
|
293
295
|
], MetadataStore.prototype, "load", null);
|
|
294
|
-
|
|
296
|
+
_ts_decorate([
|
|
295
297
|
import_async.synchronized
|
|
296
298
|
], MetadataStore.prototype, "_save", null);
|
|
297
299
|
var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
298
300
|
|
|
299
301
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
300
|
-
var
|
|
302
|
+
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
301
303
|
var import_async3 = require("@dxos/async");
|
|
302
304
|
var import_context = require("@dxos/context");
|
|
303
|
-
var
|
|
305
|
+
var import_debug2 = require("@dxos/debug");
|
|
304
306
|
var import_feed_store = require("@dxos/feed-store");
|
|
305
307
|
var import_keys = require("@dxos/keys");
|
|
306
|
-
var
|
|
308
|
+
var import_log4 = require("@dxos/log");
|
|
307
309
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
308
|
-
var
|
|
310
|
+
var import_util2 = require("@dxos/util");
|
|
309
311
|
|
|
310
312
|
// packages/core/echo/echo-pipeline/src/common/codec.ts
|
|
311
313
|
var import_hypercore = require("@dxos/hypercore");
|
|
@@ -314,38 +316,43 @@ var codec = import_protocols2.schema.getCodecForType("dxos.echo.feed.FeedMessage
|
|
|
314
316
|
var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
|
|
315
317
|
|
|
316
318
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
317
|
-
var
|
|
319
|
+
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
318
320
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
319
|
-
(0,
|
|
320
|
-
(0,
|
|
321
|
+
(0, import_tiny_invariant2.default)(mapper);
|
|
322
|
+
(0, import_tiny_invariant2.default)(writer);
|
|
321
323
|
return {
|
|
322
324
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
323
325
|
};
|
|
324
326
|
};
|
|
325
327
|
|
|
326
328
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
327
|
-
var
|
|
328
|
-
var
|
|
329
|
-
var
|
|
329
|
+
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
330
|
+
var import_log2 = require("@dxos/log");
|
|
331
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
|
|
330
332
|
var createMessageSelector = (timeframeClock) => {
|
|
331
333
|
return (messages) => {
|
|
332
334
|
for (let i = 0; i < messages.length; i++) {
|
|
333
335
|
const { data: { timeframe } } = messages[i];
|
|
334
|
-
(0,
|
|
336
|
+
(0, import_tiny_invariant3.default)(timeframe);
|
|
335
337
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
336
338
|
return i;
|
|
337
339
|
}
|
|
338
340
|
}
|
|
339
|
-
|
|
341
|
+
(0, import_log2.log)("Skipping...", void 0, {
|
|
342
|
+
F: __dxlog_file2,
|
|
343
|
+
L: 34,
|
|
344
|
+
S: void 0,
|
|
345
|
+
C: (f, a) => f(...a)
|
|
346
|
+
});
|
|
340
347
|
};
|
|
341
348
|
};
|
|
342
349
|
|
|
343
350
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
344
351
|
var import_async2 = require("@dxos/async");
|
|
345
|
-
var
|
|
346
|
-
var
|
|
352
|
+
var import_debug = require("@dxos/debug");
|
|
353
|
+
var import_log3 = require("@dxos/log");
|
|
347
354
|
var import_timeframe = require("@dxos/timeframe");
|
|
348
|
-
|
|
355
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
349
356
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
350
357
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
351
358
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -354,7 +361,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
354
361
|
if (d = decorators[i])
|
|
355
362
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
356
363
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
357
|
-
}
|
|
364
|
+
}
|
|
365
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
358
366
|
var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
359
367
|
feedKey,
|
|
360
368
|
index
|
|
@@ -409,36 +417,36 @@ var TimeframeClock = class {
|
|
|
409
417
|
return !gaps.isEmpty();
|
|
410
418
|
}
|
|
411
419
|
async waitUntilReached(target) {
|
|
412
|
-
(0,
|
|
420
|
+
(0, import_log3.log)("waitUntilReached", {
|
|
413
421
|
target,
|
|
414
422
|
current: this._timeframe
|
|
415
423
|
}, {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
424
|
+
F: __dxlog_file3,
|
|
425
|
+
L: 73,
|
|
426
|
+
S: this,
|
|
427
|
+
C: (f, a) => f(...a)
|
|
420
428
|
});
|
|
421
429
|
await this.update.waitForCondition(() => {
|
|
422
|
-
(0,
|
|
430
|
+
(0, import_log3.log)("check if reached", {
|
|
423
431
|
target,
|
|
424
432
|
current: this._timeframe,
|
|
425
433
|
deps: import_timeframe.Timeframe.dependencies(target, this._timeframe)
|
|
426
434
|
}, {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
435
|
+
F: __dxlog_file3,
|
|
436
|
+
L: 75,
|
|
437
|
+
S: this,
|
|
438
|
+
C: (f, a) => f(...a)
|
|
431
439
|
});
|
|
432
440
|
return import_timeframe.Timeframe.dependencies(target, this._timeframe).isEmpty();
|
|
433
441
|
});
|
|
434
442
|
}
|
|
435
443
|
};
|
|
436
|
-
|
|
437
|
-
(0,
|
|
444
|
+
_ts_decorate2([
|
|
445
|
+
(0, import_debug.timed)(5e3)
|
|
438
446
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
439
447
|
|
|
440
448
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
441
|
-
|
|
449
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
442
450
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
443
451
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
444
452
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -447,7 +455,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
447
455
|
if (d = decorators[i])
|
|
448
456
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
449
457
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
450
|
-
}
|
|
458
|
+
}
|
|
459
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
451
460
|
var PipelineState = class {
|
|
452
461
|
// prettier-ignore
|
|
453
462
|
constructor(_feeds, _timeframeClock) {
|
|
@@ -498,15 +507,15 @@ var PipelineState = class {
|
|
|
498
507
|
*/
|
|
499
508
|
async waitUntilReachedTargetTimeframe({ ctx = new import_context.Context(), timeout, breakOnStall = true } = {}) {
|
|
500
509
|
var _a;
|
|
501
|
-
(0,
|
|
510
|
+
(0, import_log4.log)("waitUntilReachedTargetTimeframe", {
|
|
502
511
|
timeout,
|
|
503
512
|
current: this.timeframe,
|
|
504
513
|
target: this.targetTimeframe
|
|
505
514
|
}, {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
515
|
+
F: __dxlog_file4,
|
|
516
|
+
L: 118,
|
|
517
|
+
S: this,
|
|
518
|
+
C: (f, a) => f(...a)
|
|
510
519
|
});
|
|
511
520
|
(_a = this._reachedTargetPromise) != null ? _a : this._reachedTargetPromise = Promise.race([
|
|
512
521
|
this._timeframeClock.update.waitForCondition(() => {
|
|
@@ -527,16 +536,16 @@ var PipelineState = class {
|
|
|
527
536
|
if (done) {
|
|
528
537
|
return;
|
|
529
538
|
}
|
|
530
|
-
|
|
539
|
+
import_log4.log.warn("waitUntilReachedTargetTimeframe timed out", {
|
|
531
540
|
timeout,
|
|
532
541
|
current: this.timeframe,
|
|
533
542
|
target: this.targetTimeframe,
|
|
534
543
|
dependencies: import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe)
|
|
535
544
|
}, {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
545
|
+
F: __dxlog_file4,
|
|
546
|
+
L: 144,
|
|
547
|
+
S: this,
|
|
548
|
+
C: (f, a) => f(...a)
|
|
540
549
|
});
|
|
541
550
|
})
|
|
542
551
|
]);
|
|
@@ -548,7 +557,7 @@ var PipelineState = class {
|
|
|
548
557
|
var Pipeline = class {
|
|
549
558
|
constructor() {
|
|
550
559
|
this._timeframeClock = new TimeframeClock(new import_timeframe2.Timeframe());
|
|
551
|
-
this._feeds = new
|
|
560
|
+
this._feeds = new import_util2.ComplexMap(import_keys.PublicKey.hash);
|
|
552
561
|
// External state accessor.
|
|
553
562
|
this._state = new PipelineState(this._feeds, this._timeframeClock);
|
|
554
563
|
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
@@ -563,7 +572,7 @@ var Pipeline = class {
|
|
|
563
572
|
return this._state;
|
|
564
573
|
}
|
|
565
574
|
get writer() {
|
|
566
|
-
(0,
|
|
575
|
+
(0, import_tiny_invariant4.default)(this._writer, "Writer not set.");
|
|
567
576
|
return this._writer;
|
|
568
577
|
}
|
|
569
578
|
getFeeds() {
|
|
@@ -582,46 +591,46 @@ var Pipeline = class {
|
|
|
582
591
|
return this._feeds.has(feedKey);
|
|
583
592
|
}
|
|
584
593
|
setWriteFeed(feed) {
|
|
585
|
-
(0,
|
|
586
|
-
(0,
|
|
594
|
+
(0, import_tiny_invariant4.default)(!this._writer, "Writer already set.");
|
|
595
|
+
(0, import_tiny_invariant4.default)(feed.properties.writable, "Feed must be writable.");
|
|
587
596
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
588
597
|
timeframe: this._timeframeClock.timeframe,
|
|
589
598
|
payload
|
|
590
599
|
}), feed.createFeedWriter());
|
|
591
600
|
}
|
|
592
601
|
async start() {
|
|
593
|
-
(0,
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
602
|
+
(0, import_log4.log)("starting...", {}, {
|
|
603
|
+
F: __dxlog_file4,
|
|
604
|
+
L: 264,
|
|
605
|
+
S: this,
|
|
606
|
+
C: (f, a) => f(...a)
|
|
598
607
|
});
|
|
599
608
|
await this._initIterator();
|
|
600
609
|
await this._feedSetIterator.open();
|
|
601
|
-
(0,
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
610
|
+
(0, import_log4.log)("started", void 0, {
|
|
611
|
+
F: __dxlog_file4,
|
|
612
|
+
L: 267,
|
|
613
|
+
S: this,
|
|
614
|
+
C: (f, a) => f(...a)
|
|
606
615
|
});
|
|
607
616
|
this._isStarted = true;
|
|
608
617
|
}
|
|
609
618
|
async stop() {
|
|
610
619
|
var _a;
|
|
611
|
-
(0,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
620
|
+
(0, import_log4.log)("stopping...", {}, {
|
|
621
|
+
F: __dxlog_file4,
|
|
622
|
+
L: 273,
|
|
623
|
+
S: this,
|
|
624
|
+
C: (f, a) => f(...a)
|
|
616
625
|
});
|
|
617
626
|
this._isStopping = true;
|
|
618
627
|
await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
|
|
619
628
|
await this._processingTrigger.wait();
|
|
620
|
-
(0,
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
629
|
+
(0, import_log4.log)("stopped", void 0, {
|
|
630
|
+
F: __dxlog_file4,
|
|
631
|
+
L: 277,
|
|
632
|
+
S: this,
|
|
633
|
+
C: (f, a) => f(...a)
|
|
625
634
|
});
|
|
626
635
|
this._isStarted = false;
|
|
627
636
|
}
|
|
@@ -629,7 +638,7 @@ var Pipeline = class {
|
|
|
629
638
|
* @param timeframe Timeframe of already processed messages. The pipeline will start processing messages AFTER this timeframe.
|
|
630
639
|
*/
|
|
631
640
|
async setCursor(timeframe) {
|
|
632
|
-
(0,
|
|
641
|
+
(0, import_tiny_invariant4.default)(!this._isStarted || this._isPaused, "Invalid state.");
|
|
633
642
|
this._state._startTimeframe = timeframe;
|
|
634
643
|
this._timeframeClock.setTimeframe(timeframe);
|
|
635
644
|
for (const feed of this._feeds.values()) {
|
|
@@ -645,7 +654,7 @@ var Pipeline = class {
|
|
|
645
654
|
* Calling pause while processing will cause a deadlock.
|
|
646
655
|
*/
|
|
647
656
|
async pause() {
|
|
648
|
-
(0,
|
|
657
|
+
(0, import_tiny_invariant4.default)(this._isStarted, "Pipeline is not open.");
|
|
649
658
|
if (this._isPaused) {
|
|
650
659
|
return;
|
|
651
660
|
}
|
|
@@ -654,8 +663,8 @@ var Pipeline = class {
|
|
|
654
663
|
this._isPaused = true;
|
|
655
664
|
}
|
|
656
665
|
async unpause() {
|
|
657
|
-
(0,
|
|
658
|
-
(0,
|
|
666
|
+
(0, import_tiny_invariant4.default)(this._isStarted, "Pipeline is not open.");
|
|
667
|
+
(0, import_tiny_invariant4.default)(this._isPaused, "Pipeline is not paused.");
|
|
659
668
|
this._pauseTrigger.wake();
|
|
660
669
|
this._isPaused = false;
|
|
661
670
|
}
|
|
@@ -664,15 +673,15 @@ var Pipeline = class {
|
|
|
664
673
|
* Updates the timeframe clock after the message has bee processed.
|
|
665
674
|
*/
|
|
666
675
|
async *consume() {
|
|
667
|
-
(0,
|
|
676
|
+
(0, import_tiny_invariant4.default)(!this._isOpen, "Pipeline is already being consumed.");
|
|
668
677
|
this._isOpen = true;
|
|
669
|
-
(0,
|
|
678
|
+
(0, import_tiny_invariant4.default)(this._feedSetIterator, "Iterator not initialized.");
|
|
670
679
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
671
680
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
672
681
|
while (!this._isStopping) {
|
|
673
682
|
await this._pauseTrigger.wait();
|
|
674
683
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
675
|
-
(0,
|
|
684
|
+
(0, import_tiny_invariant4.default)(this._feedSetIterator, "Iterator not initialized.");
|
|
676
685
|
lastFeedSetIterator = this._feedSetIterator;
|
|
677
686
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
678
687
|
}
|
|
@@ -680,7 +689,7 @@ var Pipeline = class {
|
|
|
680
689
|
if (done) {
|
|
681
690
|
continue;
|
|
682
691
|
}
|
|
683
|
-
const block = value != null ? value : (0,
|
|
692
|
+
const block = value != null ? value : (0, import_debug2.failUndefined)();
|
|
684
693
|
this._processingTrigger.reset();
|
|
685
694
|
this._timeframeClock.updatePendingTimeframe(import_keys.PublicKey.from(block.feedKey), block.seq);
|
|
686
695
|
yield block;
|
|
@@ -694,24 +703,24 @@ var Pipeline = class {
|
|
|
694
703
|
const timeframe = this._state._startTimeframe;
|
|
695
704
|
const seq = (_a = timeframe.get(feed.key)) != null ? _a : 0;
|
|
696
705
|
feed.undownload({
|
|
697
|
-
callback: () => (0,
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
706
|
+
callback: () => (0, import_log4.log)("Undownloaded", void 0, {
|
|
707
|
+
F: __dxlog_file4,
|
|
708
|
+
L: 371,
|
|
709
|
+
S: this,
|
|
710
|
+
C: (f, a) => f(...a)
|
|
702
711
|
})
|
|
703
712
|
});
|
|
704
713
|
feed.download({
|
|
705
714
|
start: seq + 1,
|
|
706
715
|
linear: true
|
|
707
716
|
}).catch((err) => {
|
|
708
|
-
(0,
|
|
717
|
+
(0, import_log4.log)("failed to download feed", {
|
|
709
718
|
err
|
|
710
719
|
}, {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
720
|
+
F: __dxlog_file4,
|
|
721
|
+
L: 374,
|
|
722
|
+
S: this,
|
|
723
|
+
C: (f, a) => f(...a)
|
|
715
724
|
});
|
|
716
725
|
});
|
|
717
726
|
}
|
|
@@ -721,11 +730,11 @@ var Pipeline = class {
|
|
|
721
730
|
stallTimeout: 1e3
|
|
722
731
|
});
|
|
723
732
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
733
|
+
import_log4.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
734
|
+
F: __dxlog_file4,
|
|
735
|
+
L: 384,
|
|
736
|
+
S: this,
|
|
737
|
+
C: (f, a) => f(...a)
|
|
729
738
|
});
|
|
730
739
|
this._state.stalled.emit();
|
|
731
740
|
});
|
|
@@ -734,30 +743,31 @@ var Pipeline = class {
|
|
|
734
743
|
}
|
|
735
744
|
}
|
|
736
745
|
};
|
|
737
|
-
|
|
746
|
+
_ts_decorate3([
|
|
738
747
|
import_async3.synchronized
|
|
739
748
|
], Pipeline.prototype, "start", null);
|
|
740
|
-
|
|
749
|
+
_ts_decorate3([
|
|
741
750
|
import_async3.synchronized
|
|
742
751
|
], Pipeline.prototype, "stop", null);
|
|
743
|
-
|
|
752
|
+
_ts_decorate3([
|
|
744
753
|
import_async3.synchronized
|
|
745
754
|
], Pipeline.prototype, "setCursor", null);
|
|
746
|
-
|
|
755
|
+
_ts_decorate3([
|
|
747
756
|
import_async3.synchronized
|
|
748
757
|
], Pipeline.prototype, "pause", null);
|
|
749
|
-
|
|
758
|
+
_ts_decorate3([
|
|
750
759
|
import_async3.synchronized
|
|
751
760
|
], Pipeline.prototype, "unpause", null);
|
|
752
761
|
|
|
753
762
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
754
|
-
var
|
|
763
|
+
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
755
764
|
var import_async4 = require("@dxos/async");
|
|
756
765
|
var import_context2 = require("@dxos/context");
|
|
757
766
|
var import_crypto = require("@dxos/crypto");
|
|
758
|
-
var
|
|
767
|
+
var import_log5 = require("@dxos/log");
|
|
759
768
|
var import_protocols3 = require("@dxos/protocols");
|
|
760
769
|
var import_teleport = require("@dxos/teleport");
|
|
770
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
761
771
|
var AuthExtension = class extends import_teleport.RpcExtension {
|
|
762
772
|
constructor(_authParams) {
|
|
763
773
|
super({
|
|
@@ -772,11 +782,11 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
772
782
|
this._authParams = _authParams;
|
|
773
783
|
this._ctx = new import_context2.Context({
|
|
774
784
|
onError: (err) => {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
785
|
+
import_log5.log.catch(err, void 0, {
|
|
786
|
+
F: __dxlog_file5,
|
|
787
|
+
L: 29,
|
|
788
|
+
S: this,
|
|
789
|
+
C: (f, a) => f(...a)
|
|
780
790
|
});
|
|
781
791
|
}
|
|
782
792
|
});
|
|
@@ -794,11 +804,11 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
794
804
|
credential
|
|
795
805
|
};
|
|
796
806
|
} catch (err) {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
807
|
+
import_log5.log.error("failed to generate auth credentials", err, {
|
|
808
|
+
F: __dxlog_file5,
|
|
809
|
+
L: 56,
|
|
810
|
+
S: this,
|
|
811
|
+
C: (f, a) => f(...a)
|
|
802
812
|
});
|
|
803
813
|
throw new Error("auth rejected");
|
|
804
814
|
}
|
|
@@ -814,16 +824,16 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
814
824
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
815
825
|
challenge
|
|
816
826
|
});
|
|
817
|
-
(0,
|
|
827
|
+
(0, import_tiny_invariant5.default)((credential == null ? void 0 : credential.length) > 0, "invalid credential");
|
|
818
828
|
const success = await this._authParams.verifier(challenge, credential);
|
|
819
|
-
(0,
|
|
829
|
+
(0, import_tiny_invariant5.default)(success, "credential not verified");
|
|
820
830
|
(0, import_async4.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
|
|
821
831
|
} catch (err) {
|
|
822
|
-
(0,
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
832
|
+
(0, import_log5.log)("auth failed", err, {
|
|
833
|
+
F: __dxlog_file5,
|
|
834
|
+
L: 75,
|
|
835
|
+
S: this,
|
|
836
|
+
C: (f, a) => f(...a)
|
|
827
837
|
});
|
|
828
838
|
this.close();
|
|
829
839
|
this._authParams.onAuthFailure();
|
|
@@ -837,48 +847,49 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
837
847
|
};
|
|
838
848
|
|
|
839
849
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
840
|
-
var
|
|
850
|
+
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
841
851
|
var import_async7 = require("@dxos/async");
|
|
842
|
-
var
|
|
852
|
+
var import_log10 = require("@dxos/log");
|
|
843
853
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
844
|
-
var
|
|
854
|
+
var import_util6 = require("@dxos/util");
|
|
845
855
|
|
|
846
856
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
847
857
|
var import_credentials = require("@dxos/credentials");
|
|
848
858
|
var import_keys2 = require("@dxos/keys");
|
|
849
|
-
var
|
|
859
|
+
var import_log6 = require("@dxos/log");
|
|
850
860
|
var import_credentials2 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
851
861
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
852
|
-
var
|
|
862
|
+
var import_util3 = require("@dxos/util");
|
|
863
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
853
864
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
854
865
|
var ControlPipeline = class {
|
|
855
866
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
856
867
|
this._lastTimeframeSaveTime = Date.now();
|
|
857
|
-
this.onFeedAdmitted = new
|
|
868
|
+
this.onFeedAdmitted = new import_util3.Callback();
|
|
858
869
|
this._spaceKey = spaceKey;
|
|
859
870
|
this._metadata = metadataStore;
|
|
860
871
|
this._pipeline = new Pipeline();
|
|
861
872
|
void this._pipeline.addFeed(genesisFeed);
|
|
862
873
|
this._spaceStateMachine = new import_credentials.SpaceStateMachine(spaceKey);
|
|
863
874
|
this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
|
|
864
|
-
(0,
|
|
875
|
+
(0, import_log6.log)("feed admitted", {
|
|
865
876
|
key: info.key
|
|
866
877
|
}, {
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
878
|
+
F: __dxlog_file6,
|
|
879
|
+
L: 51,
|
|
880
|
+
S: this,
|
|
881
|
+
C: (f, a) => f(...a)
|
|
871
882
|
});
|
|
872
883
|
if (info.assertion.designation === import_credentials2.AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
|
|
873
884
|
try {
|
|
874
885
|
const feed = await feedProvider(info.key);
|
|
875
886
|
await this._pipeline.addFeed(feed);
|
|
876
887
|
} catch (err) {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
888
|
+
import_log6.log.catch(err, void 0, {
|
|
889
|
+
F: __dxlog_file6,
|
|
890
|
+
L: 59,
|
|
891
|
+
S: this,
|
|
892
|
+
C: (f, a) => f(...a)
|
|
882
893
|
});
|
|
883
894
|
}
|
|
884
895
|
}
|
|
@@ -897,55 +908,55 @@ var ControlPipeline = class {
|
|
|
897
908
|
this._pipeline.setWriteFeed(feed);
|
|
898
909
|
}
|
|
899
910
|
async start() {
|
|
900
|
-
(0,
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
911
|
+
(0, import_log6.log)("starting...", void 0, {
|
|
912
|
+
F: __dxlog_file6,
|
|
913
|
+
L: 83,
|
|
914
|
+
S: this,
|
|
915
|
+
C: (f, a) => f(...a)
|
|
905
916
|
});
|
|
906
917
|
setTimeout(async () => {
|
|
907
918
|
for await (const msg of this._pipeline.consume()) {
|
|
908
919
|
try {
|
|
909
|
-
(0,
|
|
920
|
+
(0, import_log6.log)("processing", {
|
|
910
921
|
key: msg.feedKey,
|
|
911
922
|
seq: msg.seq
|
|
912
923
|
}, {
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
924
|
+
F: __dxlog_file6,
|
|
925
|
+
L: 88,
|
|
926
|
+
S: this,
|
|
927
|
+
C: (f, a) => f(...a)
|
|
917
928
|
});
|
|
918
929
|
if (msg.data.payload.credential) {
|
|
919
930
|
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys2.PublicKey.from(msg.feedKey));
|
|
920
931
|
if (!result) {
|
|
921
|
-
|
|
932
|
+
import_log6.log.warn("processing failed", {
|
|
922
933
|
msg
|
|
923
934
|
}, {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
935
|
+
F: __dxlog_file6,
|
|
936
|
+
L: 95,
|
|
937
|
+
S: this,
|
|
938
|
+
C: (f, a) => f(...a)
|
|
928
939
|
});
|
|
929
940
|
} else {
|
|
930
941
|
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
931
942
|
}
|
|
932
943
|
}
|
|
933
944
|
} catch (err) {
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
945
|
+
import_log6.log.catch(err, void 0, {
|
|
946
|
+
F: __dxlog_file6,
|
|
947
|
+
L: 101,
|
|
948
|
+
S: this,
|
|
949
|
+
C: (f, a) => f(...a)
|
|
939
950
|
});
|
|
940
951
|
}
|
|
941
952
|
}
|
|
942
953
|
});
|
|
943
954
|
await this._pipeline.start();
|
|
944
|
-
(0,
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
955
|
+
(0, import_log6.log)("started", void 0, {
|
|
956
|
+
F: __dxlog_file6,
|
|
957
|
+
L: 107,
|
|
958
|
+
S: this,
|
|
959
|
+
C: (f, a) => f(...a)
|
|
949
960
|
});
|
|
950
961
|
}
|
|
951
962
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
@@ -955,19 +966,19 @@ var ControlPipeline = class {
|
|
|
955
966
|
}
|
|
956
967
|
}
|
|
957
968
|
async stop() {
|
|
958
|
-
(0,
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
969
|
+
(0, import_log6.log)("stopping...", void 0, {
|
|
970
|
+
F: __dxlog_file6,
|
|
971
|
+
L: 121,
|
|
972
|
+
S: this,
|
|
973
|
+
C: (f, a) => f(...a)
|
|
963
974
|
});
|
|
964
975
|
await this._pipeline.stop();
|
|
965
976
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
966
|
-
(0,
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
977
|
+
(0, import_log6.log)("stopped", void 0, {
|
|
978
|
+
F: __dxlog_file6,
|
|
979
|
+
L: 124,
|
|
980
|
+
S: this,
|
|
981
|
+
C: (f, a) => f(...a)
|
|
971
982
|
});
|
|
972
983
|
}
|
|
973
984
|
async _saveTargetTimeframe(timeframe) {
|
|
@@ -977,38 +988,39 @@ var ControlPipeline = class {
|
|
|
977
988
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
978
989
|
this._targetTimeframe = newTimeframe;
|
|
979
990
|
} catch (err) {
|
|
980
|
-
(0,
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
991
|
+
(0, import_log6.log)(err, void 0, {
|
|
992
|
+
F: __dxlog_file6,
|
|
993
|
+
L: 133,
|
|
994
|
+
S: this,
|
|
995
|
+
C: (f, a) => f(...a)
|
|
985
996
|
});
|
|
986
997
|
}
|
|
987
998
|
}
|
|
988
999
|
};
|
|
989
1000
|
|
|
990
1001
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
991
|
-
var
|
|
1002
|
+
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
992
1003
|
var import_async6 = require("@dxos/async");
|
|
993
1004
|
var import_context4 = require("@dxos/context");
|
|
994
1005
|
var import_credentials3 = require("@dxos/credentials");
|
|
995
1006
|
var import_echo_db3 = require("@dxos/echo-db");
|
|
996
1007
|
var import_errors2 = require("@dxos/errors");
|
|
997
|
-
var
|
|
1008
|
+
var import_log9 = require("@dxos/log");
|
|
998
1009
|
var import_timeframe4 = require("@dxos/timeframe");
|
|
999
1010
|
|
|
1000
1011
|
// packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
|
|
1001
|
-
var
|
|
1012
|
+
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
1002
1013
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
1003
1014
|
var import_echo_db = require("@dxos/echo-db");
|
|
1004
|
-
var
|
|
1005
|
-
var
|
|
1015
|
+
var import_log7 = require("@dxos/log");
|
|
1016
|
+
var import_util4 = require("@dxos/util");
|
|
1017
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts";
|
|
1006
1018
|
var DataServiceHost = class {
|
|
1007
1019
|
constructor(_itemManager, _itemDemuxer, _writeStream) {
|
|
1008
1020
|
this._itemManager = _itemManager;
|
|
1009
1021
|
this._itemDemuxer = _itemDemuxer;
|
|
1010
1022
|
this._writeStream = _writeStream;
|
|
1011
|
-
this._clientTagMap = new
|
|
1023
|
+
this._clientTagMap = new import_util4.ComplexMap(([feedKey, seq]) => `${feedKey.toHex()}:${seq}`);
|
|
1012
1024
|
}
|
|
1013
1025
|
/**
|
|
1014
1026
|
* Real-time subscription to data objects in a space.
|
|
@@ -1024,15 +1036,15 @@ var DataServiceHost = class {
|
|
|
1024
1036
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
1025
1037
|
var _a;
|
|
1026
1038
|
const { batch, meta } = message;
|
|
1027
|
-
(0,
|
|
1028
|
-
(0,
|
|
1039
|
+
(0, import_tiny_invariant6.default)(!meta.clientTag, "Unexpected client tag in mutation message");
|
|
1040
|
+
(0, import_log7.log)("message", {
|
|
1029
1041
|
batch,
|
|
1030
1042
|
meta
|
|
1031
1043
|
}, {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1044
|
+
F: __dxlog_file7,
|
|
1045
|
+
L: 51,
|
|
1046
|
+
S: this,
|
|
1047
|
+
C: (f, a) => f(...a)
|
|
1036
1048
|
});
|
|
1037
1049
|
const clientTag = this._clientTagMap.get([
|
|
1038
1050
|
message.meta.feedKey,
|
|
@@ -1057,29 +1069,29 @@ var DataServiceHost = class {
|
|
|
1057
1069
|
}
|
|
1058
1070
|
async write(request) {
|
|
1059
1071
|
var _a, _b;
|
|
1060
|
-
(0,
|
|
1061
|
-
(0,
|
|
1072
|
+
(0, import_tiny_invariant6.default)(this._writeStream, "Cannot write mutations in readonly mode");
|
|
1073
|
+
(0, import_log7.log)("write", {
|
|
1062
1074
|
clientTag: request.clientTag,
|
|
1063
1075
|
objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
|
|
1064
1076
|
}, {
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1077
|
+
F: __dxlog_file7,
|
|
1078
|
+
L: 79,
|
|
1079
|
+
S: this,
|
|
1080
|
+
C: (f, a) => f(...a)
|
|
1069
1081
|
});
|
|
1070
1082
|
const message = createDataMessage(request.batch);
|
|
1071
1083
|
const receipt = await this._writeStream.write(message, {
|
|
1072
1084
|
afterWrite: async (receipt2) => {
|
|
1073
1085
|
if (request.clientTag) {
|
|
1074
|
-
(0,
|
|
1086
|
+
(0, import_log7.log)("tag", {
|
|
1075
1087
|
clientTag: request.clientTag,
|
|
1076
1088
|
feedKey: receipt2.feedKey,
|
|
1077
1089
|
seq: receipt2.seq
|
|
1078
1090
|
}, {
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1091
|
+
F: __dxlog_file7,
|
|
1092
|
+
L: 88,
|
|
1093
|
+
S: this,
|
|
1094
|
+
C: (f, a) => f(...a)
|
|
1083
1095
|
});
|
|
1084
1096
|
this._clientTagMap.set([
|
|
1085
1097
|
receipt2.feedKey,
|
|
@@ -1145,11 +1157,11 @@ var DatabaseHost = class {
|
|
|
1145
1157
|
// packages/core/echo/echo-pipeline/src/dbhost/snapshot-manager.ts
|
|
1146
1158
|
var import_async5 = require("@dxos/async");
|
|
1147
1159
|
var import_context3 = require("@dxos/context");
|
|
1148
|
-
var
|
|
1160
|
+
var import_debug3 = require("@dxos/debug");
|
|
1149
1161
|
var import_keys3 = require("@dxos/keys");
|
|
1150
1162
|
var import_protocols4 = require("@dxos/protocols");
|
|
1151
1163
|
var import_blob = require("@dxos/protocols/proto/dxos/echo/blob");
|
|
1152
|
-
|
|
1164
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
1153
1165
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1154
1166
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1155
1167
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1158,7 +1170,7 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
1158
1170
|
if (d = decorators[i])
|
|
1159
1171
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1160
1172
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1161
|
-
}
|
|
1173
|
+
}
|
|
1162
1174
|
var SnapshotManager = class SnapshotManager2 {
|
|
1163
1175
|
// prettier-ignore
|
|
1164
1176
|
constructor(_snapshotStore, _blobStore, _blobSync) {
|
|
@@ -1189,10 +1201,10 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
1189
1201
|
return import_keys3.PublicKey.from(id).toHex();
|
|
1190
1202
|
}
|
|
1191
1203
|
};
|
|
1192
|
-
|
|
1193
|
-
(0,
|
|
1204
|
+
_ts_decorate4([
|
|
1205
|
+
(0, import_debug3.timed)(1e4)
|
|
1194
1206
|
], SnapshotManager.prototype, "load", null);
|
|
1195
|
-
SnapshotManager =
|
|
1207
|
+
SnapshotManager = _ts_decorate4([
|
|
1196
1208
|
(0, import_async5.trackLeaks)("open", "close")
|
|
1197
1209
|
], SnapshotManager);
|
|
1198
1210
|
|
|
@@ -1242,37 +1254,38 @@ var SnapshotStore = class {
|
|
|
1242
1254
|
};
|
|
1243
1255
|
|
|
1244
1256
|
// packages/core/echo/echo-pipeline/src/dbhost/data-service.ts
|
|
1245
|
-
var
|
|
1246
|
-
var
|
|
1257
|
+
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1258
|
+
var import_debug4 = require("@dxos/debug");
|
|
1247
1259
|
var import_keys4 = require("@dxos/keys");
|
|
1248
|
-
var
|
|
1249
|
-
var
|
|
1260
|
+
var import_log8 = require("@dxos/log");
|
|
1261
|
+
var import_util5 = require("@dxos/util");
|
|
1262
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service.ts";
|
|
1250
1263
|
var DataServiceSubscriptions = class {
|
|
1251
1264
|
constructor() {
|
|
1252
|
-
this._spaces = new
|
|
1265
|
+
this._spaces = new import_util5.ComplexMap(import_keys4.PublicKey.hash);
|
|
1253
1266
|
}
|
|
1254
1267
|
clear() {
|
|
1255
1268
|
this._spaces.clear();
|
|
1256
1269
|
}
|
|
1257
1270
|
registerSpace(spaceKey, host) {
|
|
1258
|
-
(0,
|
|
1271
|
+
(0, import_log8.log)("Registering space", {
|
|
1259
1272
|
spaceKey
|
|
1260
1273
|
}, {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1274
|
+
F: __dxlog_file8,
|
|
1275
|
+
L: 31,
|
|
1276
|
+
S: this,
|
|
1277
|
+
C: (f, a) => f(...a)
|
|
1265
1278
|
});
|
|
1266
1279
|
this._spaces.set(spaceKey, host);
|
|
1267
1280
|
}
|
|
1268
1281
|
unregisterSpace(spaceKey) {
|
|
1269
|
-
(0,
|
|
1282
|
+
(0, import_log8.log)("Unregistering space", {
|
|
1270
1283
|
spaceKey
|
|
1271
1284
|
}, {
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1285
|
+
F: __dxlog_file8,
|
|
1286
|
+
L: 36,
|
|
1287
|
+
S: this,
|
|
1288
|
+
C: (f, a) => f(...a)
|
|
1276
1289
|
});
|
|
1277
1290
|
this._spaces.delete(spaceKey);
|
|
1278
1291
|
}
|
|
@@ -1286,21 +1299,21 @@ var DataServiceImpl = class {
|
|
|
1286
1299
|
}
|
|
1287
1300
|
subscribe(request) {
|
|
1288
1301
|
var _a;
|
|
1289
|
-
(0,
|
|
1290
|
-
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : (0,
|
|
1302
|
+
(0, import_tiny_invariant7.default)(request.spaceKey);
|
|
1303
|
+
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : (0, import_debug4.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
1291
1304
|
return host.subscribe();
|
|
1292
1305
|
}
|
|
1293
1306
|
write(request) {
|
|
1294
1307
|
var _a;
|
|
1295
|
-
(0,
|
|
1296
|
-
(0,
|
|
1297
|
-
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : (0,
|
|
1308
|
+
(0, import_tiny_invariant7.default)(request.spaceKey);
|
|
1309
|
+
(0, import_tiny_invariant7.default)(request.batch);
|
|
1310
|
+
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : (0, import_debug4.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
1298
1311
|
return host.write(request);
|
|
1299
1312
|
}
|
|
1300
1313
|
};
|
|
1301
1314
|
|
|
1302
1315
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1303
|
-
|
|
1316
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1304
1317
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1305
1318
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1306
1319
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1309,7 +1322,8 @@ var __decorate5 = function(decorators, target, key, desc) {
|
|
|
1309
1322
|
if (d = decorators[i])
|
|
1310
1323
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1311
1324
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1312
|
-
}
|
|
1325
|
+
}
|
|
1326
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1313
1327
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1314
1328
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1315
1329
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
@@ -1365,8 +1379,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1365
1379
|
}
|
|
1366
1380
|
const feedWriter = {
|
|
1367
1381
|
write: (data, options) => {
|
|
1368
|
-
(0,
|
|
1369
|
-
(0,
|
|
1382
|
+
(0, import_tiny_invariant8.default)(this._pipeline, "Pipeline is not initialized.");
|
|
1383
|
+
(0, import_tiny_invariant8.default)(this.currentEpoch, "Epoch is not initialized.");
|
|
1370
1384
|
return this._pipeline.writer.write({
|
|
1371
1385
|
data
|
|
1372
1386
|
}, options);
|
|
@@ -1385,11 +1399,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1385
1399
|
if (!this._isOpen) {
|
|
1386
1400
|
return;
|
|
1387
1401
|
}
|
|
1388
|
-
(0,
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1402
|
+
(0, import_log9.log)("close", void 0, {
|
|
1403
|
+
F: __dxlog_file9,
|
|
1404
|
+
L: 174,
|
|
1405
|
+
S: this,
|
|
1406
|
+
C: (f, a) => f(...a)
|
|
1393
1407
|
});
|
|
1394
1408
|
this._isOpen = false;
|
|
1395
1409
|
await this._ctx.dispose();
|
|
@@ -1400,11 +1414,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1400
1414
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1401
1415
|
}
|
|
1402
1416
|
} catch (err) {
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1417
|
+
import_log9.log.catch(err, void 0, {
|
|
1418
|
+
F: __dxlog_file9,
|
|
1419
|
+
L: 187,
|
|
1420
|
+
S: this,
|
|
1421
|
+
C: (f, a) => f(...a)
|
|
1408
1422
|
});
|
|
1409
1423
|
}
|
|
1410
1424
|
await ((_b = this.databaseHost) == null ? void 0 : _b.close());
|
|
@@ -1416,29 +1430,29 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1416
1430
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1417
1431
|
await waitForOneEpoch;
|
|
1418
1432
|
}
|
|
1419
|
-
(0,
|
|
1433
|
+
(0, import_tiny_invariant8.default)(this._pipeline, "Pipeline is not initialized.");
|
|
1420
1434
|
for await (const msg of this._pipeline.consume()) {
|
|
1421
1435
|
const { feedKey, seq, data } = msg;
|
|
1422
|
-
(0,
|
|
1436
|
+
(0, import_log9.log)("processing message", {
|
|
1423
1437
|
feedKey,
|
|
1424
1438
|
seq
|
|
1425
1439
|
}, {
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1440
|
+
F: __dxlog_file9,
|
|
1441
|
+
L: 204,
|
|
1442
|
+
S: this,
|
|
1443
|
+
C: (f, a) => f(...a)
|
|
1430
1444
|
});
|
|
1431
1445
|
try {
|
|
1432
1446
|
if (data.payload.data) {
|
|
1433
1447
|
const feedInfo = this._params.feedInfoProvider(feedKey);
|
|
1434
1448
|
if (!feedInfo) {
|
|
1435
|
-
|
|
1449
|
+
import_log9.log.error("Could not find feed.", {
|
|
1436
1450
|
feedKey
|
|
1437
1451
|
}, {
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1452
|
+
F: __dxlog_file9,
|
|
1453
|
+
L: 210,
|
|
1454
|
+
S: this,
|
|
1455
|
+
C: (f, a) => f(...a)
|
|
1442
1456
|
});
|
|
1443
1457
|
continue;
|
|
1444
1458
|
}
|
|
@@ -1451,30 +1465,30 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1451
1465
|
memberKey: feedInfo.assertion.identityKey
|
|
1452
1466
|
}
|
|
1453
1467
|
});
|
|
1454
|
-
|
|
1468
|
+
import_log9.log.trace("dxos.echo.data-pipeline.processed", {
|
|
1455
1469
|
feedKey: feedKey.toHex(),
|
|
1456
1470
|
seq,
|
|
1457
1471
|
spaceKey: this._params.spaceKey.toHex()
|
|
1458
1472
|
}, {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1473
|
+
F: __dxlog_file9,
|
|
1474
|
+
L: 224,
|
|
1475
|
+
S: this,
|
|
1476
|
+
C: (f, a) => f(...a)
|
|
1463
1477
|
});
|
|
1464
1478
|
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1465
1479
|
}
|
|
1466
1480
|
} catch (err) {
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1481
|
+
import_log9.log.catch(err, void 0, {
|
|
1482
|
+
F: __dxlog_file9,
|
|
1483
|
+
L: 234,
|
|
1484
|
+
S: this,
|
|
1485
|
+
C: (f, a) => f(...a)
|
|
1472
1486
|
});
|
|
1473
1487
|
}
|
|
1474
1488
|
}
|
|
1475
1489
|
}
|
|
1476
1490
|
_createSnapshot() {
|
|
1477
|
-
(0,
|
|
1491
|
+
(0, import_tiny_invariant8.default)(this.databaseHost, "Database backend is not initialized.");
|
|
1478
1492
|
return {
|
|
1479
1493
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1480
1494
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1493,17 +1507,17 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1493
1507
|
try {
|
|
1494
1508
|
const propertiesItem = this.itemManager.items.find((item) => {
|
|
1495
1509
|
var _a2, _b;
|
|
1496
|
-
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
|
|
1510
|
+
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";
|
|
1497
1511
|
});
|
|
1498
1512
|
if (propertiesItem) {
|
|
1499
1513
|
cache.properties = (_a = (0, import_echo_db3.getStateMachineFromItem)(propertiesItem)) == null ? void 0 : _a.snapshot();
|
|
1500
1514
|
}
|
|
1501
1515
|
} catch (err) {
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1516
|
+
import_log9.log.warn("Failed to cache properties", err, {
|
|
1517
|
+
F: __dxlog_file9,
|
|
1518
|
+
L: 269,
|
|
1519
|
+
S: this,
|
|
1520
|
+
C: (f, a) => f(...a)
|
|
1507
1521
|
});
|
|
1508
1522
|
}
|
|
1509
1523
|
await this._params.metadataStore.setCache(this._params.spaceKey, cache);
|
|
@@ -1526,18 +1540,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1526
1540
|
const ctx = new import_context4.Context({
|
|
1527
1541
|
onError: (err) => {
|
|
1528
1542
|
if (err instanceof import_errors2.CancelledError) {
|
|
1529
|
-
(0,
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1543
|
+
(0, import_log9.log)("Epoch processing cancelled.", void 0, {
|
|
1544
|
+
F: __dxlog_file9,
|
|
1545
|
+
L: 301,
|
|
1546
|
+
S: this,
|
|
1547
|
+
C: (f, a) => f(...a)
|
|
1534
1548
|
});
|
|
1535
1549
|
} else {
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1550
|
+
import_log9.log.catch(err, void 0, {
|
|
1551
|
+
F: __dxlog_file9,
|
|
1552
|
+
L: 303,
|
|
1553
|
+
S: this,
|
|
1554
|
+
C: (f, a) => f(...a)
|
|
1541
1555
|
});
|
|
1542
1556
|
}
|
|
1543
1557
|
}
|
|
@@ -1547,13 +1561,13 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1547
1561
|
if (!this._isOpen) {
|
|
1548
1562
|
return;
|
|
1549
1563
|
}
|
|
1550
|
-
(0,
|
|
1564
|
+
(0, import_log9.log)("process epoch", {
|
|
1551
1565
|
epoch
|
|
1552
1566
|
}, {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1567
|
+
F: __dxlog_file9,
|
|
1568
|
+
L: 313,
|
|
1569
|
+
S: this,
|
|
1570
|
+
C: (f, a) => f(...a)
|
|
1557
1571
|
});
|
|
1558
1572
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1559
1573
|
this.appliedEpoch = epoch;
|
|
@@ -1561,38 +1575,38 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1561
1575
|
});
|
|
1562
1576
|
}
|
|
1563
1577
|
async _processEpoch(ctx, epoch) {
|
|
1564
|
-
(0,
|
|
1565
|
-
(0,
|
|
1578
|
+
(0, import_tiny_invariant8.default)(this._isOpen, "Space is closed.");
|
|
1579
|
+
(0, import_tiny_invariant8.default)(this._pipeline);
|
|
1566
1580
|
this._lastProcessedEpoch = epoch.number;
|
|
1567
|
-
(0,
|
|
1581
|
+
(0, import_log9.log)("Processing epoch", {
|
|
1568
1582
|
epoch
|
|
1569
1583
|
}, {
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1584
|
+
F: __dxlog_file9,
|
|
1585
|
+
L: 327,
|
|
1586
|
+
S: this,
|
|
1587
|
+
C: (f, a) => f(...a)
|
|
1574
1588
|
});
|
|
1575
1589
|
if (epoch.snapshotCid) {
|
|
1576
1590
|
const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
|
|
1577
1591
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1578
1592
|
}
|
|
1579
|
-
(0,
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1593
|
+
(0, import_log9.log)("restarting pipeline for epoch", void 0, {
|
|
1594
|
+
F: __dxlog_file9,
|
|
1595
|
+
L: 335,
|
|
1596
|
+
S: this,
|
|
1597
|
+
C: (f, a) => f(...a)
|
|
1584
1598
|
});
|
|
1585
1599
|
await this._pipeline.pause();
|
|
1586
1600
|
await this._pipeline.setCursor(epoch.timeframe);
|
|
1587
1601
|
await this._pipeline.unpause();
|
|
1588
1602
|
}
|
|
1589
1603
|
async waitUntilTimeframe(timeframe) {
|
|
1590
|
-
(0,
|
|
1604
|
+
(0, import_tiny_invariant8.default)(this._pipeline, "Pipeline is not initialized.");
|
|
1591
1605
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1592
1606
|
}
|
|
1593
1607
|
async createEpoch() {
|
|
1594
|
-
(0,
|
|
1595
|
-
(0,
|
|
1608
|
+
(0, import_tiny_invariant8.default)(this._pipeline);
|
|
1609
|
+
(0, import_tiny_invariant8.default)(this.currentEpoch);
|
|
1596
1610
|
await this._pipeline.pause();
|
|
1597
1611
|
const snapshot = await this._createSnapshot();
|
|
1598
1612
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1609,24 +1623,24 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1609
1623
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1610
1624
|
}
|
|
1611
1625
|
};
|
|
1612
|
-
|
|
1626
|
+
_ts_decorate5([
|
|
1613
1627
|
import_async6.synchronized
|
|
1614
1628
|
], DataPipeline.prototype, "open", null);
|
|
1615
|
-
|
|
1629
|
+
_ts_decorate5([
|
|
1616
1630
|
import_async6.synchronized
|
|
1617
1631
|
], DataPipeline.prototype, "close", null);
|
|
1618
|
-
|
|
1632
|
+
_ts_decorate5([
|
|
1619
1633
|
import_async6.synchronized
|
|
1620
1634
|
], DataPipeline.prototype, "_processEpoch", null);
|
|
1621
|
-
|
|
1635
|
+
_ts_decorate5([
|
|
1622
1636
|
import_async6.synchronized
|
|
1623
1637
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1624
|
-
DataPipeline =
|
|
1638
|
+
DataPipeline = _ts_decorate5([
|
|
1625
1639
|
(0, import_async6.trackLeaks)("open", "close")
|
|
1626
1640
|
], DataPipeline);
|
|
1627
1641
|
|
|
1628
1642
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1629
|
-
|
|
1643
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1630
1644
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1631
1645
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1632
1646
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1635,16 +1649,17 @@ var __decorate6 = function(decorators, target, key, desc) {
|
|
|
1635
1649
|
if (d = decorators[i])
|
|
1636
1650
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1637
1651
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1638
|
-
}
|
|
1652
|
+
}
|
|
1653
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1639
1654
|
var Space = class Space2 {
|
|
1640
1655
|
constructor(params) {
|
|
1641
1656
|
this._addFeedLock = new import_async7.Lock();
|
|
1642
|
-
this.onCredentialProcessed = new
|
|
1657
|
+
this.onCredentialProcessed = new import_util6.Callback();
|
|
1643
1658
|
this.stateUpdate = new import_async7.Event();
|
|
1644
1659
|
// Processes epoch credentials.
|
|
1645
1660
|
this._dataPipelineCredentialConsumer = void 0;
|
|
1646
1661
|
this._isOpen = false;
|
|
1647
|
-
(0,
|
|
1662
|
+
(0, import_tiny_invariant9.default)(params.spaceKey && params.feedProvider);
|
|
1648
1663
|
this._key = params.spaceKey;
|
|
1649
1664
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1650
1665
|
this._feedProvider = params.feedProvider;
|
|
@@ -1676,13 +1691,13 @@ var Space = class Space2 {
|
|
|
1676
1691
|
});
|
|
1677
1692
|
this._controlPipeline.onCredentialProcessed.set(async (credential) => {
|
|
1678
1693
|
await this.onCredentialProcessed.callIfSet(credential);
|
|
1679
|
-
(0,
|
|
1694
|
+
(0, import_log10.log)("onCredentialProcessed", {
|
|
1680
1695
|
credential
|
|
1681
1696
|
}, {
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1697
|
+
F: __dxlog_file10,
|
|
1698
|
+
L: 110,
|
|
1699
|
+
S: this,
|
|
1700
|
+
C: (f, a) => f(...a)
|
|
1686
1701
|
});
|
|
1687
1702
|
this.stateUpdate.emit();
|
|
1688
1703
|
});
|
|
@@ -1745,14 +1760,14 @@ var Space = class Space2 {
|
|
|
1745
1760
|
return this._snapshotManager;
|
|
1746
1761
|
}
|
|
1747
1762
|
setControlFeed(feed) {
|
|
1748
|
-
(0,
|
|
1763
|
+
(0, import_tiny_invariant9.default)(!this._controlFeed, "Control feed already set.");
|
|
1749
1764
|
this._controlFeed = feed;
|
|
1750
1765
|
this._controlPipeline.setWriteFeed(feed);
|
|
1751
1766
|
return this;
|
|
1752
1767
|
}
|
|
1753
1768
|
setDataFeed(feed) {
|
|
1754
1769
|
var _a;
|
|
1755
|
-
(0,
|
|
1770
|
+
(0, import_tiny_invariant9.default)(!this._dataFeed, "Data feed already set.");
|
|
1756
1771
|
this._dataFeed = feed;
|
|
1757
1772
|
(_a = this._dataPipeline.pipeline) == null ? void 0 : _a.setWriteFeed(feed);
|
|
1758
1773
|
return this;
|
|
@@ -1770,11 +1785,11 @@ var Space = class Space2 {
|
|
|
1770
1785
|
// return this._dataPipeline?.getFeeds();
|
|
1771
1786
|
// }
|
|
1772
1787
|
async open() {
|
|
1773
|
-
(0,
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1788
|
+
(0, import_log10.log)("opening...", void 0, {
|
|
1789
|
+
F: __dxlog_file10,
|
|
1790
|
+
L: 212,
|
|
1791
|
+
S: this,
|
|
1792
|
+
C: (f, a) => f(...a)
|
|
1778
1793
|
});
|
|
1779
1794
|
if (this._isOpen) {
|
|
1780
1795
|
return;
|
|
@@ -1784,22 +1799,22 @@ var Space = class Space2 {
|
|
|
1784
1799
|
this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
|
|
1785
1800
|
await this._dataPipelineCredentialConsumer.open();
|
|
1786
1801
|
this._isOpen = true;
|
|
1787
|
-
(0,
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1802
|
+
(0, import_log10.log)("opened", void 0, {
|
|
1803
|
+
F: __dxlog_file10,
|
|
1804
|
+
L: 228,
|
|
1805
|
+
S: this,
|
|
1806
|
+
C: (f, a) => f(...a)
|
|
1792
1807
|
});
|
|
1793
1808
|
}
|
|
1794
1809
|
async close() {
|
|
1795
1810
|
var _a;
|
|
1796
|
-
(0,
|
|
1811
|
+
(0, import_log10.log)("closing...", {
|
|
1797
1812
|
key: this._key
|
|
1798
1813
|
}, {
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1814
|
+
F: __dxlog_file10,
|
|
1815
|
+
L: 233,
|
|
1816
|
+
S: this,
|
|
1817
|
+
C: (f, a) => f(...a)
|
|
1803
1818
|
});
|
|
1804
1819
|
if (!this._isOpen) {
|
|
1805
1820
|
return;
|
|
@@ -1810,58 +1825,58 @@ var Space = class Space2 {
|
|
|
1810
1825
|
await this.protocol.stop();
|
|
1811
1826
|
await this._controlPipeline.stop();
|
|
1812
1827
|
this._isOpen = false;
|
|
1813
|
-
(0,
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1828
|
+
(0, import_log10.log)("closed", void 0, {
|
|
1829
|
+
F: __dxlog_file10,
|
|
1830
|
+
L: 247,
|
|
1831
|
+
S: this,
|
|
1832
|
+
C: (f, a) => f(...a)
|
|
1818
1833
|
});
|
|
1819
1834
|
}
|
|
1820
1835
|
async initializeDataPipeline() {
|
|
1821
|
-
(0,
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1836
|
+
(0, import_log10.log)("initializeDataPipeline", void 0, {
|
|
1837
|
+
F: __dxlog_file10,
|
|
1838
|
+
L: 252,
|
|
1839
|
+
S: this,
|
|
1840
|
+
C: (f, a) => f(...a)
|
|
1826
1841
|
});
|
|
1827
|
-
(0,
|
|
1842
|
+
(0, import_tiny_invariant9.default)(this._isOpen, "Space must be open to initialize data pipeline.");
|
|
1828
1843
|
await this._dataPipeline.open();
|
|
1829
1844
|
}
|
|
1830
1845
|
};
|
|
1831
|
-
|
|
1832
|
-
|
|
1846
|
+
_ts_decorate6([
|
|
1847
|
+
import_log10.logInfo
|
|
1833
1848
|
], Space.prototype, "key", null);
|
|
1834
|
-
|
|
1849
|
+
_ts_decorate6([
|
|
1835
1850
|
import_async7.synchronized
|
|
1836
1851
|
], Space.prototype, "open", null);
|
|
1837
|
-
|
|
1852
|
+
_ts_decorate6([
|
|
1838
1853
|
import_async7.synchronized
|
|
1839
1854
|
], Space.prototype, "close", null);
|
|
1840
|
-
|
|
1855
|
+
_ts_decorate6([
|
|
1841
1856
|
import_async7.synchronized
|
|
1842
1857
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1843
|
-
Space =
|
|
1858
|
+
Space = _ts_decorate6([
|
|
1844
1859
|
(0, import_async7.trackLeaks)("open", "close")
|
|
1845
1860
|
], Space);
|
|
1846
1861
|
|
|
1847
1862
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
1848
1863
|
var import_async8 = require("@dxos/async");
|
|
1849
|
-
var
|
|
1864
|
+
var import_debug5 = require("@dxos/debug");
|
|
1850
1865
|
var import_keys6 = require("@dxos/keys");
|
|
1851
|
-
var
|
|
1866
|
+
var import_log12 = require("@dxos/log");
|
|
1852
1867
|
var import_protocols6 = require("@dxos/protocols");
|
|
1853
|
-
var
|
|
1868
|
+
var import_util8 = require("@dxos/util");
|
|
1854
1869
|
|
|
1855
1870
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
1856
1871
|
var import_crypto3 = require("@dxos/crypto");
|
|
1857
1872
|
var import_keys5 = require("@dxos/keys");
|
|
1858
|
-
var
|
|
1873
|
+
var import_log11 = require("@dxos/log");
|
|
1859
1874
|
var import_network_manager = require("@dxos/network-manager");
|
|
1860
1875
|
var import_teleport2 = require("@dxos/teleport");
|
|
1861
1876
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
1862
1877
|
var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
|
|
1863
|
-
var
|
|
1864
|
-
|
|
1878
|
+
var import_util7 = require("@dxos/util");
|
|
1879
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1865
1880
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1866
1881
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1867
1882
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1870,13 +1885,14 @@ var __decorate7 = function(decorators, target, key, desc) {
|
|
|
1870
1885
|
if (d = decorators[i])
|
|
1871
1886
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1872
1887
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1873
|
-
}
|
|
1888
|
+
}
|
|
1889
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1874
1890
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1875
1891
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1876
1892
|
var SpaceProtocol = class {
|
|
1877
1893
|
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore }) {
|
|
1878
1894
|
this._feeds = /* @__PURE__ */ new Set();
|
|
1879
|
-
this._sessions = new
|
|
1895
|
+
this._sessions = new import_util7.ComplexMap(import_keys5.PublicKey.hash);
|
|
1880
1896
|
this._networkManager = networkManager;
|
|
1881
1897
|
this._swarmIdentity = swarmIdentity;
|
|
1882
1898
|
this._onSessionAuth = onSessionAuth;
|
|
@@ -1884,7 +1900,7 @@ var SpaceProtocol = class {
|
|
|
1884
1900
|
this.blobSync = new import_teleport_extension_object_sync.BlobSync({
|
|
1885
1901
|
blobStore
|
|
1886
1902
|
});
|
|
1887
|
-
this._topic =
|
|
1903
|
+
this._topic = import_crypto3.subtleCrypto.digest("SHA-256", topic.asBuffer()).then(import_crypto3.discoveryKey).then(import_keys5.PublicKey.from);
|
|
1888
1904
|
}
|
|
1889
1905
|
get sessions() {
|
|
1890
1906
|
return this._sessions;
|
|
@@ -1897,13 +1913,13 @@ var SpaceProtocol = class {
|
|
|
1897
1913
|
}
|
|
1898
1914
|
// TODO(burdon): Create abstraction for Space (e.g., add keys and have provider).
|
|
1899
1915
|
addFeed(feed) {
|
|
1900
|
-
(0,
|
|
1916
|
+
(0, import_log11.log)("addFeed", {
|
|
1901
1917
|
key: feed.key
|
|
1902
1918
|
}, {
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1919
|
+
F: __dxlog_file11,
|
|
1920
|
+
L: 96,
|
|
1921
|
+
S: this,
|
|
1922
|
+
C: (f, a) => f(...a)
|
|
1907
1923
|
});
|
|
1908
1924
|
this._feeds.add(feed);
|
|
1909
1925
|
for (const session of this._sessions.values()) {
|
|
@@ -1921,41 +1937,41 @@ var SpaceProtocol = class {
|
|
|
1921
1937
|
sampleSize: 20
|
|
1922
1938
|
};
|
|
1923
1939
|
await this.blobSync.open();
|
|
1924
|
-
(0,
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1940
|
+
(0, import_log11.log)("starting...", void 0, {
|
|
1941
|
+
F: __dxlog_file11,
|
|
1942
|
+
L: 121,
|
|
1943
|
+
S: this,
|
|
1944
|
+
C: (f, a) => f(...a)
|
|
1929
1945
|
});
|
|
1930
1946
|
this._connection = await this._networkManager.joinSwarm({
|
|
1931
1947
|
protocolProvider: this._createProtocolProvider(credentials),
|
|
1932
1948
|
peerId: this._swarmIdentity.peerKey,
|
|
1933
|
-
topic: this._topic,
|
|
1949
|
+
topic: await this._topic,
|
|
1934
1950
|
topology: new import_network_manager.MMSTTopology(topologyConfig),
|
|
1935
1951
|
label: `Protocol swarm: ${this._topic}`
|
|
1936
1952
|
});
|
|
1937
|
-
(0,
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1953
|
+
(0, import_log11.log)("started", void 0, {
|
|
1954
|
+
F: __dxlog_file11,
|
|
1955
|
+
L: 130,
|
|
1956
|
+
S: this,
|
|
1957
|
+
C: (f, a) => f(...a)
|
|
1942
1958
|
});
|
|
1943
1959
|
}
|
|
1944
1960
|
async stop() {
|
|
1945
1961
|
await this.blobSync.close();
|
|
1946
1962
|
if (this._connection) {
|
|
1947
|
-
(0,
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1963
|
+
(0, import_log11.log)("stopping...", void 0, {
|
|
1964
|
+
F: __dxlog_file11,
|
|
1965
|
+
L: 137,
|
|
1966
|
+
S: this,
|
|
1967
|
+
C: (f, a) => f(...a)
|
|
1952
1968
|
});
|
|
1953
1969
|
await this._connection.close();
|
|
1954
|
-
(0,
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1970
|
+
(0, import_log11.log)("stopped", void 0, {
|
|
1971
|
+
F: __dxlog_file11,
|
|
1972
|
+
L: 139,
|
|
1973
|
+
S: this,
|
|
1974
|
+
C: (f, a) => f(...a)
|
|
1959
1975
|
});
|
|
1960
1976
|
}
|
|
1961
1977
|
}
|
|
@@ -1976,11 +1992,11 @@ var SpaceProtocol = class {
|
|
|
1976
1992
|
};
|
|
1977
1993
|
}
|
|
1978
1994
|
};
|
|
1979
|
-
|
|
1980
|
-
|
|
1995
|
+
_ts_decorate7([
|
|
1996
|
+
import_log11.logInfo
|
|
1981
1997
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
1982
|
-
|
|
1983
|
-
|
|
1998
|
+
_ts_decorate7([
|
|
1999
|
+
import_log11.logInfo
|
|
1984
2000
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
1985
2001
|
var AuthStatus;
|
|
1986
2002
|
(function(AuthStatus2) {
|
|
@@ -2006,6 +2022,9 @@ var SpaceProtocolSession = class {
|
|
|
2006
2022
|
get authStatus() {
|
|
2007
2023
|
return this._authStatus;
|
|
2008
2024
|
}
|
|
2025
|
+
get stats() {
|
|
2026
|
+
return this._teleport.stats;
|
|
2027
|
+
}
|
|
2009
2028
|
get stream() {
|
|
2010
2029
|
return this._teleport.stream;
|
|
2011
2030
|
}
|
|
@@ -2016,11 +2035,11 @@ var SpaceProtocolSession = class {
|
|
|
2016
2035
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
2017
2036
|
onAuthSuccess: () => {
|
|
2018
2037
|
var _a;
|
|
2019
|
-
(0,
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2038
|
+
(0, import_log11.log)("Peer authenticated", void 0, {
|
|
2039
|
+
F: __dxlog_file11,
|
|
2040
|
+
L: 236,
|
|
2041
|
+
S: this,
|
|
2042
|
+
C: (f, a) => f(...a)
|
|
2024
2043
|
});
|
|
2025
2044
|
this._authStatus = AuthStatus.SUCCESS;
|
|
2026
2045
|
(_a = this._onSessionAuth) == null ? void 0 : _a.call(this, this._teleport);
|
|
@@ -2038,15 +2057,15 @@ var SpaceProtocolSession = class {
|
|
|
2038
2057
|
await this._teleport.close();
|
|
2039
2058
|
}
|
|
2040
2059
|
};
|
|
2041
|
-
|
|
2042
|
-
|
|
2060
|
+
_ts_decorate7([
|
|
2061
|
+
import_log11.logInfo
|
|
2043
2062
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
2044
|
-
|
|
2045
|
-
|
|
2063
|
+
_ts_decorate7([
|
|
2064
|
+
import_log11.logInfo
|
|
2046
2065
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
2047
2066
|
|
|
2048
2067
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
2049
|
-
|
|
2068
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2050
2069
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2051
2070
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2052
2071
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2055,10 +2074,11 @@ var __decorate8 = function(decorators, target, key, desc) {
|
|
|
2055
2074
|
if (d = decorators[i])
|
|
2056
2075
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2057
2076
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2058
|
-
}
|
|
2077
|
+
}
|
|
2078
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2059
2079
|
var SpaceManager = class SpaceManager2 {
|
|
2060
2080
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
2061
|
-
this._spaces = new
|
|
2081
|
+
this._spaces = new import_util8.ComplexMap(import_keys6.PublicKey.hash);
|
|
2062
2082
|
this._instanceId = import_keys6.PublicKey.random().toHex();
|
|
2063
2083
|
this._feedStore = feedStore;
|
|
2064
2084
|
this._networkManager = networkManager;
|
|
@@ -2080,23 +2100,23 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2080
2100
|
}
|
|
2081
2101
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2082
2102
|
var _a;
|
|
2083
|
-
|
|
2103
|
+
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.begin({
|
|
2084
2104
|
id: this._instanceId
|
|
2085
2105
|
}), {
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2106
|
+
F: __dxlog_file12,
|
|
2107
|
+
L: 97,
|
|
2108
|
+
S: this,
|
|
2109
|
+
C: (f, a) => f(...a)
|
|
2090
2110
|
});
|
|
2091
|
-
(0,
|
|
2111
|
+
(0, import_log12.log)("constructing space...", {
|
|
2092
2112
|
spaceKey: metadata.genesisFeedKey
|
|
2093
2113
|
}, {
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2114
|
+
F: __dxlog_file12,
|
|
2115
|
+
L: 98,
|
|
2116
|
+
S: this,
|
|
2117
|
+
C: (f, a) => f(...a)
|
|
2098
2118
|
});
|
|
2099
|
-
const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : (0,
|
|
2119
|
+
const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : (0, import_debug5.failUndefined)());
|
|
2100
2120
|
const spaceKey = metadata.key;
|
|
2101
2121
|
const protocol = new SpaceProtocol({
|
|
2102
2122
|
topic: spaceKey,
|
|
@@ -2118,24 +2138,24 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2118
2138
|
memberKey
|
|
2119
2139
|
});
|
|
2120
2140
|
this._spaces.set(space.key, space);
|
|
2121
|
-
|
|
2141
|
+
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.end({
|
|
2122
2142
|
id: this._instanceId
|
|
2123
2143
|
}), {
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2144
|
+
F: __dxlog_file12,
|
|
2145
|
+
L: 125,
|
|
2146
|
+
S: this,
|
|
2147
|
+
C: (f, a) => f(...a)
|
|
2128
2148
|
});
|
|
2129
2149
|
return space;
|
|
2130
2150
|
}
|
|
2131
2151
|
};
|
|
2132
|
-
|
|
2152
|
+
_ts_decorate8([
|
|
2133
2153
|
import_async8.synchronized
|
|
2134
2154
|
], SpaceManager.prototype, "open", null);
|
|
2135
|
-
|
|
2155
|
+
_ts_decorate8([
|
|
2136
2156
|
import_async8.synchronized
|
|
2137
2157
|
], SpaceManager.prototype, "close", null);
|
|
2138
|
-
SpaceManager =
|
|
2158
|
+
SpaceManager = _ts_decorate8([
|
|
2139
2159
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2140
2160
|
], SpaceManager);
|
|
2141
2161
|
// Annotate the CommonJS export names for ESM import in node:
|