@dxos/echo-pipeline 0.8.1 → 0.8.2-main.10c050d
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-3XSXS5EX.mjs} +15 -21
- package/dist/lib/browser/chunk-3XSXS5EX.mjs.map +7 -0
- package/dist/lib/browser/chunk-CGS2ULMK.mjs +11 -0
- package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +7 -0
- package/dist/lib/browser/chunk-TQJTKNMS.mjs +126 -0
- package/dist/lib/browser/chunk-TQJTKNMS.mjs.map +7 -0
- package/dist/lib/browser/filter/index.mjs +11 -0
- package/dist/lib/browser/filter/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1380 -516
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +202 -22
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/chunk-HOPOFWAL.cjs +147 -0
- package/dist/lib/node/chunk-HOPOFWAL.cjs.map +7 -0
- package/dist/lib/node/chunk-Q7SFCCGT.cjs +33 -0
- package/dist/lib/node/chunk-Q7SFCCGT.cjs.map +7 -0
- package/dist/lib/node/{chunk-TC2PRBEU.cjs → chunk-SG2PL5RH.cjs} +18 -24
- package/dist/lib/node/chunk-SG2PL5RH.cjs.map +7 -0
- package/dist/lib/node/filter/index.cjs +32 -0
- package/dist/lib/node/filter/index.cjs.map +7 -0
- package/dist/lib/node/index.cjs +1381 -525
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +207 -31
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/lib/node-esm/{chunk-UKOLB3LW.mjs → chunk-3BZP75TJ.mjs} +15 -21
- package/dist/lib/node-esm/chunk-3BZP75TJ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RVK35BS7.mjs +126 -0
- package/dist/lib/node-esm/chunk-RVK35BS7.mjs.map +7 -0
- package/dist/lib/node-esm/filter/index.mjs +11 -0
- package/dist/lib/node-esm/filter/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1380 -516
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +202 -22
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/automerge/automerge-host.d.ts +6 -4
- 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/mesh-echo-replicator.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 +7 -7
- package/dist/types/src/db-host/database-root.d.ts.map +1 -1
- package/dist/types/src/db-host/documents-iterator.d.ts +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 +4 -4
- package/dist/types/src/db-host/documents-synchronizer.d.ts.map +1 -1
- package/dist/types/src/db-host/echo-host.d.ts +13 -2
- package/dist/types/src/db-host/echo-host.d.ts.map +1 -1
- package/dist/types/src/db-host/index.d.ts +0 -1
- package/dist/types/src/db-host/index.d.ts.map +1 -1
- package/dist/types/src/db-host/query-service.d.ts +2 -0
- package/dist/types/src/db-host/query-service.d.ts.map +1 -1
- package/dist/types/src/db-host/space-state-manager.d.ts +4 -3
- 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/edge/inflight-request-limiter.d.ts.map +1 -1
- package/dist/types/src/filter/filter-match.d.ts +13 -0
- package/dist/types/src/filter/filter-match.d.ts.map +1 -0
- package/dist/types/src/filter/filter-match.test.d.ts +2 -0
- package/dist/types/src/filter/filter-match.test.d.ts.map +1 -0
- package/dist/types/src/filter/index.d.ts +2 -0
- package/dist/types/src/filter/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/pipeline/timeframe-clock.d.ts.map +1 -1
- package/dist/types/src/query/errors.d.ts +23 -0
- package/dist/types/src/query/errors.d.ts.map +1 -0
- package/dist/types/src/query/index.d.ts +5 -0
- package/dist/types/src/query/index.d.ts.map +1 -0
- package/dist/types/src/query/plan.d.ts +132 -0
- package/dist/types/src/query/plan.d.ts.map +1 -0
- package/dist/types/src/query/query-executor.d.ts +83 -0
- package/dist/types/src/query/query-executor.d.ts.map +1 -0
- package/dist/types/src/query/query-planner.d.ts +33 -0
- package/dist/types/src/query/query-planner.d.ts.map +1 -0
- package/dist/types/src/query/query-planner.test.d.ts +2 -0
- package/dist/types/src/query/query-planner.test.d.ts.map +1 -0
- package/dist/types/src/space/admission-discovery-extension.d.ts.map +1 -1
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/change-metadata.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +18 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- 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/testing/test-schema.d.ts +39 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +2 -2
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -34
- package/src/automerge/automerge-host.test.ts +7 -7
- package/src/automerge/automerge-host.ts +58 -60
- package/src/automerge/automerge-repo.test.ts +65 -65
- package/src/automerge/collection-synchronizer.test.ts +1 -1
- package/src/automerge/collection-synchronizer.ts +11 -10
- package/src/automerge/echo-data-monitor.ts +21 -20
- package/src/automerge/echo-network-adapter.test.ts +1 -1
- package/src/automerge/echo-network-adapter.ts +25 -18
- package/src/automerge/heads-store.ts +4 -3
- package/src/automerge/leveldb-storage-adapter.ts +1 -1
- package/src/automerge/mesh-echo-replicator-connection.ts +6 -5
- package/src/automerge/mesh-echo-replicator.ts +2 -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 +4 -3
- package/src/db-host/database-root.ts +17 -22
- package/src/db-host/documents-iterator.ts +9 -8
- package/src/db-host/documents-synchronizer.test.ts +2 -2
- package/src/db-host/documents-synchronizer.ts +20 -18
- package/src/db-host/echo-host.ts +44 -15
- package/src/db-host/index.ts +0 -1
- package/src/db-host/query-service.ts +43 -37
- package/src/db-host/space-state-manager.ts +14 -4
- package/src/edge/echo-edge-replicator.test.ts +3 -3
- package/src/edge/echo-edge-replicator.ts +9 -8
- package/src/edge/inflight-request-limiter.ts +4 -4
- package/src/filter/filter-match.test.ts +101 -0
- package/src/filter/filter-match.ts +174 -0
- package/src/filter/index.ts +5 -0
- package/src/index.ts +1 -0
- package/src/metadata/metadata-store.ts +13 -13
- package/src/pipeline/pipeline-stress.test.ts +9 -9
- package/src/pipeline/pipeline.ts +13 -13
- package/src/pipeline/timeframe-clock.ts +5 -5
- package/src/query/errors.ts +7 -0
- package/src/query/index.ts +8 -0
- package/src/query/plan.ts +179 -0
- package/src/query/query-executor.ts +648 -0
- package/src/query/query-planner.test.ts +613 -0
- package/src/query/query-planner.ts +470 -0
- package/src/space/admission-discovery-extension.ts +2 -2
- package/src/space/control-pipeline.ts +8 -8
- package/src/space/space-manager.ts +5 -4
- package/src/space/space-protocol.browser.test.ts +1 -0
- package/src/space/space-protocol.test.ts +1 -0
- package/src/space/space-protocol.ts +4 -4
- package/src/space/space.ts +5 -5
- package/src/testing/index.ts +2 -0
- package/src/testing/test-agent-builder.ts +6 -6
- package/src/testing/test-data.ts +127 -0
- package/src/testing/test-network-adapter.ts +15 -12
- package/src/testing/test-replicator.ts +2 -2
- package/src/testing/test-schema.ts +53 -0
- package/src/util.ts +7 -3
- package/dist/lib/browser/chunk-32WDI3LB.mjs.map +0 -7
- package/dist/lib/node/chunk-TC2PRBEU.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-UKOLB3LW.mjs.map +0 -7
- package/dist/types/src/db-host/query-state.d.ts +0 -41
- package/dist/types/src/db-host/query-state.d.ts.map +0 -1
- package/src/db-host/query-state.ts +0 -217
package/dist/lib/node/index.cjs
CHANGED
|
@@ -28,77 +28,85 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var node_exports = {};
|
|
30
30
|
__export(node_exports, {
|
|
31
|
-
AuthExtension: () =>
|
|
32
|
-
AuthStatus: () =>
|
|
31
|
+
AuthExtension: () => import_chunk_SG2PL5RH.AuthExtension,
|
|
32
|
+
AuthStatus: () => import_chunk_SG2PL5RH.AuthStatus,
|
|
33
33
|
AutomergeHost: () => AutomergeHost,
|
|
34
|
-
CredentialRetrieverExtension: () =>
|
|
35
|
-
CredentialServerExtension: () =>
|
|
34
|
+
CredentialRetrieverExtension: () => import_chunk_SG2PL5RH.CredentialRetrieverExtension,
|
|
35
|
+
CredentialServerExtension: () => import_chunk_SG2PL5RH.CredentialServerExtension,
|
|
36
36
|
DataServiceImpl: () => DataServiceImpl,
|
|
37
37
|
DatabaseRoot: () => DatabaseRoot,
|
|
38
38
|
DocumentsSynchronizer: () => DocumentsSynchronizer,
|
|
39
39
|
EchoDataMonitor: () => EchoDataMonitor,
|
|
40
40
|
EchoEdgeReplicator: () => EchoEdgeReplicator,
|
|
41
41
|
EchoHost: () => EchoHost,
|
|
42
|
+
ExecutionTrace: () => ExecutionTrace,
|
|
43
|
+
FIND_PARAMS: () => FIND_PARAMS,
|
|
42
44
|
LevelDBStorageAdapter: () => LevelDBStorageAdapter,
|
|
43
|
-
MOCK_AUTH_PROVIDER: () =>
|
|
44
|
-
MOCK_AUTH_VERIFIER: () =>
|
|
45
|
+
MOCK_AUTH_PROVIDER: () => import_chunk_SG2PL5RH.MOCK_AUTH_PROVIDER,
|
|
46
|
+
MOCK_AUTH_VERIFIER: () => import_chunk_SG2PL5RH.MOCK_AUTH_VERIFIER,
|
|
45
47
|
MeshEchoReplicator: () => MeshEchoReplicator,
|
|
46
|
-
MetadataStore: () =>
|
|
47
|
-
Pipeline: () =>
|
|
48
|
+
MetadataStore: () => import_chunk_SG2PL5RH.MetadataStore,
|
|
49
|
+
Pipeline: () => import_chunk_SG2PL5RH.Pipeline,
|
|
50
|
+
QueryExecutor: () => QueryExecutor,
|
|
51
|
+
QueryPlan: () => QueryPlan,
|
|
52
|
+
QueryPlanner: () => QueryPlanner,
|
|
48
53
|
QueryServiceImpl: () => QueryServiceImpl,
|
|
49
|
-
|
|
50
|
-
Space: () => import_chunk_TC2PRBEU.Space,
|
|
54
|
+
Space: () => import_chunk_SG2PL5RH.Space,
|
|
51
55
|
SpaceDocumentListUpdatedEvent: () => SpaceDocumentListUpdatedEvent,
|
|
52
|
-
SpaceManager: () =>
|
|
53
|
-
SpaceProtocol: () =>
|
|
54
|
-
SpaceProtocolSession: () =>
|
|
56
|
+
SpaceManager: () => import_chunk_SG2PL5RH.SpaceManager,
|
|
57
|
+
SpaceProtocol: () => import_chunk_SG2PL5RH.SpaceProtocol,
|
|
58
|
+
SpaceProtocolSession: () => import_chunk_SG2PL5RH.SpaceProtocolSession,
|
|
55
59
|
SpaceStateManager: () => SpaceStateManager,
|
|
56
|
-
TimeframeClock: () =>
|
|
57
|
-
codec: () =>
|
|
58
|
-
createIdFromSpaceKey: () =>
|
|
59
|
-
createMappedFeedWriter: () =>
|
|
60
|
+
TimeframeClock: () => import_chunk_SG2PL5RH.TimeframeClock,
|
|
61
|
+
codec: () => import_chunk_SG2PL5RH.codec,
|
|
62
|
+
createIdFromSpaceKey: () => import_chunk_SG2PL5RH.createIdFromSpaceKey,
|
|
63
|
+
createMappedFeedWriter: () => import_chunk_SG2PL5RH.createMappedFeedWriter,
|
|
60
64
|
deriveCollectionIdFromSpaceId: () => deriveCollectionIdFromSpaceId,
|
|
61
65
|
diffCollectionState: () => diffCollectionState,
|
|
62
66
|
encodingOptions: () => encodingOptions,
|
|
67
|
+
filterMatchObject: () => import_chunk_HOPOFWAL.filterMatchObject,
|
|
68
|
+
filterMatchValue: () => import_chunk_HOPOFWAL.filterMatchValue,
|
|
63
69
|
findInlineObjectOfType: () => findInlineObjectOfType,
|
|
64
70
|
getSpaceIdFromCollectionId: () => getSpaceIdFromCollectionId,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
valueEncoding: () => import_chunk_TC2PRBEU.valueEncoding
|
|
71
|
+
hasInvitationExpired: () => import_chunk_SG2PL5RH.hasInvitationExpired,
|
|
72
|
+
mapFeedIndexesToTimeframe: () => import_chunk_SG2PL5RH.mapFeedIndexesToTimeframe,
|
|
73
|
+
mapTimeframeToFeedIndexes: () => import_chunk_SG2PL5RH.mapTimeframeToFeedIndexes,
|
|
74
|
+
startAfter: () => import_chunk_SG2PL5RH.startAfter,
|
|
75
|
+
valueEncoding: () => import_chunk_SG2PL5RH.valueEncoding
|
|
71
76
|
});
|
|
72
77
|
module.exports = __toCommonJS(node_exports);
|
|
73
|
-
var
|
|
78
|
+
var import_chunk_HOPOFWAL = require("./chunk-HOPOFWAL.cjs");
|
|
79
|
+
var import_chunk_SG2PL5RH = require("./chunk-SG2PL5RH.cjs");
|
|
80
|
+
var import_chunk_Q7SFCCGT = require("./chunk-Q7SFCCGT.cjs");
|
|
74
81
|
var import_async = require("@dxos/async");
|
|
75
82
|
var import_stream = require("@dxos/codec-protobuf/stream");
|
|
76
83
|
var import_invariant = require("@dxos/invariant");
|
|
77
84
|
var import_keys = require("@dxos/keys");
|
|
78
85
|
var import_log = require("@dxos/log");
|
|
86
|
+
var import_automerge = require("@automerge/automerge");
|
|
79
87
|
var import_async2 = require("@dxos/async");
|
|
80
|
-
var import_automerge = require("@dxos/automerge/automerge");
|
|
81
88
|
var import_context = require("@dxos/context");
|
|
82
89
|
var import_invariant2 = require("@dxos/invariant");
|
|
83
90
|
var import_log2 = require("@dxos/log");
|
|
91
|
+
var import_automerge2 = require("@automerge/automerge");
|
|
92
|
+
var import_automerge_repo = require("@automerge/automerge-repo");
|
|
84
93
|
var import_async3 = require("@dxos/async");
|
|
85
|
-
var import_automerge2 = require("@dxos/automerge/automerge");
|
|
86
|
-
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
87
94
|
var import_context2 = require("@dxos/context");
|
|
95
|
+
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
88
96
|
var import_invariant3 = require("@dxos/invariant");
|
|
89
97
|
var import_keys2 = require("@dxos/keys");
|
|
90
98
|
var import_log3 = require("@dxos/log");
|
|
91
99
|
var import_protocols = require("@dxos/protocols");
|
|
92
100
|
var import_tracing = require("@dxos/tracing");
|
|
93
101
|
var import_util = require("@dxos/util");
|
|
102
|
+
var import_automerge3 = require("@automerge/automerge");
|
|
94
103
|
var import_async4 = require("@dxos/async");
|
|
95
|
-
var import_automerge3 = require("@dxos/automerge/automerge");
|
|
96
104
|
var import_context3 = require("@dxos/context");
|
|
97
105
|
var import_log4 = require("@dxos/log");
|
|
98
106
|
var import_tracing2 = require("@dxos/tracing");
|
|
99
107
|
var import_util2 = require("@dxos/util");
|
|
108
|
+
var import_automerge_repo2 = require("@automerge/automerge-repo");
|
|
100
109
|
var import_async5 = require("@dxos/async");
|
|
101
|
-
var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
|
|
102
110
|
var import_context4 = require("@dxos/context");
|
|
103
111
|
var import_invariant4 = require("@dxos/invariant");
|
|
104
112
|
var import_log5 = require("@dxos/log");
|
|
@@ -110,8 +118,8 @@ var import_invariant5 = require("@dxos/invariant");
|
|
|
110
118
|
var import_keys3 = require("@dxos/keys");
|
|
111
119
|
var import_log6 = require("@dxos/log");
|
|
112
120
|
var import_util4 = require("@dxos/util");
|
|
113
|
-
var A2 = __toESM(require("@
|
|
114
|
-
var import_automerge_repo3 = require("@
|
|
121
|
+
var A2 = __toESM(require("@automerge/automerge"));
|
|
122
|
+
var import_automerge_repo3 = require("@automerge/automerge-repo");
|
|
115
123
|
var import_context6 = require("@dxos/context");
|
|
116
124
|
var import_invariant6 = require("@dxos/invariant");
|
|
117
125
|
var import_log7 = require("@dxos/log");
|
|
@@ -122,63 +130,67 @@ var import_tracing3 = require("@dxos/tracing");
|
|
|
122
130
|
var import_util5 = require("@dxos/util");
|
|
123
131
|
var import_context7 = require("@dxos/context");
|
|
124
132
|
var import_debug = require("@dxos/debug");
|
|
125
|
-
var
|
|
133
|
+
var import_echo_protocol2 = require("@dxos/echo-protocol");
|
|
126
134
|
var import_indexing2 = require("@dxos/indexing");
|
|
127
135
|
var import_invariant8 = require("@dxos/invariant");
|
|
128
136
|
var import_indexing3 = require("@dxos/protocols/proto/dxos/echo/indexing");
|
|
129
137
|
var import_tracing4 = require("@dxos/tracing");
|
|
130
|
-
var A3 = __toESM(require("@
|
|
138
|
+
var A3 = __toESM(require("@automerge/automerge"));
|
|
131
139
|
var import_context8 = require("@dxos/context");
|
|
132
|
-
var
|
|
140
|
+
var import_echo_protocol3 = require("@dxos/echo-protocol");
|
|
133
141
|
var import_invariant9 = require("@dxos/invariant");
|
|
134
142
|
var import_log8 = require("@dxos/log");
|
|
135
143
|
var import_protocols3 = require("@dxos/protocols");
|
|
144
|
+
var import_automerge4 = require("@automerge/automerge");
|
|
145
|
+
var import_effect = require("effect");
|
|
136
146
|
var import_async6 = require("@dxos/async");
|
|
137
|
-
var import_automerge4 = require("@dxos/automerge/automerge");
|
|
138
147
|
var import_stream2 = require("@dxos/codec-protobuf/stream");
|
|
139
148
|
var import_context9 = require("@dxos/context");
|
|
149
|
+
var import_debug2 = require("@dxos/debug");
|
|
150
|
+
var import_echo_protocol4 = require("@dxos/echo-protocol");
|
|
140
151
|
var import_log9 = require("@dxos/log");
|
|
141
152
|
var import_protocols4 = require("@dxos/protocols");
|
|
142
153
|
var import_tracing5 = require("@dxos/tracing");
|
|
154
|
+
var import_effect2 = require("effect");
|
|
143
155
|
var import_context10 = require("@dxos/context");
|
|
144
|
-
var
|
|
156
|
+
var import_echo_protocol5 = require("@dxos/echo-protocol");
|
|
157
|
+
var import_indexing4 = require("@dxos/indexing");
|
|
145
158
|
var import_invariant10 = require("@dxos/invariant");
|
|
146
159
|
var import_keys5 = require("@dxos/keys");
|
|
160
|
+
var import_log10 = require("@dxos/log");
|
|
147
161
|
var import_protocols5 = require("@dxos/protocols");
|
|
148
|
-
var import_tracing6 = require("@dxos/tracing");
|
|
149
162
|
var import_util6 = require("@dxos/util");
|
|
163
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
164
|
+
var import_errors = require("@dxos/errors");
|
|
165
|
+
var import_automerge_repo4 = require("@automerge/automerge-repo");
|
|
150
166
|
var import_lodash = __toESM(require("lodash.isequal"));
|
|
151
167
|
var import_async7 = require("@dxos/async");
|
|
152
|
-
var import_automerge_repo4 = require("@dxos/automerge/automerge-repo");
|
|
153
168
|
var import_context11 = require("@dxos/context");
|
|
154
|
-
var
|
|
155
|
-
var
|
|
156
|
-
var
|
|
157
|
-
var
|
|
158
|
-
var
|
|
169
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
170
|
+
var import_automerge_repo5 = require("@automerge/automerge-repo");
|
|
171
|
+
var import_echo_protocol6 = require("@dxos/echo-protocol");
|
|
172
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
173
|
+
var A4 = __toESM(require("@automerge/automerge"));
|
|
174
|
+
var import_log11 = require("@dxos/log");
|
|
175
|
+
var import_automerge_repo6 = require("@automerge/automerge-repo");
|
|
159
176
|
var import_async8 = require("@dxos/async");
|
|
160
|
-
var import_automerge_repo6 = require("@dxos/automerge/automerge-repo");
|
|
161
177
|
var import_context12 = require("@dxos/context");
|
|
162
178
|
var import_crypto = require("@dxos/crypto");
|
|
163
|
-
var
|
|
164
|
-
var
|
|
179
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
180
|
+
var import_log12 = require("@dxos/log");
|
|
165
181
|
var import_protocols6 = require("@dxos/protocols");
|
|
166
182
|
var import_buf = require("@dxos/protocols/buf");
|
|
167
183
|
var import_messenger_pb = require("@dxos/protocols/buf/dxos/edge/messenger_pb");
|
|
168
184
|
var import_util7 = require("@dxos/util");
|
|
169
185
|
var import_async9 = require("@dxos/async");
|
|
170
186
|
var import_context13 = require("@dxos/context");
|
|
171
|
-
var
|
|
172
|
-
var
|
|
187
|
+
var import_log13 = require("@dxos/log");
|
|
188
|
+
var import_echo_protocol7 = require("@dxos/echo-protocol");
|
|
173
189
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/documents-synchronizer.ts";
|
|
174
190
|
var MAX_UPDATE_FREQ = 10;
|
|
175
191
|
var DocumentsSynchronizer = class extends import_context.Resource {
|
|
176
192
|
constructor(_params) {
|
|
177
|
-
super();
|
|
178
|
-
this._params = _params;
|
|
179
|
-
this._syncStates = /* @__PURE__ */ new Map();
|
|
180
|
-
this._pendingUpdates = /* @__PURE__ */ new Set();
|
|
181
|
-
this._sendUpdatesJob = void 0;
|
|
193
|
+
super(), this._params = _params, this._syncStates = /* @__PURE__ */ new Map(), this._pendingUpdates = /* @__PURE__ */ new Set(), this._sendUpdatesJob = void 0;
|
|
182
194
|
}
|
|
183
195
|
addDocuments(documentIds, retryCounter = 0) {
|
|
184
196
|
if (retryCounter > 3) {
|
|
@@ -186,15 +198,15 @@ var DocumentsSynchronizer = class extends import_context.Resource {
|
|
|
186
198
|
documentIds
|
|
187
199
|
}, {
|
|
188
200
|
F: __dxlog_file,
|
|
189
|
-
L:
|
|
201
|
+
L: 50,
|
|
190
202
|
S: this,
|
|
191
203
|
C: (f, a) => f(...a)
|
|
192
204
|
});
|
|
193
205
|
return;
|
|
194
206
|
}
|
|
195
207
|
for (const documentId of documentIds) {
|
|
196
|
-
|
|
197
|
-
|
|
208
|
+
this._params.repo.find(documentId).then(async (doc) => {
|
|
209
|
+
await doc.whenReady();
|
|
198
210
|
this._startSync(doc);
|
|
199
211
|
this._pendingUpdates.add(doc.documentId);
|
|
200
212
|
this._sendUpdatesJob.trigger();
|
|
@@ -204,7 +216,7 @@ var DocumentsSynchronizer = class extends import_context.Resource {
|
|
|
204
216
|
error
|
|
205
217
|
}, {
|
|
206
218
|
F: __dxlog_file,
|
|
207
|
-
L:
|
|
219
|
+
L: 64,
|
|
208
220
|
S: this,
|
|
209
221
|
C: (f, a) => f(...a)
|
|
210
222
|
});
|
|
@@ -233,7 +245,7 @@ var DocumentsSynchronizer = class extends import_context.Resource {
|
|
|
233
245
|
update(updates) {
|
|
234
246
|
for (const { documentId, mutation, isNew } of updates) {
|
|
235
247
|
if (isNew) {
|
|
236
|
-
const doc = this._params.repo.
|
|
248
|
+
const { handle: doc } = this._params.repo.findWithProgress(documentId);
|
|
237
249
|
doc.update((doc2) => import_automerge.next.loadIncremental(doc2, mutation));
|
|
238
250
|
this._startSync(doc);
|
|
239
251
|
} else {
|
|
@@ -247,7 +259,7 @@ var DocumentsSynchronizer = class extends import_context.Resource {
|
|
|
247
259
|
documentId: doc.documentId
|
|
248
260
|
}, {
|
|
249
261
|
F: __dxlog_file,
|
|
250
|
-
L:
|
|
262
|
+
L: 103,
|
|
251
263
|
S: this,
|
|
252
264
|
C: (f, a) => f(...a)
|
|
253
265
|
});
|
|
@@ -290,17 +302,18 @@ var DocumentsSynchronizer = class extends import_context.Resource {
|
|
|
290
302
|
const syncState = this._syncStates.get(documentId);
|
|
291
303
|
(0, import_invariant2.invariant)(syncState, "Sync state for document not found", {
|
|
292
304
|
F: __dxlog_file,
|
|
293
|
-
L:
|
|
305
|
+
L: 144,
|
|
294
306
|
S: this,
|
|
295
307
|
A: [
|
|
296
308
|
"syncState",
|
|
297
309
|
"'Sync state for document not found'"
|
|
298
310
|
]
|
|
299
311
|
});
|
|
300
|
-
const
|
|
301
|
-
if (!doc) {
|
|
312
|
+
const handle = syncState.handle;
|
|
313
|
+
if (!handle || !handle.isReady() || !handle.doc()) {
|
|
302
314
|
return;
|
|
303
315
|
}
|
|
316
|
+
const doc = handle.doc();
|
|
304
317
|
const mutation = syncState.lastSentHead ? import_automerge.next.saveSince(doc, syncState.lastSentHead) : import_automerge.next.save(doc);
|
|
305
318
|
if (mutation.length === 0) {
|
|
306
319
|
return;
|
|
@@ -312,7 +325,7 @@ var DocumentsSynchronizer = class extends import_context.Resource {
|
|
|
312
325
|
const syncState = this._syncStates.get(documentId);
|
|
313
326
|
(0, import_invariant2.invariant)(syncState, "Sync state for document not found", {
|
|
314
327
|
F: __dxlog_file,
|
|
315
|
-
L:
|
|
328
|
+
L: 160,
|
|
316
329
|
S: this,
|
|
317
330
|
A: [
|
|
318
331
|
"syncState",
|
|
@@ -374,7 +387,7 @@ var CollectionSynchronizer = class extends import_context3.Resource {
|
|
|
374
387
|
state
|
|
375
388
|
}, {
|
|
376
389
|
F: __dxlog_file2,
|
|
377
|
-
L:
|
|
390
|
+
L: 76,
|
|
378
391
|
S: this,
|
|
379
392
|
C: (f, a) => f(...a)
|
|
380
393
|
});
|
|
@@ -393,7 +406,7 @@ var CollectionSynchronizer = class extends import_context3.Resource {
|
|
|
393
406
|
collectionId
|
|
394
407
|
}, {
|
|
395
408
|
F: __dxlog_file2,
|
|
396
|
-
L:
|
|
409
|
+
L: 90,
|
|
397
410
|
S: this,
|
|
398
411
|
C: (f, a) => f(...a)
|
|
399
412
|
});
|
|
@@ -476,7 +489,7 @@ var CollectionSynchronizer = class extends import_context3.Resource {
|
|
|
476
489
|
state
|
|
477
490
|
}, {
|
|
478
491
|
F: __dxlog_file2,
|
|
479
|
-
L:
|
|
492
|
+
L: 171,
|
|
480
493
|
S: this,
|
|
481
494
|
C: (f, a) => f(...a)
|
|
482
495
|
});
|
|
@@ -581,12 +594,13 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
581
594
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/echo-network-adapter.ts";
|
|
582
595
|
var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
583
596
|
constructor(_params) {
|
|
584
|
-
super();
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
this.
|
|
588
|
-
|
|
589
|
-
|
|
597
|
+
super(), this._params = _params, this._replicators = /* @__PURE__ */ new Set(), this._connections = /* @__PURE__ */ new Map(), this._lifecycleState = import_context4.LifecycleState.CLOSED, this._connected = new import_async5.Trigger(), this._ready = new import_async5.Trigger();
|
|
598
|
+
}
|
|
599
|
+
isReady() {
|
|
600
|
+
return this._lifecycleState === import_context4.LifecycleState.OPEN;
|
|
601
|
+
}
|
|
602
|
+
whenReady() {
|
|
603
|
+
return this._ready.wait();
|
|
590
604
|
}
|
|
591
605
|
connect(peerId, peerMetadata) {
|
|
592
606
|
this.peerId = peerId;
|
|
@@ -603,15 +617,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
603
617
|
return;
|
|
604
618
|
}
|
|
605
619
|
this._lifecycleState = import_context4.LifecycleState.OPEN;
|
|
606
|
-
(
|
|
607
|
-
F: __dxlog_file3,
|
|
608
|
-
L: 82,
|
|
609
|
-
S: this,
|
|
610
|
-
C: (f, a) => f(...a)
|
|
611
|
-
});
|
|
612
|
-
this.emit("ready", {
|
|
613
|
-
network: this
|
|
614
|
-
});
|
|
620
|
+
this._ready.wake();
|
|
615
621
|
}
|
|
616
622
|
async close() {
|
|
617
623
|
if (this._lifecycleState === import_context4.LifecycleState.CLOSED) {
|
|
@@ -621,6 +627,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
621
627
|
await replicator.disconnect();
|
|
622
628
|
}
|
|
623
629
|
this._replicators.clear();
|
|
630
|
+
this._ready.reset();
|
|
624
631
|
this._lifecycleState = import_context4.LifecycleState.CLOSED;
|
|
625
632
|
}
|
|
626
633
|
async whenConnected() {
|
|
@@ -631,7 +638,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
631
638
|
async addReplicator(replicator) {
|
|
632
639
|
(0, import_invariant4.invariant)(this._lifecycleState === import_context4.LifecycleState.OPEN, void 0, {
|
|
633
640
|
F: __dxlog_file3,
|
|
634
|
-
L:
|
|
641
|
+
L: 115,
|
|
635
642
|
S: this,
|
|
636
643
|
A: [
|
|
637
644
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -640,7 +647,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
640
647
|
});
|
|
641
648
|
(0, import_invariant4.invariant)(this.peerId, void 0, {
|
|
642
649
|
F: __dxlog_file3,
|
|
643
|
-
L:
|
|
650
|
+
L: 116,
|
|
644
651
|
S: this,
|
|
645
652
|
A: [
|
|
646
653
|
"this.peerId",
|
|
@@ -649,7 +656,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
649
656
|
});
|
|
650
657
|
(0, import_invariant4.invariant)(!this._replicators.has(replicator), void 0, {
|
|
651
658
|
F: __dxlog_file3,
|
|
652
|
-
L:
|
|
659
|
+
L: 117,
|
|
653
660
|
S: this,
|
|
654
661
|
A: [
|
|
655
662
|
"!this._replicators.has(replicator)",
|
|
@@ -666,14 +673,14 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
666
673
|
getContainingSpaceForDocument: this._params.getContainingSpaceForDocument,
|
|
667
674
|
getContainingSpaceIdForDocument: async (documentId) => {
|
|
668
675
|
const key = await this._params.getContainingSpaceForDocument(documentId);
|
|
669
|
-
return key ? (0,
|
|
676
|
+
return key ? (0, import_chunk_SG2PL5RH.createIdFromSpaceKey)(key) : null;
|
|
670
677
|
}
|
|
671
678
|
});
|
|
672
679
|
}
|
|
673
680
|
async removeReplicator(replicator) {
|
|
674
681
|
(0, import_invariant4.invariant)(this._lifecycleState === import_context4.LifecycleState.OPEN, void 0, {
|
|
675
682
|
F: __dxlog_file3,
|
|
676
|
-
L:
|
|
683
|
+
L: 136,
|
|
677
684
|
S: this,
|
|
678
685
|
A: [
|
|
679
686
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -682,7 +689,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
682
689
|
});
|
|
683
690
|
(0, import_invariant4.invariant)(this._replicators.has(replicator), void 0, {
|
|
684
691
|
F: __dxlog_file3,
|
|
685
|
-
L:
|
|
692
|
+
L: 137,
|
|
686
693
|
S: this,
|
|
687
694
|
A: [
|
|
688
695
|
"this._replicators.has(replicator)",
|
|
@@ -738,7 +745,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
738
745
|
if (connectionEntry.isOpen) {
|
|
739
746
|
import_log5.log.catch(err, void 0, {
|
|
740
747
|
F: __dxlog_file3,
|
|
741
|
-
L:
|
|
748
|
+
L: 197,
|
|
742
749
|
S: this,
|
|
743
750
|
C: (f, a) => f(...a)
|
|
744
751
|
});
|
|
@@ -759,13 +766,13 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
759
766
|
peerId: connection.peerId
|
|
760
767
|
}, {
|
|
761
768
|
F: __dxlog_file3,
|
|
762
|
-
L:
|
|
769
|
+
L: 215,
|
|
763
770
|
S: this,
|
|
764
771
|
C: (f, a) => f(...a)
|
|
765
772
|
});
|
|
766
773
|
(0, import_invariant4.invariant)(!this._connections.has(connection.peerId), void 0, {
|
|
767
774
|
F: __dxlog_file3,
|
|
768
|
-
L:
|
|
775
|
+
L: 216,
|
|
769
776
|
S: this,
|
|
770
777
|
A: [
|
|
771
778
|
"!this._connections.has(connection.peerId as PeerId)",
|
|
@@ -794,7 +801,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
794
801
|
if (connectionEntry.isOpen) {
|
|
795
802
|
import_log5.log.catch(err, void 0, {
|
|
796
803
|
F: __dxlog_file3,
|
|
797
|
-
L:
|
|
804
|
+
L: 235,
|
|
798
805
|
S: this,
|
|
799
806
|
C: (f, a) => f(...a)
|
|
800
807
|
});
|
|
@@ -805,7 +812,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
805
812
|
peerId: connection.peerId
|
|
806
813
|
}, {
|
|
807
814
|
F: __dxlog_file3,
|
|
808
|
-
L:
|
|
815
|
+
L: 240,
|
|
809
816
|
S: this,
|
|
810
817
|
C: (f, a) => f(...a)
|
|
811
818
|
});
|
|
@@ -837,14 +844,14 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
837
844
|
peerId: connection.peerId
|
|
838
845
|
}, {
|
|
839
846
|
F: __dxlog_file3,
|
|
840
|
-
L:
|
|
847
|
+
L: 268,
|
|
841
848
|
S: this,
|
|
842
849
|
C: (f, a) => f(...a)
|
|
843
850
|
});
|
|
844
851
|
const entry = this._connections.get(connection.peerId);
|
|
845
852
|
(0, import_invariant4.invariant)(entry, void 0, {
|
|
846
853
|
F: __dxlog_file3,
|
|
847
|
-
L:
|
|
854
|
+
L: 270,
|
|
848
855
|
S: this,
|
|
849
856
|
A: [
|
|
850
857
|
"entry",
|
|
@@ -861,14 +868,14 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
861
868
|
peerId: connection.peerId
|
|
862
869
|
}, {
|
|
863
870
|
F: __dxlog_file3,
|
|
864
|
-
L:
|
|
871
|
+
L: 276,
|
|
865
872
|
S: this,
|
|
866
873
|
C: (f, a) => f(...a)
|
|
867
874
|
});
|
|
868
875
|
const entry = this._connections.get(connection.peerId);
|
|
869
876
|
(0, import_invariant4.invariant)(entry, void 0, {
|
|
870
877
|
F: __dxlog_file3,
|
|
871
|
-
L:
|
|
878
|
+
L: 278,
|
|
872
879
|
S: this,
|
|
873
880
|
A: [
|
|
874
881
|
"entry",
|
|
@@ -882,13 +889,13 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
882
889
|
this._params.monitor?.recordPeerDisconnected(connection.peerId);
|
|
883
890
|
void entry.reader.cancel().catch((err) => import_log5.log.catch(err, void 0, {
|
|
884
891
|
F: __dxlog_file3,
|
|
885
|
-
L:
|
|
892
|
+
L: 284,
|
|
886
893
|
S: this,
|
|
887
894
|
C: (f, a) => f(...a)
|
|
888
895
|
}));
|
|
889
896
|
void entry.writer.abort().catch((err) => import_log5.log.catch(err, void 0, {
|
|
890
897
|
F: __dxlog_file3,
|
|
891
|
-
L:
|
|
898
|
+
L: 285,
|
|
892
899
|
S: this,
|
|
893
900
|
C: (f, a) => f(...a)
|
|
894
901
|
}));
|
|
@@ -939,8 +946,7 @@ var HeadsStore = class {
|
|
|
939
946
|
};
|
|
940
947
|
var LevelDBStorageAdapter = class extends import_context5.Resource {
|
|
941
948
|
constructor(_params) {
|
|
942
|
-
super();
|
|
943
|
-
this._params = _params;
|
|
949
|
+
super(), this._params = _params;
|
|
944
950
|
}
|
|
945
951
|
async load(keyArray) {
|
|
946
952
|
try {
|
|
@@ -1047,6 +1053,12 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1047
1053
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1048
1054
|
}
|
|
1049
1055
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
1056
|
+
var FIND_PARAMS = {
|
|
1057
|
+
allowableStates: [
|
|
1058
|
+
"ready",
|
|
1059
|
+
"requesting"
|
|
1060
|
+
]
|
|
1061
|
+
};
|
|
1050
1062
|
var AutomergeHost = class extends import_context2.Resource {
|
|
1051
1063
|
constructor({ db, indexMetadataStore, dataMonitor, peerIdProvider, getSpaceKeyByRootDocumentId }) {
|
|
1052
1064
|
super();
|
|
@@ -1146,7 +1158,7 @@ var AutomergeHost = class extends import_context2.Resource {
|
|
|
1146
1158
|
handle = this._repo.handles[documentId];
|
|
1147
1159
|
}
|
|
1148
1160
|
if (!handle) {
|
|
1149
|
-
handle = this._repo.find(documentId);
|
|
1161
|
+
handle = await this._repo.find(documentId, FIND_PARAMS);
|
|
1150
1162
|
}
|
|
1151
1163
|
if (!handle.isReady()) {
|
|
1152
1164
|
if (!opts?.timeout) {
|
|
@@ -1202,12 +1214,12 @@ var AutomergeHost = class extends import_context2.Resource {
|
|
|
1202
1214
|
await Promise.all(headsToWait.map(async (entry, index) => {
|
|
1203
1215
|
const handle = await this.loadDoc(import_context2.Context.default(void 0, {
|
|
1204
1216
|
F: __dxlog_file4,
|
|
1205
|
-
L:
|
|
1217
|
+
L: 288
|
|
1206
1218
|
}), entry.documentId);
|
|
1207
1219
|
await waitForHeads(handle, entry.heads);
|
|
1208
1220
|
}));
|
|
1209
1221
|
}
|
|
1210
|
-
await this._repo.flush(documentIds.filter((documentId) =>
|
|
1222
|
+
await this._repo.flush(documentIds.filter((documentId) => this._repo.handles[documentId] && this._repo.handles[documentId].isReady()));
|
|
1211
1223
|
}
|
|
1212
1224
|
async reIndexHeads(documentIds) {
|
|
1213
1225
|
for (const documentId of documentIds) {
|
|
@@ -1215,46 +1227,30 @@ var AutomergeHost = class extends import_context2.Resource {
|
|
|
1215
1227
|
documentId
|
|
1216
1228
|
}, {
|
|
1217
1229
|
F: __dxlog_file4,
|
|
1218
|
-
L:
|
|
1230
|
+
L: 302,
|
|
1219
1231
|
S: this,
|
|
1220
1232
|
C: (f, a) => f(...a)
|
|
1221
1233
|
});
|
|
1222
|
-
const handle = this._repo.find(documentId);
|
|
1223
|
-
|
|
1224
|
-
"ready",
|
|
1225
|
-
"requesting"
|
|
1226
|
-
]);
|
|
1227
|
-
if (handle.inState([
|
|
1228
|
-
"requesting"
|
|
1229
|
-
])) {
|
|
1234
|
+
const handle = await this._repo.find(documentId, FIND_PARAMS);
|
|
1235
|
+
if (!handle.isReady()) {
|
|
1230
1236
|
import_log3.log.warn("document is not available locally, skipping", {
|
|
1231
1237
|
documentId
|
|
1232
1238
|
}, {
|
|
1233
1239
|
F: __dxlog_file4,
|
|
1234
|
-
L:
|
|
1240
|
+
L: 305,
|
|
1235
1241
|
S: this,
|
|
1236
1242
|
C: (f, a) => f(...a)
|
|
1237
1243
|
});
|
|
1238
1244
|
continue;
|
|
1239
1245
|
}
|
|
1240
|
-
const
|
|
1241
|
-
(0, import_invariant3.invariant)(doc, void 0, {
|
|
1242
|
-
F: __dxlog_file4,
|
|
1243
|
-
L: 303,
|
|
1244
|
-
S: this,
|
|
1245
|
-
A: [
|
|
1246
|
-
"doc",
|
|
1247
|
-
""
|
|
1248
|
-
]
|
|
1249
|
-
});
|
|
1250
|
-
const heads = (0, import_automerge2.getHeads)(doc);
|
|
1246
|
+
const heads = handle.heads();
|
|
1251
1247
|
const batch = this._db.batch();
|
|
1252
1248
|
this._headsStore.setHeads(documentId, heads, batch);
|
|
1253
1249
|
await batch.write();
|
|
1254
1250
|
}
|
|
1255
1251
|
import_log3.log.info("done re-indexing heads", void 0, {
|
|
1256
1252
|
F: __dxlog_file4,
|
|
1257
|
-
L:
|
|
1253
|
+
L: 314,
|
|
1258
1254
|
S: this,
|
|
1259
1255
|
C: (f, a) => f(...a)
|
|
1260
1256
|
});
|
|
@@ -1280,16 +1276,16 @@ var AutomergeHost = class extends import_context2.Resource {
|
|
|
1280
1276
|
}
|
|
1281
1277
|
async _beforeSave({ path, batch }) {
|
|
1282
1278
|
const handle = this._repo.handles[path[0]];
|
|
1283
|
-
if (!handle) {
|
|
1279
|
+
if (!handle || !handle.isReady()) {
|
|
1284
1280
|
return;
|
|
1285
1281
|
}
|
|
1286
|
-
const doc = handle.
|
|
1282
|
+
const doc = handle.doc();
|
|
1287
1283
|
if (!doc) {
|
|
1288
1284
|
return;
|
|
1289
1285
|
}
|
|
1290
1286
|
const heads = (0, import_automerge2.getHeads)(doc);
|
|
1291
1287
|
this._headsStore.setHeads(handle.documentId, heads, batch);
|
|
1292
|
-
const spaceKey =
|
|
1288
|
+
const spaceKey = import_echo_protocol.DatabaseDirectory.getSpaceKey(doc) ?? void 0;
|
|
1293
1289
|
const objectIds = Object.keys(doc.objects ?? {});
|
|
1294
1290
|
const encodedIds = objectIds.map((objectId) => import_protocols.objectPointerCodec.encode({
|
|
1295
1291
|
documentId: handle.documentId,
|
|
@@ -1317,7 +1313,7 @@ var AutomergeHost = class extends import_context2.Resource {
|
|
|
1317
1313
|
async _afterSave(path) {
|
|
1318
1314
|
this._indexMetadataStore.notifyMarkedDirty();
|
|
1319
1315
|
const documentId = path[0];
|
|
1320
|
-
const document = this._repo.handles[documentId]?.
|
|
1316
|
+
const document = this._repo.handles[documentId]?.doc();
|
|
1321
1317
|
if (document) {
|
|
1322
1318
|
const heads = (0, import_automerge2.getHeads)(document);
|
|
1323
1319
|
this._onHeadsChanged(documentId, heads);
|
|
@@ -1337,9 +1333,12 @@ var AutomergeHost = class extends import_context2.Resource {
|
|
|
1337
1333
|
return false;
|
|
1338
1334
|
}
|
|
1339
1335
|
async _getContainingSpaceForDocument(documentId) {
|
|
1340
|
-
const
|
|
1341
|
-
if (
|
|
1342
|
-
|
|
1336
|
+
const handle = this._repo.handles[documentId];
|
|
1337
|
+
if (handle.state === "loading") {
|
|
1338
|
+
await handle.whenReady();
|
|
1339
|
+
}
|
|
1340
|
+
if (handle && handle.isReady() && handle.doc()) {
|
|
1341
|
+
const spaceKeyHex = import_echo_protocol.DatabaseDirectory.getSpaceKey(handle.doc());
|
|
1343
1342
|
if (spaceKeyHex) {
|
|
1344
1343
|
return import_keys2.PublicKey.from(spaceKeyHex);
|
|
1345
1344
|
}
|
|
@@ -1354,7 +1353,10 @@ var AutomergeHost = class extends import_context2.Resource {
|
|
|
1354
1353
|
* Flush documents to disk.
|
|
1355
1354
|
*/
|
|
1356
1355
|
async flush({ documentIds } = {}) {
|
|
1357
|
-
const loadedDocuments = documentIds?.filter((documentId) =>
|
|
1356
|
+
const loadedDocuments = documentIds?.filter((documentId) => {
|
|
1357
|
+
const handle = this._repo.handles[documentId];
|
|
1358
|
+
return handle && handle.isReady();
|
|
1359
|
+
});
|
|
1358
1360
|
await this._repo.flush(loadedDocuments);
|
|
1359
1361
|
}
|
|
1360
1362
|
async getHeads(documentIds) {
|
|
@@ -1362,9 +1364,9 @@ var AutomergeHost = class extends import_context2.Resource {
|
|
|
1362
1364
|
const storeRequestIds = [];
|
|
1363
1365
|
const storeResultIndices = [];
|
|
1364
1366
|
for (const documentId of documentIds) {
|
|
1365
|
-
const
|
|
1366
|
-
if (doc) {
|
|
1367
|
-
result.push((0, import_automerge2.getHeads)(doc));
|
|
1367
|
+
const handle = this._repo.handles[documentId];
|
|
1368
|
+
if (handle && handle.isReady() && handle.doc()) {
|
|
1369
|
+
result.push((0, import_automerge2.getHeads)(handle.doc()));
|
|
1368
1370
|
} else {
|
|
1369
1371
|
storeRequestIds.push(documentId);
|
|
1370
1372
|
storeResultIndices.push(result.length);
|
|
@@ -1469,12 +1471,12 @@ var AutomergeHost = class extends import_context2.Resource {
|
|
|
1469
1471
|
count: toReplicate.length
|
|
1470
1472
|
}, {
|
|
1471
1473
|
F: __dxlog_file4,
|
|
1472
|
-
L:
|
|
1474
|
+
L: 557,
|
|
1473
1475
|
S: this,
|
|
1474
1476
|
C: (f, a) => f(...a)
|
|
1475
1477
|
});
|
|
1476
1478
|
for (const documentId of toReplicate) {
|
|
1477
|
-
this._repo.
|
|
1479
|
+
this._repo.findWithProgress(documentId);
|
|
1478
1480
|
}
|
|
1479
1481
|
}
|
|
1480
1482
|
_onHeadsChanged(documentId, heads) {
|
|
@@ -1511,19 +1513,12 @@ _ts_decorate3([
|
|
|
1511
1513
|
AutomergeHost = _ts_decorate3([
|
|
1512
1514
|
import_tracing.trace.resource()
|
|
1513
1515
|
], AutomergeHost);
|
|
1514
|
-
var getSpaceKeyFromDoc = (doc) => {
|
|
1515
|
-
const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
|
|
1516
|
-
if (rawSpaceKey == null) {
|
|
1517
|
-
return null;
|
|
1518
|
-
}
|
|
1519
|
-
return String(rawSpaceKey);
|
|
1520
|
-
};
|
|
1521
1516
|
var waitForHeads = async (handle, heads) => {
|
|
1522
1517
|
const unavailableHeads = new Set(heads);
|
|
1523
1518
|
await handle.whenReady();
|
|
1524
1519
|
await import_async3.Event.wrap(handle, "change").waitForCondition(() => {
|
|
1525
1520
|
for (const changeHash of unavailableHeads.values()) {
|
|
1526
|
-
if (changeIsPresentInDoc(handle.
|
|
1521
|
+
if (changeIsPresentInDoc(handle.doc(), changeHash)) {
|
|
1527
1522
|
unavailableHeads.delete(changeHash);
|
|
1528
1523
|
}
|
|
1529
1524
|
}
|
|
@@ -1536,7 +1531,7 @@ var changeIsPresentInDoc = (doc, changeHash) => {
|
|
|
1536
1531
|
var decodeCollectionState = (state) => {
|
|
1537
1532
|
(0, import_invariant3.invariant)(typeof state === "object" && state !== null, "Invalid state", {
|
|
1538
1533
|
F: __dxlog_file4,
|
|
1539
|
-
L:
|
|
1534
|
+
L: 608,
|
|
1540
1535
|
S: void 0,
|
|
1541
1536
|
A: [
|
|
1542
1537
|
"typeof state === 'object' && state !== null",
|
|
@@ -1552,11 +1547,7 @@ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipelin
|
|
|
1552
1547
|
var DEFAULT_FACTORY = (params) => new import_teleport_extension_automerge_replicator.AutomergeReplicator(...params);
|
|
1553
1548
|
var MeshReplicatorConnection = class extends import_context6.Resource {
|
|
1554
1549
|
constructor(_params) {
|
|
1555
|
-
super();
|
|
1556
|
-
this._params = _params;
|
|
1557
|
-
this.remoteDeviceKey = null;
|
|
1558
|
-
this._remotePeerId = null;
|
|
1559
|
-
this._isEnabled = false;
|
|
1550
|
+
super(), this._params = _params, this.remoteDeviceKey = null, this._remotePeerId = null, this._isEnabled = false;
|
|
1560
1551
|
let readableStreamController;
|
|
1561
1552
|
this.readable = new ReadableStream({
|
|
1562
1553
|
start: (controller) => {
|
|
@@ -1568,7 +1559,7 @@ var MeshReplicatorConnection = class extends import_context6.Resource {
|
|
|
1568
1559
|
write: async (message, controller) => {
|
|
1569
1560
|
(0, import_invariant6.invariant)(this._isEnabled, "Writing to a disabled connection", {
|
|
1570
1561
|
F: __dxlog_file5,
|
|
1571
|
-
L:
|
|
1562
|
+
L: 51,
|
|
1572
1563
|
S: this,
|
|
1573
1564
|
A: [
|
|
1574
1565
|
"this._isEnabled",
|
|
@@ -1601,7 +1592,7 @@ var MeshReplicatorConnection = class extends import_context6.Resource {
|
|
|
1601
1592
|
remotePeerId: remotePeerId.toHex()
|
|
1602
1593
|
}, {
|
|
1603
1594
|
F: __dxlog_file5,
|
|
1604
|
-
L:
|
|
1595
|
+
L: 80,
|
|
1605
1596
|
S: this,
|
|
1606
1597
|
C: (f, a) => f(...a)
|
|
1607
1598
|
});
|
|
@@ -1628,7 +1619,7 @@ var MeshReplicatorConnection = class extends import_context6.Resource {
|
|
|
1628
1619
|
get peerId() {
|
|
1629
1620
|
(0, import_invariant6.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1630
1621
|
F: __dxlog_file5,
|
|
1631
|
-
L:
|
|
1622
|
+
L: 106,
|
|
1632
1623
|
S: this,
|
|
1633
1624
|
A: [
|
|
1634
1625
|
"this._remotePeerId != null",
|
|
@@ -1653,7 +1644,7 @@ var MeshReplicatorConnection = class extends import_context6.Resource {
|
|
|
1653
1644
|
enable() {
|
|
1654
1645
|
(0, import_invariant6.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1655
1646
|
F: __dxlog_file5,
|
|
1656
|
-
L:
|
|
1647
|
+
L: 127,
|
|
1657
1648
|
S: this,
|
|
1658
1649
|
A: [
|
|
1659
1650
|
"this._remotePeerId != null",
|
|
@@ -1684,7 +1675,7 @@ var logSendSync = (message) => {
|
|
|
1684
1675
|
};
|
|
1685
1676
|
}, {
|
|
1686
1677
|
F: __dxlog_file5,
|
|
1687
|
-
L:
|
|
1678
|
+
L: 140,
|
|
1688
1679
|
S: void 0,
|
|
1689
1680
|
C: (f, a) => f(...a)
|
|
1690
1681
|
});
|
|
@@ -1695,7 +1686,7 @@ var getSpaceIdFromCollectionId = (collectionId) => {
|
|
|
1695
1686
|
const spaceId = collectionId.split(":")[1];
|
|
1696
1687
|
(0, import_invariant7.invariant)(import_keys4.SpaceId.isValid(spaceId), void 0, {
|
|
1697
1688
|
F: __dxlog_file6,
|
|
1698
|
-
L:
|
|
1689
|
+
L: 16,
|
|
1699
1690
|
S: void 0,
|
|
1700
1691
|
A: [
|
|
1701
1692
|
"SpaceId.isValid(spaceId)",
|
|
@@ -1843,7 +1834,7 @@ var MeshEchoReplicator = class {
|
|
|
1843
1834
|
});
|
|
1844
1835
|
return remoteDocumentExists;
|
|
1845
1836
|
}
|
|
1846
|
-
const spaceId = await (0,
|
|
1837
|
+
const spaceId = await (0, import_chunk_SG2PL5RH.createIdFromSpaceKey)(spaceKey);
|
|
1847
1838
|
const authorizedDevices = this._authorizedDevices.get(spaceId);
|
|
1848
1839
|
if (!connection.remoteDeviceKey) {
|
|
1849
1840
|
(0, import_log6.log)("device key not found for share policy check", {
|
|
@@ -1914,7 +1905,7 @@ var MeshEchoReplicator = class {
|
|
|
1914
1905
|
S: this,
|
|
1915
1906
|
C: (f, a) => f(...a)
|
|
1916
1907
|
});
|
|
1917
|
-
const spaceId = await (0,
|
|
1908
|
+
const spaceId = await (0, import_chunk_SG2PL5RH.createIdFromSpaceKey)(spaceKey);
|
|
1918
1909
|
(0, import_util4.defaultMap)(this._authorizedDevices, spaceId, () => new import_util4.ComplexSet(import_keys3.PublicKey.hash)).add(deviceKey);
|
|
1919
1910
|
for (const connection of this._connections) {
|
|
1920
1911
|
if (connection.isEnabled && connection.remoteDeviceKey && connection.remoteDeviceKey.equals(deviceKey)) {
|
|
@@ -1943,7 +1934,7 @@ var EchoDataMonitor = class {
|
|
|
1943
1934
|
this._localTimeSeries = createLocalTimeSeries();
|
|
1944
1935
|
this._storageAverages = createStorageAverages();
|
|
1945
1936
|
this._replicationAverages = createNetworkAverages();
|
|
1946
|
-
this.
|
|
1937
|
+
this._sizeByMessage = {};
|
|
1947
1938
|
this._lastReceivedMessages = new import_util5.CircularBuffer(100);
|
|
1948
1939
|
this._lastSentMessages = new import_util5.CircularBuffer(100);
|
|
1949
1940
|
this._connectionsCount = 0;
|
|
@@ -1981,8 +1972,8 @@ var EchoDataMonitor = class {
|
|
|
1981
1972
|
countPerSecond: this._replicationAverages.sentPerSecond.average(),
|
|
1982
1973
|
failedPerSecond: this._replicationAverages.sendsFailedPerSecond.average()
|
|
1983
1974
|
},
|
|
1984
|
-
|
|
1985
|
-
|
|
1975
|
+
countByMessage: this._computeMessageHistogram("type"),
|
|
1976
|
+
avgSizeByMessage: (0, import_util5.mapValues)(this._sizeByMessage, (summary) => summary.average())
|
|
1986
1977
|
}
|
|
1987
1978
|
};
|
|
1988
1979
|
}
|
|
@@ -2187,7 +2178,7 @@ var EchoDataMonitor = class {
|
|
|
2187
2178
|
messageCounts.failed++;
|
|
2188
2179
|
}
|
|
2189
2180
|
_getStatsForType(message) {
|
|
2190
|
-
const messageSize = this.
|
|
2181
|
+
const messageSize = this._sizeByMessage[message.type] ??= createSlidingWindow();
|
|
2191
2182
|
const messageCounts = this._activeCounters.byType[message.type] ??= createMessageCounter();
|
|
2192
2183
|
return {
|
|
2193
2184
|
messageCounts,
|
|
@@ -2301,7 +2292,7 @@ var DataServiceImpl = class {
|
|
|
2301
2292
|
ready();
|
|
2302
2293
|
}).catch((err) => import_log.log.catch(err, void 0, {
|
|
2303
2294
|
F: __dxlog_file8,
|
|
2304
|
-
L:
|
|
2295
|
+
L: 71,
|
|
2305
2296
|
S: this,
|
|
2306
2297
|
C: (f, a) => f(...a)
|
|
2307
2298
|
}));
|
|
@@ -2312,7 +2303,7 @@ var DataServiceImpl = class {
|
|
|
2312
2303
|
const synchronizer = this._subscriptions.get(request.subscriptionId);
|
|
2313
2304
|
(0, import_invariant.invariant)(synchronizer, "Subscription not found", {
|
|
2314
2305
|
F: __dxlog_file8,
|
|
2315
|
-
L:
|
|
2306
|
+
L: 78,
|
|
2316
2307
|
S: this,
|
|
2317
2308
|
A: [
|
|
2318
2309
|
"synchronizer",
|
|
@@ -2333,7 +2324,7 @@ var DataServiceImpl = class {
|
|
|
2333
2324
|
const synchronizer = this._subscriptions.get(request.subscriptionId);
|
|
2334
2325
|
(0, import_invariant.invariant)(synchronizer, "Subscription not found", {
|
|
2335
2326
|
F: __dxlog_file8,
|
|
2336
|
-
L:
|
|
2327
|
+
L: 93,
|
|
2337
2328
|
S: this,
|
|
2338
2329
|
A: [
|
|
2339
2330
|
"synchronizer",
|
|
@@ -2378,7 +2369,7 @@ var DataServiceImpl = class {
|
|
|
2378
2369
|
const spaceId = request.spaceId;
|
|
2379
2370
|
(0, import_invariant.invariant)(import_keys.SpaceId.isValid(spaceId), void 0, {
|
|
2380
2371
|
F: __dxlog_file8,
|
|
2381
|
-
L:
|
|
2372
|
+
L: 133,
|
|
2382
2373
|
S: this,
|
|
2383
2374
|
A: [
|
|
2384
2375
|
"SpaceId.isValid(spaceId)",
|
|
@@ -2431,12 +2422,12 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2431
2422
|
const { documentId, objectId } = import_protocols3.objectPointerCodec.decode(id);
|
|
2432
2423
|
const handle = await automergeHost.loadDoc(import_context8.Context.default(void 0, {
|
|
2433
2424
|
F: __dxlog_file9,
|
|
2434
|
-
L:
|
|
2425
|
+
L: 31
|
|
2435
2426
|
}), documentId);
|
|
2436
|
-
let doc = handle.
|
|
2427
|
+
let doc = handle.doc();
|
|
2437
2428
|
(0, import_invariant9.invariant)(doc, void 0, {
|
|
2438
2429
|
F: __dxlog_file9,
|
|
2439
|
-
L:
|
|
2430
|
+
L: 34,
|
|
2440
2431
|
S: this,
|
|
2441
2432
|
A: [
|
|
2442
2433
|
"doc",
|
|
@@ -2455,13 +2446,13 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2455
2446
|
originalHeads: currentHeads
|
|
2456
2447
|
}, {
|
|
2457
2448
|
F: __dxlog_file9,
|
|
2458
|
-
L:
|
|
2449
|
+
L: 45,
|
|
2459
2450
|
S: this,
|
|
2460
2451
|
C: (f, a) => f(...a)
|
|
2461
2452
|
});
|
|
2462
2453
|
}
|
|
2463
2454
|
}
|
|
2464
|
-
if (doc.version !==
|
|
2455
|
+
if (doc.version !== import_echo_protocol3.SpaceDocVersion.CURRENT) {
|
|
2465
2456
|
continue;
|
|
2466
2457
|
}
|
|
2467
2458
|
if (!doc.objects?.[objectId]) {
|
|
@@ -2469,7 +2460,7 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2469
2460
|
}
|
|
2470
2461
|
let newId = id;
|
|
2471
2462
|
if (import_protocols3.objectPointerCodec.getVersion(id) === import_protocols3.ObjectPointerVersion.V0) {
|
|
2472
|
-
const spaceKey =
|
|
2463
|
+
const spaceKey = import_echo_protocol3.DatabaseDirectory.getSpaceKey(doc) ?? void 0;
|
|
2473
2464
|
newId = import_protocols3.objectPointerCodec.encode({
|
|
2474
2465
|
documentId,
|
|
2475
2466
|
objectId,
|
|
@@ -2490,7 +2481,7 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2490
2481
|
error
|
|
2491
2482
|
}, {
|
|
2492
2483
|
F: __dxlog_file9,
|
|
2493
|
-
L:
|
|
2484
|
+
L: 71,
|
|
2494
2485
|
S: this,
|
|
2495
2486
|
C: (f, a) => f(...a)
|
|
2496
2487
|
});
|
|
@@ -2498,187 +2489,992 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2498
2489
|
}
|
|
2499
2490
|
}
|
|
2500
2491
|
);
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2492
|
+
var QueryError = class extends import_errors.BaseError.extend("QUERY_ERROR") {
|
|
2493
|
+
};
|
|
2494
|
+
(function(QueryPlan2) {
|
|
2495
|
+
QueryPlan2.Plan = Object.freeze({
|
|
2496
|
+
make: (steps) => ({
|
|
2497
|
+
steps
|
|
2498
|
+
})
|
|
2499
|
+
});
|
|
2500
|
+
QueryPlan2.FilterStep = Object.freeze({
|
|
2501
|
+
isNoop: (step) => {
|
|
2502
|
+
switch (step.filter.type) {
|
|
2503
|
+
case "object": {
|
|
2504
|
+
return step.filter.typename === null && (step.filter.id === void 0 || step.filter.id.length === 0) && (step.filter.props === void 0 || Object.keys(step.filter.props).length === 0) && (step.filter.foreignKeys === void 0 || step.filter.foreignKeys.length === 0);
|
|
2505
|
+
}
|
|
2506
|
+
default:
|
|
2507
|
+
return false;
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
});
|
|
2511
|
+
})(QueryPlan || (QueryPlan = {}));
|
|
2512
|
+
var QueryPlan;
|
|
2513
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/query/query-planner.ts";
|
|
2514
|
+
var DEFAULT_OPTIONS = {
|
|
2515
|
+
defaultTextSearchKind: "full-text"
|
|
2516
|
+
};
|
|
2517
|
+
var QueryPlanner = class {
|
|
2518
|
+
constructor(options) {
|
|
2519
|
+
this._options = {
|
|
2520
|
+
...DEFAULT_OPTIONS,
|
|
2521
|
+
...options
|
|
2522
|
+
};
|
|
2511
2523
|
}
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
+
createPlan(query) {
|
|
2525
|
+
let plan = this._generate(query, {
|
|
2526
|
+
...DEFAULT_CONTEXT,
|
|
2527
|
+
originalQuery: query
|
|
2528
|
+
});
|
|
2529
|
+
plan = this._optimizeEmptyFilters(plan);
|
|
2530
|
+
plan = this._optimizeSoloUnions(plan);
|
|
2531
|
+
return plan;
|
|
2532
|
+
}
|
|
2533
|
+
_generate(query, context) {
|
|
2534
|
+
switch (query.type) {
|
|
2535
|
+
case "options":
|
|
2536
|
+
return this._generateOptionsClause(query, context);
|
|
2537
|
+
case "select":
|
|
2538
|
+
return this._generateSelectClause(query, context);
|
|
2539
|
+
case "filter":
|
|
2540
|
+
return this._generateFilterClause(query, context);
|
|
2541
|
+
case "incoming-references":
|
|
2542
|
+
return this._generateIncomingReferencesClause(query, context);
|
|
2543
|
+
case "relation":
|
|
2544
|
+
return this._generateRelationClause(query, context);
|
|
2545
|
+
case "relation-traversal":
|
|
2546
|
+
return this._generateRelationTraversalClause(query, context);
|
|
2547
|
+
case "reference-traversal":
|
|
2548
|
+
return this._generateReferenceTraversalClause(query, context);
|
|
2549
|
+
case "union":
|
|
2550
|
+
return this._generateUnionClause(query, context);
|
|
2551
|
+
default:
|
|
2552
|
+
throw new QueryError(`Unsupported query type: ${query.type}`, {
|
|
2553
|
+
context: {
|
|
2554
|
+
query: context.originalQuery
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
_generateOptionsClause(query, context) {
|
|
2560
|
+
const newContext = {
|
|
2561
|
+
...context
|
|
2524
2562
|
};
|
|
2525
|
-
|
|
2563
|
+
if (query.options.spaceIds) {
|
|
2564
|
+
newContext.selectionSpaces = query.options.spaceIds;
|
|
2565
|
+
}
|
|
2566
|
+
if (query.options.deleted) {
|
|
2567
|
+
newContext.deletedHandling = query.options.deleted;
|
|
2568
|
+
}
|
|
2569
|
+
return this._generate(query.query, newContext);
|
|
2570
|
+
}
|
|
2571
|
+
_generateSelectClause(query, context) {
|
|
2572
|
+
return this._generateSelectionFromFilter(query.filter, context);
|
|
2573
|
+
}
|
|
2574
|
+
// TODO(dmaretskyi): This can be rewritten as a function of (filter[]) -> (selection ? undefined, rest: filter[]) that recurses onto itself.
|
|
2575
|
+
// TODO(dmaretskyi): If the tip of the query ast is a [select, ...filter] shape we can reorder the filters so the query is most efficient.
|
|
2576
|
+
_generateSelectionFromFilter(filter, context) {
|
|
2577
|
+
switch (filter.type) {
|
|
2578
|
+
case "object": {
|
|
2579
|
+
if (context.selectionInverted && filter.id === void 0 && filter.typename === null && Object.keys(filter.props).length === 0) {
|
|
2580
|
+
return QueryPlan.Plan.make([
|
|
2581
|
+
{
|
|
2582
|
+
_tag: "ClearWorkingSetStep"
|
|
2583
|
+
},
|
|
2584
|
+
...this._generateDeletedHandlingSteps(context)
|
|
2585
|
+
]);
|
|
2586
|
+
}
|
|
2587
|
+
if (context.selectionInverted) {
|
|
2588
|
+
throw new QueryError("Query too complex", {
|
|
2589
|
+
context: {
|
|
2590
|
+
query: context.originalQuery
|
|
2591
|
+
}
|
|
2592
|
+
});
|
|
2593
|
+
}
|
|
2594
|
+
if (filter.id && filter.id?.length > 0) {
|
|
2595
|
+
return QueryPlan.Plan.make([
|
|
2596
|
+
{
|
|
2597
|
+
_tag: "SelectStep",
|
|
2598
|
+
spaces: context.selectionSpaces,
|
|
2599
|
+
selector: {
|
|
2600
|
+
_tag: "IdSelector",
|
|
2601
|
+
objectIds: filter.id
|
|
2602
|
+
}
|
|
2603
|
+
},
|
|
2604
|
+
...this._generateDeletedHandlingSteps(context),
|
|
2605
|
+
{
|
|
2606
|
+
_tag: "FilterStep",
|
|
2607
|
+
filter: {
|
|
2608
|
+
...filter,
|
|
2609
|
+
id: void 0
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
]);
|
|
2613
|
+
} else if (filter.typename) {
|
|
2614
|
+
return QueryPlan.Plan.make([
|
|
2615
|
+
{
|
|
2616
|
+
_tag: "SelectStep",
|
|
2617
|
+
spaces: context.selectionSpaces,
|
|
2618
|
+
selector: {
|
|
2619
|
+
_tag: "TypeSelector",
|
|
2620
|
+
typename: [
|
|
2621
|
+
filter.typename
|
|
2622
|
+
],
|
|
2623
|
+
inverted: false
|
|
2624
|
+
}
|
|
2625
|
+
},
|
|
2626
|
+
...this._generateDeletedHandlingSteps(context),
|
|
2627
|
+
{
|
|
2628
|
+
_tag: "FilterStep",
|
|
2629
|
+
filter: {
|
|
2630
|
+
...filter,
|
|
2631
|
+
typename: null
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
]);
|
|
2635
|
+
} else {
|
|
2636
|
+
return QueryPlan.Plan.make([
|
|
2637
|
+
{
|
|
2638
|
+
_tag: "SelectStep",
|
|
2639
|
+
spaces: context.selectionSpaces,
|
|
2640
|
+
selector: {
|
|
2641
|
+
_tag: "WildcardSelector"
|
|
2642
|
+
}
|
|
2643
|
+
},
|
|
2644
|
+
...this._generateDeletedHandlingSteps(context),
|
|
2645
|
+
{
|
|
2646
|
+
_tag: "FilterStep",
|
|
2647
|
+
filter: {
|
|
2648
|
+
...filter
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
]);
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
case "text-search": {
|
|
2655
|
+
return QueryPlan.Plan.make([
|
|
2656
|
+
{
|
|
2657
|
+
_tag: "SelectStep",
|
|
2658
|
+
spaces: context.selectionSpaces,
|
|
2659
|
+
selector: {
|
|
2660
|
+
_tag: "TextSelector",
|
|
2661
|
+
text: filter.text,
|
|
2662
|
+
searchKind: filter.searchKind ?? this._options.defaultTextSearchKind
|
|
2663
|
+
}
|
|
2664
|
+
},
|
|
2665
|
+
...this._generateDeletedHandlingSteps(context)
|
|
2666
|
+
]);
|
|
2667
|
+
}
|
|
2668
|
+
case "compare":
|
|
2669
|
+
throw new QueryError("Query too complex", {
|
|
2670
|
+
context: {
|
|
2671
|
+
query: context.originalQuery
|
|
2672
|
+
}
|
|
2673
|
+
});
|
|
2674
|
+
case "in":
|
|
2675
|
+
throw new QueryError("Query too complex", {
|
|
2676
|
+
context: {
|
|
2677
|
+
query: context.originalQuery
|
|
2678
|
+
}
|
|
2679
|
+
});
|
|
2680
|
+
case "range":
|
|
2681
|
+
throw new QueryError("Query too complex", {
|
|
2682
|
+
context: {
|
|
2683
|
+
query: context.originalQuery
|
|
2684
|
+
}
|
|
2685
|
+
});
|
|
2686
|
+
case "not":
|
|
2687
|
+
return this._generateSelectionFromFilter(filter.filter, {
|
|
2688
|
+
...context,
|
|
2689
|
+
selectionInverted: !context.selectionInverted
|
|
2690
|
+
});
|
|
2691
|
+
case "and":
|
|
2692
|
+
throw new QueryError("Query too complex", {
|
|
2693
|
+
context: {
|
|
2694
|
+
query: context.originalQuery
|
|
2695
|
+
}
|
|
2696
|
+
});
|
|
2697
|
+
case "or":
|
|
2698
|
+
if (filter.filters.every(isTrivialTypenameFilter)) {
|
|
2699
|
+
const typenames = filter.filters.map((f) => {
|
|
2700
|
+
(0, import_invariant11.invariant)(f.type === "object" && f.typename !== null, void 0, {
|
|
2701
|
+
F: __dxlog_file10,
|
|
2702
|
+
L: 189,
|
|
2703
|
+
S: this,
|
|
2704
|
+
A: [
|
|
2705
|
+
"f.type === 'object' && f.typename !== null",
|
|
2706
|
+
""
|
|
2707
|
+
]
|
|
2708
|
+
});
|
|
2709
|
+
return f.typename;
|
|
2710
|
+
});
|
|
2711
|
+
return QueryPlan.Plan.make([
|
|
2712
|
+
{
|
|
2713
|
+
_tag: "SelectStep",
|
|
2714
|
+
spaces: context.selectionSpaces,
|
|
2715
|
+
selector: {
|
|
2716
|
+
_tag: "TypeSelector",
|
|
2717
|
+
typename: typenames,
|
|
2718
|
+
inverted: context.selectionInverted
|
|
2719
|
+
}
|
|
2720
|
+
},
|
|
2721
|
+
...this._generateDeletedHandlingSteps(context)
|
|
2722
|
+
]);
|
|
2723
|
+
} else {
|
|
2724
|
+
throw new QueryError("Query too complex", {
|
|
2725
|
+
context: {
|
|
2726
|
+
query: context.originalQuery
|
|
2727
|
+
}
|
|
2728
|
+
});
|
|
2729
|
+
}
|
|
2730
|
+
default:
|
|
2731
|
+
throw new QueryError(`Unsupported filter type: ${filter.type}`, {
|
|
2732
|
+
context: {
|
|
2733
|
+
query: context.originalQuery
|
|
2734
|
+
}
|
|
2735
|
+
});
|
|
2736
|
+
}
|
|
2526
2737
|
}
|
|
2527
|
-
|
|
2528
|
-
|
|
2738
|
+
_generateDeletedHandlingSteps(context) {
|
|
2739
|
+
switch (context.deletedHandling) {
|
|
2740
|
+
case "include":
|
|
2741
|
+
return [];
|
|
2742
|
+
case "exclude":
|
|
2743
|
+
return [
|
|
2744
|
+
{
|
|
2745
|
+
_tag: "FilterDeletedStep",
|
|
2746
|
+
mode: "only-non-deleted"
|
|
2747
|
+
}
|
|
2748
|
+
];
|
|
2749
|
+
case "only":
|
|
2750
|
+
return [
|
|
2751
|
+
{
|
|
2752
|
+
_tag: "FilterDeletedStep",
|
|
2753
|
+
mode: "only-deleted"
|
|
2754
|
+
}
|
|
2755
|
+
];
|
|
2756
|
+
}
|
|
2529
2757
|
}
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
} else {
|
|
2548
|
-
if (this._firstRun) {
|
|
2549
|
-
this.metrics.documentsLoaded++;
|
|
2758
|
+
_generateUnionClause(query, context) {
|
|
2759
|
+
return QueryPlan.Plan.make([
|
|
2760
|
+
{
|
|
2761
|
+
_tag: "UnionStep",
|
|
2762
|
+
plans: query.queries.map((query2) => this._generate(query2, context))
|
|
2763
|
+
}
|
|
2764
|
+
]);
|
|
2765
|
+
}
|
|
2766
|
+
_generateReferenceTraversalClause(query, context) {
|
|
2767
|
+
return QueryPlan.Plan.make([
|
|
2768
|
+
...this._generate(query.anchor, context).steps,
|
|
2769
|
+
{
|
|
2770
|
+
_tag: "TraverseStep",
|
|
2771
|
+
traversal: {
|
|
2772
|
+
_tag: "ReferenceTraversal",
|
|
2773
|
+
direction: "outgoing",
|
|
2774
|
+
property: query.property
|
|
2550
2775
|
}
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2776
|
+
},
|
|
2777
|
+
...this._generateDeletedHandlingSteps(context)
|
|
2778
|
+
]);
|
|
2779
|
+
}
|
|
2780
|
+
_generateIncomingReferencesClause(query, context) {
|
|
2781
|
+
return QueryPlan.Plan.make([
|
|
2782
|
+
...this._generate(query.anchor, context).steps,
|
|
2783
|
+
{
|
|
2784
|
+
_tag: "TraverseStep",
|
|
2785
|
+
traversal: {
|
|
2786
|
+
_tag: "ReferenceTraversal",
|
|
2787
|
+
direction: "incoming",
|
|
2788
|
+
property: query.property
|
|
2789
|
+
}
|
|
2790
|
+
},
|
|
2791
|
+
...this._generateDeletedHandlingSteps(context),
|
|
2792
|
+
{
|
|
2793
|
+
_tag: "FilterStep",
|
|
2794
|
+
filter: {
|
|
2795
|
+
type: "object",
|
|
2796
|
+
typename: query.typename,
|
|
2797
|
+
props: {}
|
|
2557
2798
|
}
|
|
2558
|
-
spaceKey = getSpaceKeyFromDoc(handle.docSync());
|
|
2559
2799
|
}
|
|
2560
|
-
|
|
2561
|
-
|
|
2800
|
+
]);
|
|
2801
|
+
}
|
|
2802
|
+
_generateRelationTraversalClause(query, context) {
|
|
2803
|
+
switch (query.direction) {
|
|
2804
|
+
case "source": {
|
|
2805
|
+
return QueryPlan.Plan.make([
|
|
2806
|
+
...this._generate(query.anchor, context).steps,
|
|
2807
|
+
createRelationTraversalStep("relation-to-source"),
|
|
2808
|
+
...this._generateDeletedHandlingSteps(context)
|
|
2809
|
+
]);
|
|
2562
2810
|
}
|
|
2563
|
-
|
|
2564
|
-
return
|
|
2811
|
+
case "target": {
|
|
2812
|
+
return QueryPlan.Plan.make([
|
|
2813
|
+
...this._generate(query.anchor, context).steps,
|
|
2814
|
+
createRelationTraversalStep("relation-to-target"),
|
|
2815
|
+
...this._generateDeletedHandlingSteps(context)
|
|
2816
|
+
]);
|
|
2565
2817
|
}
|
|
2566
|
-
|
|
2567
|
-
this.
|
|
2818
|
+
case "both": {
|
|
2819
|
+
const anchorPlan = this._generate(query.anchor, context);
|
|
2820
|
+
return QueryPlan.Plan.make([
|
|
2821
|
+
...anchorPlan.steps,
|
|
2822
|
+
{
|
|
2823
|
+
_tag: "UnionStep",
|
|
2824
|
+
plans: [
|
|
2825
|
+
QueryPlan.Plan.make([
|
|
2826
|
+
createRelationTraversalStep("relation-to-source")
|
|
2827
|
+
]),
|
|
2828
|
+
QueryPlan.Plan.make([
|
|
2829
|
+
createRelationTraversalStep("relation-to-target")
|
|
2830
|
+
])
|
|
2831
|
+
]
|
|
2832
|
+
},
|
|
2833
|
+
...this._generateDeletedHandlingSteps(context)
|
|
2834
|
+
]);
|
|
2568
2835
|
}
|
|
2569
|
-
return {
|
|
2570
|
-
id: objectId,
|
|
2571
|
-
documentId,
|
|
2572
|
-
spaceId: await (0, import_echo_protocol3.createIdFromSpaceKey)(import_keys5.PublicKey.from(spaceKey)),
|
|
2573
|
-
spaceKey: import_keys5.PublicKey.from(spaceKey),
|
|
2574
|
-
rank: result.rank
|
|
2575
|
-
};
|
|
2576
|
-
}))).filter(import_util6.isNonNullable);
|
|
2577
|
-
if (this._firstRun) {
|
|
2578
|
-
this.metrics.documentLoadTime = performance.now() - beginFilter;
|
|
2579
2836
|
}
|
|
2837
|
+
}
|
|
2838
|
+
_generateRelationClause(query, context) {
|
|
2839
|
+
switch (query.direction) {
|
|
2840
|
+
case "outgoing": {
|
|
2841
|
+
return QueryPlan.Plan.make([
|
|
2842
|
+
...this._generate(query.anchor, context).steps,
|
|
2843
|
+
createRelationTraversalStep("source-to-relation"),
|
|
2844
|
+
...this._generateDeletedHandlingSteps(context),
|
|
2845
|
+
{
|
|
2846
|
+
_tag: "FilterStep",
|
|
2847
|
+
filter: query.filter ?? NOOP_FILTER
|
|
2848
|
+
}
|
|
2849
|
+
]);
|
|
2850
|
+
}
|
|
2851
|
+
case "incoming": {
|
|
2852
|
+
return QueryPlan.Plan.make([
|
|
2853
|
+
...this._generate(query.anchor, context).steps,
|
|
2854
|
+
createRelationTraversalStep("target-to-relation"),
|
|
2855
|
+
...this._generateDeletedHandlingSteps(context),
|
|
2856
|
+
{
|
|
2857
|
+
_tag: "FilterStep",
|
|
2858
|
+
filter: query.filter ?? NOOP_FILTER
|
|
2859
|
+
}
|
|
2860
|
+
]);
|
|
2861
|
+
}
|
|
2862
|
+
case "both": {
|
|
2863
|
+
const anchorPlan = this._generate(query.anchor, context);
|
|
2864
|
+
return QueryPlan.Plan.make([
|
|
2865
|
+
...anchorPlan.steps,
|
|
2866
|
+
{
|
|
2867
|
+
_tag: "UnionStep",
|
|
2868
|
+
plans: [
|
|
2869
|
+
QueryPlan.Plan.make([
|
|
2870
|
+
createRelationTraversalStep("source-to-relation")
|
|
2871
|
+
]),
|
|
2872
|
+
QueryPlan.Plan.make([
|
|
2873
|
+
createRelationTraversalStep("target-to-relation")
|
|
2874
|
+
])
|
|
2875
|
+
]
|
|
2876
|
+
},
|
|
2877
|
+
...this._generateDeletedHandlingSteps(context),
|
|
2878
|
+
{
|
|
2879
|
+
_tag: "FilterStep",
|
|
2880
|
+
filter: query.filter ?? NOOP_FILTER
|
|
2881
|
+
}
|
|
2882
|
+
]);
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
_generateFilterClause(query, context) {
|
|
2887
|
+
return QueryPlan.Plan.make([
|
|
2888
|
+
...this._generate(query.selection, context).steps,
|
|
2889
|
+
{
|
|
2890
|
+
_tag: "FilterStep",
|
|
2891
|
+
filter: query.filter
|
|
2892
|
+
}
|
|
2893
|
+
]);
|
|
2894
|
+
}
|
|
2895
|
+
/**
|
|
2896
|
+
* Removes filter steps that have no predicates.
|
|
2897
|
+
*/
|
|
2898
|
+
_optimizeEmptyFilters(plan) {
|
|
2899
|
+
return QueryPlan.Plan.make(plan.steps.filter((step) => {
|
|
2900
|
+
if (step._tag === "FilterStep") {
|
|
2901
|
+
return !QueryPlan.FilterStep.isNoop(step);
|
|
2902
|
+
} else {
|
|
2903
|
+
return true;
|
|
2904
|
+
}
|
|
2905
|
+
}).map((step) => {
|
|
2906
|
+
if (step._tag === "UnionStep") {
|
|
2907
|
+
return {
|
|
2908
|
+
_tag: "UnionStep",
|
|
2909
|
+
plans: step.plans.map((plan2) => this._optimizeEmptyFilters(plan2))
|
|
2910
|
+
};
|
|
2911
|
+
} else {
|
|
2912
|
+
return step;
|
|
2913
|
+
}
|
|
2914
|
+
}));
|
|
2915
|
+
}
|
|
2916
|
+
/**
|
|
2917
|
+
* Removes union steps that have only one child.
|
|
2918
|
+
*/
|
|
2919
|
+
_optimizeSoloUnions(plan) {
|
|
2920
|
+
return plan;
|
|
2921
|
+
}
|
|
2922
|
+
};
|
|
2923
|
+
var DEFAULT_CONTEXT = {
|
|
2924
|
+
originalQuery: null,
|
|
2925
|
+
selectionSpaces: [],
|
|
2926
|
+
deletedHandling: "exclude",
|
|
2927
|
+
selectionInverted: false
|
|
2928
|
+
};
|
|
2929
|
+
var NOOP_FILTER = {
|
|
2930
|
+
type: "object",
|
|
2931
|
+
typename: null,
|
|
2932
|
+
id: [],
|
|
2933
|
+
props: {}
|
|
2934
|
+
};
|
|
2935
|
+
var createRelationTraversalStep = (direction) => ({
|
|
2936
|
+
_tag: "TraverseStep",
|
|
2937
|
+
traversal: {
|
|
2938
|
+
_tag: "RelationTraversal",
|
|
2939
|
+
direction
|
|
2940
|
+
}
|
|
2941
|
+
});
|
|
2942
|
+
var isTrivialTypenameFilter = (filter) => {
|
|
2943
|
+
return filter.type === "object" && filter.typename !== null && Object.keys(filter.props).length === 0 && (filter.id === void 0 || filter.id.length === 0) && (filter.foreignKeys === void 0 || filter.foreignKeys.length === 0);
|
|
2944
|
+
};
|
|
2945
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/query/query-executor.ts";
|
|
2946
|
+
var ExecutionTrace = Object.freeze({
|
|
2947
|
+
makeEmpty: () => ({
|
|
2948
|
+
name: "Empty",
|
|
2949
|
+
details: "",
|
|
2950
|
+
objectCount: 0,
|
|
2951
|
+
documentsLoaded: 0,
|
|
2952
|
+
indexHits: 0,
|
|
2953
|
+
indexQueryTime: 0,
|
|
2954
|
+
documentLoadTime: 0,
|
|
2955
|
+
executionTime: 0,
|
|
2956
|
+
children: []
|
|
2957
|
+
}),
|
|
2958
|
+
format: (trace6) => {
|
|
2959
|
+
const go = (trace7, indent) => {
|
|
2960
|
+
return [
|
|
2961
|
+
`${" ".repeat(indent)} - ${trace7.name}(${trace7.details})`,
|
|
2962
|
+
`${" ".repeat(indent)} objects: ${trace7.objectCount} docs: ${trace7.documentsLoaded} index hits: ${trace7.indexHits} | total: ${trace7.executionTime.toFixed(0)}ms index: ${trace7.indexQueryTime.toFixed(0)}ms load: ${trace7.documentLoadTime.toFixed(0)}ms`,
|
|
2963
|
+
"",
|
|
2964
|
+
...trace7.children.map((child) => go(child, indent + 2))
|
|
2965
|
+
].join("\n");
|
|
2966
|
+
};
|
|
2967
|
+
return go(trace6, 0);
|
|
2968
|
+
}
|
|
2969
|
+
});
|
|
2970
|
+
var QueryExecutor = class extends import_context10.Resource {
|
|
2971
|
+
constructor(options) {
|
|
2972
|
+
super();
|
|
2973
|
+
this._trace = ExecutionTrace.makeEmpty();
|
|
2974
|
+
this._lastResultSet = [];
|
|
2975
|
+
this._indexer = options.indexer;
|
|
2976
|
+
this._automergeHost = options.automergeHost;
|
|
2977
|
+
this._spaceStateManager = options.spaceStateManager;
|
|
2978
|
+
this._id = options.queryId;
|
|
2979
|
+
this._query = options.query;
|
|
2980
|
+
this._reactivity = options.reactivity;
|
|
2981
|
+
const queryPlanner = new QueryPlanner();
|
|
2982
|
+
this._plan = queryPlanner.createPlan(this._query);
|
|
2983
|
+
}
|
|
2984
|
+
get query() {
|
|
2985
|
+
return this._query;
|
|
2986
|
+
}
|
|
2987
|
+
get plan() {
|
|
2988
|
+
return this._plan;
|
|
2989
|
+
}
|
|
2990
|
+
get trace() {
|
|
2991
|
+
return this._trace;
|
|
2992
|
+
}
|
|
2993
|
+
async _open(ctx) {
|
|
2994
|
+
}
|
|
2995
|
+
async _close(ctx) {
|
|
2996
|
+
}
|
|
2997
|
+
getResults() {
|
|
2998
|
+
return this._lastResultSet.map((item) => ({
|
|
2999
|
+
id: item.objectId,
|
|
3000
|
+
documentId: item.documentId,
|
|
3001
|
+
spaceId: item.spaceId,
|
|
3002
|
+
// TODO(dmaretskyi): Plumb through the rank.
|
|
3003
|
+
rank: 0
|
|
3004
|
+
}));
|
|
3005
|
+
}
|
|
3006
|
+
async execQuery() {
|
|
3007
|
+
(0, import_invariant10.invariant)(this._lifecycleState === import_context10.LifecycleState.OPEN, void 0, {
|
|
3008
|
+
F: __dxlog_file11,
|
|
3009
|
+
L: 171,
|
|
3010
|
+
S: this,
|
|
3011
|
+
A: [
|
|
3012
|
+
"this._lifecycleState === LifecycleState.OPEN",
|
|
3013
|
+
""
|
|
3014
|
+
]
|
|
3015
|
+
});
|
|
3016
|
+
const prevResultSet = this._lastResultSet;
|
|
3017
|
+
const { workingSet, trace: trace6 } = await this._execPlan(this._plan, this._lastResultSet);
|
|
3018
|
+
this._lastResultSet = workingSet;
|
|
3019
|
+
trace6.name = "Root";
|
|
3020
|
+
trace6.details = JSON.stringify({
|
|
3021
|
+
id: this._id
|
|
3022
|
+
});
|
|
3023
|
+
this._trace = trace6;
|
|
3024
|
+
const changed = prevResultSet.length !== workingSet.length || prevResultSet.some((item, index) => workingSet[index].objectId !== item.objectId || workingSet[index].spaceId !== item.spaceId || workingSet[index].documentId !== item.documentId);
|
|
3025
|
+
return {
|
|
3026
|
+
changed
|
|
3027
|
+
};
|
|
3028
|
+
}
|
|
3029
|
+
async _execPlan(plan, workingSet) {
|
|
3030
|
+
const trace6 = ExecutionTrace.makeEmpty();
|
|
3031
|
+
for (const step of plan.steps) {
|
|
3032
|
+
if (this._ctx.disposed) {
|
|
3033
|
+
throw new import_context10.ContextDisposedError();
|
|
3034
|
+
}
|
|
3035
|
+
const result = await this._execStep(step, workingSet);
|
|
3036
|
+
workingSet = result.workingSet;
|
|
3037
|
+
trace6.children.push(result.trace);
|
|
3038
|
+
}
|
|
3039
|
+
return {
|
|
3040
|
+
workingSet,
|
|
3041
|
+
trace: trace6
|
|
3042
|
+
};
|
|
3043
|
+
}
|
|
3044
|
+
async _execStep(step, workingSet) {
|
|
2580
3045
|
if (this._ctx.disposed) {
|
|
2581
3046
|
return {
|
|
2582
|
-
|
|
3047
|
+
workingSet,
|
|
3048
|
+
trace: ExecutionTrace.makeEmpty()
|
|
2583
3049
|
};
|
|
2584
3050
|
}
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
3051
|
+
let newWorkingSet, trace6;
|
|
3052
|
+
const begin = performance.now();
|
|
3053
|
+
switch (step._tag) {
|
|
3054
|
+
case "ClearWorkingSetStep":
|
|
3055
|
+
newWorkingSet = [];
|
|
3056
|
+
trace6 = ExecutionTrace.makeEmpty();
|
|
3057
|
+
break;
|
|
3058
|
+
case "SelectStep":
|
|
3059
|
+
({ workingSet: newWorkingSet, trace: trace6 } = await this._execSelectStep(step, workingSet));
|
|
3060
|
+
break;
|
|
3061
|
+
case "FilterStep":
|
|
3062
|
+
({ workingSet: newWorkingSet, trace: trace6 } = await this._execFilterStep(step, workingSet));
|
|
3063
|
+
break;
|
|
3064
|
+
case "FilterDeletedStep":
|
|
3065
|
+
({ workingSet: newWorkingSet, trace: trace6 } = await this._execFilterDeletedStep(step, workingSet));
|
|
3066
|
+
break;
|
|
3067
|
+
case "UnionStep":
|
|
3068
|
+
({ workingSet: newWorkingSet, trace: trace6 } = await this._execUnionStep(step, workingSet));
|
|
3069
|
+
break;
|
|
3070
|
+
case "TraverseStep":
|
|
3071
|
+
({ workingSet: newWorkingSet, trace: trace6 } = await this._execTraverseStep(step, workingSet));
|
|
3072
|
+
break;
|
|
3073
|
+
default:
|
|
3074
|
+
throw new Error(`Unknown step type: ${step._tag}`);
|
|
2588
3075
|
}
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
3076
|
+
trace6.executionTime = performance.now() - begin;
|
|
3077
|
+
return {
|
|
3078
|
+
workingSet: newWorkingSet,
|
|
3079
|
+
trace: trace6
|
|
3080
|
+
};
|
|
3081
|
+
}
|
|
3082
|
+
async _execSelectStep(step, workingSet) {
|
|
3083
|
+
workingSet = [
|
|
3084
|
+
...workingSet
|
|
3085
|
+
];
|
|
3086
|
+
const trace6 = {
|
|
3087
|
+
...ExecutionTrace.makeEmpty(),
|
|
3088
|
+
name: "Select",
|
|
3089
|
+
details: JSON.stringify(step.selector)
|
|
3090
|
+
};
|
|
3091
|
+
switch (step.selector._tag) {
|
|
3092
|
+
case "WildcardSelector": {
|
|
3093
|
+
const beginIndexQuery = performance.now();
|
|
3094
|
+
const indexHits = await this._indexer.execQuery({
|
|
3095
|
+
typenames: [],
|
|
3096
|
+
inverted: false
|
|
3097
|
+
});
|
|
3098
|
+
trace6.indexHits = +indexHits.length;
|
|
3099
|
+
trace6.indexQueryTime += performance.now() - beginIndexQuery;
|
|
3100
|
+
if (this._ctx.disposed) {
|
|
3101
|
+
return {
|
|
3102
|
+
workingSet,
|
|
3103
|
+
trace: trace6
|
|
3104
|
+
};
|
|
3105
|
+
}
|
|
3106
|
+
const documentLoadStart = performance.now();
|
|
3107
|
+
const results = await this._loadDocumentsAfterIndexQuery(indexHits);
|
|
3108
|
+
trace6.documentsLoaded += results.length;
|
|
3109
|
+
trace6.documentLoadTime += performance.now() - documentLoadStart;
|
|
3110
|
+
workingSet.push(...results.filter(import_util6.isNonNullable).filter((item) => step.spaces.includes(item.spaceId)));
|
|
3111
|
+
trace6.objectCount = workingSet.length;
|
|
3112
|
+
break;
|
|
3113
|
+
}
|
|
3114
|
+
case "IdSelector": {
|
|
3115
|
+
const beginLoad = performance.now();
|
|
3116
|
+
const items = await Promise.all(step.selector.objectIds.map((id) => this._loadFromDXN(import_keys5.DXN.fromLocalObjectId(id), {
|
|
3117
|
+
sourceSpaceId: step.spaces[0]
|
|
3118
|
+
})));
|
|
3119
|
+
trace6.documentLoadTime += performance.now() - beginLoad;
|
|
3120
|
+
workingSet.push(...items.filter(import_util6.isNonNullable));
|
|
3121
|
+
trace6.objectCount = workingSet.length;
|
|
3122
|
+
break;
|
|
3123
|
+
}
|
|
3124
|
+
case "TypeSelector": {
|
|
3125
|
+
const beginIndexQuery = performance.now();
|
|
3126
|
+
const indexHits = await this._indexer.execQuery({
|
|
3127
|
+
typenames: step.selector.typename,
|
|
3128
|
+
inverted: step.selector.inverted
|
|
3129
|
+
});
|
|
3130
|
+
trace6.indexHits = +indexHits.length;
|
|
3131
|
+
trace6.indexQueryTime += performance.now() - beginIndexQuery;
|
|
3132
|
+
if (this._ctx.disposed) {
|
|
3133
|
+
return {
|
|
3134
|
+
workingSet,
|
|
3135
|
+
trace: trace6
|
|
3136
|
+
};
|
|
3137
|
+
}
|
|
3138
|
+
const documentLoadStart = performance.now();
|
|
3139
|
+
const results = await this._loadDocumentsAfterIndexQuery(indexHits);
|
|
3140
|
+
trace6.documentsLoaded += results.length;
|
|
3141
|
+
trace6.documentLoadTime += performance.now() - documentLoadStart;
|
|
3142
|
+
workingSet.push(...results.filter(import_util6.isNonNullable).filter((item) => step.spaces.includes(item.spaceId)));
|
|
3143
|
+
trace6.objectCount = workingSet.length;
|
|
3144
|
+
break;
|
|
3145
|
+
}
|
|
3146
|
+
case "TextSelector": {
|
|
3147
|
+
const beginIndexQuery = performance.now();
|
|
3148
|
+
const indexHits = await this._indexer.execQuery({
|
|
3149
|
+
typenames: [],
|
|
3150
|
+
text: {
|
|
3151
|
+
query: step.selector.text,
|
|
3152
|
+
kind: import_effect2.Match.type().pipe(import_effect2.Match.withReturnType(), import_effect2.Match.when("full-text", () => "text"), import_effect2.Match.when("vector", () => "vector"), import_effect2.Match.orElseAbsurd)(step.selector.searchKind)
|
|
3153
|
+
}
|
|
3154
|
+
});
|
|
3155
|
+
trace6.indexHits = +indexHits.length;
|
|
3156
|
+
trace6.indexQueryTime += performance.now() - beginIndexQuery;
|
|
3157
|
+
if (this._ctx.disposed) {
|
|
3158
|
+
return {
|
|
3159
|
+
workingSet,
|
|
3160
|
+
trace: trace6
|
|
3161
|
+
};
|
|
3162
|
+
}
|
|
3163
|
+
const documentLoadStart = performance.now();
|
|
3164
|
+
const results = await this._loadDocumentsAfterIndexQuery(indexHits);
|
|
3165
|
+
trace6.documentsLoaded += results.length;
|
|
3166
|
+
trace6.documentLoadTime += performance.now() - documentLoadStart;
|
|
3167
|
+
workingSet.push(...results.filter(import_util6.isNonNullable).filter((item) => step.spaces.includes(item.spaceId)));
|
|
3168
|
+
trace6.objectCount = workingSet.length;
|
|
3169
|
+
break;
|
|
3170
|
+
}
|
|
3171
|
+
default:
|
|
3172
|
+
throw new Error(`Unknown selector type: ${step.selector._tag}`);
|
|
2594
3173
|
}
|
|
2595
|
-
this._results = results;
|
|
2596
3174
|
return {
|
|
2597
|
-
|
|
3175
|
+
workingSet,
|
|
3176
|
+
trace: trace6
|
|
2598
3177
|
};
|
|
2599
3178
|
}
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
3179
|
+
async _execFilterStep(step, workingSet) {
|
|
3180
|
+
const result = workingSet.filter((item) => (0, import_chunk_HOPOFWAL.filterMatchObject)(step.filter, {
|
|
3181
|
+
id: item.objectId,
|
|
3182
|
+
spaceId: item.spaceId,
|
|
3183
|
+
doc: item.doc
|
|
3184
|
+
}));
|
|
3185
|
+
return {
|
|
3186
|
+
workingSet: result,
|
|
3187
|
+
trace: {
|
|
3188
|
+
...ExecutionTrace.makeEmpty(),
|
|
3189
|
+
name: "Filter",
|
|
3190
|
+
details: JSON.stringify(step.filter),
|
|
3191
|
+
objectCount: result.length
|
|
3192
|
+
}
|
|
3193
|
+
};
|
|
3194
|
+
}
|
|
3195
|
+
async _execFilterDeletedStep(step, workingSet) {
|
|
3196
|
+
const expected = step.mode === "only-deleted";
|
|
3197
|
+
const result = workingSet.filter((item) => import_echo_protocol5.ObjectStructure.isDeleted(item.doc) === expected);
|
|
3198
|
+
return {
|
|
3199
|
+
workingSet: result,
|
|
3200
|
+
trace: {
|
|
3201
|
+
...ExecutionTrace.makeEmpty(),
|
|
3202
|
+
name: "FilterDeleted",
|
|
3203
|
+
details: step.mode,
|
|
3204
|
+
objectCount: result.length
|
|
3205
|
+
}
|
|
3206
|
+
};
|
|
3207
|
+
}
|
|
3208
|
+
// TODO(dmaretskyi): This needs to be completed.
|
|
3209
|
+
async _execTraverseStep(step, workingSet) {
|
|
3210
|
+
const trace6 = {
|
|
3211
|
+
...ExecutionTrace.makeEmpty(),
|
|
3212
|
+
name: "Traverse",
|
|
3213
|
+
details: JSON.stringify(step.traversal)
|
|
3214
|
+
};
|
|
3215
|
+
const newWorkingSet = [];
|
|
3216
|
+
switch (step.traversal._tag) {
|
|
3217
|
+
case "ReferenceTraversal": {
|
|
3218
|
+
switch (step.traversal.direction) {
|
|
3219
|
+
case "outgoing": {
|
|
3220
|
+
const property = import_indexing4.EscapedPropPath.unescape(step.traversal.property);
|
|
3221
|
+
const refs = workingSet.map((item) => {
|
|
3222
|
+
const ref = (0, import_util6.getDeep)(item.doc.data, property);
|
|
3223
|
+
if (!(0, import_echo_protocol5.isEncodedReference)(ref)) {
|
|
3224
|
+
return null;
|
|
3225
|
+
}
|
|
3226
|
+
try {
|
|
3227
|
+
return {
|
|
3228
|
+
ref: import_keys5.DXN.parse(ref["/"]),
|
|
3229
|
+
spaceId: item.spaceId
|
|
3230
|
+
};
|
|
3231
|
+
} catch {
|
|
3232
|
+
import_log10.log.warn("Invalid reference", {
|
|
3233
|
+
ref: ref["/"]
|
|
3234
|
+
}, {
|
|
3235
|
+
F: __dxlog_file11,
|
|
3236
|
+
L: 421,
|
|
3237
|
+
S: this,
|
|
3238
|
+
C: (f, a) => f(...a)
|
|
3239
|
+
});
|
|
3240
|
+
return null;
|
|
3241
|
+
}
|
|
3242
|
+
}).filter(import_util6.isNonNullable);
|
|
3243
|
+
const beginLoad = performance.now();
|
|
3244
|
+
const items = await Promise.all(refs.map(({ ref, spaceId }) => this._loadFromDXN(ref, {
|
|
3245
|
+
sourceSpaceId: spaceId
|
|
3246
|
+
})));
|
|
3247
|
+
trace6.documentLoadTime += performance.now() - beginLoad;
|
|
3248
|
+
newWorkingSet.push(...items.filter(import_util6.isNonNullable));
|
|
3249
|
+
trace6.objectCount = newWorkingSet.length;
|
|
3250
|
+
break;
|
|
3251
|
+
}
|
|
3252
|
+
case "incoming": {
|
|
3253
|
+
const indexHits = await this._indexer.execQuery({
|
|
3254
|
+
typenames: [],
|
|
3255
|
+
inverted: false,
|
|
3256
|
+
graph: {
|
|
3257
|
+
kind: "inbound-reference",
|
|
3258
|
+
property: step.traversal.property,
|
|
3259
|
+
anchors: workingSet.map((item) => item.objectId)
|
|
3260
|
+
}
|
|
3261
|
+
});
|
|
3262
|
+
trace6.indexHits += indexHits.length;
|
|
3263
|
+
const documentLoadStart = performance.now();
|
|
3264
|
+
const results = await this._loadDocumentsAfterIndexQuery(indexHits);
|
|
3265
|
+
trace6.documentsLoaded += results.length;
|
|
3266
|
+
trace6.documentLoadTime += performance.now() - documentLoadStart;
|
|
3267
|
+
newWorkingSet.push(...results.filter(import_util6.isNonNullable));
|
|
3268
|
+
trace6.objectCount = newWorkingSet.length;
|
|
3269
|
+
break;
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
break;
|
|
3273
|
+
}
|
|
3274
|
+
case "RelationTraversal": {
|
|
3275
|
+
switch (step.traversal.direction) {
|
|
3276
|
+
case "relation-to-source":
|
|
3277
|
+
case "relation-to-target": {
|
|
3278
|
+
const refs = workingSet.map((item) => {
|
|
3279
|
+
const ref = step.traversal.direction === "relation-to-source" ? import_echo_protocol5.ObjectStructure.getRelationSource(item.doc) : import_echo_protocol5.ObjectStructure.getRelationTarget(item.doc);
|
|
3280
|
+
if (!(0, import_echo_protocol5.isEncodedReference)(ref)) {
|
|
3281
|
+
return null;
|
|
3282
|
+
}
|
|
3283
|
+
try {
|
|
3284
|
+
return {
|
|
3285
|
+
ref: import_keys5.DXN.parse(ref["/"]),
|
|
3286
|
+
spaceId: item.spaceId
|
|
3287
|
+
};
|
|
3288
|
+
} catch {
|
|
3289
|
+
import_log10.log.warn("Invalid reference", {
|
|
3290
|
+
ref: ref["/"]
|
|
3291
|
+
}, {
|
|
3292
|
+
F: __dxlog_file11,
|
|
3293
|
+
L: 483,
|
|
3294
|
+
S: this,
|
|
3295
|
+
C: (f, a) => f(...a)
|
|
3296
|
+
});
|
|
3297
|
+
return null;
|
|
3298
|
+
}
|
|
3299
|
+
}).filter(import_util6.isNonNullable);
|
|
3300
|
+
const beginLoad = performance.now();
|
|
3301
|
+
const items = await Promise.all(refs.map(({ ref, spaceId }) => this._loadFromDXN(ref, {
|
|
3302
|
+
sourceSpaceId: spaceId
|
|
3303
|
+
})));
|
|
3304
|
+
trace6.documentLoadTime += performance.now() - beginLoad;
|
|
3305
|
+
newWorkingSet.push(...items.filter(import_util6.isNonNullable));
|
|
3306
|
+
trace6.objectCount = newWorkingSet.length;
|
|
3307
|
+
break;
|
|
3308
|
+
}
|
|
3309
|
+
case "source-to-relation":
|
|
3310
|
+
case "target-to-relation": {
|
|
3311
|
+
const indexHits = await this._indexer.execQuery({
|
|
3312
|
+
typenames: [],
|
|
3313
|
+
inverted: false,
|
|
3314
|
+
graph: {
|
|
3315
|
+
kind: step.traversal.direction === "source-to-relation" ? "relation-source" : "relation-target",
|
|
3316
|
+
anchors: workingSet.map((item) => item.objectId),
|
|
3317
|
+
property: null
|
|
3318
|
+
}
|
|
3319
|
+
});
|
|
3320
|
+
trace6.indexHits += indexHits.length;
|
|
3321
|
+
const documentLoadStart = performance.now();
|
|
3322
|
+
const results = await this._loadDocumentsAfterIndexQuery(indexHits);
|
|
3323
|
+
trace6.documentsLoaded += results.length;
|
|
3324
|
+
trace6.documentLoadTime += performance.now() - documentLoadStart;
|
|
3325
|
+
newWorkingSet.push(...results.filter(import_util6.isNonNullable));
|
|
3326
|
+
trace6.objectCount = newWorkingSet.length;
|
|
3327
|
+
break;
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
break;
|
|
3331
|
+
}
|
|
3332
|
+
default:
|
|
3333
|
+
throw new Error(`Unknown traversal type: ${step.traversal._tag}`);
|
|
2618
3334
|
}
|
|
2619
|
-
})
|
|
2620
|
-
], QueryState.prototype, "execQuery", null);
|
|
2621
|
-
QueryState = _ts_decorate5([
|
|
2622
|
-
import_tracing6.trace.resource()
|
|
2623
|
-
], QueryState);
|
|
2624
|
-
var filterToIndexQuery = (filter) => {
|
|
2625
|
-
(0, import_invariant10.invariant)(!(filter.type && (filter.or ?? []).length > 0), "Cannot mix type and or filters.", {
|
|
2626
|
-
F: __dxlog_file10,
|
|
2627
|
-
L: 184,
|
|
2628
|
-
S: void 0,
|
|
2629
|
-
A: [
|
|
2630
|
-
"!(filter.type && (filter.or ?? []).length > 0)",
|
|
2631
|
-
"'Cannot mix type and or filters.'"
|
|
2632
|
-
]
|
|
2633
|
-
});
|
|
2634
|
-
(0, import_invariant10.invariant)((filter.or ?? []).every((subFilter) => !(subFilter.type && (subFilter.or ?? []).length > 0)), "Cannot mix type and or filters.", {
|
|
2635
|
-
F: __dxlog_file10,
|
|
2636
|
-
L: 185,
|
|
2637
|
-
S: void 0,
|
|
2638
|
-
A: [
|
|
2639
|
-
"(filter.or ?? []).every((subFilter) => !(subFilter.type && (subFilter.or ?? []).length > 0))",
|
|
2640
|
-
"'Cannot mix type and or filters.'"
|
|
2641
|
-
]
|
|
2642
|
-
});
|
|
2643
|
-
if (filter.type || (filter.or ?? []).length > 0 && (filter.or ?? []).every((subFilter) => !subFilter.not && subFilter.type)) {
|
|
2644
3335
|
return {
|
|
2645
|
-
|
|
2646
|
-
|
|
3336
|
+
workingSet: newWorkingSet,
|
|
3337
|
+
trace: trace6
|
|
3338
|
+
};
|
|
3339
|
+
}
|
|
3340
|
+
async _execUnionStep(step, workingSet) {
|
|
3341
|
+
const results = /* @__PURE__ */ new Map();
|
|
3342
|
+
const resultSets = await Promise.all(step.plans.map((plan) => this._execPlan(plan, [
|
|
3343
|
+
...workingSet
|
|
3344
|
+
])));
|
|
3345
|
+
const trace6 = {
|
|
3346
|
+
...ExecutionTrace.makeEmpty(),
|
|
3347
|
+
name: "Union"
|
|
2647
3348
|
};
|
|
2648
|
-
|
|
3349
|
+
for (const resultSet of resultSets) {
|
|
3350
|
+
for (const item of resultSet.workingSet) {
|
|
3351
|
+
results.set(`${item.spaceId}:${item.documentId}:${item.objectId}`, item);
|
|
3352
|
+
}
|
|
3353
|
+
trace6.children.push(resultSet.trace);
|
|
3354
|
+
}
|
|
2649
3355
|
return {
|
|
2650
|
-
|
|
3356
|
+
workingSet: [
|
|
3357
|
+
...results.values()
|
|
3358
|
+
],
|
|
3359
|
+
trace: trace6
|
|
2651
3360
|
};
|
|
2652
3361
|
}
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
default
|
|
2661
|
-
|
|
3362
|
+
async _loadDocumentsAfterIndexQuery(indexHits) {
|
|
3363
|
+
return Promise.all(indexHits.map(async (hit) => {
|
|
3364
|
+
return this._loadFromIndexHit(hit);
|
|
3365
|
+
}));
|
|
3366
|
+
}
|
|
3367
|
+
async _loadFromIndexHit(hit) {
|
|
3368
|
+
const { objectId, documentId, spaceKey: spaceKeyInIndex } = import_protocols5.objectPointerCodec.decode(hit.id);
|
|
3369
|
+
const handle = await this._automergeHost.loadDoc(import_context10.Context.default(void 0, {
|
|
3370
|
+
F: __dxlog_file11,
|
|
3371
|
+
L: 571
|
|
3372
|
+
}), documentId);
|
|
3373
|
+
const doc = handle.doc();
|
|
3374
|
+
if (!doc) {
|
|
3375
|
+
return null;
|
|
3376
|
+
}
|
|
3377
|
+
const spaceKey = spaceKeyInIndex ?? import_echo_protocol5.DatabaseDirectory.getSpaceKey(doc);
|
|
3378
|
+
if (!spaceKey) {
|
|
3379
|
+
return null;
|
|
3380
|
+
}
|
|
3381
|
+
const object = import_echo_protocol5.DatabaseDirectory.getInlineObject(doc, objectId);
|
|
3382
|
+
if (!object) {
|
|
3383
|
+
return null;
|
|
3384
|
+
}
|
|
3385
|
+
return {
|
|
3386
|
+
objectId,
|
|
3387
|
+
documentId,
|
|
3388
|
+
spaceId: await (0, import_chunk_SG2PL5RH.createIdFromSpaceKey)(import_keys5.PublicKey.from(spaceKey)),
|
|
3389
|
+
doc: object
|
|
3390
|
+
};
|
|
3391
|
+
}
|
|
3392
|
+
async _loadFromDXN(dxn, { sourceSpaceId }) {
|
|
3393
|
+
const echoDxn = dxn.asEchoDXN();
|
|
3394
|
+
if (!echoDxn) {
|
|
3395
|
+
import_log10.log.warn("unable to resolve DXN", {
|
|
3396
|
+
dxn
|
|
3397
|
+
}, {
|
|
3398
|
+
F: __dxlog_file11,
|
|
3399
|
+
L: 598,
|
|
3400
|
+
S: this,
|
|
3401
|
+
C: (f, a) => f(...a)
|
|
3402
|
+
});
|
|
3403
|
+
return null;
|
|
3404
|
+
}
|
|
3405
|
+
const spaceId = echoDxn.spaceId ?? sourceSpaceId;
|
|
3406
|
+
const spaceRoot = this._spaceStateManager.getRootBySpaceId(spaceId);
|
|
3407
|
+
if (!spaceRoot) {
|
|
3408
|
+
import_log10.log.warn("no space state found for", {
|
|
3409
|
+
spaceId
|
|
3410
|
+
}, {
|
|
3411
|
+
F: __dxlog_file11,
|
|
3412
|
+
L: 606,
|
|
3413
|
+
S: this,
|
|
3414
|
+
C: (f, a) => f(...a)
|
|
3415
|
+
});
|
|
3416
|
+
return null;
|
|
3417
|
+
}
|
|
3418
|
+
const dbDirectory = spaceRoot.doc();
|
|
3419
|
+
if (!dbDirectory) {
|
|
3420
|
+
import_log10.log.warn("no space state found for", {
|
|
3421
|
+
spaceId
|
|
3422
|
+
}, {
|
|
3423
|
+
F: __dxlog_file11,
|
|
3424
|
+
L: 611,
|
|
3425
|
+
S: this,
|
|
3426
|
+
C: (f, a) => f(...a)
|
|
3427
|
+
});
|
|
3428
|
+
return null;
|
|
3429
|
+
}
|
|
3430
|
+
const inlineObject = import_echo_protocol5.DatabaseDirectory.getInlineObject(dbDirectory, echoDxn.echoId);
|
|
3431
|
+
if (inlineObject) {
|
|
3432
|
+
return {
|
|
3433
|
+
objectId: echoDxn.echoId,
|
|
3434
|
+
documentId: spaceRoot.documentId,
|
|
3435
|
+
spaceId,
|
|
3436
|
+
doc: inlineObject
|
|
3437
|
+
};
|
|
3438
|
+
}
|
|
3439
|
+
const link = import_echo_protocol5.DatabaseDirectory.getLink(dbDirectory, echoDxn.echoId);
|
|
3440
|
+
if (!link) {
|
|
3441
|
+
return null;
|
|
3442
|
+
}
|
|
3443
|
+
const handle = await this._automergeHost.loadDoc(import_context10.Context.default(void 0, {
|
|
3444
|
+
F: __dxlog_file11,
|
|
3445
|
+
L: 630
|
|
3446
|
+
}), link);
|
|
3447
|
+
const doc = handle.doc();
|
|
3448
|
+
if (!doc) {
|
|
3449
|
+
return null;
|
|
3450
|
+
}
|
|
3451
|
+
const object = import_echo_protocol5.DatabaseDirectory.getInlineObject(doc, echoDxn.echoId);
|
|
3452
|
+
if (!object) {
|
|
3453
|
+
return null;
|
|
3454
|
+
}
|
|
3455
|
+
return {
|
|
3456
|
+
objectId: echoDxn.echoId,
|
|
3457
|
+
documentId: handle.documentId,
|
|
3458
|
+
spaceId,
|
|
3459
|
+
doc: object
|
|
3460
|
+
};
|
|
2662
3461
|
}
|
|
2663
3462
|
};
|
|
2664
|
-
var
|
|
3463
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/query-service.ts";
|
|
2665
3464
|
var QueryServiceImpl = class extends import_context9.Resource {
|
|
2666
3465
|
// TODO(burdon): OK for options, but not params. Pass separately and type readonly here.
|
|
2667
3466
|
constructor(_params) {
|
|
2668
|
-
super()
|
|
2669
|
-
this._params = _params;
|
|
2670
|
-
this._queries = /* @__PURE__ */ new Set();
|
|
2671
|
-
this._updateQueries = new import_async6.DeferredTask(this._ctx, async () => {
|
|
3467
|
+
super(), this._params = _params, this._queries = /* @__PURE__ */ new Set(), this._updateQueries = new import_async6.DeferredTask(this._ctx, async () => {
|
|
2672
3468
|
await Promise.all(Array.from(this._queries).map(async (query) => {
|
|
2673
3469
|
try {
|
|
2674
|
-
const { changed } = await query.
|
|
3470
|
+
const { changed } = await query.executor.execQuery();
|
|
2675
3471
|
if (changed) {
|
|
2676
|
-
query.sendResults(query.
|
|
3472
|
+
query.sendResults(query.executor.getResults());
|
|
2677
3473
|
}
|
|
2678
3474
|
} catch (err) {
|
|
2679
3475
|
import_log9.log.catch(err, void 0, {
|
|
2680
|
-
F:
|
|
2681
|
-
L:
|
|
3476
|
+
F: __dxlog_file12,
|
|
3477
|
+
L: 57,
|
|
2682
3478
|
S: this,
|
|
2683
3479
|
C: (f, a) => f(...a)
|
|
2684
3480
|
});
|
|
@@ -2691,8 +3487,9 @@ var QueryServiceImpl = class extends import_context9.Resource {
|
|
|
2691
3487
|
fetch: () => {
|
|
2692
3488
|
return Array.from(this._queries).map((query) => {
|
|
2693
3489
|
return {
|
|
2694
|
-
|
|
2695
|
-
|
|
3490
|
+
query: JSON.stringify(query.executor.query),
|
|
3491
|
+
plan: JSON.stringify(query.executor.plan),
|
|
3492
|
+
trace: JSON.stringify(query.executor.trace)
|
|
2696
3493
|
};
|
|
2697
3494
|
});
|
|
2698
3495
|
}
|
|
@@ -2705,24 +3502,19 @@ var QueryServiceImpl = class extends import_context9.Resource {
|
|
|
2705
3502
|
await Promise.all(Array.from(this._queries).map((query) => query.close()));
|
|
2706
3503
|
}
|
|
2707
3504
|
async setConfig(config) {
|
|
2708
|
-
|
|
2709
|
-
import_log9.log.warn("Indexer already initialized.", void 0, {
|
|
2710
|
-
F: __dxlog_file11,
|
|
2711
|
-
L: 86,
|
|
2712
|
-
S: this,
|
|
2713
|
-
C: (f, a) => f(...a)
|
|
2714
|
-
});
|
|
2715
|
-
return;
|
|
2716
|
-
}
|
|
2717
|
-
this._params.indexer.setConfig(config);
|
|
3505
|
+
await this._params.indexer.setConfig(config);
|
|
2718
3506
|
}
|
|
2719
3507
|
execQuery(request) {
|
|
2720
3508
|
return new import_stream2.Stream(({ next, close, ctx }) => {
|
|
2721
|
-
const
|
|
2722
|
-
|
|
3509
|
+
const parsedQuery = import_echo_protocol4.QueryAST.Query.pipe(import_effect.Schema.decodeUnknownSync)(JSON.parse(request.query));
|
|
3510
|
+
const queryEntry = {
|
|
3511
|
+
executor: new QueryExecutor({
|
|
2723
3512
|
indexer: this._params.indexer,
|
|
2724
3513
|
automergeHost: this._params.automergeHost,
|
|
2725
|
-
request
|
|
3514
|
+
queryId: request.queryId ?? (0, import_debug2.raise)(new Error("query id required")),
|
|
3515
|
+
query: parsedQuery,
|
|
3516
|
+
reactivity: request.reactivity,
|
|
3517
|
+
spaceStateManager: this._params.spaceStateManager
|
|
2726
3518
|
}),
|
|
2727
3519
|
sendResults: (results) => {
|
|
2728
3520
|
if (ctx.disposed) {
|
|
@@ -2735,28 +3527,21 @@ var QueryServiceImpl = class extends import_context9.Resource {
|
|
|
2735
3527
|
},
|
|
2736
3528
|
close: async () => {
|
|
2737
3529
|
close();
|
|
2738
|
-
await
|
|
2739
|
-
this._queries.delete(
|
|
3530
|
+
await queryEntry.executor.close();
|
|
3531
|
+
this._queries.delete(queryEntry);
|
|
2740
3532
|
}
|
|
2741
3533
|
};
|
|
2742
|
-
this._queries.add(
|
|
3534
|
+
this._queries.add(queryEntry);
|
|
2743
3535
|
queueMicrotask(async () => {
|
|
2744
|
-
await
|
|
3536
|
+
await queryEntry.executor.open();
|
|
2745
3537
|
try {
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
query.sendResults(query.state.getResults());
|
|
2749
|
-
}
|
|
3538
|
+
await queryEntry.executor.execQuery();
|
|
3539
|
+
queryEntry.sendResults(queryEntry.executor.getResults());
|
|
2750
3540
|
} catch (error) {
|
|
2751
|
-
|
|
2752
|
-
F: __dxlog_file11,
|
|
2753
|
-
L: 123,
|
|
2754
|
-
S: this,
|
|
2755
|
-
C: (f, a) => f(...a)
|
|
2756
|
-
});
|
|
3541
|
+
close(error);
|
|
2757
3542
|
}
|
|
2758
3543
|
});
|
|
2759
|
-
return
|
|
3544
|
+
return queryEntry.close;
|
|
2760
3545
|
});
|
|
2761
3546
|
}
|
|
2762
3547
|
/**
|
|
@@ -2764,8 +3549,8 @@ var QueryServiceImpl = class extends import_context9.Resource {
|
|
|
2764
3549
|
*/
|
|
2765
3550
|
async reindex() {
|
|
2766
3551
|
import_log9.log.info("Reindexing all documents...", void 0, {
|
|
2767
|
-
F:
|
|
2768
|
-
L:
|
|
3552
|
+
F: __dxlog_file12,
|
|
3553
|
+
L: 141,
|
|
2769
3554
|
S: this,
|
|
2770
3555
|
C: (f, a) => f(...a)
|
|
2771
3556
|
});
|
|
@@ -2779,8 +3564,8 @@ var QueryServiceImpl = class extends import_context9.Resource {
|
|
|
2779
3564
|
import_log9.log.info("Collected documents...", {
|
|
2780
3565
|
count: ids.size
|
|
2781
3566
|
}, {
|
|
2782
|
-
F:
|
|
2783
|
-
L:
|
|
3567
|
+
F: __dxlog_file12,
|
|
3568
|
+
L: 149,
|
|
2784
3569
|
S: this,
|
|
2785
3570
|
C: (f, a) => f(...a)
|
|
2786
3571
|
});
|
|
@@ -2789,8 +3574,8 @@ var QueryServiceImpl = class extends import_context9.Resource {
|
|
|
2789
3574
|
import_log9.log.info("Marking all documents as dirty...", {
|
|
2790
3575
|
count: ids.size
|
|
2791
3576
|
}, {
|
|
2792
|
-
F:
|
|
2793
|
-
L:
|
|
3577
|
+
F: __dxlog_file12,
|
|
3578
|
+
L: 153,
|
|
2794
3579
|
S: this,
|
|
2795
3580
|
C: (f, a) => f(...a)
|
|
2796
3581
|
});
|
|
@@ -2805,11 +3590,11 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
2805
3590
|
async function* getAllDocuments() {
|
|
2806
3591
|
const visited = /* @__PURE__ */ new Set();
|
|
2807
3592
|
async function* getObjectsFromHandle(handle) {
|
|
2808
|
-
if (visited.has(handle.documentId)) {
|
|
3593
|
+
if (visited.has(handle.documentId) || !handle.isReady()) {
|
|
2809
3594
|
return;
|
|
2810
3595
|
}
|
|
2811
|
-
const doc = handle.
|
|
2812
|
-
const spaceKey =
|
|
3596
|
+
const doc = handle.doc();
|
|
3597
|
+
const spaceKey = import_echo_protocol4.DatabaseDirectory.getSpaceKey(doc) ?? void 0;
|
|
2813
3598
|
if (doc.objects) {
|
|
2814
3599
|
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
2815
3600
|
return {
|
|
@@ -2830,8 +3615,8 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
2830
3615
|
continue;
|
|
2831
3616
|
}
|
|
2832
3617
|
const linkHandle = await automergeHost.loadDoc(import_context9.Context.default(void 0, {
|
|
2833
|
-
F:
|
|
2834
|
-
L:
|
|
3618
|
+
F: __dxlog_file12,
|
|
3619
|
+
L: 195
|
|
2835
3620
|
}), urlString);
|
|
2836
3621
|
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
2837
3622
|
yield result;
|
|
@@ -2851,7 +3636,7 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
2851
3636
|
}
|
|
2852
3637
|
}
|
|
2853
3638
|
);
|
|
2854
|
-
var
|
|
3639
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/automerge-metrics.ts";
|
|
2855
3640
|
var measureDocMetrics = (doc) => {
|
|
2856
3641
|
const snapshot = A4.save(doc);
|
|
2857
3642
|
const start = Date.now();
|
|
@@ -2862,11 +3647,11 @@ var measureDocMetrics = (doc) => {
|
|
|
2862
3647
|
const mutationCount = A4.getAllChanges(doc).length;
|
|
2863
3648
|
const getAllChangesEnd = Date.now();
|
|
2864
3649
|
if (getAllChangesEnd - getAllChangesStart > 300) {
|
|
2865
|
-
|
|
3650
|
+
import_log11.log.warn("getAllChanges took too long", {
|
|
2866
3651
|
elapsed: getAllChangesEnd - getAllChangesStart
|
|
2867
3652
|
}, {
|
|
2868
|
-
F:
|
|
2869
|
-
L:
|
|
3653
|
+
F: __dxlog_file13,
|
|
3654
|
+
L: 31,
|
|
2870
3655
|
S: void 0,
|
|
2871
3656
|
C: (f, a) => f(...a)
|
|
2872
3657
|
});
|
|
@@ -2877,7 +3662,7 @@ var measureDocMetrics = (doc) => {
|
|
|
2877
3662
|
mutationCount
|
|
2878
3663
|
};
|
|
2879
3664
|
};
|
|
2880
|
-
var
|
|
3665
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/database-root.ts";
|
|
2881
3666
|
var DatabaseRoot = class {
|
|
2882
3667
|
static mapLinks(doc, mapping) {
|
|
2883
3668
|
doc.change((d) => {
|
|
@@ -2902,47 +3687,47 @@ var DatabaseRoot = class {
|
|
|
2902
3687
|
return this._rootHandle.url;
|
|
2903
3688
|
}
|
|
2904
3689
|
get isLoaded() {
|
|
2905
|
-
return
|
|
3690
|
+
return this._rootHandle.isReady();
|
|
2906
3691
|
}
|
|
2907
3692
|
get handle() {
|
|
2908
3693
|
return this._rootHandle;
|
|
2909
3694
|
}
|
|
2910
|
-
|
|
2911
|
-
return this._rootHandle.
|
|
3695
|
+
doc() {
|
|
3696
|
+
return this._rootHandle.isReady() ? this._rootHandle.doc() : null;
|
|
2912
3697
|
}
|
|
2913
3698
|
getVersion() {
|
|
2914
|
-
const doc = this.
|
|
3699
|
+
const doc = this.doc();
|
|
2915
3700
|
if (!doc) {
|
|
2916
3701
|
return null;
|
|
2917
3702
|
}
|
|
2918
|
-
return doc.version ??
|
|
3703
|
+
return doc.version ?? import_echo_protocol6.SpaceDocVersion.LEGACY;
|
|
2919
3704
|
}
|
|
2920
3705
|
getSpaceKey() {
|
|
2921
|
-
const doc = this.
|
|
3706
|
+
const doc = this.doc();
|
|
2922
3707
|
if (!doc) {
|
|
2923
3708
|
return null;
|
|
2924
3709
|
}
|
|
2925
|
-
return
|
|
3710
|
+
return import_echo_protocol6.DatabaseDirectory.getSpaceKey(doc);
|
|
2926
3711
|
}
|
|
2927
3712
|
getInlineObjectCount() {
|
|
2928
|
-
const doc = this.
|
|
3713
|
+
const doc = this.doc();
|
|
2929
3714
|
if (!doc) {
|
|
2930
3715
|
return null;
|
|
2931
3716
|
}
|
|
2932
3717
|
return Object.keys(doc.objects ?? {}).length;
|
|
2933
3718
|
}
|
|
2934
3719
|
getLinkedObjectCount() {
|
|
2935
|
-
const doc = this.
|
|
3720
|
+
const doc = this.doc();
|
|
2936
3721
|
if (!doc) {
|
|
2937
3722
|
return null;
|
|
2938
3723
|
}
|
|
2939
3724
|
return Object.keys(doc.links ?? {}).length;
|
|
2940
3725
|
}
|
|
2941
3726
|
getAllLinkedDocuments() {
|
|
2942
|
-
const doc = this.
|
|
2943
|
-
(0,
|
|
2944
|
-
F:
|
|
2945
|
-
L:
|
|
3727
|
+
const doc = this.doc();
|
|
3728
|
+
(0, import_invariant13.invariant)(doc, void 0, {
|
|
3729
|
+
F: __dxlog_file14,
|
|
3730
|
+
L: 88,
|
|
2946
3731
|
S: this,
|
|
2947
3732
|
A: [
|
|
2948
3733
|
"doc",
|
|
@@ -2952,14 +3737,14 @@ var DatabaseRoot = class {
|
|
|
2952
3737
|
return Object.values(doc.links ?? {}).map((s) => s.toString());
|
|
2953
3738
|
}
|
|
2954
3739
|
measureMetrics() {
|
|
2955
|
-
const doc = this.
|
|
3740
|
+
const doc = this.doc();
|
|
2956
3741
|
if (!doc) {
|
|
2957
3742
|
return null;
|
|
2958
3743
|
}
|
|
2959
3744
|
return measureDocMetrics(doc);
|
|
2960
3745
|
}
|
|
2961
3746
|
};
|
|
2962
|
-
var
|
|
3747
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/space-state-manager.ts";
|
|
2963
3748
|
var SpaceStateManager = class extends import_context11.Resource {
|
|
2964
3749
|
constructor() {
|
|
2965
3750
|
super(...arguments);
|
|
@@ -2984,6 +3769,22 @@ var SpaceStateManager = class extends import_context11.Resource {
|
|
|
2984
3769
|
getSpaceRootDocumentId(spaceId) {
|
|
2985
3770
|
return this._rootBySpace.get(spaceId);
|
|
2986
3771
|
}
|
|
3772
|
+
getRootBySpaceId(spaceId) {
|
|
3773
|
+
(0, import_invariant12.invariant)(this._lifecycleState === import_context11.LifecycleState.OPEN, void 0, {
|
|
3774
|
+
F: __dxlog_file15,
|
|
3775
|
+
L: 44,
|
|
3776
|
+
S: this,
|
|
3777
|
+
A: [
|
|
3778
|
+
"this._lifecycleState === LifecycleState.OPEN",
|
|
3779
|
+
""
|
|
3780
|
+
]
|
|
3781
|
+
});
|
|
3782
|
+
const documentId = this._rootBySpace.get(spaceId);
|
|
3783
|
+
if (!documentId) {
|
|
3784
|
+
return void 0;
|
|
3785
|
+
}
|
|
3786
|
+
return this._roots.get(documentId);
|
|
3787
|
+
}
|
|
2987
3788
|
async assignRootToSpace(spaceId, handle) {
|
|
2988
3789
|
let root;
|
|
2989
3790
|
if (this._roots.has(handle.documentId)) {
|
|
@@ -3002,8 +3803,8 @@ var SpaceStateManager = class extends import_context11.Resource {
|
|
|
3002
3803
|
}
|
|
3003
3804
|
this._rootBySpace.set(spaceId, root.handle.documentId);
|
|
3004
3805
|
const ctx = new import_context11.Context(void 0, {
|
|
3005
|
-
F:
|
|
3006
|
-
L:
|
|
3806
|
+
F: __dxlog_file15,
|
|
3807
|
+
L: 72
|
|
3007
3808
|
});
|
|
3008
3809
|
this._perRootContext.set(root.handle.documentId, ctx);
|
|
3009
3810
|
await root.handle.whenReady();
|
|
@@ -3034,19 +3835,20 @@ var SpaceDocumentListUpdatedEvent = class {
|
|
|
3034
3835
|
this.documentIds = documentIds;
|
|
3035
3836
|
}
|
|
3036
3837
|
};
|
|
3037
|
-
var
|
|
3038
|
-
var
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
kind: import_indexing3.IndexKind.Kind.SCHEMA_MATCH
|
|
3043
|
-
}
|
|
3044
|
-
]
|
|
3838
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/echo-host.ts";
|
|
3839
|
+
var DEFAULT_INDEXING_CONFIG = {
|
|
3840
|
+
// TODO(dmaretskyi): Disabled by default since embedding generation is expensive.
|
|
3841
|
+
fullText: false,
|
|
3842
|
+
vector: false
|
|
3045
3843
|
};
|
|
3046
3844
|
var EchoHost = class extends import_context7.Resource {
|
|
3047
|
-
constructor({ kv, peerIdProvider, getSpaceKeyByRootDocumentId }) {
|
|
3845
|
+
constructor({ kv, indexing = {}, peerIdProvider, getSpaceKeyByRootDocumentId }) {
|
|
3048
3846
|
super();
|
|
3049
3847
|
this._spaceStateManager = new SpaceStateManager();
|
|
3848
|
+
const indexingConfig = {
|
|
3849
|
+
...DEFAULT_INDEXING_CONFIG,
|
|
3850
|
+
...indexing
|
|
3851
|
+
};
|
|
3050
3852
|
this._indexMetadataStore = new import_indexing2.IndexMetadataStore({
|
|
3051
3853
|
db: kv.sublevel("index-metadata")
|
|
3052
3854
|
});
|
|
@@ -3067,10 +3869,32 @@ var EchoHost = class extends import_context7.Resource {
|
|
|
3067
3869
|
loadDocuments: createSelectedDocumentsIterator(this._automergeHost),
|
|
3068
3870
|
indexCooldownTime: process.env.NODE_ENV === "test" ? 0 : void 0
|
|
3069
3871
|
});
|
|
3070
|
-
this._indexer.setConfig(
|
|
3872
|
+
void this._indexer.setConfig({
|
|
3873
|
+
enabled: true,
|
|
3874
|
+
indexes: [
|
|
3875
|
+
//
|
|
3876
|
+
{
|
|
3877
|
+
kind: import_indexing3.IndexKind.Kind.SCHEMA_MATCH
|
|
3878
|
+
},
|
|
3879
|
+
{
|
|
3880
|
+
kind: import_indexing3.IndexKind.Kind.GRAPH
|
|
3881
|
+
},
|
|
3882
|
+
...indexingConfig.fullText ? [
|
|
3883
|
+
{
|
|
3884
|
+
kind: import_indexing3.IndexKind.Kind.FULL_TEXT
|
|
3885
|
+
}
|
|
3886
|
+
] : [],
|
|
3887
|
+
...indexingConfig.vector ? [
|
|
3888
|
+
{
|
|
3889
|
+
kind: import_indexing3.IndexKind.Kind.VECTOR
|
|
3890
|
+
}
|
|
3891
|
+
] : []
|
|
3892
|
+
]
|
|
3893
|
+
});
|
|
3071
3894
|
this._queryService = new QueryServiceImpl({
|
|
3072
3895
|
automergeHost: this._automergeHost,
|
|
3073
|
-
indexer: this._indexer
|
|
3896
|
+
indexer: this._indexer,
|
|
3897
|
+
spaceStateManager: this._spaceStateManager
|
|
3074
3898
|
});
|
|
3075
3899
|
this._dataService = new DataServiceImpl({
|
|
3076
3900
|
automergeHost: this._automergeHost,
|
|
@@ -3146,8 +3970,8 @@ var EchoHost = class extends import_context7.Resource {
|
|
|
3146
3970
|
});
|
|
3147
3971
|
}
|
|
3148
3972
|
async _close(ctx) {
|
|
3149
|
-
await this._spaceStateManager.close();
|
|
3150
3973
|
await this._queryService.close(ctx);
|
|
3974
|
+
await this._spaceStateManager.close(ctx);
|
|
3151
3975
|
await this._indexer.close(ctx);
|
|
3152
3976
|
await this._automergeHost.close();
|
|
3153
3977
|
}
|
|
@@ -3183,17 +4007,17 @@ var EchoHost = class extends import_context7.Resource {
|
|
|
3183
4007
|
*/
|
|
3184
4008
|
async createSpaceRoot(spaceKey) {
|
|
3185
4009
|
(0, import_invariant8.invariant)(this._lifecycleState === import_context7.LifecycleState.OPEN, void 0, {
|
|
3186
|
-
F:
|
|
3187
|
-
L:
|
|
4010
|
+
F: __dxlog_file16,
|
|
4011
|
+
L: 252,
|
|
3188
4012
|
S: this,
|
|
3189
4013
|
A: [
|
|
3190
4014
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
3191
4015
|
""
|
|
3192
4016
|
]
|
|
3193
4017
|
});
|
|
3194
|
-
const spaceId = await (0,
|
|
4018
|
+
const spaceId = await (0, import_echo_protocol2.createIdFromSpaceKey)(spaceKey);
|
|
3195
4019
|
const automergeRoot = this._automergeHost.createDoc({
|
|
3196
|
-
version:
|
|
4020
|
+
version: import_echo_protocol2.SpaceDocVersion.CURRENT,
|
|
3197
4021
|
access: {
|
|
3198
4022
|
spaceKey: spaceKey.toHex()
|
|
3199
4023
|
},
|
|
@@ -3211,15 +4035,16 @@ var EchoHost = class extends import_context7.Resource {
|
|
|
3211
4035
|
// TODO(dmaretskyi): Change to document id.
|
|
3212
4036
|
async openSpaceRoot(spaceId, automergeUrl) {
|
|
3213
4037
|
(0, import_invariant8.invariant)(this._lifecycleState === import_context7.LifecycleState.OPEN, void 0, {
|
|
3214
|
-
F:
|
|
3215
|
-
L:
|
|
4038
|
+
F: __dxlog_file16,
|
|
4039
|
+
L: 271,
|
|
3216
4040
|
S: this,
|
|
3217
4041
|
A: [
|
|
3218
4042
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
3219
4043
|
""
|
|
3220
4044
|
]
|
|
3221
4045
|
});
|
|
3222
|
-
const handle = this._automergeHost.repo.find(automergeUrl);
|
|
4046
|
+
const handle = await this._automergeHost.repo.find(automergeUrl, FIND_PARAMS);
|
|
4047
|
+
await handle.whenReady();
|
|
3223
4048
|
return this._spaceStateManager.assignRootToSpace(spaceId, handle);
|
|
3224
4049
|
}
|
|
3225
4050
|
// TODO(dmaretskyi): Change to document id.
|
|
@@ -3239,13 +4064,10 @@ var EchoHost = class extends import_context7.Resource {
|
|
|
3239
4064
|
await this._automergeHost.removeReplicator(replicator);
|
|
3240
4065
|
}
|
|
3241
4066
|
};
|
|
3242
|
-
var
|
|
4067
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/edge/inflight-request-limiter.ts";
|
|
3243
4068
|
var InflightRequestLimiter = class extends import_context13.Resource {
|
|
3244
4069
|
constructor(_config) {
|
|
3245
|
-
super();
|
|
3246
|
-
this._config = _config;
|
|
3247
|
-
this._inflightRequestBalance = 0;
|
|
3248
|
-
this._requestBarrier = new import_async9.Trigger();
|
|
4070
|
+
super(), this._config = _config, this._inflightRequestBalance = 0, this._requestBarrier = new import_async9.Trigger();
|
|
3249
4071
|
}
|
|
3250
4072
|
async _open() {
|
|
3251
4073
|
this._inflightRequestBalance = 0;
|
|
@@ -3268,8 +4090,8 @@ var InflightRequestLimiter = class extends import_context13.Resource {
|
|
|
3268
4090
|
if (this._inflightRequestBalance === this._config.maxInflightRequests) {
|
|
3269
4091
|
this._requestBarrier.reset();
|
|
3270
4092
|
this._resetBalanceTimeout = setTimeout(() => {
|
|
3271
|
-
|
|
3272
|
-
F:
|
|
4093
|
+
import_log13.log.warn("Request balance has not changed during specified timeout, resetting request limiter.", void 0, {
|
|
4094
|
+
F: __dxlog_file17,
|
|
3273
4095
|
L: 52,
|
|
3274
4096
|
S: this,
|
|
3275
4097
|
C: (f, a) => f(...a)
|
|
@@ -3290,69 +4112,72 @@ var InflightRequestLimiter = class extends import_context13.Resource {
|
|
|
3290
4112
|
}
|
|
3291
4113
|
}
|
|
3292
4114
|
};
|
|
3293
|
-
function
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
}
|
|
3306
|
-
if (isAwait) {
|
|
3307
|
-
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
3308
|
-
}
|
|
3309
|
-
if (dispose == null) {
|
|
3310
|
-
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
3311
|
-
}
|
|
3312
|
-
if (typeof dispose !== "function") {
|
|
3313
|
-
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
3314
|
-
}
|
|
3315
|
-
stack.push({
|
|
3316
|
-
v: value,
|
|
3317
|
-
d: dispose,
|
|
3318
|
-
a: isAwait
|
|
3319
|
-
});
|
|
3320
|
-
} else if (isAwait) {
|
|
3321
|
-
stack.push({
|
|
3322
|
-
d: value,
|
|
3323
|
-
a: isAwait
|
|
3324
|
-
});
|
|
4115
|
+
function _ts_add_disposable_resource(env, value, async) {
|
|
4116
|
+
if (value !== null && value !== void 0) {
|
|
4117
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4118
|
+
var dispose, inner;
|
|
4119
|
+
if (async) {
|
|
4120
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
4121
|
+
dispose = value[Symbol.asyncDispose];
|
|
4122
|
+
}
|
|
4123
|
+
if (dispose === void 0) {
|
|
4124
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
4125
|
+
dispose = value[Symbol.dispose];
|
|
4126
|
+
if (async) inner = dispose;
|
|
3325
4127
|
}
|
|
3326
|
-
|
|
4128
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
4129
|
+
if (inner) dispose = function() {
|
|
4130
|
+
try {
|
|
4131
|
+
inner.call(this);
|
|
4132
|
+
} catch (e) {
|
|
4133
|
+
return Promise.reject(e);
|
|
4134
|
+
}
|
|
4135
|
+
};
|
|
4136
|
+
env.stack.push({
|
|
4137
|
+
value,
|
|
4138
|
+
dispose,
|
|
4139
|
+
async
|
|
4140
|
+
});
|
|
4141
|
+
} else if (async) {
|
|
4142
|
+
env.stack.push({
|
|
4143
|
+
async: true
|
|
4144
|
+
});
|
|
3327
4145
|
}
|
|
3328
|
-
return
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
4146
|
+
return value;
|
|
4147
|
+
}
|
|
4148
|
+
function _ts_dispose_resources(env) {
|
|
4149
|
+
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
4150
|
+
var e = new Error(message);
|
|
4151
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
4152
|
+
};
|
|
4153
|
+
return (_ts_dispose_resources = function _ts_dispose_resources2(env2) {
|
|
4154
|
+
function fail(e) {
|
|
4155
|
+
env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
|
|
4156
|
+
env2.hasError = true;
|
|
4157
|
+
}
|
|
4158
|
+
var r, s = 0;
|
|
4159
|
+
function next() {
|
|
4160
|
+
while (r = env2.stack.pop()) {
|
|
4161
|
+
try {
|
|
4162
|
+
if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
|
|
4163
|
+
if (r.dispose) {
|
|
4164
|
+
var result = r.dispose.call(r.value);
|
|
4165
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
|
|
4166
|
+
fail(e);
|
|
4167
|
+
return next();
|
|
4168
|
+
});
|
|
4169
|
+
} else s |= 1;
|
|
4170
|
+
} catch (e) {
|
|
4171
|
+
fail(e);
|
|
3344
4172
|
}
|
|
3345
|
-
if (error !== empty) throw error;
|
|
3346
|
-
}
|
|
3347
|
-
function err(e) {
|
|
3348
|
-
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
3349
|
-
return next();
|
|
3350
4173
|
}
|
|
3351
|
-
return
|
|
4174
|
+
if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
|
|
4175
|
+
if (env2.hasError) throw env2.error;
|
|
3352
4176
|
}
|
|
3353
|
-
|
|
4177
|
+
return next();
|
|
4178
|
+
})(env);
|
|
3354
4179
|
}
|
|
3355
|
-
var
|
|
4180
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/edge/echo-edge-replicator.ts";
|
|
3356
4181
|
var INITIAL_RESTART_DELAY = 500;
|
|
3357
4182
|
var RESTART_DELAY_JITTER = 250;
|
|
3358
4183
|
var MAX_RESTART_DELAY = 5e3;
|
|
@@ -3368,28 +4193,32 @@ var EchoEdgeReplicator = class {
|
|
|
3368
4193
|
this._sharePolicyEnabled = !disableSharePolicy;
|
|
3369
4194
|
}
|
|
3370
4195
|
async connect(context) {
|
|
3371
|
-
|
|
4196
|
+
import_log12.log.info("connecting...", {
|
|
3372
4197
|
peerId: context.peerId,
|
|
3373
4198
|
connectedSpaces: this._connectedSpaces.size
|
|
3374
4199
|
}, {
|
|
3375
|
-
F:
|
|
3376
|
-
L:
|
|
4200
|
+
F: __dxlog_file18,
|
|
4201
|
+
L: 61,
|
|
3377
4202
|
S: this,
|
|
3378
4203
|
C: (f, a) => f(...a)
|
|
3379
4204
|
});
|
|
3380
4205
|
this._context = context;
|
|
3381
4206
|
this._ctx = import_context12.Context.default(void 0, {
|
|
3382
|
-
F:
|
|
3383
|
-
L:
|
|
4207
|
+
F: __dxlog_file18,
|
|
4208
|
+
L: 64
|
|
3384
4209
|
});
|
|
3385
4210
|
this._ctx.onDispose(this._edgeConnection.onReconnected(() => {
|
|
3386
4211
|
this._ctx && (0, import_async8.scheduleMicroTask)(this._ctx, () => this._handleReconnect());
|
|
3387
4212
|
}));
|
|
3388
4213
|
}
|
|
3389
4214
|
async _handleReconnect() {
|
|
4215
|
+
const env = {
|
|
4216
|
+
stack: [],
|
|
4217
|
+
error: void 0,
|
|
4218
|
+
hasError: false
|
|
4219
|
+
};
|
|
3390
4220
|
try {
|
|
3391
|
-
|
|
3392
|
-
const _guard = _usingCtx.u(await this._mutex.acquire());
|
|
4221
|
+
const _guard = _ts_add_disposable_resource(env, await this._mutex.acquire(), false);
|
|
3393
4222
|
const spaces = [
|
|
3394
4223
|
...this._connectedSpaces
|
|
3395
4224
|
];
|
|
@@ -3402,31 +4231,41 @@ var EchoEdgeReplicator = class {
|
|
|
3402
4231
|
await this._openConnection(spaceId);
|
|
3403
4232
|
}
|
|
3404
4233
|
}
|
|
3405
|
-
} catch (
|
|
3406
|
-
|
|
4234
|
+
} catch (e) {
|
|
4235
|
+
env.error = e;
|
|
4236
|
+
env.hasError = true;
|
|
3407
4237
|
} finally {
|
|
3408
|
-
|
|
4238
|
+
_ts_dispose_resources(env);
|
|
3409
4239
|
}
|
|
3410
4240
|
}
|
|
3411
4241
|
async disconnect() {
|
|
4242
|
+
const env = {
|
|
4243
|
+
stack: [],
|
|
4244
|
+
error: void 0,
|
|
4245
|
+
hasError: false
|
|
4246
|
+
};
|
|
3412
4247
|
try {
|
|
3413
|
-
|
|
3414
|
-
const _guard = _usingCtx.u(await this._mutex.acquire());
|
|
4248
|
+
const _guard = _ts_add_disposable_resource(env, await this._mutex.acquire(), false);
|
|
3415
4249
|
await this._ctx?.dispose();
|
|
3416
4250
|
for (const connection of this._connections.values()) {
|
|
3417
4251
|
await connection.close();
|
|
3418
4252
|
}
|
|
3419
4253
|
this._connections.clear();
|
|
3420
|
-
} catch (
|
|
3421
|
-
|
|
4254
|
+
} catch (e) {
|
|
4255
|
+
env.error = e;
|
|
4256
|
+
env.hasError = true;
|
|
3422
4257
|
} finally {
|
|
3423
|
-
|
|
4258
|
+
_ts_dispose_resources(env);
|
|
3424
4259
|
}
|
|
3425
4260
|
}
|
|
3426
4261
|
async connectToSpace(spaceId) {
|
|
4262
|
+
const env = {
|
|
4263
|
+
stack: [],
|
|
4264
|
+
error: void 0,
|
|
4265
|
+
hasError: false
|
|
4266
|
+
};
|
|
3427
4267
|
try {
|
|
3428
|
-
|
|
3429
|
-
const _guard = _usingCtx.u(await this._mutex.acquire());
|
|
4268
|
+
const _guard = _ts_add_disposable_resource(env, await this._mutex.acquire(), false);
|
|
3430
4269
|
if (this._connectedSpaces.has(spaceId)) {
|
|
3431
4270
|
return;
|
|
3432
4271
|
}
|
|
@@ -3434,41 +4273,47 @@ var EchoEdgeReplicator = class {
|
|
|
3434
4273
|
if (this._context !== null) {
|
|
3435
4274
|
await this._openConnection(spaceId);
|
|
3436
4275
|
}
|
|
3437
|
-
} catch (
|
|
3438
|
-
|
|
4276
|
+
} catch (e) {
|
|
4277
|
+
env.error = e;
|
|
4278
|
+
env.hasError = true;
|
|
3439
4279
|
} finally {
|
|
3440
|
-
|
|
4280
|
+
_ts_dispose_resources(env);
|
|
3441
4281
|
}
|
|
3442
4282
|
}
|
|
3443
4283
|
async disconnectFromSpace(spaceId) {
|
|
4284
|
+
const env = {
|
|
4285
|
+
stack: [],
|
|
4286
|
+
error: void 0,
|
|
4287
|
+
hasError: false
|
|
4288
|
+
};
|
|
3444
4289
|
try {
|
|
3445
|
-
|
|
3446
|
-
const _guard = _usingCtx.u(await this._mutex.acquire());
|
|
4290
|
+
const _guard = _ts_add_disposable_resource(env, await this._mutex.acquire(), false);
|
|
3447
4291
|
this._connectedSpaces.delete(spaceId);
|
|
3448
4292
|
const connection = this._connections.get(spaceId);
|
|
3449
4293
|
if (connection) {
|
|
3450
4294
|
await connection.close();
|
|
3451
4295
|
this._connections.delete(spaceId);
|
|
3452
4296
|
}
|
|
3453
|
-
} catch (
|
|
3454
|
-
|
|
4297
|
+
} catch (e) {
|
|
4298
|
+
env.error = e;
|
|
4299
|
+
env.hasError = true;
|
|
3455
4300
|
} finally {
|
|
3456
|
-
|
|
4301
|
+
_ts_dispose_resources(env);
|
|
3457
4302
|
}
|
|
3458
4303
|
}
|
|
3459
4304
|
async _openConnection(spaceId, reconnects = 0) {
|
|
3460
|
-
(0,
|
|
3461
|
-
F:
|
|
3462
|
-
L:
|
|
4305
|
+
(0, import_invariant14.invariant)(this._context, void 0, {
|
|
4306
|
+
F: __dxlog_file18,
|
|
4307
|
+
L: 125,
|
|
3463
4308
|
S: this,
|
|
3464
4309
|
A: [
|
|
3465
4310
|
"this._context",
|
|
3466
4311
|
""
|
|
3467
4312
|
]
|
|
3468
4313
|
});
|
|
3469
|
-
(0,
|
|
3470
|
-
F:
|
|
3471
|
-
L:
|
|
4314
|
+
(0, import_invariant14.invariant)(!this._connections.has(spaceId), void 0, {
|
|
4315
|
+
F: __dxlog_file18,
|
|
4316
|
+
L: 126,
|
|
3472
4317
|
S: this,
|
|
3473
4318
|
A: [
|
|
3474
4319
|
"!this._connections.has(spaceId)",
|
|
@@ -3492,21 +4337,25 @@ var EchoEdgeReplicator = class {
|
|
|
3492
4337
|
return;
|
|
3493
4338
|
}
|
|
3494
4339
|
const restartDelay = Math.min(MAX_RESTART_DELAY, INITIAL_RESTART_DELAY * reconnects) + Math.random() * RESTART_DELAY_JITTER;
|
|
3495
|
-
|
|
4340
|
+
import_log12.log.info("connection restart scheduled", {
|
|
3496
4341
|
spaceId,
|
|
3497
4342
|
reconnects,
|
|
3498
4343
|
restartDelay
|
|
3499
4344
|
}, {
|
|
3500
|
-
F:
|
|
3501
|
-
L:
|
|
4345
|
+
F: __dxlog_file18,
|
|
4346
|
+
L: 149,
|
|
3502
4347
|
S: this,
|
|
3503
4348
|
C: (f, a) => f(...a)
|
|
3504
4349
|
});
|
|
3505
4350
|
restartScheduled = true;
|
|
3506
4351
|
(0, import_async8.scheduleTask)(this._ctx, async () => {
|
|
4352
|
+
const env = {
|
|
4353
|
+
stack: [],
|
|
4354
|
+
error: void 0,
|
|
4355
|
+
hasError: false
|
|
4356
|
+
};
|
|
3507
4357
|
try {
|
|
3508
|
-
|
|
3509
|
-
const _guard = _usingCtx.u(await this._mutex.acquire());
|
|
4358
|
+
const _guard = _ts_add_disposable_resource(env, await this._mutex.acquire(), false);
|
|
3510
4359
|
if (this._connections.get(spaceId) !== connection) {
|
|
3511
4360
|
return;
|
|
3512
4361
|
}
|
|
@@ -3517,10 +4366,11 @@ var EchoEdgeReplicator = class {
|
|
|
3517
4366
|
return;
|
|
3518
4367
|
}
|
|
3519
4368
|
await this._openConnection(spaceId, reconnects + 1);
|
|
3520
|
-
} catch (
|
|
3521
|
-
|
|
4369
|
+
} catch (e) {
|
|
4370
|
+
env.error = e;
|
|
4371
|
+
env.hasError = true;
|
|
3522
4372
|
} finally {
|
|
3523
|
-
|
|
4373
|
+
_ts_dispose_resources(env);
|
|
3524
4374
|
}
|
|
3525
4375
|
}, restartDelay);
|
|
3526
4376
|
}
|
|
@@ -3561,9 +4411,9 @@ var EdgeReplicatorConnection = class extends import_context12.Resource {
|
|
|
3561
4411
|
});
|
|
3562
4412
|
}
|
|
3563
4413
|
async _open(ctx) {
|
|
3564
|
-
(0,
|
|
3565
|
-
F:
|
|
3566
|
-
L:
|
|
4414
|
+
(0, import_log12.log)("opening...", void 0, {
|
|
4415
|
+
F: __dxlog_file18,
|
|
4416
|
+
L: 252,
|
|
3567
4417
|
S: this,
|
|
3568
4418
|
C: (f, a) => f(...a)
|
|
3569
4419
|
});
|
|
@@ -3574,9 +4424,9 @@ var EdgeReplicatorConnection = class extends import_context12.Resource {
|
|
|
3574
4424
|
await this._onRemoteConnected();
|
|
3575
4425
|
}
|
|
3576
4426
|
async _close() {
|
|
3577
|
-
(0,
|
|
3578
|
-
F:
|
|
3579
|
-
L:
|
|
4427
|
+
(0, import_log12.log)("closing...", void 0, {
|
|
4428
|
+
F: __dxlog_file18,
|
|
4429
|
+
L: 267,
|
|
3580
4430
|
S: this,
|
|
3581
4431
|
C: (f, a) => f(...a)
|
|
3582
4432
|
});
|
|
@@ -3585,9 +4435,9 @@ var EdgeReplicatorConnection = class extends import_context12.Resource {
|
|
|
3585
4435
|
await this._onRemoteDisconnected();
|
|
3586
4436
|
}
|
|
3587
4437
|
get peerId() {
|
|
3588
|
-
(0,
|
|
3589
|
-
F:
|
|
3590
|
-
L:
|
|
4438
|
+
(0, import_invariant14.invariant)(this._remotePeerId, "Not connected", {
|
|
4439
|
+
F: __dxlog_file18,
|
|
4440
|
+
L: 276,
|
|
3591
4441
|
S: this,
|
|
3592
4442
|
A: [
|
|
3593
4443
|
"this._remotePeerId",
|
|
@@ -3606,13 +4456,13 @@ var EdgeReplicatorConnection = class extends import_context12.Resource {
|
|
|
3606
4456
|
documentId: params.documentId,
|
|
3607
4457
|
peerId: this._remotePeerId
|
|
3608
4458
|
});
|
|
3609
|
-
|
|
4459
|
+
import_log12.log.verbose("document not found locally for share policy check", {
|
|
3610
4460
|
documentId: params.documentId,
|
|
3611
4461
|
acceptDocument: remoteDocumentExists,
|
|
3612
4462
|
remoteId: this._remotePeerId
|
|
3613
4463
|
}, {
|
|
3614
|
-
F:
|
|
3615
|
-
L:
|
|
4464
|
+
F: __dxlog_file18,
|
|
4465
|
+
L: 291,
|
|
3616
4466
|
S: this,
|
|
3617
4467
|
C: (f, a) => f(...a)
|
|
3618
4468
|
});
|
|
@@ -3632,13 +4482,13 @@ var EdgeReplicatorConnection = class extends import_context12.Resource {
|
|
|
3632
4482
|
return;
|
|
3633
4483
|
}
|
|
3634
4484
|
const payload = import_automerge_repo6.cbor.decode(message.payload.value);
|
|
3635
|
-
|
|
4485
|
+
import_log12.log.verbose("received", {
|
|
3636
4486
|
type: payload.type,
|
|
3637
4487
|
documentId: payload.type === "sync" && payload.documentId,
|
|
3638
4488
|
remoteId: this._remotePeerId
|
|
3639
4489
|
}, {
|
|
3640
|
-
F:
|
|
3641
|
-
L:
|
|
4490
|
+
F: __dxlog_file18,
|
|
4491
|
+
L: 320,
|
|
3642
4492
|
S: this,
|
|
3643
4493
|
C: (f, a) => f(...a)
|
|
3644
4494
|
});
|
|
@@ -3655,13 +4505,13 @@ var EdgeReplicatorConnection = class extends import_context12.Resource {
|
|
|
3655
4505
|
}
|
|
3656
4506
|
async _sendMessage(message) {
|
|
3657
4507
|
message.targetId = this._targetServiceId;
|
|
3658
|
-
|
|
4508
|
+
import_log12.log.verbose("sending...", {
|
|
3659
4509
|
type: message.type,
|
|
3660
4510
|
documentId: message.type === "sync" && message.documentId,
|
|
3661
4511
|
remoteId: this._remotePeerId
|
|
3662
4512
|
}, {
|
|
3663
|
-
F:
|
|
3664
|
-
L:
|
|
4513
|
+
F: __dxlog_file18,
|
|
4514
|
+
L: 349,
|
|
3665
4515
|
S: this,
|
|
3666
4516
|
C: (f, a) => f(...a)
|
|
3667
4517
|
});
|
|
@@ -3682,7 +4532,8 @@ var isForbiddenErrorMessage = (message) => message.type === "error" && message.m
|
|
|
3682
4532
|
var findInlineObjectOfType = (spaceDoc, typename) => {
|
|
3683
4533
|
for (const id in spaceDoc.objects ?? {}) {
|
|
3684
4534
|
const obj = spaceDoc.objects[id];
|
|
3685
|
-
|
|
4535
|
+
const objType = import_echo_protocol7.ObjectStructure.getTypeReference(obj);
|
|
4536
|
+
if (objType && (0, import_echo_protocol7.decodeReference)(objType).objectId === typename) {
|
|
3686
4537
|
return [
|
|
3687
4538
|
id,
|
|
3688
4539
|
obj
|
|
@@ -3704,14 +4555,18 @@ var findInlineObjectOfType = (spaceDoc, typename) => {
|
|
|
3704
4555
|
EchoDataMonitor,
|
|
3705
4556
|
EchoEdgeReplicator,
|
|
3706
4557
|
EchoHost,
|
|
4558
|
+
ExecutionTrace,
|
|
4559
|
+
FIND_PARAMS,
|
|
3707
4560
|
LevelDBStorageAdapter,
|
|
3708
4561
|
MOCK_AUTH_PROVIDER,
|
|
3709
4562
|
MOCK_AUTH_VERIFIER,
|
|
3710
4563
|
MeshEchoReplicator,
|
|
3711
4564
|
MetadataStore,
|
|
3712
4565
|
Pipeline,
|
|
4566
|
+
QueryExecutor,
|
|
4567
|
+
QueryPlan,
|
|
4568
|
+
QueryPlanner,
|
|
3713
4569
|
QueryServiceImpl,
|
|
3714
|
-
QueryState,
|
|
3715
4570
|
Space,
|
|
3716
4571
|
SpaceDocumentListUpdatedEvent,
|
|
3717
4572
|
SpaceManager,
|
|
@@ -3725,9 +4580,10 @@ var findInlineObjectOfType = (spaceDoc, typename) => {
|
|
|
3725
4580
|
deriveCollectionIdFromSpaceId,
|
|
3726
4581
|
diffCollectionState,
|
|
3727
4582
|
encodingOptions,
|
|
4583
|
+
filterMatchObject,
|
|
4584
|
+
filterMatchValue,
|
|
3728
4585
|
findInlineObjectOfType,
|
|
3729
4586
|
getSpaceIdFromCollectionId,
|
|
3730
|
-
getSpaceKeyFromDoc,
|
|
3731
4587
|
hasInvitationExpired,
|
|
3732
4588
|
mapFeedIndexesToTimeframe,
|
|
3733
4589
|
mapTimeframeToFeedIndexes,
|