@firebase/firestore 3.4.4-canary.2dd99ae2d → 3.4.4-canary.50de44c2e

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 (128) hide show
  1. package/dist/firestore/src/api/snapshot.d.ts +1 -2
  2. package/dist/firestore/src/core/target.d.ts +8 -4
  3. package/dist/firestore/src/lite-api/query.d.ts +2 -2
  4. package/dist/firestore/src/local/index_manager.d.ts +52 -0
  5. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +21 -2
  6. package/dist/firestore/src/local/indexeddb_persistence.d.ts +4 -4
  7. package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  8. package/dist/firestore/src/local/indexeddb_schema.d.ts +149 -7
  9. package/dist/firestore/src/local/local_documents_view.d.ts +0 -1
  10. package/dist/firestore/src/local/local_serializer.d.ts +7 -2
  11. package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
  12. package/dist/firestore/src/local/memory_persistence.d.ts +3 -2
  13. package/dist/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  14. package/dist/firestore/src/local/persistence.d.ts +2 -2
  15. package/dist/firestore/src/local/remote_document_cache.d.ts +7 -9
  16. package/dist/firestore/src/local/simple_db.d.ts +1 -0
  17. package/dist/firestore/src/model/field_index.d.ts +2 -2
  18. package/dist/firestore/src/model/target_index_matcher.d.ts +70 -0
  19. package/dist/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  20. package/dist/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  21. package/dist/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  22. package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
  23. package/dist/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  24. package/dist/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  25. package/dist/firestore/test/util/helpers.d.ts +1 -1
  26. package/dist/index.d.ts +1 -2
  27. package/dist/index.esm2017.js +3375 -3136
  28. package/dist/index.esm2017.js.map +1 -1
  29. package/dist/index.esm5.js +3649 -3430
  30. package/dist/index.esm5.js.map +1 -1
  31. package/dist/index.node.cjs.js +498 -219
  32. package/dist/index.node.cjs.js.map +1 -1
  33. package/dist/index.node.mjs +498 -219
  34. package/dist/index.node.mjs.map +1 -1
  35. package/dist/index.rn.js +3635 -3396
  36. package/dist/index.rn.js.map +1 -1
  37. package/dist/internal.d.ts +178 -14
  38. package/dist/lite/firestore/src/api/snapshot.d.ts +1 -2
  39. package/dist/lite/firestore/src/core/target.d.ts +8 -4
  40. package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
  41. package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
  42. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +21 -2
  43. package/dist/lite/firestore/src/local/indexeddb_persistence.d.ts +4 -4
  44. package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  45. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +149 -7
  46. package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -1
  47. package/dist/lite/firestore/src/local/local_serializer.d.ts +7 -2
  48. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
  49. package/dist/lite/firestore/src/local/memory_persistence.d.ts +3 -2
  50. package/dist/lite/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  51. package/dist/lite/firestore/src/local/persistence.d.ts +2 -2
  52. package/dist/lite/firestore/src/local/remote_document_cache.d.ts +7 -9
  53. package/dist/lite/firestore/src/local/simple_db.d.ts +1 -0
  54. package/dist/lite/firestore/src/model/field_index.d.ts +2 -2
  55. package/dist/lite/firestore/src/model/target_index_matcher.d.ts +70 -0
  56. package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  57. package/dist/lite/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  58. package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  59. package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
  60. package/dist/lite/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  61. package/dist/lite/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  62. package/dist/lite/firestore/test/util/helpers.d.ts +1 -1
  63. package/dist/lite/index.browser.esm2017.js +1146 -1143
  64. package/dist/lite/index.browser.esm2017.js.map +1 -1
  65. package/dist/lite/index.browser.esm5.js +332 -331
  66. package/dist/lite/index.browser.esm5.js.map +1 -1
  67. package/dist/lite/index.node.cjs.js +36 -29
  68. package/dist/lite/index.node.cjs.js.map +1 -1
  69. package/dist/lite/index.node.mjs +36 -29
  70. package/dist/lite/index.node.mjs.map +1 -1
  71. package/dist/lite/index.rn.esm2017.js +301 -298
  72. package/dist/lite/index.rn.esm2017.js.map +1 -1
  73. package/dist/lite/internal.d.ts +2 -2
  74. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +121 -121
  75. package/dist/lite/packages/firestore/src/api/snapshot.d.ts +1 -2
  76. package/dist/lite/packages/firestore/src/core/target.d.ts +8 -4
  77. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
  78. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
  79. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +21 -2
  80. package/dist/lite/packages/firestore/src/local/indexeddb_persistence.d.ts +4 -4
  81. package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  82. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +149 -7
  83. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  84. package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +7 -2
  85. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  86. package/dist/lite/packages/firestore/src/local/memory_persistence.d.ts +3 -2
  87. package/dist/lite/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  88. package/dist/lite/packages/firestore/src/local/persistence.d.ts +2 -2
  89. package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  90. package/dist/lite/packages/firestore/src/local/simple_db.d.ts +1 -0
  91. package/dist/lite/packages/firestore/src/model/field_index.d.ts +2 -2
  92. package/dist/lite/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  93. package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  94. package/dist/lite/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  95. package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  96. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
  97. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  98. package/dist/lite/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  99. package/dist/lite/packages/firestore/test/util/helpers.d.ts +1 -1
  100. package/dist/lite/private.d.ts +2 -2
  101. package/dist/packages/firestore/dist/index.esm2017.d.ts +177 -177
  102. package/dist/packages/firestore/src/api/snapshot.d.ts +1 -2
  103. package/dist/packages/firestore/src/core/target.d.ts +8 -4
  104. package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
  105. package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
  106. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +21 -2
  107. package/dist/packages/firestore/src/local/indexeddb_persistence.d.ts +4 -4
  108. package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  109. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +149 -7
  110. package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  111. package/dist/packages/firestore/src/local/local_serializer.d.ts +7 -2
  112. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  113. package/dist/packages/firestore/src/local/memory_persistence.d.ts +3 -2
  114. package/dist/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  115. package/dist/packages/firestore/src/local/persistence.d.ts +2 -2
  116. package/dist/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  117. package/dist/packages/firestore/src/local/simple_db.d.ts +1 -0
  118. package/dist/packages/firestore/src/model/field_index.d.ts +2 -2
  119. package/dist/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  120. package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  121. package/dist/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  122. package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  123. package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
  124. package/dist/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  125. package/dist/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  126. package/dist/packages/firestore/test/util/helpers.d.ts +1 -1
  127. package/dist/private.d.ts +178 -14
  128. package/package.json +9 -9
@@ -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
+ }
@@ -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>;
@@ -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 {};
@@ -71,7 +71,7 @@ export declare function setMutation(keyStr: string, json: JsonObject<unknown>):
71
71
  export declare function patchMutation(keyStr: string, json: JsonObject<unknown>, precondition?: Precondition): PatchMutation;
72
72
  export declare function deleteMutation(keyStr: string): DeleteMutation;
73
73
  export declare function mutationResult(testVersion: TestSnapshotVersion): MutationResult;
74
- export declare function bound(values: unknown[], before: boolean): Bound;
74
+ export declare function bound(values: unknown[], inclusive: boolean): Bound;
75
75
  export declare function query(resourcePath: string, ...constraints: Array<OrderBy | Filter>): Query;
76
76
  export declare function targetData(targetId: TargetId, queryPurpose: TargetPurpose, path: string): TargetData;
77
77
  export declare function noChangeEvent(targetId: number, snapshotVersion: number, resumeToken?: ByteString): RemoteEvent;
package/dist/private.d.ts CHANGED
@@ -197,8 +197,8 @@ declare type BatchId = number;
197
197
  */
198
198
  declare class Bound {
199
199
  readonly position: Value[];
200
- readonly before: boolean;
201
- constructor(position: Value[], before: boolean);
200
+ readonly inclusive: boolean;
201
+ constructor(position: Value[], inclusive: boolean);
202
202
  }
203
203
 
204
204
  /**
@@ -967,8 +967,7 @@ export declare class DocumentSnapshot<T = DocumentData> extends DocumentSnapshot
967
967
  /** @hideconstructor protected */
968
968
  constructor(_firestore: Firestore, userDataWriter: AbstractUserDataWriter, key: _DocumentKey, document: Document_2 | null, metadata: SnapshotMetadata, converter: UntypedFirestoreDataConverter<T> | null);
969
969
  /**
970
- * Property of the `DocumentSnapshot` that signals whether or not the data
971
- * exists. True if the document exists.
970
+ * Returns whether or not the data exists. True if the document exists.
972
971
  */
973
972
  exists(): this is QueryDocumentSnapshot<T>;
974
973
  /**
@@ -1192,6 +1191,45 @@ declare interface EventManager {
1192
1191
 
1193
1192
  declare type FieldFilterOp = 'OPERATOR_UNSPECIFIED' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUAL' | 'EQUAL' | 'NOT_EQUAL' | 'ARRAY_CONTAINS' | 'IN' | 'ARRAY_CONTAINS_ANY' | 'NOT_IN';
1194
1193
 
1194
+ /**
1195
+ * An index definition for field indexes in Firestore.
1196
+ *
1197
+ * Every index is associated with a collection. The definition contains a list
1198
+ * of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
1199
+ * `CONTAINS` for ArrayContains/ArrayContainsAny queries).
1200
+ *
1201
+ * Unlike the backend, the SDK does not differentiate between collection or
1202
+ * collection group-scoped indices. Every index can be used for both single
1203
+ * collection and collection group queries.
1204
+ */
1205
+ declare class FieldIndex {
1206
+ /**
1207
+ * The index ID. Returns -1 if the index ID is not available (e.g. the index
1208
+ * has not yet been persisted).
1209
+ */
1210
+ readonly indexId: number;
1211
+ /** The collection ID this index applies to. */
1212
+ readonly collectionGroup: string;
1213
+ /** The field segments for this index. */
1214
+ readonly fields: IndexSegment[];
1215
+ /** Shows how up-to-date the index is for the current user. */
1216
+ readonly indexState: IndexState_2;
1217
+ /** An ID for an index that has not yet been added to persistence. */
1218
+ static UNKNOWN_ID: number;
1219
+ constructor(
1220
+ /**
1221
+ * The index ID. Returns -1 if the index ID is not available (e.g. the index
1222
+ * has not yet been persisted).
1223
+ */
1224
+ indexId: number,
1225
+ /** The collection ID this index applies to. */
1226
+ collectionGroup: string,
1227
+ /** The field segments for this index. */
1228
+ fields: IndexSegment[],
1229
+ /** Shows how up-to-date the index is for the current user. */
1230
+ indexState: IndexState_2);
1231
+ }
1232
+
1195
1233
  /**
1196
1234
  * Provides a set of fields that can be used to partially patch a document.
1197
1235
  * FieldMask is used in conjunction with ObjectValue.
@@ -2154,6 +2192,20 @@ export declare function increment(n: number): FieldValue;
2154
2192
 
2155
2193
  declare type IndexFieldMode = 'MODE_UNSPECIFIED' | 'ASCENDING' | 'DESCENDING';
2156
2194
 
2195
+ /** The type of the index, e.g. for which type of query it can be used. */
2196
+ declare const enum IndexKind {
2197
+ /**
2198
+ * Ordered index. Can be used for <, <=, ==, >=, >, !=, IN and NOT IN queries.
2199
+ */
2200
+ ASCENDING = 0,
2201
+ /**
2202
+ * Ordered index. Can be used for <, <=, ==, >=, >, !=, IN and NOT IN queries.
2203
+ */
2204
+ DESCENDING = 1,
2205
+ /** Contains index. Can be used for ArrayContains and ArrayContainsAny. */
2206
+ CONTAINS = 2
2207
+ }
2208
+
2157
2209
  /**
2158
2210
  * Represents a set of indexes that are used to execute queries efficiently.
2159
2211
  *
@@ -2177,10 +2229,125 @@ declare interface IndexManager {
2177
2229
  * path for a root-level collection).
2178
2230
  */
2179
2231
  getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<_ResourcePath[]>;
2232
+ /**
2233
+ * Adds a field path index.
2234
+ *
2235
+ * Values for this index are persisted via the index backfill, which runs
2236
+ * asynchronously in the background. Once the first values are written,
2237
+ * an index can be used to serve partial results for any matching queries.
2238
+ * Any unindexed portion of the database will continue to be served via
2239
+ * collection scons.
2240
+ */
2241
+ addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
2242
+ /** Removes the given field index and deletes all index values. */
2243
+ deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
2244
+ /**
2245
+ * Returns a list of field indexes that correspond to the specified collection
2246
+ * group.
2247
+ *
2248
+ * @param collectionGroup The collection group to get matching field indexes
2249
+ * for.
2250
+ * @return A collection of field indexes for the specified collection group.
2251
+ */
2252
+ getFieldIndexes(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<FieldIndex[]>;
2253
+ /** Returns all configured field indexes. */
2254
+ getFieldIndexes(transaction: PersistenceTransaction): PersistencePromise<FieldIndex[]>;
2255
+ /**
2256
+ * Returns an index that can be used to serve the provided target. Returns
2257
+ * `null` if no index is configured.
2258
+ */
2259
+ getFieldIndex(transaction: PersistenceTransaction, target: Target): PersistencePromise<FieldIndex | null>;
2260
+ /**
2261
+ * Returns the documents that match the given target based on the provided
2262
+ * index.
2263
+ */
2264
+ getDocumentsMatchingTarget(transaction: PersistenceTransaction, fieldIndex: FieldIndex, target: Target): PersistencePromise<DocumentKeySet>;
2265
+ /**
2266
+ * Returns the next collection group to update. Returns `null` if no group
2267
+ * exists.
2268
+ */
2269
+ getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>;
2270
+ /**
2271
+ * Sets the collection group's latest read time.
2272
+ *
2273
+ * This method updates the index offset for all field indices for the
2274
+ * collection group and increments their sequence number. Subsequent calls to
2275
+ * `getNextCollectionGroupToUpdate()` will return a different collection group
2276
+ * (unless only one collection group is configured).
2277
+ */
2278
+ updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>;
2279
+ /** Updates the index entries for the provided documents. */
2280
+ updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>;
2281
+ }
2282
+
2283
+ /**
2284
+ * Stores the latest read time, document and batch ID that were processed for an
2285
+ * index.
2286
+ */
2287
+ declare class IndexOffset {
2288
+ /**
2289
+ * The latest read time version that has been indexed by Firestore for this
2290
+ * field index.
2291
+ */
2292
+ readonly readTime: SnapshotVersion;
2293
+ /**
2294
+ * The key of the last document that was indexed for this query. Use
2295
+ * `DocumentKey.empty()` if no document has been indexed.
2296
+ */
2297
+ readonly documentKey: _DocumentKey;
2298
+ readonly largestBatchId: number;
2299
+ constructor(
2300
+ /**
2301
+ * The latest read time version that has been indexed by Firestore for this
2302
+ * field index.
2303
+ */
2304
+ readTime: SnapshotVersion,
2305
+ /**
2306
+ * The key of the last document that was indexed for this query. Use
2307
+ * `DocumentKey.empty()` if no document has been indexed.
2308
+ */
2309
+ documentKey: _DocumentKey, largestBatchId: number);
2310
+ /** The state of an index that has not yet been backfilled. */
2311
+ static min(): IndexOffset;
2312
+ }
2313
+
2314
+ /** An index component consisting of field path and index type. */
2315
+ declare class IndexSegment {
2316
+ /** The field path of the component. */
2317
+ readonly fieldPath: _FieldPath;
2318
+ /** The fields sorting order. */
2319
+ readonly kind: IndexKind;
2320
+ constructor(
2321
+ /** The field path of the component. */
2322
+ fieldPath: _FieldPath,
2323
+ /** The fields sorting order. */
2324
+ kind: IndexKind);
2180
2325
  }
2181
2326
 
2182
2327
  declare type IndexState = 'STATE_UNSPECIFIED' | 'CREATING' | 'READY' | 'ERROR';
2183
2328
 
2329
+ /**
2330
+ * Stores the "high water mark" that indicates how updated the Index is for the
2331
+ * current user.
2332
+ */
2333
+ declare class IndexState_2 {
2334
+ /**
2335
+ * Indicates when the index was last updated (relative to other indexes).
2336
+ */
2337
+ readonly sequenceNumber: number;
2338
+ /** The the latest indexed read time, document and batch id. */
2339
+ readonly offset: IndexOffset;
2340
+ constructor(
2341
+ /**
2342
+ * Indicates when the index was last updated (relative to other indexes).
2343
+ */
2344
+ sequenceNumber: number,
2345
+ /** The the latest indexed read time, document and batch id. */
2346
+ offset: IndexOffset);
2347
+ /** The state of an index that has not yet been backfilled. */
2348
+ static empty(): IndexState_2;
2349
+ }
2350
+
2184
2351
  /**
2185
2352
  * Initializes a new instance of {@link Firestore} with the provided settings.
2186
2353
  * Can only be called before any other function, including
@@ -3293,7 +3460,7 @@ declare interface Persistence {
3293
3460
  * extent possible (e.g. in the case of uid switching from
3294
3461
  * sally=&gt;jack=&gt;sally, sally's mutation queue will be preserved).
3295
3462
  */
3296
- getMutationQueue(user: User): MutationQueue;
3463
+ getMutationQueue(user: User, indexManager: IndexManager): MutationQueue;
3297
3464
  /**
3298
3465
  * Returns a TargetCache representing the persisted cache of targets.
3299
3466
  *
@@ -3326,7 +3493,7 @@ declare interface Persistence {
3326
3493
  * this is called. In particular, the memory-backed implementation does this
3327
3494
  * to emulate the persisted implementation to the extent possible.
3328
3495
  */
3329
- getIndexManager(): IndexManager;
3496
+ getIndexManager(user: User): IndexManager;
3330
3497
  /**
3331
3498
  * Performs an operation inside a persistence transaction. Any reads or writes
3332
3499
  * against persistence must be performed within a transaction. Writes will be
@@ -3737,6 +3904,8 @@ declare type Rejector = (error: Error) => void;
3737
3904
  * documents that are known to not exist.
3738
3905
  */
3739
3906
  declare interface RemoteDocumentCache {
3907
+ /** Sets the index manager to use for managing the collectionGroup index. */
3908
+ setIndexManager(indexManager: IndexManager): void;
3740
3909
  /**
3741
3910
  * Looks up an entry in the cache.
3742
3911
  *
@@ -3754,19 +3923,14 @@ declare interface RemoteDocumentCache {
3754
3923
  */
3755
3924
  getEntries(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
3756
3925
  /**
3757
- * Executes a query against the cached Document entries.
3758
- *
3759
- * Implementations may return extra documents if convenient. The results
3760
- * should be re-filtered by the consumer before presenting them to the user.
3761
- *
3762
- * Cached NoDocument entries have no bearing on query results.
3926
+ * Returns the documents from the provided collection.
3763
3927
  *
3764
- * @param query - The query to match documents against.
3928
+ * @param collection - The collection to read.
3765
3929
  * @param sinceReadTime - If not set to SnapshotVersion.min(), return only
3766
3930
  * documents that have been read since this snapshot version (exclusive).
3767
3931
  * @returns The set of matching documents.
3768
3932
  */
3769
- getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query_2, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
3933
+ getAll(transaction: PersistenceTransaction, collection: _ResourcePath, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
3770
3934
  /**
3771
3935
  * Provides access to add or update the contents of the cache. The buffer
3772
3936
  * handles proper size accounting for the change.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase/firestore",
3
- "version": "3.4.4-canary.2dd99ae2d",
3
+ "version": "3.4.4-canary.50de44c2e",
4
4
  "engines": {
5
5
  "node": ">=10.10.0"
6
6
  },
@@ -77,22 +77,22 @@
77
77
  "lite/package.json"
78
78
  ],
79
79
  "dependencies": {
80
- "@firebase/component": "0.5.10-canary.2dd99ae2d",
81
- "@firebase/logger": "0.3.2-canary.2dd99ae2d",
82
- "@firebase/util": "1.4.3-canary.2dd99ae2d",
83
- "@firebase/webchannel-wrapper": "0.6.1-canary.2dd99ae2d",
80
+ "@firebase/component": "0.5.10-canary.50de44c2e",
81
+ "@firebase/logger": "0.3.2-canary.50de44c2e",
82
+ "@firebase/util": "1.4.3-canary.50de44c2e",
83
+ "@firebase/webchannel-wrapper": "0.6.1-canary.50de44c2e",
84
84
  "@grpc/grpc-js": "^1.3.2",
85
85
  "@grpc/proto-loader": "^0.6.0",
86
86
  "node-fetch": "2.6.7",
87
87
  "tslib": "^2.1.0"
88
88
  },
89
89
  "peerDependencies": {
90
- "@firebase/app": "0.7.15-canary.2dd99ae2d"
90
+ "@firebase/app": "0.7.16-canary.50de44c2e"
91
91
  },
92
92
  "devDependencies": {
93
- "@firebase/app": "0.7.15-canary.2dd99ae2d",
94
- "@firebase/app-compat": "0.1.16-canary.2dd99ae2d",
95
- "@firebase/auth": "0.19.7-canary.2dd99ae2d",
93
+ "@firebase/app": "0.7.16-canary.50de44c2e",
94
+ "@firebase/app-compat": "0.1.17-canary.50de44c2e",
95
+ "@firebase/auth": "0.19.8-canary.50de44c2e",
96
96
  "@rollup/plugin-alias": "3.1.5",
97
97
  "@rollup/plugin-json": "4.1.0",
98
98
  "@types/eslint": "7.28.0",