@dxos/echo-pipeline 0.1.56-main.5ff23aa → 0.1.56-main.6293c6e
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-7RPTJNLX.mjs → chunk-3OTHGQEY.mjs} +100 -125
- 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 +99 -124
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +112 -141
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/db-host/snapshot-manager.d.ts.map +1 -1
- package/dist/types/src/pipeline/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/db-host/snapshot-manager.ts +0 -2
- package/src/metadata/metadata-store.ts +1 -1
- package/src/pipeline/pipeline.test.ts +37 -1
- package/src/pipeline/pipeline.ts +2 -0
- package/src/space/space.test.ts +10 -9
- package/src/space/space.ts +5 -1
- package/src/testing/test-agent-builder.ts +2 -1
- package/dist/lib/browser/chunk-7RPTJNLX.mjs.map +0 -7
|
@@ -67,7 +67,6 @@ var DataServiceHost = class {
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
70
|
-
var _a;
|
|
71
70
|
const { batch, meta } = message;
|
|
72
71
|
invariant2(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
73
72
|
F: __dxlog_file2,
|
|
@@ -91,7 +90,7 @@ var DataServiceHost = class {
|
|
|
91
90
|
message.meta.feedKey,
|
|
92
91
|
message.meta.seq
|
|
93
92
|
]);
|
|
94
|
-
|
|
93
|
+
batch.objects?.forEach((object) => {
|
|
95
94
|
setMetadataOnObject(object, {
|
|
96
95
|
...meta
|
|
97
96
|
});
|
|
@@ -109,7 +108,6 @@ var DataServiceHost = class {
|
|
|
109
108
|
});
|
|
110
109
|
}
|
|
111
110
|
async write(request) {
|
|
112
|
-
var _a, _b;
|
|
113
111
|
invariant2(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
114
112
|
F: __dxlog_file2,
|
|
115
113
|
L: 88,
|
|
@@ -130,7 +128,7 @@ var DataServiceHost = class {
|
|
|
130
128
|
});
|
|
131
129
|
log("write", {
|
|
132
130
|
clientTag: request.clientTag,
|
|
133
|
-
objectCount:
|
|
131
|
+
objectCount: request.batch.objects?.length ?? 0
|
|
134
132
|
}, {
|
|
135
133
|
F: __dxlog_file2,
|
|
136
134
|
L: 91,
|
|
@@ -161,24 +159,18 @@ var DataServiceHost = class {
|
|
|
161
159
|
return receipt;
|
|
162
160
|
}
|
|
163
161
|
};
|
|
164
|
-
var createDataMessage = (batch) => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
meta: void 0
|
|
177
|
-
};
|
|
178
|
-
})
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
};
|
|
162
|
+
var createDataMessage = (batch) => ({
|
|
163
|
+
batch: {
|
|
164
|
+
objects: batch.objects?.map((object) => ({
|
|
165
|
+
...object,
|
|
166
|
+
mutations: object.mutations?.map((mutation) => ({
|
|
167
|
+
...mutation,
|
|
168
|
+
meta: void 0
|
|
169
|
+
})),
|
|
170
|
+
meta: void 0
|
|
171
|
+
}))
|
|
172
|
+
}
|
|
173
|
+
});
|
|
182
174
|
|
|
183
175
|
// packages/core/echo/echo-pipeline/src/db-host/database-host.ts
|
|
184
176
|
import { ItemDemuxer } from "@dxos/echo-db";
|
|
@@ -207,15 +199,13 @@ var DatabaseHost = class {
|
|
|
207
199
|
return this._itemDemuxer.createSnapshot();
|
|
208
200
|
}
|
|
209
201
|
createDataServiceHost() {
|
|
210
|
-
|
|
211
|
-
return new DataServiceHost(this._itemManager, this._itemDemuxer, (_a = this._outboundStream) != null ? _a : void 0);
|
|
202
|
+
return new DataServiceHost(this._itemManager, this._itemDemuxer, this._outboundStream ?? void 0);
|
|
212
203
|
}
|
|
213
204
|
};
|
|
214
205
|
|
|
215
206
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
|
|
216
207
|
import { trackLeaks } from "@dxos/async";
|
|
217
208
|
import { cancelWithContext } from "@dxos/context";
|
|
218
|
-
import { timed } from "@dxos/debug";
|
|
219
209
|
import { PublicKey } from "@dxos/keys";
|
|
220
210
|
import { schema as schema2 } from "@dxos/protocols";
|
|
221
211
|
import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
|
|
@@ -260,9 +250,6 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
260
250
|
return PublicKey.from(id).toHex();
|
|
261
251
|
}
|
|
262
252
|
};
|
|
263
|
-
_ts_decorate([
|
|
264
|
-
timed(1e4)
|
|
265
|
-
], SnapshotManager.prototype, "load", null);
|
|
266
253
|
SnapshotManager = _ts_decorate([
|
|
267
254
|
trackLeaks("open", "close")
|
|
268
255
|
], SnapshotManager);
|
|
@@ -358,7 +345,7 @@ var DataServiceSubscriptions = class {
|
|
|
358
345
|
C: (f, a) => f(...a)
|
|
359
346
|
});
|
|
360
347
|
const host = this._spaces.get(spaceKey);
|
|
361
|
-
await
|
|
348
|
+
await host?.close();
|
|
362
349
|
this._spaces.delete(spaceKey);
|
|
363
350
|
}
|
|
364
351
|
getDataService(spaceKey) {
|
|
@@ -370,7 +357,6 @@ var DataServiceImpl = class {
|
|
|
370
357
|
this._subscriptions = _subscriptions;
|
|
371
358
|
}
|
|
372
359
|
subscribe(request) {
|
|
373
|
-
var _a;
|
|
374
360
|
invariant3(request.spaceKey, void 0, {
|
|
375
361
|
F: __dxlog_file3,
|
|
376
362
|
L: 56,
|
|
@@ -380,11 +366,10 @@ var DataServiceImpl = class {
|
|
|
380
366
|
""
|
|
381
367
|
]
|
|
382
368
|
});
|
|
383
|
-
const host =
|
|
369
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
384
370
|
return host.subscribe();
|
|
385
371
|
}
|
|
386
372
|
write(request) {
|
|
387
|
-
var _a;
|
|
388
373
|
invariant3(request.spaceKey, void 0, {
|
|
389
374
|
F: __dxlog_file3,
|
|
390
375
|
L: 63,
|
|
@@ -403,7 +388,7 @@ var DataServiceImpl = class {
|
|
|
403
388
|
""
|
|
404
389
|
]
|
|
405
390
|
});
|
|
406
|
-
const host =
|
|
391
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
407
392
|
return host.write(request);
|
|
408
393
|
}
|
|
409
394
|
};
|
|
@@ -431,8 +416,8 @@ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipelin
|
|
|
431
416
|
var emptyEchoMetadata = () => ({
|
|
432
417
|
version: STORAGE_VERSION,
|
|
433
418
|
spaces: [],
|
|
434
|
-
created: new Date(),
|
|
435
|
-
updated: new Date()
|
|
419
|
+
created: /* @__PURE__ */ new Date(),
|
|
420
|
+
updated: /* @__PURE__ */ new Date()
|
|
436
421
|
});
|
|
437
422
|
var EchoMetadata = schema4.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
438
423
|
var MetadataStore = class {
|
|
@@ -446,22 +431,19 @@ var MetadataStore = class {
|
|
|
446
431
|
return this._metadata;
|
|
447
432
|
}
|
|
448
433
|
get version() {
|
|
449
|
-
|
|
450
|
-
return (_a = this._metadata.version) != null ? _a : 0;
|
|
434
|
+
return this._metadata.version ?? 0;
|
|
451
435
|
}
|
|
452
436
|
/**
|
|
453
437
|
* Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and
|
|
454
438
|
* addSpaceFeed functions.
|
|
455
439
|
*/
|
|
456
440
|
get spaces() {
|
|
457
|
-
|
|
458
|
-
return (_a = this._metadata.spaces) != null ? _a : [];
|
|
441
|
+
return this._metadata.spaces ?? [];
|
|
459
442
|
}
|
|
460
443
|
/**
|
|
461
444
|
* Loads metadata from persistent storage.
|
|
462
445
|
*/
|
|
463
446
|
async load() {
|
|
464
|
-
var _a;
|
|
465
447
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
466
448
|
try {
|
|
467
449
|
const { size: fileLength } = await file.stat();
|
|
@@ -480,7 +462,10 @@ var MetadataStore = class {
|
|
|
480
462
|
C: (f, a) => f(...a)
|
|
481
463
|
});
|
|
482
464
|
if (fileLength < dataSize + 8) {
|
|
483
|
-
throw new DataCorruptionError("Metadata size is smaller than expected."
|
|
465
|
+
throw new DataCorruptionError("Metadata size is smaller than expected.", {
|
|
466
|
+
fileLength,
|
|
467
|
+
dataSize
|
|
468
|
+
});
|
|
484
469
|
}
|
|
485
470
|
const data = await file.read(8, dataSize);
|
|
486
471
|
const calculatedChecksum = CRC32.buf(data);
|
|
@@ -488,9 +473,8 @@ var MetadataStore = class {
|
|
|
488
473
|
throw new DataCorruptionError("Metadata checksum is invalid.");
|
|
489
474
|
}
|
|
490
475
|
this._metadata = EchoMetadata.decode(data);
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
(_a2 = space.state) != null ? _a2 : space.state = SpaceState.ACTIVE;
|
|
476
|
+
this._metadata.spaces?.forEach((space) => {
|
|
477
|
+
space.state ??= SpaceState.ACTIVE;
|
|
494
478
|
});
|
|
495
479
|
} catch (err) {
|
|
496
480
|
log3.error("failed to load metadata", {
|
|
@@ -507,12 +491,11 @@ var MetadataStore = class {
|
|
|
507
491
|
}
|
|
508
492
|
}
|
|
509
493
|
async _save() {
|
|
510
|
-
var _a;
|
|
511
494
|
const data = {
|
|
512
495
|
...this._metadata,
|
|
513
496
|
version: STORAGE_VERSION,
|
|
514
|
-
created:
|
|
515
|
-
updated: new Date()
|
|
497
|
+
created: this._metadata.created ?? /* @__PURE__ */ new Date(),
|
|
498
|
+
updated: /* @__PURE__ */ new Date()
|
|
516
499
|
};
|
|
517
500
|
this.update.emit(data);
|
|
518
501
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
@@ -538,8 +521,7 @@ var MetadataStore = class {
|
|
|
538
521
|
}
|
|
539
522
|
}
|
|
540
523
|
_getSpace(spaceKey) {
|
|
541
|
-
|
|
542
|
-
if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
|
|
524
|
+
if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
|
|
543
525
|
return this._metadata.identity.haloSpace;
|
|
544
526
|
}
|
|
545
527
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
@@ -584,8 +566,7 @@ var MetadataStore = class {
|
|
|
584
566
|
await this._save();
|
|
585
567
|
}
|
|
586
568
|
async addSpace(record) {
|
|
587
|
-
|
|
588
|
-
invariant4(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
569
|
+
invariant4(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
589
570
|
F: __dxlog_file4,
|
|
590
571
|
L: 162,
|
|
591
572
|
S: this,
|
|
@@ -594,7 +575,7 @@ var MetadataStore = class {
|
|
|
594
575
|
"'Cannot overwrite existing space in metadata'"
|
|
595
576
|
]
|
|
596
577
|
});
|
|
597
|
-
(
|
|
578
|
+
(this._metadata.spaces ??= []).push(record);
|
|
598
579
|
await this._save();
|
|
599
580
|
}
|
|
600
581
|
async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
|
|
@@ -630,7 +611,7 @@ var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
|
630
611
|
|
|
631
612
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
632
613
|
import { Event as Event2 } from "@dxos/async";
|
|
633
|
-
import { timed
|
|
614
|
+
import { timed } from "@dxos/debug";
|
|
634
615
|
import { log as log4 } from "@dxos/log";
|
|
635
616
|
import { Timeframe } from "@dxos/timeframe";
|
|
636
617
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -723,7 +704,7 @@ var TimeframeClock = class {
|
|
|
723
704
|
}
|
|
724
705
|
};
|
|
725
706
|
_ts_decorate3([
|
|
726
|
-
|
|
707
|
+
timed(5e3)
|
|
727
708
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
728
709
|
|
|
729
710
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
@@ -829,7 +810,6 @@ var PipelineState = class {
|
|
|
829
810
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
830
811
|
*/
|
|
831
812
|
async waitUntilReachedTargetTimeframe({ ctx = new Context2(), timeout, breakOnStall = true } = {}) {
|
|
832
|
-
var _a;
|
|
833
813
|
log6("waitUntilReachedTargetTimeframe", {
|
|
834
814
|
timeout,
|
|
835
815
|
current: this.timeframe,
|
|
@@ -840,7 +820,7 @@ var PipelineState = class {
|
|
|
840
820
|
S: this,
|
|
841
821
|
C: (f, a) => f(...a)
|
|
842
822
|
});
|
|
843
|
-
|
|
823
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
844
824
|
this._timeframeClock.update.waitForCondition(() => {
|
|
845
825
|
return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
846
826
|
}),
|
|
@@ -947,10 +927,19 @@ var Pipeline = class {
|
|
|
947
927
|
}), feed.createFeedWriter());
|
|
948
928
|
}
|
|
949
929
|
async start() {
|
|
950
|
-
|
|
930
|
+
invariant6(!this._isStarted, "Pipeline is already started.", {
|
|
951
931
|
F: __dxlog_file7,
|
|
952
932
|
L: 267,
|
|
953
933
|
S: this,
|
|
934
|
+
A: [
|
|
935
|
+
"!this._isStarted",
|
|
936
|
+
"'Pipeline is already started.'"
|
|
937
|
+
]
|
|
938
|
+
});
|
|
939
|
+
log6("starting...", void 0, {
|
|
940
|
+
F: __dxlog_file7,
|
|
941
|
+
L: 268,
|
|
942
|
+
S: this,
|
|
954
943
|
C: (f, a) => f(...a)
|
|
955
944
|
});
|
|
956
945
|
await this._initIterator();
|
|
@@ -958,21 +947,20 @@ var Pipeline = class {
|
|
|
958
947
|
this._isStarted = true;
|
|
959
948
|
log6("started", void 0, {
|
|
960
949
|
F: __dxlog_file7,
|
|
961
|
-
L:
|
|
950
|
+
L: 272,
|
|
962
951
|
S: this,
|
|
963
952
|
C: (f, a) => f(...a)
|
|
964
953
|
});
|
|
965
954
|
}
|
|
966
955
|
async stop() {
|
|
967
|
-
var _a;
|
|
968
956
|
log6("stopping...", void 0, {
|
|
969
957
|
F: __dxlog_file7,
|
|
970
|
-
L:
|
|
958
|
+
L: 277,
|
|
971
959
|
S: this,
|
|
972
960
|
C: (f, a) => f(...a)
|
|
973
961
|
});
|
|
974
962
|
this._isStopping = true;
|
|
975
|
-
await
|
|
963
|
+
await this._feedSetIterator?.close();
|
|
976
964
|
await this._processingTrigger.wait();
|
|
977
965
|
await this._state._ctx.dispose();
|
|
978
966
|
this._state._ctx = new Context2();
|
|
@@ -980,7 +968,7 @@ var Pipeline = class {
|
|
|
980
968
|
this._isStarted = false;
|
|
981
969
|
log6("stopped", void 0, {
|
|
982
970
|
F: __dxlog_file7,
|
|
983
|
-
L:
|
|
971
|
+
L: 285,
|
|
984
972
|
S: this,
|
|
985
973
|
C: (f, a) => f(...a)
|
|
986
974
|
});
|
|
@@ -992,7 +980,7 @@ var Pipeline = class {
|
|
|
992
980
|
async setCursor(timeframe) {
|
|
993
981
|
invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
994
982
|
F: __dxlog_file7,
|
|
995
|
-
L:
|
|
983
|
+
L: 294,
|
|
996
984
|
S: this,
|
|
997
985
|
A: [
|
|
998
986
|
"!this._isStarted || this._isPaused",
|
|
@@ -1016,7 +1004,7 @@ var Pipeline = class {
|
|
|
1016
1004
|
async pause() {
|
|
1017
1005
|
invariant6(this._isStarted, "Pipeline is not open.", {
|
|
1018
1006
|
F: __dxlog_file7,
|
|
1019
|
-
L:
|
|
1007
|
+
L: 316,
|
|
1020
1008
|
S: this,
|
|
1021
1009
|
A: [
|
|
1022
1010
|
"this._isStarted",
|
|
@@ -1033,7 +1021,7 @@ var Pipeline = class {
|
|
|
1033
1021
|
async unpause() {
|
|
1034
1022
|
invariant6(this._isStarted, "Pipeline is not open.", {
|
|
1035
1023
|
F: __dxlog_file7,
|
|
1036
|
-
L:
|
|
1024
|
+
L: 328,
|
|
1037
1025
|
S: this,
|
|
1038
1026
|
A: [
|
|
1039
1027
|
"this._isStarted",
|
|
@@ -1042,7 +1030,7 @@ var Pipeline = class {
|
|
|
1042
1030
|
});
|
|
1043
1031
|
invariant6(this._isPaused, "Pipeline is not paused.", {
|
|
1044
1032
|
F: __dxlog_file7,
|
|
1045
|
-
L:
|
|
1033
|
+
L: 329,
|
|
1046
1034
|
S: this,
|
|
1047
1035
|
A: [
|
|
1048
1036
|
"this._isPaused",
|
|
@@ -1059,7 +1047,7 @@ var Pipeline = class {
|
|
|
1059
1047
|
async *consume() {
|
|
1060
1048
|
invariant6(!this._isOpen, "Pipeline is already being consumed.", {
|
|
1061
1049
|
F: __dxlog_file7,
|
|
1062
|
-
L:
|
|
1050
|
+
L: 340,
|
|
1063
1051
|
S: this,
|
|
1064
1052
|
A: [
|
|
1065
1053
|
"!this._isOpen",
|
|
@@ -1069,7 +1057,7 @@ var Pipeline = class {
|
|
|
1069
1057
|
this._isOpen = true;
|
|
1070
1058
|
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1071
1059
|
F: __dxlog_file7,
|
|
1072
|
-
L:
|
|
1060
|
+
L: 343,
|
|
1073
1061
|
S: this,
|
|
1074
1062
|
A: [
|
|
1075
1063
|
"this._feedSetIterator",
|
|
@@ -1083,7 +1071,7 @@ var Pipeline = class {
|
|
|
1083
1071
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
1084
1072
|
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1085
1073
|
F: __dxlog_file7,
|
|
1086
|
-
L:
|
|
1074
|
+
L: 352,
|
|
1087
1075
|
S: this,
|
|
1088
1076
|
A: [
|
|
1089
1077
|
"this._feedSetIterator",
|
|
@@ -1095,7 +1083,7 @@ var Pipeline = class {
|
|
|
1095
1083
|
}
|
|
1096
1084
|
const { done, value } = await iterable.next();
|
|
1097
1085
|
if (!done) {
|
|
1098
|
-
const block = value
|
|
1086
|
+
const block = value ?? failUndefined();
|
|
1099
1087
|
this._processingTrigger.reset();
|
|
1100
1088
|
this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
|
|
1101
1089
|
yield block;
|
|
@@ -1106,13 +1094,12 @@ var Pipeline = class {
|
|
|
1106
1094
|
this._isOpen = false;
|
|
1107
1095
|
}
|
|
1108
1096
|
_setFeedDownloadState(feed) {
|
|
1109
|
-
var _a;
|
|
1110
1097
|
const timeframe = this._state._startTimeframe;
|
|
1111
|
-
const seq =
|
|
1098
|
+
const seq = timeframe.get(feed.key) ?? 0;
|
|
1112
1099
|
feed.undownload({
|
|
1113
1100
|
callback: () => log6("undownload", void 0, {
|
|
1114
1101
|
F: __dxlog_file7,
|
|
1115
|
-
L:
|
|
1102
|
+
L: 377,
|
|
1116
1103
|
S: this,
|
|
1117
1104
|
C: (f, a) => f(...a)
|
|
1118
1105
|
})
|
|
@@ -1125,7 +1112,7 @@ var Pipeline = class {
|
|
|
1125
1112
|
err
|
|
1126
1113
|
}, {
|
|
1127
1114
|
F: __dxlog_file7,
|
|
1128
|
-
L:
|
|
1115
|
+
L: 379,
|
|
1129
1116
|
S: this,
|
|
1130
1117
|
C: (f, a) => f(...a)
|
|
1131
1118
|
});
|
|
@@ -1139,7 +1126,7 @@ var Pipeline = class {
|
|
|
1139
1126
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
1140
1127
|
log6.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
1141
1128
|
F: __dxlog_file7,
|
|
1142
|
-
L:
|
|
1129
|
+
L: 390,
|
|
1143
1130
|
S: this,
|
|
1144
1131
|
C: (f, a) => f(...a)
|
|
1145
1132
|
});
|
|
@@ -1231,7 +1218,7 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1231
1218
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1232
1219
|
challenge
|
|
1233
1220
|
});
|
|
1234
|
-
invariant7(
|
|
1221
|
+
invariant7(credential?.length > 0, "invalid credential", {
|
|
1235
1222
|
F: __dxlog_file8,
|
|
1236
1223
|
L: 69,
|
|
1237
1224
|
S: this,
|
|
@@ -1315,13 +1302,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1315
1302
|
return this._pipeline;
|
|
1316
1303
|
}
|
|
1317
1304
|
get pipelineState() {
|
|
1318
|
-
|
|
1319
|
-
return (_a = this._pipeline) == null ? void 0 : _a.state;
|
|
1305
|
+
return this._pipeline?.state;
|
|
1320
1306
|
}
|
|
1321
1307
|
setTargetTimeframe(timeframe) {
|
|
1322
|
-
var _a;
|
|
1323
1308
|
this._targetTimeframe = timeframe;
|
|
1324
|
-
|
|
1309
|
+
this._pipeline?.state.setTargetTimeframe(timeframe);
|
|
1325
1310
|
}
|
|
1326
1311
|
async processCredential(credential) {
|
|
1327
1312
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -1377,7 +1362,6 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1377
1362
|
this._isOpen = true;
|
|
1378
1363
|
}
|
|
1379
1364
|
async close() {
|
|
1380
|
-
var _a, _b, _c;
|
|
1381
1365
|
if (!this._isOpen) {
|
|
1382
1366
|
return;
|
|
1383
1367
|
}
|
|
@@ -1389,7 +1373,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1389
1373
|
});
|
|
1390
1374
|
this._isOpen = false;
|
|
1391
1375
|
await this._ctx.dispose();
|
|
1392
|
-
await
|
|
1376
|
+
await this._pipeline?.stop();
|
|
1393
1377
|
try {
|
|
1394
1378
|
await this._saveCache();
|
|
1395
1379
|
if (this._pipeline) {
|
|
@@ -1403,8 +1387,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1403
1387
|
C: (f, a) => f(...a)
|
|
1404
1388
|
});
|
|
1405
1389
|
}
|
|
1406
|
-
await
|
|
1407
|
-
await
|
|
1390
|
+
await this.databaseHost?.close();
|
|
1391
|
+
await this.itemManager?.destroy();
|
|
1408
1392
|
this._ctx = new Context4();
|
|
1409
1393
|
this._pipeline = void 0;
|
|
1410
1394
|
this._targetTimeframe = void 0;
|
|
@@ -1504,21 +1488,17 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1504
1488
|
};
|
|
1505
1489
|
}
|
|
1506
1490
|
async _saveTargetTimeframe(timeframe) {
|
|
1507
|
-
|
|
1508
|
-
const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
|
|
1491
|
+
const newTimeframe = Timeframe3.merge(this._targetTimeframe ?? new Timeframe3(), timeframe);
|
|
1509
1492
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1510
1493
|
this._targetTimeframe = newTimeframe;
|
|
1511
1494
|
}
|
|
1512
1495
|
async _saveCache() {
|
|
1513
|
-
var _a;
|
|
1514
1496
|
const cache = {};
|
|
1515
1497
|
try {
|
|
1516
|
-
const propertiesItem = this.itemManager.items.find((item) =>
|
|
1517
|
-
|
|
1518
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
|
|
1519
|
-
});
|
|
1498
|
+
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1499
|
+
(getStateMachineFromItem(item)?.snapshot()).type === "dxos.sdk.client.Properties");
|
|
1520
1500
|
if (propertiesItem) {
|
|
1521
|
-
cache.properties =
|
|
1501
|
+
cache.properties = getStateMachineFromItem(propertiesItem)?.snapshot();
|
|
1522
1502
|
}
|
|
1523
1503
|
} catch (err) {
|
|
1524
1504
|
log8.warn("Failed to cache properties", err, {
|
|
@@ -1540,11 +1520,10 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1540
1520
|
}
|
|
1541
1521
|
}
|
|
1542
1522
|
async _processEpochInSeparateTask(epoch) {
|
|
1543
|
-
var _a;
|
|
1544
1523
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
1545
1524
|
return;
|
|
1546
1525
|
}
|
|
1547
|
-
await
|
|
1526
|
+
await this._epochCtx?.dispose();
|
|
1548
1527
|
const ctx = new Context4({
|
|
1549
1528
|
onError: (err) => {
|
|
1550
1529
|
if (err instanceof CancelledError) {
|
|
@@ -1692,6 +1671,7 @@ import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeak
|
|
|
1692
1671
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1693
1672
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1694
1673
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1674
|
+
import { trace } from "@dxos/tracing";
|
|
1695
1675
|
import { Callback as Callback2 } from "@dxos/util";
|
|
1696
1676
|
|
|
1697
1677
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
@@ -1825,9 +1805,8 @@ var ControlPipeline = class {
|
|
|
1825
1805
|
});
|
|
1826
1806
|
}
|
|
1827
1807
|
async _saveTargetTimeframe(timeframe) {
|
|
1828
|
-
var _a;
|
|
1829
1808
|
try {
|
|
1830
|
-
const newTimeframe = Timeframe4.merge(
|
|
1809
|
+
const newTimeframe = Timeframe4.merge(this._targetTimeframe ?? new Timeframe4(), timeframe);
|
|
1831
1810
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1832
1811
|
this._targetTimeframe = newTimeframe;
|
|
1833
1812
|
} catch (err) {
|
|
@@ -1861,7 +1840,7 @@ var Space = class Space2 {
|
|
|
1861
1840
|
this._isOpen = false;
|
|
1862
1841
|
invariant9(params.spaceKey && params.feedProvider, void 0, {
|
|
1863
1842
|
F: __dxlog_file11,
|
|
1864
|
-
L:
|
|
1843
|
+
L: 73,
|
|
1865
1844
|
S: this,
|
|
1866
1845
|
A: [
|
|
1867
1846
|
"params.spaceKey && params.feedProvider",
|
|
@@ -1903,7 +1882,7 @@ var Space = class Space2 {
|
|
|
1903
1882
|
credential
|
|
1904
1883
|
}, {
|
|
1905
1884
|
F: __dxlog_file11,
|
|
1906
|
-
L:
|
|
1885
|
+
L: 109,
|
|
1907
1886
|
S: this,
|
|
1908
1887
|
C: (f, a) => f(...a)
|
|
1909
1888
|
});
|
|
@@ -1945,12 +1924,10 @@ var Space = class Space2 {
|
|
|
1945
1924
|
return this._genesisFeedKey;
|
|
1946
1925
|
}
|
|
1947
1926
|
get controlFeedKey() {
|
|
1948
|
-
|
|
1949
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
1927
|
+
return this._controlFeed?.key;
|
|
1950
1928
|
}
|
|
1951
1929
|
get dataFeedKey() {
|
|
1952
|
-
|
|
1953
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
1930
|
+
return this._dataFeed?.key;
|
|
1954
1931
|
}
|
|
1955
1932
|
get spaceState() {
|
|
1956
1933
|
return this._controlPipeline.spaceState;
|
|
@@ -1970,7 +1947,7 @@ var Space = class Space2 {
|
|
|
1970
1947
|
setControlFeed(feed) {
|
|
1971
1948
|
invariant9(!this._controlFeed, "Control feed already set.", {
|
|
1972
1949
|
F: __dxlog_file11,
|
|
1973
|
-
L:
|
|
1950
|
+
L: 183,
|
|
1974
1951
|
S: this,
|
|
1975
1952
|
A: [
|
|
1976
1953
|
"!this._controlFeed",
|
|
@@ -1982,10 +1959,9 @@ var Space = class Space2 {
|
|
|
1982
1959
|
return this;
|
|
1983
1960
|
}
|
|
1984
1961
|
setDataFeed(feed) {
|
|
1985
|
-
var _a;
|
|
1986
1962
|
invariant9(!this._dataFeed, "Data feed already set.", {
|
|
1987
1963
|
F: __dxlog_file11,
|
|
1988
|
-
L:
|
|
1964
|
+
L: 190,
|
|
1989
1965
|
S: this,
|
|
1990
1966
|
A: [
|
|
1991
1967
|
"!this._dataFeed",
|
|
@@ -1993,7 +1969,7 @@ var Space = class Space2 {
|
|
|
1993
1969
|
]
|
|
1994
1970
|
});
|
|
1995
1971
|
this._dataFeed = feed;
|
|
1996
|
-
|
|
1972
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1997
1973
|
return this;
|
|
1998
1974
|
}
|
|
1999
1975
|
/**
|
|
@@ -2008,10 +1984,10 @@ var Space = class Space2 {
|
|
|
2008
1984
|
// getDataFeeds(): FeedInfo[] {
|
|
2009
1985
|
// return this._dataPipeline?.getFeeds();
|
|
2010
1986
|
// }
|
|
2011
|
-
async open() {
|
|
1987
|
+
async open(ctx) {
|
|
2012
1988
|
log10("opening...", void 0, {
|
|
2013
1989
|
F: __dxlog_file11,
|
|
2014
|
-
L:
|
|
1990
|
+
L: 212,
|
|
2015
1991
|
S: this,
|
|
2016
1992
|
C: (f, a) => f(...a)
|
|
2017
1993
|
});
|
|
@@ -2024,7 +2000,7 @@ var Space = class Space2 {
|
|
|
2024
2000
|
this._isOpen = true;
|
|
2025
2001
|
log10("opened", void 0, {
|
|
2026
2002
|
F: __dxlog_file11,
|
|
2027
|
-
L:
|
|
2003
|
+
L: 223,
|
|
2028
2004
|
S: this,
|
|
2029
2005
|
C: (f, a) => f(...a)
|
|
2030
2006
|
});
|
|
@@ -2034,7 +2010,7 @@ var Space = class Space2 {
|
|
|
2034
2010
|
key: this._key
|
|
2035
2011
|
}, {
|
|
2036
2012
|
F: __dxlog_file11,
|
|
2037
|
-
L:
|
|
2013
|
+
L: 228,
|
|
2038
2014
|
S: this,
|
|
2039
2015
|
C: (f, a) => f(...a)
|
|
2040
2016
|
});
|
|
@@ -2048,7 +2024,7 @@ var Space = class Space2 {
|
|
|
2048
2024
|
this._isOpen = false;
|
|
2049
2025
|
log10("closed", void 0, {
|
|
2050
2026
|
F: __dxlog_file11,
|
|
2051
|
-
L:
|
|
2027
|
+
L: 241,
|
|
2052
2028
|
S: this,
|
|
2053
2029
|
C: (f, a) => f(...a)
|
|
2054
2030
|
});
|
|
@@ -2056,13 +2032,13 @@ var Space = class Space2 {
|
|
|
2056
2032
|
async initializeDataPipeline() {
|
|
2057
2033
|
log10("initializeDataPipeline", void 0, {
|
|
2058
2034
|
F: __dxlog_file11,
|
|
2059
|
-
L:
|
|
2035
|
+
L: 246,
|
|
2060
2036
|
S: this,
|
|
2061
2037
|
C: (f, a) => f(...a)
|
|
2062
2038
|
});
|
|
2063
2039
|
invariant9(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2064
2040
|
F: __dxlog_file11,
|
|
2065
|
-
L:
|
|
2041
|
+
L: 247,
|
|
2066
2042
|
S: this,
|
|
2067
2043
|
A: [
|
|
2068
2044
|
"this._isOpen",
|
|
@@ -2076,7 +2052,8 @@ _ts_decorate6([
|
|
|
2076
2052
|
logInfo
|
|
2077
2053
|
], Space.prototype, "key", null);
|
|
2078
2054
|
_ts_decorate6([
|
|
2079
|
-
synchronized4
|
|
2055
|
+
synchronized4,
|
|
2056
|
+
trace.span()
|
|
2080
2057
|
], Space.prototype, "open", null);
|
|
2081
2058
|
_ts_decorate6([
|
|
2082
2059
|
synchronized4
|
|
@@ -2085,7 +2062,8 @@ _ts_decorate6([
|
|
|
2085
2062
|
synchronized4
|
|
2086
2063
|
], Space.prototype, "initializeDataPipeline", null);
|
|
2087
2064
|
Space = _ts_decorate6([
|
|
2088
|
-
trackLeaks3("open", "close")
|
|
2065
|
+
trackLeaks3("open", "close"),
|
|
2066
|
+
trace.resource()
|
|
2089
2067
|
], Space);
|
|
2090
2068
|
|
|
2091
2069
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
@@ -2256,7 +2234,6 @@ var SpaceProtocolSession = class {
|
|
|
2256
2234
|
provider: this._swarmIdentity.credentialProvider,
|
|
2257
2235
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
2258
2236
|
onAuthSuccess: () => {
|
|
2259
|
-
var _a;
|
|
2260
2237
|
log11("Peer authenticated", void 0, {
|
|
2261
2238
|
F: __dxlog_file12,
|
|
2262
2239
|
L: 236,
|
|
@@ -2264,12 +2241,11 @@ var SpaceProtocolSession = class {
|
|
|
2264
2241
|
C: (f, a) => f(...a)
|
|
2265
2242
|
});
|
|
2266
2243
|
this._authStatus = AuthStatus.SUCCESS;
|
|
2267
|
-
|
|
2244
|
+
this._onSessionAuth?.(this._teleport);
|
|
2268
2245
|
},
|
|
2269
2246
|
onAuthFailure: () => {
|
|
2270
|
-
var _a;
|
|
2271
2247
|
this._authStatus = AuthStatus.FAILURE;
|
|
2272
|
-
|
|
2248
|
+
this._onAuthFailure?.(this._teleport);
|
|
2273
2249
|
}
|
|
2274
2250
|
}));
|
|
2275
2251
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -2291,7 +2267,7 @@ import { synchronized as synchronized5, trackLeaks as trackLeaks4 } from "@dxos/
|
|
|
2291
2267
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
2292
2268
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2293
2269
|
import { log as log12 } from "@dxos/log";
|
|
2294
|
-
import { trace } from "@dxos/protocols";
|
|
2270
|
+
import { trace as trace2 } from "@dxos/protocols";
|
|
2295
2271
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
2296
2272
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
2297
2273
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -2327,8 +2303,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2327
2303
|
].map((space) => space.close()));
|
|
2328
2304
|
}
|
|
2329
2305
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2330
|
-
|
|
2331
|
-
log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
|
|
2306
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace2.begin({
|
|
2332
2307
|
id: this._instanceId
|
|
2333
2308
|
}), {
|
|
2334
2309
|
F: __dxlog_file13,
|
|
@@ -2344,7 +2319,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2344
2319
|
S: this,
|
|
2345
2320
|
C: (f, a) => f(...a)
|
|
2346
2321
|
});
|
|
2347
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2322
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
|
|
2348
2323
|
const spaceKey = metadata.key;
|
|
2349
2324
|
const protocol = new SpaceProtocol({
|
|
2350
2325
|
topic: spaceKey,
|
|
@@ -2366,7 +2341,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2366
2341
|
memberKey
|
|
2367
2342
|
});
|
|
2368
2343
|
this._spaces.set(space.key, space);
|
|
2369
|
-
log12.trace("dxos.echo.space-manager.construct-space",
|
|
2344
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace2.end({
|
|
2370
2345
|
id: this._instanceId
|
|
2371
2346
|
}), {
|
|
2372
2347
|
F: __dxlog_file13,
|
|
@@ -2413,4 +2388,4 @@ export {
|
|
|
2413
2388
|
SpaceProtocolSession,
|
|
2414
2389
|
SpaceManager
|
|
2415
2390
|
};
|
|
2416
|
-
//# sourceMappingURL=chunk-
|
|
2391
|
+
//# sourceMappingURL=chunk-3OTHGQEY.mjs.map
|