@firebase/firestore 3.4.9-canary.aa44d529e → 3.4.9-canary.abcab980c

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 (145) hide show
  1. package/dist/firestore/src/api/transaction.d.ts +2 -0
  2. package/dist/firestore/src/core/component_provider.d.ts +11 -6
  3. package/dist/firestore/src/lite-api/transaction.d.ts +2 -0
  4. package/dist/firestore/src/local/document_overlay_cache.d.ts +5 -0
  5. package/dist/firestore/src/local/index_backfiller.d.ts +44 -0
  6. package/dist/firestore/src/local/index_manager.d.ts +2 -0
  7. package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
  8. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  9. package/dist/firestore/src/local/indexeddb_schema.d.ts +3 -2
  10. package/dist/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  11. package/dist/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
  12. package/dist/firestore/src/local/local_documents_view.d.ts +64 -9
  13. package/dist/firestore/src/local/local_store.d.ts +9 -0
  14. package/dist/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  15. package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
  16. package/dist/firestore/src/local/memory_index_manager.d.ts +1 -0
  17. package/dist/firestore/src/local/overlayed_document.d.ts +36 -0
  18. package/dist/firestore/src/local/persistence.d.ts +3 -5
  19. package/dist/firestore/src/local/persistence_promise.d.ts +11 -0
  20. package/dist/firestore/src/local/query_engine.d.ts +1 -1
  21. package/dist/firestore/src/model/collections.d.ts +8 -2
  22. package/dist/firestore/src/model/field_mask.d.ts +6 -0
  23. package/dist/firestore/src/model/mutation.d.ts +19 -1
  24. package/dist/firestore/src/model/mutation_batch.d.ts +8 -4
  25. package/dist/firestore/src/util/async_queue.d.ts +5 -1
  26. package/dist/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  27. package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
  28. package/dist/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  29. package/dist/firestore/test/util/helpers.d.ts +13 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.esm2017.js +10689 -10296
  32. package/dist/index.esm2017.js.map +1 -1
  33. package/dist/index.esm5.js +9353 -8844
  34. package/dist/index.esm5.js.map +1 -1
  35. package/dist/index.node.cjs.js +6738 -6123
  36. package/dist/index.node.cjs.js.map +1 -1
  37. package/dist/index.node.mjs +6738 -6123
  38. package/dist/index.node.mjs.map +1 -1
  39. package/dist/index.rn.js +9818 -9424
  40. package/dist/index.rn.js.map +1 -1
  41. package/dist/internal.d.ts +190 -17
  42. package/dist/lite/firestore/src/api/transaction.d.ts +2 -0
  43. package/dist/lite/firestore/src/core/component_provider.d.ts +11 -6
  44. package/dist/lite/firestore/src/lite-api/transaction.d.ts +2 -0
  45. package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +5 -0
  46. package/dist/lite/firestore/src/local/index_backfiller.d.ts +44 -0
  47. package/dist/lite/firestore/src/local/index_manager.d.ts +2 -0
  48. package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
  49. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  50. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +3 -2
  51. package/dist/lite/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  52. package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
  53. package/dist/lite/firestore/src/local/local_documents_view.d.ts +64 -9
  54. package/dist/lite/firestore/src/local/local_store.d.ts +9 -0
  55. package/dist/lite/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  56. package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
  57. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +1 -0
  58. package/dist/lite/firestore/src/local/overlayed_document.d.ts +36 -0
  59. package/dist/lite/firestore/src/local/persistence.d.ts +3 -5
  60. package/dist/lite/firestore/src/local/persistence_promise.d.ts +11 -0
  61. package/dist/lite/firestore/src/local/query_engine.d.ts +1 -1
  62. package/dist/lite/firestore/src/model/collections.d.ts +8 -2
  63. package/dist/lite/firestore/src/model/field_mask.d.ts +6 -0
  64. package/dist/lite/firestore/src/model/mutation.d.ts +19 -1
  65. package/dist/lite/firestore/src/model/mutation_batch.d.ts +8 -4
  66. package/dist/lite/firestore/src/util/async_queue.d.ts +5 -1
  67. package/dist/lite/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  68. package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
  69. package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  70. package/dist/lite/firestore/test/util/helpers.d.ts +13 -0
  71. package/dist/lite/index.browser.esm2017.js +1220 -738
  72. package/dist/lite/index.browser.esm2017.js.map +1 -1
  73. package/dist/lite/index.browser.esm5.js +1156 -764
  74. package/dist/lite/index.browser.esm5.js.map +1 -1
  75. package/dist/lite/index.d.ts +2 -0
  76. package/dist/lite/index.node.cjs.js +655 -2
  77. package/dist/lite/index.node.cjs.js.map +1 -1
  78. package/dist/lite/index.node.mjs +655 -2
  79. package/dist/lite/index.node.mjs.map +1 -1
  80. package/dist/lite/index.rn.esm2017.js +1184 -702
  81. package/dist/lite/index.rn.esm2017.js.map +1 -1
  82. package/dist/lite/internal.d.ts +19 -1
  83. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +106 -104
  84. package/dist/lite/packages/firestore/src/api/transaction.d.ts +2 -0
  85. package/dist/lite/packages/firestore/src/core/component_provider.d.ts +11 -6
  86. package/dist/lite/packages/firestore/src/lite-api/transaction.d.ts +2 -0
  87. package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +5 -0
  88. package/dist/lite/packages/firestore/src/local/index_backfiller.d.ts +44 -0
  89. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +2 -0
  90. package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
  91. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  92. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +3 -2
  93. package/dist/lite/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  94. package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
  95. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +64 -9
  96. package/dist/lite/packages/firestore/src/local/local_store.d.ts +9 -0
  97. package/dist/lite/packages/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  98. package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
  99. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
  100. package/dist/lite/packages/firestore/src/local/overlayed_document.d.ts +36 -0
  101. package/dist/lite/packages/firestore/src/local/persistence.d.ts +3 -5
  102. package/dist/lite/packages/firestore/src/local/persistence_promise.d.ts +11 -0
  103. package/dist/lite/packages/firestore/src/local/query_engine.d.ts +1 -1
  104. package/dist/lite/packages/firestore/src/model/collections.d.ts +8 -2
  105. package/dist/lite/packages/firestore/src/model/field_mask.d.ts +6 -0
  106. package/dist/lite/packages/firestore/src/model/mutation.d.ts +19 -1
  107. package/dist/lite/packages/firestore/src/model/mutation_batch.d.ts +8 -4
  108. package/dist/lite/packages/firestore/src/util/async_queue.d.ts +5 -1
  109. package/dist/lite/packages/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  110. package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
  111. package/dist/lite/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  112. package/dist/lite/packages/firestore/test/util/helpers.d.ts +13 -0
  113. package/dist/lite/private.d.ts +19 -1
  114. package/dist/packages/firestore/dist/index.esm2017.d.ts +203 -201
  115. package/dist/packages/firestore/src/api/transaction.d.ts +2 -0
  116. package/dist/packages/firestore/src/core/component_provider.d.ts +11 -6
  117. package/dist/packages/firestore/src/lite-api/transaction.d.ts +2 -0
  118. package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +5 -0
  119. package/dist/packages/firestore/src/local/index_backfiller.d.ts +44 -0
  120. package/dist/packages/firestore/src/local/index_manager.d.ts +2 -0
  121. package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
  122. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  123. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +3 -2
  124. package/dist/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  125. package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
  126. package/dist/packages/firestore/src/local/local_documents_view.d.ts +64 -9
  127. package/dist/packages/firestore/src/local/local_store.d.ts +9 -0
  128. package/dist/packages/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  129. package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
  130. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
  131. package/dist/packages/firestore/src/local/overlayed_document.d.ts +36 -0
  132. package/dist/packages/firestore/src/local/persistence.d.ts +3 -5
  133. package/dist/packages/firestore/src/local/persistence_promise.d.ts +11 -0
  134. package/dist/packages/firestore/src/local/query_engine.d.ts +1 -1
  135. package/dist/packages/firestore/src/model/collections.d.ts +8 -2
  136. package/dist/packages/firestore/src/model/field_mask.d.ts +6 -0
  137. package/dist/packages/firestore/src/model/mutation.d.ts +19 -1
  138. package/dist/packages/firestore/src/model/mutation_batch.d.ts +8 -4
  139. package/dist/packages/firestore/src/util/async_queue.d.ts +5 -1
  140. package/dist/packages/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  141. package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
  142. package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  143. package/dist/packages/firestore/test/util/helpers.d.ts +13 -0
  144. package/dist/private.d.ts +190 -17
  145. package/package.json +15 -13
@@ -20,8 +20,9 @@ import { Observer } from '../../../src/core/event_manager';
20
20
  import { Query } from '../../../src/core/query';
21
21
  import { ViewSnapshot } from '../../../src/core/view_snapshot';
22
22
  import { IndexedDbPersistence } from '../../../src/local/indexeddb_persistence';
23
+ import { LocalStore } from '../../../src/local/local_store';
23
24
  import { MemoryPersistence } from '../../../src/local/memory_persistence';
24
- import { GarbageCollectionScheduler, Persistence } from '../../../src/local/persistence';
25
+ import { Scheduler, Persistence } from '../../../src/local/persistence';
25
26
  import { PersistencePromise } from '../../../src/local/persistence_promise';
26
27
  import { PersistenceTransaction, PersistenceTransactionMode } from '../../../src/local/persistence_transaction';
27
28
  import { SharedClientState } from '../../../src/local/shared_client_state';
@@ -62,7 +63,8 @@ export declare class MockMultiTabOfflineComponentProvider extends MultiTabOfflin
62
63
  private readonly document;
63
64
  persistence: MockIndexedDbPersistence;
64
65
  constructor(window: WindowLike, document: FakeDocument, onlineComponentProvider: OnlineComponentProvider);
65
- createGarbageCollectionScheduler(cfg: ComponentConfiguration): GarbageCollectionScheduler | null;
66
+ createGarbageCollectionScheduler(cfg: ComponentConfiguration, localStore: LocalStore): Scheduler | null;
67
+ createIndexBackfillerScheduler(cfg: ComponentConfiguration, localStore: LocalStore): Scheduler | null;
66
68
  createSharedClientState(cfg: ComponentConfiguration): SharedClientState;
67
69
  createPersistence(cfg: ComponentConfiguration): MockIndexedDbPersistence;
68
70
  }
@@ -71,7 +73,7 @@ export declare class MockMemoryOfflineComponentProvider extends MemoryOfflineCom
71
73
  persistence: MockMemoryPersistence;
72
74
  connection: MockConnection;
73
75
  constructor(gcEnabled: boolean);
74
- createGarbageCollectionScheduler(cfg: ComponentConfiguration): GarbageCollectionScheduler | null;
76
+ createGarbageCollectionScheduler(cfg: ComponentConfiguration): Scheduler | null;
75
77
  createPersistence(cfg: ComponentConfiguration): Persistence;
76
78
  }
77
79
  export declare class MockConnection implements Connection {
@@ -63,12 +63,14 @@ export declare function fieldIndex(collectionGroup: string, options?: {
63
63
  id?: number;
64
64
  fields?: Array<[field: string, kind: IndexKind]>;
65
65
  offset?: IndexOffset;
66
+ sequenceNumber?: number;
66
67
  }): FieldIndex;
67
68
  export declare function mask(...paths: string[]): FieldMask;
68
69
  export declare function blob(...bytes: number[]): Bytes;
69
70
  export declare function filter(path: string, op: string, value: unknown): FieldFilter;
70
71
  export declare function setMutation(keyStr: string, json: JsonObject<unknown>): SetMutation;
71
72
  export declare function patchMutation(keyStr: string, json: JsonObject<unknown>, precondition?: Precondition): PatchMutation;
73
+ export declare function mergeMutation(keyStr: string, json: JsonObject<unknown>, updateMask: FieldPath[]): PatchMutation;
72
74
  export declare function deleteMutation(keyStr: string): DeleteMutation;
73
75
  export declare function mutationResult(testVersion: TestSnapshotVersion): MutationResult;
74
76
  export declare function bound(values: unknown[], inclusive: boolean): Bound;
@@ -177,3 +179,14 @@ export declare function expectSetToEqual<T>(set: SortedSet<T>, arr: T[]): void;
177
179
  export declare function expectEqualitySets<T>(elems: T[][], equalityFn: (v1: T, v2: T) => boolean, stringifyFn?: (v: T) => string): void;
178
180
  export declare function validateFirestoreError(expectedCode: Code, actualError: Error): void;
179
181
  export declare function forEachNumber<V>(obj: Dict<V>, fn: (key: number, val: V) => void): void;
182
+ /**
183
+ * Returns all possible permutations of the given array.
184
+ * For `[a, b]`, this method returns `[[a, b], [b, a]]`.
185
+ */
186
+ export declare function computePermutations<T>(input: T[]): T[][];
187
+ /**
188
+ * Returns all possible combinations of the given array, including an empty
189
+ * array. For `[a, b, c]` this method returns
190
+ * `[[], [a], [a, b], [a, c], [b, c], [a, b, c]`.
191
+ */
192
+ export declare function computeCombinations<T>(input: T[]): T[][];
package/dist/private.d.ts CHANGED
@@ -846,6 +846,8 @@ export declare function documentId(): FieldPath;
846
846
 
847
847
  /* Excluded from this release type: _DocumentKey */
848
848
 
849
+ declare type DocumentKeyMap<T> = ObjectMap<_DocumentKey, T>;
850
+
849
851
  declare type DocumentKeySet = SortedSet<_DocumentKey>;
850
852
 
851
853
  declare type DocumentMap = SortedMap<_DocumentKey, Document_2>;
@@ -866,6 +868,11 @@ declare interface DocumentOverlayCache {
866
868
  * Returns null if there is no overlay for that key.
867
869
  */
868
870
  getOverlay(transaction: PersistenceTransaction, key: _DocumentKey): PersistencePromise<Overlay | null>;
871
+ /**
872
+ * Gets the saved overlay mutation for the given document keys. Skips keys for
873
+ * which there are no overlays.
874
+ */
875
+ getOverlays(transaction: PersistenceTransaction, keys: _DocumentKey[]): PersistencePromise<OverlayMap>;
869
876
  /**
870
877
  * Saves the given document mutation map to persistence as overlays.
871
878
  * All overlays will have their largest batch id set to `largestBatchId`.
@@ -1293,6 +1300,12 @@ declare class FieldIndex {
1293
1300
  declare class FieldMask {
1294
1301
  readonly fields: _FieldPath[];
1295
1302
  constructor(fields: _FieldPath[]);
1303
+ static empty(): FieldMask;
1304
+ /**
1305
+ * Returns a new FieldMask object that is the result of adding all the given
1306
+ * fields paths to this field mask.
1307
+ */
1308
+ unionWith(extraFields: _FieldPath[]): FieldMask;
1296
1309
  /**
1297
1310
  * Verifies that `fieldPath` is included by at least one field in this field
1298
1311
  * mask.
@@ -2072,16 +2085,6 @@ declare interface FirstPartyCredentialsSettings {
2072
2085
  */
2073
2086
  declare type FulfilledHandler<T, R> = ((result: T) => R | PersistencePromise<R>) | null;
2074
2087
 
2075
- /**
2076
- * Interface implemented by the LRU scheduler to start(), stop() and restart
2077
- * garbage collection.
2078
- */
2079
- declare interface GarbageCollectionScheduler {
2080
- readonly started: boolean;
2081
- start(localStore: LocalStore): void;
2082
- stop(): void;
2083
- }
2084
-
2085
2088
  /**
2086
2089
  * @license
2087
2090
  * Copyright 2017 Google LLC
@@ -2333,6 +2336,8 @@ declare interface IndexManager {
2333
2336
  * and returns the minimum offset of them all.
2334
2337
  */
2335
2338
  getMinOffset(transaction: PersistenceTransaction, target: Target): PersistencePromise<IndexOffset>;
2339
+ /** Returns the minimum offset for the given collection group. */
2340
+ getMinOffsetFromCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<IndexOffset>;
2336
2341
  }
2337
2342
 
2338
2343
  /**
@@ -2603,8 +2608,119 @@ export declare interface LoadBundleTaskProgress {
2603
2608
  taskState: TaskState;
2604
2609
  }
2605
2610
 
2611
+ /**
2612
+ * A readonly view of the local state of all documents we're tracking (i.e. we
2613
+ * have a cached version in remoteDocumentCache or local mutations for the
2614
+ * document). The view is computed by applying the mutations in the
2615
+ * MutationQueue to the RemoteDocumentCache.
2616
+ */
2617
+ declare class LocalDocumentsView {
2618
+ readonly remoteDocumentCache: RemoteDocumentCache;
2619
+ readonly mutationQueue: MutationQueue;
2620
+ readonly documentOverlayCache: DocumentOverlayCache;
2621
+ readonly indexManager: IndexManager;
2622
+ constructor(remoteDocumentCache: RemoteDocumentCache, mutationQueue: MutationQueue, documentOverlayCache: DocumentOverlayCache, indexManager: IndexManager);
2623
+ /**
2624
+ * Get the local view of the document identified by `key`.
2625
+ *
2626
+ * @returns Local view of the document or null if we don't have any cached
2627
+ * state for it.
2628
+ */
2629
+ getDocument(transaction: PersistenceTransaction, key: _DocumentKey): PersistencePromise<Document_2>;
2630
+ /**
2631
+ * Gets the local view of the documents identified by `keys`.
2632
+ *
2633
+ * If we don't have cached state for a document in `keys`, a NoDocument will
2634
+ * be stored for that key in the resulting set.
2635
+ */
2636
+ getDocuments(transaction: PersistenceTransaction, keys: DocumentKeySet): PersistencePromise<DocumentMap>;
2637
+ /**
2638
+ * Similar to `getDocuments`, but creates the local view from the given
2639
+ * `baseDocs` without retrieving documents from the local store.
2640
+ *
2641
+ * @param transaction - The transaction this operation is scoped to.
2642
+ * @param docs - The documents to apply local mutations to get the local views.
2643
+ * @param existenceStateChanged - The set of document keys whose existence state
2644
+ * is changed. This is useful to determine if some documents overlay needs
2645
+ * to be recalculated.
2646
+ */
2647
+ getLocalViewOfDocuments(transaction: PersistenceTransaction, docs: MutableDocumentMap, existenceStateChanged?: DocumentKeySet): PersistencePromise<DocumentMap>;
2648
+ /**
2649
+ * Gets the overlayed documents for the given document map, which will include
2650
+ * the local view of those documents and a `FieldMask` indicating which fields
2651
+ * are mutated locally, `null` if overlay is a Set or Delete mutation.
2652
+ */
2653
+ getOverlayedDocuments(transaction: PersistenceTransaction, docs: MutableDocumentMap): PersistencePromise<OverlayedDocumentMap>;
2654
+ /**
2655
+ * Fetches the overlays for {@code docs} and adds them to provided overlay map
2656
+ * if the map does not already contain an entry for the given document key.
2657
+ */
2658
+ private populateOverlays;
2659
+ /**
2660
+ * Computes the local view for the given documents.
2661
+ *
2662
+ * @param docs - The documents to compute views for. It also has the base
2663
+ * version of the documents.
2664
+ * @param overlays - The overlays that need to be applied to the given base
2665
+ * version of the documents.
2666
+ * @param existenceStateChanged - A set of documents whose existence states
2667
+ * might have changed. This is used to determine if we need to re-calculate
2668
+ * overlays from mutation queues.
2669
+ * @return A map represents the local documents view.
2670
+ */
2671
+ computeViews(transaction: PersistenceTransaction, docs: MutableDocumentMap, overlays: OverlayMap, existenceStateChanged: DocumentKeySet): PersistencePromise<OverlayedDocumentMap>;
2672
+ private recalculateAndSaveOverlays;
2673
+ /**
2674
+ * Recalculates overlays by reading the documents from remote document cache
2675
+ * first, and saves them after they are calculated.
2676
+ */
2677
+ recalculateAndSaveOverlaysForDocumentKeys(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<DocumentKeyMap<FieldMask | null>>;
2678
+ /**
2679
+ * Performs a query against the local view of all documents.
2680
+ *
2681
+ * @param transaction - The persistence transaction.
2682
+ * @param query - The query to match documents against.
2683
+ * @param offset - Read time and key to start scanning by (exclusive).
2684
+ */
2685
+ getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query_2, offset: IndexOffset): PersistencePromise<DocumentMap>;
2686
+ /**
2687
+ * Given a collection group, returns the next documents that follow the provided offset, along
2688
+ * with an updated batch ID.
2689
+ *
2690
+ * <p>The documents returned by this method are ordered by remote version from the provided
2691
+ * offset. If there are no more remote documents after the provided offset, documents with
2692
+ * mutations in order of batch id from the offset are returned. Since all documents in a batch are
2693
+ * returned together, the total number of documents returned can exceed {@code count}.
2694
+ *
2695
+ * @param transaction
2696
+ * @param collectionGroup The collection group for the documents.
2697
+ * @param offset The offset to index into.
2698
+ * @param count The number of documents to return
2699
+ * @return A LocalWriteResult with the documents that follow the provided offset and the last processed batch id.
2700
+ */
2701
+ getNextDocuments(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset, count: number): PersistencePromise<LocalWriteResult>;
2702
+ private getDocumentsMatchingDocumentQuery;
2703
+ private getDocumentsMatchingCollectionGroupQuery;
2704
+ private getDocumentsMatchingCollectionQuery;
2705
+ /** Returns a base document that can be used to apply `overlay`. */
2706
+ private getBaseDocument;
2707
+ }
2708
+
2606
2709
  declare interface LocalStore {
2607
2710
  collectGarbage(garbageCollector: LruGarbageCollector): Promise<LruResults>;
2711
+ /** Manages the list of active field and collection indices. */
2712
+ indexManager: IndexManager;
2713
+ /**
2714
+ * The "local" view of all documents (layering mutationQueue on top of
2715
+ * remoteDocumentCache).
2716
+ */
2717
+ localDocuments: LocalDocumentsView;
2718
+ }
2719
+
2720
+ /** The result of a write to the local store. */
2721
+ declare interface LocalWriteResult {
2722
+ batchId: BatchId;
2723
+ changes: DocumentMap;
2608
2724
  }
2609
2725
  export { LogLevel }
2610
2726
 
@@ -2776,6 +2892,12 @@ declare abstract class Mutation {
2776
2892
  abstract readonly key: _DocumentKey;
2777
2893
  abstract readonly precondition: Precondition;
2778
2894
  abstract readonly fieldTransforms: FieldTransform[];
2895
+ /**
2896
+ * Returns a `FieldMask` representing the fields that will be changed by
2897
+ * applying this mutation. Returns `null` if the mutation will overwrite the
2898
+ * entire document.
2899
+ */
2900
+ abstract getFieldMask(): FieldMask | null;
2779
2901
  }
2780
2902
 
2781
2903
  /**
@@ -2812,13 +2934,16 @@ declare class MutationBatch {
2812
2934
  * batch.
2813
2935
  *
2814
2936
  * @param document - The document to apply mutations to.
2937
+ * @param mutatedFields - Fields that have been updated before applying this mutation batch.
2938
+ * @returns A `FieldMask` representing all the fields that are mutated.
2815
2939
  */
2816
- applyToLocalView(document: MutableDocument): void;
2940
+ applyToLocalView(document: MutableDocument, mutatedFields: FieldMask | null): FieldMask | null;
2817
2941
  /**
2818
2942
  * Computes the local view for all provided documents given the mutations in
2819
- * this batch.
2943
+ * this batch. Returns a `DocumentKey` to `Mutation` map which can be used to
2944
+ * replace all the mutation applications.
2820
2945
  */
2821
- applyToLocalDocumentSet(documentMap: DocumentMap): void;
2946
+ applyToLocalDocumentSet(documentMap: OverlayedDocumentMap, documentsWithoutRemoteVersion: DocumentKeySet): MutationMap;
2822
2947
  keys(): DocumentKeySet;
2823
2948
  isEqual(other: MutationBatch): boolean;
2824
2949
  }
@@ -2842,7 +2967,7 @@ declare class MutationBatchResult {
2842
2967
  static from(batch: MutationBatch, commitVersion: SnapshotVersion, results: MutationResult[]): MutationBatchResult;
2843
2968
  }
2844
2969
 
2845
- declare type MutationMap = ObjectMap<_DocumentKey, Mutation>;
2970
+ declare type MutationMap = DocumentKeyMap<Mutation>;
2846
2971
 
2847
2972
  /** A queue of mutations to apply to the remote store. */
2848
2973
  declare interface MutationQueue {
@@ -3148,7 +3273,8 @@ declare interface OfflineComponentProvider {
3148
3273
  persistence: Persistence;
3149
3274
  sharedClientState: SharedClientState;
3150
3275
  localStore: LocalStore;
3151
- gcScheduler: GarbageCollectionScheduler | null;
3276
+ gcScheduler: Scheduler | null;
3277
+ indexBackfillerScheduler: Scheduler | null;
3152
3278
  synchronizeTabs: boolean;
3153
3279
  initialize(cfg: ComponentConfiguration): Promise<void>;
3154
3280
  terminate(): Promise<void>;
@@ -3451,7 +3577,28 @@ declare class Overlay {
3451
3577
  toString(): string;
3452
3578
  }
3453
3579
 
3454
- declare type OverlayMap = ObjectMap<_DocumentKey, Overlay>;
3580
+ /**
3581
+ * Represents a local view (overlay) of a document, and the fields that are
3582
+ * locally mutated.
3583
+ */
3584
+ declare class OverlayedDocument {
3585
+ readonly overlayedDocument: Document_2;
3586
+ /**
3587
+ * The fields that are locally mutated by patch mutations. If the overlayed
3588
+ * document is from set or delete mutations, this returns null.
3589
+ */
3590
+ readonly mutatedFields: FieldMask | null;
3591
+ constructor(overlayedDocument: Document_2,
3592
+ /**
3593
+ * The fields that are locally mutated by patch mutations. If the overlayed
3594
+ * document is from set or delete mutations, this returns null.
3595
+ */
3596
+ mutatedFields: FieldMask | null);
3597
+ }
3598
+
3599
+ declare type OverlayedDocumentMap = DocumentKeyMap<OverlayedDocument>;
3600
+
3601
+ declare type OverlayMap = DocumentKeyMap<Overlay>;
3455
3602
 
3456
3603
  declare interface ParseContext {
3457
3604
  readonly databaseId: _DatabaseId;
@@ -3670,6 +3817,17 @@ declare class PersistencePromise<T> {
3670
3817
  static forEach<R>(collection: {
3671
3818
  forEach: (cb: (r: R) => void) => void;
3672
3819
  }, f: (r: R) => PersistencePromise<void>): PersistencePromise<void>;
3820
+ /**
3821
+ * Concurrently map all array elements through asynchronous function.
3822
+ */
3823
+ static mapArray<T, U>(array: T[], f: (t: T) => PersistencePromise<U>): PersistencePromise<U[]>;
3824
+ /**
3825
+ * An alternative to recursive PersistencePromise calls, that avoids
3826
+ * potential memory problems from unbounded chains of promises.
3827
+ *
3828
+ * The `action` will be called repeatedly while `condition` is true.
3829
+ */
3830
+ static doWhile(condition: () => boolean, action: () => PersistencePromise<void>): PersistencePromise<void>;
3673
3831
  }
3674
3832
 
3675
3833
  /**
@@ -4277,6 +4435,8 @@ declare type Resolver<T> = (value?: T) => void;
4277
4435
  * transaction against.
4278
4436
  * @param updateFunction - The function to execute within the transaction
4279
4437
  * context.
4438
+ * @param options - An options object to configure maximum number of attempts to
4439
+ * commit.
4280
4440
  * @returns If the transaction completed successfully or was explicitly aborted
4281
4441
  * (the `updateFunction` returned a failed promise), the promise returned by the
4282
4442
  * `updateFunction `is returned here. Otherwise, if the transaction failed, a
@@ -4284,6 +4444,15 @@ declare type Resolver<T> = (value?: T) => void;
4284
4444
  */
4285
4445
  export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
4286
4446
 
4447
+ /**
4448
+ * Interface to schedule periodic tasks within SDK.
4449
+ */
4450
+ declare interface Scheduler {
4451
+ readonly started: boolean;
4452
+ start(): void;
4453
+ stop(): void;
4454
+ }
4455
+
4287
4456
  /**
4288
4457
  * Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
4289
4458
  * include a server-generated timestamp in the written data.
@@ -5073,7 +5242,11 @@ declare const enum TimerId {
5073
5242
  * A timer used to retry operations scheduled via retryable AsyncQueue
5074
5243
  * operations.
5075
5244
  */
5076
- AsyncQueueRetry = "async_queue_retry"
5245
+ AsyncQueueRetry = "async_queue_retry",
5246
+ /**
5247
+ * A timer used to periodically attempt index backfill.
5248
+ */
5249
+ IndexBackfill = "index_backfill"
5077
5250
  }
5078
5251
 
5079
5252
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase/firestore",
3
- "version": "3.4.9-canary.aa44d529e",
3
+ "version": "3.4.9-canary.abcab980c",
4
4
  "engines": {
5
5
  "node": ">=10.10.0"
6
6
  },
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "exports": {
48
48
  ".": {
49
+ "types": "./dist/index.d.ts",
49
50
  "node": {
50
51
  "require": "./dist/index.node.cjs.js",
51
52
  "import": "./dist/index.node.mjs"
@@ -55,13 +56,14 @@
55
56
  "default": "./dist/index.esm2017.js"
56
57
  },
57
58
  "./lite": {
59
+ "types": "./dist/lite/index.d.ts",
58
60
  "node": {
59
61
  "require": "./dist/lite/index.node.cjs.js",
60
62
  "import": "./dist/lite/index.node.mjs"
61
63
  },
62
- "react-native": "./dist/lite/index.rn.esm2017.js",
63
- "esm5": "./dist/lite/index.browser.esm5.js",
64
- "default": "./dist/lite/index.browser.esm2017.js"
64
+ "react-native": "./dist/index.rn.js",
65
+ "esm5": "./dist/index.esm5.js",
66
+ "default": "./dist/index.esm2017.js"
65
67
  },
66
68
  "./package.json": "./package.json"
67
69
  },
@@ -77,25 +79,25 @@
77
79
  "lite/package.json"
78
80
  ],
79
81
  "dependencies": {
80
- "@firebase/component": "0.5.14-canary.aa44d529e",
81
- "@firebase/logger": "0.3.2-canary.aa44d529e",
82
- "@firebase/util": "1.6.0-canary.aa44d529e",
83
- "@firebase/webchannel-wrapper": "0.6.1-canary.aa44d529e",
82
+ "@firebase/component": "0.5.14-canary.abcab980c",
83
+ "@firebase/logger": "0.3.2-canary.abcab980c",
84
+ "@firebase/util": "1.6.0-canary.abcab980c",
85
+ "@firebase/webchannel-wrapper": "0.6.1-canary.abcab980c",
84
86
  "@grpc/grpc-js": "^1.3.2",
85
87
  "@grpc/proto-loader": "^0.6.0",
86
88
  "node-fetch": "2.6.7",
87
89
  "tslib": "^2.1.0"
88
90
  },
89
91
  "peerDependencies": {
90
- "@firebase/app": "0.7.24-canary.aa44d529e"
92
+ "@firebase/app": "0.7.25-canary.abcab980c"
91
93
  },
92
94
  "devDependencies": {
93
- "@firebase/app": "0.7.24-canary.aa44d529e",
94
- "@firebase/app-compat": "0.1.25-canary.aa44d529e",
95
- "@firebase/auth": "0.20.1-canary.aa44d529e",
95
+ "@firebase/app": "0.7.25-canary.abcab980c",
96
+ "@firebase/app-compat": "0.1.26-canary.abcab980c",
97
+ "@firebase/auth": "0.20.2-canary.abcab980c",
96
98
  "@rollup/plugin-alias": "3.1.9",
97
99
  "@rollup/plugin-json": "4.1.0",
98
- "@types/eslint": "7.28.0",
100
+ "@types/eslint": "7.29.0",
99
101
  "@types/json-stable-stringify": "1.0.34",
100
102
  "json-stable-stringify": "1.0.1",
101
103
  "protobufjs": "6.11.2",