@dxos/echo-pipeline 0.8.4-main.ae835ea → 0.8.4-main.bc2380dfbc
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/{browser/chunk-WJJXJTNS.mjs → neutral/chunk-46DCRDA7.mjs} +44 -13
- package/dist/lib/neutral/chunk-46DCRDA7.mjs.map +7 -0
- package/dist/lib/{browser/chunk-FR6GJ4S4.mjs → neutral/chunk-LR7UFVQX.mjs} +145 -618
- package/dist/lib/neutral/chunk-LR7UFVQX.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/filter/index.mjs +1 -2
- package/dist/lib/neutral/index.mjs +7332 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/testing/index.mjs +49 -292
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/automerge/automerge-host-subduction.test.d.ts +2 -0
- package/dist/types/src/automerge/automerge-host-subduction.test.d.ts.map +1 -0
- package/dist/types/src/automerge/automerge-host.d.ts +105 -27
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-repo-subduction.test.d.ts +2 -0
- package/dist/types/src/automerge/automerge-repo-subduction.test.d.ts.map +1 -0
- package/dist/types/src/automerge/automerge-repo.test.d.ts +1 -1
- package/dist/types/src/automerge/automerge-repo.test.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-subduction.test.d.ts +2 -0
- package/dist/types/src/automerge/automerge-subduction.test.d.ts.map +1 -0
- package/dist/types/src/automerge/collection-synchronizer.d.ts +22 -2
- package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-data-monitor.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +17 -11
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-replicator.d.ts +28 -16
- package/dist/types/src/automerge/echo-replicator.d.ts.map +1 -1
- package/dist/types/src/automerge/errors.d.ts +35 -0
- package/dist/types/src/automerge/errors.d.ts.map +1 -0
- package/dist/types/src/automerge/handle-state.d.ts +52 -0
- package/dist/types/src/automerge/handle-state.d.ts.map +1 -0
- package/dist/types/src/automerge/heads-store.d.ts +9 -2
- package/dist/types/src/automerge/heads-store.d.ts.map +1 -1
- package/dist/types/src/automerge/index.d.ts +2 -0
- package/dist/types/src/automerge/index.d.ts.map +1 -1
- package/dist/types/src/automerge/leveldb-storage-adapter.d.ts +10 -4
- package/dist/types/src/automerge/leveldb-storage-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts +8 -8
- package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts +6 -5
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
- package/dist/types/src/automerge/network-protocol.d.ts.map +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-data-source.d.ts +35 -0
- package/dist/types/src/db-host/automerge-data-source.d.ts.map +1 -0
- package/dist/types/src/db-host/automerge-data-source.test.d.ts +2 -0
- package/dist/types/src/db-host/automerge-data-source.test.d.ts.map +1 -0
- package/dist/types/src/db-host/automerge-metrics.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts +12 -6
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/database-root.d.ts +9 -3
- package/dist/types/src/db-host/database-root.d.ts.map +1 -1
- package/dist/types/src/db-host/documents-synchronizer.d.ts +30 -8
- package/dist/types/src/db-host/documents-synchronizer.d.ts.map +1 -1
- package/dist/types/src/db-host/echo-host.d.ts +74 -28
- package/dist/types/src/db-host/echo-host.d.ts.map +1 -1
- package/dist/types/src/db-host/index.d.ts +2 -0
- package/dist/types/src/db-host/index.d.ts.map +1 -1
- package/dist/types/src/db-host/invalidation-hint.d.ts +19 -0
- package/dist/types/src/db-host/invalidation-hint.d.ts.map +1 -0
- package/dist/types/src/db-host/local-queue-service.d.ts +19 -0
- package/dist/types/src/db-host/local-queue-service.d.ts.map +1 -0
- package/dist/types/src/db-host/query-invalidation.test.d.ts +2 -0
- package/dist/types/src/db-host/query-invalidation.test.d.ts.map +1 -0
- package/dist/types/src/db-host/query-service.d.ts +18 -10
- package/dist/types/src/db-host/query-service.d.ts.map +1 -1
- package/dist/types/src/db-host/queue-data-source.d.ts +38 -0
- package/dist/types/src/db-host/queue-data-source.d.ts.map +1 -0
- package/dist/types/src/db-host/queue-service.test.d.ts +2 -0
- package/dist/types/src/db-host/queue-service.test.d.ts.map +1 -0
- package/dist/types/src/db-host/space-state-manager.d.ts +3 -2
- package/dist/types/src/db-host/space-state-manager.d.ts.map +1 -1
- package/dist/types/src/db-host/stub.d.ts +11 -0
- package/dist/types/src/db-host/stub.d.ts.map +1 -0
- package/dist/types/src/edge/echo-edge-replicator.d.ts +7 -6
- package/dist/types/src/edge/echo-edge-replicator.d.ts.map +1 -1
- package/dist/types/src/edge/echo-edge-subduction-replicator.d.ts +39 -0
- package/dist/types/src/edge/echo-edge-subduction-replicator.d.ts.map +1 -0
- package/dist/types/src/edge/echo-edge-subduction-replicator.test.d.ts +2 -0
- package/dist/types/src/edge/echo-edge-subduction-replicator.test.d.ts.map +1 -0
- package/dist/types/src/edge/index.d.ts +1 -0
- package/dist/types/src/edge/index.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 +1 -1
- package/dist/types/src/filter/filter-match.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 +2 -2
- 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 +16 -20
- package/dist/types/src/query/errors.d.ts.map +1 -1
- package/dist/types/src/query/plan.d.ts +59 -8
- package/dist/types/src/query/plan.d.ts.map +1 -1
- package/dist/types/src/query/query-executor.d.ts +55 -12
- package/dist/types/src/query/query-executor.d.ts.map +1 -1
- package/dist/types/src/query/query-planner.d.ts +10 -1
- package/dist/types/src/query/query-planner.d.ts.map +1 -1
- package/dist/types/src/space/admission-discovery-extension.d.ts.map +1 -1
- package/dist/types/src/space/auth.d.ts +3 -3
- package/dist/types/src/space/auth.d.ts.map +1 -1
- package/dist/types/src/space/control-pipeline.d.ts +4 -3
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +7 -7
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts +9 -8
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +5 -5
- 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 +0 -2
- 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-feed-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-network-adapter.d.ts +1 -1
- package/dist/types/src/testing/test-network-adapter.d.ts.map +1 -1
- package/dist/types/src/testing/test-replicator.d.ts +13 -13
- package/dist/types/src/testing/test-replicator.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -54
- package/src/automerge/automerge-host-subduction.test.ts +263 -0
- package/src/automerge/automerge-host.test.ts +145 -32
- package/src/automerge/automerge-host.ts +442 -163
- package/src/automerge/automerge-repo-subduction.test.ts +1054 -0
- package/src/automerge/automerge-repo.test.ts +284 -77
- package/src/automerge/automerge-subduction.test.ts +330 -0
- package/src/automerge/collection-synchronizer.test.ts +96 -16
- package/src/automerge/collection-synchronizer.ts +125 -26
- package/src/automerge/echo-network-adapter.test.ts +2 -1
- package/src/automerge/echo-network-adapter.ts +44 -32
- package/src/automerge/echo-replicator.ts +30 -16
- package/src/automerge/errors.ts +10 -0
- package/src/automerge/handle-state.ts +62 -0
- package/src/automerge/heads-store.ts +42 -3
- package/src/automerge/index.ts +2 -0
- package/src/automerge/leveldb-storage-adapter.ts +70 -4
- package/src/automerge/mesh-echo-replicator-connection.ts +8 -8
- package/src/automerge/mesh-echo-replicator.ts +14 -11
- package/src/db-host/automerge-data-source.test.ts +299 -0
- package/src/db-host/automerge-data-source.ts +187 -0
- package/src/db-host/data-service.ts +27 -10
- package/src/db-host/database-root.ts +19 -7
- package/src/db-host/documents-synchronizer.test.ts +145 -14
- package/src/db-host/documents-synchronizer.ts +158 -59
- package/src/db-host/echo-host.ts +376 -90
- package/src/db-host/index.ts +2 -0
- package/src/db-host/invalidation-hint.ts +50 -0
- package/src/db-host/local-queue-service.ts +127 -0
- package/src/db-host/query-invalidation.test.ts +270 -0
- package/src/db-host/query-service.ts +108 -111
- package/src/db-host/queue-data-source.ts +160 -0
- package/src/db-host/queue-service.test.ts +145 -0
- package/src/db-host/space-state-manager.ts +11 -9
- package/src/db-host/stub.ts +33 -0
- package/src/edge/echo-edge-replicator.test.ts +9 -9
- package/src/edge/echo-edge-replicator.ts +50 -42
- package/src/edge/echo-edge-subduction-replicator.test.ts +158 -0
- package/src/edge/echo-edge-subduction-replicator.ts +377 -0
- package/src/edge/index.ts +1 -0
- package/src/filter/filter-match.test.ts +41 -25
- package/src/filter/filter-match.ts +75 -20
- package/src/metadata/metadata-store.ts +8 -5
- package/src/pipeline/pipeline-stress.test.ts +1 -3
- package/src/pipeline/pipeline.test.ts +0 -1
- package/src/pipeline/pipeline.ts +2 -3
- package/src/query/errors.ts +2 -2
- package/src/query/plan.ts +73 -9
- package/src/query/query-executor.ts +1064 -172
- package/src/query/query-planner.test.ts +854 -86
- package/src/query/query-planner.ts +444 -38
- package/src/space/admission-discovery-extension.ts +1 -1
- package/src/space/auth.ts +6 -6
- package/src/space/control-pipeline.test.ts +2 -2
- package/src/space/control-pipeline.ts +7 -7
- package/src/space/space-manager.ts +12 -17
- package/src/space/space-protocol.browser.test.ts +13 -12
- package/src/space/space-protocol.test.ts +13 -13
- package/src/space/space-protocol.ts +16 -15
- package/src/space/space.test.ts +2 -2
- package/src/space/space.ts +9 -10
- package/src/testing/index.ts +0 -2
- package/src/testing/test-agent-builder.ts +0 -1
- package/src/testing/test-network-adapter.ts +24 -3
- package/src/testing/test-replicator.ts +15 -20
- package/src/util.ts +7 -3
- package/dist/lib/browser/chunk-CGS2ULMK.mjs +0 -11
- package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +0 -7
- package/dist/lib/browser/chunk-FR6GJ4S4.mjs.map +0 -7
- package/dist/lib/browser/chunk-WJJXJTNS.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -5492
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JQCCVDLT.mjs +0 -2144
- package/dist/lib/node-esm/chunk-JQCCVDLT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LEQ77KAT.mjs +0 -240
- package/dist/lib/node-esm/chunk-LEQ77KAT.mjs.map +0 -7
- package/dist/lib/node-esm/filter/index.mjs +0 -13
- package/dist/lib/node-esm/filter/index.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -5492
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -764
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/db-host/documents-iterator.d.ts +0 -7
- package/dist/types/src/db-host/documents-iterator.d.ts.map +0 -1
- package/dist/types/src/testing/test-data.d.ts +0 -18
- package/dist/types/src/testing/test-data.d.ts.map +0 -1
- package/dist/types/src/testing/test-schema.d.ts +0 -37
- package/dist/types/src/testing/test-schema.d.ts.map +0 -1
- package/src/db-host/documents-iterator.ts +0 -74
- package/src/testing/test-data.ts +0 -127
- package/src/testing/test-schema.ts +0 -53
- /package/dist/lib/{browser → neutral}/filter/index.mjs.map +0 -0
|
@@ -91,14 +91,17 @@ export class MetadataStore {
|
|
|
91
91
|
log('loaded', { size: dataSize, checksum, name: file.filename });
|
|
92
92
|
|
|
93
93
|
if (fileLength < dataSize + 8) {
|
|
94
|
-
throw new DataCorruptionError(
|
|
94
|
+
throw new DataCorruptionError({
|
|
95
|
+
message: 'Metadata size is smaller than expected.',
|
|
96
|
+
context: { fileLength, dataSize },
|
|
97
|
+
});
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
const data = await file.read(8, dataSize);
|
|
98
101
|
|
|
99
102
|
const calculatedChecksum = CRC32.buf(data);
|
|
100
103
|
if (calculatedChecksum !== checksum) {
|
|
101
|
-
throw new DataCorruptionError('Metadata checksum is invalid.');
|
|
104
|
+
throw new DataCorruptionError({ message: 'Metadata checksum is invalid.' });
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
return codec.decode(data);
|
|
@@ -363,9 +366,9 @@ const fromBytesInt32 = (buf: Buffer) => buf.readInt32LE(0);
|
|
|
363
366
|
export const hasInvitationExpired = (invitation: Invitation): boolean => {
|
|
364
367
|
return Boolean(
|
|
365
368
|
invitation.created &&
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
+
invitation.lifetime &&
|
|
370
|
+
invitation.lifetime !== 0 &&
|
|
371
|
+
invitation.created.getTime() + invitation.lifetime * 1000 < Date.now(),
|
|
369
372
|
);
|
|
370
373
|
};
|
|
371
374
|
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { inspect } from 'node:util';
|
|
6
|
-
|
|
7
5
|
import * as fc from 'fast-check';
|
|
6
|
+
import { inspect } from 'node:util';
|
|
8
7
|
import { describe, expect, test } from 'vitest';
|
|
9
8
|
|
|
10
9
|
import { asyncTimeout } from '@dxos/async';
|
|
@@ -17,7 +16,6 @@ import { Timeframe } from '@dxos/timeframe';
|
|
|
17
16
|
import { range } from '@dxos/util';
|
|
18
17
|
|
|
19
18
|
import { TestFeedBuilder } from '../testing';
|
|
20
|
-
|
|
21
19
|
import { Pipeline } from './pipeline';
|
|
22
20
|
|
|
23
21
|
const NUM_AGENTS = 2;
|
package/src/pipeline/pipeline.ts
CHANGED
|
@@ -15,11 +15,10 @@ import { Timeframe } from '@dxos/timeframe';
|
|
|
15
15
|
import { ComplexMap } from '@dxos/util';
|
|
16
16
|
|
|
17
17
|
import { createMappedFeedWriter } from '../common';
|
|
18
|
-
|
|
19
18
|
import { createMessageSelector } from './message-selector';
|
|
20
19
|
import { TimeframeClock, mapFeedIndexesToTimeframe, startAfter } from './timeframe-clock';
|
|
21
20
|
|
|
22
|
-
export type
|
|
21
|
+
export type WaitUntilReachedTargetProps = {
|
|
23
22
|
/**
|
|
24
23
|
* For cancellation.
|
|
25
24
|
*/
|
|
@@ -132,7 +131,7 @@ export class PipelineState {
|
|
|
132
131
|
ctx = new Context(),
|
|
133
132
|
timeout,
|
|
134
133
|
breakOnStall = true,
|
|
135
|
-
}:
|
|
134
|
+
}: WaitUntilReachedTargetProps = {}): Promise<void> {
|
|
136
135
|
log('waitUntilReachedTargetTimeframe', {
|
|
137
136
|
timeout,
|
|
138
137
|
current: this.timeframe,
|
package/src/query/errors.ts
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import { BaseError } from '@dxos/errors';
|
|
6
6
|
|
|
7
|
-
export class QueryError extends BaseError.extend('
|
|
7
|
+
export class QueryError extends BaseError.extend('QueryError') {}
|
|
8
8
|
|
|
9
|
-
export class InvalidQueryError extends QueryError.extend('
|
|
9
|
+
export class InvalidQueryError extends QueryError.extend('InvalidQueryError') {}
|
package/src/query/plan.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import type { QueryAST } from '@dxos/echo-protocol';
|
|
6
|
-
import type { EscapedPropPath } from '@dxos/
|
|
7
|
-
import type { DXN, ObjectId
|
|
6
|
+
import type { EscapedPropPath } from '@dxos/index-core';
|
|
7
|
+
import type { DXN, ObjectId } from '@dxos/keys';
|
|
8
8
|
|
|
9
9
|
export namespace QueryPlan {
|
|
10
10
|
export type TextSearchKind = 'full-text' | 'vector' | 'hybrid';
|
|
@@ -33,7 +33,8 @@ export namespace QueryPlan {
|
|
|
33
33
|
| TraverseStep
|
|
34
34
|
| UnionStep
|
|
35
35
|
| SetDifferenceStep
|
|
36
|
-
| OrderStep
|
|
36
|
+
| OrderStep
|
|
37
|
+
| LimitStep;
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Clear the current working set.
|
|
@@ -44,20 +45,34 @@ export namespace QueryPlan {
|
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* Select objects based on id, typename, or other predicates.
|
|
47
|
-
* Specifies the spaces to select from.
|
|
48
|
+
* Specifies the spaces and/or queues to select from.
|
|
49
|
+
* The results from spaces and queues are unioned together.
|
|
48
50
|
*/
|
|
49
51
|
export type SelectStep = {
|
|
50
52
|
_tag: 'SelectStep';
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
/**
|
|
55
|
+
* What to select from the scope.
|
|
56
|
+
*/
|
|
53
57
|
selector: Selector;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Where to select from.
|
|
61
|
+
*/
|
|
62
|
+
scope: QueryAST.Scope;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Optional limit on the number of results to select.
|
|
66
|
+
* When set, the index scan can be optimized to stop early.
|
|
67
|
+
*/
|
|
68
|
+
limit?: number;
|
|
54
69
|
};
|
|
55
70
|
|
|
56
71
|
/**
|
|
57
72
|
* Specifier to scan the database for objects.
|
|
58
73
|
* Optimized to utilize database indexes.
|
|
59
74
|
*/
|
|
60
|
-
export type Selector = WildcardSelector | IdSelector | TypeSelector | TextSelector;
|
|
75
|
+
export type Selector = WildcardSelector | IdSelector | TypeSelector | TextSelector | TimestampSelector;
|
|
61
76
|
|
|
62
77
|
export type WildcardSelector = {
|
|
63
78
|
_tag: 'WildcardSelector';
|
|
@@ -91,6 +106,24 @@ export namespace QueryPlan {
|
|
|
91
106
|
|
|
92
107
|
text: string;
|
|
93
108
|
searchKind: TextSearchKind;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Optionally select only objects of the given typenames.
|
|
112
|
+
*/
|
|
113
|
+
typename: DXN.String[] | null;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Select objects by timestamp range (createdAt / updatedAt).
|
|
118
|
+
* Uses the ObjectMetaIndex timestamp columns.
|
|
119
|
+
*/
|
|
120
|
+
export type TimestampSelector = {
|
|
121
|
+
_tag: 'TimestampSelector';
|
|
122
|
+
|
|
123
|
+
updatedAfter?: number;
|
|
124
|
+
updatedBefore?: number;
|
|
125
|
+
createdAfter?: number;
|
|
126
|
+
createdBefore?: number;
|
|
94
127
|
};
|
|
95
128
|
|
|
96
129
|
/**
|
|
@@ -111,7 +144,8 @@ export namespace QueryPlan {
|
|
|
111
144
|
step.filter.typename === null &&
|
|
112
145
|
(step.filter.id === undefined || step.filter.id.length === 0) &&
|
|
113
146
|
(step.filter.props === undefined || Object.keys(step.filter.props).length === 0) &&
|
|
114
|
-
(step.filter.foreignKeys === undefined || step.filter.foreignKeys.length === 0)
|
|
147
|
+
(step.filter.foreignKeys === undefined || step.filter.foreignKeys.length === 0) &&
|
|
148
|
+
step.filter.metaKey === undefined
|
|
115
149
|
);
|
|
116
150
|
}
|
|
117
151
|
default:
|
|
@@ -141,7 +175,7 @@ export namespace QueryPlan {
|
|
|
141
175
|
/**
|
|
142
176
|
* Describes a traversal of the object graph.
|
|
143
177
|
*/
|
|
144
|
-
export type Traversal = ReferenceTraversal | RelationTraversal;
|
|
178
|
+
export type Traversal = ReferenceTraversal | RelationTraversal | HierarchyTraversal;
|
|
145
179
|
|
|
146
180
|
/**
|
|
147
181
|
* Traverse a reference connection.
|
|
@@ -151,8 +185,9 @@ export namespace QueryPlan {
|
|
|
151
185
|
|
|
152
186
|
/**
|
|
153
187
|
* Property path where the reference is located.
|
|
188
|
+
* If null, matches references from any property (only valid for incoming direction).
|
|
154
189
|
*/
|
|
155
|
-
property: EscapedPropPath;
|
|
190
|
+
property: EscapedPropPath | null;
|
|
156
191
|
|
|
157
192
|
/**
|
|
158
193
|
* outgoing: the reference points from the anchor object to the target.
|
|
@@ -174,6 +209,19 @@ export namespace QueryPlan {
|
|
|
174
209
|
direction: 'source-to-relation' | 'relation-to-source' | 'target-to-relation' | 'relation-to-target';
|
|
175
210
|
};
|
|
176
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Traverse parent-child hierarchy.
|
|
214
|
+
*/
|
|
215
|
+
export type HierarchyTraversal = {
|
|
216
|
+
_tag: 'HierarchyTraversal';
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* to-parent: traverse from child to parent.
|
|
220
|
+
* to-children: traverse from parent to children.
|
|
221
|
+
*/
|
|
222
|
+
direction: 'to-parent' | 'to-children';
|
|
223
|
+
};
|
|
224
|
+
|
|
177
225
|
/**
|
|
178
226
|
* Combine results from multiple plans.
|
|
179
227
|
* Each of the plans starts with a copy of the current working set.
|
|
@@ -203,5 +251,21 @@ export namespace QueryPlan {
|
|
|
203
251
|
|
|
204
252
|
// Defaults to natural order if empty.
|
|
205
253
|
order: readonly QueryAST.Order[];
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Optional limit on the number of results to return after ordering.
|
|
257
|
+
* When set, the sorting can be optimized to only track the top N elements.
|
|
258
|
+
*/
|
|
259
|
+
// TODO(dmaretskyi): Remove. This doesn't belong here.
|
|
260
|
+
limit?: number;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Limit the number of results.
|
|
265
|
+
*/
|
|
266
|
+
export type LimitStep = {
|
|
267
|
+
_tag: 'LimitStep';
|
|
268
|
+
|
|
269
|
+
limit: number;
|
|
206
270
|
};
|
|
207
271
|
}
|