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