@firebase/firestore 3.4.5-canary.e987dac26 → 3.4.6-canary.69aa7b02d

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 (72) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/firestore/src/core/snapshot_version.d.ts +1 -0
  3. package/dist/firestore/src/local/indexeddb_mutation_batch_impl.d.ts +2 -1
  4. package/dist/firestore/src/local/indexeddb_schema.d.ts +16 -13
  5. package/dist/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  6. package/dist/firestore/src/local/indexeddb_schema_legacy.d.ts +29 -0
  7. package/dist/firestore/src/local/indexeddb_sentinels.d.ts +24 -11
  8. package/dist/firestore/src/local/local_documents_view.d.ts +3 -4
  9. package/dist/firestore/src/local/local_serializer.d.ts +2 -1
  10. package/dist/firestore/src/local/remote_document_cache.d.ts +13 -4
  11. package/dist/firestore/src/model/field_index.d.ts +8 -1
  12. package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -1
  13. package/dist/index.esm2017.js +3174 -3071
  14. package/dist/index.esm2017.js.map +1 -1
  15. package/dist/index.esm5.js +3766 -3636
  16. package/dist/index.esm5.js.map +1 -1
  17. package/dist/index.node.cjs.js +337 -133
  18. package/dist/index.node.cjs.js.map +1 -1
  19. package/dist/index.node.mjs +337 -133
  20. package/dist/index.node.mjs.map +1 -1
  21. package/dist/index.rn.js +3190 -3087
  22. package/dist/index.rn.js.map +1 -1
  23. package/dist/internal.d.ts +16 -4
  24. package/dist/lite/firestore/src/core/snapshot_version.d.ts +1 -0
  25. package/dist/lite/firestore/src/local/indexeddb_mutation_batch_impl.d.ts +2 -1
  26. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +16 -13
  27. package/dist/lite/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  28. package/dist/lite/firestore/src/local/indexeddb_schema_legacy.d.ts +29 -0
  29. package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +24 -11
  30. package/dist/lite/firestore/src/local/local_documents_view.d.ts +3 -4
  31. package/dist/lite/firestore/src/local/local_serializer.d.ts +2 -1
  32. package/dist/lite/firestore/src/local/remote_document_cache.d.ts +13 -4
  33. package/dist/lite/firestore/src/model/field_index.d.ts +8 -1
  34. package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -1
  35. package/dist/lite/index.browser.esm2017.js +75 -72
  36. package/dist/lite/index.browser.esm2017.js.map +1 -1
  37. package/dist/lite/index.browser.esm5.js +100 -98
  38. package/dist/lite/index.browser.esm5.js.map +1 -1
  39. package/dist/lite/index.node.cjs.js +5 -2
  40. package/dist/lite/index.node.cjs.js.map +1 -1
  41. package/dist/lite/index.node.mjs +5 -2
  42. package/dist/lite/index.node.mjs.map +1 -1
  43. package/dist/lite/index.rn.esm2017.js +5 -2
  44. package/dist/lite/index.rn.esm2017.js.map +1 -1
  45. package/dist/lite/internal.d.ts +1 -0
  46. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +18 -18
  47. package/dist/lite/packages/firestore/src/core/snapshot_version.d.ts +1 -0
  48. package/dist/lite/packages/firestore/src/local/indexeddb_mutation_batch_impl.d.ts +2 -1
  49. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +16 -13
  50. package/dist/lite/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  51. package/dist/lite/packages/firestore/src/local/indexeddb_schema_legacy.d.ts +29 -0
  52. package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +24 -11
  53. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +3 -4
  54. package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +2 -1
  55. package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +13 -4
  56. package/dist/lite/packages/firestore/src/model/field_index.d.ts +8 -1
  57. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -1
  58. package/dist/lite/private.d.ts +1 -0
  59. package/dist/packages/firestore/dist/index.esm2017.d.ts +174 -174
  60. package/dist/packages/firestore/src/core/snapshot_version.d.ts +1 -0
  61. package/dist/packages/firestore/src/local/indexeddb_mutation_batch_impl.d.ts +2 -1
  62. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +16 -13
  63. package/dist/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  64. package/dist/packages/firestore/src/local/indexeddb_schema_legacy.d.ts +29 -0
  65. package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +24 -11
  66. package/dist/packages/firestore/src/local/local_documents_view.d.ts +3 -4
  67. package/dist/packages/firestore/src/local/local_serializer.d.ts +2 -1
  68. package/dist/packages/firestore/src/local/remote_document_cache.d.ts +13 -4
  69. package/dist/packages/firestore/src/model/field_index.d.ts +8 -1
  70. package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +3 -1
  71. package/dist/private.d.ts +16 -4
  72. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @firebase/firestore
2
2
 
3
+ ## 3.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`2d672cead`](https://github.com/firebase/firebase-js-sdk/commit/2d672cead167187cb714cd89b638c0884ba58f03)]:
8
+ - @firebase/util@1.5.0
9
+ - @firebase/component@0.5.11
10
+
3
11
  ## 3.4.5
4
12
 
5
13
  ### Patch Changes
@@ -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;
@@ -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;
@@ -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,7 +79,22 @@ 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
+ /**
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.
96
+ */
97
+ export declare const DbRemoteDocumentKeyPath: string[];
83
98
  /**
84
99
  * An index that provides access to all entries sorted by read time (which
85
100
  * corresponds to the last modification time of each row).
@@ -88,15 +103,17 @@ export declare const DbRemoteDocumentStore = "remoteDocuments";
88
103
  */
89
104
  export declare const DbRemoteDocumentReadTimeIndex = "readTimeIndex";
90
105
  export declare const DbRemoteDocumentReadTimeIndexPath = "readTime";
106
+ /** An index that provides access to documents by key. */
107
+ export declare const DbRemoteDocumentDocumentKeyIndex = "documentKeyIndex";
108
+ export declare const DbRemoteDocumentDocumentKeyIndexPath: string[];
91
109
  /**
92
- * An index that provides access to documents in a collection sorted by read
110
+ * An index that provides access to documents by collection group and read
93
111
  * time.
94
112
  *
95
- * This index is used to allow the RemoteDocumentCache to fetch newly changed
96
- * documents in a collection.
113
+ * This index is used by the index backfiller.
97
114
  */
98
- export declare const DbRemoteDocumentCollectionReadTimeIndex = "collectionReadTimeIndex";
99
- export declare const DbRemoteDocumentCollectionReadTimeIndexPath: string[];
115
+ export declare const DbRemoteDocumentCollectionGroupIndex = "collectionGroupIndex";
116
+ export declare const DbRemoteDocumentCollectionGroupIndexPath: string[];
100
117
  export declare const DbRemoteDocumentGlobalStore = "remoteDocumentGlobal";
101
118
  export declare const DbRemoteDocumentGlobalKey = "remoteDocumentGlobalKey";
102
119
  export declare type DbRemoteDocumentGlobalKey = typeof DbRemoteDocumentGlobalKey;
@@ -223,6 +240,7 @@ export declare const V8_STORES: string[];
223
240
  export declare const V11_STORES: string[];
224
241
  export declare const V12_STORES: string[];
225
242
  export declare const V13_STORES: string[];
243
+ export declare const V14_STORES: string[];
226
244
  /**
227
245
  * The list of all default IndexedDB stores used throughout the SDK. This is
228
246
  * used when creating transactions so that access across all stores is done
@@ -231,8 +249,3 @@ export declare const V13_STORES: string[];
231
249
  export declare const ALL_STORES: string[];
232
250
  /** Returns the object stores for the provided schema. */
233
251
  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 */
@@ -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.
@@ -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;