@dxos/echo-pipeline 0.1.56-main.e47dfd1 → 0.1.56-main.ed2f871
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-7U2NXI2P.mjs → chunk-3OTHGQEY.mjs} +531 -251
- package/dist/lib/browser/chunk-3OTHGQEY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +14 -18
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +530 -250
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +527 -251
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/common/feeds.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/snapshot-manager.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/space/auth.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +2 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/common/feeds.ts +1 -2
- package/src/db-host/data-service-host.ts +1 -2
- package/src/db-host/data-service.ts +1 -2
- package/src/db-host/snapshot-manager.ts +0 -2
- package/src/metadata/metadata-store.ts +2 -2
- package/src/pipeline/message-selector.ts +1 -2
- package/src/pipeline/pipeline.test.ts +37 -1
- package/src/pipeline/pipeline.ts +3 -2
- package/src/space/auth.ts +1 -2
- package/src/space/data-pipeline.ts +1 -2
- package/src/space/space.test.ts +18 -17
- package/src/space/space.ts +6 -3
- package/src/testing/test-agent-builder.ts +2 -1
- package/dist/lib/browser/chunk-7U2NXI2P.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -71,23 +71,40 @@ var codec = import_protocols.schema.getCodecForType("dxos.echo.feed.FeedMessage"
|
|
|
71
71
|
var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
|
|
72
72
|
|
|
73
73
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
74
|
-
var
|
|
74
|
+
var import_invariant = require("@dxos/invariant");
|
|
75
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
|
|
75
76
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
76
|
-
(0,
|
|
77
|
-
|
|
77
|
+
(0, import_invariant.invariant)(mapper, void 0, {
|
|
78
|
+
F: __dxlog_file,
|
|
79
|
+
L: 16,
|
|
80
|
+
S: void 0,
|
|
81
|
+
A: [
|
|
82
|
+
"mapper",
|
|
83
|
+
""
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
(0, import_invariant.invariant)(writer, void 0, {
|
|
87
|
+
F: __dxlog_file,
|
|
88
|
+
L: 17,
|
|
89
|
+
S: void 0,
|
|
90
|
+
A: [
|
|
91
|
+
"writer",
|
|
92
|
+
""
|
|
93
|
+
]
|
|
94
|
+
});
|
|
78
95
|
return {
|
|
79
96
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
80
97
|
};
|
|
81
98
|
};
|
|
82
99
|
|
|
83
100
|
// packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts
|
|
84
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
85
101
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
86
102
|
var import_context = require("@dxos/context");
|
|
87
103
|
var import_echo_db = require("@dxos/echo-db");
|
|
104
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
88
105
|
var import_log = require("@dxos/log");
|
|
89
106
|
var import_util = require("@dxos/util");
|
|
90
|
-
var
|
|
107
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
|
|
91
108
|
var DataServiceHost = class {
|
|
92
109
|
constructor(_itemManager, _itemDemuxer, _writeStream) {
|
|
93
110
|
this._itemManager = _itemManager;
|
|
@@ -114,15 +131,22 @@ var DataServiceHost = class {
|
|
|
114
131
|
}
|
|
115
132
|
});
|
|
116
133
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
117
|
-
var _a;
|
|
118
134
|
const { batch, meta } = message;
|
|
119
|
-
(0,
|
|
135
|
+
(0, import_invariant2.invariant)(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
136
|
+
F: __dxlog_file2,
|
|
137
|
+
L: 61,
|
|
138
|
+
S: this,
|
|
139
|
+
A: [
|
|
140
|
+
"!(meta as any).clientTag",
|
|
141
|
+
"'Unexpected client tag in mutation message'"
|
|
142
|
+
]
|
|
143
|
+
});
|
|
120
144
|
(0, import_log.log)("message", {
|
|
121
145
|
batch,
|
|
122
146
|
meta
|
|
123
147
|
}, {
|
|
124
|
-
F:
|
|
125
|
-
L:
|
|
148
|
+
F: __dxlog_file2,
|
|
149
|
+
L: 62,
|
|
126
150
|
S: this,
|
|
127
151
|
C: (f, a) => f(...a)
|
|
128
152
|
});
|
|
@@ -130,7 +154,7 @@ var DataServiceHost = class {
|
|
|
130
154
|
message.meta.feedKey,
|
|
131
155
|
message.meta.seq
|
|
132
156
|
]);
|
|
133
|
-
|
|
157
|
+
batch.objects?.forEach((object) => {
|
|
134
158
|
(0, import_echo_db.setMetadataOnObject)(object, {
|
|
135
159
|
...meta
|
|
136
160
|
});
|
|
@@ -148,15 +172,30 @@ var DataServiceHost = class {
|
|
|
148
172
|
});
|
|
149
173
|
}
|
|
150
174
|
async write(request) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
175
|
+
(0, import_invariant2.invariant)(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
176
|
+
F: __dxlog_file2,
|
|
177
|
+
L: 88,
|
|
178
|
+
S: this,
|
|
179
|
+
A: [
|
|
180
|
+
"!this._ctx.disposed",
|
|
181
|
+
"'Cannot write to closed DataServiceHost'"
|
|
182
|
+
]
|
|
183
|
+
});
|
|
184
|
+
(0, import_invariant2.invariant)(this._writeStream, "Cannot write mutations in readonly mode", {
|
|
185
|
+
F: __dxlog_file2,
|
|
186
|
+
L: 89,
|
|
187
|
+
S: this,
|
|
188
|
+
A: [
|
|
189
|
+
"this._writeStream",
|
|
190
|
+
"'Cannot write mutations in readonly mode'"
|
|
191
|
+
]
|
|
192
|
+
});
|
|
154
193
|
(0, import_log.log)("write", {
|
|
155
194
|
clientTag: request.clientTag,
|
|
156
|
-
objectCount:
|
|
195
|
+
objectCount: request.batch.objects?.length ?? 0
|
|
157
196
|
}, {
|
|
158
|
-
F:
|
|
159
|
-
L:
|
|
197
|
+
F: __dxlog_file2,
|
|
198
|
+
L: 91,
|
|
160
199
|
S: this,
|
|
161
200
|
C: (f, a) => f(...a)
|
|
162
201
|
});
|
|
@@ -169,8 +208,8 @@ var DataServiceHost = class {
|
|
|
169
208
|
feedKey: receipt2.feedKey,
|
|
170
209
|
seq: receipt2.seq
|
|
171
210
|
}, {
|
|
172
|
-
F:
|
|
173
|
-
L:
|
|
211
|
+
F: __dxlog_file2,
|
|
212
|
+
L: 100,
|
|
174
213
|
S: this,
|
|
175
214
|
C: (f, a) => f(...a)
|
|
176
215
|
});
|
|
@@ -184,24 +223,18 @@ var DataServiceHost = class {
|
|
|
184
223
|
return receipt;
|
|
185
224
|
}
|
|
186
225
|
};
|
|
187
|
-
var createDataMessage = (batch) => {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
meta: void 0
|
|
200
|
-
};
|
|
201
|
-
})
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
};
|
|
226
|
+
var createDataMessage = (batch) => ({
|
|
227
|
+
batch: {
|
|
228
|
+
objects: batch.objects?.map((object) => ({
|
|
229
|
+
...object,
|
|
230
|
+
mutations: object.mutations?.map((mutation) => ({
|
|
231
|
+
...mutation,
|
|
232
|
+
meta: void 0
|
|
233
|
+
})),
|
|
234
|
+
meta: void 0
|
|
235
|
+
}))
|
|
236
|
+
}
|
|
237
|
+
});
|
|
205
238
|
|
|
206
239
|
// packages/core/echo/echo-pipeline/src/db-host/database-host.ts
|
|
207
240
|
var import_echo_db2 = require("@dxos/echo-db");
|
|
@@ -230,15 +263,13 @@ var DatabaseHost = class {
|
|
|
230
263
|
return this._itemDemuxer.createSnapshot();
|
|
231
264
|
}
|
|
232
265
|
createDataServiceHost() {
|
|
233
|
-
|
|
234
|
-
return new DataServiceHost(this._itemManager, this._itemDemuxer, (_a = this._outboundStream) != null ? _a : void 0);
|
|
266
|
+
return new DataServiceHost(this._itemManager, this._itemDemuxer, this._outboundStream ?? void 0);
|
|
235
267
|
}
|
|
236
268
|
};
|
|
237
269
|
|
|
238
270
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
|
|
239
271
|
var import_async = require("@dxos/async");
|
|
240
272
|
var import_context2 = require("@dxos/context");
|
|
241
|
-
var import_debug = require("@dxos/debug");
|
|
242
273
|
var import_keys = require("@dxos/keys");
|
|
243
274
|
var import_protocols2 = require("@dxos/protocols");
|
|
244
275
|
var import_blob = require("@dxos/protocols/proto/dxos/echo/blob");
|
|
@@ -283,9 +314,6 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
283
314
|
return import_keys.PublicKey.from(id).toHex();
|
|
284
315
|
}
|
|
285
316
|
};
|
|
286
|
-
_ts_decorate([
|
|
287
|
-
(0, import_debug.timed)(1e4)
|
|
288
|
-
], SnapshotManager.prototype, "load", null);
|
|
289
317
|
SnapshotManager = _ts_decorate([
|
|
290
318
|
(0, import_async.trackLeaks)("open", "close")
|
|
291
319
|
], SnapshotManager);
|
|
@@ -337,12 +365,12 @@ var SnapshotStore = class {
|
|
|
337
365
|
};
|
|
338
366
|
|
|
339
367
|
// packages/core/echo/echo-pipeline/src/db-host/data-service.ts
|
|
340
|
-
var
|
|
341
|
-
var
|
|
368
|
+
var import_debug = require("@dxos/debug");
|
|
369
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
342
370
|
var import_keys2 = require("@dxos/keys");
|
|
343
371
|
var import_log2 = require("@dxos/log");
|
|
344
372
|
var import_util2 = require("@dxos/util");
|
|
345
|
-
var
|
|
373
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
|
|
346
374
|
var DataServiceSubscriptions = class {
|
|
347
375
|
constructor() {
|
|
348
376
|
this._spaces = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
|
|
@@ -354,12 +382,20 @@ var DataServiceSubscriptions = class {
|
|
|
354
382
|
(0, import_log2.log)("Registering space", {
|
|
355
383
|
spaceKey
|
|
356
384
|
}, {
|
|
357
|
-
F:
|
|
358
|
-
L:
|
|
385
|
+
F: __dxlog_file3,
|
|
386
|
+
L: 30,
|
|
359
387
|
S: this,
|
|
360
388
|
C: (f, a) => f(...a)
|
|
361
389
|
});
|
|
362
|
-
(0,
|
|
390
|
+
(0, import_invariant3.invariant)(!this._spaces.has(spaceKey), void 0, {
|
|
391
|
+
F: __dxlog_file3,
|
|
392
|
+
L: 31,
|
|
393
|
+
S: this,
|
|
394
|
+
A: [
|
|
395
|
+
"!this._spaces.has(spaceKey)",
|
|
396
|
+
""
|
|
397
|
+
]
|
|
398
|
+
});
|
|
363
399
|
await host.open();
|
|
364
400
|
this._spaces.set(spaceKey, host);
|
|
365
401
|
}
|
|
@@ -367,13 +403,13 @@ var DataServiceSubscriptions = class {
|
|
|
367
403
|
(0, import_log2.log)("Unregistering space", {
|
|
368
404
|
spaceKey
|
|
369
405
|
}, {
|
|
370
|
-
F:
|
|
371
|
-
L:
|
|
406
|
+
F: __dxlog_file3,
|
|
407
|
+
L: 37,
|
|
372
408
|
S: this,
|
|
373
409
|
C: (f, a) => f(...a)
|
|
374
410
|
});
|
|
375
411
|
const host = this._spaces.get(spaceKey);
|
|
376
|
-
await
|
|
412
|
+
await host?.close();
|
|
377
413
|
this._spaces.delete(spaceKey);
|
|
378
414
|
}
|
|
379
415
|
getDataService(spaceKey) {
|
|
@@ -385,16 +421,38 @@ var DataServiceImpl = class {
|
|
|
385
421
|
this._subscriptions = _subscriptions;
|
|
386
422
|
}
|
|
387
423
|
subscribe(request) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
424
|
+
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
425
|
+
F: __dxlog_file3,
|
|
426
|
+
L: 56,
|
|
427
|
+
S: this,
|
|
428
|
+
A: [
|
|
429
|
+
"request.spaceKey",
|
|
430
|
+
""
|
|
431
|
+
]
|
|
432
|
+
});
|
|
433
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? (0, import_debug.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
391
434
|
return host.subscribe();
|
|
392
435
|
}
|
|
393
436
|
write(request) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
437
|
+
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
438
|
+
F: __dxlog_file3,
|
|
439
|
+
L: 63,
|
|
440
|
+
S: this,
|
|
441
|
+
A: [
|
|
442
|
+
"request.spaceKey",
|
|
443
|
+
""
|
|
444
|
+
]
|
|
445
|
+
});
|
|
446
|
+
(0, import_invariant3.invariant)(request.batch, void 0, {
|
|
447
|
+
F: __dxlog_file3,
|
|
448
|
+
L: 64,
|
|
449
|
+
S: this,
|
|
450
|
+
A: [
|
|
451
|
+
"request.batch",
|
|
452
|
+
""
|
|
453
|
+
]
|
|
454
|
+
});
|
|
455
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? (0, import_debug.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
398
456
|
return host.write(request);
|
|
399
457
|
}
|
|
400
458
|
};
|
|
@@ -450,9 +508,9 @@ var UnknownModelError = class extends DBError {
|
|
|
450
508
|
|
|
451
509
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
452
510
|
var import_crc_32 = __toESM(require("crc-32"));
|
|
453
|
-
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
454
511
|
var import_async2 = require("@dxos/async");
|
|
455
512
|
var import_errors = require("@dxos/errors");
|
|
513
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
456
514
|
var import_log3 = require("@dxos/log");
|
|
457
515
|
var import_protocols4 = require("@dxos/protocols");
|
|
458
516
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -467,12 +525,12 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
467
525
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
468
526
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
469
527
|
}
|
|
470
|
-
var
|
|
528
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
471
529
|
var emptyEchoMetadata = () => ({
|
|
472
530
|
version: import_protocols4.STORAGE_VERSION,
|
|
473
531
|
spaces: [],
|
|
474
|
-
created: new Date(),
|
|
475
|
-
updated: new Date()
|
|
532
|
+
created: /* @__PURE__ */ new Date(),
|
|
533
|
+
updated: /* @__PURE__ */ new Date()
|
|
476
534
|
});
|
|
477
535
|
var EchoMetadata = import_protocols4.schema.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
478
536
|
var MetadataStore = class {
|
|
@@ -486,22 +544,19 @@ var MetadataStore = class {
|
|
|
486
544
|
return this._metadata;
|
|
487
545
|
}
|
|
488
546
|
get version() {
|
|
489
|
-
|
|
490
|
-
return (_a = this._metadata.version) != null ? _a : 0;
|
|
547
|
+
return this._metadata.version ?? 0;
|
|
491
548
|
}
|
|
492
549
|
/**
|
|
493
550
|
* Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and
|
|
494
551
|
* addSpaceFeed functions.
|
|
495
552
|
*/
|
|
496
553
|
get spaces() {
|
|
497
|
-
|
|
498
|
-
return (_a = this._metadata.spaces) != null ? _a : [];
|
|
554
|
+
return this._metadata.spaces ?? [];
|
|
499
555
|
}
|
|
500
556
|
/**
|
|
501
557
|
* Loads metadata from persistent storage.
|
|
502
558
|
*/
|
|
503
559
|
async load() {
|
|
504
|
-
var _a;
|
|
505
560
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
506
561
|
try {
|
|
507
562
|
const { size: fileLength } = await file.stat();
|
|
@@ -514,13 +569,16 @@ var MetadataStore = class {
|
|
|
514
569
|
size: dataSize,
|
|
515
570
|
checksum
|
|
516
571
|
}, {
|
|
517
|
-
F:
|
|
572
|
+
F: __dxlog_file4,
|
|
518
573
|
L: 72,
|
|
519
574
|
S: this,
|
|
520
575
|
C: (f, a) => f(...a)
|
|
521
576
|
});
|
|
522
577
|
if (fileLength < dataSize + 8) {
|
|
523
|
-
throw new import_errors.DataCorruptionError("Metadata size is smaller than expected."
|
|
578
|
+
throw new import_errors.DataCorruptionError("Metadata size is smaller than expected.", {
|
|
579
|
+
fileLength,
|
|
580
|
+
dataSize
|
|
581
|
+
});
|
|
524
582
|
}
|
|
525
583
|
const data = await file.read(8, dataSize);
|
|
526
584
|
const calculatedChecksum = import_crc_32.default.buf(data);
|
|
@@ -528,15 +586,14 @@ var MetadataStore = class {
|
|
|
528
586
|
throw new import_errors.DataCorruptionError("Metadata checksum is invalid.");
|
|
529
587
|
}
|
|
530
588
|
this._metadata = EchoMetadata.decode(data);
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
(_a2 = space.state) != null ? _a2 : space.state = import_services.SpaceState.ACTIVE;
|
|
589
|
+
this._metadata.spaces?.forEach((space) => {
|
|
590
|
+
space.state ??= import_services.SpaceState.ACTIVE;
|
|
534
591
|
});
|
|
535
592
|
} catch (err) {
|
|
536
593
|
import_log3.log.error("failed to load metadata", {
|
|
537
594
|
err
|
|
538
595
|
}, {
|
|
539
|
-
F:
|
|
596
|
+
F: __dxlog_file4,
|
|
540
597
|
L: 92,
|
|
541
598
|
S: this,
|
|
542
599
|
C: (f, a) => f(...a)
|
|
@@ -547,12 +604,11 @@ var MetadataStore = class {
|
|
|
547
604
|
}
|
|
548
605
|
}
|
|
549
606
|
async _save() {
|
|
550
|
-
var _a;
|
|
551
607
|
const data = {
|
|
552
608
|
...this._metadata,
|
|
553
609
|
version: import_protocols4.STORAGE_VERSION,
|
|
554
|
-
created:
|
|
555
|
-
updated: new Date()
|
|
610
|
+
created: this._metadata.created ?? /* @__PURE__ */ new Date(),
|
|
611
|
+
updated: /* @__PURE__ */ new Date()
|
|
556
612
|
};
|
|
557
613
|
this.update.emit(data);
|
|
558
614
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
@@ -568,7 +624,7 @@ var MetadataStore = class {
|
|
|
568
624
|
size: encoded.length,
|
|
569
625
|
checksum
|
|
570
626
|
}, {
|
|
571
|
-
F:
|
|
627
|
+
F: __dxlog_file4,
|
|
572
628
|
L: 124,
|
|
573
629
|
S: this,
|
|
574
630
|
C: (f, a) => f(...a)
|
|
@@ -578,12 +634,19 @@ var MetadataStore = class {
|
|
|
578
634
|
}
|
|
579
635
|
}
|
|
580
636
|
_getSpace(spaceKey) {
|
|
581
|
-
|
|
582
|
-
if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
|
|
637
|
+
if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
|
|
583
638
|
return this._metadata.identity.haloSpace;
|
|
584
639
|
}
|
|
585
640
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
586
|
-
(0,
|
|
641
|
+
(0, import_invariant4.invariant)(space, "Space not found", {
|
|
642
|
+
F: __dxlog_file4,
|
|
643
|
+
L: 137,
|
|
644
|
+
S: this,
|
|
645
|
+
A: [
|
|
646
|
+
"space",
|
|
647
|
+
"'Space not found'"
|
|
648
|
+
]
|
|
649
|
+
});
|
|
587
650
|
return space;
|
|
588
651
|
}
|
|
589
652
|
/**
|
|
@@ -591,7 +654,7 @@ var MetadataStore = class {
|
|
|
591
654
|
*/
|
|
592
655
|
async clear() {
|
|
593
656
|
(0, import_log3.log)("clearing all metadata", void 0, {
|
|
594
|
-
F:
|
|
657
|
+
F: __dxlog_file4,
|
|
595
658
|
L: 145,
|
|
596
659
|
S: this,
|
|
597
660
|
C: (f, a) => f(...a)
|
|
@@ -603,14 +666,29 @@ var MetadataStore = class {
|
|
|
603
666
|
return this._metadata.identity;
|
|
604
667
|
}
|
|
605
668
|
async setIdentityRecord(record) {
|
|
606
|
-
(0,
|
|
669
|
+
(0, import_invariant4.invariant)(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
|
|
670
|
+
F: __dxlog_file4,
|
|
671
|
+
L: 155,
|
|
672
|
+
S: this,
|
|
673
|
+
A: [
|
|
674
|
+
"!this._metadata.identity",
|
|
675
|
+
"'Cannot overwrite existing identity in metadata'"
|
|
676
|
+
]
|
|
677
|
+
});
|
|
607
678
|
this._metadata.identity = record;
|
|
608
679
|
await this._save();
|
|
609
680
|
}
|
|
610
681
|
async addSpace(record) {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
682
|
+
(0, import_invariant4.invariant)(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
683
|
+
F: __dxlog_file4,
|
|
684
|
+
L: 162,
|
|
685
|
+
S: this,
|
|
686
|
+
A: [
|
|
687
|
+
"!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
|
|
688
|
+
"'Cannot overwrite existing space in metadata'"
|
|
689
|
+
]
|
|
690
|
+
});
|
|
691
|
+
(this._metadata.spaces ??= []).push(record);
|
|
614
692
|
await this._save();
|
|
615
693
|
}
|
|
616
694
|
async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
|
|
@@ -645,32 +723,40 @@ _ts_decorate2([
|
|
|
645
723
|
var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
646
724
|
|
|
647
725
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
648
|
-
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
649
726
|
var import_async4 = require("@dxos/async");
|
|
650
727
|
var import_context3 = require("@dxos/context");
|
|
651
|
-
var
|
|
728
|
+
var import_debug3 = require("@dxos/debug");
|
|
652
729
|
var import_feed_store = require("@dxos/feed-store");
|
|
730
|
+
var import_invariant6 = require("@dxos/invariant");
|
|
653
731
|
var import_keys3 = require("@dxos/keys");
|
|
654
732
|
var import_log6 = require("@dxos/log");
|
|
655
733
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
656
734
|
var import_util4 = require("@dxos/util");
|
|
657
735
|
|
|
658
736
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
659
|
-
var
|
|
737
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
660
738
|
var import_log4 = require("@dxos/log");
|
|
661
|
-
var
|
|
739
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
|
|
662
740
|
var createMessageSelector = (timeframeClock) => {
|
|
663
741
|
return (messages) => {
|
|
664
742
|
for (let i = 0; i < messages.length; i++) {
|
|
665
743
|
const { data: { timeframe } } = messages[i];
|
|
666
|
-
(0,
|
|
744
|
+
(0, import_invariant5.invariant)(timeframe, void 0, {
|
|
745
|
+
F: __dxlog_file5,
|
|
746
|
+
L: 25,
|
|
747
|
+
S: void 0,
|
|
748
|
+
A: [
|
|
749
|
+
"timeframe",
|
|
750
|
+
""
|
|
751
|
+
]
|
|
752
|
+
});
|
|
667
753
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
668
754
|
return i;
|
|
669
755
|
}
|
|
670
756
|
}
|
|
671
757
|
(0, import_log4.log)("Skipping...", void 0, {
|
|
672
|
-
F:
|
|
673
|
-
L:
|
|
758
|
+
F: __dxlog_file5,
|
|
759
|
+
L: 33,
|
|
674
760
|
S: void 0,
|
|
675
761
|
C: (f, a) => f(...a)
|
|
676
762
|
});
|
|
@@ -679,7 +765,7 @@ var createMessageSelector = (timeframeClock) => {
|
|
|
679
765
|
|
|
680
766
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
681
767
|
var import_async3 = require("@dxos/async");
|
|
682
|
-
var
|
|
768
|
+
var import_debug2 = require("@dxos/debug");
|
|
683
769
|
var import_log5 = require("@dxos/log");
|
|
684
770
|
var import_timeframe = require("@dxos/timeframe");
|
|
685
771
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -692,7 +778,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
692
778
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
693
779
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
694
780
|
}
|
|
695
|
-
var
|
|
781
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
696
782
|
var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
697
783
|
feedKey,
|
|
698
784
|
index
|
|
@@ -751,7 +837,7 @@ var TimeframeClock = class {
|
|
|
751
837
|
target,
|
|
752
838
|
current: this._timeframe
|
|
753
839
|
}, {
|
|
754
|
-
F:
|
|
840
|
+
F: __dxlog_file6,
|
|
755
841
|
L: 73,
|
|
756
842
|
S: this,
|
|
757
843
|
C: (f, a) => f(...a)
|
|
@@ -762,7 +848,7 @@ var TimeframeClock = class {
|
|
|
762
848
|
current: this._timeframe,
|
|
763
849
|
deps: import_timeframe.Timeframe.dependencies(target, this._timeframe)
|
|
764
850
|
}, {
|
|
765
|
-
F:
|
|
851
|
+
F: __dxlog_file6,
|
|
766
852
|
L: 75,
|
|
767
853
|
S: this,
|
|
768
854
|
C: (f, a) => f(...a)
|
|
@@ -772,7 +858,7 @@ var TimeframeClock = class {
|
|
|
772
858
|
}
|
|
773
859
|
};
|
|
774
860
|
_ts_decorate3([
|
|
775
|
-
(0,
|
|
861
|
+
(0, import_debug2.timed)(5e3)
|
|
776
862
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
777
863
|
|
|
778
864
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
@@ -786,7 +872,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
786
872
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
787
873
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
788
874
|
}
|
|
789
|
-
var
|
|
875
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
790
876
|
var PipelineState = class {
|
|
791
877
|
// prettier-ignore
|
|
792
878
|
constructor(_feeds, _timeframeClock) {
|
|
@@ -837,18 +923,17 @@ var PipelineState = class {
|
|
|
837
923
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
838
924
|
*/
|
|
839
925
|
async waitUntilReachedTargetTimeframe({ ctx = new import_context3.Context(), timeout, breakOnStall = true } = {}) {
|
|
840
|
-
var _a;
|
|
841
926
|
(0, import_log6.log)("waitUntilReachedTargetTimeframe", {
|
|
842
927
|
timeout,
|
|
843
928
|
current: this.timeframe,
|
|
844
929
|
target: this.targetTimeframe
|
|
845
930
|
}, {
|
|
846
|
-
F:
|
|
847
|
-
L:
|
|
931
|
+
F: __dxlog_file7,
|
|
932
|
+
L: 125,
|
|
848
933
|
S: this,
|
|
849
934
|
C: (f, a) => f(...a)
|
|
850
935
|
});
|
|
851
|
-
|
|
936
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
852
937
|
this._timeframeClock.update.waitForCondition(() => {
|
|
853
938
|
return import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
854
939
|
}),
|
|
@@ -874,8 +959,8 @@ var PipelineState = class {
|
|
|
874
959
|
target: this.targetTimeframe,
|
|
875
960
|
dependencies: import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe)
|
|
876
961
|
}, {
|
|
877
|
-
F:
|
|
878
|
-
L:
|
|
962
|
+
F: __dxlog_file7,
|
|
963
|
+
L: 152,
|
|
879
964
|
S: this,
|
|
880
965
|
C: (f, a) => f(...a)
|
|
881
966
|
});
|
|
@@ -904,7 +989,15 @@ var Pipeline = class {
|
|
|
904
989
|
return this._state;
|
|
905
990
|
}
|
|
906
991
|
get writer() {
|
|
907
|
-
(0,
|
|
992
|
+
(0, import_invariant6.invariant)(this._writer, "Writer not set.", {
|
|
993
|
+
F: __dxlog_file7,
|
|
994
|
+
L: 230,
|
|
995
|
+
S: this,
|
|
996
|
+
A: [
|
|
997
|
+
"this._writer",
|
|
998
|
+
"'Writer not set.'"
|
|
999
|
+
]
|
|
1000
|
+
});
|
|
908
1001
|
return this._writer;
|
|
909
1002
|
}
|
|
910
1003
|
hasFeed(feedKey) {
|
|
@@ -923,16 +1016,41 @@ var Pipeline = class {
|
|
|
923
1016
|
this._setFeedDownloadState(feed);
|
|
924
1017
|
}
|
|
925
1018
|
setWriteFeed(feed) {
|
|
926
|
-
(0,
|
|
927
|
-
|
|
1019
|
+
(0, import_invariant6.invariant)(!this._writer, "Writer already set.", {
|
|
1020
|
+
F: __dxlog_file7,
|
|
1021
|
+
L: 253,
|
|
1022
|
+
S: this,
|
|
1023
|
+
A: [
|
|
1024
|
+
"!this._writer",
|
|
1025
|
+
"'Writer already set.'"
|
|
1026
|
+
]
|
|
1027
|
+
});
|
|
1028
|
+
(0, import_invariant6.invariant)(feed.properties.writable, "Feed must be writable.", {
|
|
1029
|
+
F: __dxlog_file7,
|
|
1030
|
+
L: 254,
|
|
1031
|
+
S: this,
|
|
1032
|
+
A: [
|
|
1033
|
+
"feed.properties.writable",
|
|
1034
|
+
"'Feed must be writable.'"
|
|
1035
|
+
]
|
|
1036
|
+
});
|
|
928
1037
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
929
1038
|
timeframe: this._timeframeClock.timeframe,
|
|
930
1039
|
payload
|
|
931
1040
|
}), feed.createFeedWriter());
|
|
932
1041
|
}
|
|
933
1042
|
async start() {
|
|
1043
|
+
(0, import_invariant6.invariant)(!this._isStarted, "Pipeline is already started.", {
|
|
1044
|
+
F: __dxlog_file7,
|
|
1045
|
+
L: 267,
|
|
1046
|
+
S: this,
|
|
1047
|
+
A: [
|
|
1048
|
+
"!this._isStarted",
|
|
1049
|
+
"'Pipeline is already started.'"
|
|
1050
|
+
]
|
|
1051
|
+
});
|
|
934
1052
|
(0, import_log6.log)("starting...", void 0, {
|
|
935
|
-
F:
|
|
1053
|
+
F: __dxlog_file7,
|
|
936
1054
|
L: 268,
|
|
937
1055
|
S: this,
|
|
938
1056
|
C: (f, a) => f(...a)
|
|
@@ -941,29 +1059,28 @@ var Pipeline = class {
|
|
|
941
1059
|
await this._feedSetIterator.open();
|
|
942
1060
|
this._isStarted = true;
|
|
943
1061
|
(0, import_log6.log)("started", void 0, {
|
|
944
|
-
F:
|
|
1062
|
+
F: __dxlog_file7,
|
|
945
1063
|
L: 272,
|
|
946
1064
|
S: this,
|
|
947
1065
|
C: (f, a) => f(...a)
|
|
948
1066
|
});
|
|
949
1067
|
}
|
|
950
1068
|
async stop() {
|
|
951
|
-
var _a;
|
|
952
1069
|
(0, import_log6.log)("stopping...", void 0, {
|
|
953
|
-
F:
|
|
1070
|
+
F: __dxlog_file7,
|
|
954
1071
|
L: 277,
|
|
955
1072
|
S: this,
|
|
956
1073
|
C: (f, a) => f(...a)
|
|
957
1074
|
});
|
|
958
1075
|
this._isStopping = true;
|
|
959
|
-
await
|
|
1076
|
+
await this._feedSetIterator?.close();
|
|
960
1077
|
await this._processingTrigger.wait();
|
|
961
1078
|
await this._state._ctx.dispose();
|
|
962
1079
|
this._state._ctx = new import_context3.Context();
|
|
963
1080
|
this._state._reachedTargetPromise = void 0;
|
|
964
1081
|
this._isStarted = false;
|
|
965
1082
|
(0, import_log6.log)("stopped", void 0, {
|
|
966
|
-
F:
|
|
1083
|
+
F: __dxlog_file7,
|
|
967
1084
|
L: 285,
|
|
968
1085
|
S: this,
|
|
969
1086
|
C: (f, a) => f(...a)
|
|
@@ -974,7 +1091,15 @@ var Pipeline = class {
|
|
|
974
1091
|
* The pipeline will start processing messages AFTER this timeframe.
|
|
975
1092
|
*/
|
|
976
1093
|
async setCursor(timeframe) {
|
|
977
|
-
(0,
|
|
1094
|
+
(0, import_invariant6.invariant)(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
1095
|
+
F: __dxlog_file7,
|
|
1096
|
+
L: 294,
|
|
1097
|
+
S: this,
|
|
1098
|
+
A: [
|
|
1099
|
+
"!this._isStarted || this._isPaused",
|
|
1100
|
+
"'Invalid state.'"
|
|
1101
|
+
]
|
|
1102
|
+
});
|
|
978
1103
|
this._state._startTimeframe = timeframe;
|
|
979
1104
|
this._timeframeClock.setTimeframe(timeframe);
|
|
980
1105
|
for (const feed of this._feeds.values()) {
|
|
@@ -990,7 +1115,15 @@ var Pipeline = class {
|
|
|
990
1115
|
* Calling pause while processing will cause a deadlock.
|
|
991
1116
|
*/
|
|
992
1117
|
async pause() {
|
|
993
|
-
(0,
|
|
1118
|
+
(0, import_invariant6.invariant)(this._isStarted, "Pipeline is not open.", {
|
|
1119
|
+
F: __dxlog_file7,
|
|
1120
|
+
L: 316,
|
|
1121
|
+
S: this,
|
|
1122
|
+
A: [
|
|
1123
|
+
"this._isStarted",
|
|
1124
|
+
"'Pipeline is not open.'"
|
|
1125
|
+
]
|
|
1126
|
+
});
|
|
994
1127
|
if (this._isPaused) {
|
|
995
1128
|
return;
|
|
996
1129
|
}
|
|
@@ -999,8 +1132,24 @@ var Pipeline = class {
|
|
|
999
1132
|
this._isPaused = true;
|
|
1000
1133
|
}
|
|
1001
1134
|
async unpause() {
|
|
1002
|
-
(0,
|
|
1003
|
-
|
|
1135
|
+
(0, import_invariant6.invariant)(this._isStarted, "Pipeline is not open.", {
|
|
1136
|
+
F: __dxlog_file7,
|
|
1137
|
+
L: 328,
|
|
1138
|
+
S: this,
|
|
1139
|
+
A: [
|
|
1140
|
+
"this._isStarted",
|
|
1141
|
+
"'Pipeline is not open.'"
|
|
1142
|
+
]
|
|
1143
|
+
});
|
|
1144
|
+
(0, import_invariant6.invariant)(this._isPaused, "Pipeline is not paused.", {
|
|
1145
|
+
F: __dxlog_file7,
|
|
1146
|
+
L: 329,
|
|
1147
|
+
S: this,
|
|
1148
|
+
A: [
|
|
1149
|
+
"this._isPaused",
|
|
1150
|
+
"'Pipeline is not paused.'"
|
|
1151
|
+
]
|
|
1152
|
+
});
|
|
1004
1153
|
this._pauseTrigger.wake();
|
|
1005
1154
|
this._isPaused = false;
|
|
1006
1155
|
}
|
|
@@ -1009,21 +1158,45 @@ var Pipeline = class {
|
|
|
1009
1158
|
* Updates the timeframe clock after the message has bee processed.
|
|
1010
1159
|
*/
|
|
1011
1160
|
async *consume() {
|
|
1012
|
-
(0,
|
|
1161
|
+
(0, import_invariant6.invariant)(!this._isOpen, "Pipeline is already being consumed.", {
|
|
1162
|
+
F: __dxlog_file7,
|
|
1163
|
+
L: 340,
|
|
1164
|
+
S: this,
|
|
1165
|
+
A: [
|
|
1166
|
+
"!this._isOpen",
|
|
1167
|
+
"'Pipeline is already being consumed.'"
|
|
1168
|
+
]
|
|
1169
|
+
});
|
|
1013
1170
|
this._isOpen = true;
|
|
1014
|
-
(0,
|
|
1171
|
+
(0, import_invariant6.invariant)(this._feedSetIterator, "Iterator not initialized.", {
|
|
1172
|
+
F: __dxlog_file7,
|
|
1173
|
+
L: 343,
|
|
1174
|
+
S: this,
|
|
1175
|
+
A: [
|
|
1176
|
+
"this._feedSetIterator",
|
|
1177
|
+
"'Iterator not initialized.'"
|
|
1178
|
+
]
|
|
1179
|
+
});
|
|
1015
1180
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
1016
1181
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
1017
1182
|
while (!this._isStopping) {
|
|
1018
1183
|
await this._pauseTrigger.wait();
|
|
1019
1184
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
1020
|
-
(0,
|
|
1185
|
+
(0, import_invariant6.invariant)(this._feedSetIterator, "Iterator not initialized.", {
|
|
1186
|
+
F: __dxlog_file7,
|
|
1187
|
+
L: 352,
|
|
1188
|
+
S: this,
|
|
1189
|
+
A: [
|
|
1190
|
+
"this._feedSetIterator",
|
|
1191
|
+
"'Iterator not initialized.'"
|
|
1192
|
+
]
|
|
1193
|
+
});
|
|
1021
1194
|
lastFeedSetIterator = this._feedSetIterator;
|
|
1022
1195
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
1023
1196
|
}
|
|
1024
1197
|
const { done, value } = await iterable.next();
|
|
1025
1198
|
if (!done) {
|
|
1026
|
-
const block = value
|
|
1199
|
+
const block = value ?? (0, import_debug3.failUndefined)();
|
|
1027
1200
|
this._processingTrigger.reset();
|
|
1028
1201
|
this._timeframeClock.updatePendingTimeframe(import_keys3.PublicKey.from(block.feedKey), block.seq);
|
|
1029
1202
|
yield block;
|
|
@@ -1034,13 +1207,12 @@ var Pipeline = class {
|
|
|
1034
1207
|
this._isOpen = false;
|
|
1035
1208
|
}
|
|
1036
1209
|
_setFeedDownloadState(feed) {
|
|
1037
|
-
var _a;
|
|
1038
1210
|
const timeframe = this._state._startTimeframe;
|
|
1039
|
-
const seq =
|
|
1211
|
+
const seq = timeframe.get(feed.key) ?? 0;
|
|
1040
1212
|
feed.undownload({
|
|
1041
1213
|
callback: () => (0, import_log6.log)("undownload", void 0, {
|
|
1042
|
-
F:
|
|
1043
|
-
L:
|
|
1214
|
+
F: __dxlog_file7,
|
|
1215
|
+
L: 377,
|
|
1044
1216
|
S: this,
|
|
1045
1217
|
C: (f, a) => f(...a)
|
|
1046
1218
|
})
|
|
@@ -1052,8 +1224,8 @@ var Pipeline = class {
|
|
|
1052
1224
|
(0, import_log6.log)("failed to download feed", {
|
|
1053
1225
|
err
|
|
1054
1226
|
}, {
|
|
1055
|
-
F:
|
|
1056
|
-
L:
|
|
1227
|
+
F: __dxlog_file7,
|
|
1228
|
+
L: 379,
|
|
1057
1229
|
S: this,
|
|
1058
1230
|
C: (f, a) => f(...a)
|
|
1059
1231
|
});
|
|
@@ -1066,8 +1238,8 @@ var Pipeline = class {
|
|
|
1066
1238
|
});
|
|
1067
1239
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
1068
1240
|
import_log6.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
1069
|
-
F:
|
|
1070
|
-
L:
|
|
1241
|
+
F: __dxlog_file7,
|
|
1242
|
+
L: 390,
|
|
1071
1243
|
S: this,
|
|
1072
1244
|
C: (f, a) => f(...a)
|
|
1073
1245
|
});
|
|
@@ -1095,14 +1267,14 @@ _ts_decorate4([
|
|
|
1095
1267
|
], Pipeline.prototype, "unpause", null);
|
|
1096
1268
|
|
|
1097
1269
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
1098
|
-
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1099
1270
|
var import_async5 = require("@dxos/async");
|
|
1100
1271
|
var import_context4 = require("@dxos/context");
|
|
1101
1272
|
var import_crypto2 = require("@dxos/crypto");
|
|
1273
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
1102
1274
|
var import_log7 = require("@dxos/log");
|
|
1103
1275
|
var import_protocols5 = require("@dxos/protocols");
|
|
1104
1276
|
var import_teleport = require("@dxos/teleport");
|
|
1105
|
-
var
|
|
1277
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
1106
1278
|
var AuthExtension = class extends import_teleport.RpcExtension {
|
|
1107
1279
|
constructor(_authParams) {
|
|
1108
1280
|
super({
|
|
@@ -1118,8 +1290,8 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1118
1290
|
this._ctx = new import_context4.Context({
|
|
1119
1291
|
onError: (err) => {
|
|
1120
1292
|
import_log7.log.catch(err, void 0, {
|
|
1121
|
-
F:
|
|
1122
|
-
L:
|
|
1293
|
+
F: __dxlog_file8,
|
|
1294
|
+
L: 28,
|
|
1123
1295
|
S: this,
|
|
1124
1296
|
C: (f, a) => f(...a)
|
|
1125
1297
|
});
|
|
@@ -1140,8 +1312,8 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1140
1312
|
};
|
|
1141
1313
|
} catch (err) {
|
|
1142
1314
|
import_log7.log.error("failed to generate auth credentials", err, {
|
|
1143
|
-
F:
|
|
1144
|
-
L:
|
|
1315
|
+
F: __dxlog_file8,
|
|
1316
|
+
L: 55,
|
|
1145
1317
|
S: this,
|
|
1146
1318
|
C: (f, a) => f(...a)
|
|
1147
1319
|
});
|
|
@@ -1159,14 +1331,30 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1159
1331
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1160
1332
|
challenge
|
|
1161
1333
|
});
|
|
1162
|
-
(0,
|
|
1334
|
+
(0, import_invariant7.invariant)(credential?.length > 0, "invalid credential", {
|
|
1335
|
+
F: __dxlog_file8,
|
|
1336
|
+
L: 69,
|
|
1337
|
+
S: this,
|
|
1338
|
+
A: [
|
|
1339
|
+
"credential?.length > 0",
|
|
1340
|
+
"'invalid credential'"
|
|
1341
|
+
]
|
|
1342
|
+
});
|
|
1163
1343
|
const success = await this._authParams.verifier(challenge, credential);
|
|
1164
|
-
(0,
|
|
1344
|
+
(0, import_invariant7.invariant)(success, "credential not verified", {
|
|
1345
|
+
F: __dxlog_file8,
|
|
1346
|
+
L: 71,
|
|
1347
|
+
S: this,
|
|
1348
|
+
A: [
|
|
1349
|
+
"success",
|
|
1350
|
+
"'credential not verified'"
|
|
1351
|
+
]
|
|
1352
|
+
});
|
|
1165
1353
|
(0, import_async5.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
|
|
1166
1354
|
} catch (err) {
|
|
1167
1355
|
(0, import_log7.log)("auth failed", err, {
|
|
1168
|
-
F:
|
|
1169
|
-
L:
|
|
1356
|
+
F: __dxlog_file8,
|
|
1357
|
+
L: 74,
|
|
1170
1358
|
S: this,
|
|
1171
1359
|
C: (f, a) => f(...a)
|
|
1172
1360
|
});
|
|
@@ -1182,10 +1370,11 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1182
1370
|
};
|
|
1183
1371
|
|
|
1184
1372
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1185
|
-
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
1186
1373
|
var import_async7 = require("@dxos/async");
|
|
1374
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
1187
1375
|
var import_log10 = require("@dxos/log");
|
|
1188
1376
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
1377
|
+
var import_tracing = require("@dxos/tracing");
|
|
1189
1378
|
var import_util7 = require("@dxos/util");
|
|
1190
1379
|
|
|
1191
1380
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
@@ -1195,7 +1384,7 @@ var import_log8 = require("@dxos/log");
|
|
|
1195
1384
|
var import_credentials2 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
1196
1385
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
1197
1386
|
var import_util5 = require("@dxos/util");
|
|
1198
|
-
var
|
|
1387
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1199
1388
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
1200
1389
|
var ControlPipeline = class {
|
|
1201
1390
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
@@ -1210,7 +1399,7 @@ var ControlPipeline = class {
|
|
|
1210
1399
|
(0, import_log8.log)("feed admitted", {
|
|
1211
1400
|
key: info.key
|
|
1212
1401
|
}, {
|
|
1213
|
-
F:
|
|
1402
|
+
F: __dxlog_file9,
|
|
1214
1403
|
L: 51,
|
|
1215
1404
|
S: this,
|
|
1216
1405
|
C: (f, a) => f(...a)
|
|
@@ -1221,7 +1410,7 @@ var ControlPipeline = class {
|
|
|
1221
1410
|
await this._pipeline.addFeed(feed);
|
|
1222
1411
|
} catch (err) {
|
|
1223
1412
|
import_log8.log.catch(err, void 0, {
|
|
1224
|
-
F:
|
|
1413
|
+
F: __dxlog_file9,
|
|
1225
1414
|
L: 59,
|
|
1226
1415
|
S: this,
|
|
1227
1416
|
C: (f, a) => f(...a)
|
|
@@ -1244,7 +1433,7 @@ var ControlPipeline = class {
|
|
|
1244
1433
|
}
|
|
1245
1434
|
async start() {
|
|
1246
1435
|
(0, import_log8.log)("starting...", void 0, {
|
|
1247
|
-
F:
|
|
1436
|
+
F: __dxlog_file9,
|
|
1248
1437
|
L: 83,
|
|
1249
1438
|
S: this,
|
|
1250
1439
|
C: (f, a) => f(...a)
|
|
@@ -1256,7 +1445,7 @@ var ControlPipeline = class {
|
|
|
1256
1445
|
key: msg.feedKey,
|
|
1257
1446
|
seq: msg.seq
|
|
1258
1447
|
}, {
|
|
1259
|
-
F:
|
|
1448
|
+
F: __dxlog_file9,
|
|
1260
1449
|
L: 88,
|
|
1261
1450
|
S: this,
|
|
1262
1451
|
C: (f, a) => f(...a)
|
|
@@ -1269,7 +1458,7 @@ var ControlPipeline = class {
|
|
|
1269
1458
|
import_log8.log.warn("processing failed", {
|
|
1270
1459
|
msg
|
|
1271
1460
|
}, {
|
|
1272
|
-
F:
|
|
1461
|
+
F: __dxlog_file9,
|
|
1273
1462
|
L: 98,
|
|
1274
1463
|
S: this,
|
|
1275
1464
|
C: (f, a) => f(...a)
|
|
@@ -1280,7 +1469,7 @@ var ControlPipeline = class {
|
|
|
1280
1469
|
}
|
|
1281
1470
|
} catch (err) {
|
|
1282
1471
|
import_log8.log.catch(err, void 0, {
|
|
1283
|
-
F:
|
|
1472
|
+
F: __dxlog_file9,
|
|
1284
1473
|
L: 104,
|
|
1285
1474
|
S: this,
|
|
1286
1475
|
C: (f, a) => f(...a)
|
|
@@ -1290,7 +1479,7 @@ var ControlPipeline = class {
|
|
|
1290
1479
|
});
|
|
1291
1480
|
await this._pipeline.start();
|
|
1292
1481
|
(0, import_log8.log)("started", void 0, {
|
|
1293
|
-
F:
|
|
1482
|
+
F: __dxlog_file9,
|
|
1294
1483
|
L: 110,
|
|
1295
1484
|
S: this,
|
|
1296
1485
|
C: (f, a) => f(...a)
|
|
@@ -1304,7 +1493,7 @@ var ControlPipeline = class {
|
|
|
1304
1493
|
}
|
|
1305
1494
|
async stop() {
|
|
1306
1495
|
(0, import_log8.log)("stopping...", void 0, {
|
|
1307
|
-
F:
|
|
1496
|
+
F: __dxlog_file9,
|
|
1308
1497
|
L: 124,
|
|
1309
1498
|
S: this,
|
|
1310
1499
|
C: (f, a) => f(...a)
|
|
@@ -1312,21 +1501,20 @@ var ControlPipeline = class {
|
|
|
1312
1501
|
await this._pipeline.stop();
|
|
1313
1502
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1314
1503
|
(0, import_log8.log)("stopped", void 0, {
|
|
1315
|
-
F:
|
|
1504
|
+
F: __dxlog_file9,
|
|
1316
1505
|
L: 127,
|
|
1317
1506
|
S: this,
|
|
1318
1507
|
C: (f, a) => f(...a)
|
|
1319
1508
|
});
|
|
1320
1509
|
}
|
|
1321
1510
|
async _saveTargetTimeframe(timeframe) {
|
|
1322
|
-
var _a;
|
|
1323
1511
|
try {
|
|
1324
|
-
const newTimeframe = import_timeframe3.Timeframe.merge(
|
|
1512
|
+
const newTimeframe = import_timeframe3.Timeframe.merge(this._targetTimeframe ?? new import_timeframe3.Timeframe(), timeframe);
|
|
1325
1513
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1326
1514
|
this._targetTimeframe = newTimeframe;
|
|
1327
1515
|
} catch (err) {
|
|
1328
1516
|
(0, import_log8.log)(err, void 0, {
|
|
1329
|
-
F:
|
|
1517
|
+
F: __dxlog_file9,
|
|
1330
1518
|
L: 136,
|
|
1331
1519
|
S: this,
|
|
1332
1520
|
C: (f, a) => f(...a)
|
|
@@ -1336,12 +1524,12 @@ var ControlPipeline = class {
|
|
|
1336
1524
|
};
|
|
1337
1525
|
|
|
1338
1526
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1339
|
-
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
1340
1527
|
var import_async6 = require("@dxos/async");
|
|
1341
1528
|
var import_context5 = require("@dxos/context");
|
|
1342
1529
|
var import_credentials3 = require("@dxos/credentials");
|
|
1343
1530
|
var import_echo_db3 = require("@dxos/echo-db");
|
|
1344
1531
|
var import_errors2 = require("@dxos/errors");
|
|
1532
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
1345
1533
|
var import_log9 = require("@dxos/log");
|
|
1346
1534
|
var import_timeframe4 = require("@dxos/timeframe");
|
|
1347
1535
|
var import_util6 = require("@dxos/util");
|
|
@@ -1355,7 +1543,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1355
1543
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1356
1544
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1357
1545
|
}
|
|
1358
|
-
var
|
|
1546
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1359
1547
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1360
1548
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1361
1549
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
@@ -1381,13 +1569,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1381
1569
|
return this._pipeline;
|
|
1382
1570
|
}
|
|
1383
1571
|
get pipelineState() {
|
|
1384
|
-
|
|
1385
|
-
return (_a = this._pipeline) == null ? void 0 : _a.state;
|
|
1572
|
+
return this._pipeline?.state;
|
|
1386
1573
|
}
|
|
1387
1574
|
setTargetTimeframe(timeframe) {
|
|
1388
|
-
var _a;
|
|
1389
1575
|
this._targetTimeframe = timeframe;
|
|
1390
|
-
|
|
1576
|
+
this._pipeline?.state.setTargetTimeframe(timeframe);
|
|
1391
1577
|
}
|
|
1392
1578
|
async processCredential(credential) {
|
|
1393
1579
|
if (!(0, import_credentials3.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -1411,8 +1597,24 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1411
1597
|
}
|
|
1412
1598
|
const feedWriter = {
|
|
1413
1599
|
write: (data, options) => {
|
|
1414
|
-
(0,
|
|
1415
|
-
|
|
1600
|
+
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1601
|
+
F: __dxlog_file10,
|
|
1602
|
+
L: 145,
|
|
1603
|
+
S: this,
|
|
1604
|
+
A: [
|
|
1605
|
+
"this._pipeline",
|
|
1606
|
+
"'Pipeline is not initialized.'"
|
|
1607
|
+
]
|
|
1608
|
+
});
|
|
1609
|
+
(0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
|
|
1610
|
+
F: __dxlog_file10,
|
|
1611
|
+
L: 146,
|
|
1612
|
+
S: this,
|
|
1613
|
+
A: [
|
|
1614
|
+
"this.currentEpoch",
|
|
1615
|
+
"'Epoch is not initialized.'"
|
|
1616
|
+
]
|
|
1617
|
+
});
|
|
1416
1618
|
return this._pipeline.writer.write({
|
|
1417
1619
|
data
|
|
1418
1620
|
}, options);
|
|
@@ -1427,19 +1629,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1427
1629
|
this._isOpen = true;
|
|
1428
1630
|
}
|
|
1429
1631
|
async close() {
|
|
1430
|
-
var _a, _b, _c;
|
|
1431
1632
|
if (!this._isOpen) {
|
|
1432
1633
|
return;
|
|
1433
1634
|
}
|
|
1434
1635
|
(0, import_log9.log)("close", void 0, {
|
|
1435
|
-
F:
|
|
1436
|
-
L:
|
|
1636
|
+
F: __dxlog_file10,
|
|
1637
|
+
L: 170,
|
|
1437
1638
|
S: this,
|
|
1438
1639
|
C: (f, a) => f(...a)
|
|
1439
1640
|
});
|
|
1440
1641
|
this._isOpen = false;
|
|
1441
1642
|
await this._ctx.dispose();
|
|
1442
|
-
await
|
|
1643
|
+
await this._pipeline?.stop();
|
|
1443
1644
|
try {
|
|
1444
1645
|
await this._saveCache();
|
|
1445
1646
|
if (this._pipeline) {
|
|
@@ -1447,14 +1648,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1447
1648
|
}
|
|
1448
1649
|
} catch (err) {
|
|
1449
1650
|
import_log9.log.catch(err, void 0, {
|
|
1450
|
-
F:
|
|
1451
|
-
L:
|
|
1651
|
+
F: __dxlog_file10,
|
|
1652
|
+
L: 183,
|
|
1452
1653
|
S: this,
|
|
1453
1654
|
C: (f, a) => f(...a)
|
|
1454
1655
|
});
|
|
1455
1656
|
}
|
|
1456
|
-
await
|
|
1457
|
-
await
|
|
1657
|
+
await this.databaseHost?.close();
|
|
1658
|
+
await this.itemManager?.destroy();
|
|
1458
1659
|
this._ctx = new import_context5.Context();
|
|
1459
1660
|
this._pipeline = void 0;
|
|
1460
1661
|
this._targetTimeframe = void 0;
|
|
@@ -1470,15 +1671,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1470
1671
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1471
1672
|
await waitForOneEpoch;
|
|
1472
1673
|
}
|
|
1473
|
-
(0,
|
|
1674
|
+
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1675
|
+
F: __dxlog_file10,
|
|
1676
|
+
L: 206,
|
|
1677
|
+
S: this,
|
|
1678
|
+
A: [
|
|
1679
|
+
"this._pipeline",
|
|
1680
|
+
"'Pipeline is not initialized.'"
|
|
1681
|
+
]
|
|
1682
|
+
});
|
|
1474
1683
|
for await (const msg of this._pipeline.consume()) {
|
|
1475
1684
|
const { feedKey, seq, data } = msg;
|
|
1476
1685
|
(0, import_log9.log)("processing message", {
|
|
1477
1686
|
feedKey,
|
|
1478
1687
|
seq
|
|
1479
1688
|
}, {
|
|
1480
|
-
F:
|
|
1481
|
-
L:
|
|
1689
|
+
F: __dxlog_file10,
|
|
1690
|
+
L: 209,
|
|
1482
1691
|
S: this,
|
|
1483
1692
|
C: (f, a) => f(...a)
|
|
1484
1693
|
});
|
|
@@ -1489,8 +1698,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1489
1698
|
import_log9.log.warn("Could not find feed", {
|
|
1490
1699
|
feedKey
|
|
1491
1700
|
}, {
|
|
1492
|
-
F:
|
|
1493
|
-
L:
|
|
1701
|
+
F: __dxlog_file10,
|
|
1702
|
+
L: 215,
|
|
1494
1703
|
S: this,
|
|
1495
1704
|
C: (f, a) => f(...a)
|
|
1496
1705
|
});
|
|
@@ -1512,8 +1721,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1512
1721
|
seq,
|
|
1513
1722
|
spaceKey: this._params.spaceKey.toHex()
|
|
1514
1723
|
}, {
|
|
1515
|
-
F:
|
|
1516
|
-
L:
|
|
1724
|
+
F: __dxlog_file10,
|
|
1725
|
+
L: 232,
|
|
1517
1726
|
S: this,
|
|
1518
1727
|
C: (f, a) => f(...a)
|
|
1519
1728
|
});
|
|
@@ -1521,8 +1730,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1521
1730
|
}
|
|
1522
1731
|
} catch (err) {
|
|
1523
1732
|
import_log9.log.catch(err, void 0, {
|
|
1524
|
-
F:
|
|
1525
|
-
L:
|
|
1733
|
+
F: __dxlog_file10,
|
|
1734
|
+
L: 242,
|
|
1526
1735
|
S: this,
|
|
1527
1736
|
C: (f, a) => f(...a)
|
|
1528
1737
|
});
|
|
@@ -1530,7 +1739,15 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1530
1739
|
}
|
|
1531
1740
|
}
|
|
1532
1741
|
_createSnapshot() {
|
|
1533
|
-
(0,
|
|
1742
|
+
(0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
|
|
1743
|
+
F: __dxlog_file10,
|
|
1744
|
+
L: 248,
|
|
1745
|
+
S: this,
|
|
1746
|
+
A: [
|
|
1747
|
+
"this.databaseHost",
|
|
1748
|
+
"'Database backend is not initialized.'"
|
|
1749
|
+
]
|
|
1750
|
+
});
|
|
1534
1751
|
return {
|
|
1535
1752
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1536
1753
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1538,26 +1755,22 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1538
1755
|
};
|
|
1539
1756
|
}
|
|
1540
1757
|
async _saveTargetTimeframe(timeframe) {
|
|
1541
|
-
|
|
1542
|
-
const newTimeframe = import_timeframe4.Timeframe.merge((_a = this._targetTimeframe) != null ? _a : new import_timeframe4.Timeframe(), timeframe);
|
|
1758
|
+
const newTimeframe = import_timeframe4.Timeframe.merge(this._targetTimeframe ?? new import_timeframe4.Timeframe(), timeframe);
|
|
1543
1759
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1544
1760
|
this._targetTimeframe = newTimeframe;
|
|
1545
1761
|
}
|
|
1546
1762
|
async _saveCache() {
|
|
1547
|
-
var _a;
|
|
1548
1763
|
const cache = {};
|
|
1549
1764
|
try {
|
|
1550
|
-
const propertiesItem = this.itemManager.items.find((item) =>
|
|
1551
|
-
|
|
1552
|
-
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";
|
|
1553
|
-
});
|
|
1765
|
+
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1766
|
+
((0, import_echo_db3.getStateMachineFromItem)(item)?.snapshot()).type === "dxos.sdk.client.Properties");
|
|
1554
1767
|
if (propertiesItem) {
|
|
1555
|
-
cache.properties = (
|
|
1768
|
+
cache.properties = (0, import_echo_db3.getStateMachineFromItem)(propertiesItem)?.snapshot();
|
|
1556
1769
|
}
|
|
1557
1770
|
} catch (err) {
|
|
1558
1771
|
import_log9.log.warn("Failed to cache properties", err, {
|
|
1559
|
-
F:
|
|
1560
|
-
L:
|
|
1772
|
+
F: __dxlog_file10,
|
|
1773
|
+
L: 277,
|
|
1561
1774
|
S: this,
|
|
1562
1775
|
C: (f, a) => f(...a)
|
|
1563
1776
|
});
|
|
@@ -1574,24 +1787,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1574
1787
|
}
|
|
1575
1788
|
}
|
|
1576
1789
|
async _processEpochInSeparateTask(epoch) {
|
|
1577
|
-
var _a;
|
|
1578
1790
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
1579
1791
|
return;
|
|
1580
1792
|
}
|
|
1581
|
-
await
|
|
1793
|
+
await this._epochCtx?.dispose();
|
|
1582
1794
|
const ctx = new import_context5.Context({
|
|
1583
1795
|
onError: (err) => {
|
|
1584
1796
|
if (err instanceof import_errors2.CancelledError) {
|
|
1585
1797
|
(0, import_log9.log)("Epoch processing cancelled.", void 0, {
|
|
1586
|
-
F:
|
|
1587
|
-
L:
|
|
1798
|
+
F: __dxlog_file10,
|
|
1799
|
+
L: 309,
|
|
1588
1800
|
S: this,
|
|
1589
1801
|
C: (f, a) => f(...a)
|
|
1590
1802
|
});
|
|
1591
1803
|
} else {
|
|
1592
1804
|
import_log9.log.catch(err, void 0, {
|
|
1593
|
-
F:
|
|
1594
|
-
L:
|
|
1805
|
+
F: __dxlog_file10,
|
|
1806
|
+
L: 311,
|
|
1595
1807
|
S: this,
|
|
1596
1808
|
C: (f, a) => f(...a)
|
|
1597
1809
|
});
|
|
@@ -1606,8 +1818,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1606
1818
|
(0, import_log9.log)("process epoch", {
|
|
1607
1819
|
epoch
|
|
1608
1820
|
}, {
|
|
1609
|
-
F:
|
|
1610
|
-
L:
|
|
1821
|
+
F: __dxlog_file10,
|
|
1822
|
+
L: 321,
|
|
1611
1823
|
S: this,
|
|
1612
1824
|
C: (f, a) => f(...a)
|
|
1613
1825
|
});
|
|
@@ -1617,14 +1829,30 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1617
1829
|
});
|
|
1618
1830
|
}
|
|
1619
1831
|
async _processEpoch(ctx, epoch) {
|
|
1620
|
-
(0,
|
|
1621
|
-
|
|
1832
|
+
(0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
|
|
1833
|
+
F: __dxlog_file10,
|
|
1834
|
+
L: 331,
|
|
1835
|
+
S: this,
|
|
1836
|
+
A: [
|
|
1837
|
+
"this._isOpen",
|
|
1838
|
+
"'Space is closed.'"
|
|
1839
|
+
]
|
|
1840
|
+
});
|
|
1841
|
+
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1842
|
+
F: __dxlog_file10,
|
|
1843
|
+
L: 332,
|
|
1844
|
+
S: this,
|
|
1845
|
+
A: [
|
|
1846
|
+
"this._pipeline",
|
|
1847
|
+
""
|
|
1848
|
+
]
|
|
1849
|
+
});
|
|
1622
1850
|
this._lastProcessedEpoch = epoch.number;
|
|
1623
1851
|
(0, import_log9.log)("Processing epoch", {
|
|
1624
1852
|
epoch
|
|
1625
1853
|
}, {
|
|
1626
|
-
F:
|
|
1627
|
-
L:
|
|
1854
|
+
F: __dxlog_file10,
|
|
1855
|
+
L: 335,
|
|
1628
1856
|
S: this,
|
|
1629
1857
|
C: (f, a) => f(...a)
|
|
1630
1858
|
});
|
|
@@ -1633,8 +1861,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1633
1861
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1634
1862
|
}
|
|
1635
1863
|
(0, import_log9.log)("restarting pipeline for epoch", void 0, {
|
|
1636
|
-
F:
|
|
1637
|
-
L:
|
|
1864
|
+
F: __dxlog_file10,
|
|
1865
|
+
L: 343,
|
|
1638
1866
|
S: this,
|
|
1639
1867
|
C: (f, a) => f(...a)
|
|
1640
1868
|
});
|
|
@@ -1643,12 +1871,36 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1643
1871
|
await this._pipeline.unpause();
|
|
1644
1872
|
}
|
|
1645
1873
|
async waitUntilTimeframe(timeframe) {
|
|
1646
|
-
(0,
|
|
1874
|
+
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1875
|
+
F: __dxlog_file10,
|
|
1876
|
+
L: 351,
|
|
1877
|
+
S: this,
|
|
1878
|
+
A: [
|
|
1879
|
+
"this._pipeline",
|
|
1880
|
+
"'Pipeline is not initialized.'"
|
|
1881
|
+
]
|
|
1882
|
+
});
|
|
1647
1883
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1648
1884
|
}
|
|
1649
1885
|
async createEpoch() {
|
|
1650
|
-
(0,
|
|
1651
|
-
|
|
1886
|
+
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1887
|
+
F: __dxlog_file10,
|
|
1888
|
+
L: 357,
|
|
1889
|
+
S: this,
|
|
1890
|
+
A: [
|
|
1891
|
+
"this._pipeline",
|
|
1892
|
+
""
|
|
1893
|
+
]
|
|
1894
|
+
});
|
|
1895
|
+
(0, import_invariant8.invariant)(this.currentEpoch, void 0, {
|
|
1896
|
+
F: __dxlog_file10,
|
|
1897
|
+
L: 358,
|
|
1898
|
+
S: this,
|
|
1899
|
+
A: [
|
|
1900
|
+
"this.currentEpoch",
|
|
1901
|
+
""
|
|
1902
|
+
]
|
|
1903
|
+
});
|
|
1652
1904
|
await this._pipeline.pause();
|
|
1653
1905
|
const snapshot = await this._createSnapshot();
|
|
1654
1906
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1692,14 +1944,22 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1692
1944
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1693
1945
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1694
1946
|
}
|
|
1695
|
-
var
|
|
1947
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1696
1948
|
var Space = class Space2 {
|
|
1697
1949
|
constructor(params) {
|
|
1698
1950
|
this._addFeedLock = new import_async7.Lock();
|
|
1699
1951
|
this.onCredentialProcessed = new import_util7.Callback();
|
|
1700
1952
|
this.stateUpdate = new import_async7.Event();
|
|
1701
1953
|
this._isOpen = false;
|
|
1702
|
-
(0,
|
|
1954
|
+
(0, import_invariant9.invariant)(params.spaceKey && params.feedProvider, void 0, {
|
|
1955
|
+
F: __dxlog_file11,
|
|
1956
|
+
L: 73,
|
|
1957
|
+
S: this,
|
|
1958
|
+
A: [
|
|
1959
|
+
"params.spaceKey && params.feedProvider",
|
|
1960
|
+
""
|
|
1961
|
+
]
|
|
1962
|
+
});
|
|
1703
1963
|
this._key = params.spaceKey;
|
|
1704
1964
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1705
1965
|
this._feedProvider = params.feedProvider;
|
|
@@ -1734,8 +1994,8 @@ var Space = class Space2 {
|
|
|
1734
1994
|
(0, import_log10.log)("onCredentialProcessed", {
|
|
1735
1995
|
credential
|
|
1736
1996
|
}, {
|
|
1737
|
-
F:
|
|
1738
|
-
L:
|
|
1997
|
+
F: __dxlog_file11,
|
|
1998
|
+
L: 109,
|
|
1739
1999
|
S: this,
|
|
1740
2000
|
C: (f, a) => f(...a)
|
|
1741
2001
|
});
|
|
@@ -1777,12 +2037,10 @@ var Space = class Space2 {
|
|
|
1777
2037
|
return this._genesisFeedKey;
|
|
1778
2038
|
}
|
|
1779
2039
|
get controlFeedKey() {
|
|
1780
|
-
|
|
1781
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
2040
|
+
return this._controlFeed?.key;
|
|
1782
2041
|
}
|
|
1783
2042
|
get dataFeedKey() {
|
|
1784
|
-
|
|
1785
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
2043
|
+
return this._dataFeed?.key;
|
|
1786
2044
|
}
|
|
1787
2045
|
get spaceState() {
|
|
1788
2046
|
return this._controlPipeline.spaceState;
|
|
@@ -1800,16 +2058,31 @@ var Space = class Space2 {
|
|
|
1800
2058
|
return this._snapshotManager;
|
|
1801
2059
|
}
|
|
1802
2060
|
setControlFeed(feed) {
|
|
1803
|
-
(0,
|
|
2061
|
+
(0, import_invariant9.invariant)(!this._controlFeed, "Control feed already set.", {
|
|
2062
|
+
F: __dxlog_file11,
|
|
2063
|
+
L: 183,
|
|
2064
|
+
S: this,
|
|
2065
|
+
A: [
|
|
2066
|
+
"!this._controlFeed",
|
|
2067
|
+
"'Control feed already set.'"
|
|
2068
|
+
]
|
|
2069
|
+
});
|
|
1804
2070
|
this._controlFeed = feed;
|
|
1805
2071
|
this._controlPipeline.setWriteFeed(feed);
|
|
1806
2072
|
return this;
|
|
1807
2073
|
}
|
|
1808
2074
|
setDataFeed(feed) {
|
|
1809
|
-
|
|
1810
|
-
|
|
2075
|
+
(0, import_invariant9.invariant)(!this._dataFeed, "Data feed already set.", {
|
|
2076
|
+
F: __dxlog_file11,
|
|
2077
|
+
L: 190,
|
|
2078
|
+
S: this,
|
|
2079
|
+
A: [
|
|
2080
|
+
"!this._dataFeed",
|
|
2081
|
+
"'Data feed already set.'"
|
|
2082
|
+
]
|
|
2083
|
+
});
|
|
1811
2084
|
this._dataFeed = feed;
|
|
1812
|
-
|
|
2085
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1813
2086
|
return this;
|
|
1814
2087
|
}
|
|
1815
2088
|
/**
|
|
@@ -1824,10 +2097,10 @@ var Space = class Space2 {
|
|
|
1824
2097
|
// getDataFeeds(): FeedInfo[] {
|
|
1825
2098
|
// return this._dataPipeline?.getFeeds();
|
|
1826
2099
|
// }
|
|
1827
|
-
async open() {
|
|
2100
|
+
async open(ctx) {
|
|
1828
2101
|
(0, import_log10.log)("opening...", void 0, {
|
|
1829
|
-
F:
|
|
1830
|
-
L:
|
|
2102
|
+
F: __dxlog_file11,
|
|
2103
|
+
L: 212,
|
|
1831
2104
|
S: this,
|
|
1832
2105
|
C: (f, a) => f(...a)
|
|
1833
2106
|
});
|
|
@@ -1839,8 +2112,8 @@ var Space = class Space2 {
|
|
|
1839
2112
|
await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
|
|
1840
2113
|
this._isOpen = true;
|
|
1841
2114
|
(0, import_log10.log)("opened", void 0, {
|
|
1842
|
-
F:
|
|
1843
|
-
L:
|
|
2115
|
+
F: __dxlog_file11,
|
|
2116
|
+
L: 223,
|
|
1844
2117
|
S: this,
|
|
1845
2118
|
C: (f, a) => f(...a)
|
|
1846
2119
|
});
|
|
@@ -1849,8 +2122,8 @@ var Space = class Space2 {
|
|
|
1849
2122
|
(0, import_log10.log)("closing...", {
|
|
1850
2123
|
key: this._key
|
|
1851
2124
|
}, {
|
|
1852
|
-
F:
|
|
1853
|
-
L:
|
|
2125
|
+
F: __dxlog_file11,
|
|
2126
|
+
L: 228,
|
|
1854
2127
|
S: this,
|
|
1855
2128
|
C: (f, a) => f(...a)
|
|
1856
2129
|
});
|
|
@@ -1863,20 +2136,28 @@ var Space = class Space2 {
|
|
|
1863
2136
|
await this._controlPipeline.stop();
|
|
1864
2137
|
this._isOpen = false;
|
|
1865
2138
|
(0, import_log10.log)("closed", void 0, {
|
|
1866
|
-
F:
|
|
1867
|
-
L:
|
|
2139
|
+
F: __dxlog_file11,
|
|
2140
|
+
L: 241,
|
|
1868
2141
|
S: this,
|
|
1869
2142
|
C: (f, a) => f(...a)
|
|
1870
2143
|
});
|
|
1871
2144
|
}
|
|
1872
2145
|
async initializeDataPipeline() {
|
|
1873
2146
|
(0, import_log10.log)("initializeDataPipeline", void 0, {
|
|
1874
|
-
F:
|
|
1875
|
-
L:
|
|
2147
|
+
F: __dxlog_file11,
|
|
2148
|
+
L: 246,
|
|
1876
2149
|
S: this,
|
|
1877
2150
|
C: (f, a) => f(...a)
|
|
1878
2151
|
});
|
|
1879
|
-
(0,
|
|
2152
|
+
(0, import_invariant9.invariant)(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2153
|
+
F: __dxlog_file11,
|
|
2154
|
+
L: 247,
|
|
2155
|
+
S: this,
|
|
2156
|
+
A: [
|
|
2157
|
+
"this._isOpen",
|
|
2158
|
+
"'Space must be open to initialize data pipeline.'"
|
|
2159
|
+
]
|
|
2160
|
+
});
|
|
1880
2161
|
await this._dataPipeline.open();
|
|
1881
2162
|
}
|
|
1882
2163
|
};
|
|
@@ -1884,7 +2165,8 @@ _ts_decorate6([
|
|
|
1884
2165
|
import_log10.logInfo
|
|
1885
2166
|
], Space.prototype, "key", null);
|
|
1886
2167
|
_ts_decorate6([
|
|
1887
|
-
import_async7.synchronized
|
|
2168
|
+
import_async7.synchronized,
|
|
2169
|
+
import_tracing.trace.span()
|
|
1888
2170
|
], Space.prototype, "open", null);
|
|
1889
2171
|
_ts_decorate6([
|
|
1890
2172
|
import_async7.synchronized
|
|
@@ -1893,12 +2175,13 @@ _ts_decorate6([
|
|
|
1893
2175
|
import_async7.synchronized
|
|
1894
2176
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1895
2177
|
Space = _ts_decorate6([
|
|
1896
|
-
(0, import_async7.trackLeaks)("open", "close")
|
|
2178
|
+
(0, import_async7.trackLeaks)("open", "close"),
|
|
2179
|
+
import_tracing.trace.resource()
|
|
1897
2180
|
], Space);
|
|
1898
2181
|
|
|
1899
2182
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
1900
2183
|
var import_async8 = require("@dxos/async");
|
|
1901
|
-
var
|
|
2184
|
+
var import_debug4 = require("@dxos/debug");
|
|
1902
2185
|
var import_keys6 = require("@dxos/keys");
|
|
1903
2186
|
var import_log12 = require("@dxos/log");
|
|
1904
2187
|
var import_protocols6 = require("@dxos/protocols");
|
|
@@ -1923,7 +2206,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1923
2206
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1924
2207
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1925
2208
|
}
|
|
1926
|
-
var
|
|
2209
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1927
2210
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1928
2211
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1929
2212
|
var SpaceProtocol = class {
|
|
@@ -1953,7 +2236,7 @@ var SpaceProtocol = class {
|
|
|
1953
2236
|
(0, import_log11.log)("addFeed", {
|
|
1954
2237
|
key: feed.key
|
|
1955
2238
|
}, {
|
|
1956
|
-
F:
|
|
2239
|
+
F: __dxlog_file12,
|
|
1957
2240
|
L: 95,
|
|
1958
2241
|
S: this,
|
|
1959
2242
|
C: (f, a) => f(...a)
|
|
@@ -1975,7 +2258,7 @@ var SpaceProtocol = class {
|
|
|
1975
2258
|
};
|
|
1976
2259
|
await this.blobSync.open();
|
|
1977
2260
|
(0, import_log11.log)("starting...", void 0, {
|
|
1978
|
-
F:
|
|
2261
|
+
F: __dxlog_file12,
|
|
1979
2262
|
L: 120,
|
|
1980
2263
|
S: this,
|
|
1981
2264
|
C: (f, a) => f(...a)
|
|
@@ -1989,7 +2272,7 @@ var SpaceProtocol = class {
|
|
|
1989
2272
|
label: `Protocol swarm: ${topic}`
|
|
1990
2273
|
});
|
|
1991
2274
|
(0, import_log11.log)("started", void 0, {
|
|
1992
|
-
F:
|
|
2275
|
+
F: __dxlog_file12,
|
|
1993
2276
|
L: 130,
|
|
1994
2277
|
S: this,
|
|
1995
2278
|
C: (f, a) => f(...a)
|
|
@@ -1999,14 +2282,14 @@ var SpaceProtocol = class {
|
|
|
1999
2282
|
await this.blobSync.close();
|
|
2000
2283
|
if (this._connection) {
|
|
2001
2284
|
(0, import_log11.log)("stopping...", void 0, {
|
|
2002
|
-
F:
|
|
2285
|
+
F: __dxlog_file12,
|
|
2003
2286
|
L: 137,
|
|
2004
2287
|
S: this,
|
|
2005
2288
|
C: (f, a) => f(...a)
|
|
2006
2289
|
});
|
|
2007
2290
|
await this._connection.close();
|
|
2008
2291
|
(0, import_log11.log)("stopped", void 0, {
|
|
2009
|
-
F:
|
|
2292
|
+
F: __dxlog_file12,
|
|
2010
2293
|
L: 139,
|
|
2011
2294
|
S: this,
|
|
2012
2295
|
C: (f, a) => f(...a)
|
|
@@ -2072,20 +2355,18 @@ var SpaceProtocolSession = class {
|
|
|
2072
2355
|
provider: this._swarmIdentity.credentialProvider,
|
|
2073
2356
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
2074
2357
|
onAuthSuccess: () => {
|
|
2075
|
-
var _a;
|
|
2076
2358
|
(0, import_log11.log)("Peer authenticated", void 0, {
|
|
2077
|
-
F:
|
|
2359
|
+
F: __dxlog_file12,
|
|
2078
2360
|
L: 236,
|
|
2079
2361
|
S: this,
|
|
2080
2362
|
C: (f, a) => f(...a)
|
|
2081
2363
|
});
|
|
2082
2364
|
this._authStatus = AuthStatus.SUCCESS;
|
|
2083
|
-
|
|
2365
|
+
this._onSessionAuth?.(this._teleport);
|
|
2084
2366
|
},
|
|
2085
2367
|
onAuthFailure: () => {
|
|
2086
|
-
var _a;
|
|
2087
2368
|
this._authStatus = AuthStatus.FAILURE;
|
|
2088
|
-
|
|
2369
|
+
this._onAuthFailure?.(this._teleport);
|
|
2089
2370
|
}
|
|
2090
2371
|
}));
|
|
2091
2372
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -2113,7 +2394,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
2113
2394
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2114
2395
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2115
2396
|
}
|
|
2116
|
-
var
|
|
2397
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2117
2398
|
var SpaceManager = class SpaceManager2 {
|
|
2118
2399
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
2119
2400
|
this._spaces = new import_util9.ComplexMap(import_keys6.PublicKey.hash);
|
|
@@ -2137,11 +2418,10 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2137
2418
|
].map((space) => space.close()));
|
|
2138
2419
|
}
|
|
2139
2420
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2140
|
-
var _a;
|
|
2141
2421
|
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.begin({
|
|
2142
2422
|
id: this._instanceId
|
|
2143
2423
|
}), {
|
|
2144
|
-
F:
|
|
2424
|
+
F: __dxlog_file13,
|
|
2145
2425
|
L: 97,
|
|
2146
2426
|
S: this,
|
|
2147
2427
|
C: (f, a) => f(...a)
|
|
@@ -2149,12 +2429,12 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2149
2429
|
(0, import_log12.log)("constructing space...", {
|
|
2150
2430
|
spaceKey: metadata.genesisFeedKey
|
|
2151
2431
|
}, {
|
|
2152
|
-
F:
|
|
2432
|
+
F: __dxlog_file13,
|
|
2153
2433
|
L: 98,
|
|
2154
2434
|
S: this,
|
|
2155
2435
|
C: (f, a) => f(...a)
|
|
2156
2436
|
});
|
|
2157
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2437
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? (0, import_debug4.failUndefined)());
|
|
2158
2438
|
const spaceKey = metadata.key;
|
|
2159
2439
|
const protocol = new SpaceProtocol({
|
|
2160
2440
|
topic: spaceKey,
|
|
@@ -2179,7 +2459,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2179
2459
|
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.end({
|
|
2180
2460
|
id: this._instanceId
|
|
2181
2461
|
}), {
|
|
2182
|
-
F:
|
|
2462
|
+
F: __dxlog_file13,
|
|
2183
2463
|
L: 125,
|
|
2184
2464
|
S: this,
|
|
2185
2465
|
C: (f, a) => f(...a)
|