@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,1273 @@
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
+ /**
21
+ * @beta
22
+ * Expression type kind (for internal/backend use).
23
+ */
24
+
25
+ /**
26
+ * @beta
27
+ * Firestore value type for isType() checks.
28
+ */
29
+
30
+ /**
31
+ * @beta
32
+ * Time granularity for timestampTruncate.
33
+ */
34
+
35
+ /**
36
+ * @beta
37
+ * Boolean expression for pipeline `where()` (e.g. field('x').gt(0), and(...), or(...)).
38
+ */
39
+
40
+ /**
41
+ * @beta
42
+ * Selectable for pipeline field selection/expressions (e.g. field('a').as('b'), expressions).
43
+ */
44
+
45
+ /**
46
+ * @beta
47
+ * Field reference for pipeline stages.
48
+ */
49
+
50
+ /**
51
+ * @beta
52
+ * Function expression (e.g. map(...), array(...)). Used as return type and in Expression union.
53
+ */
54
+
55
+ /**
56
+ * @beta
57
+ * Constant/literal expression returned by `constant(...)`.
58
+ */
59
+
60
+ /**
61
+ * @beta
62
+ * Expression type for pipeline parameters (field refs, literals, function results).
63
+ */
64
+
65
+ /**
66
+ * @beta
67
+ * Ordering for pipeline sort() (e.g. Ordering.of(field('rating')).descending()).
68
+ */
69
+
70
+ /**
71
+ * @beta
72
+ * Accumulator for pipeline aggregate() (e.g. avg(field('rating')).as('avgRating'), countAll().as('total')).
73
+ */
74
+
75
+ /**
76
+ * @beta
77
+ * Aggregate function (e.g. countAll()). Alias for Accumulator.
78
+ */
79
+
80
+ /**
81
+ * @beta
82
+ * An aggregate function with an output alias.
83
+ */
84
+
85
+ /**
86
+ * @beta
87
+ * An expression with an output alias (implements Selectable).
88
+ */
89
+
90
+ const RUNTIME_NODE_SYMBOL = Symbol.for('RNFBFirestorePipelineExpressionNode');
91
+ function isRecord(value) {
92
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
93
+ }
94
+ function isPlainObject(value) {
95
+ if (!isRecord(value)) {
96
+ return false;
97
+ }
98
+ const proto = Object.getPrototypeOf(value);
99
+ return proto === Object.prototype || proto === null;
100
+ }
101
+ function isDocumentReferenceLike(value) {
102
+ return isRecord(value) && typeof value.path === 'string' && value.path.length > 0 && isRecord(value.firestore);
103
+ }
104
+ function isRuntimeNode(value) {
105
+ return isRecord(value) && value[RUNTIME_NODE_SYMBOL] === true;
106
+ }
107
+ function isOrderingNode(value) {
108
+ return isRuntimeNode(value) && value.__kind === 'ordering';
109
+ }
110
+ function containsRuntimeNode(value) {
111
+ if (isRuntimeNode(value)) {
112
+ return true;
113
+ }
114
+ if (Array.isArray(value)) {
115
+ return value.some(containsRuntimeNode);
116
+ }
117
+ if (!isRecord(value)) {
118
+ return false;
119
+ }
120
+ if (!isPlainObject(value)) {
121
+ return false;
122
+ }
123
+ return Object.values(value).some(containsRuntimeNode);
124
+ }
125
+ function toCanonicalFunctionName(name) {
126
+ switch (name) {
127
+ case 'gt':
128
+ return 'greaterThan';
129
+ case 'eq':
130
+ return 'equal';
131
+ case 'gte':
132
+ return 'greaterThanOrEqual';
133
+ case 'lt':
134
+ return 'lessThan';
135
+ case 'lte':
136
+ return 'lessThanOrEqual';
137
+ case 'avg':
138
+ return 'average';
139
+ case 'toLower':
140
+ return 'lower';
141
+ case 'toUpper':
142
+ return 'upper';
143
+ default:
144
+ return name;
145
+ }
146
+ }
147
+ const AGGREGATE_KINDS = new Set(['countAll', 'count', 'countIf', 'sum', 'average', 'minimum', 'maximum', 'countDistinct', 'first', 'last', 'arrayAgg', 'arrayAggDistinct']);
148
+ const EXPRESSION_METHOD_NAMES = ['and', 'or', 'gt', 'greaterThan', 'eq', 'equal', 'notEqual', 'gte', 'greaterThanOrEqual', 'lt', 'lessThan', 'lte', 'lessThanOrEqual', 'exists', 'arrayContains', 'arrayContainsAny', 'arrayContainsAll', 'startsWith', 'endsWith', 'add', 'subtract', 'divide', 'multiply', 'documentId', 'sum', 'count', 'average', 'abs', 'ceil', 'floor', 'mod', 'round', 'conditional', 'countDistinct', 'first', 'last', 'arrayAgg', 'concat', 'sqrt', 'currentTimestamp', 'not', 'ifAbsent', 'ifError', 'toLower', 'toUpper', 'trim', 'substring', 'arrayAggDistinct', 'arrayConcat', 'arrayGet', 'arrayLength', 'arraySum', 'byteLength', 'charLength', 'collectionId', 'countIf', 'exp', 'join', 'like', 'ln', 'log', 'log10', 'maximum', 'minimum', 'pow', 'reverse', 'split', 'cosineDistance', 'dotProduct', 'equalAny', 'euclideanDistance', 'isAbsent', 'isError', 'isType', 'logicalMaximum', 'logicalMinimum', 'ltrim', 'notEqualAny', 'rand', 'rtrim', 'stringConcat', 'mapEntries', 'mapGet', 'mapKeys', 'mapMerge', 'mapRemove', 'mapSet', 'mapValues', 'regexContains', 'regexFind', 'regexFindAll', 'regexMatch', 'stringContains', 'stringIndexOf', 'stringRepeat', 'stringReplaceAll', 'stringReplaceOne', 'stringReverse', 'timestampAdd', 'timestampSubtract', 'timestampToUnixMicros', 'timestampToUnixMillis', 'timestampToUnixSeconds', 'timestampTruncate', 'trunc', 'type', 'unixMicrosToTimestamp', 'unixMillisToTimestamp', 'unixSecondsToTimestamp', 'vectorLength', 'xor', 'length'];
149
+ function createNode(proto, node) {
150
+ const runtimeNode = Object.create(proto);
151
+ Object.assign(runtimeNode, node);
152
+ return runtimeNode;
153
+ }
154
+ function createExpressionProto() {
155
+ const proto = {
156
+ as(name) {
157
+ return createAliasedExpression(this, name);
158
+ },
159
+ ascending() {
160
+ return createOrdering(this, 'ascending');
161
+ },
162
+ descending() {
163
+ return createOrdering(this, 'descending');
164
+ }
165
+ };
166
+ for (const methodName of EXPRESSION_METHOD_NAMES) {
167
+ Object.defineProperty(proto, methodName, {
168
+ value(...args) {
169
+ return createMethodResult(methodName, this, args);
170
+ }
171
+ });
172
+ }
173
+ return proto;
174
+ }
175
+ const expressionProto = createExpressionProto();
176
+ const aggregateProto = {
177
+ as(name) {
178
+ return createAliasedAggregate(this, name);
179
+ }
180
+ };
181
+ const orderingProto = {
182
+ ascending() {
183
+ return createOrdering(this.expr, 'ascending');
184
+ },
185
+ descending() {
186
+ return createOrdering(this.expr, 'descending');
187
+ }
188
+ };
189
+ function createField(path) {
190
+ return createNode(expressionProto, {
191
+ [RUNTIME_NODE_SYMBOL]: true,
192
+ __kind: 'expression',
193
+ exprType: 'Field',
194
+ selectable: true,
195
+ path: String(path ?? '')
196
+ });
197
+ }
198
+ function createConstant(value) {
199
+ return createNode(expressionProto, {
200
+ [RUNTIME_NODE_SYMBOL]: true,
201
+ __kind: 'expression',
202
+ exprType: 'Constant',
203
+ value
204
+ });
205
+ }
206
+ function normalizeMapLikeValue(value) {
207
+ const output = {};
208
+ for (const [key, entryValue] of Object.entries(value)) {
209
+ output[key] = normalizeRawValue(entryValue);
210
+ }
211
+ return output;
212
+ }
213
+ function normalizeRawValue(value) {
214
+ if (isRuntimeNode(value)) {
215
+ return value;
216
+ }
217
+ if (Array.isArray(value)) {
218
+ if (containsRuntimeNode(value)) {
219
+ return createFunctionExpression('array', value.map(entry => toExpressionArgument(entry)));
220
+ }
221
+ return value.map(normalizeRawValue);
222
+ }
223
+ if (isDocumentReferenceLike(value)) {
224
+ // Treat references as atomic values to avoid walking circular internal firestore graphs.
225
+ return value;
226
+ }
227
+ if (isRecord(value)) {
228
+ if (!isPlainObject(value)) {
229
+ return value;
230
+ }
231
+ return normalizeMapLikeValue(value);
232
+ }
233
+ return value;
234
+ }
235
+ function toExpressionArgument(value, fieldString = false) {
236
+ if (isRuntimeNode(value)) {
237
+ return value;
238
+ }
239
+ if (fieldString && typeof value === 'string') {
240
+ return createField(value);
241
+ }
242
+ if (Array.isArray(value) && containsRuntimeNode(value)) {
243
+ return createFunctionExpression('array', value.map(entry => toExpressionArgument(entry)));
244
+ }
245
+ return createConstant(normalizeRawValue(value));
246
+ }
247
+ function createFunctionExpression(name, args) {
248
+ return createNode(expressionProto, {
249
+ [RUNTIME_NODE_SYMBOL]: true,
250
+ __kind: 'expression',
251
+ exprType: 'Function',
252
+ selectable: true,
253
+ name,
254
+ args
255
+ });
256
+ }
257
+ function createBooleanExpression(name, args) {
258
+ return createNode(expressionProto, {
259
+ [RUNTIME_NODE_SYMBOL]: true,
260
+ __kind: 'expression',
261
+ exprType: 'Function',
262
+ selectable: true,
263
+ name,
264
+ args
265
+ });
266
+ }
267
+ function createAggregate(kind, args = []) {
268
+ return createNode(aggregateProto, {
269
+ [RUNTIME_NODE_SYMBOL]: true,
270
+ __kind: 'aggregate',
271
+ exprType: 'AggregateFunction',
272
+ kind,
273
+ args
274
+ });
275
+ }
276
+ function createAliasedExpression(expr, alias) {
277
+ return createNode(Object.prototype, {
278
+ [RUNTIME_NODE_SYMBOL]: true,
279
+ __kind: 'aliasedExpression',
280
+ exprType: 'AliasedExpression',
281
+ selectable: true,
282
+ expr,
283
+ alias
284
+ });
285
+ }
286
+ function createAliasedAggregate(aggregate, alias) {
287
+ return createNode(Object.prototype, {
288
+ [RUNTIME_NODE_SYMBOL]: true,
289
+ __kind: 'aliasedAggregate',
290
+ aggregate,
291
+ alias
292
+ });
293
+ }
294
+ function createOrdering(expr, direction) {
295
+ return createNode(orderingProto, {
296
+ [RUNTIME_NODE_SYMBOL]: true,
297
+ __kind: 'ordering',
298
+ expr,
299
+ direction
300
+ });
301
+ }
302
+ function normalizeGlobalArguments(name, args) {
303
+ const fieldIndexList = [];
304
+ switch (name) {
305
+ case 'add':
306
+ case 'subtract':
307
+ case 'divide':
308
+ case 'multiply':
309
+ case 'mod':
310
+ case 'pow':
311
+ case 'abs':
312
+ case 'ceil':
313
+ case 'floor':
314
+ case 'round':
315
+ case 'trunc':
316
+ case 'toLower':
317
+ case 'toUpper':
318
+ case 'trim':
319
+ case 'substring':
320
+ case 'arrayGet':
321
+ case 'arrayLength':
322
+ case 'arraySum':
323
+ case 'arrayConcat':
324
+ case 'byteLength':
325
+ case 'charLength':
326
+ case 'collectionId':
327
+ case 'exp':
328
+ case 'ln':
329
+ case 'log':
330
+ case 'log10':
331
+ case 'reverse':
332
+ case 'split':
333
+ case 'cosineDistance':
334
+ case 'dotProduct':
335
+ case 'euclideanDistance':
336
+ case 'isAbsent':
337
+ case 'isType':
338
+ case 'logicalMaximum':
339
+ case 'logicalMinimum':
340
+ case 'ltrim':
341
+ case 'rtrim':
342
+ case 'stringConcat':
343
+ case 'mapEntries':
344
+ case 'mapGet':
345
+ case 'mapKeys':
346
+ case 'mapMerge':
347
+ case 'mapRemove':
348
+ case 'mapSet':
349
+ case 'mapValues':
350
+ case 'regexContains':
351
+ case 'regexFind':
352
+ case 'regexFindAll':
353
+ case 'regexMatch':
354
+ case 'stringContains':
355
+ case 'stringIndexOf':
356
+ case 'stringRepeat':
357
+ case 'stringReplaceAll':
358
+ case 'stringReplaceOne':
359
+ case 'stringReverse':
360
+ case 'timestampAdd':
361
+ case 'timestampSubtract':
362
+ case 'timestampToUnixMicros':
363
+ case 'timestampToUnixMillis':
364
+ case 'timestampToUnixSeconds':
365
+ case 'timestampTruncate':
366
+ case 'type':
367
+ case 'unixMicrosToTimestamp':
368
+ case 'unixMillisToTimestamp':
369
+ case 'unixSecondsToTimestamp':
370
+ case 'vectorLength':
371
+ case 'length':
372
+ case 'startsWith':
373
+ case 'endsWith':
374
+ case 'like':
375
+ case 'equalAny':
376
+ case 'notEqualAny':
377
+ fieldIndexList.push(0);
378
+ break;
379
+ case 'gt':
380
+ case 'greaterThan':
381
+ case 'eq':
382
+ case 'equal':
383
+ case 'notEqual':
384
+ case 'gte':
385
+ case 'greaterThanOrEqual':
386
+ case 'lt':
387
+ case 'lessThan':
388
+ case 'lte':
389
+ case 'lessThanOrEqual':
390
+ case 'exists':
391
+ case 'arrayContains':
392
+ case 'arrayContainsAny':
393
+ case 'arrayContainsAll':
394
+ case 'sum':
395
+ case 'count':
396
+ case 'average':
397
+ case 'countDistinct':
398
+ case 'first':
399
+ case 'last':
400
+ case 'arrayAgg':
401
+ case 'arrayAggDistinct':
402
+ case 'maximum':
403
+ case 'minimum':
404
+ fieldIndexList.push(0);
405
+ break;
406
+ default:
407
+ break;
408
+ }
409
+ return args.map((arg, index) => toExpressionArgument(arg, fieldIndexList.includes(index)));
410
+ }
411
+ function createMethodResult(name, base, rawArgs) {
412
+ const canonicalName = toCanonicalFunctionName(name);
413
+ if (AGGREGATE_KINDS.has(canonicalName)) {
414
+ return createAggregate(canonicalName, [base, ...rawArgs.map(arg => toExpressionArgument(arg))]);
415
+ }
416
+ return createFunctionExpression(canonicalName, [base, ...rawArgs.map(arg => toExpressionArgument(arg))]);
417
+ }
418
+ function callBooleanHelper(name, argsLike) {
419
+ return createBooleanExpression(toCanonicalFunctionName(name), normalizeGlobalArguments(name, Array.from(argsLike)));
420
+ }
421
+ function callFunctionHelper(name, argsLike) {
422
+ return createFunctionExpression(toCanonicalFunctionName(name), normalizeGlobalArguments(name, Array.from(argsLike)));
423
+ }
424
+ function callAggregateHelper(name, argsLike) {
425
+ return createAggregate(toCanonicalFunctionName(name), normalizeGlobalArguments(name, Array.from(argsLike)));
426
+ }
427
+ function callExpressionHelper(name, argsLike) {
428
+ return createFunctionExpression(toCanonicalFunctionName(name), normalizeGlobalArguments(name, Array.from(argsLike)));
429
+ }
430
+
431
+ // --- Expression / helper stubs (for use in where, select, addFields, aggregate, sort, etc.) ---
432
+
433
+ /**
434
+ * @beta
435
+ * Returns a Field reference for use in pipeline expressions.
436
+ */
437
+ export function field(_path) {
438
+ return createField(_path);
439
+ }
440
+
441
+ /**
442
+ * @beta
443
+ * Logical AND of boolean expressions.
444
+ */
445
+ export function and(first, second, ...more) {
446
+ void first;
447
+ void second;
448
+ void more;
449
+ return callBooleanHelper('and', arguments);
450
+ }
451
+
452
+ /**
453
+ * @beta
454
+ * Logical OR of boolean expressions.
455
+ */
456
+ export function or(first, second, ...more) {
457
+ void first;
458
+ void second;
459
+ void more;
460
+ return callBooleanHelper('or', arguments);
461
+ }
462
+
463
+ /**
464
+ * @beta
465
+ * Greater-than comparison.
466
+ */
467
+ export function gt(_left, _right) {
468
+ return callBooleanHelper('gt', arguments);
469
+ }
470
+
471
+ /**
472
+ * @beta
473
+ * Greater-than comparison (alias for gt).
474
+ */
475
+ export function greaterThan(_left, _right) {
476
+ return callBooleanHelper('greaterThan', arguments);
477
+ }
478
+
479
+ /**
480
+ * @beta
481
+ * Equality comparison.
482
+ */
483
+ export function eq(_left, _right) {
484
+ return callBooleanHelper('eq', arguments);
485
+ }
486
+
487
+ /**
488
+ * @beta
489
+ * Equality comparison (alias for eq).
490
+ */
491
+ export function equal(_left, _right) {
492
+ return callBooleanHelper('equal', arguments);
493
+ }
494
+
495
+ /**
496
+ * @beta
497
+ * Inequality comparison.
498
+ */
499
+ export function notEqual(_left, _right) {
500
+ return callBooleanHelper('notEqual', arguments);
501
+ }
502
+
503
+ /**
504
+ * @beta
505
+ * Greater-than-or-equal comparison.
506
+ */
507
+ export function gte(_left, _right) {
508
+ return callBooleanHelper('gte', arguments);
509
+ }
510
+
511
+ /**
512
+ * @beta
513
+ * Less-than comparison.
514
+ */
515
+ export function lt(_left, _right) {
516
+ return callBooleanHelper('lt', arguments);
517
+ }
518
+
519
+ /**
520
+ * @beta
521
+ * Less-than comparison (alias for lt).
522
+ */
523
+ export function lessThan(_left, _right) {
524
+ return callBooleanHelper('lessThan', arguments);
525
+ }
526
+
527
+ /**
528
+ * @beta
529
+ * Less-than-or-equal comparison.
530
+ */
531
+ export function lte(_left, _right) {
532
+ return callBooleanHelper('lte', arguments);
533
+ }
534
+
535
+ /**
536
+ * @beta
537
+ * Less-than-or-equal comparison (alias for lte).
538
+ */
539
+ export function lessThanOrEqual(_left, _right) {
540
+ return callBooleanHelper('lessThanOrEqual', arguments);
541
+ }
542
+
543
+ /**
544
+ * @beta
545
+ * Greater-than-or-equal comparison (alias for gte).
546
+ */
547
+ export function greaterThanOrEqual(_left, _right) {
548
+ return callBooleanHelper('greaterThanOrEqual', arguments);
549
+ }
550
+
551
+ /**
552
+ * @beta
553
+ * Checks if a field exists (or expression evaluates to a value).
554
+ */
555
+ export function exists(_valueOrFieldName) {
556
+ return callBooleanHelper('exists', arguments);
557
+ }
558
+
559
+ /**
560
+ * @beta
561
+ * Checks if an array contains an element.
562
+ */
563
+ export function arrayContains(_arrayOrFieldName, _element) {
564
+ return callBooleanHelper('arrayContains', arguments);
565
+ }
566
+
567
+ /**
568
+ * @beta
569
+ * Checks if an array contains any of the given values.
570
+ */
571
+ export function arrayContainsAny(_arrayOrFieldName, _values) {
572
+ return callBooleanHelper('arrayContainsAny', arguments);
573
+ }
574
+
575
+ /**
576
+ * @beta
577
+ * Checks if an array contains all of the given values.
578
+ */
579
+ export function arrayContainsAll(_arrayOrFieldName, _values) {
580
+ return callBooleanHelper('arrayContainsAll', arguments);
581
+ }
582
+
583
+ /**
584
+ * @beta
585
+ * Checks if a string starts with a prefix.
586
+ */
587
+
588
+ export function startsWith(_stringOrFieldName, _prefix) {
589
+ return callBooleanHelper('startsWith', arguments);
590
+ }
591
+
592
+ /**
593
+ * @beta
594
+ * Checks if a string ends with a suffix.
595
+ */
596
+
597
+ export function endsWith(_stringOrFieldName, _suffix) {
598
+ return callBooleanHelper('endsWith', arguments);
599
+ }
600
+
601
+ /**
602
+ * @beta
603
+ * Ordering helper (e.g. Ordering.of(field('rating')).descending()).
604
+ */
605
+ export const OrderingHelper = {
606
+ of(_fieldOrOrdering) {
607
+ if (isOrderingNode(_fieldOrOrdering)) {
608
+ return _fieldOrOrdering;
609
+ }
610
+ return createOrdering(toExpressionArgument(_fieldOrOrdering, true), 'ascending');
611
+ }
612
+ };
613
+
614
+ /**
615
+ * @beta
616
+ * Ascending ordering (standalone). Use in sort().
617
+ */
618
+ export function ascending(_expr) {
619
+ return createOrdering(toExpressionArgument(_expr, true), 'ascending');
620
+ }
621
+
622
+ /**
623
+ * @beta
624
+ * Descending ordering (standalone). Use in sort().
625
+ */
626
+ export function descending(_expr) {
627
+ return createOrdering(toExpressionArgument(_expr, true), 'descending');
628
+ }
629
+
630
+ /**
631
+ * @beta
632
+ * Average aggregation (e.g. avg(field('rating')).as('avgRating')).
633
+ */
634
+ export function avg(_f) {
635
+ return callAggregateHelper('avg', arguments);
636
+ }
637
+
638
+ /**
639
+ * @beta
640
+ * Count-all aggregation (e.g. countAll().as('total')).
641
+ */
642
+ export function countAll() {
643
+ return createAggregate('countAll');
644
+ }
645
+
646
+ /**
647
+ * @beta
648
+ * Map expression for replaceWith etc.
649
+ */
650
+ export function map(_entries) {
651
+ return createFunctionExpression('map', [toExpressionArgument(_entries)]);
652
+ }
653
+
654
+ /**
655
+ * @beta
656
+ * Array expression.
657
+ */
658
+ export function array(_elements) {
659
+ return createFunctionExpression('array', _elements.map(entry => toExpressionArgument(entry)));
660
+ }
661
+
662
+ // --- Arithmetic / constant expression helpers (align with JS SDK) ---
663
+
664
+ /**
665
+ * @beta
666
+ * Creates a constant expression for a number value.
667
+ */
668
+
669
+ /**
670
+ * @beta
671
+ * Creates a constant expression for a string value.
672
+ */
673
+
674
+ /**
675
+ * @beta
676
+ * Creates a constant boolean expression.
677
+ */
678
+
679
+ /**
680
+ * @beta
681
+ * Creates a constant expression for null.
682
+ */
683
+
684
+ /**
685
+ * @beta
686
+ * Creates a constant expression for a value (e.g. GeoPoint, Timestamp, Date, Bytes, DocumentReference, VectorValue).
687
+ */
688
+
689
+ export function constant(_value) {
690
+ return createConstant(normalizeRawValue(_value));
691
+ }
692
+
693
+ /**
694
+ * @beta
695
+ * Creates an expression that adds two or more expressions together.
696
+ *
697
+ * @param first - The first expression to add.
698
+ * @param second - The second expression or literal to add.
699
+ * @returns A new Expression representing the addition operation.
700
+ */
701
+
702
+ /**
703
+ * @beta
704
+ * Creates an expression that adds a field's value to an expression.
705
+ *
706
+ * @param fieldName - The name of the field containing the value to add.
707
+ * @param second - The second expression or literal to add.
708
+ * @returns A new Expression representing the addition operation.
709
+ */
710
+
711
+ export function add(_first, _second) {
712
+ return callFunctionHelper('add', arguments);
713
+ }
714
+
715
+ /**
716
+ * @beta
717
+ * Creates an expression that subtracts the second from the first.
718
+ */
719
+
720
+ /**
721
+ * @beta
722
+ * Creates an expression that subtracts a constant value from an expression.
723
+ */
724
+
725
+ /**
726
+ * @beta
727
+ * Creates an expression that subtracts an expression from a field's value.
728
+ */
729
+
730
+ /**
731
+ * @beta
732
+ * Creates an expression that subtracts a constant value from a field's value.
733
+ */
734
+
735
+ export function subtract(_leftOrField, _rightOrValue) {
736
+ return callFunctionHelper('subtract', arguments);
737
+ }
738
+
739
+ // --- Additional arithmetic and aggregate helpers (align with JS SDK) ---
740
+
741
+ /**
742
+ * @beta
743
+ * Creates an expression that divides the first by the second.
744
+ */
745
+
746
+ /**
747
+ * @beta
748
+ * Creates an expression that divides an expression by a constant value.
749
+ */
750
+
751
+ /**
752
+ * @beta
753
+ * Creates an expression that divides a field's value by an expression.
754
+ */
755
+
756
+ /**
757
+ * @beta
758
+ * Creates an expression that divides a field's value by a constant.
759
+ */
760
+
761
+ export function divide(_leftOrField, _rightOrValue) {
762
+ return callFunctionHelper('divide', arguments);
763
+ }
764
+
765
+ /**
766
+ * @beta
767
+ * Creates an expression that multiplies two or more expressions.
768
+ */
769
+
770
+ /**
771
+ * @beta
772
+ * Creates an expression that multiplies a field's value by an expression or literal.
773
+ */
774
+
775
+ export function multiply(_first, _second) {
776
+ return callFunctionHelper('multiply', arguments);
777
+ }
778
+
779
+ /**
780
+ * @beta
781
+ * Creates an expression that evaluates to the document ID (and optionally path).
782
+ *
783
+ * @param documentPath - Document path string or DocumentReference.
784
+ * @returns A new Expression representing the document ID.
785
+ */
786
+
787
+ /**
788
+ * @beta
789
+ * Creates an expression that evaluates to the document ID from a path expression.
790
+ */
791
+
792
+ export function documentId(_documentPath) {
793
+ return callFunctionHelper('documentId', arguments);
794
+ }
795
+
796
+ /**
797
+ * @beta
798
+ * Creates an aggregation that sums values from an expression across stage inputs.
799
+ */
800
+
801
+ /**
802
+ * @beta
803
+ * Creates an aggregation that sums a field's values across stage inputs.
804
+ */
805
+
806
+ export function sum(_exprOrField) {
807
+ return callAggregateHelper('sum', arguments);
808
+ }
809
+
810
+ /**
811
+ * @beta
812
+ * Creates an aggregation that counts stage inputs with valid evaluations of the expression.
813
+ */
814
+
815
+ /**
816
+ * @beta
817
+ * Creates an aggregation that counts stage inputs where the field exists.
818
+ */
819
+
820
+ export function count(_exprOrField) {
821
+ return callAggregateHelper('count', arguments);
822
+ }
823
+
824
+ /**
825
+ * @beta
826
+ * Creates an aggregation that calculates the average (mean) of values from an expression.
827
+ * SDK name: average (avg is RN alias).
828
+ */
829
+
830
+ /**
831
+ * @beta
832
+ * Creates an aggregation that calculates the average (mean) of a field's values.
833
+ */
834
+
835
+ export function average(_exprOrField) {
836
+ return callAggregateHelper('average', arguments);
837
+ }
838
+
839
+ // --- More expression and aggregate helpers (align with JS SDK) ---
840
+
841
+ /**
842
+ * @beta
843
+ * Absolute value of a numeric expression.
844
+ */
845
+
846
+ /**
847
+ * @beta
848
+ * Absolute value of a field.
849
+ */
850
+
851
+ export function abs(_exprOrField) {
852
+ return callFunctionHelper('abs', arguments);
853
+ }
854
+
855
+ /**
856
+ * @beta
857
+ * Rounds up to the nearest integer.
858
+ */
859
+
860
+ export function ceil(_exprOrField) {
861
+ return callFunctionHelper('ceil', arguments);
862
+ }
863
+
864
+ /**
865
+ * @beta
866
+ * Rounds down to the nearest integer.
867
+ */
868
+
869
+ export function floor(_exprOrField) {
870
+ return callFunctionHelper('floor', arguments);
871
+ }
872
+
873
+ /**
874
+ * @beta
875
+ * Remainder (modulo) of left divided by right.
876
+ */
877
+
878
+ export function mod(_leftOrField, _rightOrValue) {
879
+ return callFunctionHelper('mod', arguments);
880
+ }
881
+
882
+ /**
883
+ * @beta
884
+ * Rounds to the nearest integer (or to decimalPlaces when provided).
885
+ */
886
+
887
+ /**
888
+ * @beta
889
+ * Rounds to the given number of decimal places.
890
+ */
891
+
892
+ export function round(_exprOrField, _decimalPlaces) {
893
+ return callFunctionHelper('round', arguments);
894
+ }
895
+
896
+ /**
897
+ * @beta
898
+ * Conditional expression: if condition then thenExpr else elseExpr.
899
+ */
900
+ export function conditional(_condition, _thenExpr, _elseExpr) {
901
+ return callFunctionHelper('conditional', arguments);
902
+ }
903
+
904
+ /**
905
+ * @beta
906
+ * Count distinct values of an expression or field.
907
+ */
908
+ export function countDistinct(_expr) {
909
+ return callAggregateHelper('countDistinct', arguments);
910
+ }
911
+
912
+ /**
913
+ * @beta
914
+ * First value of the expression in each group (aggregate).
915
+ */
916
+
917
+ export function first(_exprOrField) {
918
+ return callAggregateHelper('first', arguments);
919
+ }
920
+
921
+ /**
922
+ * @beta
923
+ * Last value of the expression in each group (aggregate).
924
+ */
925
+
926
+ export function last(_exprOrField) {
927
+ return callAggregateHelper('last', arguments);
928
+ }
929
+
930
+ // --- arrayAgg, concat, sqrt, currentTimestamp, not, ifAbsent, ifError, string helpers ---
931
+
932
+ /**
933
+ * @beta
934
+ * Collects all values of an expression across stage inputs into an array (aggregate).
935
+ */
936
+
937
+ export function arrayAgg(_exprOrField) {
938
+ return callAggregateHelper('arrayAgg', arguments);
939
+ }
940
+
941
+ /**
942
+ * @beta
943
+ * Concatenates two or more expressions (e.g. strings or arrays).
944
+ */
945
+
946
+ export function concat(_first, _second, ..._others) {
947
+ return callFunctionHelper('concat', arguments);
948
+ }
949
+
950
+ /**
951
+ * @beta
952
+ * Square root of a numeric expression.
953
+ */
954
+
955
+ export function sqrt(_exprOrField) {
956
+ return callFunctionHelper('sqrt', arguments);
957
+ }
958
+
959
+ /**
960
+ * @beta
961
+ * Server timestamp at execution time.
962
+ */
963
+ export function currentTimestamp() {
964
+ return callFunctionHelper('currentTimestamp', arguments);
965
+ }
966
+
967
+ /**
968
+ * @beta
969
+ * Logical NOT of a boolean expression.
970
+ */
971
+ export function not(_booleanExpr) {
972
+ return callBooleanHelper('not', arguments);
973
+ }
974
+
975
+ /**
976
+ * @beta
977
+ * If ifExpr is present use it, else use elseExpr/elseValue.
978
+ */
979
+
980
+ export function ifAbsent(_ifExpr, _elseValue) {
981
+ return callExpressionHelper('ifAbsent', arguments);
982
+ }
983
+
984
+ /**
985
+ * @beta
986
+ * If tryExpr errors, return catchExpr/catchValue (error handling expression).
987
+ */
988
+
989
+ export function ifError(_tryExpr, _catch) {
990
+ return callFunctionHelper('ifError', arguments);
991
+ }
992
+
993
+ /**
994
+ * @beta
995
+ * Converts string to lower case.
996
+ */
997
+
998
+ export function toLower(_fieldOrExpr) {
999
+ return callFunctionHelper('toLower', arguments);
1000
+ }
1001
+
1002
+ /**
1003
+ * @beta
1004
+ * Converts string to upper case.
1005
+ */
1006
+
1007
+ export function toUpper(_fieldOrExpr) {
1008
+ return callFunctionHelper('toUpper', arguments);
1009
+ }
1010
+
1011
+ /**
1012
+ * @beta
1013
+ * Trims whitespace (or optional valueToTrim) from string.
1014
+ */
1015
+
1016
+ export function trim(_fieldOrExpr, _valueToTrim) {
1017
+ return callFunctionHelper('trim', arguments);
1018
+ }
1019
+
1020
+ /**
1021
+ * @beta
1022
+ * Substring from position with optional length.
1023
+ */
1024
+
1025
+ export function substring(_fieldOrInput, _position, _length) {
1026
+ return callFunctionHelper('substring', arguments);
1027
+ }
1028
+
1029
+ // --- Array expression helpers (align with JS SDK) ---
1030
+
1031
+ /**
1032
+ * @beta
1033
+ * Collects distinct values of an expression across stage inputs into an array (aggregate).
1034
+ */
1035
+
1036
+ export function arrayAggDistinct(_exprOrField) {
1037
+ return callAggregateHelper('arrayAggDistinct', arguments);
1038
+ }
1039
+
1040
+ /**
1041
+ * @beta
1042
+ * Concatenates two or more arrays.
1043
+ */
1044
+
1045
+ export function arrayConcat(_first, _second, ..._others) {
1046
+ return callFunctionHelper('arrayConcat', arguments);
1047
+ }
1048
+
1049
+ /**
1050
+ * @beta
1051
+ * Gets element at offset in an array field or expression.
1052
+ */
1053
+
1054
+ export function arrayGet(_arrayOrField, _offset) {
1055
+ return callFunctionHelper('arrayGet', arguments);
1056
+ }
1057
+
1058
+ /**
1059
+ * @beta
1060
+ * Length of an array (field or expression).
1061
+ */
1062
+
1063
+ export function arrayLength(_fieldOrExpr) {
1064
+ return callFunctionHelper('arrayLength', arguments);
1065
+ }
1066
+
1067
+ /**
1068
+ * @beta
1069
+ * Sum of numeric values in an array (aggregate-like for arrays).
1070
+ */
1071
+
1072
+ export function arraySum(_fieldOrExpr) {
1073
+ return callFunctionHelper('arraySum', arguments);
1074
+ }
1075
+
1076
+ // --- Batch: byteLength, charLength, collectionId, countIf, exp, join, like, ln, log, log10, maximum, minimum, pow, reverse, split ---
1077
+
1078
+ export function byteLength(_exprOrField) {
1079
+ return callFunctionHelper('byteLength', arguments);
1080
+ }
1081
+ export function charLength(_fieldOrExpr) {
1082
+ return callFunctionHelper('charLength', arguments);
1083
+ }
1084
+ export function collectionId(_fieldOrExpr) {
1085
+ return callFunctionHelper('collectionId', arguments);
1086
+ }
1087
+ export function countIf(_booleanExpr) {
1088
+ return callAggregateHelper('countIf', arguments);
1089
+ }
1090
+ export function exp(_exprOrField) {
1091
+ return callFunctionHelper('exp', arguments);
1092
+ }
1093
+ export function join(_arrayOrField, _delimiter) {
1094
+ return callExpressionHelper('join', arguments);
1095
+ }
1096
+ export function like(_fieldOrExpr, _pattern) {
1097
+ return callBooleanHelper('like', arguments);
1098
+ }
1099
+ export function ln(_fieldOrExpr) {
1100
+ return callFunctionHelper('ln', arguments);
1101
+ }
1102
+ export function log(_exprOrField, _base) {
1103
+ return callFunctionHelper('log', arguments);
1104
+ }
1105
+ export function log10(_fieldOrExpr) {
1106
+ return callFunctionHelper('log10', arguments);
1107
+ }
1108
+ export function maximum(_exprOrField) {
1109
+ return callAggregateHelper('maximum', arguments);
1110
+ }
1111
+ export function minimum(_exprOrField) {
1112
+ return callAggregateHelper('minimum', arguments);
1113
+ }
1114
+ export function pow(_base, _exponent) {
1115
+ return callFunctionHelper('pow', arguments);
1116
+ }
1117
+ export function reverse(_exprOrField) {
1118
+ return callFunctionHelper('reverse', arguments);
1119
+ }
1120
+ export function split(_fieldOrExpr, _delimiter) {
1121
+ return callFunctionHelper('split', arguments);
1122
+ }
1123
+
1124
+ // --- Batch 2: cosineDistance, dotProduct, equalAny, euclideanDistance, isAbsent, isError, isType, logicalMaximum, logicalMinimum, ltrim, notEqualAny, rand, rtrim, stringConcat ---
1125
+
1126
+ export function cosineDistance(_fieldOrExpr, _vectorOrExpr) {
1127
+ return callFunctionHelper('cosineDistance', arguments);
1128
+ }
1129
+ export function dotProduct(_fieldOrExpr, _vectorOrExpr) {
1130
+ return callFunctionHelper('dotProduct', arguments);
1131
+ }
1132
+ export function equalAny(_exprOrField, _valuesOrArray) {
1133
+ return callBooleanHelper('equalAny', arguments);
1134
+ }
1135
+ export function euclideanDistance(_fieldOrExpr, _vectorOrExpr) {
1136
+ return callFunctionHelper('euclideanDistance', arguments);
1137
+ }
1138
+ export function isAbsent(_valueOrField) {
1139
+ return callBooleanHelper('isAbsent', arguments);
1140
+ }
1141
+ export function isError(_value) {
1142
+ return callBooleanHelper('isError', arguments);
1143
+ }
1144
+ export function isType(_fieldOrExpr, _type) {
1145
+ return callBooleanHelper('isType', arguments);
1146
+ }
1147
+ export function logicalMaximum(_first, _second, ..._others) {
1148
+ return callFunctionHelper('logicalMaximum', arguments);
1149
+ }
1150
+ export function logicalMinimum(_first, _second, ..._others) {
1151
+ return callFunctionHelper('logicalMinimum', arguments);
1152
+ }
1153
+ export function ltrim(_fieldOrExpr, _valueToTrim) {
1154
+ return callFunctionHelper('ltrim', arguments);
1155
+ }
1156
+ export function notEqualAny(_elemOrField, _valuesOrArray) {
1157
+ return callBooleanHelper('notEqualAny', arguments);
1158
+ }
1159
+ export function rand() {
1160
+ return callFunctionHelper('rand', arguments);
1161
+ }
1162
+ export function rtrim(_fieldOrExpr, _valueToTrim) {
1163
+ return callFunctionHelper('rtrim', arguments);
1164
+ }
1165
+ export function stringConcat(_first, _second, ..._others) {
1166
+ return callFunctionHelper('stringConcat', arguments);
1167
+ }
1168
+
1169
+ // --- Batch 3: map*, regex*, stringContains, stringIndexOf, stringRepeat, stringReplaceAll ---
1170
+
1171
+ export function mapEntries(_mapOrExpr) {
1172
+ return callFunctionHelper('mapEntries', arguments);
1173
+ }
1174
+ export function mapGet(_mapOrExpr, _subField) {
1175
+ return callFunctionHelper('mapGet', arguments);
1176
+ }
1177
+ export function mapKeys(_mapOrExpr) {
1178
+ return callFunctionHelper('mapKeys', arguments);
1179
+ }
1180
+ export function mapMerge(_first, _second, ..._others) {
1181
+ return callFunctionHelper('mapMerge', arguments);
1182
+ }
1183
+ export function mapRemove(_mapOrExpr, _keyOrExpr) {
1184
+ return callFunctionHelper('mapRemove', arguments);
1185
+ }
1186
+ export function mapSet(_mapOrExpr, _key, _value, ..._more) {
1187
+ return callFunctionHelper('mapSet', arguments);
1188
+ }
1189
+ export function mapValues(_mapOrExpr) {
1190
+ return callFunctionHelper('mapValues', arguments);
1191
+ }
1192
+ export function regexContains(_fieldOrExpr, _pattern) {
1193
+ return callBooleanHelper('regexContains', arguments);
1194
+ }
1195
+ export function regexFind(_fieldOrExpr, _pattern) {
1196
+ return callFunctionHelper('regexFind', arguments);
1197
+ }
1198
+ export function regexFindAll(_fieldOrExpr, _pattern) {
1199
+ return callFunctionHelper('regexFindAll', arguments);
1200
+ }
1201
+ export function regexMatch(_fieldOrExpr, _pattern) {
1202
+ return callBooleanHelper('regexMatch', arguments);
1203
+ }
1204
+ export function stringContains(_fieldOrExpr, _substring) {
1205
+ return callBooleanHelper('stringContains', arguments);
1206
+ }
1207
+ export function stringIndexOf(_fieldOrExpr, _search) {
1208
+ return callFunctionHelper('stringIndexOf', arguments);
1209
+ }
1210
+ export function stringRepeat(_fieldOrExpr, _repetitions) {
1211
+ return callFunctionHelper('stringRepeat', arguments);
1212
+ }
1213
+ export function stringReplaceAll(_fieldOrExpr, _find, _replacement) {
1214
+ return callFunctionHelper('stringReplaceAll', arguments);
1215
+ }
1216
+
1217
+ // --- Batch 4: stringReplaceOne, stringReverse, timestamp*, trunc, type, unix*ToTimestamp, vectorLength, xor ---
1218
+
1219
+ export function stringReplaceOne(_fieldOrExpr, _find, _replacement) {
1220
+ return callFunctionHelper('stringReplaceOne', arguments);
1221
+ }
1222
+ export function stringReverse(_exprOrField) {
1223
+ return callFunctionHelper('stringReverse', arguments);
1224
+ }
1225
+ export function timestampAdd(_tsOrField, _unit, _amount) {
1226
+ return callFunctionHelper('timestampAdd', arguments);
1227
+ }
1228
+ export function timestampSubtract(_tsOrField, _unit, _amount) {
1229
+ return callFunctionHelper('timestampSubtract', arguments);
1230
+ }
1231
+ export function timestampToUnixMicros(_exprOrField) {
1232
+ return callFunctionHelper('timestampToUnixMicros', arguments);
1233
+ }
1234
+ export function timestampToUnixMillis(_exprOrField) {
1235
+ return callFunctionHelper('timestampToUnixMillis', arguments);
1236
+ }
1237
+ export function timestampToUnixSeconds(_exprOrField) {
1238
+ return callFunctionHelper('timestampToUnixSeconds', arguments);
1239
+ }
1240
+ export function timestampTruncate(_fieldOrExpr, _granularity, _timezone) {
1241
+ return callFunctionHelper('timestampTruncate', arguments);
1242
+ }
1243
+ export function trunc(_fieldOrExpr, _decimalPlaces) {
1244
+ return callFunctionHelper('trunc', arguments);
1245
+ }
1246
+ export function type(_fieldOrExpr) {
1247
+ return callFunctionHelper('type', arguments);
1248
+ }
1249
+ export function unixMicrosToTimestamp(_exprOrField) {
1250
+ return callFunctionHelper('unixMicrosToTimestamp', arguments);
1251
+ }
1252
+ export function unixMillisToTimestamp(_exprOrField) {
1253
+ return callFunctionHelper('unixMillisToTimestamp', arguments);
1254
+ }
1255
+ export function unixSecondsToTimestamp(_exprOrField) {
1256
+ return callFunctionHelper('unixSecondsToTimestamp', arguments);
1257
+ }
1258
+ export function vectorLength(_exprOrField) {
1259
+ return callFunctionHelper('vectorLength', arguments);
1260
+ }
1261
+ export function xor(_first, _second, ..._additionalConditions) {
1262
+ return callBooleanHelper('xor', arguments);
1263
+ }
1264
+
1265
+ /**
1266
+ * @beta
1267
+ * Length of string, array, map, vector, or bytes (field or expression).
1268
+ */
1269
+
1270
+ export function length(_fieldOrExpr) {
1271
+ return callFunctionHelper('length', arguments);
1272
+ }
1273
+ //# sourceMappingURL=expressions.js.map