@firebase/firestore 3.4.4 → 3.4.5-canary.8ac8fb099

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 (221) 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 +72 -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 +45 -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 +195 -7
  18. package/dist/firestore/src/local/local_documents_view.d.ts +0 -1
  19. package/dist/firestore/src/local/local_serializer.d.ts +19 -3
  20. package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  21. package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
  22. package/dist/firestore/src/local/memory_persistence.d.ts +6 -2
  23. package/dist/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  24. package/dist/firestore/src/local/persistence.d.ts +8 -2
  25. package/dist/firestore/src/local/remote_document_cache.d.ts +7 -9
  26. package/dist/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  27. package/dist/firestore/src/local/simple_db.d.ts +12 -0
  28. package/dist/firestore/src/model/document.d.ts +7 -0
  29. package/dist/firestore/src/model/document_key.d.ts +6 -0
  30. package/dist/firestore/src/model/field_index.d.ts +89 -7
  31. package/dist/firestore/src/model/overlay.d.ts +32 -0
  32. package/dist/firestore/src/model/target_index_matcher.d.ts +70 -0
  33. package/dist/firestore/src/model/type_order.d.ts +2 -1
  34. package/dist/firestore/src/model/values.d.ts +7 -0
  35. package/dist/firestore/src/platform/node/base64.d.ts +1 -0
  36. package/dist/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  37. package/dist/firestore/src/platform/node/load_protos.d.ts +2 -2
  38. package/dist/firestore/src/util/sorted_set.d.ts +18 -0
  39. package/dist/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  40. package/dist/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  41. package/dist/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  42. package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  43. package/dist/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  44. package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  45. package/dist/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  46. package/dist/firestore/test/unit/model/field_index.test.d.ts +17 -0
  47. package/dist/firestore/test/unit/model/target.test.d.ts +17 -0
  48. package/dist/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  49. package/dist/firestore/test/util/helpers.d.ts +8 -2
  50. package/dist/index.d.ts +1 -2
  51. package/dist/index.esm2017.js +5415 -3839
  52. package/dist/index.esm2017.js.map +1 -1
  53. package/dist/index.esm5.js +5039 -3613
  54. package/dist/index.esm5.js.map +1 -1
  55. package/dist/index.node.cjs.js +2908 -592
  56. package/dist/index.node.cjs.js.map +1 -1
  57. package/dist/index.node.mjs +2888 -593
  58. package/dist/index.node.mjs.map +1 -1
  59. package/dist/index.rn.js +5396 -3862
  60. package/dist/index.rn.js.map +1 -1
  61. package/dist/internal.d.ts +265 -26
  62. package/dist/lite/firestore/src/api/credentials.d.ts +1 -0
  63. package/dist/lite/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  64. package/dist/lite/firestore/src/api/snapshot.d.ts +1 -2
  65. package/dist/lite/firestore/src/api.d.ts +1 -1
  66. package/dist/lite/firestore/src/core/database_info.d.ts +1 -0
  67. package/dist/lite/firestore/src/core/target.d.ts +34 -5
  68. package/dist/lite/firestore/src/index/index_byte_encoder.d.ts +18 -1
  69. package/dist/lite/firestore/src/index/index_entry.d.ts +32 -0
  70. package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
  71. package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +72 -0
  72. package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
  73. package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  74. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
  75. package/dist/lite/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  76. package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  77. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +195 -7
  78. package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -1
  79. package/dist/lite/firestore/src/local/local_serializer.d.ts +19 -3
  80. package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  81. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
  82. package/dist/lite/firestore/src/local/memory_persistence.d.ts +6 -2
  83. package/dist/lite/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  84. package/dist/lite/firestore/src/local/persistence.d.ts +8 -2
  85. package/dist/lite/firestore/src/local/remote_document_cache.d.ts +7 -9
  86. package/dist/lite/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  87. package/dist/lite/firestore/src/local/simple_db.d.ts +12 -0
  88. package/dist/lite/firestore/src/model/document.d.ts +7 -0
  89. package/dist/lite/firestore/src/model/document_key.d.ts +6 -0
  90. package/dist/lite/firestore/src/model/field_index.d.ts +89 -7
  91. package/dist/lite/firestore/src/model/overlay.d.ts +32 -0
  92. package/dist/lite/firestore/src/model/target_index_matcher.d.ts +70 -0
  93. package/dist/lite/firestore/src/model/type_order.d.ts +2 -1
  94. package/dist/lite/firestore/src/model/values.d.ts +7 -0
  95. package/dist/lite/firestore/src/platform/node/base64.d.ts +1 -0
  96. package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  97. package/dist/lite/firestore/src/platform/node/load_protos.d.ts +2 -2
  98. package/dist/lite/firestore/src/util/sorted_set.d.ts +18 -0
  99. package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  100. package/dist/lite/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  101. package/dist/lite/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  102. package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  103. package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  104. package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  105. package/dist/lite/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  106. package/dist/lite/firestore/test/unit/model/field_index.test.d.ts +17 -0
  107. package/dist/lite/firestore/test/unit/model/target.test.d.ts +17 -0
  108. package/dist/lite/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  109. package/dist/lite/firestore/test/util/helpers.d.ts +8 -2
  110. package/dist/lite/index.browser.esm2017.js +1207 -1174
  111. package/dist/lite/index.browser.esm2017.js.map +1 -1
  112. package/dist/lite/index.browser.esm5.js +370 -361
  113. package/dist/lite/index.browser.esm5.js.map +1 -1
  114. package/dist/lite/index.node.cjs.js +83 -41
  115. package/dist/lite/index.node.cjs.js.map +1 -1
  116. package/dist/lite/index.node.mjs +83 -41
  117. package/dist/lite/index.node.mjs.map +1 -1
  118. package/dist/lite/index.rn.esm2017.js +375 -342
  119. package/dist/lite/index.rn.esm2017.js.map +1 -1
  120. package/dist/lite/internal.d.ts +16 -2
  121. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +125 -124
  122. package/dist/lite/packages/firestore/src/api/credentials.d.ts +1 -0
  123. package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  124. package/dist/lite/packages/firestore/src/api/snapshot.d.ts +1 -2
  125. package/dist/lite/packages/firestore/src/api.d.ts +1 -1
  126. package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
  127. package/dist/lite/packages/firestore/src/core/target.d.ts +34 -5
  128. package/dist/lite/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
  129. package/dist/lite/packages/firestore/src/index/index_entry.d.ts +32 -0
  130. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
  131. package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +72 -0
  132. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
  133. package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  134. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
  135. package/dist/lite/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  136. package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  137. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +195 -7
  138. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  139. package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +19 -3
  140. package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  141. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  142. package/dist/lite/packages/firestore/src/local/memory_persistence.d.ts +6 -2
  143. package/dist/lite/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  144. package/dist/lite/packages/firestore/src/local/persistence.d.ts +8 -2
  145. package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  146. package/dist/lite/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  147. package/dist/lite/packages/firestore/src/local/simple_db.d.ts +12 -0
  148. package/dist/lite/packages/firestore/src/model/document.d.ts +7 -0
  149. package/dist/lite/packages/firestore/src/model/document_key.d.ts +6 -0
  150. package/dist/lite/packages/firestore/src/model/field_index.d.ts +89 -7
  151. package/dist/lite/packages/firestore/src/model/overlay.d.ts +32 -0
  152. package/dist/lite/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  153. package/dist/lite/packages/firestore/src/model/type_order.d.ts +2 -1
  154. package/dist/lite/packages/firestore/src/model/values.d.ts +7 -0
  155. package/dist/lite/packages/firestore/src/platform/node/base64.d.ts +1 -0
  156. package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  157. package/dist/lite/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
  158. package/dist/lite/packages/firestore/src/util/sorted_set.d.ts +18 -0
  159. package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  160. package/dist/lite/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  161. package/dist/lite/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  162. package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  163. package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  164. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  165. package/dist/lite/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  166. package/dist/lite/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
  167. package/dist/lite/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  168. package/dist/lite/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  169. package/dist/lite/packages/firestore/test/util/helpers.d.ts +8 -2
  170. package/dist/lite/private.d.ts +9 -2
  171. package/dist/packages/firestore/dist/index.esm2017.d.ts +199 -194
  172. package/dist/packages/firestore/src/api/credentials.d.ts +1 -0
  173. package/dist/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  174. package/dist/packages/firestore/src/api/snapshot.d.ts +1 -2
  175. package/dist/packages/firestore/src/api.d.ts +1 -1
  176. package/dist/packages/firestore/src/core/database_info.d.ts +1 -0
  177. package/dist/packages/firestore/src/core/target.d.ts +34 -5
  178. package/dist/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
  179. package/dist/packages/firestore/src/index/index_entry.d.ts +32 -0
  180. package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
  181. package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +72 -0
  182. package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
  183. package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
  184. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +87 -2
  185. package/dist/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
  186. package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
  187. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +195 -7
  188. package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -1
  189. package/dist/packages/firestore/src/local/local_serializer.d.ts +19 -3
  190. package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
  191. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  192. package/dist/packages/firestore/src/local/memory_persistence.d.ts +6 -2
  193. package/dist/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
  194. package/dist/packages/firestore/src/local/persistence.d.ts +8 -2
  195. package/dist/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
  196. package/dist/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
  197. package/dist/packages/firestore/src/local/simple_db.d.ts +12 -0
  198. package/dist/packages/firestore/src/model/document.d.ts +7 -0
  199. package/dist/packages/firestore/src/model/document_key.d.ts +6 -0
  200. package/dist/packages/firestore/src/model/field_index.d.ts +89 -7
  201. package/dist/packages/firestore/src/model/overlay.d.ts +32 -0
  202. package/dist/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
  203. package/dist/packages/firestore/src/model/type_order.d.ts +2 -1
  204. package/dist/packages/firestore/src/model/values.d.ts +7 -0
  205. package/dist/packages/firestore/src/platform/node/base64.d.ts +1 -0
  206. package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
  207. package/dist/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
  208. package/dist/packages/firestore/src/util/sorted_set.d.ts +18 -0
  209. package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
  210. package/dist/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
  211. package/dist/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
  212. package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
  213. package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
  214. package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +5 -3
  215. package/dist/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
  216. package/dist/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
  217. package/dist/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  218. package/dist/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
  219. package/dist/packages/firestore/test/util/helpers.d.ts +8 -2
  220. package/dist/private.d.ts +258 -26
  221. 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: Map<_DocumentKey, Mutation>): 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<Map<_DocumentKey, Overlay>>;
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<Map<_DocumentKey, Overlay>>;
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;
@@ -3183,6 +3407,21 @@ export declare type OrderByDirection = 'desc' | 'asc';
3183
3407
 
3184
3408
  declare type OrderDirection = 'DIRECTION_UNSPECIFIED' | 'ASCENDING' | 'DESCENDING';
3185
3409
 
3410
+ /**
3411
+ * Representation of an overlay computed by Firestore.
3412
+ *
3413
+ * Holds information about a mutation and the largest batch id in Firestore when
3414
+ * the mutation was created.
3415
+ */
3416
+ declare class Overlay {
3417
+ readonly largestBatchId: number;
3418
+ readonly mutation: Mutation;
3419
+ constructor(largestBatchId: number, mutation: Mutation);
3420
+ getKey(): _DocumentKey;
3421
+ isEqual(other: Overlay | null): boolean;
3422
+ toString(): string;
3423
+ }
3424
+
3186
3425
  declare interface ParseContext {
3187
3426
  readonly databaseId: _DatabaseId;
3188
3427
  readonly ignoreUndefinedProperties: boolean;
@@ -3286,7 +3525,7 @@ declare interface Persistence {
3286
3525
  * extent possible (e.g. in the case of uid switching from
3287
3526
  * sally=&gt;jack=&gt;sally, sally's mutation queue will be preserved).
3288
3527
  */
3289
- getMutationQueue(user: User): MutationQueue;
3528
+ getMutationQueue(user: User, indexManager: IndexManager): MutationQueue;
3290
3529
  /**
3291
3530
  * Returns a TargetCache representing the persisted cache of targets.
3292
3531
  *
@@ -3319,7 +3558,12 @@ declare interface Persistence {
3319
3558
  * this is called. In particular, the memory-backed implementation does this
3320
3559
  * to emulate the persisted implementation to the extent possible.
3321
3560
  */
3322
- getIndexManager(): IndexManager;
3561
+ getIndexManager(user: User): IndexManager;
3562
+ /**
3563
+ * Returns a DocumentOverlayCache representing the documents that are mutated
3564
+ * locally.
3565
+ */
3566
+ getDocumentOverlayCache(user: User): DocumentOverlayCache;
3323
3567
  /**
3324
3568
  * Performs an operation inside a persistence transaction. Any reads or writes
3325
3569
  * against persistence must be performed within a transaction. Writes will be
@@ -3730,6 +3974,8 @@ declare type Rejector = (error: Error) => void;
3730
3974
  * documents that are known to not exist.
3731
3975
  */
3732
3976
  declare interface RemoteDocumentCache {
3977
+ /** Sets the index manager to use for managing the collectionGroup index. */
3978
+ setIndexManager(indexManager: IndexManager): void;
3733
3979
  /**
3734
3980
  * Looks up an entry in the cache.
3735
3981
  *
@@ -3747,19 +3993,14 @@ declare interface RemoteDocumentCache {
3747
3993
  */
3748
3994
  getEntries(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
3749
3995
  /**
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.
3996
+ * Returns the documents from the provided collection.
3754
3997
  *
3755
- * Cached NoDocument entries have no bearing on query results.
3756
- *
3757
- * @param query - The query to match documents against.
3998
+ * @param collection - The collection to read.
3758
3999
  * @param sinceReadTime - If not set to SnapshotVersion.min(), return only
3759
4000
  * documents that have been read since this snapshot version (exclusive).
3760
4001
  * @returns The set of matching documents.
3761
4002
  */
3762
- getDocumentsMatchingQuery(transaction: PersistenceTransaction, query: Query_2, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
4003
+ getAll(transaction: PersistenceTransaction, collection: _ResourcePath, sinceReadTime: SnapshotVersion): PersistencePromise<MutableDocumentMap>;
3763
4004
  /**
3764
4005
  * Provides access to add or update the contents of the cache. The buffer
3765
4006
  * handles proper size accounting for the change.
@@ -3780,14 +4021,6 @@ declare interface RemoteDocumentCache {
3780
4021
  getSize(transaction: PersistenceTransaction): PersistencePromise<number>;
3781
4022
  }
3782
4023
 
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
4024
  /**
3792
4025
  * An in-memory buffer of entries to be written to a RemoteDocumentCache.
3793
4026
  * It can be used to batch up a set of changes to be written to the cache, but
@@ -3803,26 +4036,25 @@ declare interface RemoteDocumentChange {
3803
4036
  * porting this class as part of that implementation work.
3804
4037
  */
3805
4038
  declare abstract class RemoteDocumentChangeBuffer {
3806
- protected changes: ObjectMap<_DocumentKey, RemoteDocumentChange>;
4039
+ protected changes: ObjectMap<_DocumentKey, MutableDocument>;
3807
4040
  private changesApplied;
3808
4041
  protected abstract getFromCache(transaction: PersistenceTransaction, documentKey: _DocumentKey): PersistencePromise<MutableDocument>;
3809
4042
  protected abstract getAllFromCache(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
3810
4043
  protected abstract applyChanges(transaction: PersistenceTransaction): PersistencePromise<void>;
3811
- protected getReadTime(key: _DocumentKey): SnapshotVersion;
3812
4044
  /**
3813
4045
  * Buffers a `RemoteDocumentCache.addEntry()` call.
3814
4046
  *
3815
4047
  * You can only modify documents that have already been retrieved via
3816
4048
  * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
3817
4049
  */
3818
- addEntry(document: MutableDocument, readTime: SnapshotVersion): void;
4050
+ addEntry(document: MutableDocument): void;
3819
4051
  /**
3820
4052
  * Buffers a `RemoteDocumentCache.removeEntry()` call.
3821
4053
  *
3822
4054
  * You can only remove documents that have already been retrieved via
3823
4055
  * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
3824
4056
  */
3825
- removeEntry(key: _DocumentKey, readTime?: SnapshotVersion | null): void;
4057
+ removeEntry(key: _DocumentKey, readTime: SnapshotVersion): void;
3826
4058
  /**
3827
4059
  * Looks up an entry in the cache. The buffered changes will first be checked,
3828
4060
  * 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.8ac8fb099",
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.8ac8fb099",
81
+ "@firebase/logger": "0.3.2-canary.8ac8fb099",
82
+ "@firebase/util": "1.4.3-canary.8ac8fb099",
83
+ "@firebase/webchannel-wrapper": "0.6.1-canary.8ac8fb099",
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.8ac8fb099"
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.8ac8fb099",
94
+ "@firebase/app-compat": "0.1.18-canary.8ac8fb099",
95
+ "@firebase/auth": "0.19.9-canary.8ac8fb099",
96
96
  "@rollup/plugin-alias": "3.1.5",
97
97
  "@rollup/plugin-json": "4.1.0",
98
98
  "@types/eslint": "7.28.0",