@firebase/firestore 3.4.4 → 3.4.5-canary.09e62431f

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 (237) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/firestore/src/api/credentials.d.ts +1 -0
  3. package/dist/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  4. package/dist/firestore/src/api/snapshot.d.ts +1 -2
  5. package/dist/firestore/src/api.d.ts +1 -1
  6. package/dist/firestore/src/core/database_info.d.ts +1 -0
  7. package/dist/firestore/src/core/target.d.ts +34 -5
  8. package/dist/firestore/src/index/index_byte_encoder.d.ts +18 -1
  9. package/dist/firestore/src/index/index_entry.d.ts +32 -0
  10. package/dist/firestore/src/lite-api/query.d.ts +2 -2
  11. package/dist/firestore/src/local/document_overlay_cache.d.ts +71 -0
  12. package/dist/firestore/src/local/index_manager.d.ts +52 -0
  13. package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
  14. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
  15. package/dist/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  16. package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  17. package/dist/firestore/src/local/indexeddb_schema.d.ts +106 -437
  18. package/dist/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
  19. package/dist/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
  20. package/dist/firestore/src/local/local_documents_view.d.ts +0 -1
  21. package/dist/firestore/src/local/local_serializer.d.ts +20 -3
  22. package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
  23. package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
  24. package/dist/firestore/src/local/memory_persistence.d.ts +6 -2
  25. package/dist/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  26. package/dist/firestore/src/local/persistence.d.ts +8 -2
  27. package/dist/firestore/src/local/remote_document_cache.d.ts +7 -9
  28. package/dist/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  29. package/dist/firestore/src/local/simple_db.d.ts +12 -0
  30. package/dist/firestore/src/model/collections.d.ts +7 -0
  31. package/dist/firestore/src/model/document.d.ts +7 -0
  32. package/dist/firestore/src/model/document_key.d.ts +6 -0
  33. package/dist/firestore/src/model/field_index.d.ts +89 -7
  34. package/dist/firestore/src/model/overlay.d.ts +32 -0
  35. package/dist/firestore/src/model/target_index_matcher.d.ts +70 -0
  36. package/dist/firestore/src/model/type_order.d.ts +2 -1
  37. package/dist/firestore/src/model/values.d.ts +7 -0
  38. package/dist/firestore/src/platform/node/base64.d.ts +1 -0
  39. package/dist/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  40. package/dist/firestore/src/platform/node/load_protos.d.ts +2 -2
  41. package/dist/firestore/src/util/obj_map.d.ts +3 -0
  42. package/dist/firestore/src/util/sorted_set.d.ts +18 -0
  43. package/dist/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  44. package/dist/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  45. package/dist/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  46. package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  47. package/dist/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  48. package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  49. package/dist/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  50. package/dist/firestore/test/unit/model/field_index.test.d.ts +17 -0
  51. package/dist/firestore/test/unit/model/target.test.d.ts +17 -0
  52. package/dist/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  53. package/dist/firestore/test/util/helpers.d.ts +8 -2
  54. package/dist/index.d.ts +1 -2
  55. package/dist/index.esm2017.js +5421 -4355
  56. package/dist/index.esm2017.js.map +1 -1
  57. package/dist/index.esm5.js +5471 -4495
  58. package/dist/index.esm5.js.map +1 -1
  59. package/dist/index.node.cjs.js +3056 -1181
  60. package/dist/index.node.cjs.js.map +1 -1
  61. package/dist/index.node.mjs +3048 -1194
  62. package/dist/index.node.mjs.map +1 -1
  63. package/dist/index.rn.js +5469 -4445
  64. package/dist/index.rn.js.map +1 -1
  65. package/dist/internal.d.ts +272 -26
  66. package/dist/lite/firestore/src/api/credentials.d.ts +1 -0
  67. package/dist/lite/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  68. package/dist/lite/firestore/src/api/snapshot.d.ts +1 -2
  69. package/dist/lite/firestore/src/api.d.ts +1 -1
  70. package/dist/lite/firestore/src/core/database_info.d.ts +1 -0
  71. package/dist/lite/firestore/src/core/target.d.ts +34 -5
  72. package/dist/lite/firestore/src/index/index_byte_encoder.d.ts +18 -1
  73. package/dist/lite/firestore/src/index/index_entry.d.ts +32 -0
  74. package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
  75. package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +71 -0
  76. package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
  77. package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
  78. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
  79. package/dist/lite/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  80. package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  81. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +106 -437
  82. package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
  83. package/dist/lite/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
  84. package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -1
  85. package/dist/lite/firestore/src/local/local_serializer.d.ts +20 -3
  86. package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
  87. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
  88. package/dist/lite/firestore/src/local/memory_persistence.d.ts +6 -2
  89. package/dist/lite/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  90. package/dist/lite/firestore/src/local/persistence.d.ts +8 -2
  91. package/dist/lite/firestore/src/local/remote_document_cache.d.ts +7 -9
  92. package/dist/lite/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  93. package/dist/lite/firestore/src/local/simple_db.d.ts +12 -0
  94. package/dist/lite/firestore/src/model/collections.d.ts +7 -0
  95. package/dist/lite/firestore/src/model/document.d.ts +7 -0
  96. package/dist/lite/firestore/src/model/document_key.d.ts +6 -0
  97. package/dist/lite/firestore/src/model/field_index.d.ts +89 -7
  98. package/dist/lite/firestore/src/model/overlay.d.ts +32 -0
  99. package/dist/lite/firestore/src/model/target_index_matcher.d.ts +70 -0
  100. package/dist/lite/firestore/src/model/type_order.d.ts +2 -1
  101. package/dist/lite/firestore/src/model/values.d.ts +7 -0
  102. package/dist/lite/firestore/src/platform/node/base64.d.ts +1 -0
  103. package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  104. package/dist/lite/firestore/src/platform/node/load_protos.d.ts +2 -2
  105. package/dist/lite/firestore/src/util/obj_map.d.ts +3 -0
  106. package/dist/lite/firestore/src/util/sorted_set.d.ts +18 -0
  107. package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  108. package/dist/lite/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  109. package/dist/lite/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  110. package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  111. package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  112. package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  113. package/dist/lite/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  114. package/dist/lite/firestore/test/unit/model/field_index.test.d.ts +17 -0
  115. package/dist/lite/firestore/test/unit/model/target.test.d.ts +17 -0
  116. package/dist/lite/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  117. package/dist/lite/firestore/test/util/helpers.d.ts +8 -2
  118. package/dist/lite/index.browser.esm2017.js +1198 -1165
  119. package/dist/lite/index.browser.esm2017.js.map +1 -1
  120. package/dist/lite/index.browser.esm5.js +366 -357
  121. package/dist/lite/index.browser.esm5.js.map +1 -1
  122. package/dist/lite/index.node.cjs.js +83 -41
  123. package/dist/lite/index.node.cjs.js.map +1 -1
  124. package/dist/lite/index.node.mjs +83 -41
  125. package/dist/lite/index.node.mjs.map +1 -1
  126. package/dist/lite/index.rn.esm2017.js +375 -342
  127. package/dist/lite/index.rn.esm2017.js.map +1 -1
  128. package/dist/lite/internal.d.ts +16 -2
  129. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +122 -121
  130. package/dist/lite/packages/firestore/src/api/credentials.d.ts +1 -0
  131. package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  132. package/dist/lite/packages/firestore/src/api/snapshot.d.ts +1 -2
  133. package/dist/lite/packages/firestore/src/api.d.ts +1 -1
  134. package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
  135. package/dist/lite/packages/firestore/src/core/target.d.ts +34 -5
  136. package/dist/lite/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
  137. package/dist/lite/packages/firestore/src/index/index_entry.d.ts +32 -0
  138. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
  139. package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +71 -0
  140. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
  141. package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
  142. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
  143. package/dist/lite/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  144. package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  145. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +106 -437
  146. package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
  147. package/dist/lite/packages/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
  148. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  149. package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +20 -3
  150. package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
  151. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  152. package/dist/lite/packages/firestore/src/local/memory_persistence.d.ts +6 -2
  153. package/dist/lite/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  154. package/dist/lite/packages/firestore/src/local/persistence.d.ts +8 -2
  155. package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  156. package/dist/lite/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  157. package/dist/lite/packages/firestore/src/local/simple_db.d.ts +12 -0
  158. package/dist/lite/packages/firestore/src/model/collections.d.ts +7 -0
  159. package/dist/lite/packages/firestore/src/model/document.d.ts +7 -0
  160. package/dist/lite/packages/firestore/src/model/document_key.d.ts +6 -0
  161. package/dist/lite/packages/firestore/src/model/field_index.d.ts +89 -7
  162. package/dist/lite/packages/firestore/src/model/overlay.d.ts +32 -0
  163. package/dist/lite/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  164. package/dist/lite/packages/firestore/src/model/type_order.d.ts +2 -1
  165. package/dist/lite/packages/firestore/src/model/values.d.ts +7 -0
  166. package/dist/lite/packages/firestore/src/platform/node/base64.d.ts +1 -0
  167. package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  168. package/dist/lite/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
  169. package/dist/lite/packages/firestore/src/util/obj_map.d.ts +3 -0
  170. package/dist/lite/packages/firestore/src/util/sorted_set.d.ts +18 -0
  171. package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  172. package/dist/lite/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  173. package/dist/lite/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  174. package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  175. package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  176. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  177. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  178. package/dist/lite/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
  179. package/dist/lite/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  180. package/dist/lite/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  181. package/dist/lite/packages/firestore/test/util/helpers.d.ts +8 -2
  182. package/dist/lite/private.d.ts +9 -2
  183. package/dist/packages/firestore/dist/index.esm2017.d.ts +200 -195
  184. package/dist/packages/firestore/src/api/credentials.d.ts +1 -0
  185. package/dist/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  186. package/dist/packages/firestore/src/api/snapshot.d.ts +1 -2
  187. package/dist/packages/firestore/src/api.d.ts +1 -1
  188. package/dist/packages/firestore/src/core/database_info.d.ts +1 -0
  189. package/dist/packages/firestore/src/core/target.d.ts +34 -5
  190. package/dist/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
  191. package/dist/packages/firestore/src/index/index_entry.d.ts +32 -0
  192. package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
  193. package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +71 -0
  194. package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
  195. package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +44 -0
  196. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
  197. package/dist/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  198. package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  199. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +106 -437
  200. package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +238 -0
  201. package/dist/packages/firestore/src/local/indexeddb_target_cache.d.ts +2 -1
  202. package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  203. package/dist/packages/firestore/src/local/local_serializer.d.ts +20 -3
  204. package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +36 -0
  205. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  206. package/dist/packages/firestore/src/local/memory_persistence.d.ts +6 -2
  207. package/dist/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  208. package/dist/packages/firestore/src/local/persistence.d.ts +8 -2
  209. package/dist/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  210. package/dist/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  211. package/dist/packages/firestore/src/local/simple_db.d.ts +12 -0
  212. package/dist/packages/firestore/src/model/collections.d.ts +7 -0
  213. package/dist/packages/firestore/src/model/document.d.ts +7 -0
  214. package/dist/packages/firestore/src/model/document_key.d.ts +6 -0
  215. package/dist/packages/firestore/src/model/field_index.d.ts +89 -7
  216. package/dist/packages/firestore/src/model/overlay.d.ts +32 -0
  217. package/dist/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  218. package/dist/packages/firestore/src/model/type_order.d.ts +2 -1
  219. package/dist/packages/firestore/src/model/values.d.ts +7 -0
  220. package/dist/packages/firestore/src/platform/node/base64.d.ts +1 -0
  221. package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  222. package/dist/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
  223. package/dist/packages/firestore/src/util/obj_map.d.ts +3 -0
  224. package/dist/packages/firestore/src/util/sorted_set.d.ts +18 -0
  225. package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  226. package/dist/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  227. package/dist/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  228. package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  229. package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  230. package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  231. package/dist/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  232. package/dist/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
  233. package/dist/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  234. package/dist/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  235. package/dist/packages/firestore/test/util/helpers.d.ts +8 -2
  236. package/dist/private.d.ts +265 -26
  237. package/package.json +9 -9
package/dist/private.d.ts CHANGED
@@ -197,8 +197,8 @@ declare type BatchId = number;
197
197
  */
198
198
  declare class Bound {
199
199
  readonly position: Value[];
200
- readonly before: boolean;
201
- constructor(position: Value[], before: boolean);
200
+ readonly inclusive: boolean;
201
+ constructor(position: Value[], inclusive: boolean);
202
202
  }
203
203
 
204
204
  /**
@@ -757,6 +757,11 @@ declare interface Document_2 {
757
757
  * document was guaranteed to not exist.
758
758
  */
759
759
  readonly version: SnapshotVersion;
760
+ /**
761
+ * The timestamp at which this document was read from the remote server. Uses
762
+ * `SnapshotVersion.min()` for documents created by the user.
763
+ */
764
+ readonly readTime: SnapshotVersion;
760
765
  /** The underlying data of this document or an empty value if no data exists. */
761
766
  readonly data: ObjectValue;
762
767
  /** Returns whether local mutations were applied via the mutation queue. */
@@ -845,6 +850,56 @@ declare type DocumentKeySet = SortedSet<_DocumentKey>;
845
850
 
846
851
  declare type DocumentMap = SortedMap<_DocumentKey, Document_2>;
847
852
 
853
+ /**
854
+ * Provides methods to read and write document overlays.
855
+ *
856
+ * An overlay is a saved mutation, that gives a local view of a document when
857
+ * applied to the remote version of the document.
858
+ *
859
+ * Each overlay stores the largest batch ID that is included in the overlay,
860
+ * which allows us to remove the overlay once all batches leading up to it have
861
+ * been acknowledged.
862
+ */
863
+ declare interface DocumentOverlayCache {
864
+ /**
865
+ * Gets the saved overlay mutation for the given document key.
866
+ * Returns null if there is no overlay for that key.
867
+ */
868
+ getOverlay(transaction: PersistenceTransaction, key: _DocumentKey): PersistencePromise<Overlay | null>;
869
+ /**
870
+ * Saves the given document mutation map to persistence as overlays.
871
+ * All overlays will have their largest batch id set to `largestBatchId`.
872
+ */
873
+ saveOverlays(transaction: PersistenceTransaction, largestBatchId: number, overlays: MutationMap): PersistencePromise<void>;
874
+ /** Removes overlays for the given document keys and batch ID. */
875
+ removeOverlaysForBatchId(transaction: PersistenceTransaction, documentKeys: DocumentKeySet, batchId: number): PersistencePromise<void>;
876
+ /**
877
+ * Returns all saved overlays for the given collection.
878
+ *
879
+ * @param transaction - The persistence transaction to use for this operation.
880
+ * @param collection - The collection path to get the overlays for.
881
+ * @param sinceBatchId - The minimum batch ID to filter by (exclusive).
882
+ * Only overlays that contain a change past `sinceBatchId` are returned.
883
+ * @returns Mapping of each document key in the collection to its overlay.
884
+ */
885
+ getOverlaysForCollection(transaction: PersistenceTransaction, collection: _ResourcePath, sinceBatchId: number): PersistencePromise<OverlayMap>;
886
+ /**
887
+ * Returns `count` overlays with a batch ID higher than `sinceBatchId` for the
888
+ * provided collection group, processed by ascending batch ID. The method
889
+ * always returns all overlays for a batch even if the last batch contains
890
+ * more documents than the remaining limit.
891
+ *
892
+ * @param transaction - The persistence transaction used for this operation.
893
+ * @param collectionGroup - The collection group to get the overlays for.
894
+ * @param sinceBatchId - The minimum batch ID to filter by (exclusive).
895
+ * Only overlays that contain a change past `sinceBatchId` are returned.
896
+ * @param count - The number of overlays to return. Can be exceeded if the last
897
+ * batch contains more entries.
898
+ * @return Mapping of each document key in the collection group to its overlay.
899
+ */
900
+ getOverlaysForCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, sinceBatchId: number, count: number): PersistencePromise<OverlayMap>;
901
+ }
902
+
848
903
  /**
849
904
  * A `DocumentReference` refers to a document location in a Firestore database
850
905
  * and can be used to write, read, or listen to the location. The document at
@@ -962,8 +1017,7 @@ export declare class DocumentSnapshot<T = DocumentData> extends DocumentSnapshot
962
1017
  /** @hideconstructor protected */
963
1018
  constructor(_firestore: Firestore, userDataWriter: AbstractUserDataWriter, key: _DocumentKey, document: Document_2 | null, metadata: SnapshotMetadata, converter: UntypedFirestoreDataConverter<T> | null);
964
1019
  /**
965
- * Property of the `DocumentSnapshot` that signals whether or not the data
966
- * exists. True if the document exists.
1020
+ * Returns whether or not the data exists. True if the document exists.
967
1021
  */
968
1022
  exists(): this is QueryDocumentSnapshot<T>;
969
1023
  /**
@@ -1187,6 +1241,45 @@ declare interface EventManager {
1187
1241
 
1188
1242
  declare type FieldFilterOp = 'OPERATOR_UNSPECIFIED' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUAL' | 'EQUAL' | 'NOT_EQUAL' | 'ARRAY_CONTAINS' | 'IN' | 'ARRAY_CONTAINS_ANY' | 'NOT_IN';
1189
1243
 
1244
+ /**
1245
+ * An index definition for field indexes in Firestore.
1246
+ *
1247
+ * Every index is associated with a collection. The definition contains a list
1248
+ * of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
1249
+ * `CONTAINS` for ArrayContains/ArrayContainsAny queries).
1250
+ *
1251
+ * Unlike the backend, the SDK does not differentiate between collection or
1252
+ * collection group-scoped indices. Every index can be used for both single
1253
+ * collection and collection group queries.
1254
+ */
1255
+ declare class FieldIndex {
1256
+ /**
1257
+ * The index ID. Returns -1 if the index ID is not available (e.g. the index
1258
+ * has not yet been persisted).
1259
+ */
1260
+ readonly indexId: number;
1261
+ /** The collection ID this index applies to. */
1262
+ readonly collectionGroup: string;
1263
+ /** The field segments for this index. */
1264
+ readonly fields: IndexSegment[];
1265
+ /** Shows how up-to-date the index is for the current user. */
1266
+ readonly indexState: IndexState_2;
1267
+ /** An ID for an index that has not yet been added to persistence. */
1268
+ static UNKNOWN_ID: number;
1269
+ constructor(
1270
+ /**
1271
+ * The index ID. Returns -1 if the index ID is not available (e.g. the index
1272
+ * has not yet been persisted).
1273
+ */
1274
+ indexId: number,
1275
+ /** The collection ID this index applies to. */
1276
+ collectionGroup: string,
1277
+ /** The field segments for this index. */
1278
+ fields: IndexSegment[],
1279
+ /** Shows how up-to-date the index is for the current user. */
1280
+ indexState: IndexState_2);
1281
+ }
1282
+
1190
1283
  /**
1191
1284
  * Provides a set of fields that can be used to partially patch a document.
1192
1285
  * FieldMask is used in conjunction with ObjectValue.
@@ -2149,6 +2242,20 @@ export declare function increment(n: number): FieldValue;
2149
2242
 
2150
2243
  declare type IndexFieldMode = 'MODE_UNSPECIFIED' | 'ASCENDING' | 'DESCENDING';
2151
2244
 
2245
+ /** The type of the index, e.g. for which type of query it can be used. */
2246
+ declare const enum IndexKind {
2247
+ /**
2248
+ * Ordered index. Can be used for <, <=, ==, >=, >, !=, IN and NOT IN queries.
2249
+ */
2250
+ ASCENDING = 0,
2251
+ /**
2252
+ * Ordered index. Can be used for <, <=, ==, >=, >, !=, IN and NOT IN queries.
2253
+ */
2254
+ DESCENDING = 1,
2255
+ /** Contains index. Can be used for ArrayContains and ArrayContainsAny. */
2256
+ CONTAINS = 2
2257
+ }
2258
+
2152
2259
  /**
2153
2260
  * Represents a set of indexes that are used to execute queries efficiently.
2154
2261
  *
@@ -2172,10 +2279,125 @@ declare interface IndexManager {
2172
2279
  * path for a root-level collection).
2173
2280
  */
2174
2281
  getCollectionParents(transaction: PersistenceTransaction, collectionId: string): PersistencePromise<_ResourcePath[]>;
2282
+ /**
2283
+ * Adds a field path index.
2284
+ *
2285
+ * Values for this index are persisted via the index backfill, which runs
2286
+ * asynchronously in the background. Once the first values are written,
2287
+ * an index can be used to serve partial results for any matching queries.
2288
+ * Any unindexed portion of the database will continue to be served via
2289
+ * collection scons.
2290
+ */
2291
+ addFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
2292
+ /** Removes the given field index and deletes all index values. */
2293
+ deleteFieldIndex(transaction: PersistenceTransaction, index: FieldIndex): PersistencePromise<void>;
2294
+ /**
2295
+ * Returns a list of field indexes that correspond to the specified collection
2296
+ * group.
2297
+ *
2298
+ * @param collectionGroup The collection group to get matching field indexes
2299
+ * for.
2300
+ * @return A collection of field indexes for the specified collection group.
2301
+ */
2302
+ getFieldIndexes(transaction: PersistenceTransaction, collectionGroup: string): PersistencePromise<FieldIndex[]>;
2303
+ /** Returns all configured field indexes. */
2304
+ getFieldIndexes(transaction: PersistenceTransaction): PersistencePromise<FieldIndex[]>;
2305
+ /**
2306
+ * Returns an index that can be used to serve the provided target. Returns
2307
+ * `null` if no index is configured.
2308
+ */
2309
+ getFieldIndex(transaction: PersistenceTransaction, target: Target): PersistencePromise<FieldIndex | null>;
2310
+ /**
2311
+ * Returns the documents that match the given target based on the provided
2312
+ * index or `null` if the target does not have a matching index.
2313
+ */
2314
+ getDocumentsMatchingTarget(transaction: PersistenceTransaction, target: Target): PersistencePromise<DocumentKeySet | null>;
2315
+ /**
2316
+ * Returns the next collection group to update. Returns `null` if no group
2317
+ * exists.
2318
+ */
2319
+ getNextCollectionGroupToUpdate(transaction: PersistenceTransaction): PersistencePromise<string | null>;
2320
+ /**
2321
+ * Sets the collection group's latest read time.
2322
+ *
2323
+ * This method updates the index offset for all field indices for the
2324
+ * collection group and increments their sequence number. Subsequent calls to
2325
+ * `getNextCollectionGroupToUpdate()` will return a different collection group
2326
+ * (unless only one collection group is configured).
2327
+ */
2328
+ updateCollectionGroup(transaction: PersistenceTransaction, collectionGroup: string, offset: IndexOffset): PersistencePromise<void>;
2329
+ /** Updates the index entries for the provided documents. */
2330
+ updateIndexEntries(transaction: PersistenceTransaction, documents: DocumentMap): PersistencePromise<void>;
2331
+ }
2332
+
2333
+ /**
2334
+ * Stores the latest read time, document and batch ID that were processed for an
2335
+ * index.
2336
+ */
2337
+ declare class IndexOffset {
2338
+ /**
2339
+ * The latest read time version that has been indexed by Firestore for this
2340
+ * field index.
2341
+ */
2342
+ readonly readTime: SnapshotVersion;
2343
+ /**
2344
+ * The key of the last document that was indexed for this query. Use
2345
+ * `DocumentKey.empty()` if no document has been indexed.
2346
+ */
2347
+ readonly documentKey: _DocumentKey;
2348
+ readonly largestBatchId: number;
2349
+ constructor(
2350
+ /**
2351
+ * The latest read time version that has been indexed by Firestore for this
2352
+ * field index.
2353
+ */
2354
+ readTime: SnapshotVersion,
2355
+ /**
2356
+ * The key of the last document that was indexed for this query. Use
2357
+ * `DocumentKey.empty()` if no document has been indexed.
2358
+ */
2359
+ documentKey: _DocumentKey, largestBatchId: number);
2360
+ /** The state of an index that has not yet been backfilled. */
2361
+ static min(): IndexOffset;
2362
+ }
2363
+
2364
+ /** An index component consisting of field path and index type. */
2365
+ declare class IndexSegment {
2366
+ /** The field path of the component. */
2367
+ readonly fieldPath: _FieldPath;
2368
+ /** The fields sorting order. */
2369
+ readonly kind: IndexKind;
2370
+ constructor(
2371
+ /** The field path of the component. */
2372
+ fieldPath: _FieldPath,
2373
+ /** The fields sorting order. */
2374
+ kind: IndexKind);
2175
2375
  }
2176
2376
 
2177
2377
  declare type IndexState = 'STATE_UNSPECIFIED' | 'CREATING' | 'READY' | 'ERROR';
2178
2378
 
2379
+ /**
2380
+ * Stores the "high water mark" that indicates how updated the Index is for the
2381
+ * current user.
2382
+ */
2383
+ declare class IndexState_2 {
2384
+ /**
2385
+ * Indicates when the index was last updated (relative to other indexes).
2386
+ */
2387
+ readonly sequenceNumber: number;
2388
+ /** The the latest indexed read time, document and batch id. */
2389
+ readonly offset: IndexOffset;
2390
+ constructor(
2391
+ /**
2392
+ * Indicates when the index was last updated (relative to other indexes).
2393
+ */
2394
+ sequenceNumber: number,
2395
+ /** The the latest indexed read time, document and batch id. */
2396
+ offset: IndexOffset);
2397
+ /** The state of an index that has not yet been backfilled. */
2398
+ static empty(): IndexState_2;
2399
+ }
2400
+
2179
2401
  /**
2180
2402
  * Initializes a new instance of {@link Firestore} with the provided settings.
2181
2403
  * Can only be called before any other function, including
@@ -2425,6 +2647,7 @@ declare class MutableDocument implements Document_2 {
2425
2647
  readonly key: _DocumentKey;
2426
2648
  private documentType;
2427
2649
  version: SnapshotVersion;
2650
+ readTime: SnapshotVersion;
2428
2651
  data: ObjectValue;
2429
2652
  private documentState;
2430
2653
  private constructor();
@@ -2464,6 +2687,7 @@ declare class MutableDocument implements Document_2 {
2464
2687
  convertToUnknownDocument(version: SnapshotVersion): MutableDocument;
2465
2688
  setHasCommittedMutations(): MutableDocument;
2466
2689
  setHasLocalMutations(): MutableDocument;
2690
+ setReadTime(readTime: SnapshotVersion): MutableDocument;
2467
2691
  get hasLocalMutations(): boolean;
2468
2692
  get hasCommittedMutations(): boolean;
2469
2693
  get hasPendingWrites(): boolean;
@@ -2594,6 +2818,8 @@ declare class MutationBatchResult {
2594
2818
  static from(batch: MutationBatch, commitVersion: SnapshotVersion, results: MutationResult[]): MutationBatchResult;
2595
2819
  }
2596
2820
 
2821
+ declare type MutationMap = ObjectMap<_DocumentKey, Mutation>;
2822
+
2597
2823
  /** A queue of mutations to apply to the remote store. */
2598
2824
  declare interface MutationQueue {
2599
2825
  /** Returns true if this queue contains no mutation batches. */
@@ -2820,6 +3046,8 @@ declare class ObjectMap<KeyType, ValueType> {
2820
3046
  * constant time lookups in practice.
2821
3047
  */
2822
3048
  private inner;
3049
+ /** The number of entries stored in the map */
3050
+ private innerSize;
2823
3051
  constructor(mapKeyFn: (key: KeyType) => string, equalsFn: (l: KeyType, r: KeyType) => boolean);
2824
3052
  /** Get a value for this key, or undefined if it does not exist. */
2825
3053
  get(key: KeyType): ValueType | undefined;
@@ -2832,6 +3060,7 @@ declare class ObjectMap<KeyType, ValueType> {
2832
3060
  delete(key: KeyType): boolean;
2833
3061
  forEach(fn: (key: KeyType, val: ValueType) => void): void;
2834
3062
  isEmpty(): boolean;
3063
+ size(): number;
2835
3064
  }
2836
3065
 
2837
3066
  /**
@@ -3183,6 +3412,23 @@ export declare type OrderByDirection = 'desc' | 'asc';
3183
3412
 
3184
3413
  declare type OrderDirection = 'DIRECTION_UNSPECIFIED' | 'ASCENDING' | 'DESCENDING';
3185
3414
 
3415
+ /**
3416
+ * Representation of an overlay computed by Firestore.
3417
+ *
3418
+ * Holds information about a mutation and the largest batch id in Firestore when
3419
+ * the mutation was created.
3420
+ */
3421
+ declare class Overlay {
3422
+ readonly largestBatchId: number;
3423
+ readonly mutation: Mutation;
3424
+ constructor(largestBatchId: number, mutation: Mutation);
3425
+ getKey(): _DocumentKey;
3426
+ isEqual(other: Overlay | null): boolean;
3427
+ toString(): string;
3428
+ }
3429
+
3430
+ declare type OverlayMap = ObjectMap<_DocumentKey, Overlay>;
3431
+
3186
3432
  declare interface ParseContext {
3187
3433
  readonly databaseId: _DatabaseId;
3188
3434
  readonly ignoreUndefinedProperties: boolean;
@@ -3286,7 +3532,7 @@ declare interface Persistence {
3286
3532
  * extent possible (e.g. in the case of uid switching from
3287
3533
  * sally=&gt;jack=&gt;sally, sally's mutation queue will be preserved).
3288
3534
  */
3289
- getMutationQueue(user: User): MutationQueue;
3535
+ getMutationQueue(user: User, indexManager: IndexManager): MutationQueue;
3290
3536
  /**
3291
3537
  * Returns a TargetCache representing the persisted cache of targets.
3292
3538
  *
@@ -3319,7 +3565,12 @@ declare interface Persistence {
3319
3565
  * this is called. In particular, the memory-backed implementation does this
3320
3566
  * to emulate the persisted implementation to the extent possible.
3321
3567
  */
3322
- getIndexManager(): IndexManager;
3568
+ getIndexManager(user: User): IndexManager;
3569
+ /**
3570
+ * Returns a DocumentOverlayCache representing the documents that are mutated
3571
+ * locally.
3572
+ */
3573
+ getDocumentOverlayCache(user: User): DocumentOverlayCache;
3323
3574
  /**
3324
3575
  * Performs an operation inside a persistence transaction. Any reads or writes
3325
3576
  * against persistence must be performed within a transaction. Writes will be
@@ -3730,6 +3981,8 @@ declare type Rejector = (error: Error) => void;
3730
3981
  * documents that are known to not exist.
3731
3982
  */
3732
3983
  declare interface RemoteDocumentCache {
3984
+ /** Sets the index manager to use for managing the collectionGroup index. */
3985
+ setIndexManager(indexManager: IndexManager): void;
3733
3986
  /**
3734
3987
  * Looks up an entry in the cache.
3735
3988
  *
@@ -3747,19 +4000,14 @@ declare interface RemoteDocumentCache {
3747
4000
  */
3748
4001
  getEntries(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
3749
4002
  /**
3750
- * Executes a query against the cached Document entries.
3751
- *
3752
- * Implementations may return extra documents if convenient. The results
3753
- * should be re-filtered by the consumer before presenting them to the user.
4003
+ * Returns the documents from the provided collection.
3754
4004
  *
3755
- * Cached NoDocument entries have no bearing on query results.
3756
- *
3757
- * @param query - The query to match documents against.
4005
+ * @param collection - The collection to read.
3758
4006
  * @param sinceReadTime - If not set to SnapshotVersion.min(), return only
3759
4007
  * documents that have been read since this snapshot version (exclusive).
3760
4008
  * @returns The set of matching documents.
3761
4009
  */
3762
- getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query_2, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
4010
+ getAll(transaction: PersistenceTransaction, collection: _ResourcePath, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
3763
4011
  /**
3764
4012
  * Provides access to add or update the contents of the cache. The buffer
3765
4013
  * handles proper size accounting for the change.
@@ -3780,14 +4028,6 @@ declare interface RemoteDocumentCache {
3780
4028
  getSize(transaction: PersistenceTransaction): PersistencePromise<number>;
3781
4029
  }
3782
4030
 
3783
- /**
3784
- * Represents a document change to be applied to remote document cache.
3785
- */
3786
- declare interface RemoteDocumentChange {
3787
- readonly document: MutableDocument;
3788
- readonly readTime: SnapshotVersion | null;
3789
- }
3790
-
3791
4031
  /**
3792
4032
  * An in-memory buffer of entries to be written to a RemoteDocumentCache.
3793
4033
  * It can be used to batch up a set of changes to be written to the cache, but
@@ -3803,26 +4043,25 @@ declare interface RemoteDocumentChange {
3803
4043
  * porting this class as part of that implementation work.
3804
4044
  */
3805
4045
  declare abstract class RemoteDocumentChangeBuffer {
3806
- protected changes: ObjectMap<_DocumentKey, RemoteDocumentChange>;
4046
+ protected changes: ObjectMap<_DocumentKey, MutableDocument>;
3807
4047
  private changesApplied;
3808
4048
  protected abstract getFromCache(transaction: PersistenceTransaction, documentKey: _DocumentKey): PersistencePromise<MutableDocument>;
3809
4049
  protected abstract getAllFromCache(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
3810
4050
  protected abstract applyChanges(transaction: PersistenceTransaction): PersistencePromise<void>;
3811
- protected getReadTime(key: _DocumentKey): SnapshotVersion;
3812
4051
  /**
3813
4052
  * Buffers a `RemoteDocumentCache.addEntry()` call.
3814
4053
  *
3815
4054
  * You can only modify documents that have already been retrieved via
3816
4055
  * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
3817
4056
  */
3818
- addEntry(document: MutableDocument, readTime: SnapshotVersion): void;
4057
+ addEntry(document: MutableDocument): void;
3819
4058
  /**
3820
4059
  * Buffers a `RemoteDocumentCache.removeEntry()` call.
3821
4060
  *
3822
4061
  * You can only remove documents that have already been retrieved via
3823
4062
  * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
3824
4063
  */
3825
- removeEntry(key: _DocumentKey, readTime?: SnapshotVersion | null): void;
4064
+ removeEntry(key: _DocumentKey, readTime: SnapshotVersion): void;
3826
4065
  /**
3827
4066
  * Looks up an entry in the cache. The buffered changes will first be checked,
3828
4067
  * and if no buffered change applies, this will forward to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase/firestore",
3
- "version": "3.4.4",
3
+ "version": "3.4.5-canary.09e62431f",
4
4
  "engines": {
5
5
  "node": ">=10.10.0"
6
6
  },
@@ -77,22 +77,22 @@
77
77
  "lite/package.json"
78
78
  ],
79
79
  "dependencies": {
80
- "@firebase/component": "0.5.10",
81
- "@firebase/logger": "0.3.2",
82
- "@firebase/util": "1.4.3",
83
- "@firebase/webchannel-wrapper": "0.6.1",
80
+ "@firebase/component": "0.5.10-canary.09e62431f",
81
+ "@firebase/logger": "0.3.2-canary.09e62431f",
82
+ "@firebase/util": "1.4.3-canary.09e62431f",
83
+ "@firebase/webchannel-wrapper": "0.6.1-canary.09e62431f",
84
84
  "@grpc/grpc-js": "^1.3.2",
85
85
  "@grpc/proto-loader": "^0.6.0",
86
86
  "node-fetch": "2.6.7",
87
87
  "tslib": "^2.1.0"
88
88
  },
89
89
  "peerDependencies": {
90
- "@firebase/app": "0.x"
90
+ "@firebase/app": "0.7.17-canary.09e62431f"
91
91
  },
92
92
  "devDependencies": {
93
- "@firebase/app": "0.7.15",
94
- "@firebase/app-compat": "0.1.16",
95
- "@firebase/auth": "0.19.7",
93
+ "@firebase/app": "0.7.17-canary.09e62431f",
94
+ "@firebase/app-compat": "0.1.18-canary.09e62431f",
95
+ "@firebase/auth": "0.19.9-canary.09e62431f",
96
96
  "@rollup/plugin-alias": "3.1.5",
97
97
  "@rollup/plugin-json": "4.1.0",
98
98
  "@types/eslint": "7.28.0",