@firebase/firestore 3.4.9-canary.f84cacd70 → 3.4.10

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 +14 -0
  2. package/dist/firestore/src/core/component_provider.d.ts +11 -6
  3. package/dist/firestore/src/local/document_overlay_cache.d.ts +1 -1
  4. package/dist/firestore/src/local/index_backfiller.d.ts +44 -0
  5. package/dist/firestore/src/local/index_manager.d.ts +2 -0
  6. package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -1
  7. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  8. package/dist/firestore/src/local/local_documents_view.d.ts +20 -4
  9. package/dist/firestore/src/local/local_store.d.ts +9 -0
  10. package/dist/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  11. package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +1 -1
  12. package/dist/firestore/src/local/memory_index_manager.d.ts +1 -0
  13. package/dist/firestore/src/local/persistence.d.ts +3 -5
  14. package/dist/firestore/src/local/persistence_promise.d.ts +11 -0
  15. package/dist/firestore/src/model/collections.d.ts +6 -2
  16. package/dist/firestore/src/model/mutation_batch.d.ts +2 -3
  17. package/dist/firestore/src/util/async_queue.d.ts +5 -1
  18. package/dist/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  19. package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -1
  20. package/dist/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  21. package/dist/firestore/test/util/helpers.d.ts +1 -0
  22. package/dist/index.esm2017.js +7499 -7351
  23. package/dist/index.esm2017.js.map +1 -1
  24. package/dist/index.esm5.js +8227 -7997
  25. package/dist/index.esm5.js.map +1 -1
  26. package/dist/index.node.cjs.js +1552 -1309
  27. package/dist/index.node.cjs.js.map +1 -1
  28. package/dist/index.node.mjs +1552 -1309
  29. package/dist/index.node.mjs.map +1 -1
  30. package/dist/index.rn.js +7491 -7342
  31. package/dist/index.rn.js.map +1 -1
  32. package/dist/internal.d.ts +146 -16
  33. package/dist/lite/firestore/src/core/component_provider.d.ts +11 -6
  34. package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +1 -1
  35. package/dist/lite/firestore/src/local/index_backfiller.d.ts +44 -0
  36. package/dist/lite/firestore/src/local/index_manager.d.ts +2 -0
  37. package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -1
  38. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  39. package/dist/lite/firestore/src/local/local_documents_view.d.ts +20 -4
  40. package/dist/lite/firestore/src/local/local_store.d.ts +9 -0
  41. package/dist/lite/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  42. package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +1 -1
  43. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +1 -0
  44. package/dist/lite/firestore/src/local/persistence.d.ts +3 -5
  45. package/dist/lite/firestore/src/local/persistence_promise.d.ts +11 -0
  46. package/dist/lite/firestore/src/model/collections.d.ts +6 -2
  47. package/dist/lite/firestore/src/model/mutation_batch.d.ts +2 -3
  48. package/dist/lite/firestore/src/util/async_queue.d.ts +5 -1
  49. package/dist/lite/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  50. package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -1
  51. package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  52. package/dist/lite/firestore/test/util/helpers.d.ts +1 -0
  53. package/dist/lite/index.browser.esm2017.js +2 -2
  54. package/dist/lite/index.browser.esm2017.js.map +1 -1
  55. package/dist/lite/index.browser.esm5.js +2 -2
  56. package/dist/lite/index.browser.esm5.js.map +1 -1
  57. package/dist/lite/index.node.cjs.js +2 -2
  58. package/dist/lite/index.node.cjs.js.map +1 -1
  59. package/dist/lite/index.node.mjs +2 -2
  60. package/dist/lite/index.node.mjs.map +1 -1
  61. package/dist/lite/index.rn.esm2017.js +2 -2
  62. package/dist/lite/index.rn.esm2017.js.map +1 -1
  63. package/dist/lite/internal.d.ts +5 -1
  64. package/dist/lite/packages/firestore/src/core/component_provider.d.ts +11 -6
  65. package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +1 -1
  66. package/dist/lite/packages/firestore/src/local/index_backfiller.d.ts +44 -0
  67. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +2 -0
  68. package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -1
  69. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  70. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +20 -4
  71. package/dist/lite/packages/firestore/src/local/local_store.d.ts +9 -0
  72. package/dist/lite/packages/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  73. package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +1 -1
  74. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
  75. package/dist/lite/packages/firestore/src/local/persistence.d.ts +3 -5
  76. package/dist/lite/packages/firestore/src/local/persistence_promise.d.ts +11 -0
  77. package/dist/lite/packages/firestore/src/model/collections.d.ts +6 -2
  78. package/dist/lite/packages/firestore/src/model/mutation_batch.d.ts +2 -3
  79. package/dist/lite/packages/firestore/src/util/async_queue.d.ts +5 -1
  80. package/dist/lite/packages/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  81. package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -1
  82. package/dist/lite/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  83. package/dist/lite/packages/firestore/test/util/helpers.d.ts +1 -0
  84. package/dist/lite/private.d.ts +5 -1
  85. package/dist/packages/firestore/dist/index.esm2017.d.ts +200 -200
  86. package/dist/packages/firestore/src/core/component_provider.d.ts +11 -6
  87. package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +1 -1
  88. package/dist/packages/firestore/src/local/index_backfiller.d.ts +44 -0
  89. package/dist/packages/firestore/src/local/index_manager.d.ts +2 -0
  90. package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -1
  91. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  92. package/dist/packages/firestore/src/local/local_documents_view.d.ts +20 -4
  93. package/dist/packages/firestore/src/local/local_store.d.ts +9 -0
  94. package/dist/packages/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  95. package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +1 -1
  96. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
  97. package/dist/packages/firestore/src/local/persistence.d.ts +3 -5
  98. package/dist/packages/firestore/src/local/persistence_promise.d.ts +11 -0
  99. package/dist/packages/firestore/src/model/collections.d.ts +6 -2
  100. package/dist/packages/firestore/src/model/mutation_batch.d.ts +2 -3
  101. package/dist/packages/firestore/src/util/async_queue.d.ts +5 -1
  102. package/dist/packages/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  103. package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -1
  104. package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  105. package/dist/packages/firestore/test/util/helpers.d.ts +1 -0
  106. package/dist/private.d.ts +146 -16
  107. package/package.json +9 -9
package/dist/private.d.ts CHANGED
@@ -872,7 +872,7 @@ declare interface DocumentOverlayCache {
872
872
  * Gets the saved overlay mutation for the given document keys. Skips keys for
873
873
  * which there are no overlays.
874
874
  */
875
- getOverlays(transaction: PersistenceTransaction, keys: DocumentKeySet): PersistencePromise<OverlayMap>;
875
+ getOverlays(transaction: PersistenceTransaction, keys: _DocumentKey[]): PersistencePromise<OverlayMap>;
876
876
  /**
877
877
  * Saves the given document mutation map to persistence as overlays.
878
878
  * All overlays will have their largest batch id set to `largestBatchId`.
@@ -2085,16 +2085,6 @@ declare interface FirstPartyCredentialsSettings {
2085
2085
  */
2086
2086
  declare type FulfilledHandler<T, R> = ((result: T) => R | PersistencePromise<R>) | null;
2087
2087
 
2088
- /**
2089
- * Interface implemented by the LRU scheduler to start(), stop() and restart
2090
- * garbage collection.
2091
- */
2092
- declare interface GarbageCollectionScheduler {
2093
- readonly started: boolean;
2094
- start(localStore: LocalStore): void;
2095
- stop(): void;
2096
- }
2097
-
2098
2088
  /**
2099
2089
  * @license
2100
2090
  * Copyright 2017 Google LLC
@@ -2346,6 +2336,8 @@ declare interface IndexManager {
2346
2336
  * and returns the minimum offset of them all.
2347
2337
  */
2348
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>;
2349
2341
  }
2350
2342
 
2351
2343
  /**
@@ -2616,8 +2608,119 @@ export declare interface LoadBundleTaskProgress {
2616
2608
  taskState: TaskState;
2617
2609
  }
2618
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
+
2619
2709
  declare interface LocalStore {
2620
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;
2621
2724
  }
2622
2725
  export { LogLevel }
2623
2726
 
@@ -2840,7 +2943,7 @@ declare class MutationBatch {
2840
2943
  * this batch. Returns a `DocumentKey` to `Mutation` map which can be used to
2841
2944
  * replace all the mutation applications.
2842
2945
  */
2843
- applyToLocalDocumentSet(documentMap: DocumentKeyMap<OverlayedDocument>, documentsWithoutRemoteVersion: DocumentKeySet): MutationMap;
2946
+ applyToLocalDocumentSet(documentMap: OverlayedDocumentMap, documentsWithoutRemoteVersion: DocumentKeySet): MutationMap;
2844
2947
  keys(): DocumentKeySet;
2845
2948
  isEqual(other: MutationBatch): boolean;
2846
2949
  }
@@ -2864,7 +2967,7 @@ declare class MutationBatchResult {
2864
2967
  static from(batch: MutationBatch, commitVersion: SnapshotVersion, results: MutationResult[]): MutationBatchResult;
2865
2968
  }
2866
2969
 
2867
- declare type MutationMap = ObjectMap<_DocumentKey, Mutation>;
2970
+ declare type MutationMap = DocumentKeyMap<Mutation>;
2868
2971
 
2869
2972
  /** A queue of mutations to apply to the remote store. */
2870
2973
  declare interface MutationQueue {
@@ -3170,7 +3273,8 @@ declare interface OfflineComponentProvider {
3170
3273
  persistence: Persistence;
3171
3274
  sharedClientState: SharedClientState;
3172
3275
  localStore: LocalStore;
3173
- gcScheduler: GarbageCollectionScheduler | null;
3276
+ gcScheduler: Scheduler | null;
3277
+ indexBackfillerScheduler: Scheduler | null;
3174
3278
  synchronizeTabs: boolean;
3175
3279
  initialize(cfg: ComponentConfiguration): Promise<void>;
3176
3280
  terminate(): Promise<void>;
@@ -3492,7 +3596,9 @@ declare class OverlayedDocument {
3492
3596
  mutatedFields: FieldMask | null);
3493
3597
  }
3494
3598
 
3495
- declare type OverlayMap = ObjectMap<_DocumentKey, Overlay>;
3599
+ declare type OverlayedDocumentMap = DocumentKeyMap<OverlayedDocument>;
3600
+
3601
+ declare type OverlayMap = DocumentKeyMap<Overlay>;
3496
3602
 
3497
3603
  declare interface ParseContext {
3498
3604
  readonly databaseId: _DatabaseId;
@@ -3711,6 +3817,17 @@ declare class PersistencePromise<T> {
3711
3817
  static forEach<R>(collection: {
3712
3818
  forEach: (cb: (r: R) => void) => void;
3713
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>;
3714
3831
  }
3715
3832
 
3716
3833
  /**
@@ -4327,6 +4444,15 @@ declare type Resolver<T> = (value?: T) => void;
4327
4444
  */
4328
4445
  export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
4329
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
+
4330
4456
  /**
4331
4457
  * Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
4332
4458
  * include a server-generated timestamp in the written data.
@@ -5116,7 +5242,11 @@ declare const enum TimerId {
5116
5242
  * A timer used to retry operations scheduled via retryable AsyncQueue
5117
5243
  * operations.
5118
5244
  */
5119
- AsyncQueueRetry = "async_queue_retry"
5245
+ AsyncQueueRetry = "async_queue_retry",
5246
+ /**
5247
+ * A timer used to periodically attempt index backfill.
5248
+ */
5249
+ IndexBackfill = "index_backfill"
5120
5250
  }
5121
5251
 
5122
5252
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase/firestore",
3
- "version": "3.4.9-canary.f84cacd70",
3
+ "version": "3.4.10",
4
4
  "engines": {
5
5
  "node": ">=10.10.0"
6
6
  },
@@ -79,22 +79,22 @@
79
79
  "lite/package.json"
80
80
  ],
81
81
  "dependencies": {
82
- "@firebase/component": "0.5.14-canary.f84cacd70",
83
- "@firebase/logger": "0.3.2-canary.f84cacd70",
84
- "@firebase/util": "1.6.0-canary.f84cacd70",
85
- "@firebase/webchannel-wrapper": "0.6.1-canary.f84cacd70",
82
+ "@firebase/component": "0.5.15",
83
+ "@firebase/logger": "0.3.3",
84
+ "@firebase/util": "1.6.1",
85
+ "@firebase/webchannel-wrapper": "0.6.2",
86
86
  "@grpc/grpc-js": "^1.3.2",
87
87
  "@grpc/proto-loader": "^0.6.0",
88
88
  "node-fetch": "2.6.7",
89
89
  "tslib": "^2.1.0"
90
90
  },
91
91
  "peerDependencies": {
92
- "@firebase/app": "0.7.25-canary.f84cacd70"
92
+ "@firebase/app": "0.x"
93
93
  },
94
94
  "devDependencies": {
95
- "@firebase/app": "0.7.25-canary.f84cacd70",
96
- "@firebase/app-compat": "0.1.26-canary.f84cacd70",
97
- "@firebase/auth": "0.20.2-canary.f84cacd70",
95
+ "@firebase/app": "0.7.26",
96
+ "@firebase/app-compat": "0.1.27",
97
+ "@firebase/auth": "0.20.3",
98
98
  "@rollup/plugin-alias": "3.1.9",
99
99
  "@rollup/plugin-json": "4.1.0",
100
100
  "@types/eslint": "7.29.0",