@firebase/firestore 3.4.4-canary.f5ac47fb1 → 3.4.5

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.
Files changed (151) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/firestore/src/api/credentials.d.ts +1 -0
  3. package/dist/firestore/src/index/index_byte_encoder.d.ts +18 -1
  4. package/dist/firestore/src/index/index_entry.d.ts +26 -0
  5. package/dist/firestore/src/local/document_overlay_cache.d.ts +72 -0
  6. package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  7. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +29 -2
  8. package/dist/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  9. package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  10. package/dist/firestore/src/local/indexeddb_schema.d.ts +83 -9
  11. package/dist/firestore/src/local/local_documents_view.d.ts +0 -1
  12. package/dist/firestore/src/local/local_serializer.d.ts +18 -2
  13. package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  14. package/dist/firestore/src/local/memory_persistence.d.ts +6 -2
  15. package/dist/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  16. package/dist/firestore/src/local/persistence.d.ts +8 -2
  17. package/dist/firestore/src/local/remote_document_cache.d.ts +7 -9
  18. package/dist/firestore/src/model/document_key.d.ts +5 -0
  19. package/dist/firestore/src/model/field_index.d.ts +2 -2
  20. package/dist/firestore/src/model/overlay.d.ts +32 -0
  21. package/dist/firestore/src/model/target_index_matcher.d.ts +70 -0
  22. package/dist/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  23. package/dist/firestore/src/platform/node/load_protos.d.ts +2 -2
  24. package/dist/firestore/src/util/sorted_set.d.ts +18 -0
  25. package/dist/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  26. package/dist/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  27. package/dist/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  28. package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  29. package/dist/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  30. package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
  31. package/dist/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  32. package/dist/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  33. package/dist/index.esm2017.js +4367 -3517
  34. package/dist/index.esm2017.js.map +1 -1
  35. package/dist/index.esm5.js +4226 -3437
  36. package/dist/index.esm5.js.map +1 -1
  37. package/dist/index.node.cjs.js +1519 -242
  38. package/dist/index.node.cjs.js.map +1 -1
  39. package/dist/index.node.mjs +1501 -245
  40. package/dist/index.node.mjs.map +1 -1
  41. package/dist/index.rn.js +4355 -3509
  42. package/dist/index.rn.js.map +1 -1
  43. package/dist/internal.d.ts +84 -12
  44. package/dist/lite/firestore/src/api/credentials.d.ts +1 -0
  45. package/dist/lite/firestore/src/index/index_byte_encoder.d.ts +18 -1
  46. package/dist/lite/firestore/src/index/index_entry.d.ts +26 -0
  47. package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +72 -0
  48. package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  49. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +29 -2
  50. package/dist/lite/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  51. package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  52. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +83 -9
  53. package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -1
  54. package/dist/lite/firestore/src/local/local_serializer.d.ts +18 -2
  55. package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  56. package/dist/lite/firestore/src/local/memory_persistence.d.ts +6 -2
  57. package/dist/lite/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  58. package/dist/lite/firestore/src/local/persistence.d.ts +8 -2
  59. package/dist/lite/firestore/src/local/remote_document_cache.d.ts +7 -9
  60. package/dist/lite/firestore/src/model/document_key.d.ts +5 -0
  61. package/dist/lite/firestore/src/model/field_index.d.ts +2 -2
  62. package/dist/lite/firestore/src/model/overlay.d.ts +32 -0
  63. package/dist/lite/firestore/src/model/target_index_matcher.d.ts +70 -0
  64. package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  65. package/dist/lite/firestore/src/platform/node/load_protos.d.ts +2 -2
  66. package/dist/lite/firestore/src/util/sorted_set.d.ts +18 -0
  67. package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  68. package/dist/lite/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  69. package/dist/lite/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  70. package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  71. package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  72. package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
  73. package/dist/lite/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  74. package/dist/lite/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  75. package/dist/lite/index.browser.esm2017.js +1121 -1112
  76. package/dist/lite/index.browser.esm2017.js.map +1 -1
  77. package/dist/lite/index.browser.esm5.js +60 -48
  78. package/dist/lite/index.browser.esm5.js.map +1 -1
  79. package/dist/lite/index.node.cjs.js +13 -2
  80. package/dist/lite/index.node.cjs.js.map +1 -1
  81. package/dist/lite/index.node.mjs +13 -2
  82. package/dist/lite/index.node.mjs.map +1 -1
  83. package/dist/lite/index.rn.esm2017.js +46 -37
  84. package/dist/lite/index.rn.esm2017.js.map +1 -1
  85. package/dist/lite/internal.d.ts +5 -0
  86. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +112 -112
  87. package/dist/lite/packages/firestore/src/api/credentials.d.ts +1 -0
  88. package/dist/lite/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
  89. package/dist/lite/packages/firestore/src/index/index_entry.d.ts +26 -0
  90. package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +72 -0
  91. package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  92. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +29 -2
  93. package/dist/lite/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  94. package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  95. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +83 -9
  96. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  97. package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +18 -2
  98. package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  99. package/dist/lite/packages/firestore/src/local/memory_persistence.d.ts +6 -2
  100. package/dist/lite/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  101. package/dist/lite/packages/firestore/src/local/persistence.d.ts +8 -2
  102. package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  103. package/dist/lite/packages/firestore/src/model/document_key.d.ts +5 -0
  104. package/dist/lite/packages/firestore/src/model/field_index.d.ts +2 -2
  105. package/dist/lite/packages/firestore/src/model/overlay.d.ts +32 -0
  106. package/dist/lite/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  107. package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  108. package/dist/lite/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
  109. package/dist/lite/packages/firestore/src/util/sorted_set.d.ts +18 -0
  110. package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  111. package/dist/lite/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  112. package/dist/lite/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  113. package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  114. package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  115. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
  116. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  117. package/dist/lite/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  118. package/dist/packages/firestore/dist/index.esm2017.d.ts +187 -184
  119. package/dist/packages/firestore/src/api/credentials.d.ts +1 -0
  120. package/dist/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
  121. package/dist/packages/firestore/src/index/index_entry.d.ts +26 -0
  122. package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +72 -0
  123. package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  124. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +29 -2
  125. package/dist/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  126. package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  127. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +83 -9
  128. package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  129. package/dist/packages/firestore/src/local/local_serializer.d.ts +18 -2
  130. package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  131. package/dist/packages/firestore/src/local/memory_persistence.d.ts +6 -2
  132. package/dist/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  133. package/dist/packages/firestore/src/local/persistence.d.ts +8 -2
  134. package/dist/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  135. package/dist/packages/firestore/src/model/document_key.d.ts +5 -0
  136. package/dist/packages/firestore/src/model/field_index.d.ts +2 -2
  137. package/dist/packages/firestore/src/model/overlay.d.ts +32 -0
  138. package/dist/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  139. package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  140. package/dist/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
  141. package/dist/packages/firestore/src/util/sorted_set.d.ts +18 -0
  142. package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  143. package/dist/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  144. package/dist/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  145. package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  146. package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  147. package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
  148. package/dist/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  149. package/dist/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  150. package/dist/private.d.ts +79 -12
  151. package/package.json +9 -9
@@ -18,6 +18,7 @@ import { User } from '../auth/user';
18
18
  import { TargetId } from '../core/types';
19
19
  import { DocumentKey } from '../model/document_key';
20
20
  import { BundleCache } from './bundle_cache';
21
+ import { DocumentOverlayCache } from './document_overlay_cache';
21
22
  import { IndexManager } from './index_manager';
22
23
  import { LocalStore } from './local_store';
23
24
  import { MutationQueue } from './mutation_queue';
@@ -140,7 +141,7 @@ export interface Persistence {
140
141
  * extent possible (e.g. in the case of uid switching from
141
142
  * sally=>jack=>sally, sally's mutation queue will be preserved).
142
143
  */
143
- getMutationQueue(user: User): MutationQueue;
144
+ getMutationQueue(user: User, indexManager: IndexManager): MutationQueue;
144
145
  /**
145
146
  * Returns a TargetCache representing the persisted cache of targets.
146
147
  *
@@ -173,7 +174,12 @@ export interface Persistence {
173
174
  * this is called. In particular, the memory-backed implementation does this
174
175
  * to emulate the persisted implementation to the extent possible.
175
176
  */
176
- getIndexManager(): IndexManager;
177
+ getIndexManager(user: User): IndexManager;
178
+ /**
179
+ * Returns a DocumentOverlayCache representing the documents that are mutated
180
+ * locally.
181
+ */
182
+ getDocumentOverlayCache(user: User): DocumentOverlayCache;
177
183
  /**
178
184
  * Performs an operation inside a persistence transaction. Any reads or writes
179
185
  * against persistence must be performed within a transaction. Writes will be
@@ -14,11 +14,12 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { Query } from '../core/query';
18
17
  import { SnapshotVersion } from '../core/snapshot_version';
19
18
  import { DocumentKeySet, MutableDocumentMap } from '../model/collections';
20
19
  import { MutableDocument } from '../model/document';
21
20
  import { DocumentKey } from '../model/document_key';
21
+ import { ResourcePath } from '../model/path';
22
+ import { IndexManager } from './index_manager';
22
23
  import { PersistencePromise } from './persistence_promise';
23
24
  import { PersistenceTransaction } from './persistence_transaction';
24
25
  import { RemoteDocumentChangeBuffer } from './remote_document_change_buffer';
@@ -30,6 +31,8 @@ import { RemoteDocumentChangeBuffer } from './remote_document_change_buffer';
30
31
  * documents that are known to not exist.
31
32
  */
32
33
  export interface RemoteDocumentCache {
34
+ /** Sets the index manager to use for managing the collectionGroup index. */
35
+ setIndexManager(indexManager: IndexManager): void;
33
36
  /**
34
37
  * Looks up an entry in the cache.
35
38
  *
@@ -47,19 +50,14 @@ export interface RemoteDocumentCache {
47
50
  */
48
51
  getEntries(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
49
52
  /**
50
- * Executes a query against the cached Document entries.
53
+ * Returns the documents from the provided collection.
51
54
  *
52
- * Implementations may return extra documents if convenient. The results
53
- * should be re-filtered by the consumer before presenting them to the user.
54
- *
55
- * Cached NoDocument entries have no bearing on query results.
56
- *
57
- * @param query - The query to match documents against.
55
+ * @param collection - The collection to read.
58
56
  * @param sinceReadTime - If not set to SnapshotVersion.min(), return only
59
57
  * documents that have been read since this snapshot version (exclusive).
60
58
  * @returns The set of matching documents.
61
59
  */
62
- getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
60
+ getAll(transaction: PersistenceTransaction, collection: ResourcePath, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
63
61
  /**
64
62
  * Provides access to add or update the contents of the cache. The buffer
65
63
  * handles proper size accounting for the change.
@@ -24,8 +24,13 @@ export declare class DocumentKey {
24
24
  static fromPath(path: string): DocumentKey;
25
25
  static fromName(name: string): DocumentKey;
26
26
  static empty(): DocumentKey;
27
+ get collectionGroup(): string;
27
28
  /** Returns true if the document is in the specified collectionId. */
28
29
  hasCollectionId(collectionId: string): boolean;
30
+ /** Returns the collection group (i.e. the name of the parent collection) for this key. */
31
+ getCollectionGroup(): string;
32
+ /** Returns the fully qualified path to the parent collection. */
33
+ getCollectionPath(): ResourcePath;
29
34
  isEqual(other: DocumentKey | null): boolean;
30
35
  toString(): string;
31
36
  static comparator(k1: DocumentKey, k2: DocumentKey): number;
@@ -43,7 +43,7 @@ export declare class FieldIndex {
43
43
  /** The collection ID this index applies to. */
44
44
  readonly collectionGroup: string;
45
45
  /** The field segments for this index. */
46
- readonly segments: IndexSegment[];
46
+ readonly fields: IndexSegment[];
47
47
  /** Shows how up-to-date the index is for the current user. */
48
48
  readonly indexState: IndexState;
49
49
  /** An ID for an index that has not yet been added to persistence. */
@@ -57,7 +57,7 @@ export declare class FieldIndex {
57
57
  /** The collection ID this index applies to. */
58
58
  collectionGroup: string,
59
59
  /** The field segments for this index. */
60
- segments: IndexSegment[],
60
+ fields: IndexSegment[],
61
61
  /** Shows how up-to-date the index is for the current user. */
62
62
  indexState: IndexState);
63
63
  }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DocumentKey } from './document_key';
18
+ import { Mutation } from './mutation';
19
+ /**
20
+ * Representation of an overlay computed by Firestore.
21
+ *
22
+ * Holds information about a mutation and the largest batch id in Firestore when
23
+ * the mutation was created.
24
+ */
25
+ export declare class Overlay {
26
+ readonly largestBatchId: number;
27
+ readonly mutation: Mutation;
28
+ constructor(largestBatchId: number, mutation: Mutation);
29
+ getKey(): DocumentKey;
30
+ isEqual(other: Overlay | null): boolean;
31
+ toString(): string;
32
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Target } from '../core/target';
18
+ import { FieldIndex } from './field_index';
19
+ /**
20
+ * A light query planner for Firestore.
21
+ *
22
+ * This class matches a `FieldIndex` against a Firestore Query `Target`. It
23
+ * determines whether a given index can be used to serve the specified target.
24
+ *
25
+ * The following table showcases some possible index configurations:
26
+ *
27
+ * Query | Index
28
+ * -----------------------------------------------------------------------------
29
+ * where('a', '==', 'a').where('b', '==', 'b') | a ASC, b DESC
30
+ * where('a', '==', 'a').where('b', '==', 'b') | a ASC
31
+ * where('a', '==', 'a').where('b', '==', 'b') | b DESC
32
+ * where('a', '>=', 'a').orderBy('a') | a ASC
33
+ * where('a', '>=', 'a').orderBy('a', 'desc') | a DESC
34
+ * where('a', '>=', 'a').orderBy('a').orderBy('b') | a ASC, b ASC
35
+ * where('a', '>=', 'a').orderBy('a').orderBy('b') | a ASC
36
+ * where('a', 'array-contains', 'a').orderBy('b') | a CONTAINS, b ASCENDING
37
+ * where('a', 'array-contains', 'a').orderBy('b') | a CONTAINS
38
+ */
39
+ export declare class TargetIndexMatcher {
40
+ private readonly collectionId;
41
+ private readonly inequalityFilter?;
42
+ private readonly equalityFilters;
43
+ private readonly orderBys;
44
+ constructor(target: Target);
45
+ /**
46
+ * Returns whether the index can be used to serve the TargetIndexMatcher's
47
+ * target.
48
+ *
49
+ * An index is considered capable of serving the target when:
50
+ * - The target uses all index segments for its filters and orderBy clauses.
51
+ * The target can have additional filter and orderBy clauses, but not
52
+ * fewer.
53
+ * - If an ArrayContains/ArrayContainsAnyfilter is used, the index must also
54
+ * have a corresponding `CONTAINS` segment.
55
+ * - All directional index segments can be mapped to the target as a series of
56
+ * equality filters, a single inequality filter and a series of orderBy
57
+ * clauses.
58
+ * - The segments that represent the equality filters may appear out of order.
59
+ * - The optional segment for the inequality filter must appear after all
60
+ * equality segments.
61
+ * - The segments that represent that orderBy clause of the target must appear
62
+ * in order after all equality and inequality segments. Single orderBy
63
+ * clauses cannot be skipped, but a continuous orderBy suffix may be
64
+ * omitted.
65
+ */
66
+ servedByIndex(index: FieldIndex): boolean;
67
+ private hasMatchingEqualityFilter;
68
+ private matchesFilter;
69
+ private matchesOrderBy;
70
+ }
@@ -14,7 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { GrpcObject } from '@grpc/grpc-js';
17
+ import * as grpc from '@grpc/grpc-js';
18
18
  import { Token } from '../../api/credentials';
19
19
  import { DatabaseInfo } from '../../core/database_info';
20
20
  import { Connection, Stream } from '../../remote/connection';
@@ -26,7 +26,7 @@ export declare class GrpcConnection implements Connection {
26
26
  private readonly databasePath;
27
27
  private readonly firestore;
28
28
  private cachedStub;
29
- constructor(protos: GrpcObject, databaseInfo: DatabaseInfo);
29
+ constructor(protos: grpc.GrpcObject, databaseInfo: DatabaseInfo);
30
30
  private ensureActiveStub;
31
31
  invokeRPC<Req, Resp>(rpcName: string, path: string, request: Req, authToken: Token | null, appCheckToken: Token | null): Promise<Resp>;
32
32
  invokeStreamingRPC<Req, Resp>(rpcName: string, path: string, request: Req, authToken: Token | null, appCheckToken: Token | null): Promise<Resp[]>;
@@ -14,7 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { GrpcObject } from '@grpc/grpc-js';
17
+ import * as grpc from '@grpc/grpc-js';
18
18
  import { IConversionOptions, Root } from 'protobufjs';
19
19
  /** Used by tests so we can match @grpc/proto-loader behavior. */
20
20
  export declare const protoLoaderOptions: IConversionOptions;
@@ -23,6 +23,6 @@ export declare const protoLoaderOptions: IConversionOptions;
23
23
  *
24
24
  * @returns The GrpcObject representing our protos.
25
25
  */
26
- export declare function loadProtos(): GrpcObject;
26
+ export declare function loadProtos(): grpc.GrpcObject;
27
27
  /** Used by tests so we can directly create ProtobufJS proto message objects from JSON protos. */
28
28
  export declare function loadRawProtos(): Root;
@@ -60,3 +60,21 @@ export declare class SortedSetIterator<T> {
60
60
  getNext(): T;
61
61
  hasNext(): boolean;
62
62
  }
63
+ /**
64
+ * Compares two sorted sets for equality using their natural ordering. The
65
+ * method computes the intersection and invokes `onAdd` for every element that
66
+ * is in `after` but not `before`. `onRemove` is invoked for every element in
67
+ * `before` but missing from `after`.
68
+ *
69
+ * The method creates a copy of both `before` and `after` and runs in O(n log
70
+ * n), where n is the size of the two lists.
71
+ *
72
+ * @param before - The elements that exist in the original set.
73
+ * @param after - The elements to diff against the original set.
74
+ * @param comparator - The comparator for the elements in before and after.
75
+ * @param onAdd - A function to invoke for every element that is part of `
76
+ * after` but not `before`.
77
+ * @param onRemove - A function to invoke for every element that is part of
78
+ * `before` but not `after`.
79
+ */
80
+ export declare function diffSortedSets<T>(before: SortedSet<T>, after: SortedSet<T>, comparator: (l: T, r: T) => number, onAdd: (entry: T) => void, onRemove: (entry: T) => void): void;
@@ -31,7 +31,7 @@ export declare class CountingQueryEngine extends QueryEngine {
31
31
  * `getAllMutationBatchesAffectingQuery()` API (since the last call to
32
32
  * `resetCounts()`)
33
33
  */
34
- mutationsReadByQuery: number;
34
+ mutationsReadByCollection: number;
35
35
  /**
36
36
  * The number of mutations returned by the MutationQueue's
37
37
  * `getAllMutationBatchesAffectingDocumentKey()` and
@@ -41,9 +41,9 @@ export declare class CountingQueryEngine extends QueryEngine {
41
41
  mutationsReadByKey: number;
42
42
  /**
43
43
  * The number of documents returned by the RemoteDocumentCache's
44
- * `getDocumentsMatchingQuery()` API (since the last call to `resetCounts()`)
44
+ * `getAll()` API (since the last call to `resetCounts()`)
45
45
  */
46
- documentsReadByQuery: number;
46
+ documentsReadByCollection: number;
47
47
  /**
48
48
  * The number of documents returned by the RemoteDocumentCache's `getEntry()`
49
49
  * and `getEntries()` APIs (since the last call to `resetCounts()`)
@@ -54,6 +54,7 @@ export declare function testIndexedDbPersistence(options?: {
54
54
  dontPurgeData?: boolean;
55
55
  synchronizeTabs?: boolean;
56
56
  queue?: AsyncQueue;
57
+ schemaVersion?: number;
57
58
  }, lruParams?: LruParams): Promise<IndexedDbPersistence>;
58
59
  /** Creates and starts a MemoryPersistence instance for testing. */
59
60
  export declare function testMemoryEagerPersistence(): Promise<MemoryPersistence>;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DocumentOverlayCache } from '../../../src/local/document_overlay_cache';
18
+ import { Persistence } from '../../../src/local/persistence';
19
+ import { DocumentKeySet } from '../../../src/model/collections';
20
+ import { DocumentKey } from '../../../src/model/document_key';
21
+ import { Mutation } from '../../../src/model/mutation';
22
+ import { Overlay } from '../../../src/model/overlay';
23
+ import { ResourcePath } from '../../../src/model/path';
24
+ /**
25
+ * A wrapper around a DocumentOverlayCache that automatically creates a
26
+ * transaction around every operation to reduce test boilerplate.
27
+ */
28
+ export declare class TestDocumentOverlayCache {
29
+ private persistence;
30
+ private cache;
31
+ constructor(persistence: Persistence, cache: DocumentOverlayCache);
32
+ saveOverlays(largestBatch: number, data: Map<DocumentKey, Mutation>): Promise<void>;
33
+ getOverlay(key: DocumentKey): Promise<Overlay | null>;
34
+ getOverlayMutation(docKey: string): Promise<Mutation | null>;
35
+ getOverlaysForCollection(path: ResourcePath, sinceBatchId: number): Promise<Map<DocumentKey, Overlay>>;
36
+ getOverlaysForCollectionGroup(collectionGroup: string, sinceBatchId: number, count: number): Promise<Map<DocumentKey, Overlay>>;
37
+ removeOverlaysForBatchId(documentKeys: DocumentKeySet, batchId: number): Promise<void>;
38
+ }
@@ -14,8 +14,11 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { Target } from '../../../src/core/target';
17
18
  import { IndexManager } from '../../../src/local/index_manager';
18
19
  import { Persistence } from '../../../src/local/persistence';
20
+ import { DocumentKeySet, DocumentMap } from '../../../src/model/collections';
21
+ import { FieldIndex, IndexOffset } from '../../../src/model/field_index';
19
22
  import { ResourcePath } from '../../../src/model/path';
20
23
  /**
21
24
  * A wrapper around IndexManager that automatically creates a
@@ -27,4 +30,12 @@ export declare class TestIndexManager {
27
30
  constructor(persistence: Persistence, indexManager: IndexManager);
28
31
  addToCollectionParentIndex(collectionPath: ResourcePath): Promise<void>;
29
32
  getCollectionParents(collectionId: string): Promise<ResourcePath[]>;
33
+ addFieldIndex(index: FieldIndex): Promise<void>;
34
+ deleteFieldIndex(index: FieldIndex): Promise<void>;
35
+ getFieldIndexes(collectionGroup?: string): Promise<FieldIndex[]>;
36
+ getFieldIndex(target: Target): Promise<FieldIndex | null>;
37
+ getDocumentsMatchingTarget(fieldIndex: FieldIndex, target: Target): Promise<DocumentKeySet>;
38
+ getNextCollectionGroupToUpdate(): Promise<string | null>;
39
+ updateCollectionGroup(collectionGroup: string, offset: IndexOffset): Promise<void>;
40
+ updateIndexEntries(documents: DocumentMap): Promise<void>;
30
41
  }
@@ -14,13 +14,14 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { Query } from '../../../src/core/query';
18
17
  import { SnapshotVersion } from '../../../src/core/snapshot_version';
18
+ import { IndexManager } from '../../../src/local/index_manager';
19
19
  import { Persistence } from '../../../src/local/persistence';
20
20
  import { RemoteDocumentChangeBuffer } from '../../../src/local/remote_document_change_buffer';
21
21
  import { DocumentKeySet, MutableDocumentMap } from '../../../src/model/collections';
22
22
  import { MutableDocument } from '../../../src/model/document';
23
23
  import { DocumentKey } from '../../../src/model/document_key';
24
+ import { ResourcePath } from '../../../src/model/path';
24
25
  /**
25
26
  * A wrapper around a RemoteDocumentCache that automatically creates a
26
27
  * transaction around every operation to reduce test boilerplate.
@@ -29,6 +30,7 @@ export declare class TestRemoteDocumentCache {
29
30
  private readonly persistence;
30
31
  private readonly cache;
31
32
  constructor(persistence: Persistence);
33
+ setIndexManager(indexManager: IndexManager): void;
32
34
  /**
33
35
  * Reads all of the documents first so we can safely add them and keep the size calculation in
34
36
  * sync.
@@ -42,7 +44,7 @@ export declare class TestRemoteDocumentCache {
42
44
  removeEntry(documentKey: DocumentKey, version?: SnapshotVersion): Promise<void>;
43
45
  getEntry(documentKey: DocumentKey): Promise<MutableDocument>;
44
46
  getEntries(documentKeys: DocumentKeySet): Promise<MutableDocumentMap>;
45
- getDocumentsMatchingQuery(query: Query, sinceReadTime: SnapshotVersion): Promise<MutableDocumentMap>;
47
+ getAll(collection: ResourcePath, sinceReadTime: SnapshotVersion): Promise<MutableDocumentMap>;
46
48
  getNewDocumentChanges(sinceReadTime: SnapshotVersion): Promise<{
47
49
  changedDocs: MutableDocumentMap;
48
50
  readTime: SnapshotVersion;
@@ -28,7 +28,7 @@ export declare class TestRemoteDocumentChangeBuffer {
28
28
  buffer: RemoteDocumentChangeBuffer;
29
29
  constructor(persistence: Persistence, buffer: RemoteDocumentChangeBuffer);
30
30
  addEntry(document: MutableDocument, readTime: SnapshotVersion): void;
31
- removeEntry(key: DocumentKey): void;
31
+ removeEntry(key: DocumentKey, readTime: SnapshotVersion): void;
32
32
  getEntry(documentKey: DocumentKey): Promise<MutableDocument>;
33
33
  apply(): Promise<void>;
34
34
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export {};