@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,3 +1,5 @@
1
+ "use strict";
2
+
1
3
  /*
2
4
  * Copyright (c) 2016-present Invertase Limited & Contributors
3
5
  *
@@ -15,97 +17,95 @@
15
17
  *
16
18
  */
17
19
 
18
- import { isDate, isNumber } from '@react-native-firebase/app/dist/module/common';
20
+ import { isDate, isNumber, isObject } from '@react-native-firebase/app/dist/module/common';
19
21
 
20
- // The earlist date supported by Firestore timestamps (0001-01-01T00:00:00Z).
22
+ // Earliest date supported by Firestore timestamps (0001-01-01T00:00:00Z).
21
23
  const MIN_SECONDS = -62135596800;
22
-
23
- export default class FirestoreTimestamp {
24
+ export default class Timestamp {
24
25
  static now() {
25
- return FirestoreTimestamp.fromMillis(Date.now());
26
+ return Timestamp.fromMillis(Date.now());
26
27
  }
27
-
28
28
  static fromDate(date) {
29
29
  if (!isDate(date)) {
30
- throw new Error(
31
- "firebase.firestore.Timestamp.fromDate(*) 'date' expected a valid Date object.",
32
- );
30
+ throw new Error("firebase.firestore.Timestamp.fromDate(*) 'date' expected a valid Date object.");
33
31
  }
34
-
35
- return FirestoreTimestamp.fromMillis(date.getTime());
32
+ return Timestamp.fromMillis(date.getTime());
36
33
  }
37
-
38
34
  static fromMillis(milliseconds) {
39
35
  const seconds = Math.floor(milliseconds / 1000);
40
36
  const nanoseconds = (milliseconds - seconds * 1000) * 1e6;
41
- return new FirestoreTimestamp(seconds, nanoseconds);
37
+ return new Timestamp(seconds, nanoseconds);
42
38
  }
43
-
44
39
  constructor(seconds, nanoseconds) {
45
40
  if (!isNumber(seconds)) {
46
41
  throw new Error("firebase.firestore.Timestamp 'seconds' expected a number value.");
47
42
  }
48
-
49
43
  if (!isNumber(nanoseconds)) {
50
44
  throw new Error("firebase.firestore.Timestamp 'nanoseconds' expected a number value.");
51
45
  }
52
-
53
46
  if (nanoseconds < 0) {
54
47
  throw new Error(`firebase.firestore.Timestamp 'nanoseconds' out of range: ${nanoseconds}`);
55
48
  }
56
-
57
49
  if (nanoseconds >= 1e9) {
58
50
  throw new Error(`firebase.firestore.Timestamp 'nanoseconds' out of range: ${nanoseconds}`);
59
51
  }
60
-
61
- // Midnight at the beginning of 1/1/1 is the earliest Firestore supports.
62
52
  if (seconds < MIN_SECONDS) {
63
53
  throw new Error(`firebase.firestore.Timestamp 'seconds' out of range: ${seconds}`);
64
54
  }
65
-
66
- // This will break in the year 10,000.
67
55
  if (seconds >= 253402300800) {
68
56
  throw new Error(`firebase.firestore.Timestamp 'seconds' out of range: ${seconds}`);
69
57
  }
70
-
71
58
  this._seconds = seconds;
72
59
  this._nanoseconds = nanoseconds;
73
60
  }
74
-
75
61
  get seconds() {
76
62
  return this._seconds;
77
63
  }
78
-
79
64
  get nanoseconds() {
80
65
  return this._nanoseconds;
81
66
  }
82
-
83
67
  isEqual(other) {
84
- if (!(other instanceof FirestoreTimestamp)) {
85
- throw Error(
86
- "firebase.firestore.Timestamp.isEqual(*) 'other' expected an instance of Timestamp.",
87
- );
68
+ if (!(other instanceof Timestamp)) {
69
+ throw Error("firebase.firestore.Timestamp.isEqual(*) 'other' expected an instance of Timestamp.");
88
70
  }
89
-
90
71
  return other.seconds === this._seconds && other.nanoseconds === this._nanoseconds;
91
72
  }
92
-
93
73
  toDate() {
94
74
  return new Date(this.toMillis());
95
75
  }
96
-
97
76
  toMillis() {
98
77
  return this._seconds * 1000 + this._nanoseconds / 1e6;
99
78
  }
100
-
79
+ _compareTo(other) {
80
+ if (this._seconds === other._seconds) {
81
+ if (this._nanoseconds < other._nanoseconds) return -1;
82
+ if (this._nanoseconds > other._nanoseconds) return 1;
83
+ return 0;
84
+ }
85
+ return this._seconds < other._seconds ? -1 : 1;
86
+ }
101
87
  toString() {
102
- return `FirestoreTimestamp(seconds=${this.seconds}, nanoseconds=${this.nanoseconds})`;
88
+ return `Timestamp(seconds=${this.seconds}, nanoseconds=${this.nanoseconds})`;
103
89
  }
104
-
90
+ static _jsonSchemaVersion = 'firestore/timestamp/1.0';
91
+ static _jsonSchema = {
92
+ type: Timestamp._jsonSchemaVersion,
93
+ seconds: 'number',
94
+ nanoseconds: 'number'
95
+ };
105
96
  toJSON() {
106
- return { seconds: this.seconds, nanoseconds: this.nanoseconds };
97
+ return {
98
+ type: Timestamp._jsonSchemaVersion,
99
+ seconds: this.seconds,
100
+ nanoseconds: this.nanoseconds
101
+ };
102
+ }
103
+ static fromJSON(json) {
104
+ if (isObject(json) && json.type === Timestamp._jsonSchemaVersion && typeof json.seconds === 'number' && typeof json.nanoseconds === 'number') {
105
+ return new Timestamp(json.seconds, json.nanoseconds);
106
+ }
107
+ throw new Error('Unexpected error creating Timestamp from JSON.');
107
108
  }
108
-
109
109
  /**
110
110
  * Converts this object to a primitive string, which allows Timestamp objects to be compared
111
111
  * using the `>`, `<=`, `>=` and `>` operators.
@@ -118,9 +118,9 @@ export default class FirestoreTimestamp {
118
118
  // having a leading negative sign (i.e. a leading '-' character) in its string representation,
119
119
  // which would affect its lexiographical ordering.
120
120
  const adjustedSeconds = this.seconds - MIN_SECONDS;
121
- // Note: Up to 12 decimal digits are required to represent all valid 'seconds' values.
122
121
  const formattedSeconds = String(adjustedSeconds).padStart(12, '0');
123
122
  const formattedNanoseconds = String(this.nanoseconds).padStart(9, '0');
124
- return formattedSeconds + '.' + formattedNanoseconds;
123
+ return `${formattedSeconds}.${formattedNanoseconds}`;
125
124
  }
126
125
  }
126
+ //# sourceMappingURL=FirestoreTimestamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isDate","isNumber","isObject","MIN_SECONDS","Timestamp","now","fromMillis","Date","fromDate","date","Error","getTime","milliseconds","seconds","Math","floor","nanoseconds","constructor","_seconds","_nanoseconds","isEqual","other","toDate","toMillis","_compareTo","toString","_jsonSchemaVersion","_jsonSchema","type","toJSON","fromJSON","json","valueOf","adjustedSeconds","formattedSeconds","String","padStart","formattedNanoseconds"],"sourceRoot":"../../lib","sources":["FirestoreTimestamp.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,+CAA+C;;AAE1F;AACA,MAAMC,WAAW,GAAG,CAAC,WAAW;AAEhC,eAAe,MAAMC,SAAS,CAAC;EAC7B,OAAOC,GAAGA,CAAA,EAAc;IACtB,OAAOD,SAAS,CAACE,UAAU,CAACC,IAAI,CAACF,GAAG,CAAC,CAAC,CAAC;EACzC;EAEA,OAAOG,QAAQA,CAACC,IAAU,EAAa;IACrC,IAAI,CAACT,MAAM,CAACS,IAAI,CAAC,EAAE;MACjB,MAAM,IAAIC,KAAK,CACb,+EACF,CAAC;IACH;IAEA,OAAON,SAAS,CAACE,UAAU,CAACG,IAAI,CAACE,OAAO,CAAC,CAAC,CAAC;EAC7C;EAEA,OAAOL,UAAUA,CAACM,YAAoB,EAAa;IACjD,MAAMC,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACH,YAAY,GAAG,IAAI,CAAC;IAC/C,MAAMI,WAAW,GAAG,CAACJ,YAAY,GAAGC,OAAO,GAAG,IAAI,IAAI,GAAG;IACzD,OAAO,IAAIT,SAAS,CAACS,OAAO,EAAEG,WAAW,CAAC;EAC5C;EAKAC,WAAWA,CAACJ,OAAe,EAAEG,WAAmB,EAAE;IAChD,IAAI,CAACf,QAAQ,CAACY,OAAO,CAAC,EAAE;MACtB,MAAM,IAAIH,KAAK,CAAC,iEAAiE,CAAC;IACpF;IAEA,IAAI,CAACT,QAAQ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pB,OAAO,GAAGV,WAAW;IAClD,MAAM+B,gBAAgB,GAAGC,MAAM,CAACF,eAAe,CAAC,CAACG,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC;IAClE,MAAMC,oBAAoB,GAAGF,MAAM,CAAC,IAAI,CAACnB,WAAW,CAAC,CAACoB,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IACtE,OAAO,GAAGF,gBAAgB,IAAIG,oBAAoB,EAAE;EACtD;AACF","ignoreList":[]}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import { isObject, createDeprecationProxy } from '@react-native-firebase/app/dist/module/common';
21
+ import DocumentReference from "./FirestoreDocumentReference.js";
22
+ import DocumentSnapshot from "./FirestoreDocumentSnapshot.js";
23
+ import { parseSetOptions, parseUpdateArgs, applyFirestoreDataConverter } from "./utils/index.js";
24
+ import { buildNativeMap } from "./utils/serialize.js";
25
+ export default class Transaction {
26
+ constructor(firestore, meta) {
27
+ this._firestore = firestore;
28
+ this._meta = meta;
29
+ this._calledGetCount = 0;
30
+ this._commandBuffer = [];
31
+ this._pendingResult = undefined;
32
+ }
33
+
34
+ /**
35
+ * Clears the command buffer and any pending result in prep for
36
+ * the next transaction iteration attempt.
37
+ */
38
+ _prepare() {
39
+ this._calledGetCount = 0;
40
+ this._commandBuffer = [];
41
+ this._pendingResult = undefined;
42
+ }
43
+
44
+ /**
45
+ * Reads the document referenced by the provided DocumentReference.
46
+ */
47
+ get(documentRef) {
48
+ if (!(documentRef instanceof DocumentReference)) {
49
+ throw new Error("firebase.firestore().runTransaction() Transaction.get(*) 'documentRef' expected a DocumentReference.");
50
+ }
51
+ this._calledGetCount++;
52
+ return this._firestore.native.transactionGetDocument(this._meta.id, documentRef.path).then(data => createDeprecationProxy(new DocumentSnapshot(this._firestore, data, null)));
53
+ }
54
+
55
+ /**
56
+ * Writes to the document referred to by the provided DocumentReference.
57
+ */
58
+ set(documentRef, data, options) {
59
+ if (!(documentRef instanceof DocumentReference)) {
60
+ throw new Error("firebase.firestore().runTransaction() Transaction.set(*) 'documentRef' expected a DocumentReference.");
61
+ }
62
+ let setOptions;
63
+ try {
64
+ setOptions = parseSetOptions(options);
65
+ } catch (e) {
66
+ throw new Error(`firebase.firestore().runTransaction() Transaction.set(_, _, *) ${e.message}.`);
67
+ }
68
+ let converted = data;
69
+ try {
70
+ converted = applyFirestoreDataConverter(data, documentRef.converter, setOptions);
71
+ } catch (e) {
72
+ throw new Error(`firebase.firestore().runTransaction() Transaction.set(_, *) 'withConverter.toFirestore' threw an error: ${e.message}.`);
73
+ }
74
+ if (!isObject(converted)) {
75
+ throw new Error("firebase.firestore().runTransaction() Transaction.set(_, *) 'data' must be an object..");
76
+ }
77
+ this._commandBuffer.push({
78
+ type: 'SET',
79
+ path: documentRef.path,
80
+ data: buildNativeMap(converted, this._firestore._settings.ignoreUndefinedProperties),
81
+ options: setOptions
82
+ });
83
+ return this;
84
+ }
85
+ update(documentRef, ...args) {
86
+ if (!(documentRef instanceof DocumentReference)) {
87
+ throw new Error("firebase.firestore().runTransaction() Transaction.update(*) 'documentRef' expected a DocumentReference.");
88
+ }
89
+ let data;
90
+ try {
91
+ data = parseUpdateArgs(args);
92
+ } catch (e) {
93
+ throw new Error(`firebase.firestore().runTransaction() Transaction.update(_, *) ${e.message}`);
94
+ }
95
+ this._commandBuffer.push({
96
+ type: 'UPDATE',
97
+ path: documentRef.path,
98
+ data: buildNativeMap(data, this._firestore._settings.ignoreUndefinedProperties)
99
+ });
100
+ return this;
101
+ }
102
+ delete(documentRef) {
103
+ if (!(documentRef instanceof DocumentReference)) {
104
+ throw new Error("firebase.firestore().runTransaction() Transaction.delete(*) 'documentRef' expected a DocumentReference.");
105
+ }
106
+ this._commandBuffer.push({
107
+ type: 'DELETE',
108
+ path: documentRef.path
109
+ });
110
+ return this;
111
+ }
112
+ }
113
+ //# sourceMappingURL=FirestoreTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isObject","createDeprecationProxy","DocumentReference","DocumentSnapshot","parseSetOptions","parseUpdateArgs","applyFirestoreDataConverter","buildNativeMap","Transaction","constructor","firestore","meta","_firestore","_meta","_calledGetCount","_commandBuffer","_pendingResult","undefined","_prepare","get","documentRef","Error","native","transactionGetDocument","id","path","then","data","set","options","setOptions","e","message","converted","converter","push","type","_settings","ignoreUndefinedProperties","update","args","delete"],"sourceRoot":"../../lib","sources":["FirestoreTransaction.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,sBAAsB,QAAQ,+CAA+C;AAChG,OAAOC,iBAAiB,MAAM,iCAA8B;AAC5D,OAAOC,gBAAgB,MAAM,gCAA6B;AAE1D,SAASC,eAAe,EAAEC,eAAe,EAAEC,2BAA2B,QAAQ,kBAAS;AACvF,SAASC,cAAc,QAAQ,sBAAmB;AAoBlD,eAAe,MAAMC,WAAW,CAAC;EAO/BC,WAAWA,CAACC,SAA4B,EAAEC,IAAqB,EAAE;IAC/D,IAAI,CAACC,UAAU,GAAGF,SAAS;IAC3B,IAAI,CAACG,KAAK,GAAGF,IAAI;IACjB,IAAI,CAACG,eAAe,GAAG,CAAC;IACxB,IAAI,CAACC,cAAc,GAAG,EAAE;IACxB,IAAI,CAACC,cAAc,GAAGC,SAAS;EACjC;;EAEA;AACF;AACA;AACA;EACEC,QAAQ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 +1,137 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import NativeError from '@react-native-firebase/app/dist/module/internal/NativeFirebaseError';
21
+ import Transaction from "./FirestoreTransaction.js";
22
+ let transactionId = 0;
23
+ const generateTransactionId = () => transactionId++;
24
+ export default class FirestoreTransactionHandler {
25
+ constructor(firestore) {
26
+ this._firestore = firestore;
27
+ this._pending = {};
28
+ this._firestore.emitter.addListener(this._firestore.eventNameForApp('firestore_transaction_event'), this._onTransactionEvent.bind(this));
29
+ }
30
+ _onTransactionEvent(event) {
31
+ switch (event.body.type) {
32
+ case 'update':
33
+ this._handleUpdate(event);
34
+ break;
35
+ case 'error':
36
+ this._handleError(event);
37
+ break;
38
+ case 'complete':
39
+ this._handleComplete(event);
40
+ break;
41
+ }
42
+ }
43
+ async _handleUpdate(event) {
44
+ const id = event.listenerId;
45
+ if (id === undefined || !this._pending[id]) {
46
+ if (id !== undefined) {
47
+ this._remove(id);
48
+ }
49
+ return;
50
+ }
51
+ const {
52
+ meta,
53
+ transaction
54
+ } = this._pending[id];
55
+ const {
56
+ updateFunction,
57
+ reject
58
+ } = meta;
59
+ transaction._prepare();
60
+ let finalError;
61
+ let updateFailed = false;
62
+ let pendingResult;
63
+ try {
64
+ const possiblePromise = updateFunction(transaction);
65
+ if (!possiblePromise || typeof possiblePromise?.then !== 'function') {
66
+ throw new Error("firebase.firestore().runTransaction(*) 'updateFunction' must return a Promise.");
67
+ }
68
+ pendingResult = await possiblePromise;
69
+ } catch (exception) {
70
+ updateFailed = true;
71
+ finalError = exception;
72
+ }
73
+ if (updateFailed || finalError) {
74
+ reject?.(finalError);
75
+ return;
76
+ }
77
+ transaction._pendingResult = pendingResult;
78
+ return this._firestore.native.transactionApplyBuffer(id, transaction._commandBuffer);
79
+ }
80
+ _handleError(event) {
81
+ const id = event.listenerId;
82
+ const {
83
+ error
84
+ } = event.body;
85
+ if (id === undefined || !this._pending[id]) {
86
+ return;
87
+ }
88
+ const {
89
+ meta
90
+ } = this._pending[id];
91
+ if (meta && error) {
92
+ const errorAndStack = NativeError.fromEvent(error, 'firestore', meta.stack);
93
+ meta.reject?.(errorAndStack);
94
+ }
95
+ }
96
+ _handleComplete(event) {
97
+ const id = event.listenerId;
98
+ if (id === undefined || !this._pending[id]) {
99
+ return;
100
+ }
101
+ const {
102
+ meta,
103
+ transaction
104
+ } = this._pending[id];
105
+ if (meta) {
106
+ meta.resolve?.(transaction._pendingResult);
107
+ }
108
+ }
109
+ _add(updateFunction) {
110
+ const id = generateTransactionId();
111
+ const meta = {
112
+ id,
113
+ updateFunction,
114
+ stack: new Error().stack?.split('\n').slice(2).join('\n')
115
+ };
116
+ this._pending[id] = {
117
+ meta,
118
+ transaction: new Transaction(this._firestore, meta)
119
+ };
120
+ return new Promise((resolve, reject) => {
121
+ this._firestore.native.transactionBegin(id);
122
+ meta.resolve = result => {
123
+ this._remove(id);
124
+ resolve(result);
125
+ };
126
+ meta.reject = error => {
127
+ this._remove(id);
128
+ reject(error);
129
+ };
130
+ });
131
+ }
132
+ _remove(id) {
133
+ this._firestore.native.transactionDispose(id);
134
+ delete this._pending[id];
135
+ }
136
+ }
137
+ //# sourceMappingURL=FirestoreTransactionHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeError","Transaction","transactionId","generateTransactionId","FirestoreTransactionHandler","constructor","firestore","_firestore","_pending","emitter","addListener","eventNameForApp","_onTransactionEvent","bind","event","body","type","_handleUpdate","_handleError","_handleComplete","id","listenerId","undefined","_remove","meta","transaction","updateFunction","reject","_prepare","finalError","updateFailed","pendingResult","possiblePromise","then","Error","exception","_pendingResult","native","transactionApplyBuffer","_commandBuffer","error","errorAndStack","fromEvent","stack","resolve","_add","split","slice","join","Promise","transactionBegin","result","transactionDispose"],"sourceRoot":"../../lib","sources":["FirestoreTransactionHandler.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,WAAW,MAAM,qEAAqE;AAC7F,OAAOC,WAAW,MAAgC,2BAAwB;AAG1E,IAAIC,aAAa,GAAG,CAAC;AAErB,MAAMC,qBAAqB,GAAGA,CAAA,KAAcD,aAAa,EAAE;AAiB3D,eAAe,MAAME,2BAA2B,CAAC;EAI/CC,WAAWA,CAACC,SAA4B,EAAE;IACxC,IAAI,CAACC,UAAU,GAAGD,SAAS;IAC3B,IAAI,CAACE,QAAQ,GAAG,CAAC,CAAC;IAClB,IAAI,CAACD,UAAU,CAACE,OAAO,CAACC,WAAW,CACjC,IAAI,CAACH,UAAU,CAACI,eAAe,CAAC,6BAA6B,CAAC,EAC9D,IAAI,CAACC,mBAAmB,CAACC,IAAI,CAAC,IAAI,CACpC,CAAC;EACH;EAEAD,mBAAmBA,CAACE,KAAuB,EAAQ;IACjD,QAAQA,KAAK,CAACC,IAAI,CAACC,IAAI;MACrB,KAAK,QAAQ;QACX,IAAI,CAACC,aAAa,CAACH,KAAK,CAAC;QACzB;MACF,KAAK,OAAO;QACV,IAAI,CAACI,YAAY,CAACJ,KAAK,CAAC;QACxB;MACF,KAAK,UAAU;QACb,IAAI,CAACK,eAAe,CAACL,KAAK,CAAC;QAC3B;IACJ;EACF;EAEA,MAAMG,aAAaA,CAACH,KAAuB,EAAiB;IAC1D,MAAMM,EAAE,GAAGN,KAAK,CAACO,UAAU;IAE3B,IAAID,EAAE,KAAKE,SAAS,IAAI,CAAC,IAAI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IAAI,CAAC5B,OAAO,CAACH,EAAE,CAAC;QAChBwB,OAAO,CAACO,MAAM,CAAC;MACjB,CAAC;MAED3B,IAAI,CAACG,MAAM,GAAIa,KAAc,IAAK;QAChC,IAAI,CAACjB,OAAO,CAACH,EAAE,CAAC;QAChBO,MAAM,CAACa,KAAK,CAAC;MACf,CAAC;IACH,CAAC,CAAC;EACJ;EAEAjB,OAAOA,CAACH,EAAU,EAAQ;IACxB,IAAI,CAACb,UAAU,CAAC8B,MAAM,CAACe,kBAAkB,CAAChC,EAAE,CAAC;IAC7C,OAAO,IAAI,CAACZ,QAAQ,CAACY,EAAE,CAAC;EAC1B;AACF","ignoreList":[]}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import { isArray, isNumber, isObject } from '@react-native-firebase/app/dist/module/common';
21
+ export default class VectorValue {
22
+ constructor(values) {
23
+ if (values === undefined) {
24
+ this._values = [];
25
+ return;
26
+ }
27
+ if (!isArray(values)) {
28
+ throw new Error("firebase.firestore.VectorValue(values?) 'values' expected an array of numbers or undefined.");
29
+ }
30
+ for (let i = 0; i < values.length; i++) {
31
+ const value = values[i];
32
+ if (!isNumber(value)) {
33
+ throw new Error(`firebase.firestore.VectorValue(values?) 'values[${i}]' expected a number value.`);
34
+ }
35
+ }
36
+ this._values = values.slice();
37
+ }
38
+ static _jsonSchemaVersion = 'firestore/vectorValue/1.0';
39
+ static _jsonSchema = {
40
+ type: VectorValue._jsonSchemaVersion,
41
+ vectorValues: 'object'
42
+ };
43
+ static fromJSON(json) {
44
+ const parsedVector = isObject(json) ? json : null;
45
+ if (parsedVector && (parsedVector.type === undefined || parsedVector.type === VectorValue._jsonSchemaVersion) && Array.isArray(parsedVector.vectorValues) && parsedVector.vectorValues.every(element => typeof element === 'number')) {
46
+ return new VectorValue(parsedVector.vectorValues);
47
+ }
48
+ if (parsedVector && parsedVector.type === VectorValue._jsonSchemaVersion) {
49
+ throw new Error("Expected 'vectorValues' field to be a number array");
50
+ }
51
+ throw new Error('Unexpected error creating Timestamp from JSON.');
52
+ }
53
+ isEqual(other) {
54
+ if (!(other instanceof VectorValue)) {
55
+ throw new Error("firebase.firestore.VectorValue.isEqual(*) 'other' expected a VectorValue instance.");
56
+ }
57
+ const a = this._values;
58
+ const b = other._values;
59
+ if (a.length !== b.length) return false;
60
+ for (let i = 0; i < a.length; i++) {
61
+ if (a[i] !== b[i]) return false;
62
+ }
63
+ return true;
64
+ }
65
+ toArray() {
66
+ return this._values.slice();
67
+ }
68
+ toJSON() {
69
+ return {
70
+ type: VectorValue._jsonSchemaVersion,
71
+ vectorValues: this._values.slice()
72
+ };
73
+ }
74
+ }
75
+ //# sourceMappingURL=FirestoreVectorValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isArray","isNumber","isObject","VectorValue","constructor","values","undefined","_values","Error","i","length","value","slice","_jsonSchemaVersion","_jsonSchema","type","vectorValues","fromJSON","json","parsedVector","Array","every","element","isEqual","other","a","b","toArray","toJSON"],"sourceRoot":"../../lib","sources":["FirestoreVectorValue.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,+CAA+C;AAI3F,eAAe,MAAMC,WAAW,CAAC;EAG/BC,WAAWA,CAACC,MAAiB,EAAE;IAC7B,IAA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MAAM,IAAIA,KAAK,CAAC,gDAAgD,CAAC;EACnE;EAEAe,OAAOA,CAACC,KAAkB,EAAW;IACnC,IAAI,EAAEA,KAAK,YAAYrB,WAAW,CAAC,EAAE;MACnC,MAAM,IAAIK,KAAK,CACb,oFACF,CAAC;IACH;IAEA,MAAMiB,CAAC,GAAG,IAAI,CAAClB,OAAO;IACtB,MAAMmB,CAAC,GAAGF,KAAK,CAACjB,OAAO;IACvB,IAAIkB,CAAC,CAACf,MAAM,KAAKgB,CAAC,CAAChB,MAAM,EAAE,OAAO,KAAK;IACvC,KAAK,IAAID,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGgB,CAAC,CAACf,MAAM,EAAED,CAAC,EAAE,EAAE;MACjC,IAAIgB,CAAC,CAAChB,CAAC,CAAC,KAAKiB,CAAC,CAACjB,CAAC,CAAC,EAAE,OAAO,KAAK;IACjC;IACA,OAAO,IAAI;EACb;EAEAkB,OAAOA,CAAA,EAAa;IAClB,OAAO,IAAI,CAACpB,OAAO,CAACK,KAAK,CAAC,CAAC;EAC7B;EAEAgB,MAAMA,CAAA,EAA6C;IACjD,OAAO;MAAEb,IAAI,EAAEZ,WAAW,CAACU,kBAAkB;MAAEG,YAAY,EAAE,IAAI,CAACT,OAAO,CAACK,KAAK,CAAC;IAAE,CAAC;EACrF;AACF","ignoreList":[]}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import { isObject } from '@react-native-firebase/app/dist/module/common';
21
+ import DocumentReference from "./FirestoreDocumentReference.js";
22
+ import { parseSetOptions, parseUpdateArgs, applyFirestoreDataConverter } from "./utils/index.js";
23
+ import { buildNativeMap } from "./utils/serialize.js";
24
+ export default class WriteBatch {
25
+ constructor(firestore) {
26
+ this._firestore = firestore;
27
+ this._writes = [];
28
+ this._committed = false;
29
+ }
30
+ _verifyNotCommitted(method) {
31
+ if (this._committed) {
32
+ throw new Error(`firebase.firestore.batch().${method}(*) A write batch can no longer be used after commit() has been called.`);
33
+ }
34
+ }
35
+ commit() {
36
+ this._verifyNotCommitted('commit');
37
+ this._committed = true;
38
+ if (this._writes.length === 0) {
39
+ return Promise.resolve();
40
+ }
41
+ return this._firestore.native.documentBatch(this._writes);
42
+ }
43
+ delete(documentRef) {
44
+ this._verifyNotCommitted('delete');
45
+ if (!(documentRef instanceof DocumentReference)) {
46
+ throw new Error("firebase.firestore.batch().delete(*) 'documentRef' expected instance of a DocumentReference.");
47
+ }
48
+ if (documentRef.firestore.app !== this._firestore.app) {
49
+ throw new Error("firebase.firestore.batch().delete(*) 'documentRef' provided DocumentReference is from a different Firestore instance.");
50
+ }
51
+ this._writes.push({
52
+ path: documentRef.path,
53
+ type: 'DELETE'
54
+ });
55
+ return this;
56
+ }
57
+ set(documentRef, data, options) {
58
+ this._verifyNotCommitted('set');
59
+ if (!(documentRef instanceof DocumentReference)) {
60
+ throw new Error("firebase.firestore.batch().set(*) 'documentRef' expected instance of a DocumentReference.");
61
+ }
62
+ if (documentRef.firestore.app !== this._firestore.app) {
63
+ throw new Error("firebase.firestore.batch().set(*) 'documentRef' provided DocumentReference is from a different Firestore instance.");
64
+ }
65
+ let setOptions;
66
+ try {
67
+ setOptions = parseSetOptions(options);
68
+ } catch (e) {
69
+ throw new Error(`firebase.firestore().batch().set(_, *) ${e.message}.`);
70
+ }
71
+ let converted = data;
72
+ try {
73
+ converted = applyFirestoreDataConverter(data, documentRef.converter, setOptions);
74
+ } catch (e) {
75
+ throw new Error(`firebase.firestore().batch().set(_, *) 'withConverter.toFirestore' threw an error: ${e.message}.`);
76
+ }
77
+ if (!isObject(converted)) {
78
+ throw new Error("firebase.firestore.batch().set(_, *) 'data' must be an object.");
79
+ }
80
+ this._writes.push({
81
+ path: documentRef.path,
82
+ type: 'SET',
83
+ data: buildNativeMap(converted, this._firestore._settings.ignoreUndefinedProperties),
84
+ options: setOptions
85
+ });
86
+ return this;
87
+ }
88
+ update(documentRef, ...args) {
89
+ this._verifyNotCommitted('update');
90
+ if (!(documentRef instanceof DocumentReference)) {
91
+ throw new Error("firebase.firestore.batch().update(*) 'documentRef' expected instance of a DocumentReference.");
92
+ }
93
+ if (documentRef.firestore.app !== this._firestore.app) {
94
+ throw new Error("firebase.firestore.batch().update(*) 'documentRef' provided DocumentReference is from a different Firestore instance.");
95
+ }
96
+ if (args.length === 0) {
97
+ throw new Error('firebase.firestore.batch().update(_, *) Invalid arguments. Expected update object or list of key/value pairs.');
98
+ }
99
+ let data;
100
+ try {
101
+ data = parseUpdateArgs(args);
102
+ } catch (e) {
103
+ throw new Error(`firebase.firestore.batch().update(_, *) ${e.message}`);
104
+ }
105
+ this._writes.push({
106
+ path: documentRef.path,
107
+ type: 'UPDATE',
108
+ data: buildNativeMap(data, this._firestore._settings.ignoreUndefinedProperties)
109
+ });
110
+ return this;
111
+ }
112
+ }
113
+ //# sourceMappingURL=FirestoreWriteBatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isObject","DocumentReference","parseSetOptions","parseUpdateArgs","applyFirestoreDataConverter","buildNativeMap","WriteBatch","constructor","firestore","_firestore","_writes","_committed","_verifyNotCommitted","method","Error","commit","length","Promise","resolve","native","documentBatch","delete","documentRef","app","push","path","type","set","data","options","setOptions","e","message","converted","converter","_settings","ignoreUndefinedProperties","update","args"],"sourceRoot":"../../lib","sources":["FirestoreWriteBatch.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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