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