@react-native-firebase/firestore 23.8.8 → 24.0.0

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 (359) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/RNFBFirestore.podspec +2 -1
  3. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreCollectionModule.java +17 -4
  4. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreDocumentModule.java +2 -2
  5. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestorePipelineExecutor.java +1243 -0
  6. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestorePipelineNodeBuilder.java +3919 -0
  7. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestorePipelineParser.java +1735 -0
  8. package/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreSerialize.java +1 -1
  9. package/dist/module/FieldPath.js +59 -0
  10. package/dist/module/FieldPath.js.map +1 -0
  11. package/dist/module/FieldValue.js +82 -0
  12. package/dist/module/FieldValue.js.map +1 -0
  13. package/{lib → dist/module}/FirestoreAggregate.js +31 -43
  14. package/dist/module/FirestoreAggregate.js.map +1 -0
  15. package/dist/module/FirestoreBlob.js +56 -0
  16. package/dist/module/FirestoreBlob.js.map +1 -0
  17. package/dist/module/FirestoreCollectionReference.js +70 -0
  18. package/dist/module/FirestoreCollectionReference.js.map +1 -0
  19. package/{lib → dist/module}/FirestoreDocumentChange.js +12 -15
  20. package/dist/module/FirestoreDocumentChange.js.map +1 -0
  21. package/dist/module/FirestoreDocumentReference.js +170 -0
  22. package/dist/module/FirestoreDocumentReference.js.map +1 -0
  23. package/dist/module/FirestoreDocumentSnapshot.js +88 -0
  24. package/dist/module/FirestoreDocumentSnapshot.js.map +1 -0
  25. package/dist/module/FirestoreFilter.js +146 -0
  26. package/dist/module/FirestoreFilter.js.map +1 -0
  27. package/dist/module/FirestoreGeoPoint.js +80 -0
  28. package/dist/module/FirestoreGeoPoint.js.map +1 -0
  29. package/{lib → dist/module}/FirestorePath.js +5 -12
  30. package/dist/module/FirestorePath.js.map +1 -0
  31. package/{lib → dist/module}/FirestorePersistentCacheIndexManager.js +11 -4
  32. package/dist/module/FirestorePersistentCacheIndexManager.js.map +1 -0
  33. package/dist/module/FirestoreQuery.js +298 -0
  34. package/dist/module/FirestoreQuery.js.map +1 -0
  35. package/{lib → dist/module}/FirestoreQueryModifiers.js +25 -136
  36. package/dist/module/FirestoreQueryModifiers.js.map +1 -0
  37. package/dist/module/FirestoreQuerySnapshot.js +98 -0
  38. package/dist/module/FirestoreQuerySnapshot.js.map +1 -0
  39. package/dist/module/FirestoreSnapshotMetadata.js +38 -0
  40. package/dist/module/FirestoreSnapshotMetadata.js.map +1 -0
  41. package/dist/module/FirestoreStatics.js +50 -0
  42. package/dist/module/FirestoreStatics.js.map +1 -0
  43. package/{lib → dist/module}/FirestoreTimestamp.js +39 -39
  44. package/dist/module/FirestoreTimestamp.js.map +1 -0
  45. package/dist/module/FirestoreTransaction.js +113 -0
  46. package/dist/module/FirestoreTransaction.js.map +1 -0
  47. package/dist/module/FirestoreTransactionHandler.js +137 -0
  48. package/dist/module/FirestoreTransactionHandler.js.map +1 -0
  49. package/dist/module/FirestoreVectorValue.js +75 -0
  50. package/dist/module/FirestoreVectorValue.js.map +1 -0
  51. package/dist/module/FirestoreWriteBatch.js +113 -0
  52. package/dist/module/FirestoreWriteBatch.js.map +1 -0
  53. package/dist/module/LoadBundleTask.js +70 -0
  54. package/dist/module/LoadBundleTask.js.map +1 -0
  55. package/dist/module/index.js +31 -0
  56. package/dist/module/index.js.map +1 -0
  57. package/dist/module/modular/Bytes.js +67 -0
  58. package/dist/module/modular/Bytes.js.map +1 -0
  59. package/dist/module/modular/FieldPath.js +25 -0
  60. package/dist/module/modular/FieldPath.js.map +1 -0
  61. package/dist/module/modular/FieldValue.js +37 -0
  62. package/dist/module/modular/FieldValue.js.map +1 -0
  63. package/dist/module/modular/GeoPoint.js +22 -0
  64. package/dist/module/modular/GeoPoint.js.map +1 -0
  65. package/dist/module/modular/Timestamp.js +22 -0
  66. package/dist/module/modular/Timestamp.js.map +1 -0
  67. package/dist/module/modular/VectorValue.js +25 -0
  68. package/dist/module/modular/VectorValue.js.map +1 -0
  69. package/dist/module/modular/query.js +222 -0
  70. package/dist/module/modular/query.js.map +1 -0
  71. package/dist/module/modular/snapshot.js +32 -0
  72. package/dist/module/modular/snapshot.js.map +1 -0
  73. package/dist/module/modular.js +229 -0
  74. package/dist/module/modular.js.map +1 -0
  75. package/dist/module/namespaced.js +298 -0
  76. package/dist/module/namespaced.js.map +1 -0
  77. package/dist/module/package.json +1 -0
  78. package/dist/module/pipelines/expressions.js +1273 -0
  79. package/dist/module/pipelines/expressions.js.map +1 -0
  80. package/dist/module/pipelines/index.js +32 -0
  81. package/dist/module/pipelines/index.js.map +1 -0
  82. package/dist/module/pipelines/pipeline-result.js +58 -0
  83. package/dist/module/pipelines/pipeline-result.js.map +1 -0
  84. package/dist/module/pipelines/pipeline-source.js +4 -0
  85. package/dist/module/pipelines/pipeline-source.js.map +1 -0
  86. package/dist/module/pipelines/pipeline.js +4 -0
  87. package/dist/module/pipelines/pipeline.js.map +1 -0
  88. package/dist/module/pipelines/pipeline_impl.js +42 -0
  89. package/dist/module/pipelines/pipeline_impl.js.map +1 -0
  90. package/dist/module/pipelines/pipeline_options.js +4 -0
  91. package/dist/module/pipelines/pipeline_options.js.map +1 -0
  92. package/dist/module/pipelines/pipeline_runtime.js +526 -0
  93. package/dist/module/pipelines/pipeline_runtime.js.map +1 -0
  94. package/dist/module/pipelines/pipeline_support.js +71 -0
  95. package/dist/module/pipelines/pipeline_support.js.map +1 -0
  96. package/dist/module/pipelines/pipeline_validate.js +183 -0
  97. package/dist/module/pipelines/pipeline_validate.js.map +1 -0
  98. package/dist/module/pipelines/stage_options.js +4 -0
  99. package/dist/module/pipelines/stage_options.js.map +1 -0
  100. package/dist/module/pipelines/types.js +2 -0
  101. package/dist/module/pipelines/types.js.map +1 -0
  102. package/dist/module/types/firestore.js +4 -0
  103. package/dist/module/types/firestore.js.map +1 -0
  104. package/dist/module/types/internal.js +4 -0
  105. package/dist/module/types/internal.js.map +1 -0
  106. package/dist/module/types/namespaced.js +338 -0
  107. package/dist/module/types/namespaced.js.map +1 -0
  108. package/{lib → dist/module}/utils/index.js +59 -114
  109. package/dist/module/utils/index.js.map +1 -0
  110. package/{lib → dist/module}/utils/serialize.js +58 -116
  111. package/dist/module/utils/serialize.js.map +1 -0
  112. package/{lib → dist/module}/utils/typemap.js +6 -20
  113. package/dist/module/utils/typemap.js.map +1 -0
  114. package/dist/module/version.js +5 -0
  115. package/dist/module/version.js.map +1 -0
  116. package/dist/module/web/RNFBFirestoreModule.android.js +5 -0
  117. package/dist/module/web/RNFBFirestoreModule.android.js.map +1 -0
  118. package/dist/module/web/RNFBFirestoreModule.ios.js +5 -0
  119. package/dist/module/web/RNFBFirestoreModule.ios.js.map +1 -0
  120. package/dist/module/web/RNFBFirestoreModule.js +387 -0
  121. package/dist/module/web/RNFBFirestoreModule.js.map +1 -0
  122. package/{lib → dist/module}/web/convert.js +60 -94
  123. package/dist/module/web/convert.js.map +1 -0
  124. package/dist/module/web/pipelines/pipeline.js +34 -0
  125. package/dist/module/web/pipelines/pipeline.js.map +1 -0
  126. package/dist/module/web/pipelines/pipeline_bridge_factory.js +217 -0
  127. package/dist/module/web/pipelines/pipeline_bridge_factory.js.map +1 -0
  128. package/dist/module/web/pipelines/pipeline_node_builder.js +294 -0
  129. package/dist/module/web/pipelines/pipeline_node_builder.js.map +1 -0
  130. package/dist/module/web/pipelines/pipeline_parser.js +21 -0
  131. package/dist/module/web/pipelines/pipeline_parser.js.map +1 -0
  132. package/dist/module/web/pipelines/pipeline_snapshot_serializer.js +89 -0
  133. package/dist/module/web/pipelines/pipeline_snapshot_serializer.js.map +1 -0
  134. package/dist/module/web/query.js +95 -0
  135. package/dist/module/web/query.js.map +1 -0
  136. package/dist/typescript/lib/FieldPath.d.ts +10 -0
  137. package/dist/typescript/lib/FieldPath.d.ts.map +1 -0
  138. package/dist/typescript/lib/FieldValue.d.ts +17 -0
  139. package/dist/typescript/lib/FieldValue.d.ts.map +1 -0
  140. package/dist/typescript/lib/FirestoreAggregate.d.ts +40 -0
  141. package/dist/typescript/lib/FirestoreAggregate.d.ts.map +1 -0
  142. package/dist/typescript/lib/FirestoreBlob.d.ts +11 -0
  143. package/dist/typescript/lib/FirestoreBlob.d.ts.map +1 -0
  144. package/dist/typescript/lib/FirestoreCollectionReference.d.ts +15 -0
  145. package/dist/typescript/lib/FirestoreCollectionReference.d.ts.map +1 -0
  146. package/dist/typescript/lib/FirestoreDocumentChange.d.ts +27 -0
  147. package/dist/typescript/lib/FirestoreDocumentChange.d.ts.map +1 -0
  148. package/dist/typescript/lib/FirestoreDocumentReference.d.ts +30 -0
  149. package/dist/typescript/lib/FirestoreDocumentReference.d.ts.map +1 -0
  150. package/dist/typescript/lib/FirestoreDocumentSnapshot.d.ts +30 -0
  151. package/dist/typescript/lib/FirestoreDocumentSnapshot.d.ts.map +1 -0
  152. package/dist/typescript/lib/FirestoreFilter.d.ts +52 -0
  153. package/dist/typescript/lib/FirestoreFilter.d.ts.map +1 -0
  154. package/dist/typescript/lib/FirestoreGeoPoint.d.ts +22 -0
  155. package/dist/typescript/lib/FirestoreGeoPoint.d.ts.map +1 -0
  156. package/dist/typescript/lib/FirestorePath.d.ts +12 -0
  157. package/dist/typescript/lib/FirestorePath.d.ts.map +1 -0
  158. package/dist/typescript/lib/FirestorePersistentCacheIndexManager.d.ts +16 -0
  159. package/dist/typescript/lib/FirestorePersistentCacheIndexManager.d.ts.map +1 -0
  160. package/dist/typescript/lib/FirestoreQuery.d.ts +39 -0
  161. package/dist/typescript/lib/FirestoreQuery.d.ts.map +1 -0
  162. package/dist/typescript/lib/FirestoreQueryModifiers.d.ts +59 -0
  163. package/dist/typescript/lib/FirestoreQueryModifiers.d.ts.map +1 -0
  164. package/dist/typescript/lib/FirestoreQuerySnapshot.d.ts +49 -0
  165. package/dist/typescript/lib/FirestoreQuerySnapshot.d.ts.map +1 -0
  166. package/dist/typescript/lib/FirestoreSnapshotMetadata.d.ts +8 -0
  167. package/dist/typescript/lib/FirestoreSnapshotMetadata.d.ts.map +1 -0
  168. package/dist/typescript/lib/FirestoreStatics.d.ts +23 -0
  169. package/dist/typescript/lib/FirestoreStatics.d.ts.map +1 -0
  170. package/dist/typescript/lib/FirestoreTimestamp.d.ts +33 -0
  171. package/dist/typescript/lib/FirestoreTimestamp.d.ts.map +1 -0
  172. package/dist/typescript/lib/FirestoreTransaction.d.ts +42 -0
  173. package/dist/typescript/lib/FirestoreTransaction.d.ts.map +1 -0
  174. package/dist/typescript/lib/FirestoreTransactionHandler.d.ts +26 -0
  175. package/dist/typescript/lib/FirestoreTransactionHandler.d.ts.map +1 -0
  176. package/dist/typescript/lib/FirestoreVectorValue.d.ts +17 -0
  177. package/dist/typescript/lib/FirestoreVectorValue.d.ts.map +1 -0
  178. package/dist/typescript/lib/FirestoreWriteBatch.d.ts +21 -0
  179. package/dist/typescript/lib/FirestoreWriteBatch.d.ts.map +1 -0
  180. package/dist/typescript/lib/LoadBundleTask.d.ts +16 -0
  181. package/dist/typescript/lib/LoadBundleTask.d.ts.map +1 -0
  182. package/dist/typescript/lib/index.d.ts +6 -0
  183. package/dist/typescript/lib/index.d.ts.map +1 -0
  184. package/dist/typescript/lib/modular/Bytes.d.ts +22 -0
  185. package/dist/typescript/lib/modular/Bytes.d.ts.map +1 -0
  186. package/dist/typescript/lib/modular/FieldPath.d.ts +4 -0
  187. package/dist/typescript/lib/modular/FieldPath.d.ts.map +1 -0
  188. package/dist/typescript/lib/modular/FieldValue.d.ts +8 -0
  189. package/dist/typescript/lib/modular/FieldValue.d.ts.map +1 -0
  190. package/dist/typescript/lib/modular/GeoPoint.d.ts +3 -0
  191. package/dist/typescript/lib/modular/GeoPoint.d.ts.map +1 -0
  192. package/dist/typescript/lib/modular/Timestamp.d.ts +3 -0
  193. package/dist/typescript/lib/modular/Timestamp.d.ts.map +1 -0
  194. package/dist/typescript/lib/modular/VectorValue.d.ts +4 -0
  195. package/dist/typescript/lib/modular/VectorValue.d.ts.map +1 -0
  196. package/dist/typescript/lib/modular/query.d.ts +93 -0
  197. package/dist/typescript/lib/modular/query.d.ts.map +1 -0
  198. package/dist/typescript/lib/modular/snapshot.d.ts +30 -0
  199. package/dist/typescript/lib/modular/snapshot.d.ts.map +1 -0
  200. package/dist/typescript/lib/modular.d.ts +69 -0
  201. package/dist/typescript/lib/modular.d.ts.map +1 -0
  202. package/dist/typescript/lib/namespaced.d.ts +13 -0
  203. package/dist/typescript/lib/namespaced.d.ts.map +1 -0
  204. package/dist/typescript/lib/pipelines/expressions.d.ts +723 -0
  205. package/dist/typescript/lib/pipelines/expressions.d.ts.map +1 -0
  206. package/dist/typescript/lib/pipelines/index.d.ts +31 -0
  207. package/dist/typescript/lib/pipelines/index.d.ts.map +1 -0
  208. package/dist/typescript/lib/pipelines/pipeline-result.d.ts +30 -0
  209. package/dist/typescript/lib/pipelines/pipeline-result.d.ts.map +1 -0
  210. package/dist/typescript/lib/pipelines/pipeline-source.d.ts +64 -0
  211. package/dist/typescript/lib/pipelines/pipeline-source.d.ts.map +1 -0
  212. package/dist/typescript/lib/pipelines/pipeline.d.ts +61 -0
  213. package/dist/typescript/lib/pipelines/pipeline.d.ts.map +1 -0
  214. package/dist/typescript/lib/pipelines/pipeline_impl.d.ts +21 -0
  215. package/dist/typescript/lib/pipelines/pipeline_impl.d.ts.map +1 -0
  216. package/dist/typescript/lib/pipelines/pipeline_options.d.ts +17 -0
  217. package/dist/typescript/lib/pipelines/pipeline_options.d.ts.map +1 -0
  218. package/dist/typescript/lib/pipelines/pipeline_runtime.d.ts +10 -0
  219. package/dist/typescript/lib/pipelines/pipeline_runtime.d.ts.map +1 -0
  220. package/dist/typescript/lib/pipelines/pipeline_support.d.ts +7 -0
  221. package/dist/typescript/lib/pipelines/pipeline_support.d.ts.map +1 -0
  222. package/dist/typescript/lib/pipelines/pipeline_validate.d.ts +9 -0
  223. package/dist/typescript/lib/pipelines/pipeline_validate.d.ts.map +1 -0
  224. package/dist/typescript/lib/pipelines/stage_options.d.ts +326 -0
  225. package/dist/typescript/lib/pipelines/stage_options.d.ts.map +1 -0
  226. package/dist/typescript/lib/pipelines/types.d.ts +10 -0
  227. package/dist/typescript/lib/pipelines/types.d.ts.map +1 -0
  228. package/dist/typescript/lib/types/firestore.d.ts +263 -0
  229. package/dist/typescript/lib/types/firestore.d.ts.map +1 -0
  230. package/dist/typescript/lib/types/internal.d.ts +483 -0
  231. package/dist/typescript/lib/types/internal.d.ts.map +1 -0
  232. package/dist/typescript/lib/types/namespaced.d.ts +2285 -0
  233. package/dist/typescript/lib/types/namespaced.d.ts.map +1 -0
  234. package/dist/typescript/lib/utils/index.d.ts +15 -0
  235. package/dist/typescript/lib/utils/index.d.ts.map +1 -0
  236. package/dist/typescript/lib/utils/serialize.d.ts +17 -0
  237. package/dist/typescript/lib/utils/serialize.d.ts.map +1 -0
  238. package/dist/typescript/lib/utils/typemap.d.ts +3 -0
  239. package/dist/typescript/lib/utils/typemap.d.ts.map +1 -0
  240. package/dist/typescript/lib/version.d.ts +2 -0
  241. package/dist/typescript/lib/version.d.ts.map +1 -0
  242. package/dist/typescript/lib/web/RNFBFirestoreModule.android.d.ts +3 -0
  243. package/dist/typescript/lib/web/RNFBFirestoreModule.android.d.ts.map +1 -0
  244. package/dist/typescript/lib/web/RNFBFirestoreModule.d.ts +75 -0
  245. package/dist/typescript/lib/web/RNFBFirestoreModule.d.ts.map +1 -0
  246. package/dist/typescript/lib/web/RNFBFirestoreModule.ios.d.ts +3 -0
  247. package/dist/typescript/lib/web/RNFBFirestoreModule.ios.d.ts.map +1 -0
  248. package/dist/typescript/lib/web/convert.d.ts +14 -0
  249. package/dist/typescript/lib/web/convert.d.ts.map +1 -0
  250. package/dist/typescript/lib/web/pipelines/pipeline.d.ts +4 -0
  251. package/dist/typescript/lib/web/pipelines/pipeline.d.ts.map +1 -0
  252. package/dist/typescript/lib/web/pipelines/pipeline_bridge_factory.d.ts +5 -0
  253. package/dist/typescript/lib/web/pipelines/pipeline_bridge_factory.d.ts.map +1 -0
  254. package/dist/typescript/lib/web/pipelines/pipeline_node_builder.d.ts +5 -0
  255. package/dist/typescript/lib/web/pipelines/pipeline_node_builder.d.ts.map +1 -0
  256. package/dist/typescript/lib/web/pipelines/pipeline_parser.d.ts +3 -0
  257. package/dist/typescript/lib/web/pipelines/pipeline_parser.d.ts.map +1 -0
  258. package/dist/typescript/lib/web/pipelines/pipeline_snapshot_serializer.d.ts +4 -0
  259. package/dist/typescript/lib/web/pipelines/pipeline_snapshot_serializer.d.ts.map +1 -0
  260. package/dist/typescript/lib/web/query.d.ts +23 -0
  261. package/dist/typescript/lib/web/query.d.ts.map +1 -0
  262. package/dist/typescript/package.json +1 -0
  263. package/ios/RNFBFirestore/RNFBFirestoreCollectionModule.m +52 -2
  264. package/ios/RNFBFirestore/RNFBFirestorePipelineBridgeFactory.swift +384 -0
  265. package/ios/RNFBFirestore/RNFBFirestorePipelineCallHandler.swift +86 -0
  266. package/ios/RNFBFirestore/RNFBFirestorePipelineNodeBuilder.swift +1500 -0
  267. package/ios/RNFBFirestore/RNFBFirestorePipelineParser.swift +1352 -0
  268. package/ios/RNFBFirestore/RNFBFirestorePipelineSnapshotSerializer.swift +98 -0
  269. package/lib/{FirestoreFieldPath.js → FieldPath.ts} +10 -12
  270. package/lib/{FirestoreFieldValue.js → FieldValue.ts} +22 -19
  271. package/lib/FirestoreAggregate.ts +124 -0
  272. package/lib/FirestoreBlob.ts +73 -0
  273. package/lib/FirestoreCollectionReference.ts +99 -0
  274. package/lib/FirestoreDocumentChange.ts +71 -0
  275. package/lib/FirestoreDocumentReference.ts +310 -0
  276. package/lib/FirestoreDocumentSnapshot.ts +149 -0
  277. package/lib/FirestoreFilter.ts +232 -0
  278. package/lib/{FirestoreGeoPoint.js → FirestoreGeoPoint.ts} +48 -8
  279. package/lib/FirestorePath.ts +54 -0
  280. package/lib/FirestorePersistentCacheIndexManager.ts +46 -0
  281. package/lib/{FirestoreQuery.js → FirestoreQuery.ts} +208 -100
  282. package/lib/FirestoreQueryModifiers.ts +411 -0
  283. package/lib/{FirestoreQuerySnapshot.js → FirestoreQuerySnapshot.ts} +61 -32
  284. package/lib/{FirestoreSnapshotMetadata.js → FirestoreSnapshotMetadata.ts} +8 -6
  285. package/lib/{FirestoreStatics.js → FirestoreStatics.ts} +18 -11
  286. package/lib/FirestoreTimestamp.ts +161 -0
  287. package/lib/{FirestoreTransaction.js → FirestoreTransaction.ts} +64 -27
  288. package/lib/{FirestoreTransactionHandler.js → FirestoreTransactionHandler.ts} +54 -75
  289. package/lib/{FirestoreVectorValue.js → FirestoreVectorValue.ts} +36 -15
  290. package/lib/{FirestoreWriteBatch.js → FirestoreWriteBatch.ts} +45 -21
  291. package/lib/LoadBundleTask.ts +85 -0
  292. package/lib/index.ts +71 -0
  293. package/lib/modular/Bytes.ts +81 -0
  294. package/lib/modular/FieldPath.ts +24 -0
  295. package/lib/modular/FieldValue.ts +40 -0
  296. package/lib/modular/GeoPoint.ts +20 -0
  297. package/lib/modular/Timestamp.ts +20 -0
  298. package/lib/modular/VectorValue.ts +24 -0
  299. package/lib/modular/query.ts +368 -0
  300. package/lib/modular/snapshot.ts +137 -0
  301. package/lib/modular.ts +552 -0
  302. package/lib/{index.js → namespaced.ts} +170 -80
  303. package/lib/pipelines/expressions.ts +2321 -0
  304. package/lib/pipelines/index.ts +203 -0
  305. package/lib/pipelines/pipeline-result.ts +78 -0
  306. package/lib/pipelines/pipeline-source.ts +83 -0
  307. package/lib/pipelines/pipeline.ts +99 -0
  308. package/lib/pipelines/pipeline_impl.ts +46 -0
  309. package/lib/pipelines/pipeline_options.ts +32 -0
  310. package/lib/pipelines/pipeline_runtime.ts +863 -0
  311. package/lib/pipelines/pipeline_support.ts +134 -0
  312. package/lib/pipelines/pipeline_validate.ts +242 -0
  313. package/lib/pipelines/stage_options.ts +376 -0
  314. package/lib/pipelines/types.ts +26 -0
  315. package/lib/types/firestore.ts +477 -0
  316. package/lib/types/internal.ts +747 -0
  317. package/lib/{index.d.ts → types/namespaced.ts} +280 -79
  318. package/lib/utils/index.ts +244 -0
  319. package/lib/utils/serialize.ts +314 -0
  320. package/lib/utils/typemap.ts +65 -0
  321. package/lib/version.ts +2 -0
  322. package/lib/web/{RNFBFirestoreModule.js → RNFBFirestoreModule.ts} +222 -234
  323. package/lib/web/convert.ts +287 -0
  324. package/lib/web/pipelines/pipeline.ts +47 -0
  325. package/lib/web/pipelines/pipeline_bridge_factory.ts +377 -0
  326. package/lib/web/pipelines/pipeline_node_builder.ts +413 -0
  327. package/lib/web/pipelines/pipeline_parser.ts +23 -0
  328. package/lib/web/pipelines/pipeline_snapshot_serializer.ts +133 -0
  329. package/lib/web/query.ts +150 -0
  330. package/package.json +46 -7
  331. package/tsconfig.json +35 -0
  332. package/lib/FirestoreBlob.js +0 -107
  333. package/lib/FirestoreCollectionReference.js +0 -70
  334. package/lib/FirestoreDocumentReference.js +0 -222
  335. package/lib/FirestoreDocumentSnapshot.js +0 -132
  336. package/lib/FirestoreFilter.js +0 -156
  337. package/lib/modular/Bytes.d.ts +0 -11
  338. package/lib/modular/Bytes.js +0 -62
  339. package/lib/modular/FieldPath.d.ts +0 -20
  340. package/lib/modular/FieldPath.js +0 -7
  341. package/lib/modular/FieldValue.d.ts +0 -67
  342. package/lib/modular/FieldValue.js +0 -41
  343. package/lib/modular/GeoPoint.d.ts +0 -17
  344. package/lib/modular/GeoPoint.js +0 -3
  345. package/lib/modular/Timestamp.d.ts +0 -85
  346. package/lib/modular/Timestamp.js +0 -3
  347. package/lib/modular/VectorValue.d.ts +0 -30
  348. package/lib/modular/VectorValue.js +0 -11
  349. package/lib/modular/index.d.ts +0 -788
  350. package/lib/modular/index.js +0 -410
  351. package/lib/modular/query.d.ts +0 -370
  352. package/lib/modular/query.js +0 -233
  353. package/lib/modular/snapshot.d.ts +0 -256
  354. package/lib/modular/snapshot.js +0 -33
  355. package/lib/modular/utils/observer.js +0 -16
  356. package/lib/version.js +0 -2
  357. package/lib/web/query.js +0 -112
  358. /package/lib/web/{RNFBFirestoreModule.android.js → RNFBFirestoreModule.android.ts} +0 -0
  359. /package/lib/web/{RNFBFirestoreModule.ios.js → RNFBFirestoreModule.ios.ts} +0 -0
@@ -1,788 +0,0 @@
1
- import { ReactNativeFirebase } from '@react-native-firebase/app';
2
- import { FirebaseFirestoreTypes } from '../index';
3
-
4
- import FirebaseApp = ReactNativeFirebase.FirebaseApp;
5
- import Firestore = FirebaseFirestoreTypes.Module;
6
- import CollectionReference = FirebaseFirestoreTypes.CollectionReference;
7
- import DocumentReference = FirebaseFirestoreTypes.DocumentReference;
8
- import DocumentData = FirebaseFirestoreTypes.DocumentData;
9
- import Query = FirebaseFirestoreTypes.Query;
10
- import FieldValue = FirebaseFirestoreTypes.FieldValue;
11
- import FieldPath = FirebaseFirestoreTypes.FieldPath;
12
- import PersistentCacheIndexManager = FirebaseFirestoreTypes.PersistentCacheIndexManager;
13
- import AggregateQuerySnapshot = FirebaseFirestoreTypes.AggregateQuerySnapshot;
14
-
15
- /** Primitive types. */
16
- export type Primitive = string | number | boolean | undefined | null;
17
-
18
- /**
19
- * Similar to Typescript's `Partial<T>`, but allows nested fields to be
20
- * omitted and FieldValues to be passed in as property values.
21
- */
22
- export type PartialWithFieldValue<T> =
23
- | Partial<T>
24
- | (T extends Primitive
25
- ? T
26
- : T extends object
27
- ? { [K in keyof T]?: PartialWithFieldValue<T[K]> | FieldValue }
28
- : never);
29
-
30
- /**
31
- * Given a union type `U = T1 | T2 | ...`, returns an intersected type (`T1 & T2 & ...`).
32
- *
33
- * Uses distributive conditional types and inference from conditional types.
34
- * This works because multiple candidates for the same type variable in contra-variant positions
35
- * causes an intersection type to be inferred.
36
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-inference-in-conditional-types
37
- * https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
38
- */
39
- export declare type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (
40
- k: infer I,
41
- ) => void
42
- ? I
43
- : never;
44
-
45
- /**
46
- * Returns a new map where every key is prefixed with the outer key appended to a dot.
47
- */
48
- export declare type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
49
- [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
50
- };
51
-
52
- /**
53
- * Helper for calculating the nested fields for a given type `T1`. This is needed to distribute
54
- * union types such as `undefined | {...}` (happens for optional props) or `{a: A} | {b: B}`.
55
- *
56
- * In this use case, `V` is used to distribute the union types of `T[K]` on Record, since `T[K]`
57
- * is evaluated as an expression and not distributed.
58
- *
59
- * See https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types
60
- */
61
- export declare type ChildUpdateFields<K extends string, V> =
62
- V extends Record<string, unknown> ? AddPrefixToKeys<K, UpdateData<V>> : never;
63
-
64
- /**
65
- * For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, 'bar.qux': T2}).
66
- * Intersect them together to make a single map containing all possible keys that are all marked as optional
67
- */
68
- export declare type NestedUpdateFields<T extends Record<string, unknown>> = UnionToIntersection<
69
- {
70
- [K in keyof T & string]: ChildUpdateFields<K, T[K]>;
71
- }[keyof T & string]
72
- >;
73
-
74
- /**
75
- * Update data (for use with {@link updateDoc}) that consists of field paths (e.g. 'foo' or 'foo.baz')
76
- * mapped to values. Fields that contain dots reference nested fields within the document.
77
- * FieldValues can be passed in as property values.
78
- */
79
- export declare type UpdateData<T> = T extends Primitive
80
- ? T
81
- : T extends object
82
- ? {
83
- [K in keyof T]?: UpdateData<T[K]> | FieldValue;
84
- } & NestedUpdateFields<T>
85
- : Partial<T>;
86
-
87
- /**
88
- * Allows FieldValues to be passed in as a property value while maintaining
89
- * type safety.
90
- */
91
- export type WithFieldValue<T> =
92
- | T
93
- | (T extends Primitive
94
- ? T
95
- : T extends object
96
- ? { [K in keyof T]: WithFieldValue<T[K]> | FieldValue }
97
- : never);
98
-
99
- export type EmulatorMockTokenOptions = ({ user_id: string } | { sub: string }) &
100
- Partial<FirebaseIdToken>;
101
-
102
- /**
103
- * Returns the existing default {@link Firestore} instance that is associated with the
104
- * default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
105
- * instance with default settings.
106
- *
107
- * @returns The {@link Firestore} instance of the provided app.
108
- */
109
- export declare function getFirestore(): Firestore;
110
-
111
- /**
112
- * Returns the existing default {@link Firestore} instance that is associated with the
113
- * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
114
- * instance with default settings.
115
- *
116
- * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
117
- * instance is associated with.
118
- * @returns The {@link Firestore} instance of the provided app.
119
- * @internal
120
- */
121
- export declare function getFirestore(app: FirebaseApp): Firestore;
122
-
123
- export function getFirestore(app?: FirebaseApp): Firestore;
124
-
125
- /**
126
- * Returns the existing default {@link Firestore} instance that is associated with the
127
- * provided {@link @firebase/app#FirebaseApp} and database ID. If no instance exists, initializes a new
128
- * instance with default settings.
129
- *
130
- * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
131
- * instance is associated with.
132
- * @param databaseId - The ID of the Firestore database to use. If not provided, the default database is used.
133
- * @returns The {@link Firestore}
134
- */
135
- export declare function getFirestore(app?: FirebaseApp, databaseId?: string): Firestore;
136
-
137
- /**
138
- * Modify this instance to communicate with the Cloud Firestore emulator.
139
- *
140
- * @param firestore - A reference to the root `Firestore` instance.
141
- * instance is associated with.
142
- * @param host: emulator host (eg, 'localhost')
143
- * @param port: emulator port (eg, 8080)
144
- * @param options.mockUserToken - the mock auth token to use for unit testing
145
- * @returns void.
146
- */
147
- export declare function connectFirestoreEmulator(
148
- firestore: Firestore,
149
- host: string,
150
- port: number,
151
- options?: {
152
- mockUserToken?: EmulatorMockTokenOptions | string;
153
- },
154
- ): void;
155
- /**
156
- * Gets a `DocumentReference` instance that refers to the document at the
157
- * specified absolute path.
158
- *
159
- * @param firestore - A reference to the root `Firestore` instance.
160
- * @param path - A slash-separated path to a document.
161
- * @param pathSegments - Additional path segments that will be applied relative
162
- * to the first argument.
163
- * @throws If the final path has an odd number of segments and does not point to
164
- * a document.
165
- * @returns The `DocumentReference` instance.
166
- */
167
- export function doc(
168
- firestore: Firestore,
169
- path: string,
170
- ...pathSegments: string[]
171
- ): DocumentReference<DocumentData>;
172
-
173
- /**
174
- * Gets a `DocumentReference` instance that refers to a document within
175
- * `reference` at the specified relative path. If no path is specified, an
176
- * automatically-generated unique ID will be used for the returned
177
- * `DocumentReference`.
178
- *
179
- * @param reference - A reference to a collection.
180
- * @param path - A slash-separated path to a document. Has to be omitted to use
181
- * auto-generated IDs.
182
- * @param pathSegments - Additional path segments that will be applied relative
183
- * to the first argument.
184
- * @throws If the final path has an odd number of segments and does not point to
185
- * a document.
186
- * @returns The `DocumentReference` instance.
187
- */
188
- export declare function doc<AppModelType, DbModelType extends DocumentData>(
189
- reference: CollectionReference<AppModelType, DbModelType>,
190
- path?: string,
191
- ...pathSegments: string[]
192
- ): DocumentReference<AppModelType, DbModelType>;
193
-
194
- /**
195
- * Gets a `DocumentReference` instance that refers to a document within
196
- * `reference` at the specified relative path.
197
- *
198
- * @param reference - A reference to a Firestore document.
199
- * @param path - A slash-separated path to a document.
200
- * @param pathSegments - Additional path segments that will be applied relative
201
- * to the first argument.
202
- * @throws If the final path has an odd number of segments and does not point to
203
- * a document.
204
- * @returns The `DocumentReference` instance.
205
- */
206
- export declare function doc<AppModelType, DbModelType extends DocumentData>(
207
- reference: DocumentReference<AppModelType, DbModelType>,
208
- path: string,
209
- ...pathSegments: string[]
210
- ): DocumentReference<DocumentData, DocumentData>;
211
-
212
- export function doc<T>(
213
- parent: Firestore | CollectionReference<T> | DocumentReference<unknown>,
214
- path?: string,
215
- ...pathSegments: string[]
216
- ): DocumentReference;
217
-
218
- /**
219
- * Gets a `CollectionReference` instance that refers to the collection at
220
- * the specified absolute path.
221
- *
222
- * @param firestore - A reference to the root `Firestore` instance.
223
- * @param path - A slash-separated path to a collection.
224
- * @param pathSegments - Additional path segments to apply relative to the first
225
- * argument.
226
- * @throws If the final path has an even number of segments and does not point
227
- * to a collection.
228
- * @returns The `CollectionReference` instance.
229
- */
230
- export function collection(
231
- firestore: Firestore,
232
- path: string,
233
- ...pathSegments: string[]
234
- ): CollectionReference<DocumentData, DocumentData>;
235
-
236
- /**
237
- * Gets a `CollectionReference` instance that refers to a subcollection of
238
- * `reference` at the specified relative path.
239
- *
240
- * @param reference - A reference to a collection.
241
- * @param path - A slash-separated path to a collection.
242
- * @param pathSegments - Additional path segments to apply relative to the first
243
- * argument.
244
- * @throws If the final path has an even number of segments and does not point
245
- * to a collection.
246
- * @returns The `CollectionReference` instance.
247
- */
248
- export declare function collection<AppModelType, DbModelType extends DocumentData>(
249
- reference: CollectionReference<AppModelType, DbModelType>,
250
- path: string,
251
- ...pathSegments: string[]
252
- ): CollectionReference<DocumentData, DocumentData>;
253
-
254
- /**
255
- * Gets a `CollectionReference` instance that refers to a subcollection of
256
- * `reference` at the specified relative path.
257
- *
258
- * @param reference - A reference to a document.
259
- * @param path - A slash-separated path to a collection.
260
- * @param pathSegments - Additional path segments to apply relative to the first
261
- * argument.
262
- * @throws If the final path has an even number of segments and does not point
263
- * to a collection.
264
- * @returns The `CollectionReference` instance.
265
- */
266
- export declare function collection<AppModelType, DbModelType extends DocumentData>(
267
- reference: DocumentReference<AppModelType, DbModelType>,
268
- path: string,
269
- ...pathSegments: string[]
270
- ): CollectionReference<DocumentData, DocumentData>;
271
-
272
- /**
273
- * Gets a `CollectionReference` instance that refers to a subcollection of
274
- * `reference` at the specified relative path.
275
- *
276
- * @param reference - A reference to a Firestore document.
277
- * @param path - A slash-separated path to a collection.
278
- * @param pathSegments - Additional path segments that will be applied relative
279
- * to the first argument.
280
- * @throws If the final path has an even number of segments and does not point
281
- * to a collection.
282
- * @returns The `CollectionReference` instance.
283
- */
284
- export function collection(
285
- reference: DocumentReference,
286
- path: string,
287
- ...pathSegments: string[]
288
- ): CollectionReference<DocumentData>;
289
-
290
- export function collection(
291
- parent: Firestore | DocumentReference<unknown> | CollectionReference<unknown>,
292
- path: string,
293
- ...pathSegments: string[]
294
- ): CollectionReference<DocumentData>;
295
-
296
- /**
297
- *Returns true if the provided references are equal.
298
- *
299
- * @param left DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType> A reference to compare.
300
- * @param right DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType> A reference to compare.
301
- * @return boolean true if the references point to the same location in the same Firestore database.
302
- */
303
- export declare function refEqual<AppModelType, DbModelType extends DocumentData>(
304
- left:
305
- | DocumentReference<AppModelType, DbModelType>
306
- | CollectionReference<AppModelType, DbModelType>,
307
- right:
308
- | DocumentReference<AppModelType, DbModelType>
309
- | CollectionReference<AppModelType, DbModelType>,
310
- ): boolean;
311
-
312
- /**
313
- * Creates and returns a new `Query` instance that includes all documents in the
314
- * database that are contained in a collection or subcollection with the
315
- * given `collectionId`.
316
- *
317
- * @param firestore - A reference to the root `Firestore` instance.
318
- * @param collectionId - Identifies the collections to query over. Every
319
- * collection or subcollection with this ID as the last segment of its path
320
- * will be included. Cannot contain a slash.
321
- * @returns The created `Query`.
322
- */
323
- export function collectionGroup(
324
- firestore: Firestore,
325
- collectionId: string,
326
- ): Query<DocumentData, DocumentData>;
327
-
328
- /**
329
- * Writes to the document referred to by this `DocumentReference`. If the
330
- * document does not yet exist, it will be created.
331
- *
332
- * @param reference - A reference to the document to write.
333
- * @param data - A map of the fields and values for the document.
334
- * @returns A `Promise` resolved once the data has been successfully written
335
- * to the backend (note that it won't resolve while you're offline).
336
- */
337
- export function setDoc<T>(reference: DocumentReference<T>, data: WithFieldValue<T>): Promise<void>;
338
-
339
- /**
340
- * Writes to the document referred to by the specified `DocumentReference`. If
341
- * the document does not yet exist, it will be created. If you provide `merge`
342
- * or `mergeFields`, the provided data can be merged into an existing document.
343
- *
344
- * @param reference - A reference to the document to write.
345
- * @param data - A map of the fields and values for the document.
346
- * @param options - An object to configure the set behavior.
347
- * @returns A Promise resolved once the data has been successfully written
348
- * to the backend (note that it won't resolve while you're offline).
349
- */
350
- export function setDoc<T>(
351
- reference: DocumentReference<T>,
352
- data: PartialWithFieldValue<T>,
353
- options: FirebaseFirestoreTypes.SetOptions,
354
- ): Promise<void>;
355
-
356
- export function setDoc<T>(
357
- reference: DocumentReference<T>,
358
- data: PartialWithFieldValue<T>,
359
- options?: FirebaseFirestoreTypes.SetOptions,
360
- ): Promise<void>;
361
-
362
- /**
363
- * Updates fields in the document referred to by the specified
364
- * `DocumentReference`. The update will fail if applied to a document that does
365
- * not exist.
366
- *
367
- * @param reference - A reference to the document to update.
368
- * @param data - An object containing the fields and values with which to
369
- * update the document. Fields can contain dots to reference nested fields
370
- * within the document.
371
- * @returns A `Promise` resolved once the data has been successfully written
372
- * to the backend (note that it won't resolve while you're offline).
373
- */
374
- export function updateDoc<T>(reference: DocumentReference<T>, data: UpdateData<T>): Promise<void>;
375
- /**
376
- * Updates fields in the document referred to by the specified
377
- * `DocumentReference` The update will fail if applied to a document that does
378
- * not exist.
379
- *
380
- * Nested fields can be updated by providing dot-separated field path
381
- * strings or by providing `FieldPath` objects.
382
- *
383
- * @param reference - A reference to the document to update.
384
- * @param field - The first field to update.
385
- * @param value - The first value.
386
- * @param moreFieldsAndValues - Additional key value pairs.
387
- * @returns A `Promise` resolved once the data has been successfully written
388
- * to the backend (note that it won't resolve while you're offline).
389
- */
390
- export function updateDoc(
391
- reference: DocumentReference<unknown>,
392
- field: string | FieldPath,
393
- value: unknown,
394
- ...moreFieldsAndValues: unknown[]
395
- ): Promise<void>;
396
-
397
- /**
398
- * Add a new document to specified `CollectionReference` with the given data,
399
- * assigning it a document ID automatically.
400
- *
401
- * @param reference - A reference to the collection to add this document to.
402
- * @param data - An Object containing the data for the new document.
403
- * @returns A `Promise` resolved with a `DocumentReference` pointing to the
404
- * newly created document after it has been written to the backend (Note that it
405
- * won't resolve while you're offline).
406
- */
407
- export declare function addDoc<AppModelType, DbModelType extends DocumentData>(
408
- reference: CollectionReference<AppModelType, DbModelType>,
409
- data: WithFieldValue<AppModelType>,
410
- ): Promise<DocumentReference<AppModelType, DbModelType>>;
411
-
412
- /**
413
- * Re-enables use of the network for this {@link Firestore} instance after a prior
414
- * call to {@link disableNetwork}.
415
- *
416
- * @returns A `Promise` that is resolved once the network has been enabled.
417
- */
418
- export function enableNetwork(firestore: Firestore): Promise<void>;
419
-
420
- /**
421
- * Disables network usage for this instance. It can be re-enabled via {@link
422
- * enableNetwork}. While the network is disabled, any snapshot listeners,
423
- * `getDoc()` or `getDocs()` calls will return results from cache, and any write
424
- * operations will be queued until the network is restored.
425
- *
426
- * @returns A `Promise` that is resolved once the network has been disabled.
427
- */
428
- export function disableNetwork(firestore: Firestore): Promise<void>;
429
-
430
- /**
431
- * Aimed primarily at clearing up any data cached from running tests. Needs to be executed before any database calls
432
- * are made.
433
- *
434
- * Deprecated, please use `clearIndexedDbPersistence` instead.
435
- * @param firestore - A reference to the root `Firestore` instance.
436
- */
437
- export function clearPersistence(firestore: Firestore): Promise<void>;
438
-
439
- /**
440
- * Aimed primarily at clearing up any data cached from running tests. Needs to be executed before any database calls
441
- * are made.
442
- *
443
- * @param firestore - A reference to the root `Firestore` instance.
444
- */
445
- export function clearIndexedDbPersistence(firestore: Firestore): Promise<void>;
446
-
447
- /**
448
- * Terminates the provided {@link Firestore} instance.
449
- *
450
- * To restart after termination, create a new instance of FirebaseFirestore with
451
- * {@link (getFirestore:1)}.
452
- *
453
- * Termination does not cancel any pending writes, and any promises that are
454
- * awaiting a response from the server will not be resolved. If you have
455
- * persistence enabled, the next time you start this instance, it will resume
456
- * sending these writes to the server.
457
- *
458
- * Note: Under normal circumstances, calling `terminate()` is not required. This
459
- * function is useful only when you want to force this instance to release all
460
- * of its resources or in combination with `clearIndexedDbPersistence()` to
461
- * ensure that all local state is destroyed between test runs.
462
- *
463
- * @returns A `Promise` that is resolved when the instance has been successfully
464
- * terminated.
465
- */
466
- export function terminate(firestore: Firestore): Promise<void>;
467
-
468
- /**
469
- * Waits until all currently pending writes for the active user have been
470
- * acknowledged by the backend.
471
- *
472
- * The returned promise resolves immediately if there are no outstanding writes.
473
- * Otherwise, the promise waits for all previously issued writes (including
474
- * those written in a previous app session), but it does not wait for writes
475
- * that were added after the function is called. If you want to wait for
476
- * additional writes, call `waitForPendingWrites()` again.
477
- *
478
- * Any outstanding `waitForPendingWrites()` promises are rejected during user
479
- * changes.
480
- *
481
- * @returns A `Promise` which resolves when all currently pending writes have been
482
- * acknowledged by the backend.
483
- */
484
- export function waitForPendingWrites(firestore: Firestore): Promise<void>;
485
-
486
- /*
487
- * @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
488
- * be associated.
489
- * @param settings - A settings object to configure the {@link Firestore} instance.
490
- * @param databaseId - The name of database.
491
- * @returns A newly initialized {@link Firestore} instance.
492
- */
493
- export function initializeFirestore(
494
- app: FirebaseApp,
495
- settings: FirestoreSettings,
496
- databaseId?: string,
497
- ): Promise<Firestore>;
498
-
499
- /**
500
- * The verbosity you set for activity and error logging. Can be any of the following values:
501
- * - debug for the most verbose logging level, primarily for debugging.
502
- * - error to log errors only.
503
- * - silent to turn off logging.
504
- */
505
- type LogLevel = 'debug' | 'error' | 'silent';
506
-
507
- /**
508
- * Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
509
- * @param logLevel - The verbosity you set for activity and error logging.
510
- */
511
- export function setLogLevel(logLevel: LogLevel): void;
512
-
513
- /**
514
- * Executes the given `updateFunction` and then attempts to commit the changes
515
- * applied within the transaction. If any document read within the transaction
516
- * has changed, Cloud Firestore retries the `updateFunction`. If it fails to
517
- * commit after 5 attempts, the transaction fails.
518
- *
519
- * The maximum number of writes allowed in a single transaction is 500.
520
- *
521
- * @param firestore - A reference to the Firestore database to run this
522
- * transaction against.
523
- * @param updateFunction - The function to execute within the transaction
524
- * context.
525
- * @returns If the transaction completed successfully or was explicitly aborted
526
- * (the `updateFunction` returned a failed promise), the promise returned by the
527
- * `updateFunction `is returned here. Otherwise, if the transaction failed, a
528
- * rejected promise with the corresponding failure error is returned.
529
- */
530
- export function runTransaction<T>(
531
- firestore: Firestore,
532
- updateFunction: (transaction: FirebaseFirestoreTypes.Transaction) => Promise<T>,
533
- ): Promise<T>;
534
-
535
- /**
536
- * Calculates the number of documents in the result set of the given query,
537
- * without actually downloading the documents.
538
- *
539
- * Using this function to count the documents is efficient because only the
540
- * final count, not the documents' data, is downloaded. This function can even
541
- * count the documents if the result set would be prohibitively large to
542
- * download entirely (e.g. thousands of documents).
543
- *
544
- * The result received from the server is presented, unaltered, without
545
- * considering any local state. That is, documents in the local cache are not
546
- * taken into consideration, neither are local modifications not yet
547
- * synchronized with the server. Previously-downloaded results, if any, are not
548
- * used: every request using this source necessarily involves a round trip to
549
- * the server.
550
- *
551
- * @param query - The query whose result set size to calculate.
552
- * @returns A Promise that will be resolved with the count; the count can be
553
- * retrieved from `snapshot.data().count`, where `snapshot` is the
554
- * `AggregateQuerySnapshot` to which the returned Promise resolves.
555
- */
556
- export function getCountFromServer<AppModelType, DbModelType extends DocumentData>(
557
- query: Query<AppModelType, DbModelType>,
558
- ): Promise<
559
- FirebaseFirestoreTypes.AggregateQuerySnapshot<
560
- { count: FirebaseFirestoreTypes.AggregateField<number> },
561
- AppModelType,
562
- DbModelType
563
- >
564
- >;
565
-
566
- /**
567
- * Specifies a set of aggregations and their aliases.
568
- */
569
- interface AggregateSpec {
570
- [field: string]: AggregateFieldType;
571
- }
572
-
573
- interface FirebaseIdToken {
574
- // Always set to https://securetoken.google.com/PROJECT_ID
575
- iss: string;
576
-
577
- // Always set to PROJECT_ID
578
- aud: string;
579
-
580
- // The user's unique ID
581
- sub: string;
582
-
583
- // The token issue time, in seconds since epoch
584
- iat: number;
585
-
586
- // The token expiry time, normally 'iat' + 3600
587
- exp: number;
588
-
589
- // The user's unique ID. Must be equal to 'sub'
590
- user_id: string;
591
-
592
- // The time the user authenticated, normally 'iat'
593
- auth_time: number;
594
-
595
- // The sign in provider, only set when the provider is 'anonymous'
596
- provider_id?: 'anonymous';
597
-
598
- // The user's primary email
599
- email?: string;
600
-
601
- // The user's email verification status
602
- email_verified?: boolean;
603
-
604
- // The user's primary phone number
605
- phone_number?: string;
606
-
607
- // The user's display name
608
- name?: string;
609
-
610
- // The user's profile photo URL
611
- picture?: string;
612
-
613
- // Information on all identities linked to this user
614
- firebase: {
615
- // The primary sign-in provider
616
- sign_in_provider: FirebaseSignInProvider;
617
-
618
- // A map of providers to the user's list of unique identifiers from
619
- // each provider
620
- identities?: { [provider in FirebaseSignInProvider]?: string[] };
621
- };
622
-
623
- // Custom claims set by the developer
624
- [claim: string]: unknown;
625
-
626
- uid?: never; // Try to catch a common mistake of "uid" (should be "sub" instead).
627
- }
628
-
629
- /**
630
- * The union of all `AggregateField` types that are supported by Firestore.
631
- */
632
- export type AggregateFieldType =
633
- | ReturnType<typeof sum>
634
- | ReturnType<typeof average>
635
- | ReturnType<typeof count>;
636
-
637
- export function getAggregateFromServer<
638
- AggregateSpecType extends AggregateSpec,
639
- AppModelType,
640
- DbModelType extends DocumentData,
641
- >(
642
- query: Query<AppModelType, DbModelType>,
643
- aggregateSpec: AggregateSpecType,
644
- ): Promise<AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>>;
645
-
646
- /**
647
- * Create an AggregateField object that can be used to compute the sum of
648
- * a specified field over a range of documents in the result set of a query.
649
- * @param field Specifies the field to sum across the result set.
650
- */
651
- export function sum(field: string | FieldPath): AggregateField<number>;
652
-
653
- /**
654
- * Create an AggregateField object that can be used to compute the average of
655
- * a specified field over a range of documents in the result set of a query.
656
- * @param field Specifies the field to average across the result set.
657
- */
658
- export function average(field: string | FieldPath): AggregateField<number | null>;
659
-
660
- /**
661
- * Create an AggregateField object that can be used to compute the count of
662
- * documents in the result set of a query.
663
- */
664
- export function count(): AggregateField<number>;
665
-
666
- /**
667
- * Represents an aggregation that can be performed by Firestore.
668
- */
669
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
670
- export class AggregateField<T> {
671
- /** A type string to uniquely identify instances of this class. */
672
- readonly type = 'AggregateField';
673
-
674
- /** Indicates the aggregation operation of this AggregateField. */
675
- readonly aggregateType: AggregateType;
676
-
677
- /**
678
- * Create a new AggregateField<T>
679
- * @param aggregateType Specifies the type of aggregation operation to perform.
680
- * @param _internalFieldPath Optionally specifies the field that is aggregated.
681
- * @internal
682
- */
683
- constructor(
684
- aggregateType: AggregateType = 'count',
685
- readonly _internalFieldPath?: InternalFieldPath,
686
- ) {
687
- this.aggregateType = aggregateType;
688
- }
689
- }
690
-
691
- /**
692
- * Represents the task of loading a Firestore bundle.
693
- * It provides progress of bundle loading, as well as task completion and error events.
694
- */
695
- type LoadBundleTask = Promise<FirebaseFirestoreTypes.LoadBundleTaskProgress>;
696
-
697
- /**
698
- * Loads a Firestore bundle into the local cache.
699
- *
700
- * @param firestore - The {@link Firestore} instance to load bundles for.
701
- * @param bundleData - An object representing the bundle to be loaded. Valid
702
- * objects are `ArrayBuffer`, `ReadableStream<Uint8Array>` or `string`.
703
- *
704
- * @returns A `LoadBundleTask` object, which notifies callers with progress
705
- * updates, and completion or error events. It can be used as a
706
- * `Promise<LoadBundleTaskProgress>`.
707
- */
708
- export function loadBundle(
709
- firestore: Firestore,
710
- bundleData: ReadableStream<Uint8Array> | ArrayBuffer | string,
711
- ): LoadBundleTask;
712
-
713
- /**
714
- * Reads a Firestore {@link Query} from local cache, identified by the given
715
- * name.
716
- *
717
- * The named queries are packaged into bundles on the server side (along
718
- * with resulting documents), and loaded to local cache using `loadBundle`. Once
719
- * in local cache, use this method to extract a {@link Query} by name.
720
- *
721
- * @param firestore - The {@link Firestore} instance to read the query from.
722
- * @param name - The name of the query.
723
- * @returns A named Query.
724
- */
725
- export function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;
726
-
727
- /**
728
- * Creates a write batch, used for performing multiple writes as a single
729
- * atomic operation. The maximum number of writes allowed in a single WriteBatch
730
- * is 500.
731
- *
732
- * The result of these writes will only be reflected in document reads that
733
- * occur after the returned promise resolves. If the client is offline, the
734
- * write fails. If you would like to see local modifications or buffer writes
735
- * until the client is online, use the full Firestore SDK.
736
- *
737
- * @returns A `WriteBatch` that can be used to atomically execute multiple
738
- * writes.
739
- */
740
- export function writeBatch(firestore: Firestore): FirebaseFirestoreTypes.WriteBatch;
741
-
742
- /**
743
- * Gets the `PersistentCacheIndexManager` instance used by this Cloud Firestore instance.
744
- * This is not the same as Cloud Firestore Indexes.
745
- * Persistent cache indexes are optional indexes that only exist within the SDK to assist in local query execution.
746
- * @param {Firestore} - The Firestore instance.
747
- * @return {PersistentCacheIndexManager | null} - The `PersistentCacheIndexManager` instance or `null` if local persistent storage is not in use.
748
- */
749
- export function getPersistentCacheIndexManager(
750
- firestore: Firestore,
751
- ): PersistentCacheIndexManager | null;
752
- /**
753
- * Enables the SDK to create persistent cache indexes automatically for local query
754
- * execution when the SDK believes cache indexes can help improves performance.
755
- * This feature is disabled by default.
756
- * @param {PersistentCacheIndexManager} - The `PersistentCacheIndexManager` instance.
757
- * @return {Promise<void>} - A promise that resolves when the operation is complete.
758
- */
759
- export function enablePersistentCacheIndexAutoCreation(
760
- indexManager: PersistentCacheIndexManager,
761
- ): Promise<void>;
762
- /**
763
- * Stops creating persistent cache indexes automatically for local query execution.
764
- * The indexes which have been created by calling `enableIndexAutoCreation()` still take effect.
765
- * @param {PersistentCacheIndexManager} - The `PersistentCacheIndexManager` instance.
766
- * @return {Promise<void>} - A promise that resolves when the operation is complete.
767
- */
768
- export function disablePersistentCacheIndexAutoCreation(
769
- indexManager: PersistentCacheIndexManager,
770
- ): Promise<void>;
771
- /**
772
- * Removes all persistent cache indexes. Note this function also deletes indexes
773
- * generated by `setIndexConfiguration()`, which is deprecated.
774
- * @param {PersistentCacheIndexManager} - The `PersistentCacheIndexManager` instance.
775
- * @return {Promise<void>} - A promise that resolves when the operation is complete.
776
- */
777
- export function deleteAllPersistentCacheIndexes(
778
- indexManager: PersistentCacheIndexManager,
779
- ): Promise<void>;
780
-
781
- export * from './query';
782
- export * from './snapshot';
783
- export * from './Bytes';
784
- export * from './FieldPath';
785
- export * from './FieldValue';
786
- export * from './GeoPoint';
787
- export * from './Timestamp';
788
- export * from './VectorValue';