@dxos/echo-pipeline 0.8.2-main.f081794 → 0.8.2-main.fbd8ed0
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-32WDI3LB.mjs → chunk-TPEBUDNJ.mjs} +9 -9
- package/dist/lib/browser/{chunk-32WDI3LB.mjs.map → chunk-TPEBUDNJ.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +157 -156
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +11 -12
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-TC2PRBEU.cjs → chunk-QD3U65NM.cjs} +12 -12
- package/dist/lib/node/{chunk-TC2PRBEU.cjs.map → chunk-QD3U65NM.cjs.map} +2 -2
- package/dist/lib/node/index.cjs +182 -180
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +20 -21
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/{chunk-UKOLB3LW.mjs → chunk-S5YERQ4D.mjs} +9 -9
- package/dist/lib/node-esm/{chunk-UKOLB3LW.mjs.map → chunk-S5YERQ4D.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +157 -156
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +11 -12
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/automerge/automerge-host.d.ts +5 -2
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts +1 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-data-monitor.d.ts +6 -6
- package/dist/types/src/automerge/echo-data-monitor.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +4 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/heads-store.d.ts +2 -2
- package/dist/types/src/automerge/heads-store.d.ts.map +1 -1
- package/dist/types/src/automerge/leveldb-storage-adapter.d.ts +1 -1
- package/dist/types/src/automerge/leveldb-storage-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts.map +1 -1
- package/dist/types/src/automerge/network-protocol.d.ts +1 -1
- package/dist/types/src/automerge/network-protocol.d.ts.map +1 -1
- package/dist/types/src/automerge/space-collection.d.ts +1 -1
- package/dist/types/src/automerge/space-collection.d.ts.map +1 -1
- package/dist/types/src/common/feeds.d.ts.map +1 -1
- package/dist/types/src/common/space-id.d.ts.map +1 -1
- package/dist/types/src/db-host/automerge-metrics.d.ts +1 -1
- package/dist/types/src/db-host/automerge-metrics.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/database-root.d.ts +3 -3
- package/dist/types/src/db-host/database-root.d.ts.map +1 -1
- package/dist/types/src/db-host/documents-iterator.d.ts.map +1 -1
- package/dist/types/src/db-host/documents-synchronizer.d.ts +2 -2
- package/dist/types/src/db-host/documents-synchronizer.d.ts.map +1 -1
- package/dist/types/src/db-host/echo-host.d.ts +1 -1
- package/dist/types/src/db-host/echo-host.d.ts.map +1 -1
- package/dist/types/src/db-host/query-service.d.ts.map +1 -1
- package/dist/types/src/db-host/query-state.d.ts.map +1 -1
- package/dist/types/src/db-host/space-state-manager.d.ts +1 -1
- package/dist/types/src/db-host/space-state-manager.d.ts.map +1 -1
- package/dist/types/src/edge/echo-edge-replicator.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/timeframe-clock.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/testing/change-metadata.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-network-adapter.d.ts +3 -2
- package/dist/types/src/testing/test-network-adapter.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +35 -34
- package/src/automerge/automerge-host.test.ts +7 -7
- package/src/automerge/automerge-host.ts +30 -23
- package/src/automerge/automerge-repo.test.ts +65 -65
- package/src/automerge/collection-synchronizer.test.ts +1 -1
- package/src/automerge/collection-synchronizer.ts +3 -2
- package/src/automerge/echo-data-monitor.ts +9 -8
- package/src/automerge/echo-network-adapter.test.ts +1 -1
- package/src/automerge/echo-network-adapter.ts +13 -6
- package/src/automerge/heads-store.ts +3 -2
- package/src/automerge/leveldb-storage-adapter.ts +1 -1
- package/src/automerge/mesh-echo-replicator-connection.ts +3 -2
- package/src/automerge/network-protocol.ts +2 -1
- package/src/automerge/space-collection.ts +2 -1
- package/src/db-host/automerge-metrics.ts +2 -1
- package/src/db-host/data-service.ts +2 -1
- package/src/db-host/database-root.ts +12 -16
- package/src/db-host/documents-iterator.ts +4 -3
- package/src/db-host/documents-synchronizer.test.ts +2 -2
- package/src/db-host/documents-synchronizer.ts +11 -9
- package/src/db-host/echo-host.ts +6 -3
- package/src/db-host/query-service.ts +6 -5
- package/src/db-host/query-state.ts +20 -13
- package/src/db-host/space-state-manager.ts +1 -1
- package/src/edge/echo-edge-replicator.test.ts +3 -3
- package/src/edge/echo-edge-replicator.ts +2 -1
- package/src/space/space-manager.ts +2 -1
- package/src/testing/test-network-adapter.ts +8 -5
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
mapTimeframeToFeedIndexes,
|
|
22
22
|
startAfter,
|
|
23
23
|
valueEncoding
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-TPEBUDNJ.mjs";
|
|
25
25
|
|
|
26
26
|
// packages/core/echo/echo-pipeline/src/db-host/data-service.ts
|
|
27
27
|
import { UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
|
|
@@ -31,8 +31,8 @@ import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
|
31
31
|
import { log as log7 } from "@dxos/log";
|
|
32
32
|
|
|
33
33
|
// packages/core/echo/echo-pipeline/src/db-host/documents-synchronizer.ts
|
|
34
|
+
import { next as A } from "@automerge/automerge";
|
|
34
35
|
import { UpdateScheduler } from "@dxos/async";
|
|
35
|
-
import { next as A } from "@dxos/automerge/automerge";
|
|
36
36
|
import { Resource } from "@dxos/context";
|
|
37
37
|
import { invariant } from "@dxos/invariant";
|
|
38
38
|
import { log } from "@dxos/log";
|
|
@@ -52,15 +52,15 @@ var DocumentsSynchronizer = class extends Resource {
|
|
|
52
52
|
documentIds
|
|
53
53
|
}, {
|
|
54
54
|
F: __dxlog_file,
|
|
55
|
-
L:
|
|
55
|
+
L: 50,
|
|
56
56
|
S: this,
|
|
57
57
|
C: (f, a) => f(...a)
|
|
58
58
|
});
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
for (const documentId of documentIds) {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
this._params.repo.find(documentId).then(async (doc) => {
|
|
63
|
+
await doc.whenReady();
|
|
64
64
|
this._startSync(doc);
|
|
65
65
|
this._pendingUpdates.add(doc.documentId);
|
|
66
66
|
this._sendUpdatesJob.trigger();
|
|
@@ -70,7 +70,7 @@ var DocumentsSynchronizer = class extends Resource {
|
|
|
70
70
|
error
|
|
71
71
|
}, {
|
|
72
72
|
F: __dxlog_file,
|
|
73
|
-
L:
|
|
73
|
+
L: 64,
|
|
74
74
|
S: this,
|
|
75
75
|
C: (f, a) => f(...a)
|
|
76
76
|
});
|
|
@@ -99,7 +99,7 @@ var DocumentsSynchronizer = class extends Resource {
|
|
|
99
99
|
update(updates) {
|
|
100
100
|
for (const { documentId, mutation, isNew } of updates) {
|
|
101
101
|
if (isNew) {
|
|
102
|
-
const doc = this._params.repo.
|
|
102
|
+
const { handle: doc } = this._params.repo.findWithProgress(documentId);
|
|
103
103
|
doc.update((doc2) => A.loadIncremental(doc2, mutation));
|
|
104
104
|
this._startSync(doc);
|
|
105
105
|
} else {
|
|
@@ -113,7 +113,7 @@ var DocumentsSynchronizer = class extends Resource {
|
|
|
113
113
|
documentId: doc.documentId
|
|
114
114
|
}, {
|
|
115
115
|
F: __dxlog_file,
|
|
116
|
-
L:
|
|
116
|
+
L: 103,
|
|
117
117
|
S: this,
|
|
118
118
|
C: (f, a) => f(...a)
|
|
119
119
|
});
|
|
@@ -156,17 +156,18 @@ var DocumentsSynchronizer = class extends Resource {
|
|
|
156
156
|
const syncState = this._syncStates.get(documentId);
|
|
157
157
|
invariant(syncState, "Sync state for document not found", {
|
|
158
158
|
F: __dxlog_file,
|
|
159
|
-
L:
|
|
159
|
+
L: 144,
|
|
160
160
|
S: this,
|
|
161
161
|
A: [
|
|
162
162
|
"syncState",
|
|
163
163
|
"'Sync state for document not found'"
|
|
164
164
|
]
|
|
165
165
|
});
|
|
166
|
-
const
|
|
167
|
-
if (!doc) {
|
|
166
|
+
const handle = syncState.handle;
|
|
167
|
+
if (!handle || !handle.isReady() || !handle.doc()) {
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
|
+
const doc = handle.doc();
|
|
170
171
|
const mutation = syncState.lastSentHead ? A.saveSince(doc, syncState.lastSentHead) : A.save(doc);
|
|
171
172
|
if (mutation.length === 0) {
|
|
172
173
|
return;
|
|
@@ -178,7 +179,7 @@ var DocumentsSynchronizer = class extends Resource {
|
|
|
178
179
|
const syncState = this._syncStates.get(documentId);
|
|
179
180
|
invariant(syncState, "Sync state for document not found", {
|
|
180
181
|
F: __dxlog_file,
|
|
181
|
-
L:
|
|
182
|
+
L: 160,
|
|
182
183
|
S: this,
|
|
183
184
|
A: [
|
|
184
185
|
"syncState",
|
|
@@ -197,9 +198,9 @@ var DocumentsSynchronizer = class extends Resource {
|
|
|
197
198
|
};
|
|
198
199
|
|
|
199
200
|
// packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts
|
|
201
|
+
import { getBackend, getHeads, isAutomerge, equals as headsEquals, save } from "@automerge/automerge";
|
|
202
|
+
import { Repo, interpretAsDocumentId } from "@automerge/automerge-repo";
|
|
200
203
|
import { Event as Event2, asyncTimeout } from "@dxos/async";
|
|
201
|
-
import { getBackend, getHeads, isAutomerge, equals as headsEquals, save } from "@dxos/automerge/automerge";
|
|
202
|
-
import { Repo, interpretAsDocumentId } from "@dxos/automerge/automerge-repo";
|
|
203
204
|
import { Context, Resource as Resource4, cancelWithContext } from "@dxos/context";
|
|
204
205
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
205
206
|
import { PublicKey } from "@dxos/keys";
|
|
@@ -209,8 +210,8 @@ import { trace as trace2 } from "@dxos/tracing";
|
|
|
209
210
|
import { bufferToArray } from "@dxos/util";
|
|
210
211
|
|
|
211
212
|
// packages/core/echo/echo-pipeline/src/automerge/collection-synchronizer.ts
|
|
213
|
+
import { next as am } from "@automerge/automerge";
|
|
212
214
|
import { asyncReturn, Event, scheduleTask, scheduleTaskInterval } from "@dxos/async";
|
|
213
|
-
import { next as am } from "@dxos/automerge/automerge";
|
|
214
215
|
import { Resource as Resource2 } from "@dxos/context";
|
|
215
216
|
import { log as log2 } from "@dxos/log";
|
|
216
217
|
import { trace } from "@dxos/tracing";
|
|
@@ -263,7 +264,7 @@ var CollectionSynchronizer = class extends Resource2 {
|
|
|
263
264
|
state
|
|
264
265
|
}, {
|
|
265
266
|
F: __dxlog_file2,
|
|
266
|
-
L:
|
|
267
|
+
L: 76,
|
|
267
268
|
S: this,
|
|
268
269
|
C: (f, a) => f(...a)
|
|
269
270
|
});
|
|
@@ -282,7 +283,7 @@ var CollectionSynchronizer = class extends Resource2 {
|
|
|
282
283
|
collectionId
|
|
283
284
|
}, {
|
|
284
285
|
F: __dxlog_file2,
|
|
285
|
-
L:
|
|
286
|
+
L: 90,
|
|
286
287
|
S: this,
|
|
287
288
|
C: (f, a) => f(...a)
|
|
288
289
|
});
|
|
@@ -365,7 +366,7 @@ var CollectionSynchronizer = class extends Resource2 {
|
|
|
365
366
|
state
|
|
366
367
|
}, {
|
|
367
368
|
F: __dxlog_file2,
|
|
368
|
-
L:
|
|
369
|
+
L: 171,
|
|
369
370
|
S: this,
|
|
370
371
|
C: (f, a) => f(...a)
|
|
371
372
|
});
|
|
@@ -461,8 +462,8 @@ var getSpanName = (peerId) => {
|
|
|
461
462
|
};
|
|
462
463
|
|
|
463
464
|
// packages/core/echo/echo-pipeline/src/automerge/echo-network-adapter.ts
|
|
465
|
+
import { NetworkAdapter } from "@automerge/automerge-repo";
|
|
464
466
|
import { synchronized, Trigger } from "@dxos/async";
|
|
465
|
-
import { NetworkAdapter } from "@dxos/automerge/automerge-repo";
|
|
466
467
|
import { LifecycleState } from "@dxos/context";
|
|
467
468
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
468
469
|
import { log as log3 } from "@dxos/log";
|
|
@@ -489,6 +490,13 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
489
490
|
this._connections = /* @__PURE__ */ new Map();
|
|
490
491
|
this._lifecycleState = LifecycleState.CLOSED;
|
|
491
492
|
this._connected = new Trigger();
|
|
493
|
+
this._ready = new Trigger();
|
|
494
|
+
}
|
|
495
|
+
isReady() {
|
|
496
|
+
return this._lifecycleState === LifecycleState.OPEN;
|
|
497
|
+
}
|
|
498
|
+
whenReady() {
|
|
499
|
+
return this._ready.wait();
|
|
492
500
|
}
|
|
493
501
|
connect(peerId, peerMetadata) {
|
|
494
502
|
this.peerId = peerId;
|
|
@@ -505,15 +513,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
505
513
|
return;
|
|
506
514
|
}
|
|
507
515
|
this._lifecycleState = LifecycleState.OPEN;
|
|
508
|
-
|
|
509
|
-
F: __dxlog_file3,
|
|
510
|
-
L: 82,
|
|
511
|
-
S: this,
|
|
512
|
-
C: (f, a) => f(...a)
|
|
513
|
-
});
|
|
514
|
-
this.emit("ready", {
|
|
515
|
-
network: this
|
|
516
|
-
});
|
|
516
|
+
this._ready.wake();
|
|
517
517
|
}
|
|
518
518
|
async close() {
|
|
519
519
|
if (this._lifecycleState === LifecycleState.CLOSED) {
|
|
@@ -523,6 +523,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
523
523
|
await replicator.disconnect();
|
|
524
524
|
}
|
|
525
525
|
this._replicators.clear();
|
|
526
|
+
this._ready.reset();
|
|
526
527
|
this._lifecycleState = LifecycleState.CLOSED;
|
|
527
528
|
}
|
|
528
529
|
async whenConnected() {
|
|
@@ -533,7 +534,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
533
534
|
async addReplicator(replicator) {
|
|
534
535
|
invariant2(this._lifecycleState === LifecycleState.OPEN, void 0, {
|
|
535
536
|
F: __dxlog_file3,
|
|
536
|
-
L:
|
|
537
|
+
L: 115,
|
|
537
538
|
S: this,
|
|
538
539
|
A: [
|
|
539
540
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -542,7 +543,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
542
543
|
});
|
|
543
544
|
invariant2(this.peerId, void 0, {
|
|
544
545
|
F: __dxlog_file3,
|
|
545
|
-
L:
|
|
546
|
+
L: 116,
|
|
546
547
|
S: this,
|
|
547
548
|
A: [
|
|
548
549
|
"this.peerId",
|
|
@@ -551,7 +552,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
551
552
|
});
|
|
552
553
|
invariant2(!this._replicators.has(replicator), void 0, {
|
|
553
554
|
F: __dxlog_file3,
|
|
554
|
-
L:
|
|
555
|
+
L: 117,
|
|
555
556
|
S: this,
|
|
556
557
|
A: [
|
|
557
558
|
"!this._replicators.has(replicator)",
|
|
@@ -575,7 +576,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
575
576
|
async removeReplicator(replicator) {
|
|
576
577
|
invariant2(this._lifecycleState === LifecycleState.OPEN, void 0, {
|
|
577
578
|
F: __dxlog_file3,
|
|
578
|
-
L:
|
|
579
|
+
L: 136,
|
|
579
580
|
S: this,
|
|
580
581
|
A: [
|
|
581
582
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -584,7 +585,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
584
585
|
});
|
|
585
586
|
invariant2(this._replicators.has(replicator), void 0, {
|
|
586
587
|
F: __dxlog_file3,
|
|
587
|
-
L:
|
|
588
|
+
L: 137,
|
|
588
589
|
S: this,
|
|
589
590
|
A: [
|
|
590
591
|
"this._replicators.has(replicator)",
|
|
@@ -640,7 +641,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
640
641
|
if (connectionEntry.isOpen) {
|
|
641
642
|
log3.catch(err, void 0, {
|
|
642
643
|
F: __dxlog_file3,
|
|
643
|
-
L:
|
|
644
|
+
L: 197,
|
|
644
645
|
S: this,
|
|
645
646
|
C: (f, a) => f(...a)
|
|
646
647
|
});
|
|
@@ -661,13 +662,13 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
661
662
|
peerId: connection.peerId
|
|
662
663
|
}, {
|
|
663
664
|
F: __dxlog_file3,
|
|
664
|
-
L:
|
|
665
|
+
L: 215,
|
|
665
666
|
S: this,
|
|
666
667
|
C: (f, a) => f(...a)
|
|
667
668
|
});
|
|
668
669
|
invariant2(!this._connections.has(connection.peerId), void 0, {
|
|
669
670
|
F: __dxlog_file3,
|
|
670
|
-
L:
|
|
671
|
+
L: 216,
|
|
671
672
|
S: this,
|
|
672
673
|
A: [
|
|
673
674
|
"!this._connections.has(connection.peerId as PeerId)",
|
|
@@ -696,7 +697,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
696
697
|
if (connectionEntry.isOpen) {
|
|
697
698
|
log3.catch(err, void 0, {
|
|
698
699
|
F: __dxlog_file3,
|
|
699
|
-
L:
|
|
700
|
+
L: 235,
|
|
700
701
|
S: this,
|
|
701
702
|
C: (f, a) => f(...a)
|
|
702
703
|
});
|
|
@@ -707,7 +708,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
707
708
|
peerId: connection.peerId
|
|
708
709
|
}, {
|
|
709
710
|
F: __dxlog_file3,
|
|
710
|
-
L:
|
|
711
|
+
L: 240,
|
|
711
712
|
S: this,
|
|
712
713
|
C: (f, a) => f(...a)
|
|
713
714
|
});
|
|
@@ -739,14 +740,14 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
739
740
|
peerId: connection.peerId
|
|
740
741
|
}, {
|
|
741
742
|
F: __dxlog_file3,
|
|
742
|
-
L:
|
|
743
|
+
L: 268,
|
|
743
744
|
S: this,
|
|
744
745
|
C: (f, a) => f(...a)
|
|
745
746
|
});
|
|
746
747
|
const entry = this._connections.get(connection.peerId);
|
|
747
748
|
invariant2(entry, void 0, {
|
|
748
749
|
F: __dxlog_file3,
|
|
749
|
-
L:
|
|
750
|
+
L: 270,
|
|
750
751
|
S: this,
|
|
751
752
|
A: [
|
|
752
753
|
"entry",
|
|
@@ -763,14 +764,14 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
763
764
|
peerId: connection.peerId
|
|
764
765
|
}, {
|
|
765
766
|
F: __dxlog_file3,
|
|
766
|
-
L:
|
|
767
|
+
L: 276,
|
|
767
768
|
S: this,
|
|
768
769
|
C: (f, a) => f(...a)
|
|
769
770
|
});
|
|
770
771
|
const entry = this._connections.get(connection.peerId);
|
|
771
772
|
invariant2(entry, void 0, {
|
|
772
773
|
F: __dxlog_file3,
|
|
773
|
-
L:
|
|
774
|
+
L: 278,
|
|
774
775
|
S: this,
|
|
775
776
|
A: [
|
|
776
777
|
"entry",
|
|
@@ -784,13 +785,13 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
784
785
|
this._params.monitor?.recordPeerDisconnected(connection.peerId);
|
|
785
786
|
void entry.reader.cancel().catch((err) => log3.catch(err, void 0, {
|
|
786
787
|
F: __dxlog_file3,
|
|
787
|
-
L:
|
|
788
|
+
L: 284,
|
|
788
789
|
S: this,
|
|
789
790
|
C: (f, a) => f(...a)
|
|
790
791
|
}));
|
|
791
792
|
void entry.writer.abort().catch((err) => log3.catch(err, void 0, {
|
|
792
793
|
F: __dxlog_file3,
|
|
793
|
-
L:
|
|
794
|
+
L: 285,
|
|
794
795
|
S: this,
|
|
795
796
|
C: (f, a) => f(...a)
|
|
796
797
|
}));
|
|
@@ -957,6 +958,12 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
957
958
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
958
959
|
}
|
|
959
960
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
961
|
+
var FIND_PARAMS = {
|
|
962
|
+
allowableStates: [
|
|
963
|
+
"ready",
|
|
964
|
+
"requesting"
|
|
965
|
+
]
|
|
966
|
+
};
|
|
960
967
|
var AutomergeHost = class extends Resource4 {
|
|
961
968
|
constructor({ db, indexMetadataStore, dataMonitor, peerIdProvider, getSpaceKeyByRootDocumentId }) {
|
|
962
969
|
super();
|
|
@@ -1056,7 +1063,7 @@ var AutomergeHost = class extends Resource4 {
|
|
|
1056
1063
|
handle = this._repo.handles[documentId];
|
|
1057
1064
|
}
|
|
1058
1065
|
if (!handle) {
|
|
1059
|
-
handle = this._repo.find(documentId);
|
|
1066
|
+
handle = await this._repo.find(documentId, FIND_PARAMS);
|
|
1060
1067
|
}
|
|
1061
1068
|
if (!handle.isReady()) {
|
|
1062
1069
|
if (!opts?.timeout) {
|
|
@@ -1112,12 +1119,12 @@ var AutomergeHost = class extends Resource4 {
|
|
|
1112
1119
|
await Promise.all(headsToWait.map(async (entry, index) => {
|
|
1113
1120
|
const handle = await this.loadDoc(Context.default(void 0, {
|
|
1114
1121
|
F: __dxlog_file4,
|
|
1115
|
-
L:
|
|
1122
|
+
L: 288
|
|
1116
1123
|
}), entry.documentId);
|
|
1117
1124
|
await waitForHeads(handle, entry.heads);
|
|
1118
1125
|
}));
|
|
1119
1126
|
}
|
|
1120
|
-
await this._repo.flush(documentIds.filter((documentId) =>
|
|
1127
|
+
await this._repo.flush(documentIds.filter((documentId) => this._repo.handles[documentId] && this._repo.handles[documentId].isReady()));
|
|
1121
1128
|
}
|
|
1122
1129
|
async reIndexHeads(documentIds) {
|
|
1123
1130
|
for (const documentId of documentIds) {
|
|
@@ -1125,46 +1132,30 @@ var AutomergeHost = class extends Resource4 {
|
|
|
1125
1132
|
documentId
|
|
1126
1133
|
}, {
|
|
1127
1134
|
F: __dxlog_file4,
|
|
1128
|
-
L:
|
|
1135
|
+
L: 302,
|
|
1129
1136
|
S: this,
|
|
1130
1137
|
C: (f, a) => f(...a)
|
|
1131
1138
|
});
|
|
1132
|
-
const handle = this._repo.find(documentId);
|
|
1133
|
-
|
|
1134
|
-
"ready",
|
|
1135
|
-
"requesting"
|
|
1136
|
-
]);
|
|
1137
|
-
if (handle.inState([
|
|
1138
|
-
"requesting"
|
|
1139
|
-
])) {
|
|
1139
|
+
const handle = await this._repo.find(documentId, FIND_PARAMS);
|
|
1140
|
+
if (!handle.isReady()) {
|
|
1140
1141
|
log4.warn("document is not available locally, skipping", {
|
|
1141
1142
|
documentId
|
|
1142
1143
|
}, {
|
|
1143
1144
|
F: __dxlog_file4,
|
|
1144
|
-
L:
|
|
1145
|
+
L: 305,
|
|
1145
1146
|
S: this,
|
|
1146
1147
|
C: (f, a) => f(...a)
|
|
1147
1148
|
});
|
|
1148
1149
|
continue;
|
|
1149
1150
|
}
|
|
1150
|
-
const
|
|
1151
|
-
invariant3(doc, void 0, {
|
|
1152
|
-
F: __dxlog_file4,
|
|
1153
|
-
L: 303,
|
|
1154
|
-
S: this,
|
|
1155
|
-
A: [
|
|
1156
|
-
"doc",
|
|
1157
|
-
""
|
|
1158
|
-
]
|
|
1159
|
-
});
|
|
1160
|
-
const heads = getHeads(doc);
|
|
1151
|
+
const heads = handle.heads();
|
|
1161
1152
|
const batch = this._db.batch();
|
|
1162
1153
|
this._headsStore.setHeads(documentId, heads, batch);
|
|
1163
1154
|
await batch.write();
|
|
1164
1155
|
}
|
|
1165
1156
|
log4.info("done re-indexing heads", void 0, {
|
|
1166
1157
|
F: __dxlog_file4,
|
|
1167
|
-
L:
|
|
1158
|
+
L: 314,
|
|
1168
1159
|
S: this,
|
|
1169
1160
|
C: (f, a) => f(...a)
|
|
1170
1161
|
});
|
|
@@ -1190,10 +1181,10 @@ var AutomergeHost = class extends Resource4 {
|
|
|
1190
1181
|
}
|
|
1191
1182
|
async _beforeSave({ path, batch }) {
|
|
1192
1183
|
const handle = this._repo.handles[path[0]];
|
|
1193
|
-
if (!handle) {
|
|
1184
|
+
if (!handle || !handle.isReady()) {
|
|
1194
1185
|
return;
|
|
1195
1186
|
}
|
|
1196
|
-
const doc = handle.
|
|
1187
|
+
const doc = handle.doc();
|
|
1197
1188
|
if (!doc) {
|
|
1198
1189
|
return;
|
|
1199
1190
|
}
|
|
@@ -1227,7 +1218,7 @@ var AutomergeHost = class extends Resource4 {
|
|
|
1227
1218
|
async _afterSave(path) {
|
|
1228
1219
|
this._indexMetadataStore.notifyMarkedDirty();
|
|
1229
1220
|
const documentId = path[0];
|
|
1230
|
-
const document = this._repo.handles[documentId]?.
|
|
1221
|
+
const document = this._repo.handles[documentId]?.doc();
|
|
1231
1222
|
if (document) {
|
|
1232
1223
|
const heads = getHeads(document);
|
|
1233
1224
|
this._onHeadsChanged(documentId, heads);
|
|
@@ -1247,9 +1238,12 @@ var AutomergeHost = class extends Resource4 {
|
|
|
1247
1238
|
return false;
|
|
1248
1239
|
}
|
|
1249
1240
|
async _getContainingSpaceForDocument(documentId) {
|
|
1250
|
-
const
|
|
1251
|
-
if (
|
|
1252
|
-
|
|
1241
|
+
const handle = this._repo.handles[documentId];
|
|
1242
|
+
if (handle.state === "loading") {
|
|
1243
|
+
await handle.whenReady();
|
|
1244
|
+
}
|
|
1245
|
+
if (handle && handle.isReady() && handle.doc()) {
|
|
1246
|
+
const spaceKeyHex = getSpaceKeyFromDoc(handle.doc());
|
|
1253
1247
|
if (spaceKeyHex) {
|
|
1254
1248
|
return PublicKey.from(spaceKeyHex);
|
|
1255
1249
|
}
|
|
@@ -1272,9 +1266,9 @@ var AutomergeHost = class extends Resource4 {
|
|
|
1272
1266
|
const storeRequestIds = [];
|
|
1273
1267
|
const storeResultIndices = [];
|
|
1274
1268
|
for (const documentId of documentIds) {
|
|
1275
|
-
const
|
|
1276
|
-
if (doc) {
|
|
1277
|
-
result.push(getHeads(doc));
|
|
1269
|
+
const handle = this._repo.handles[documentId];
|
|
1270
|
+
if (handle && handle.isReady() && handle.doc()) {
|
|
1271
|
+
result.push(getHeads(handle.doc()));
|
|
1278
1272
|
} else {
|
|
1279
1273
|
storeRequestIds.push(documentId);
|
|
1280
1274
|
storeResultIndices.push(result.length);
|
|
@@ -1379,12 +1373,12 @@ var AutomergeHost = class extends Resource4 {
|
|
|
1379
1373
|
count: toReplicate.length
|
|
1380
1374
|
}, {
|
|
1381
1375
|
F: __dxlog_file4,
|
|
1382
|
-
L:
|
|
1376
|
+
L: 556,
|
|
1383
1377
|
S: this,
|
|
1384
1378
|
C: (f, a) => f(...a)
|
|
1385
1379
|
});
|
|
1386
1380
|
for (const documentId of toReplicate) {
|
|
1387
|
-
this._repo.
|
|
1381
|
+
this._repo.findWithProgress(documentId);
|
|
1388
1382
|
}
|
|
1389
1383
|
}
|
|
1390
1384
|
_onHeadsChanged(documentId, heads) {
|
|
@@ -1433,7 +1427,7 @@ var waitForHeads = async (handle, heads) => {
|
|
|
1433
1427
|
await handle.whenReady();
|
|
1434
1428
|
await Event2.wrap(handle, "change").waitForCondition(() => {
|
|
1435
1429
|
for (const changeHash of unavailableHeads.values()) {
|
|
1436
|
-
if (changeIsPresentInDoc(handle.
|
|
1430
|
+
if (changeIsPresentInDoc(handle.doc(), changeHash)) {
|
|
1437
1431
|
unavailableHeads.delete(changeHash);
|
|
1438
1432
|
}
|
|
1439
1433
|
}
|
|
@@ -1446,7 +1440,7 @@ var changeIsPresentInDoc = (doc, changeHash) => {
|
|
|
1446
1440
|
var decodeCollectionState = (state) => {
|
|
1447
1441
|
invariant3(typeof state === "object" && state !== null, "Invalid state", {
|
|
1448
1442
|
F: __dxlog_file4,
|
|
1449
|
-
L:
|
|
1443
|
+
L: 617,
|
|
1450
1444
|
S: void 0,
|
|
1451
1445
|
A: [
|
|
1452
1446
|
"typeof state === 'object' && state !== null",
|
|
@@ -1466,8 +1460,8 @@ import { log as log6 } from "@dxos/log";
|
|
|
1466
1460
|
import { ComplexSet, defaultMap as defaultMap2 } from "@dxos/util";
|
|
1467
1461
|
|
|
1468
1462
|
// packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator-connection.ts
|
|
1469
|
-
import * as A2 from "@
|
|
1470
|
-
import { cbor } from "@
|
|
1463
|
+
import * as A2 from "@automerge/automerge";
|
|
1464
|
+
import { cbor } from "@automerge/automerge-repo";
|
|
1471
1465
|
import { Resource as Resource5 } from "@dxos/context";
|
|
1472
1466
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1473
1467
|
import { log as log5 } from "@dxos/log";
|
|
@@ -1492,7 +1486,7 @@ var MeshReplicatorConnection = class extends Resource5 {
|
|
|
1492
1486
|
write: async (message, controller) => {
|
|
1493
1487
|
invariant4(this._isEnabled, "Writing to a disabled connection", {
|
|
1494
1488
|
F: __dxlog_file5,
|
|
1495
|
-
L:
|
|
1489
|
+
L: 51,
|
|
1496
1490
|
S: this,
|
|
1497
1491
|
A: [
|
|
1498
1492
|
"this._isEnabled",
|
|
@@ -1525,7 +1519,7 @@ var MeshReplicatorConnection = class extends Resource5 {
|
|
|
1525
1519
|
remotePeerId: remotePeerId.toHex()
|
|
1526
1520
|
}, {
|
|
1527
1521
|
F: __dxlog_file5,
|
|
1528
|
-
L:
|
|
1522
|
+
L: 80,
|
|
1529
1523
|
S: this,
|
|
1530
1524
|
C: (f, a) => f(...a)
|
|
1531
1525
|
});
|
|
@@ -1552,7 +1546,7 @@ var MeshReplicatorConnection = class extends Resource5 {
|
|
|
1552
1546
|
get peerId() {
|
|
1553
1547
|
invariant4(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1554
1548
|
F: __dxlog_file5,
|
|
1555
|
-
L:
|
|
1549
|
+
L: 106,
|
|
1556
1550
|
S: this,
|
|
1557
1551
|
A: [
|
|
1558
1552
|
"this._remotePeerId != null",
|
|
@@ -1577,7 +1571,7 @@ var MeshReplicatorConnection = class extends Resource5 {
|
|
|
1577
1571
|
enable() {
|
|
1578
1572
|
invariant4(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1579
1573
|
F: __dxlog_file5,
|
|
1580
|
-
L:
|
|
1574
|
+
L: 127,
|
|
1581
1575
|
S: this,
|
|
1582
1576
|
A: [
|
|
1583
1577
|
"this._remotePeerId != null",
|
|
@@ -1608,7 +1602,7 @@ var logSendSync = (message) => {
|
|
|
1608
1602
|
};
|
|
1609
1603
|
}, {
|
|
1610
1604
|
F: __dxlog_file5,
|
|
1611
|
-
L:
|
|
1605
|
+
L: 140,
|
|
1612
1606
|
S: void 0,
|
|
1613
1607
|
C: (f, a) => f(...a)
|
|
1614
1608
|
});
|
|
@@ -1623,7 +1617,7 @@ var getSpaceIdFromCollectionId = (collectionId) => {
|
|
|
1623
1617
|
const spaceId = collectionId.split(":")[1];
|
|
1624
1618
|
invariant5(SpaceId.isValid(spaceId), void 0, {
|
|
1625
1619
|
F: __dxlog_file6,
|
|
1626
|
-
L:
|
|
1620
|
+
L: 16,
|
|
1627
1621
|
S: void 0,
|
|
1628
1622
|
A: [
|
|
1629
1623
|
"SpaceId.isValid(spaceId)",
|
|
@@ -1889,7 +1883,7 @@ var EchoDataMonitor = class {
|
|
|
1889
1883
|
this._localTimeSeries = createLocalTimeSeries();
|
|
1890
1884
|
this._storageAverages = createStorageAverages();
|
|
1891
1885
|
this._replicationAverages = createNetworkAverages();
|
|
1892
|
-
this.
|
|
1886
|
+
this._sizeByMessage = {};
|
|
1893
1887
|
this._lastReceivedMessages = new CircularBuffer(100);
|
|
1894
1888
|
this._lastSentMessages = new CircularBuffer(100);
|
|
1895
1889
|
this._connectionsCount = 0;
|
|
@@ -1927,8 +1921,8 @@ var EchoDataMonitor = class {
|
|
|
1927
1921
|
countPerSecond: this._replicationAverages.sentPerSecond.average(),
|
|
1928
1922
|
failedPerSecond: this._replicationAverages.sendsFailedPerSecond.average()
|
|
1929
1923
|
},
|
|
1930
|
-
|
|
1931
|
-
|
|
1924
|
+
countByMessage: this._computeMessageHistogram("type"),
|
|
1925
|
+
avgSizeByMessage: mapValues(this._sizeByMessage, (summary) => summary.average())
|
|
1932
1926
|
}
|
|
1933
1927
|
};
|
|
1934
1928
|
}
|
|
@@ -2133,7 +2127,7 @@ var EchoDataMonitor = class {
|
|
|
2133
2127
|
messageCounts.failed++;
|
|
2134
2128
|
}
|
|
2135
2129
|
_getStatsForType(message) {
|
|
2136
|
-
const messageSize = this.
|
|
2130
|
+
const messageSize = this._sizeByMessage[message.type] ??= createSlidingWindow();
|
|
2137
2131
|
const messageCounts = this._activeCounters.byType[message.type] ??= createMessageCounter();
|
|
2138
2132
|
return {
|
|
2139
2133
|
messageCounts,
|
|
@@ -2253,7 +2247,7 @@ var DataServiceImpl = class {
|
|
|
2253
2247
|
ready();
|
|
2254
2248
|
}).catch((err) => log7.catch(err, void 0, {
|
|
2255
2249
|
F: __dxlog_file8,
|
|
2256
|
-
L:
|
|
2250
|
+
L: 71,
|
|
2257
2251
|
S: this,
|
|
2258
2252
|
C: (f, a) => f(...a)
|
|
2259
2253
|
}));
|
|
@@ -2264,7 +2258,7 @@ var DataServiceImpl = class {
|
|
|
2264
2258
|
const synchronizer = this._subscriptions.get(request.subscriptionId);
|
|
2265
2259
|
invariant7(synchronizer, "Subscription not found", {
|
|
2266
2260
|
F: __dxlog_file8,
|
|
2267
|
-
L:
|
|
2261
|
+
L: 78,
|
|
2268
2262
|
S: this,
|
|
2269
2263
|
A: [
|
|
2270
2264
|
"synchronizer",
|
|
@@ -2285,7 +2279,7 @@ var DataServiceImpl = class {
|
|
|
2285
2279
|
const synchronizer = this._subscriptions.get(request.subscriptionId);
|
|
2286
2280
|
invariant7(synchronizer, "Subscription not found", {
|
|
2287
2281
|
F: __dxlog_file8,
|
|
2288
|
-
L:
|
|
2282
|
+
L: 93,
|
|
2289
2283
|
S: this,
|
|
2290
2284
|
A: [
|
|
2291
2285
|
"synchronizer",
|
|
@@ -2330,7 +2324,7 @@ var DataServiceImpl = class {
|
|
|
2330
2324
|
const spaceId = request.spaceId;
|
|
2331
2325
|
invariant7(SpaceId2.isValid(spaceId), void 0, {
|
|
2332
2326
|
F: __dxlog_file8,
|
|
2333
|
-
L:
|
|
2327
|
+
L: 133,
|
|
2334
2328
|
S: this,
|
|
2335
2329
|
A: [
|
|
2336
2330
|
"SpaceId.isValid(spaceId)",
|
|
@@ -2381,7 +2375,7 @@ import { IndexKind } from "@dxos/protocols/proto/dxos/echo/indexing";
|
|
|
2381
2375
|
import { trace as trace6 } from "@dxos/tracing";
|
|
2382
2376
|
|
|
2383
2377
|
// packages/core/echo/echo-pipeline/src/db-host/documents-iterator.ts
|
|
2384
|
-
import * as A3 from "@
|
|
2378
|
+
import * as A3 from "@automerge/automerge";
|
|
2385
2379
|
import { Context as Context2 } from "@dxos/context";
|
|
2386
2380
|
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
2387
2381
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
@@ -2400,12 +2394,12 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2400
2394
|
const { documentId, objectId } = objectPointerCodec2.decode(id);
|
|
2401
2395
|
const handle = await automergeHost.loadDoc(Context2.default(void 0, {
|
|
2402
2396
|
F: __dxlog_file9,
|
|
2403
|
-
L:
|
|
2397
|
+
L: 31
|
|
2404
2398
|
}), documentId);
|
|
2405
|
-
let doc = handle.
|
|
2399
|
+
let doc = handle.doc();
|
|
2406
2400
|
invariant8(doc, void 0, {
|
|
2407
2401
|
F: __dxlog_file9,
|
|
2408
|
-
L:
|
|
2402
|
+
L: 34,
|
|
2409
2403
|
S: this,
|
|
2410
2404
|
A: [
|
|
2411
2405
|
"doc",
|
|
@@ -2424,7 +2418,7 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2424
2418
|
originalHeads: currentHeads
|
|
2425
2419
|
}, {
|
|
2426
2420
|
F: __dxlog_file9,
|
|
2427
|
-
L:
|
|
2421
|
+
L: 45,
|
|
2428
2422
|
S: this,
|
|
2429
2423
|
C: (f, a) => f(...a)
|
|
2430
2424
|
});
|
|
@@ -2459,7 +2453,7 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2459
2453
|
error
|
|
2460
2454
|
}, {
|
|
2461
2455
|
F: __dxlog_file9,
|
|
2462
|
-
L:
|
|
2456
|
+
L: 71,
|
|
2463
2457
|
S: this,
|
|
2464
2458
|
C: (f, a) => f(...a)
|
|
2465
2459
|
});
|
|
@@ -2469,8 +2463,8 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2469
2463
|
);
|
|
2470
2464
|
|
|
2471
2465
|
// packages/core/echo/echo-pipeline/src/db-host/query-service.ts
|
|
2466
|
+
import { getHeads as getHeads3 } from "@automerge/automerge";
|
|
2472
2467
|
import { DeferredTask } from "@dxos/async";
|
|
2473
|
-
import { getHeads as getHeads3 } from "@dxos/automerge/automerge";
|
|
2474
2468
|
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
2475
2469
|
import { Context as Context4, Resource as Resource7 } from "@dxos/context";
|
|
2476
2470
|
import { log as log9 } from "@dxos/log";
|
|
@@ -2537,12 +2531,12 @@ var QueryState = class extends Resource6 {
|
|
|
2537
2531
|
}
|
|
2538
2532
|
const handle = await this._params.automergeHost.loadDoc(Context3.default(void 0, {
|
|
2539
2533
|
F: __dxlog_file10,
|
|
2540
|
-
L:
|
|
2534
|
+
L: 118
|
|
2541
2535
|
}), documentId);
|
|
2542
2536
|
if (this._ctx.disposed) {
|
|
2543
2537
|
return;
|
|
2544
2538
|
}
|
|
2545
|
-
spaceKey = getSpaceKeyFromDoc(handle.
|
|
2539
|
+
spaceKey = getSpaceKeyFromDoc(handle.doc());
|
|
2546
2540
|
}
|
|
2547
2541
|
if (!spaceKey) {
|
|
2548
2542
|
return;
|
|
@@ -2550,13 +2544,17 @@ var QueryState = class extends Resource6 {
|
|
|
2550
2544
|
if (this._params.request.filter.options?.spaces?.length && !this._params.request.filter.options.spaces.some((key) => key.equals(spaceKey))) {
|
|
2551
2545
|
return;
|
|
2552
2546
|
}
|
|
2547
|
+
const spaceId = await createIdFromSpaceKey2(PublicKey3.from(spaceKey));
|
|
2548
|
+
if (this._params.request.filter.options?.spaceIds?.length && !this._params.request.filter.options.spaceIds.includes(spaceId)) {
|
|
2549
|
+
return;
|
|
2550
|
+
}
|
|
2553
2551
|
if (this._firstRun) {
|
|
2554
2552
|
this.metrics.objectsReturned++;
|
|
2555
2553
|
}
|
|
2556
2554
|
return {
|
|
2557
2555
|
id: objectId,
|
|
2558
2556
|
documentId,
|
|
2559
|
-
spaceId
|
|
2557
|
+
spaceId,
|
|
2560
2558
|
spaceKey: PublicKey3.from(spaceKey),
|
|
2561
2559
|
rank: result.rank
|
|
2562
2560
|
};
|
|
@@ -2609,27 +2607,28 @@ QueryState = _ts_decorate5([
|
|
|
2609
2607
|
trace4.resource()
|
|
2610
2608
|
], QueryState);
|
|
2611
2609
|
var filterToIndexQuery = (filter) => {
|
|
2612
|
-
|
|
2610
|
+
const { type = [], or = [] } = filter;
|
|
2611
|
+
invariant9(!(type.length > 0 && or.length > 0), "Cannot mix type and or filters.", {
|
|
2613
2612
|
F: __dxlog_file10,
|
|
2614
|
-
L:
|
|
2613
|
+
L: 194,
|
|
2615
2614
|
S: void 0,
|
|
2616
2615
|
A: [
|
|
2617
|
-
"!(
|
|
2616
|
+
"!(type.length > 0 && or.length > 0)",
|
|
2618
2617
|
"'Cannot mix type and or filters.'"
|
|
2619
2618
|
]
|
|
2620
2619
|
});
|
|
2621
|
-
invariant9(
|
|
2620
|
+
invariant9(or.every((subFilter) => !((subFilter.type ?? []).length > 0 && (subFilter.or ?? []).length > 0)), "Cannot mix type and or filters.", {
|
|
2622
2621
|
F: __dxlog_file10,
|
|
2623
|
-
L:
|
|
2622
|
+
L: 195,
|
|
2624
2623
|
S: void 0,
|
|
2625
2624
|
A: [
|
|
2626
|
-
"
|
|
2625
|
+
"or.every((subFilter) => !((subFilter.type ?? []).length > 0 && (subFilter.or ?? []).length > 0))",
|
|
2627
2626
|
"'Cannot mix type and or filters.'"
|
|
2628
2627
|
]
|
|
2629
2628
|
});
|
|
2630
|
-
if (
|
|
2629
|
+
if (type.length > 0 || or.length > 0 && (or ?? []).every((subFilter) => !subFilter.not && subFilter.type)) {
|
|
2631
2630
|
return {
|
|
2632
|
-
typenames:
|
|
2631
|
+
typenames: type.length > 0 ? type.map((type2) => dxnToIndexerTypename(DXN.parse(type2))) : or.flatMap((f) => (f.type ?? []).map((type2) => dxnToIndexerTypename(DXN.parse(type2))) ?? []).filter(isNonNullable2),
|
|
2633
2632
|
inverted: filter.not
|
|
2634
2633
|
};
|
|
2635
2634
|
} else {
|
|
@@ -2667,7 +2666,7 @@ var QueryServiceImpl = class extends Resource7 {
|
|
|
2667
2666
|
} catch (err) {
|
|
2668
2667
|
log9.catch(err, void 0, {
|
|
2669
2668
|
F: __dxlog_file11,
|
|
2670
|
-
L:
|
|
2669
|
+
L: 53,
|
|
2671
2670
|
S: this,
|
|
2672
2671
|
C: (f, a) => f(...a)
|
|
2673
2672
|
});
|
|
@@ -2697,13 +2696,13 @@ var QueryServiceImpl = class extends Resource7 {
|
|
|
2697
2696
|
if (this._params.indexer.initialized) {
|
|
2698
2697
|
log9.warn("Indexer already initialized.", void 0, {
|
|
2699
2698
|
F: __dxlog_file11,
|
|
2700
|
-
L:
|
|
2699
|
+
L: 87,
|
|
2701
2700
|
S: this,
|
|
2702
2701
|
C: (f, a) => f(...a)
|
|
2703
2702
|
});
|
|
2704
2703
|
return;
|
|
2705
2704
|
}
|
|
2706
|
-
this._params.indexer.setConfig(config);
|
|
2705
|
+
void this._params.indexer.setConfig(config);
|
|
2707
2706
|
}
|
|
2708
2707
|
execQuery(request) {
|
|
2709
2708
|
return new Stream2(({ next, close, ctx }) => {
|
|
@@ -2739,7 +2738,7 @@ var QueryServiceImpl = class extends Resource7 {
|
|
|
2739
2738
|
} catch (error) {
|
|
2740
2739
|
log9.catch(error, void 0, {
|
|
2741
2740
|
F: __dxlog_file11,
|
|
2742
|
-
L:
|
|
2741
|
+
L: 124,
|
|
2743
2742
|
S: this,
|
|
2744
2743
|
C: (f, a) => f(...a)
|
|
2745
2744
|
});
|
|
@@ -2754,7 +2753,7 @@ var QueryServiceImpl = class extends Resource7 {
|
|
|
2754
2753
|
async reindex() {
|
|
2755
2754
|
log9.info("Reindexing all documents...", void 0, {
|
|
2756
2755
|
F: __dxlog_file11,
|
|
2757
|
-
L:
|
|
2756
|
+
L: 136,
|
|
2758
2757
|
S: this,
|
|
2759
2758
|
C: (f, a) => f(...a)
|
|
2760
2759
|
});
|
|
@@ -2769,7 +2768,7 @@ var QueryServiceImpl = class extends Resource7 {
|
|
|
2769
2768
|
count: ids.size
|
|
2770
2769
|
}, {
|
|
2771
2770
|
F: __dxlog_file11,
|
|
2772
|
-
L:
|
|
2771
|
+
L: 144,
|
|
2773
2772
|
S: this,
|
|
2774
2773
|
C: (f, a) => f(...a)
|
|
2775
2774
|
});
|
|
@@ -2779,7 +2778,7 @@ var QueryServiceImpl = class extends Resource7 {
|
|
|
2779
2778
|
count: ids.size
|
|
2780
2779
|
}, {
|
|
2781
2780
|
F: __dxlog_file11,
|
|
2782
|
-
L:
|
|
2781
|
+
L: 148,
|
|
2783
2782
|
S: this,
|
|
2784
2783
|
C: (f, a) => f(...a)
|
|
2785
2784
|
});
|
|
@@ -2794,10 +2793,10 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
2794
2793
|
async function* getAllDocuments() {
|
|
2795
2794
|
const visited = /* @__PURE__ */ new Set();
|
|
2796
2795
|
async function* getObjectsFromHandle(handle) {
|
|
2797
|
-
if (visited.has(handle.documentId)) {
|
|
2796
|
+
if (visited.has(handle.documentId) || !handle.isReady()) {
|
|
2798
2797
|
return;
|
|
2799
2798
|
}
|
|
2800
|
-
const doc = handle.
|
|
2799
|
+
const doc = handle.doc();
|
|
2801
2800
|
const spaceKey = getSpaceKeyFromDoc(doc) ?? void 0;
|
|
2802
2801
|
if (doc.objects) {
|
|
2803
2802
|
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
@@ -2820,7 +2819,7 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
2820
2819
|
}
|
|
2821
2820
|
const linkHandle = await automergeHost.loadDoc(Context4.default(void 0, {
|
|
2822
2821
|
F: __dxlog_file11,
|
|
2823
|
-
L:
|
|
2822
|
+
L: 190
|
|
2824
2823
|
}), urlString);
|
|
2825
2824
|
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
2826
2825
|
yield result;
|
|
@@ -2842,18 +2841,18 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
2842
2841
|
);
|
|
2843
2842
|
|
|
2844
2843
|
// packages/core/echo/echo-pipeline/src/db-host/space-state-manager.ts
|
|
2844
|
+
import { interpretAsDocumentId as interpretAsDocumentId3 } from "@automerge/automerge-repo";
|
|
2845
2845
|
import isEqual from "lodash.isequal";
|
|
2846
2846
|
import { Event as Event3, UpdateScheduler as UpdateScheduler3 } from "@dxos/async";
|
|
2847
|
-
import { interpretAsDocumentId as interpretAsDocumentId3 } from "@dxos/automerge/automerge-repo";
|
|
2848
2847
|
import { Resource as Resource8, Context as Context5 } from "@dxos/context";
|
|
2849
2848
|
|
|
2850
2849
|
// packages/core/echo/echo-pipeline/src/db-host/database-root.ts
|
|
2851
|
-
import { interpretAsDocumentId as interpretAsDocumentId2 } from "@
|
|
2850
|
+
import { interpretAsDocumentId as interpretAsDocumentId2 } from "@automerge/automerge-repo";
|
|
2852
2851
|
import { SpaceDocVersion as SpaceDocVersion2 } from "@dxos/echo-protocol";
|
|
2853
2852
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2854
2853
|
|
|
2855
2854
|
// packages/core/echo/echo-pipeline/src/db-host/automerge-metrics.ts
|
|
2856
|
-
import * as A4 from "@
|
|
2855
|
+
import * as A4 from "@automerge/automerge";
|
|
2857
2856
|
import { log as log10 } from "@dxos/log";
|
|
2858
2857
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/automerge-metrics.ts";
|
|
2859
2858
|
var measureDocMetrics = (doc) => {
|
|
@@ -2870,7 +2869,7 @@ var measureDocMetrics = (doc) => {
|
|
|
2870
2869
|
elapsed: getAllChangesEnd - getAllChangesStart
|
|
2871
2870
|
}, {
|
|
2872
2871
|
F: __dxlog_file12,
|
|
2873
|
-
L:
|
|
2872
|
+
L: 31,
|
|
2874
2873
|
S: void 0,
|
|
2875
2874
|
C: (f, a) => f(...a)
|
|
2876
2875
|
});
|
|
@@ -2908,47 +2907,47 @@ var DatabaseRoot = class {
|
|
|
2908
2907
|
return this._rootHandle.url;
|
|
2909
2908
|
}
|
|
2910
2909
|
get isLoaded() {
|
|
2911
|
-
return
|
|
2910
|
+
return this._rootHandle.isReady();
|
|
2912
2911
|
}
|
|
2913
2912
|
get handle() {
|
|
2914
2913
|
return this._rootHandle;
|
|
2915
2914
|
}
|
|
2916
|
-
|
|
2917
|
-
return this._rootHandle.
|
|
2915
|
+
doc() {
|
|
2916
|
+
return this._rootHandle.isReady() ? this._rootHandle.doc() : null;
|
|
2918
2917
|
}
|
|
2919
2918
|
getVersion() {
|
|
2920
|
-
const doc = this.
|
|
2919
|
+
const doc = this.doc();
|
|
2921
2920
|
if (!doc) {
|
|
2922
2921
|
return null;
|
|
2923
2922
|
}
|
|
2924
2923
|
return doc.version ?? SpaceDocVersion2.LEGACY;
|
|
2925
2924
|
}
|
|
2926
2925
|
getSpaceKey() {
|
|
2927
|
-
const doc = this.
|
|
2926
|
+
const doc = this.doc();
|
|
2928
2927
|
if (!doc) {
|
|
2929
2928
|
return null;
|
|
2930
2929
|
}
|
|
2931
2930
|
return getSpaceKeyFromDoc(doc);
|
|
2932
2931
|
}
|
|
2933
2932
|
getInlineObjectCount() {
|
|
2934
|
-
const doc = this.
|
|
2933
|
+
const doc = this.doc();
|
|
2935
2934
|
if (!doc) {
|
|
2936
2935
|
return null;
|
|
2937
2936
|
}
|
|
2938
2937
|
return Object.keys(doc.objects ?? {}).length;
|
|
2939
2938
|
}
|
|
2940
2939
|
getLinkedObjectCount() {
|
|
2941
|
-
const doc = this.
|
|
2940
|
+
const doc = this.doc();
|
|
2942
2941
|
if (!doc) {
|
|
2943
2942
|
return null;
|
|
2944
2943
|
}
|
|
2945
2944
|
return Object.keys(doc.links ?? {}).length;
|
|
2946
2945
|
}
|
|
2947
2946
|
getAllLinkedDocuments() {
|
|
2948
|
-
const doc = this.
|
|
2947
|
+
const doc = this.doc();
|
|
2949
2948
|
invariant10(doc, void 0, {
|
|
2950
2949
|
F: __dxlog_file13,
|
|
2951
|
-
L:
|
|
2950
|
+
L: 89,
|
|
2952
2951
|
S: this,
|
|
2953
2952
|
A: [
|
|
2954
2953
|
"doc",
|
|
@@ -2958,7 +2957,7 @@ var DatabaseRoot = class {
|
|
|
2958
2957
|
return Object.values(doc.links ?? {}).map((s) => s.toString());
|
|
2959
2958
|
}
|
|
2960
2959
|
measureMetrics() {
|
|
2961
|
-
const doc = this.
|
|
2960
|
+
const doc = this.doc();
|
|
2962
2961
|
if (!doc) {
|
|
2963
2962
|
return null;
|
|
2964
2963
|
}
|
|
@@ -3077,7 +3076,7 @@ var EchoHost = class extends Resource9 {
|
|
|
3077
3076
|
loadDocuments: createSelectedDocumentsIterator(this._automergeHost),
|
|
3078
3077
|
indexCooldownTime: false ? 0 : void 0
|
|
3079
3078
|
});
|
|
3080
|
-
this._indexer.setConfig(INDEXER_CONFIG);
|
|
3079
|
+
void this._indexer.setConfig(INDEXER_CONFIG);
|
|
3081
3080
|
this._queryService = new QueryServiceImpl({
|
|
3082
3081
|
automergeHost: this._automergeHost,
|
|
3083
3082
|
indexer: this._indexer
|
|
@@ -3194,7 +3193,7 @@ var EchoHost = class extends Resource9 {
|
|
|
3194
3193
|
async createSpaceRoot(spaceKey) {
|
|
3195
3194
|
invariant11(this._lifecycleState === LifecycleState4.OPEN, void 0, {
|
|
3196
3195
|
F: __dxlog_file15,
|
|
3197
|
-
L:
|
|
3196
|
+
L: 226,
|
|
3198
3197
|
S: this,
|
|
3199
3198
|
A: [
|
|
3200
3199
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -3222,14 +3221,15 @@ var EchoHost = class extends Resource9 {
|
|
|
3222
3221
|
async openSpaceRoot(spaceId, automergeUrl) {
|
|
3223
3222
|
invariant11(this._lifecycleState === LifecycleState4.OPEN, void 0, {
|
|
3224
3223
|
F: __dxlog_file15,
|
|
3225
|
-
L:
|
|
3224
|
+
L: 245,
|
|
3226
3225
|
S: this,
|
|
3227
3226
|
A: [
|
|
3228
3227
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
3229
3228
|
""
|
|
3230
3229
|
]
|
|
3231
3230
|
});
|
|
3232
|
-
const handle = this._automergeHost.repo.find(automergeUrl);
|
|
3231
|
+
const handle = await this._automergeHost.repo.find(automergeUrl, FIND_PARAMS);
|
|
3232
|
+
await handle.whenReady();
|
|
3233
3233
|
return this._spaceStateManager.assignRootToSpace(spaceId, handle);
|
|
3234
3234
|
}
|
|
3235
3235
|
// TODO(dmaretskyi): Change to document id.
|
|
@@ -3251,8 +3251,8 @@ var EchoHost = class extends Resource9 {
|
|
|
3251
3251
|
};
|
|
3252
3252
|
|
|
3253
3253
|
// packages/core/echo/echo-pipeline/src/edge/echo-edge-replicator.ts
|
|
3254
|
+
import { cbor as cbor2 } from "@automerge/automerge-repo";
|
|
3254
3255
|
import { Mutex, scheduleTask as scheduleTask2, scheduleMicroTask } from "@dxos/async";
|
|
3255
|
-
import { cbor as cbor2 } from "@dxos/automerge/automerge-repo";
|
|
3256
3256
|
import { Context as Context6, Resource as Resource11 } from "@dxos/context";
|
|
3257
3257
|
import { randomUUID } from "@dxos/crypto";
|
|
3258
3258
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
@@ -3402,14 +3402,14 @@ var EchoEdgeReplicator = class {
|
|
|
3402
3402
|
connectedSpaces: this._connectedSpaces.size
|
|
3403
3403
|
}, {
|
|
3404
3404
|
F: __dxlog_file17,
|
|
3405
|
-
L:
|
|
3405
|
+
L: 61,
|
|
3406
3406
|
S: this,
|
|
3407
3407
|
C: (f, a) => f(...a)
|
|
3408
3408
|
});
|
|
3409
3409
|
this._context = context;
|
|
3410
3410
|
this._ctx = Context6.default(void 0, {
|
|
3411
3411
|
F: __dxlog_file17,
|
|
3412
|
-
L:
|
|
3412
|
+
L: 64
|
|
3413
3413
|
});
|
|
3414
3414
|
this._ctx.onDispose(this._edgeConnection.onReconnected(() => {
|
|
3415
3415
|
this._ctx && scheduleMicroTask(this._ctx, () => this._handleReconnect());
|
|
@@ -3488,7 +3488,7 @@ var EchoEdgeReplicator = class {
|
|
|
3488
3488
|
async _openConnection(spaceId, reconnects = 0) {
|
|
3489
3489
|
invariant12(this._context, void 0, {
|
|
3490
3490
|
F: __dxlog_file17,
|
|
3491
|
-
L:
|
|
3491
|
+
L: 125,
|
|
3492
3492
|
S: this,
|
|
3493
3493
|
A: [
|
|
3494
3494
|
"this._context",
|
|
@@ -3497,7 +3497,7 @@ var EchoEdgeReplicator = class {
|
|
|
3497
3497
|
});
|
|
3498
3498
|
invariant12(!this._connections.has(spaceId), void 0, {
|
|
3499
3499
|
F: __dxlog_file17,
|
|
3500
|
-
L:
|
|
3500
|
+
L: 126,
|
|
3501
3501
|
S: this,
|
|
3502
3502
|
A: [
|
|
3503
3503
|
"!this._connections.has(spaceId)",
|
|
@@ -3527,7 +3527,7 @@ var EchoEdgeReplicator = class {
|
|
|
3527
3527
|
restartDelay
|
|
3528
3528
|
}, {
|
|
3529
3529
|
F: __dxlog_file17,
|
|
3530
|
-
L:
|
|
3530
|
+
L: 149,
|
|
3531
3531
|
S: this,
|
|
3532
3532
|
C: (f, a) => f(...a)
|
|
3533
3533
|
});
|
|
@@ -3592,7 +3592,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3592
3592
|
async _open(ctx) {
|
|
3593
3593
|
log12("opening...", void 0, {
|
|
3594
3594
|
F: __dxlog_file17,
|
|
3595
|
-
L:
|
|
3595
|
+
L: 252,
|
|
3596
3596
|
S: this,
|
|
3597
3597
|
C: (f, a) => f(...a)
|
|
3598
3598
|
});
|
|
@@ -3605,7 +3605,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3605
3605
|
async _close() {
|
|
3606
3606
|
log12("closing...", void 0, {
|
|
3607
3607
|
F: __dxlog_file17,
|
|
3608
|
-
L:
|
|
3608
|
+
L: 267,
|
|
3609
3609
|
S: this,
|
|
3610
3610
|
C: (f, a) => f(...a)
|
|
3611
3611
|
});
|
|
@@ -3616,7 +3616,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3616
3616
|
get peerId() {
|
|
3617
3617
|
invariant12(this._remotePeerId, "Not connected", {
|
|
3618
3618
|
F: __dxlog_file17,
|
|
3619
|
-
L:
|
|
3619
|
+
L: 276,
|
|
3620
3620
|
S: this,
|
|
3621
3621
|
A: [
|
|
3622
3622
|
"this._remotePeerId",
|
|
@@ -3641,7 +3641,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3641
3641
|
remoteId: this._remotePeerId
|
|
3642
3642
|
}, {
|
|
3643
3643
|
F: __dxlog_file17,
|
|
3644
|
-
L:
|
|
3644
|
+
L: 291,
|
|
3645
3645
|
S: this,
|
|
3646
3646
|
C: (f, a) => f(...a)
|
|
3647
3647
|
});
|
|
@@ -3667,7 +3667,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3667
3667
|
remoteId: this._remotePeerId
|
|
3668
3668
|
}, {
|
|
3669
3669
|
F: __dxlog_file17,
|
|
3670
|
-
L:
|
|
3670
|
+
L: 320,
|
|
3671
3671
|
S: this,
|
|
3672
3672
|
C: (f, a) => f(...a)
|
|
3673
3673
|
});
|
|
@@ -3690,7 +3690,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3690
3690
|
remoteId: this._remotePeerId
|
|
3691
3691
|
}, {
|
|
3692
3692
|
F: __dxlog_file17,
|
|
3693
|
-
L:
|
|
3693
|
+
L: 349,
|
|
3694
3694
|
S: this,
|
|
3695
3695
|
C: (f, a) => f(...a)
|
|
3696
3696
|
});
|
|
@@ -3735,6 +3735,7 @@ export {
|
|
|
3735
3735
|
EchoDataMonitor,
|
|
3736
3736
|
EchoEdgeReplicator,
|
|
3737
3737
|
EchoHost,
|
|
3738
|
+
FIND_PARAMS,
|
|
3738
3739
|
LevelDBStorageAdapter,
|
|
3739
3740
|
MOCK_AUTH_PROVIDER,
|
|
3740
3741
|
MOCK_AUTH_VERIFIER,
|