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