@react-native-firebase/firestore 23.8.6 → 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 +35 -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
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import Foundation
18
+ import FirebaseFirestore
19
+
20
+ final class RNFBFirestorePipelineSnapshotSerializer {
21
+ private static let metadataFallbackStages: Set<String> = ["select", "addFields", "removeFields"]
22
+
23
+ func buildExecutionMetadata(_ pipeline: RNFBFirestoreParsedPipelineRequest) -> PipelineExecutionMetadata {
24
+ guard pipeline.source.sourceType == "documents",
25
+ pipeline.stages.allSatisfy({ Self.metadataFallbackStages.contains($0.stageName) }),
26
+ !pipeline.source.documents.isEmpty else {
27
+ return .empty
28
+ }
29
+
30
+ return PipelineExecutionMetadata(sourceDocumentPaths: pipeline.source.documents)
31
+ }
32
+
33
+ func serializeSnapshot(
34
+ _ snapshot: __PipelineSnapshotBridge?,
35
+ metadata: PipelineExecutionMetadata
36
+ ) throws -> [AnyHashable: Any] {
37
+ var output: [AnyHashable: Any] = [:]
38
+ let results = snapshot?.results ?? []
39
+ let resultCount = results.count
40
+
41
+ output["results"] = results.enumerated().map { index, result in
42
+ serializeResult(result, fallbackPath: metadata.fallbackPath(for: index, resultCount: resultCount))
43
+ }
44
+
45
+ guard let executionTime = snapshot?.execution_time else {
46
+ throw PipelineValidationError("pipelineExecute() expected native snapshot to include executionTime.")
47
+ }
48
+
49
+ output["executionTime"] = serializeTimestamp(executionTime)
50
+
51
+ return output
52
+ }
53
+
54
+ private func serializeResult(_ result: __PipelineResultBridge, fallbackPath: String?) -> [AnyHashable: Any] {
55
+ var map: [AnyHashable: Any] = [:]
56
+
57
+ let path = result.reference?.path ?? fallbackPath
58
+ if let path {
59
+ map["path"] = path
60
+ }
61
+
62
+ if let id = result.documentID ?? path?.split(separator: "/").last.map(String.init) {
63
+ map["id"] = id
64
+ } else {
65
+ map["id"] = NSNull()
66
+ }
67
+
68
+ map["data"] = RNFBFirestoreSerialize.serializeDictionary(result.data())
69
+ map["createTime"] = result.create_time.map(serializeTimestamp) ?? NSNull()
70
+ map["updateTime"] = result.update_time.map(serializeTimestamp) ?? NSNull()
71
+
72
+ return map
73
+ }
74
+
75
+ private func serializeTimestamp(_ timestamp: Timestamp) -> [AnyHashable: Any] {
76
+ [
77
+ "seconds": NSNumber(value: timestamp.seconds),
78
+ "nanoseconds": NSNumber(value: timestamp.nanoseconds),
79
+ ]
80
+ }
81
+ }
82
+
83
+ struct PipelineExecutionMetadata {
84
+ static let empty = PipelineExecutionMetadata(sourceDocumentPaths: [])
85
+
86
+ let sourceDocumentPaths: [String]
87
+
88
+ func fallbackPath(for index: Int, resultCount: Int) -> String? {
89
+ guard !sourceDocumentPaths.isEmpty,
90
+ sourceDocumentPaths.count == resultCount,
91
+ index >= 0,
92
+ index < sourceDocumentPaths.count else {
93
+ return nil
94
+ }
95
+
96
+ return sourceDocumentPaths[index]
97
+ }
98
+ }
@@ -19,12 +19,10 @@ import { isString } from '@react-native-firebase/app/dist/module/common';
19
19
 
20
20
  const RESERVED = new RegExp('[~*/\\[\\]]');
21
21
 
22
- export default class FirestoreFieldPath {
23
- static documentId() {
24
- return DOCUMENT_ID;
25
- }
22
+ export default class FieldPath {
23
+ _segments: string[];
26
24
 
27
- constructor(...segments) {
25
+ constructor(...segments: string[]) {
28
26
  if (segments.length === 0) {
29
27
  throw new Error('firebase.firestore.FieldPath cannot construct FieldPath with no segments.');
30
28
  }
@@ -41,8 +39,8 @@ export default class FirestoreFieldPath {
41
39
  this._segments = segments;
42
40
  }
43
41
 
44
- isEqual(other) {
45
- if (!(other instanceof FirestoreFieldPath)) {
42
+ isEqual(other: FieldPath): boolean {
43
+ if (!(other instanceof FieldPath)) {
46
44
  throw new Error(
47
45
  "firebase.firestore.FieldPath.isEqual(*) 'other' expected instance of FieldPath.",
48
46
  );
@@ -51,18 +49,18 @@ export default class FirestoreFieldPath {
51
49
  return this._toPath() === other._toPath();
52
50
  }
53
51
 
54
- _toPath() {
52
+ _toPath(): string {
55
53
  return this._segments.join('.');
56
54
  }
57
55
 
58
- _toArray() {
56
+ _toArray(): string[] {
59
57
  return this._segments;
60
58
  }
61
59
  }
62
60
 
63
- export const DOCUMENT_ID = new FirestoreFieldPath('__name__');
61
+ export const DOCUMENT_ID = new FieldPath('__name__');
64
62
 
65
- export function fromDotSeparatedString(path) {
63
+ export function fromDotSeparatedString(path: string): FieldPath {
66
64
  if (path === '' || path.startsWith('.') || path.endsWith('.') || path.indexOf('..') > 0) {
67
65
  throw new Error(
68
66
  "Invalid field path. Paths must not be empty, begin with '.', end with '.', or contain '..'.",
@@ -77,5 +75,5 @@ export function fromDotSeparatedString(path) {
77
75
  );
78
76
  }
79
77
 
80
- return new FirestoreFieldPath(...path.split('.'));
78
+ return new FieldPath(...path.split('.'));
81
79
  }
@@ -24,11 +24,11 @@ export const TypeFieldValueRemove = 'array_remove';
24
24
  export const TypeFieldValueUnion = 'array_union';
25
25
  export const TypeFieldValueTimestamp = 'timestamp';
26
26
 
27
- function validateArrayElements(elements) {
27
+ function validateArrayElements(elements: unknown[]): void {
28
28
  for (let i = 0; i < elements.length; i++) {
29
29
  const element = elements[i];
30
30
 
31
- if (element instanceof FirestoreFieldValue) {
31
+ if (element instanceof FieldValue) {
32
32
  throw new Error('FieldValue instance cannot be used with other FieldValue methods.');
33
33
  }
34
34
 
@@ -38,8 +38,11 @@ function validateArrayElements(elements) {
38
38
  }
39
39
  }
40
40
 
41
- export default class FirestoreFieldValue {
42
- constructor(internal = false, type, elements) {
41
+ export default class FieldValue {
42
+ _type: string;
43
+ _elements: unknown;
44
+
45
+ constructor(internal = false, type = '', elements?: unknown) {
43
46
  if (internal === false) {
44
47
  throw new Error(
45
48
  'firebase.firestore.FieldValue constructor is private, use FieldValue.<field>() instead.',
@@ -50,48 +53,48 @@ export default class FirestoreFieldValue {
50
53
  this._elements = elements;
51
54
  }
52
55
 
53
- static delete() {
54
- return new FirestoreFieldValue(true, TypeFieldValueDelete);
56
+ static delete(): FieldValue {
57
+ return new FieldValue(true, TypeFieldValueDelete);
55
58
  }
56
59
 
57
- static increment(n) {
60
+ static increment(n: number): FieldValue {
58
61
  if (!isNumber(n)) {
59
62
  throw new Error("firebase.firestore.FieldValue.increment(*) 'n' expected a number value.");
60
63
  }
61
64
 
62
- return new FirestoreFieldValue(true, TypeFieldValueIncrement, n);
65
+ return new FieldValue(true, TypeFieldValueIncrement, n);
63
66
  }
64
67
 
65
- static serverTimestamp() {
66
- return new FirestoreFieldValue(true, TypeFieldValueTimestamp);
68
+ static serverTimestamp(): FieldValue {
69
+ return new FieldValue(true, TypeFieldValueTimestamp);
67
70
  }
68
71
 
69
- static arrayUnion(...elements) {
72
+ static arrayUnion(...elements: unknown[]): FieldValue {
70
73
  try {
71
74
  validateArrayElements(elements);
72
75
  } catch (e) {
73
76
  throw new Error(
74
- `firebase.firestore.FieldValue.arrayUnion(*) 'elements' called with invalid data. ${e.message}`,
77
+ `firebase.firestore.FieldValue.arrayUnion(*) 'elements' called with invalid data. ${(e as Error).message}`,
75
78
  );
76
79
  }
77
80
 
78
- return new FirestoreFieldValue(true, TypeFieldValueUnion, buildNativeArray(elements));
81
+ return new FieldValue(true, TypeFieldValueUnion, buildNativeArray(elements));
79
82
  }
80
83
 
81
- static arrayRemove(...elements) {
84
+ static arrayRemove(...elements: unknown[]): FieldValue {
82
85
  try {
83
86
  validateArrayElements(elements);
84
87
  } catch (e) {
85
88
  throw new Error(
86
- `firebase.firestore.FieldValue.arrayRemove(*) 'elements' called with invalid data. ${e.message}`,
89
+ `firebase.firestore.FieldValue.arrayRemove(*) 'elements' called with invalid data. ${(e as Error).message}`,
87
90
  );
88
91
  }
89
92
 
90
- return new FirestoreFieldValue(true, TypeFieldValueRemove, buildNativeArray(elements));
93
+ return new FieldValue(true, TypeFieldValueRemove, buildNativeArray(elements));
91
94
  }
92
95
 
93
- isEqual(other) {
94
- if (!(other instanceof FirestoreFieldValue)) {
96
+ isEqual(other: FieldValue): boolean {
97
+ if (!(other instanceof FieldValue)) {
95
98
  throw new Error(
96
99
  "firebase.firestore.FieldValue.isEqual(*) 'other' expected a FieldValue instance.",
97
100
  );
@@ -104,4 +107,4 @@ export default class FirestoreFieldValue {
104
107
  }
105
108
  }
106
109
 
107
- provideFieldValueClass(FirestoreFieldValue); // serialize
110
+ provideFieldValueClass(FieldValue as Parameters<typeof provideFieldValueClass>[0]);
@@ -0,0 +1,124 @@
1
+ /*
2
+ * Copyright (c) 2022-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import type {
19
+ AggregateSpec,
20
+ AggregateSpecData,
21
+ AggregateType,
22
+ DocumentData,
23
+ Query as FirestoreQuery,
24
+ } from './types/firestore';
25
+ import FieldPath, { fromDotSeparatedString } from './FieldPath';
26
+
27
+ import type FirestorePath from './FirestorePath';
28
+ import type Query from './FirestoreQuery';
29
+ import type QueryModifiers from './FirestoreQueryModifiers';
30
+ import type { FirestoreInternal } from './types/internal';
31
+
32
+ export class AggregateQuery {
33
+ _firestore: FirestoreInternal;
34
+ _query: Query;
35
+ _collectionPath: FirestorePath;
36
+ _modifiers: QueryModifiers;
37
+
38
+ constructor(
39
+ firestore: FirestoreInternal,
40
+ query: Query,
41
+ collectionPath: FirestorePath,
42
+ modifiers: QueryModifiers,
43
+ ) {
44
+ this._firestore = firestore;
45
+ this._query = query;
46
+ this._collectionPath = collectionPath;
47
+ this._modifiers = modifiers;
48
+ }
49
+
50
+ get query(): Query {
51
+ return this._query;
52
+ }
53
+
54
+ get(): Promise<AggregateQuerySnapshot> {
55
+ return this._firestore.native
56
+ .collectionCount(
57
+ this._collectionPath.relativeName,
58
+ this._modifiers.type,
59
+ this._modifiers.filters,
60
+ this._modifiers.orders,
61
+ this._modifiers.options,
62
+ )
63
+ .then((data: { count?: number }) => new AggregateQuerySnapshot(this._query, data, true));
64
+ }
65
+ }
66
+
67
+ export class AggregateQuerySnapshot<
68
+ AggregateSpecType extends AggregateSpec = AggregateSpec,
69
+ AppModelType = DocumentData,
70
+ DbModelType extends DocumentData = DocumentData,
71
+ > {
72
+ readonly type = 'AggregateQuerySnapshot';
73
+ _query: FirestoreQuery<AppModelType, DbModelType>;
74
+ _data: { count?: number; [key: string]: unknown };
75
+ _isGetCountFromServer: boolean;
76
+
77
+ constructor(
78
+ query: FirestoreQuery<AppModelType, DbModelType>,
79
+ data: { count?: number; [key: string]: unknown },
80
+ isGetCountFromServer: boolean,
81
+ ) {
82
+ this._query = query;
83
+ this._data = data;
84
+ this._isGetCountFromServer = isGetCountFromServer;
85
+ }
86
+
87
+ get query(): FirestoreQuery<AppModelType, DbModelType> {
88
+ return this._query;
89
+ }
90
+
91
+ data(): AggregateSpecData<AggregateSpecType> {
92
+ if (this._isGetCountFromServer) {
93
+ return { count: this._data.count } as AggregateSpecData<AggregateSpecType>;
94
+ }
95
+ return { ...this._data } as AggregateSpecData<AggregateSpecType>;
96
+ }
97
+
98
+ _fieldsProto(): Record<string, unknown> {
99
+ return { ...this._data };
100
+ }
101
+ }
102
+
103
+ export class AggregateField<T = unknown> {
104
+ readonly type = 'AggregateField';
105
+ readonly aggregateType: AggregateType;
106
+ readonly _internalFieldPath?: FieldPath;
107
+ // Phantom property to anchor the type parameter T for AggregateSpecData inference.
108
+ _phantomType?: T;
109
+
110
+ constructor(aggregateType: AggregateType = 'count', fieldPath?: FieldPath) {
111
+ this.aggregateType = aggregateType;
112
+ this._internalFieldPath = fieldPath;
113
+ }
114
+ }
115
+
116
+ export function fieldPathFromArgument(path: string | FieldPath): FieldPath {
117
+ if (path instanceof FieldPath) {
118
+ return path;
119
+ }
120
+ if (typeof path === 'string') {
121
+ return fromDotSeparatedString(path);
122
+ }
123
+ throw new Error('Field path arguments must be of type `string` or `FieldPath`');
124
+ }
@@ -0,0 +1,73 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import { Base64, isString } from '@react-native-firebase/app/dist/module/common';
19
+
20
+ export default class Blob {
21
+ _binaryString: string;
22
+
23
+ constructor(internal = false, binaryString?: string) {
24
+ if (internal === false) {
25
+ throw new Error(
26
+ 'firebase.firestore.Blob constructor is private, use Blob.<field>() instead.',
27
+ );
28
+ }
29
+
30
+ this._binaryString = binaryString ?? '';
31
+ }
32
+
33
+ static fromBase64String(base64: string): Blob {
34
+ if (!isString(base64) || base64.length < 1) {
35
+ throw new Error(
36
+ 'firestore.Blob.fromBase64String expects a string of at least 1 character in length',
37
+ );
38
+ }
39
+
40
+ return new Blob(true, Base64.atob(base64));
41
+ }
42
+
43
+ static fromUint8Array(array: Uint8Array): Blob {
44
+ if (!(array instanceof Uint8Array)) {
45
+ throw new Error('firestore.Blob.fromUint8Array expects an instance of Uint8Array');
46
+ }
47
+
48
+ return new Blob(
49
+ true,
50
+ Array.prototype.map.call(array, (byte: number) => String.fromCharCode(byte)).join(''),
51
+ );
52
+ }
53
+
54
+ isEqual(blob: Blob): boolean {
55
+ if (!(blob instanceof Blob)) {
56
+ throw new Error('firestore.Blob.isEqual expects an instance of Blob');
57
+ }
58
+
59
+ return this._binaryString === blob._binaryString;
60
+ }
61
+
62
+ toBase64(): string {
63
+ return Base64.btoa(this._binaryString);
64
+ }
65
+
66
+ toUint8Array(): Uint8Array {
67
+ return new Uint8Array(this._binaryString.split('').map(char => char.charCodeAt(0)));
68
+ }
69
+
70
+ toString(): string {
71
+ return `firestore.Blob(base64: ${this.toBase64()})`;
72
+ }
73
+ }
@@ -0,0 +1,99 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import {
19
+ generateFirestoreId,
20
+ isObject,
21
+ isNull,
22
+ isUndefined,
23
+ } from '@react-native-firebase/app/dist/module/common';
24
+ import DocumentReference, { provideCollectionReferenceClass } from './FirestoreDocumentReference';
25
+ import Query from './FirestoreQuery';
26
+ import QueryModifiers from './FirestoreQueryModifiers';
27
+ import { validateWithConverter } from './utils';
28
+
29
+ import type FirestorePath from './FirestorePath';
30
+ import type { DocumentData, FirestoreDataConverter } from './types/firestore';
31
+ import type { FirestoreInternal } from './types/internal';
32
+
33
+ export default class CollectionReference extends Query {
34
+ constructor(
35
+ firestore: FirestoreInternal,
36
+ collectionPath: FirestorePath,
37
+ converter?: FirestoreDataConverter<DocumentData, DocumentData> | null,
38
+ ) {
39
+ super(firestore, collectionPath, new QueryModifiers(), undefined, converter);
40
+ }
41
+
42
+ get id(): string {
43
+ return this._collectionPath.id;
44
+ }
45
+
46
+ get parent(): DocumentReference | null {
47
+ const parent = this._collectionPath.parent();
48
+ if (!parent) {
49
+ return null;
50
+ }
51
+ return new DocumentReference(this._firestore, parent);
52
+ }
53
+
54
+ get path(): string {
55
+ return this._collectionPath.relativeName;
56
+ }
57
+
58
+ add(data: Record<string, unknown>): Promise<DocumentReference> {
59
+ if (!isObject(data)) {
60
+ throw new Error("firebase.firestore().collection().add(*) 'data' must be an object.");
61
+ }
62
+
63
+ const documentRef = this.doc();
64
+ return documentRef.set(data).then(() => Promise.resolve(documentRef));
65
+ }
66
+
67
+ doc(documentPath?: string): DocumentReference {
68
+ const newPath = documentPath ?? generateFirestoreId();
69
+ const path = this._collectionPath.child(newPath);
70
+
71
+ if (!path.isDocument) {
72
+ throw new Error(
73
+ "firebase.firestore().collection().doc(*) 'documentPath' must point to a document.",
74
+ );
75
+ }
76
+
77
+ return new DocumentReference(this._firestore, path, this._converter);
78
+ }
79
+
80
+ withConverter(converter: unknown): CollectionReference {
81
+ if (isUndefined(converter) || isNull(converter)) {
82
+ return new CollectionReference(this._firestore, this._collectionPath, null);
83
+ }
84
+
85
+ try {
86
+ validateWithConverter(converter);
87
+ } catch (e) {
88
+ throw new Error(`firebase.firestore().collection().withConverter() ${(e as Error).message}`);
89
+ }
90
+
91
+ return new CollectionReference(
92
+ this._firestore,
93
+ this._collectionPath,
94
+ converter as FirestoreDataConverter<DocumentData, DocumentData>,
95
+ );
96
+ }
97
+ }
98
+
99
+ provideCollectionReferenceClass(CollectionReference);
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import { createDeprecationProxy } from '@react-native-firebase/app/dist/module/common';
19
+ import DocumentSnapshot from './FirestoreDocumentSnapshot';
20
+ import type { FirestoreInternal } from './types/internal';
21
+ import type { DocumentData, FirestoreDataConverter } from './types/firestore';
22
+
23
+ const TYPE_MAP: Record<string, 'added' | 'modified' | 'removed'> = {
24
+ a: 'added',
25
+ m: 'modified',
26
+ r: 'removed',
27
+ };
28
+
29
+ export interface DocumentChangeNativeData {
30
+ type: string;
31
+ doc: { path: string; data?: unknown; metadata?: [boolean, boolean]; exists?: boolean };
32
+ ni: number;
33
+ oi: number;
34
+ isMetadataChange?: boolean;
35
+ }
36
+
37
+ export default class DocumentChange {
38
+ _firestore: FirestoreInternal;
39
+ _nativeData: DocumentChangeNativeData;
40
+ _isMetadataChange: boolean;
41
+ _converter: FirestoreDataConverter<DocumentData, DocumentData> | null;
42
+
43
+ constructor(
44
+ firestore: FirestoreInternal,
45
+ nativeData: DocumentChangeNativeData,
46
+ converter: FirestoreDataConverter<DocumentData, DocumentData> | null,
47
+ ) {
48
+ this._firestore = firestore;
49
+ this._nativeData = nativeData;
50
+ this._isMetadataChange = nativeData.isMetadataChange ?? false;
51
+ this._converter = converter;
52
+ }
53
+
54
+ get doc(): DocumentSnapshot {
55
+ return createDeprecationProxy(
56
+ new DocumentSnapshot(this._firestore, this._nativeData.doc, this._converter),
57
+ ) as DocumentSnapshot;
58
+ }
59
+
60
+ get newIndex(): number {
61
+ return this._nativeData.ni;
62
+ }
63
+
64
+ get oldIndex(): number {
65
+ return this._nativeData.oi;
66
+ }
67
+
68
+ get type(): 'added' | 'modified' | 'removed' {
69
+ return TYPE_MAP[this._nativeData.type] ?? 'modified';
70
+ }
71
+ }