@firebase/firestore 3.4.6 → 3.4.7-2022222232915

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 (107) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/firestore/src/core/bundle.d.ts +2 -2
  3. package/dist/firestore/src/core/bundle_impl.d.ts +2 -0
  4. package/dist/firestore/src/core/query.d.ts +7 -0
  5. package/dist/firestore/src/core/snapshot_version.d.ts +1 -0
  6. package/dist/firestore/src/core/sync_engine_impl.d.ts +1 -1
  7. package/dist/firestore/src/local/indexeddb_mutation_batch_impl.d.ts +2 -1
  8. package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +0 -17
  9. package/dist/firestore/src/local/indexeddb_schema.d.ts +16 -13
  10. package/dist/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  11. package/dist/firestore/src/local/indexeddb_schema_legacy.d.ts +29 -0
  12. package/dist/firestore/src/local/indexeddb_sentinels.d.ts +22 -17
  13. package/dist/firestore/src/local/local_documents_view.d.ts +3 -4
  14. package/dist/firestore/src/local/local_serializer.d.ts +2 -1
  15. package/dist/firestore/src/local/local_store_impl.d.ts +1 -7
  16. package/dist/firestore/src/local/remote_document_cache.d.ts +13 -4
  17. package/dist/firestore/src/local/shared_client_state.d.ts +6 -3
  18. package/dist/firestore/src/local/shared_client_state_schema.d.ts +1 -1
  19. package/dist/firestore/src/local/shared_client_state_syncer.d.ts +1 -1
  20. package/dist/firestore/src/model/field_index.d.ts +8 -1
  21. package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -1
  22. package/dist/index.esm2017.js +3206 -3134
  23. package/dist/index.esm2017.js.map +1 -1
  24. package/dist/index.esm5.js +3579 -3453
  25. package/dist/index.esm5.js.map +1 -1
  26. package/dist/index.node.cjs.js +403 -244
  27. package/dist/index.node.cjs.js.map +1 -1
  28. package/dist/index.node.mjs +403 -244
  29. package/dist/index.node.mjs.map +1 -1
  30. package/dist/index.rn.js +3160 -3088
  31. package/dist/index.rn.js.map +1 -1
  32. package/dist/internal.d.ts +19 -5
  33. package/dist/lite/firestore/src/core/bundle.d.ts +2 -2
  34. package/dist/lite/firestore/src/core/bundle_impl.d.ts +2 -0
  35. package/dist/lite/firestore/src/core/query.d.ts +7 -0
  36. package/dist/lite/firestore/src/core/snapshot_version.d.ts +1 -0
  37. package/dist/lite/firestore/src/core/sync_engine_impl.d.ts +1 -1
  38. package/dist/lite/firestore/src/local/indexeddb_mutation_batch_impl.d.ts +2 -1
  39. package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +0 -17
  40. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +16 -13
  41. package/dist/lite/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  42. package/dist/lite/firestore/src/local/indexeddb_schema_legacy.d.ts +29 -0
  43. package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +22 -17
  44. package/dist/lite/firestore/src/local/local_documents_view.d.ts +3 -4
  45. package/dist/lite/firestore/src/local/local_serializer.d.ts +2 -1
  46. package/dist/lite/firestore/src/local/local_store_impl.d.ts +1 -7
  47. package/dist/lite/firestore/src/local/remote_document_cache.d.ts +13 -4
  48. package/dist/lite/firestore/src/local/shared_client_state.d.ts +6 -3
  49. package/dist/lite/firestore/src/local/shared_client_state_schema.d.ts +1 -1
  50. package/dist/lite/firestore/src/local/shared_client_state_syncer.d.ts +1 -1
  51. package/dist/lite/firestore/src/model/field_index.d.ts +8 -1
  52. package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -1
  53. package/dist/lite/index.browser.esm2017.js +5 -2
  54. package/dist/lite/index.browser.esm2017.js.map +1 -1
  55. package/dist/lite/index.browser.esm5.js +94 -92
  56. package/dist/lite/index.browser.esm5.js.map +1 -1
  57. package/dist/lite/index.node.cjs.js +5 -2
  58. package/dist/lite/index.node.cjs.js.map +1 -1
  59. package/dist/lite/index.node.mjs +5 -2
  60. package/dist/lite/index.node.mjs.map +1 -1
  61. package/dist/lite/index.rn.esm2017.js +5 -2
  62. package/dist/lite/index.rn.esm2017.js.map +1 -1
  63. package/dist/lite/internal.d.ts +1 -0
  64. package/dist/lite/packages/firestore/src/core/bundle.d.ts +2 -2
  65. package/dist/lite/packages/firestore/src/core/bundle_impl.d.ts +2 -0
  66. package/dist/lite/packages/firestore/src/core/query.d.ts +7 -0
  67. package/dist/lite/packages/firestore/src/core/snapshot_version.d.ts +1 -0
  68. package/dist/lite/packages/firestore/src/core/sync_engine_impl.d.ts +1 -1
  69. package/dist/lite/packages/firestore/src/local/indexeddb_mutation_batch_impl.d.ts +2 -1
  70. package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +0 -17
  71. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +16 -13
  72. package/dist/lite/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  73. package/dist/lite/packages/firestore/src/local/indexeddb_schema_legacy.d.ts +29 -0
  74. package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +22 -17
  75. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +3 -4
  76. package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +2 -1
  77. package/dist/lite/packages/firestore/src/local/local_store_impl.d.ts +1 -7
  78. package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +13 -4
  79. package/dist/lite/packages/firestore/src/local/shared_client_state.d.ts +6 -3
  80. package/dist/lite/packages/firestore/src/local/shared_client_state_schema.d.ts +1 -1
  81. package/dist/lite/packages/firestore/src/local/shared_client_state_syncer.d.ts +1 -1
  82. package/dist/lite/packages/firestore/src/model/field_index.d.ts +8 -1
  83. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -1
  84. package/dist/lite/private.d.ts +1 -0
  85. package/dist/packages/firestore/dist/index.esm2017.d.ts +178 -178
  86. package/dist/packages/firestore/src/core/bundle.d.ts +2 -2
  87. package/dist/packages/firestore/src/core/bundle_impl.d.ts +2 -0
  88. package/dist/packages/firestore/src/core/query.d.ts +7 -0
  89. package/dist/packages/firestore/src/core/snapshot_version.d.ts +1 -0
  90. package/dist/packages/firestore/src/core/sync_engine_impl.d.ts +1 -1
  91. package/dist/packages/firestore/src/local/indexeddb_mutation_batch_impl.d.ts +2 -1
  92. package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +0 -17
  93. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +16 -13
  94. package/dist/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  95. package/dist/packages/firestore/src/local/indexeddb_schema_legacy.d.ts +29 -0
  96. package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +22 -17
  97. package/dist/packages/firestore/src/local/local_documents_view.d.ts +3 -4
  98. package/dist/packages/firestore/src/local/local_serializer.d.ts +2 -1
  99. package/dist/packages/firestore/src/local/local_store_impl.d.ts +1 -7
  100. package/dist/packages/firestore/src/local/remote_document_cache.d.ts +13 -4
  101. package/dist/packages/firestore/src/local/shared_client_state.d.ts +6 -3
  102. package/dist/packages/firestore/src/local/shared_client_state_schema.d.ts +1 -1
  103. package/dist/packages/firestore/src/local/shared_client_state_syncer.d.ts +1 -1
  104. package/dist/packages/firestore/src/model/field_index.d.ts +8 -1
  105. package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -1
  106. package/dist/private.d.ts +19 -5
  107. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @firebase/firestore
2
2
 
3
+ ## 3.4.7-2022222232915
4
+
5
+ ### Patch Changes
6
+
7
+ - [`69aa7b02d`](https://github.com/firebase/firebase-js-sdk/commit/69aa7b02df3b4d1f9832b7713951936b6bf32ca9) [#5988](https://github.com/firebase/firebase-js-sdk/pull/5988) - The format of some of the IndexedDB data changed. This increases the performance of document lookups after an initial migration. If you do not want to migrate data, you can call `clearIndexedDbPersistence()` before invoking `enableIndexedDbPersistence()`.
8
+
9
+ - Updated dependencies [[`3198d58dc`](https://github.com/firebase/firebase-js-sdk/commit/3198d58dcedbf7583914dbcc76984f6f7df8d2ef)]:
10
+ - @firebase/util@1.5.1-2022222232915
11
+ - @firebase/app@0.7.20-2022222232915
12
+ - @firebase/component@0.5.12-2022222232915
13
+
3
14
  ## 3.4.6
4
15
 
5
16
  ### Patch Changes
@@ -34,10 +34,10 @@ export interface BundledDocument {
34
34
  * An array of `BundledDocument`.
35
35
  */
36
36
  export declare type BundledDocuments = BundledDocument[];
37
- export declare class BundleLoadResult {
37
+ export interface BundleLoadResult {
38
38
  readonly progress: LoadBundleTaskProgress;
39
+ readonly changedCollectionGroups: Set<string>;
39
40
  readonly changedDocs: DocumentMap;
40
- constructor(progress: LoadBundleTaskProgress, changedDocs: DocumentMap);
41
41
  }
42
42
  /**
43
43
  * Represents a Firestore bundle saved by the SDK in its local storage.
@@ -51,6 +51,8 @@ export declare class BundleLoader {
51
51
  private queries;
52
52
  /** Batched documents to be saved into storage */
53
53
  private documents;
54
+ /** The collection groups affected by this bundle. */
55
+ private collectionGroups;
54
56
  constructor(bundleMetadata: ProtoBundleMetadata, localStore: LocalStore, serializer: JsonProtoSerializer);
55
57
  /**
56
58
  * Adds an element from the bundle to the loader.
@@ -121,6 +121,13 @@ export declare function canonifyQuery(query: Query): string;
121
121
  export declare function stringifyQuery(query: Query): string;
122
122
  /** Returns whether `doc` matches the constraints of `query`. */
123
123
  export declare function queryMatches(query: Query, doc: Document): boolean;
124
+ /**
125
+ * Returns the collection group that this query targets.
126
+ *
127
+ * PORTING NOTE: This is only used in the Web SDK to facilitate multi-tab
128
+ * synchronization for query results.
129
+ */
130
+ export declare function queryCollectionGroup(query: Query): string;
124
131
  /**
125
132
  * Returns a new comparator function that can be used to compare two documents
126
133
  * based on the Query's ordering constraint.
@@ -23,6 +23,7 @@ export declare class SnapshotVersion {
23
23
  private timestamp;
24
24
  static fromTimestamp(value: Timestamp): SnapshotVersion;
25
25
  static min(): SnapshotVersion;
26
+ static max(): SnapshotVersion;
26
27
  private constructor();
27
28
  compareTo(other: SnapshotVersion): number;
28
29
  isEqual(other: SnapshotVersion): boolean;
@@ -227,7 +227,7 @@ export declare function syncEngineGetRemoteKeysForTarget(syncEngine: SyncEngine,
227
227
  * Retrieves newly changed documents from remote document cache and raises
228
228
  * snapshots if needed.
229
229
  */
230
- export declare function syncEngineSynchronizeWithChangedDocuments(syncEngine: SyncEngine): Promise<void>;
230
+ export declare function syncEngineSynchronizeWithChangedDocuments(syncEngine: SyncEngine, collectionGroup: string): Promise<void>;
231
231
  /** Applies a mutation state to an existing batch. */
232
232
  export declare function syncEngineApplyBatchState(syncEngine: SyncEngine, batchId: BatchId, batchState: MutationBatchState, error?: FirestoreError): Promise<void>;
233
233
  /** Applies a query target change from a different tab. */
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { DocumentKey } from '../model/document_key';
18
18
  import { DbRemoteDocument } from './indexeddb_schema';
19
+ import { DbRemoteDocument as DbRemoteDocumentLegacy } from './indexeddb_schema_legacy';
19
20
  import { PersistencePromise } from './persistence_promise';
20
21
  import { SimpleDbTransaction } from './simple_db';
21
22
  /**
@@ -31,4 +32,4 @@ export declare function removeMutationBatch(txn: SimpleDbTransaction, userId: st
31
32
  /**
32
33
  * Returns an approximate size for the given document.
33
34
  */
34
- export declare function dbDocumentSize(doc: DbRemoteDocument | null): number;
35
+ export declare function dbDocumentSize(doc: DbRemoteDocument | DbRemoteDocumentLegacy | null): number;
@@ -14,12 +14,8 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { SnapshotVersion } from '../core/snapshot_version';
18
- import { MutableDocumentMap } from '../model/collections';
19
17
  import { MutableDocument } from '../model/document';
20
18
  import { LocalSerializer } from './local_serializer';
21
- import { PersistencePromise } from './persistence_promise';
22
- import { PersistenceTransaction } from './persistence_transaction';
23
19
  import { RemoteDocumentCache } from './remote_document_cache';
24
20
  export interface DocumentSizeEntry {
25
21
  document: MutableDocument;
@@ -29,16 +25,3 @@ export interface IndexedDbRemoteDocumentCache extends RemoteDocumentCache {
29
25
  }
30
26
  /** Creates a new IndexedDbRemoteDocumentCache. */
31
27
  export declare function newIndexedDbRemoteDocumentCache(serializer: LocalSerializer): IndexedDbRemoteDocumentCache;
32
- /**
33
- * Returns the set of documents that have changed since the specified read
34
- * time.
35
- */
36
- export declare function remoteDocumentCacheGetNewDocumentChanges(remoteDocumentCache: IndexedDbRemoteDocumentCache, transaction: PersistenceTransaction, sinceReadTime: SnapshotVersion): PersistencePromise<{
37
- changedDocs: MutableDocumentMap;
38
- readTime: SnapshotVersion;
39
- }>;
40
- /**
41
- * Returns the read time of the most recently read document in the cache, or
42
- * SnapshotVersion.min() if not available.
43
- */
44
- export declare function remoteDocumentCacheGetLastReadTime(transaction: PersistenceTransaction): PersistencePromise<SnapshotVersion>;
@@ -20,7 +20,7 @@ import { BundledQuery } from '../protos/firestore_bundle_proto';
20
20
  import { Document as ProtoDocument, DocumentsTarget as ProtoDocumentsTarget, QueryTarget as ProtoQueryTarget, Write as ProtoWrite } from '../protos/firestore_proto_api';
21
21
  import { EncodedResourcePath } from './encoded_resource_path';
22
22
  import { DbTimestampKey } from './indexeddb_sentinels';
23
- export declare const INDEXING_SCHEMA_VERSION = 13;
23
+ export declare const INDEXING_SCHEMA_VERSION = 14;
24
24
  /**
25
25
  * Schema Version for the Web client:
26
26
  * 1. Initial version including Mutation Queue, Query Cache, and Remote
@@ -40,7 +40,9 @@ export declare const INDEXING_SCHEMA_VERSION = 13;
40
40
  * 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
41
41
  * 11. Add bundles and named_queries for bundle support.
42
42
  * 12. Add document overlays.
43
- * 13. Add indexing support.
43
+ * 13. Rewrite the keys of the remote document cache to allow for efficient
44
+ * document lookup via `getAll()`.
45
+ * 14. Add indexing support.
44
46
  */
45
47
  export declare const SCHEMA_VERSION: number;
46
48
  /**
@@ -174,10 +176,21 @@ export interface DbUnknownDocument {
174
176
  * - An "unknown document" representing a document that is known to exist (at
175
177
  * some version) but whose contents are unknown.
176
178
  *
179
+ * The document key is split up across `prefixPath`, `collectionGroup` and
180
+ * `documentId`.
181
+ *
177
182
  * Note: This is the persisted equivalent of a MaybeDocument and could perhaps
178
183
  * be made more general if necessary.
179
184
  */
180
185
  export interface DbRemoteDocument {
186
+ /** The path to the document's collection (excluding). */
187
+ prefixPath: string[];
188
+ /** The collection ID the document is direclty nested under. */
189
+ collectionGroup: string;
190
+ /** The document ID. */
191
+ documentId: string;
192
+ /** When the document was read from the backend. */
193
+ readTime: DbTimestampKey;
181
194
  /**
182
195
  * Set to an instance of DbUnknownDocument if the data for a document is
183
196
  * not known, but it is known that a document exists at the specified
@@ -200,17 +213,7 @@ export interface DbRemoteDocument {
200
213
  * documents are potentially inconsistent with the backend's copy and use
201
214
  * the write's commit version as their document version.
202
215
  */
203
- hasCommittedMutations?: boolean;
204
- /**
205
- * When the document was read from the backend. Undefined for data written
206
- * prior to schema version 9.
207
- */
208
- readTime?: DbTimestampKey;
209
- /**
210
- * The path of the collection this document is part of. Undefined for data
211
- * written prior to schema version 9.
212
- */
213
- parentPath?: string[];
216
+ hasCommittedMutations: boolean;
214
217
  }
215
218
  /**
216
219
  * Contains a single entry that has metadata about the remote document cache.
@@ -38,4 +38,5 @@ export declare class SchemaConverter implements SimpleDbSchemaConverter {
38
38
  private ensureSequenceNumbers;
39
39
  private createCollectionParentIndex;
40
40
  private rewriteCanonicalIds;
41
+ private rewriteRemoteDocumentCache;
41
42
  }
@@ -0,0 +1,29 @@
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 { Document as ProtoDocument } from '../protos/firestore_proto_api';
18
+ import { DbNoDocument, DbUnknownDocument } from './indexeddb_schema';
19
+ import { DbTimestampKey } from './indexeddb_sentinels';
20
+ export interface DbRemoteDocument {
21
+ unknownDocument?: DbUnknownDocument;
22
+ noDocument?: DbNoDocument;
23
+ document?: ProtoDocument;
24
+ hasCommittedMutations?: boolean;
25
+ readTime?: DbTimestampKey;
26
+ parentPath?: string[];
27
+ }
28
+ export declare type DbRemoteDocumentKey = string[];
29
+ export declare const DbRemoteDocumentStore = "remoteDocuments";
@@ -79,24 +79,33 @@ export declare function newDbDocumentMutationKey(userId: string, path: ResourceP
79
79
  */
80
80
  export declare const DbDocumentMutationPlaceholder: DbDocumentMutation;
81
81
  export declare const DbDocumentMutationStore = "documentMutations";
82
- export declare const DbRemoteDocumentStore = "remoteDocuments";
82
+ export declare const DbRemoteDocumentStore = "remoteDocumentsV14";
83
83
  /**
84
- * An index that provides access to all entries sorted by read time (which
85
- * corresponds to the last modification time of each row).
86
- *
87
- * This index is used to provide a changelog for Multi-Tab.
84
+ * A key in the 'remoteDocumentsV14' object store is an array containing the
85
+ * collection path, the collection group, the read time and the document id.
86
+ */
87
+ export declare type DbRemoteDocumentKey = [
88
+ /** path to collection */ string[],
89
+ /** collection group */ string,
90
+ /** read time */ DbTimestampKey,
91
+ /** document ID */ string
92
+ ];
93
+ /**
94
+ * The primary key of the remote documents store, which allows for efficient
95
+ * access by collection path and read time.
88
96
  */
89
- export declare const DbRemoteDocumentReadTimeIndex = "readTimeIndex";
90
- export declare const DbRemoteDocumentReadTimeIndexPath = "readTime";
97
+ export declare const DbRemoteDocumentKeyPath: string[];
98
+ /** An index that provides access to documents by key. */
99
+ export declare const DbRemoteDocumentDocumentKeyIndex = "documentKeyIndex";
100
+ export declare const DbRemoteDocumentDocumentKeyIndexPath: string[];
91
101
  /**
92
- * An index that provides access to documents in a collection sorted by read
102
+ * An index that provides access to documents by collection group and read
93
103
  * time.
94
104
  *
95
- * This index is used to allow the RemoteDocumentCache to fetch newly changed
96
- * documents in a collection.
105
+ * This index is used by the index backfiller.
97
106
  */
98
- export declare const DbRemoteDocumentCollectionReadTimeIndex = "collectionReadTimeIndex";
99
- export declare const DbRemoteDocumentCollectionReadTimeIndexPath: string[];
107
+ export declare const DbRemoteDocumentCollectionGroupIndex = "collectionGroupIndex";
108
+ export declare const DbRemoteDocumentCollectionGroupIndexPath: string[];
100
109
  export declare const DbRemoteDocumentGlobalStore = "remoteDocumentGlobal";
101
110
  export declare const DbRemoteDocumentGlobalKey = "remoteDocumentGlobalKey";
102
111
  export declare type DbRemoteDocumentGlobalKey = typeof DbRemoteDocumentGlobalKey;
@@ -223,6 +232,7 @@ export declare const V8_STORES: string[];
223
232
  export declare const V11_STORES: string[];
224
233
  export declare const V12_STORES: string[];
225
234
  export declare const V13_STORES: string[];
235
+ export declare const V14_STORES: string[];
226
236
  /**
227
237
  * The list of all default IndexedDB stores used throughout the SDK. This is
228
238
  * used when creating transactions so that access across all stores is done
@@ -231,8 +241,3 @@ export declare const V13_STORES: string[];
231
241
  export declare const ALL_STORES: string[];
232
242
  /** Returns the object stores for the provided schema. */
233
243
  export declare function getObjectStores(schemaVersion: number): string[];
234
- /**
235
- * A key in the 'remoteDocuments' object store is a string array containing the
236
- * segments that make up the path.
237
- */
238
- export declare type DbRemoteDocumentKey = string[];
@@ -15,10 +15,10 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { Query } from '../core/query';
18
- import { SnapshotVersion } from '../core/snapshot_version';
19
18
  import { DocumentKeySet, DocumentMap, MutableDocumentMap } from '../model/collections';
20
19
  import { Document } from '../model/document';
21
20
  import { DocumentKey } from '../model/document_key';
21
+ import { IndexOffset } from '../model/field_index';
22
22
  import { IndexManager } from './index_manager';
23
23
  import { MutationQueue } from './mutation_queue';
24
24
  import { PersistencePromise } from './persistence_promise';
@@ -62,10 +62,9 @@ export declare class LocalDocumentsView {
62
62
  *
63
63
  * @param transaction - The persistence transaction.
64
64
  * @param query - The query to match documents against.
65
- * @param sinceReadTime - If not set to SnapshotVersion.min(), return only
66
- * documents that have been read since this snapshot version (exclusive).
65
+ * @param offset - Read time and key to start scanning by (exclusive).
67
66
  */
68
- getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, sinceReadTime: SnapshotVersion): PersistencePromise<DocumentMap>;
67
+ getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query, offset: IndexOffset): PersistencePromise<DocumentMap>;
69
68
  private getDocumentsMatchingDocumentQuery;
70
69
  private getDocumentsMatchingCollectionGroupQuery;
71
70
  private getDocumentsMatchingCollectionQuery;
@@ -25,7 +25,7 @@ import { MutationBatch } from '../model/mutation_batch';
25
25
  import { Overlay } from '../model/overlay';
26
26
  import { BundledQuery as ProtoBundledQuery, BundleMetadata as ProtoBundleMetadata, NamedQuery as ProtoNamedQuery } from '../protos/firestore_bundle_proto';
27
27
  import { JsonProtoSerializer } from '../remote/serializer';
28
- import { DbBundle, DbDocumentOverlay, DbIndexConfiguration, DbIndexState, DbMutationBatch, DbNamedQuery, DbRemoteDocument, DbTarget } from './indexeddb_schema';
28
+ import { DbBundle, DbDocumentOverlay, DbIndexConfiguration, DbIndexState, DbMutationBatch, DbNamedQuery, DbRemoteDocument, DbTarget, DbTimestamp } from './indexeddb_schema';
29
29
  import { DbDocumentOverlayKey, DbTimestampKey } from './indexeddb_sentinels';
30
30
  import { TargetData } from './target_data';
31
31
  /** Serializer for values stored in the LocalStore. */
@@ -39,6 +39,7 @@ export declare function fromDbRemoteDocument(localSerializer: LocalSerializer, r
39
39
  export declare function toDbRemoteDocument(localSerializer: LocalSerializer, document: MutableDocument): DbRemoteDocument;
40
40
  export declare function toDbTimestampKey(snapshotVersion: SnapshotVersion): DbTimestampKey;
41
41
  export declare function fromDbTimestampKey(dbTimestampKey: DbTimestampKey): SnapshotVersion;
42
+ export declare function toDbTimestamp(snapshotVersion: SnapshotVersion): DbTimestamp;
42
43
  /** Encodes a batch of mutations into a DbMutationBatch for local storage. */
43
44
  export declare function toDbMutationBatch(localSerializer: LocalSerializer, userId: string, batch: MutationBatch): DbMutationBatch;
44
45
  /** Decodes a DbMutationBatch into a MutationBatch */
@@ -165,13 +165,7 @@ export declare function localStoreGetCachedTarget(localStore: LocalStore, target
165
165
  * initialization. Further invocations will return document that have changed
166
166
  * since the prior call.
167
167
  */
168
- export declare function localStoreGetNewDocumentChanges(localStore: LocalStore): Promise<DocumentMap>;
169
- /**
170
- * Reads the newest document change from persistence and moves the internal
171
- * synchronization marker forward so that calls to `getNewDocumentChanges()`
172
- * only return changes that happened after client initialization.
173
- */
174
- export declare function localStoreSynchronizeLastDocumentChangeReadTime(localStore: LocalStore): Promise<void>;
168
+ export declare function localStoreGetNewDocumentChanges(localStore: LocalStore, collectionGroup: string): Promise<DocumentMap>;
175
169
  /**
176
170
  * Applies the documents from a bundle to the "ground-state" (remote)
177
171
  * documents.
@@ -14,10 +14,10 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { SnapshotVersion } from '../core/snapshot_version';
18
17
  import { DocumentKeySet, MutableDocumentMap } from '../model/collections';
19
18
  import { MutableDocument } from '../model/document';
20
19
  import { DocumentKey } from '../model/document_key';
20
+ import { IndexOffset } from '../model/field_index';
21
21
  import { ResourcePath } from '../model/path';
22
22
  import { IndexManager } from './index_manager';
23
23
  import { PersistencePromise } from './persistence_promise';
@@ -53,11 +53,20 @@ export interface RemoteDocumentCache {
53
53
  * Returns the documents from the provided collection.
54
54
  *
55
55
  * @param collection - The collection to read.
56
- * @param sinceReadTime - If not set to SnapshotVersion.min(), return only
57
- * documents that have been read since this snapshot version (exclusive).
56
+ * @param offset - The offset to start the scan at (exclusive).
58
57
  * @returns The set of matching documents.
59
58
  */
60
- getAll(transaction: PersistenceTransaction, collection: ResourcePath, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
59
+ getAllFromCollection(transaction: PersistenceTransaction, collection: ResourcePath, offset: IndexOffset): PersistencePromise<MutableDocumentMap>;
60
+ /**
61
+ * Looks up the next `limit` documents for a collection group based on the
62
+ * provided offset. The ordering is based on the document's read time and key.
63
+ *
64
+ * @param collectionGroup - The collection group to scan.
65
+ * @param offset - The offset to start the scan at (exclusive).
66
+ * @param limit - The maximum number of results to return.
67
+ * @returns The set of matching documents.
68
+ */
69
+ getAllFromCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset, limit: number): PersistencePromise<MutableDocumentMap>;
61
70
  /**
62
71
  * Provides access to add or update the contents of the cache. The buffer
63
72
  * handles proper size accounting for the change.
@@ -113,8 +113,10 @@ export interface SharedClientState {
113
113
  /**
114
114
  * Notifies other clients when remote documents have changed due to loading
115
115
  * a bundle.
116
+ *
117
+ * @param collectionGroups The collection groups affected by this bundle.
116
118
  */
117
- notifyBundleLoaded(): void;
119
+ notifyBundleLoaded(collectionGroups: Set<string>): void;
118
120
  }
119
121
  /**
120
122
  * Holds the state of a mutation batch, including its user ID, batch ID and
@@ -237,7 +239,7 @@ export declare class WebStorageSharedClientState implements SharedClientState {
237
239
  updateQueryState(targetId: TargetId, state: QueryTargetState, error?: FirestoreError): void;
238
240
  handleUserChange(user: User, removedBatchIds: BatchId[], addedBatchIds: BatchId[]): void;
239
241
  setOnlineState(onlineState: OnlineState): void;
240
- notifyBundleLoaded(): void;
242
+ notifyBundleLoaded(collectionGroups: Set<string>): void;
241
243
  shutdown(): void;
242
244
  private getItem;
243
245
  private setItem;
@@ -275,6 +277,7 @@ export declare class WebStorageSharedClientState implements SharedClientState {
275
277
  * could not be parsed.
276
278
  */
277
279
  private fromWebStorageOnlineState;
280
+ private fromWebStoreBundleLoadedState;
278
281
  private handleMutationBatchEvent;
279
282
  private handleQueryTargetEvent;
280
283
  private handleClientStateEvent;
@@ -305,5 +308,5 @@ export declare class MemorySharedClientState implements SharedClientState {
305
308
  setOnlineState(onlineState: OnlineState): void;
306
309
  shutdown(): void;
307
310
  writeSequenceNumber(sequenceNumber: ListenSequenceNumber): void;
308
- notifyBundleLoaded(): void;
311
+ notifyBundleLoaded(collectionGroups: Set<string>): void;
309
312
  }
@@ -64,7 +64,7 @@ export interface QueryTargetStateSchema {
64
64
  export declare const ONLINE_STATE_KEY_PREFIX = "firestore_online_state";
65
65
  /** Assembles the key for the online state of the primary tab. */
66
66
  export declare function createWebStorageOnlineStateKey(persistenceKey: string): string;
67
- export declare const BUNDLE_LOADED_KEY_PREFIX = "firestore_bundle_loaded";
67
+ export declare const BUNDLE_LOADED_KEY_PREFIX = "firestore_bundle_loaded_v2";
68
68
  export declare function createBundleLoadedKey(persistenceKey: string): string;
69
69
  /**
70
70
  * The JSON representation of the system's online state, as written by the
@@ -36,5 +36,5 @@ export interface SharedClientStateSyncer {
36
36
  * Retrieves newly changed documents from remote document cache and raises
37
37
  * snapshots if needed.
38
38
  */
39
- synchronizeWithChangedDocuments(): Promise<void>;
39
+ synchronizeWithChangedDocuments(collectionGroup: string): Promise<void>;
40
40
  }
@@ -18,6 +18,11 @@ import { SnapshotVersion } from '../core/snapshot_version';
18
18
  import { Document } from './document';
19
19
  import { DocumentKey } from './document_key';
20
20
  import { FieldPath } from './path';
21
+ /**
22
+ * The initial mutation batch id for each index. Gets updated during index
23
+ * backfill.
24
+ */
25
+ export declare const INITIAL_LARGEST_BATCH_ID = -1;
21
26
  /**
22
27
  * The initial sequence number for each index. Gets updated during index
23
28
  * backfill.
@@ -152,7 +157,9 @@ export declare class IndexOffset {
152
157
  * `DocumentKey.empty()` if no document has been indexed.
153
158
  */
154
159
  documentKey: DocumentKey, largestBatchId: number);
155
- /** The state of an index that has not yet been backfilled. */
160
+ /** Returns an offset that sorts before all regular offsets. */
156
161
  static min(): IndexOffset;
162
+ /** Returns an offset that sorts after all regular offsets. */
163
+ static max(): IndexOffset;
157
164
  }
158
165
  export declare function indexOffsetComparator(left: IndexOffset, right: IndexOffset): number;
@@ -21,6 +21,7 @@ import { RemoteDocumentChangeBuffer } from '../../../src/local/remote_document_c
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 { IndexOffset } from '../../../src/model/field_index';
24
25
  import { ResourcePath } from '../../../src/model/path';
25
26
  /**
26
27
  * A wrapper around a RemoteDocumentCache that automatically creates a
@@ -44,7 +45,8 @@ export declare class TestRemoteDocumentCache {
44
45
  removeEntry(documentKey: DocumentKey, version?: SnapshotVersion): Promise<void>;
45
46
  getEntry(documentKey: DocumentKey): Promise<MutableDocument>;
46
47
  getEntries(documentKeys: DocumentKeySet): Promise<MutableDocumentMap>;
47
- getAll(collection: ResourcePath, sinceReadTime: SnapshotVersion): Promise<MutableDocumentMap>;
48
+ getAllFromCollection(collection: ResourcePath, offset: IndexOffset): Promise<MutableDocumentMap>;
49
+ getAllFromCollectionGroup(collectionGroup: string, offset: IndexOffset, limit: number): Promise<MutableDocumentMap>;
48
50
  getNewDocumentChanges(sinceReadTime: SnapshotVersion): Promise<{
49
51
  changedDocs: MutableDocumentMap;
50
52
  readTime: SnapshotVersion;