@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,2321 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import type { DocumentReference } from '../types/firestore';
19
+ import type VectorValue from '../FirestoreVectorValue';
20
+ import type { Bytes } from '../modular/Bytes';
21
+
22
+ /**
23
+ * @beta
24
+ * Expression type kind (for internal/backend use).
25
+ */
26
+ export type ExpressionType =
27
+ | 'Field'
28
+ | 'Constant'
29
+ | 'Function'
30
+ | 'AggregateFunction'
31
+ | 'ListOfExpressions'
32
+ | 'AliasedExpression';
33
+
34
+ /**
35
+ * @beta
36
+ * Firestore value type for isType() checks.
37
+ */
38
+ export type Type =
39
+ | 'null'
40
+ | 'array'
41
+ | 'boolean'
42
+ | 'bytes'
43
+ | 'timestamp'
44
+ | 'geo_point'
45
+ | 'number'
46
+ | 'int32'
47
+ | 'int64'
48
+ | 'float64'
49
+ | 'decimal128'
50
+ | 'map'
51
+ | 'reference'
52
+ | 'string'
53
+ | 'vector'
54
+ | 'max_key'
55
+ | 'min_key'
56
+ | 'object_id'
57
+ | 'regex'
58
+ | 'request_timestamp';
59
+
60
+ /**
61
+ * @beta
62
+ * Time granularity for timestampTruncate.
63
+ */
64
+ export type TimeGranularity =
65
+ | 'microsecond'
66
+ | 'millisecond'
67
+ | 'second'
68
+ | 'minute'
69
+ | 'hour'
70
+ | 'day'
71
+ | 'week'
72
+ | 'week(monday)'
73
+ | 'week(tuesday)'
74
+ | 'week(wednesday)'
75
+ | 'week(thursday)'
76
+ | 'week(friday)'
77
+ | 'week(saturday)'
78
+ | 'week(sunday)'
79
+ | 'isoWeek'
80
+ | 'month'
81
+ | 'quarter'
82
+ | 'year'
83
+ | 'isoYear';
84
+
85
+ /**
86
+ * @beta
87
+ * Boolean expression for pipeline `where()` (e.g. field('x').gt(0), and(...), or(...)).
88
+ */
89
+ interface FluentExpressionMethods {
90
+ as(name: string): AliasedExpression;
91
+ ascending(): Ordering;
92
+ descending(): Ordering;
93
+ add(value: Expression): FunctionExpression;
94
+ add(value: unknown): FunctionExpression;
95
+ average(): AggregateFunction;
96
+ count(): AggregateFunction;
97
+ countDistinct(): AggregateFunction;
98
+ equal(expression: Expression): BooleanExpression;
99
+ equal(value: unknown): BooleanExpression;
100
+ first(): AggregateFunction;
101
+ greaterThan(expression: Expression): BooleanExpression;
102
+ greaterThan(value: unknown): BooleanExpression;
103
+ greaterThanOrEqual(expression: Expression): BooleanExpression;
104
+ greaterThanOrEqual(value: unknown): BooleanExpression;
105
+ last(): AggregateFunction;
106
+ maximum(): AggregateFunction;
107
+ minimum(): AggregateFunction;
108
+ sum(): AggregateFunction;
109
+ arrayAgg(): AggregateFunction;
110
+ arrayAggDistinct(): AggregateFunction;
111
+ }
112
+
113
+ export interface BooleanExpression extends Selectable, FluentExpressionMethods {
114
+ readonly _brand?: 'BooleanExpression';
115
+ }
116
+
117
+ /**
118
+ * @beta
119
+ * Selectable for pipeline field selection/expressions (e.g. field('a').as('b'), expressions).
120
+ */
121
+ export interface Selectable {
122
+ selectable: true;
123
+ }
124
+
125
+ /**
126
+ * @beta
127
+ * Field reference for pipeline stages.
128
+ */
129
+ export interface Field extends Selectable, FluentExpressionMethods {
130
+ readonly _brand?: 'Field';
131
+ }
132
+
133
+ /**
134
+ * @beta
135
+ * Function expression (e.g. map(...), array(...)). Used as return type and in Expression union.
136
+ */
137
+ export interface FunctionExpression extends Selectable, FluentExpressionMethods {
138
+ selectable: true;
139
+ readonly _brand?: 'FunctionExpression';
140
+ }
141
+
142
+ /**
143
+ * @beta
144
+ * Constant/literal expression returned by `constant(...)`.
145
+ */
146
+ export interface ConstantExpression extends FluentExpressionMethods {
147
+ readonly _brand?: 'ConstantExpression';
148
+ }
149
+
150
+ /**
151
+ * @beta
152
+ * Expression type for pipeline parameters (field refs, literals, function results).
153
+ */
154
+ export type Expression = Field | FunctionExpression | ConstantExpression | Selectable | string;
155
+
156
+ /**
157
+ * @beta
158
+ * Ordering for pipeline sort() (e.g. Ordering.of(field('rating')).descending()).
159
+ */
160
+ export interface Ordering {
161
+ descending(): Ordering;
162
+ ascending(): Ordering;
163
+ readonly _brand?: 'Ordering';
164
+ }
165
+
166
+ /**
167
+ * @beta
168
+ * Accumulator for pipeline aggregate() (e.g. avg(field('rating')).as('avgRating'), countAll().as('total')).
169
+ */
170
+ export interface Accumulator {
171
+ as(name: string): AliasedAggregate;
172
+ readonly _brand?: 'Accumulator';
173
+ }
174
+
175
+ /**
176
+ * @beta
177
+ * Aggregate function (e.g. countAll()). Alias for Accumulator.
178
+ */
179
+ export type AggregateFunction = Accumulator;
180
+
181
+ /**
182
+ * @beta
183
+ * An aggregate function with an output alias.
184
+ */
185
+ export interface AliasedAggregate {
186
+ readonly aggregate: AggregateFunction;
187
+ readonly alias: string;
188
+ }
189
+
190
+ /**
191
+ * @beta
192
+ * An expression with an output alias (implements Selectable).
193
+ */
194
+ export interface AliasedExpression extends Selectable {
195
+ readonly expr: Expression;
196
+ readonly alias: string;
197
+ exprType?: ExpressionType;
198
+ }
199
+
200
+ type RuntimeNodeKind =
201
+ | 'expression'
202
+ | 'aggregate'
203
+ | 'ordering'
204
+ | 'aliasedExpression'
205
+ | 'aliasedAggregate';
206
+ type RuntimeDirection = 'ascending' | 'descending';
207
+
208
+ const RUNTIME_NODE_SYMBOL = Symbol.for('RNFBFirestorePipelineExpressionNode');
209
+
210
+ interface RuntimeNodeBase {
211
+ readonly [RUNTIME_NODE_SYMBOL]: true;
212
+ readonly __kind: RuntimeNodeKind;
213
+ exprType?: ExpressionType;
214
+ selectable?: true;
215
+ }
216
+
217
+ interface RuntimeExpressionNode extends RuntimeNodeBase {
218
+ readonly __kind: 'expression';
219
+ path?: string;
220
+ name?: string;
221
+ args?: RuntimeNode[];
222
+ value?: unknown;
223
+ }
224
+
225
+ interface RuntimeAggregateNode extends RuntimeNodeBase {
226
+ readonly __kind: 'aggregate';
227
+ kind: string;
228
+ args?: RuntimeNode[];
229
+ }
230
+
231
+ interface RuntimeOrderingNode extends RuntimeNodeBase {
232
+ readonly __kind: 'ordering';
233
+ expr: RuntimeNode;
234
+ direction: RuntimeDirection;
235
+ }
236
+
237
+ interface RuntimeAliasedExpressionNode extends RuntimeNodeBase {
238
+ readonly __kind: 'aliasedExpression';
239
+ exprType: 'AliasedExpression';
240
+ selectable: true;
241
+ expr: RuntimeNode;
242
+ alias: string;
243
+ }
244
+
245
+ interface RuntimeAliasedAggregateNode extends RuntimeNodeBase {
246
+ readonly __kind: 'aliasedAggregate';
247
+ aggregate: RuntimeAggregateNode;
248
+ alias: string;
249
+ }
250
+
251
+ type RuntimeExpressionMethods = FluentExpressionMethods;
252
+ type RuntimeOrderingMethods = Pick<Ordering, 'ascending' | 'descending'>;
253
+ type RuntimeAggregateMethods = Pick<Accumulator, 'as'>;
254
+
255
+ type ConstantExpressionNode = RuntimeExpressionNode & RuntimeExpressionMethods & ConstantExpression;
256
+ type BooleanExpressionNode = RuntimeExpressionNode & RuntimeExpressionMethods & BooleanExpression;
257
+ type RuntimeExpressionFluentNode =
258
+ | (RuntimeExpressionNode & RuntimeExpressionMethods & Field)
259
+ | (RuntimeExpressionNode & RuntimeExpressionMethods & FunctionExpression)
260
+ | BooleanExpressionNode
261
+ | ConstantExpressionNode;
262
+ type FieldNode = RuntimeExpressionFluentNode & Field;
263
+ type FunctionExpressionNode = RuntimeExpressionFluentNode & FunctionExpression;
264
+ type AggregateNode = RuntimeAggregateNode & RuntimeAggregateMethods & AggregateFunction;
265
+ type OrderingNode = RuntimeOrderingNode & RuntimeOrderingMethods & Ordering;
266
+ type AliasedExpressionNode = RuntimeAliasedExpressionNode & AliasedExpression;
267
+ type AliasedAggregateNode = RuntimeAliasedAggregateNode & AliasedAggregate;
268
+
269
+ type RuntimeNode =
270
+ | RuntimeExpressionFluentNode
271
+ | AggregateNode
272
+ | OrderingNode
273
+ | AliasedExpressionNode
274
+ | AliasedAggregateNode;
275
+
276
+ function isRecord(value: unknown): value is Record<PropertyKey, unknown> {
277
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
278
+ }
279
+
280
+ function isPlainObject(value: unknown): value is Record<PropertyKey, unknown> {
281
+ if (!isRecord(value)) {
282
+ return false;
283
+ }
284
+
285
+ const proto = Object.getPrototypeOf(value);
286
+ return proto === Object.prototype || proto === null;
287
+ }
288
+
289
+ function isDocumentReferenceLike(value: unknown): value is { path: string; firestore: unknown } {
290
+ return (
291
+ isRecord(value) &&
292
+ typeof value.path === 'string' &&
293
+ value.path.length > 0 &&
294
+ isRecord(value.firestore)
295
+ );
296
+ }
297
+
298
+ function isRuntimeNode(value: unknown): value is RuntimeNode {
299
+ return isRecord(value) && value[RUNTIME_NODE_SYMBOL] === true;
300
+ }
301
+
302
+ function isOrderingNode(value: unknown): value is OrderingNode {
303
+ return isRuntimeNode(value) && value.__kind === 'ordering';
304
+ }
305
+
306
+ function containsRuntimeNode(value: unknown): boolean {
307
+ if (isRuntimeNode(value)) {
308
+ return true;
309
+ }
310
+
311
+ if (Array.isArray(value)) {
312
+ return value.some(containsRuntimeNode);
313
+ }
314
+
315
+ if (!isRecord(value)) {
316
+ return false;
317
+ }
318
+
319
+ if (!isPlainObject(value)) {
320
+ return false;
321
+ }
322
+
323
+ return Object.values(value).some(containsRuntimeNode);
324
+ }
325
+
326
+ function toCanonicalFunctionName(name: string): string {
327
+ switch (name) {
328
+ case 'gt':
329
+ return 'greaterThan';
330
+ case 'eq':
331
+ return 'equal';
332
+ case 'gte':
333
+ return 'greaterThanOrEqual';
334
+ case 'lt':
335
+ return 'lessThan';
336
+ case 'lte':
337
+ return 'lessThanOrEqual';
338
+ case 'avg':
339
+ return 'average';
340
+ case 'toLower':
341
+ return 'lower';
342
+ case 'toUpper':
343
+ return 'upper';
344
+ default:
345
+ return name;
346
+ }
347
+ }
348
+
349
+ const AGGREGATE_KINDS = new Set<string>([
350
+ 'countAll',
351
+ 'count',
352
+ 'countIf',
353
+ 'sum',
354
+ 'average',
355
+ 'minimum',
356
+ 'maximum',
357
+ 'countDistinct',
358
+ 'first',
359
+ 'last',
360
+ 'arrayAgg',
361
+ 'arrayAggDistinct',
362
+ ]);
363
+
364
+ const EXPRESSION_METHOD_NAMES = [
365
+ 'and',
366
+ 'or',
367
+ 'gt',
368
+ 'greaterThan',
369
+ 'eq',
370
+ 'equal',
371
+ 'notEqual',
372
+ 'gte',
373
+ 'greaterThanOrEqual',
374
+ 'lt',
375
+ 'lessThan',
376
+ 'lte',
377
+ 'lessThanOrEqual',
378
+ 'exists',
379
+ 'arrayContains',
380
+ 'arrayContainsAny',
381
+ 'arrayContainsAll',
382
+ 'startsWith',
383
+ 'endsWith',
384
+ 'add',
385
+ 'subtract',
386
+ 'divide',
387
+ 'multiply',
388
+ 'documentId',
389
+ 'sum',
390
+ 'count',
391
+ 'average',
392
+ 'abs',
393
+ 'ceil',
394
+ 'floor',
395
+ 'mod',
396
+ 'round',
397
+ 'conditional',
398
+ 'countDistinct',
399
+ 'first',
400
+ 'last',
401
+ 'arrayAgg',
402
+ 'concat',
403
+ 'sqrt',
404
+ 'currentTimestamp',
405
+ 'not',
406
+ 'ifAbsent',
407
+ 'ifError',
408
+ 'toLower',
409
+ 'toUpper',
410
+ 'trim',
411
+ 'substring',
412
+ 'arrayAggDistinct',
413
+ 'arrayConcat',
414
+ 'arrayGet',
415
+ 'arrayLength',
416
+ 'arraySum',
417
+ 'byteLength',
418
+ 'charLength',
419
+ 'collectionId',
420
+ 'countIf',
421
+ 'exp',
422
+ 'join',
423
+ 'like',
424
+ 'ln',
425
+ 'log',
426
+ 'log10',
427
+ 'maximum',
428
+ 'minimum',
429
+ 'pow',
430
+ 'reverse',
431
+ 'split',
432
+ 'cosineDistance',
433
+ 'dotProduct',
434
+ 'equalAny',
435
+ 'euclideanDistance',
436
+ 'isAbsent',
437
+ 'isError',
438
+ 'isType',
439
+ 'logicalMaximum',
440
+ 'logicalMinimum',
441
+ 'ltrim',
442
+ 'notEqualAny',
443
+ 'rand',
444
+ 'rtrim',
445
+ 'stringConcat',
446
+ 'mapEntries',
447
+ 'mapGet',
448
+ 'mapKeys',
449
+ 'mapMerge',
450
+ 'mapRemove',
451
+ 'mapSet',
452
+ 'mapValues',
453
+ 'regexContains',
454
+ 'regexFind',
455
+ 'regexFindAll',
456
+ 'regexMatch',
457
+ 'stringContains',
458
+ 'stringIndexOf',
459
+ 'stringRepeat',
460
+ 'stringReplaceAll',
461
+ 'stringReplaceOne',
462
+ 'stringReverse',
463
+ 'timestampAdd',
464
+ 'timestampSubtract',
465
+ 'timestampToUnixMicros',
466
+ 'timestampToUnixMillis',
467
+ 'timestampToUnixSeconds',
468
+ 'timestampTruncate',
469
+ 'trunc',
470
+ 'type',
471
+ 'unixMicrosToTimestamp',
472
+ 'unixMillisToTimestamp',
473
+ 'unixSecondsToTimestamp',
474
+ 'vectorLength',
475
+ 'xor',
476
+ 'length',
477
+ ] as const;
478
+
479
+ function createNode<TNode extends RuntimeNodeBase, TMethods extends object>(
480
+ proto: TMethods,
481
+ node: TNode,
482
+ ): TNode & TMethods {
483
+ const runtimeNode: TNode & TMethods = Object.create(proto);
484
+ Object.assign(runtimeNode, node);
485
+ return runtimeNode;
486
+ }
487
+
488
+ function createExpressionProto(): RuntimeExpressionMethods {
489
+ const proto: Partial<RuntimeExpressionMethods> = {
490
+ as(this: RuntimeExpressionFluentNode, name: string): AliasedExpressionNode {
491
+ return createAliasedExpression(this, name);
492
+ },
493
+
494
+ ascending(this: RuntimeExpressionFluentNode): OrderingNode {
495
+ return createOrdering(this, 'ascending');
496
+ },
497
+
498
+ descending(this: RuntimeExpressionFluentNode): OrderingNode {
499
+ return createOrdering(this, 'descending');
500
+ },
501
+ };
502
+
503
+ for (const methodName of EXPRESSION_METHOD_NAMES) {
504
+ Object.defineProperty(proto, methodName, {
505
+ value(this: RuntimeExpressionFluentNode, ...args: unknown[]) {
506
+ return createMethodResult(methodName, this, args);
507
+ },
508
+ });
509
+ }
510
+
511
+ return proto as RuntimeExpressionMethods;
512
+ }
513
+
514
+ const expressionProto = createExpressionProto();
515
+
516
+ const aggregateProto: RuntimeAggregateMethods = {
517
+ as(this: AggregateNode, name: string): AliasedAggregateNode {
518
+ return createAliasedAggregate(this, name);
519
+ },
520
+ };
521
+
522
+ const orderingProto: RuntimeOrderingMethods = {
523
+ ascending(this: OrderingNode): OrderingNode {
524
+ return createOrdering(this.expr, 'ascending');
525
+ },
526
+
527
+ descending(this: OrderingNode): OrderingNode {
528
+ return createOrdering(this.expr, 'descending');
529
+ },
530
+ };
531
+
532
+ function createField(path: unknown): FieldNode {
533
+ return createNode(expressionProto, {
534
+ [RUNTIME_NODE_SYMBOL]: true,
535
+ __kind: 'expression',
536
+ exprType: 'Field',
537
+ selectable: true,
538
+ path: String(path ?? ''),
539
+ });
540
+ }
541
+
542
+ function createConstant(value: unknown): ConstantExpressionNode {
543
+ return createNode(expressionProto, {
544
+ [RUNTIME_NODE_SYMBOL]: true,
545
+ __kind: 'expression',
546
+ exprType: 'Constant',
547
+ value,
548
+ });
549
+ }
550
+
551
+ function normalizeMapLikeValue(value: Record<string, unknown>): Record<string, unknown> {
552
+ const output: Record<string, unknown> = {};
553
+
554
+ for (const [key, entryValue] of Object.entries(value)) {
555
+ output[key] = normalizeRawValue(entryValue);
556
+ }
557
+
558
+ return output;
559
+ }
560
+
561
+ function normalizeRawValue(value: unknown): unknown {
562
+ if (isRuntimeNode(value)) {
563
+ return value;
564
+ }
565
+
566
+ if (Array.isArray(value)) {
567
+ if (containsRuntimeNode(value)) {
568
+ return createFunctionExpression(
569
+ 'array',
570
+ value.map(entry => toExpressionArgument(entry)),
571
+ );
572
+ }
573
+
574
+ return value.map(normalizeRawValue);
575
+ }
576
+
577
+ if (isDocumentReferenceLike(value)) {
578
+ // Treat references as atomic values to avoid walking circular internal firestore graphs.
579
+ return value;
580
+ }
581
+
582
+ if (isRecord(value)) {
583
+ if (!isPlainObject(value)) {
584
+ return value;
585
+ }
586
+ return normalizeMapLikeValue(value);
587
+ }
588
+
589
+ return value;
590
+ }
591
+
592
+ function toExpressionArgument(value: unknown, fieldString = false): RuntimeNode {
593
+ if (isRuntimeNode(value)) {
594
+ return value;
595
+ }
596
+
597
+ if (fieldString && typeof value === 'string') {
598
+ return createField(value);
599
+ }
600
+
601
+ if (Array.isArray(value) && containsRuntimeNode(value)) {
602
+ return createFunctionExpression(
603
+ 'array',
604
+ value.map(entry => toExpressionArgument(entry)),
605
+ );
606
+ }
607
+
608
+ return createConstant(normalizeRawValue(value));
609
+ }
610
+
611
+ function createFunctionExpression(name: string, args: RuntimeNode[]): FunctionExpressionNode {
612
+ return createNode(expressionProto, {
613
+ [RUNTIME_NODE_SYMBOL]: true,
614
+ __kind: 'expression',
615
+ exprType: 'Function',
616
+ selectable: true,
617
+ name,
618
+ args,
619
+ });
620
+ }
621
+
622
+ function createBooleanExpression(name: string, args: RuntimeNode[]): BooleanExpressionNode {
623
+ return createNode(expressionProto, {
624
+ [RUNTIME_NODE_SYMBOL]: true,
625
+ __kind: 'expression',
626
+ exprType: 'Function',
627
+ selectable: true,
628
+ name,
629
+ args,
630
+ });
631
+ }
632
+
633
+ function createAggregate(kind: string, args: RuntimeNode[] = []): AggregateNode {
634
+ return createNode(aggregateProto, {
635
+ [RUNTIME_NODE_SYMBOL]: true,
636
+ __kind: 'aggregate',
637
+ exprType: 'AggregateFunction',
638
+ kind,
639
+ args,
640
+ });
641
+ }
642
+
643
+ function createAliasedExpression(
644
+ expr: RuntimeExpressionFluentNode,
645
+ alias: string,
646
+ ): AliasedExpressionNode {
647
+ return createNode(Object.prototype, {
648
+ [RUNTIME_NODE_SYMBOL]: true,
649
+ __kind: 'aliasedExpression',
650
+ exprType: 'AliasedExpression',
651
+ selectable: true,
652
+ expr,
653
+ alias,
654
+ });
655
+ }
656
+
657
+ function createAliasedAggregate(aggregate: AggregateNode, alias: string): AliasedAggregateNode {
658
+ return createNode(Object.prototype, {
659
+ [RUNTIME_NODE_SYMBOL]: true,
660
+ __kind: 'aliasedAggregate',
661
+ aggregate,
662
+ alias,
663
+ });
664
+ }
665
+
666
+ function createOrdering(expr: RuntimeNode, direction: RuntimeDirection): OrderingNode {
667
+ return createNode(orderingProto, {
668
+ [RUNTIME_NODE_SYMBOL]: true,
669
+ __kind: 'ordering',
670
+ expr,
671
+ direction,
672
+ });
673
+ }
674
+
675
+ function normalizeGlobalArguments(name: string, args: unknown[]): RuntimeNode[] {
676
+ const fieldIndexList: number[] = [];
677
+
678
+ switch (name) {
679
+ case 'add':
680
+ case 'subtract':
681
+ case 'divide':
682
+ case 'multiply':
683
+ case 'mod':
684
+ case 'pow':
685
+ case 'abs':
686
+ case 'ceil':
687
+ case 'floor':
688
+ case 'round':
689
+ case 'trunc':
690
+ case 'toLower':
691
+ case 'toUpper':
692
+ case 'trim':
693
+ case 'substring':
694
+ case 'arrayGet':
695
+ case 'arrayLength':
696
+ case 'arraySum':
697
+ case 'arrayConcat':
698
+ case 'byteLength':
699
+ case 'charLength':
700
+ case 'collectionId':
701
+ case 'exp':
702
+ case 'ln':
703
+ case 'log':
704
+ case 'log10':
705
+ case 'reverse':
706
+ case 'split':
707
+ case 'cosineDistance':
708
+ case 'dotProduct':
709
+ case 'euclideanDistance':
710
+ case 'isAbsent':
711
+ case 'isType':
712
+ case 'logicalMaximum':
713
+ case 'logicalMinimum':
714
+ case 'ltrim':
715
+ case 'rtrim':
716
+ case 'stringConcat':
717
+ case 'mapEntries':
718
+ case 'mapGet':
719
+ case 'mapKeys':
720
+ case 'mapMerge':
721
+ case 'mapRemove':
722
+ case 'mapSet':
723
+ case 'mapValues':
724
+ case 'regexContains':
725
+ case 'regexFind':
726
+ case 'regexFindAll':
727
+ case 'regexMatch':
728
+ case 'stringContains':
729
+ case 'stringIndexOf':
730
+ case 'stringRepeat':
731
+ case 'stringReplaceAll':
732
+ case 'stringReplaceOne':
733
+ case 'stringReverse':
734
+ case 'timestampAdd':
735
+ case 'timestampSubtract':
736
+ case 'timestampToUnixMicros':
737
+ case 'timestampToUnixMillis':
738
+ case 'timestampToUnixSeconds':
739
+ case 'timestampTruncate':
740
+ case 'type':
741
+ case 'unixMicrosToTimestamp':
742
+ case 'unixMillisToTimestamp':
743
+ case 'unixSecondsToTimestamp':
744
+ case 'vectorLength':
745
+ case 'length':
746
+ case 'startsWith':
747
+ case 'endsWith':
748
+ case 'like':
749
+ case 'equalAny':
750
+ case 'notEqualAny':
751
+ fieldIndexList.push(0);
752
+ break;
753
+ case 'gt':
754
+ case 'greaterThan':
755
+ case 'eq':
756
+ case 'equal':
757
+ case 'notEqual':
758
+ case 'gte':
759
+ case 'greaterThanOrEqual':
760
+ case 'lt':
761
+ case 'lessThan':
762
+ case 'lte':
763
+ case 'lessThanOrEqual':
764
+ case 'exists':
765
+ case 'arrayContains':
766
+ case 'arrayContainsAny':
767
+ case 'arrayContainsAll':
768
+ case 'sum':
769
+ case 'count':
770
+ case 'average':
771
+ case 'countDistinct':
772
+ case 'first':
773
+ case 'last':
774
+ case 'arrayAgg':
775
+ case 'arrayAggDistinct':
776
+ case 'maximum':
777
+ case 'minimum':
778
+ fieldIndexList.push(0);
779
+ break;
780
+ default:
781
+ break;
782
+ }
783
+
784
+ return args.map((arg, index) => toExpressionArgument(arg, fieldIndexList.includes(index)));
785
+ }
786
+
787
+ function createMethodResult(
788
+ name: string,
789
+ base: RuntimeExpressionFluentNode,
790
+ rawArgs: unknown[],
791
+ ): RuntimeNode {
792
+ const canonicalName = toCanonicalFunctionName(name);
793
+
794
+ if (AGGREGATE_KINDS.has(canonicalName)) {
795
+ return createAggregate(canonicalName, [base, ...rawArgs.map(arg => toExpressionArgument(arg))]);
796
+ }
797
+
798
+ return createFunctionExpression(canonicalName, [
799
+ base,
800
+ ...rawArgs.map(arg => toExpressionArgument(arg)),
801
+ ]);
802
+ }
803
+
804
+ function callBooleanHelper(name: string, argsLike: IArguments): BooleanExpression {
805
+ return createBooleanExpression(
806
+ toCanonicalFunctionName(name),
807
+ normalizeGlobalArguments(name, Array.from(argsLike)),
808
+ );
809
+ }
810
+
811
+ function callFunctionHelper(name: string, argsLike: IArguments): FunctionExpression {
812
+ return createFunctionExpression(
813
+ toCanonicalFunctionName(name),
814
+ normalizeGlobalArguments(name, Array.from(argsLike)),
815
+ );
816
+ }
817
+
818
+ function callAggregateHelper(name: string, argsLike: IArguments): AggregateFunction {
819
+ return createAggregate(
820
+ toCanonicalFunctionName(name),
821
+ normalizeGlobalArguments(name, Array.from(argsLike)),
822
+ );
823
+ }
824
+
825
+ function callExpressionHelper(name: string, argsLike: IArguments): FunctionExpression {
826
+ return createFunctionExpression(
827
+ toCanonicalFunctionName(name),
828
+ normalizeGlobalArguments(name, Array.from(argsLike)),
829
+ );
830
+ }
831
+
832
+ // --- Expression / helper stubs (for use in where, select, addFields, aggregate, sort, etc.) ---
833
+
834
+ /**
835
+ * @beta
836
+ * Returns a Field reference for use in pipeline expressions.
837
+ */
838
+ export function field(_path: string): Field {
839
+ return createField(_path);
840
+ }
841
+
842
+ /**
843
+ * @beta
844
+ * Logical AND of boolean expressions.
845
+ */
846
+ export function and(
847
+ first: BooleanExpression,
848
+ second: BooleanExpression,
849
+ ...more: BooleanExpression[]
850
+ ): BooleanExpression {
851
+ void first;
852
+ void second;
853
+ void more;
854
+ return callBooleanHelper('and', arguments);
855
+ }
856
+
857
+ /**
858
+ * @beta
859
+ * Logical OR of boolean expressions.
860
+ */
861
+ export function or(
862
+ first: BooleanExpression,
863
+ second: BooleanExpression,
864
+ ...more: BooleanExpression[]
865
+ ): BooleanExpression {
866
+ void first;
867
+ void second;
868
+ void more;
869
+ return callBooleanHelper('or', arguments);
870
+ }
871
+
872
+ /**
873
+ * @beta
874
+ * Greater-than comparison.
875
+ */
876
+ export function gt(_left: Expression, _right: Expression): BooleanExpression {
877
+ return callBooleanHelper('gt', arguments);
878
+ }
879
+
880
+ /**
881
+ * @beta
882
+ * Greater-than comparison (alias for gt).
883
+ */
884
+ export function greaterThan(_left: Expression, _right: Expression): BooleanExpression {
885
+ return callBooleanHelper('greaterThan', arguments);
886
+ }
887
+
888
+ /**
889
+ * @beta
890
+ * Equality comparison.
891
+ */
892
+ export function eq(_left: Expression, _right: Expression): BooleanExpression {
893
+ return callBooleanHelper('eq', arguments);
894
+ }
895
+
896
+ /**
897
+ * @beta
898
+ * Equality comparison (alias for eq).
899
+ */
900
+ export function equal(_left: Expression, _right: Expression): BooleanExpression {
901
+ return callBooleanHelper('equal', arguments);
902
+ }
903
+
904
+ /**
905
+ * @beta
906
+ * Inequality comparison.
907
+ */
908
+ export function notEqual(_left: Expression, _right: Expression): BooleanExpression {
909
+ return callBooleanHelper('notEqual', arguments);
910
+ }
911
+
912
+ /**
913
+ * @beta
914
+ * Greater-than-or-equal comparison.
915
+ */
916
+ export function gte(_left: Expression, _right: Expression): BooleanExpression {
917
+ return callBooleanHelper('gte', arguments);
918
+ }
919
+
920
+ /**
921
+ * @beta
922
+ * Less-than comparison.
923
+ */
924
+ export function lt(_left: Expression, _right: Expression): BooleanExpression {
925
+ return callBooleanHelper('lt', arguments);
926
+ }
927
+
928
+ /**
929
+ * @beta
930
+ * Less-than comparison (alias for lt).
931
+ */
932
+ export function lessThan(_left: Expression, _right: Expression): BooleanExpression {
933
+ return callBooleanHelper('lessThan', arguments);
934
+ }
935
+
936
+ /**
937
+ * @beta
938
+ * Less-than-or-equal comparison.
939
+ */
940
+ export function lte(_left: Expression, _right: Expression): BooleanExpression {
941
+ return callBooleanHelper('lte', arguments);
942
+ }
943
+
944
+ /**
945
+ * @beta
946
+ * Less-than-or-equal comparison (alias for lte).
947
+ */
948
+ export function lessThanOrEqual(_left: Expression, _right: Expression): BooleanExpression {
949
+ return callBooleanHelper('lessThanOrEqual', arguments);
950
+ }
951
+
952
+ /**
953
+ * @beta
954
+ * Greater-than-or-equal comparison (alias for gte).
955
+ */
956
+ export function greaterThanOrEqual(_left: Expression, _right: Expression): BooleanExpression {
957
+ return callBooleanHelper('greaterThanOrEqual', arguments);
958
+ }
959
+
960
+ /**
961
+ * @beta
962
+ * Checks if a field exists (or expression evaluates to a value).
963
+ */
964
+ export function exists(_valueOrFieldName: Expression): BooleanExpression {
965
+ return callBooleanHelper('exists', arguments);
966
+ }
967
+
968
+ /**
969
+ * @beta
970
+ * Checks if an array contains an element.
971
+ */
972
+ export function arrayContains(
973
+ _arrayOrFieldName: Expression,
974
+ _element: Expression,
975
+ ): BooleanExpression {
976
+ return callBooleanHelper('arrayContains', arguments);
977
+ }
978
+
979
+ /**
980
+ * @beta
981
+ * Checks if an array contains any of the given values.
982
+ */
983
+ export function arrayContainsAny(
984
+ _arrayOrFieldName: Expression,
985
+ _values: Array<Expression | unknown>,
986
+ ): BooleanExpression {
987
+ return callBooleanHelper('arrayContainsAny', arguments);
988
+ }
989
+
990
+ /**
991
+ * @beta
992
+ * Checks if an array contains all of the given values.
993
+ */
994
+ export function arrayContainsAll(
995
+ _arrayOrFieldName: Expression,
996
+ _values: Array<Expression | unknown>,
997
+ ): BooleanExpression {
998
+ return callBooleanHelper('arrayContainsAll', arguments);
999
+ }
1000
+
1001
+ /**
1002
+ * @beta
1003
+ * Checks if a string starts with a prefix.
1004
+ */
1005
+ export function startsWith(_stringOrFieldName: string, _prefix: string): BooleanExpression;
1006
+ export function startsWith(
1007
+ _stringOrFieldName: Expression,
1008
+ _prefix: string | Expression,
1009
+ ): BooleanExpression;
1010
+ export function startsWith(
1011
+ _stringOrFieldName: string | Expression,
1012
+ _prefix: string | Expression,
1013
+ ): BooleanExpression {
1014
+ return callBooleanHelper('startsWith', arguments);
1015
+ }
1016
+
1017
+ /**
1018
+ * @beta
1019
+ * Checks if a string ends with a suffix.
1020
+ */
1021
+ export function endsWith(_stringOrFieldName: string, _suffix: string): BooleanExpression;
1022
+ export function endsWith(
1023
+ _stringOrFieldName: Expression,
1024
+ _suffix: string | Expression,
1025
+ ): BooleanExpression;
1026
+ export function endsWith(
1027
+ _stringOrFieldName: string | Expression,
1028
+ _suffix: string | Expression,
1029
+ ): BooleanExpression {
1030
+ return callBooleanHelper('endsWith', arguments);
1031
+ }
1032
+
1033
+ /**
1034
+ * @beta
1035
+ * Ordering helper (e.g. Ordering.of(field('rating')).descending()).
1036
+ */
1037
+ export const OrderingHelper = {
1038
+ of(_fieldOrOrdering: Field | Ordering): Ordering {
1039
+ if (isOrderingNode(_fieldOrOrdering)) {
1040
+ return _fieldOrOrdering;
1041
+ }
1042
+
1043
+ return createOrdering(toExpressionArgument(_fieldOrOrdering, true), 'ascending');
1044
+ },
1045
+ };
1046
+
1047
+ /**
1048
+ * @beta
1049
+ * Ascending ordering (standalone). Use in sort().
1050
+ */
1051
+ export function ascending(_expr: Expression): Ordering {
1052
+ return createOrdering(toExpressionArgument(_expr, true), 'ascending');
1053
+ }
1054
+
1055
+ /**
1056
+ * @beta
1057
+ * Descending ordering (standalone). Use in sort().
1058
+ */
1059
+ export function descending(_expr: Expression): Ordering {
1060
+ return createOrdering(toExpressionArgument(_expr, true), 'descending');
1061
+ }
1062
+
1063
+ /**
1064
+ * @beta
1065
+ * Average aggregation (e.g. avg(field('rating')).as('avgRating')).
1066
+ */
1067
+ export function avg(_f: Field | Selectable): Accumulator {
1068
+ return callAggregateHelper('avg', arguments);
1069
+ }
1070
+
1071
+ /**
1072
+ * @beta
1073
+ * Count-all aggregation (e.g. countAll().as('total')).
1074
+ */
1075
+ export function countAll(): AggregateFunction {
1076
+ return createAggregate('countAll');
1077
+ }
1078
+
1079
+ /**
1080
+ * @beta
1081
+ * Map expression for replaceWith etc.
1082
+ */
1083
+ export function map(_entries: Record<string, unknown>): FunctionExpression {
1084
+ return createFunctionExpression('map', [toExpressionArgument(_entries)]);
1085
+ }
1086
+
1087
+ /**
1088
+ * @beta
1089
+ * Array expression.
1090
+ */
1091
+ export function array(_elements: unknown[]): FunctionExpression {
1092
+ return createFunctionExpression(
1093
+ 'array',
1094
+ _elements.map(entry => toExpressionArgument(entry)),
1095
+ );
1096
+ }
1097
+
1098
+ // --- Arithmetic / constant expression helpers (align with JS SDK) ---
1099
+
1100
+ /**
1101
+ * @beta
1102
+ * Creates a constant expression for a number value.
1103
+ */
1104
+ export function constant(_value: number): Expression;
1105
+ /**
1106
+ * @beta
1107
+ * Creates a constant expression for a string value.
1108
+ */
1109
+ export function constant(_value: string): Expression;
1110
+ /**
1111
+ * @beta
1112
+ * Creates a constant boolean expression.
1113
+ */
1114
+ export function constant(_value: boolean): BooleanExpression;
1115
+ /**
1116
+ * @beta
1117
+ * Creates a constant expression for null.
1118
+ */
1119
+ export function constant(_value: null): Expression;
1120
+ /**
1121
+ * @beta
1122
+ * Creates a constant expression for a value (e.g. GeoPoint, Timestamp, Date, Bytes, DocumentReference, VectorValue).
1123
+ */
1124
+ export function constant(_value: unknown): Expression;
1125
+ export function constant(
1126
+ _value: number | string | boolean | null | unknown,
1127
+ ): Expression | BooleanExpression {
1128
+ return createConstant(normalizeRawValue(_value));
1129
+ }
1130
+
1131
+ /**
1132
+ * @beta
1133
+ * Creates an expression that adds two or more expressions together.
1134
+ *
1135
+ * @param first - The first expression to add.
1136
+ * @param second - The second expression or literal to add.
1137
+ * @returns A new Expression representing the addition operation.
1138
+ */
1139
+ export function add(_first: Expression, _second: Expression | unknown): FunctionExpression;
1140
+ /**
1141
+ * @beta
1142
+ * Creates an expression that adds a field's value to an expression.
1143
+ *
1144
+ * @param fieldName - The name of the field containing the value to add.
1145
+ * @param second - The second expression or literal to add.
1146
+ * @returns A new Expression representing the addition operation.
1147
+ */
1148
+ export function add(_fieldName: string, _second: Expression | unknown): FunctionExpression;
1149
+ export function add(
1150
+ _first: Expression | string,
1151
+ _second: Expression | unknown,
1152
+ ): FunctionExpression {
1153
+ return callFunctionHelper('add', arguments);
1154
+ }
1155
+
1156
+ /**
1157
+ * @beta
1158
+ * Creates an expression that subtracts the second from the first.
1159
+ */
1160
+ export function subtract(_left: Expression, _right: Expression): FunctionExpression;
1161
+ /**
1162
+ * @beta
1163
+ * Creates an expression that subtracts a constant value from an expression.
1164
+ */
1165
+ export function subtract(_expression: Expression, _value: unknown): FunctionExpression;
1166
+ /**
1167
+ * @beta
1168
+ * Creates an expression that subtracts an expression from a field's value.
1169
+ */
1170
+ export function subtract(_fieldName: string, _expression: Expression): FunctionExpression;
1171
+ /**
1172
+ * @beta
1173
+ * Creates an expression that subtracts a constant value from a field's value.
1174
+ */
1175
+ export function subtract(_fieldName: string, _value: unknown): FunctionExpression;
1176
+ export function subtract(
1177
+ _leftOrField: Expression | string,
1178
+ _rightOrValue: Expression | unknown,
1179
+ ): FunctionExpression {
1180
+ return callFunctionHelper('subtract', arguments);
1181
+ }
1182
+
1183
+ // --- Additional arithmetic and aggregate helpers (align with JS SDK) ---
1184
+
1185
+ /**
1186
+ * @beta
1187
+ * Creates an expression that divides the first by the second.
1188
+ */
1189
+ export function divide(_left: Expression, _right: Expression): FunctionExpression;
1190
+ /**
1191
+ * @beta
1192
+ * Creates an expression that divides an expression by a constant value.
1193
+ */
1194
+ export function divide(_expression: Expression, _value: unknown): FunctionExpression;
1195
+ /**
1196
+ * @beta
1197
+ * Creates an expression that divides a field's value by an expression.
1198
+ */
1199
+ export function divide(_fieldName: string, _expression: Expression): FunctionExpression;
1200
+ /**
1201
+ * @beta
1202
+ * Creates an expression that divides a field's value by a constant.
1203
+ */
1204
+ export function divide(_fieldName: string, _value: unknown): FunctionExpression;
1205
+ export function divide(
1206
+ _leftOrField: Expression | string,
1207
+ _rightOrValue: Expression | unknown,
1208
+ ): FunctionExpression {
1209
+ return callFunctionHelper('divide', arguments);
1210
+ }
1211
+
1212
+ /**
1213
+ * @beta
1214
+ * Creates an expression that multiplies two or more expressions.
1215
+ */
1216
+ export function multiply(_first: Expression, _second: Expression | unknown): FunctionExpression;
1217
+ /**
1218
+ * @beta
1219
+ * Creates an expression that multiplies a field's value by an expression or literal.
1220
+ */
1221
+ export function multiply(_fieldName: string, _second: Expression | unknown): FunctionExpression;
1222
+ export function multiply(
1223
+ _first: Expression | string,
1224
+ _second: Expression | unknown,
1225
+ ): FunctionExpression {
1226
+ return callFunctionHelper('multiply', arguments);
1227
+ }
1228
+
1229
+ /**
1230
+ * @beta
1231
+ * Creates an expression that evaluates to the document ID (and optionally path).
1232
+ *
1233
+ * @param documentPath - Document path string or DocumentReference.
1234
+ * @returns A new Expression representing the document ID.
1235
+ */
1236
+ export function documentId(_documentPath: string | DocumentReference): FunctionExpression;
1237
+ /**
1238
+ * @beta
1239
+ * Creates an expression that evaluates to the document ID from a path expression.
1240
+ */
1241
+ export function documentId(_documentPathExpr: Expression): FunctionExpression;
1242
+ export function documentId(
1243
+ _documentPath: string | DocumentReference | Expression,
1244
+ ): FunctionExpression {
1245
+ return callFunctionHelper('documentId', arguments);
1246
+ }
1247
+
1248
+ /**
1249
+ * @beta
1250
+ * Creates an aggregation that sums values from an expression across stage inputs.
1251
+ */
1252
+ export function sum(_expression: Expression): AggregateFunction;
1253
+ /**
1254
+ * @beta
1255
+ * Creates an aggregation that sums a field's values across stage inputs.
1256
+ */
1257
+ export function sum(_fieldName: string): AggregateFunction;
1258
+ export function sum(_exprOrField: Expression | string): AggregateFunction {
1259
+ return callAggregateHelper('sum', arguments);
1260
+ }
1261
+
1262
+ /**
1263
+ * @beta
1264
+ * Creates an aggregation that counts stage inputs with valid evaluations of the expression.
1265
+ */
1266
+ export function count(_expression: Expression): AggregateFunction;
1267
+ /**
1268
+ * @beta
1269
+ * Creates an aggregation that counts stage inputs where the field exists.
1270
+ */
1271
+ export function count(_fieldName: string): AggregateFunction;
1272
+ export function count(_exprOrField: Expression | string): AggregateFunction {
1273
+ return callAggregateHelper('count', arguments);
1274
+ }
1275
+
1276
+ /**
1277
+ * @beta
1278
+ * Creates an aggregation that calculates the average (mean) of values from an expression.
1279
+ * SDK name: average (avg is RN alias).
1280
+ */
1281
+ export function average(_expression: Expression): AggregateFunction;
1282
+ /**
1283
+ * @beta
1284
+ * Creates an aggregation that calculates the average (mean) of a field's values.
1285
+ */
1286
+ export function average(_fieldName: string): AggregateFunction;
1287
+ export function average(_exprOrField: Expression | string): AggregateFunction {
1288
+ return callAggregateHelper('average', arguments);
1289
+ }
1290
+
1291
+ // --- More expression and aggregate helpers (align with JS SDK) ---
1292
+
1293
+ /**
1294
+ * @beta
1295
+ * Absolute value of a numeric expression.
1296
+ */
1297
+ export function abs(_expr: Expression): FunctionExpression;
1298
+ /**
1299
+ * @beta
1300
+ * Absolute value of a field.
1301
+ */
1302
+ export function abs(_fieldName: string): FunctionExpression;
1303
+ export function abs(_exprOrField: Expression | string): FunctionExpression {
1304
+ return callFunctionHelper('abs', arguments);
1305
+ }
1306
+
1307
+ /**
1308
+ * @beta
1309
+ * Rounds up to the nearest integer.
1310
+ */
1311
+ export function ceil(_fieldName: string): FunctionExpression;
1312
+ export function ceil(_expression: Expression): FunctionExpression;
1313
+ export function ceil(_exprOrField: Expression | string): FunctionExpression {
1314
+ return callFunctionHelper('ceil', arguments);
1315
+ }
1316
+
1317
+ /**
1318
+ * @beta
1319
+ * Rounds down to the nearest integer.
1320
+ */
1321
+ export function floor(_expr: Expression): FunctionExpression;
1322
+ export function floor(_fieldName: string): FunctionExpression;
1323
+ export function floor(_exprOrField: Expression | string): FunctionExpression {
1324
+ return callFunctionHelper('floor', arguments);
1325
+ }
1326
+
1327
+ /**
1328
+ * @beta
1329
+ * Remainder (modulo) of left divided by right.
1330
+ */
1331
+ export function mod(_left: Expression, _right: Expression): FunctionExpression;
1332
+ export function mod(_expression: Expression, _value: unknown): FunctionExpression;
1333
+ export function mod(_fieldName: string, _expression: Expression): FunctionExpression;
1334
+ export function mod(_fieldName: string, _value: unknown): FunctionExpression;
1335
+ export function mod(
1336
+ _leftOrField: Expression | string,
1337
+ _rightOrValue: Expression | unknown,
1338
+ ): FunctionExpression {
1339
+ return callFunctionHelper('mod', arguments);
1340
+ }
1341
+
1342
+ /**
1343
+ * @beta
1344
+ * Rounds to the nearest integer (or to decimalPlaces when provided).
1345
+ */
1346
+ export function round(_fieldName: string): FunctionExpression;
1347
+ export function round(_expression: Expression): FunctionExpression;
1348
+ /**
1349
+ * @beta
1350
+ * Rounds to the given number of decimal places.
1351
+ */
1352
+ export function round(
1353
+ _expression: Expression,
1354
+ _decimalPlaces: number | Expression,
1355
+ ): FunctionExpression;
1356
+ export function round(_fieldName: string, _decimalPlaces: number | Expression): FunctionExpression;
1357
+ export function round(
1358
+ _exprOrField: Expression | string,
1359
+ _decimalPlaces?: number | Expression,
1360
+ ): FunctionExpression {
1361
+ return callFunctionHelper('round', arguments);
1362
+ }
1363
+
1364
+ /**
1365
+ * @beta
1366
+ * Conditional expression: if condition then thenExpr else elseExpr.
1367
+ */
1368
+ export function conditional(
1369
+ _condition: BooleanExpression,
1370
+ _thenExpr: Expression,
1371
+ _elseExpr: Expression,
1372
+ ): FunctionExpression {
1373
+ return callFunctionHelper('conditional', arguments);
1374
+ }
1375
+
1376
+ /**
1377
+ * @beta
1378
+ * Count distinct values of an expression or field.
1379
+ */
1380
+ export function countDistinct(_expr: Expression | string): AggregateFunction {
1381
+ return callAggregateHelper('countDistinct', arguments);
1382
+ }
1383
+
1384
+ /**
1385
+ * @beta
1386
+ * First value of the expression in each group (aggregate).
1387
+ */
1388
+ export function first(_expression: Expression): AggregateFunction;
1389
+ export function first(_fieldName: string): AggregateFunction;
1390
+ export function first(_exprOrField: Expression | string): AggregateFunction {
1391
+ return callAggregateHelper('first', arguments);
1392
+ }
1393
+
1394
+ /**
1395
+ * @beta
1396
+ * Last value of the expression in each group (aggregate).
1397
+ */
1398
+ export function last(_expression: Expression): AggregateFunction;
1399
+ export function last(_fieldName: string): AggregateFunction;
1400
+ export function last(_exprOrField: Expression | string): AggregateFunction {
1401
+ return callAggregateHelper('last', arguments);
1402
+ }
1403
+
1404
+ // --- arrayAgg, concat, sqrt, currentTimestamp, not, ifAbsent, ifError, string helpers ---
1405
+
1406
+ /**
1407
+ * @beta
1408
+ * Collects all values of an expression across stage inputs into an array (aggregate).
1409
+ */
1410
+ export function arrayAgg(_expression: Expression): AggregateFunction;
1411
+ export function arrayAgg(_fieldName: string): AggregateFunction;
1412
+ export function arrayAgg(_exprOrField: Expression | string): AggregateFunction {
1413
+ return callAggregateHelper('arrayAgg', arguments);
1414
+ }
1415
+
1416
+ /**
1417
+ * @beta
1418
+ * Concatenates two or more expressions (e.g. strings or arrays).
1419
+ */
1420
+ export function concat(
1421
+ _first: Expression,
1422
+ _second: Expression | unknown,
1423
+ ..._others: Array<Expression | unknown>
1424
+ ): FunctionExpression;
1425
+ export function concat(
1426
+ _fieldName: string,
1427
+ _second: Expression | unknown,
1428
+ ..._others: Array<Expression | unknown>
1429
+ ): FunctionExpression;
1430
+ export function concat(
1431
+ _first: Expression | string,
1432
+ _second: Expression | unknown,
1433
+ ..._others: Array<Expression | unknown>
1434
+ ): FunctionExpression {
1435
+ return callFunctionHelper('concat', arguments);
1436
+ }
1437
+
1438
+ /**
1439
+ * @beta
1440
+ * Square root of a numeric expression.
1441
+ */
1442
+ export function sqrt(_expression: Expression): FunctionExpression;
1443
+ export function sqrt(_fieldName: string): FunctionExpression;
1444
+ export function sqrt(_exprOrField: Expression | string): FunctionExpression {
1445
+ return callFunctionHelper('sqrt', arguments);
1446
+ }
1447
+
1448
+ /**
1449
+ * @beta
1450
+ * Server timestamp at execution time.
1451
+ */
1452
+ export function currentTimestamp(): FunctionExpression {
1453
+ return callFunctionHelper('currentTimestamp', arguments);
1454
+ }
1455
+
1456
+ /**
1457
+ * @beta
1458
+ * Logical NOT of a boolean expression.
1459
+ */
1460
+ export function not(_booleanExpr: BooleanExpression): BooleanExpression {
1461
+ return callBooleanHelper('not', arguments);
1462
+ }
1463
+
1464
+ /**
1465
+ * @beta
1466
+ * If ifExpr is present use it, else use elseExpr/elseValue.
1467
+ */
1468
+ export function ifAbsent(_ifExpr: Expression, _elseExpr: Expression): Expression;
1469
+ export function ifAbsent(_ifExpr: Expression, _elseValue: unknown): Expression;
1470
+ export function ifAbsent(_ifFieldName: string, _elseExpr: Expression): Expression;
1471
+ export function ifAbsent(
1472
+ _ifFieldName: string | Expression,
1473
+ _elseValue: Expression | unknown,
1474
+ ): Expression;
1475
+ export function ifAbsent(
1476
+ _ifExpr: string | Expression,
1477
+ _elseValue: Expression | unknown,
1478
+ ): Expression {
1479
+ return callExpressionHelper('ifAbsent', arguments);
1480
+ }
1481
+
1482
+ /**
1483
+ * @beta
1484
+ * If tryExpr errors, return catchExpr/catchValue (error handling expression).
1485
+ */
1486
+ export function ifError(
1487
+ _tryExpr: BooleanExpression,
1488
+ _catchExpr: BooleanExpression,
1489
+ ): BooleanExpression;
1490
+ export function ifError(_tryExpr: Expression, _catchExpr: Expression): FunctionExpression;
1491
+ export function ifError(_tryExpr: Expression, _catchValue: unknown): FunctionExpression;
1492
+ export function ifError(
1493
+ _tryExpr: BooleanExpression | Expression,
1494
+ _catch: BooleanExpression | Expression | unknown,
1495
+ ): BooleanExpression | FunctionExpression {
1496
+ return callFunctionHelper('ifError', arguments);
1497
+ }
1498
+
1499
+ /**
1500
+ * @beta
1501
+ * Converts string to lower case.
1502
+ */
1503
+ export function toLower(_fieldName: string): FunctionExpression;
1504
+ export function toLower(_stringExpression: Expression): FunctionExpression;
1505
+ export function toLower(_fieldOrExpr: string | Expression): FunctionExpression {
1506
+ return callFunctionHelper('toLower', arguments);
1507
+ }
1508
+
1509
+ /**
1510
+ * @beta
1511
+ * Converts string to upper case.
1512
+ */
1513
+ export function toUpper(_fieldName: string): FunctionExpression;
1514
+ export function toUpper(_stringExpression: Expression): FunctionExpression;
1515
+ export function toUpper(_fieldOrExpr: string | Expression): FunctionExpression {
1516
+ return callFunctionHelper('toUpper', arguments);
1517
+ }
1518
+
1519
+ /**
1520
+ * @beta
1521
+ * Trims whitespace (or optional valueToTrim) from string.
1522
+ */
1523
+ export function trim(_fieldName: string, _valueToTrim?: string | Expression): FunctionExpression;
1524
+ export function trim(
1525
+ _stringExpression: Expression,
1526
+ _valueToTrim?: string | Expression,
1527
+ ): FunctionExpression;
1528
+ export function trim(
1529
+ _fieldOrExpr: string | Expression,
1530
+ _valueToTrim?: string | Expression,
1531
+ ): FunctionExpression {
1532
+ return callFunctionHelper('trim', arguments);
1533
+ }
1534
+
1535
+ /**
1536
+ * @beta
1537
+ * Substring from position with optional length.
1538
+ */
1539
+ export function substring(_field: string, _position: number, _length?: number): FunctionExpression;
1540
+ export function substring(
1541
+ _input: Expression,
1542
+ _position: number,
1543
+ _length?: number,
1544
+ ): FunctionExpression;
1545
+ export function substring(
1546
+ _field: string,
1547
+ _position: Expression,
1548
+ _length?: Expression,
1549
+ ): FunctionExpression;
1550
+ export function substring(
1551
+ _input: Expression,
1552
+ _position: Expression,
1553
+ _length?: Expression,
1554
+ ): FunctionExpression;
1555
+ export function substring(
1556
+ _fieldOrInput: string | Expression,
1557
+ _position: number | Expression,
1558
+ _length?: number | Expression,
1559
+ ): FunctionExpression {
1560
+ return callFunctionHelper('substring', arguments);
1561
+ }
1562
+
1563
+ // --- Array expression helpers (align with JS SDK) ---
1564
+
1565
+ /**
1566
+ * @beta
1567
+ * Collects distinct values of an expression across stage inputs into an array (aggregate).
1568
+ */
1569
+ export function arrayAggDistinct(_expression: Expression): AggregateFunction;
1570
+ export function arrayAggDistinct(_fieldName: string): AggregateFunction;
1571
+ export function arrayAggDistinct(_exprOrField: Expression | string): AggregateFunction {
1572
+ return callAggregateHelper('arrayAggDistinct', arguments);
1573
+ }
1574
+
1575
+ /**
1576
+ * @beta
1577
+ * Concatenates two or more arrays.
1578
+ */
1579
+ export function arrayConcat(
1580
+ _firstArray: Expression,
1581
+ _secondArray: Expression | unknown[],
1582
+ ..._otherArrays: Array<Expression | unknown[]>
1583
+ ): FunctionExpression;
1584
+ export function arrayConcat(
1585
+ _firstArrayField: string,
1586
+ _secondArray: Expression | unknown[],
1587
+ ..._otherArrays: Array<Expression | unknown[]>
1588
+ ): FunctionExpression;
1589
+ export function arrayConcat(
1590
+ _first: Expression | string,
1591
+ _second: Expression | unknown[],
1592
+ ..._others: Array<Expression | unknown[]>
1593
+ ): FunctionExpression {
1594
+ return callFunctionHelper('arrayConcat', arguments);
1595
+ }
1596
+
1597
+ /**
1598
+ * @beta
1599
+ * Gets element at offset in an array field or expression.
1600
+ */
1601
+ export function arrayGet(_arrayField: string, _offset: number): FunctionExpression;
1602
+ export function arrayGet(_arrayField: string, _offsetExpr: Expression): FunctionExpression;
1603
+ export function arrayGet(_arrayExpression: Expression, _offset: number): FunctionExpression;
1604
+ export function arrayGet(_arrayExpression: Expression, _offsetExpr: Expression): FunctionExpression;
1605
+ export function arrayGet(
1606
+ _arrayOrField: string | Expression,
1607
+ _offset: number | Expression,
1608
+ ): FunctionExpression {
1609
+ return callFunctionHelper('arrayGet', arguments);
1610
+ }
1611
+
1612
+ /**
1613
+ * @beta
1614
+ * Length of an array (field or expression).
1615
+ */
1616
+ export function arrayLength(_fieldName: string): FunctionExpression;
1617
+ export function arrayLength(_array: Expression): FunctionExpression;
1618
+ export function arrayLength(_fieldOrExpr: string | Expression): FunctionExpression {
1619
+ return callFunctionHelper('arrayLength', arguments);
1620
+ }
1621
+
1622
+ /**
1623
+ * @beta
1624
+ * Sum of numeric values in an array (aggregate-like for arrays).
1625
+ */
1626
+ export function arraySum(_fieldName: string): FunctionExpression;
1627
+ export function arraySum(_expression: Expression): FunctionExpression;
1628
+ export function arraySum(_fieldOrExpr: string | Expression): FunctionExpression {
1629
+ return callFunctionHelper('arraySum', arguments);
1630
+ }
1631
+
1632
+ // --- Batch: byteLength, charLength, collectionId, countIf, exp, join, like, ln, log, log10, maximum, minimum, pow, reverse, split ---
1633
+
1634
+ export function byteLength(_expr: Expression): FunctionExpression;
1635
+ export function byteLength(_fieldName: string): FunctionExpression;
1636
+ export function byteLength(_exprOrField: Expression | string): FunctionExpression {
1637
+ return callFunctionHelper('byteLength', arguments);
1638
+ }
1639
+
1640
+ export function charLength(_fieldName: string): FunctionExpression;
1641
+ export function charLength(_stringExpression: Expression): FunctionExpression;
1642
+ export function charLength(_fieldOrExpr: string | Expression): FunctionExpression {
1643
+ return callFunctionHelper('charLength', arguments);
1644
+ }
1645
+
1646
+ export function collectionId(_fieldName: string): FunctionExpression;
1647
+ export function collectionId(_expression: Expression): FunctionExpression;
1648
+ export function collectionId(_fieldOrExpr: string | Expression): FunctionExpression {
1649
+ return callFunctionHelper('collectionId', arguments);
1650
+ }
1651
+
1652
+ export function countIf(_booleanExpr: BooleanExpression): AggregateFunction {
1653
+ return callAggregateHelper('countIf', arguments);
1654
+ }
1655
+
1656
+ export function exp(_expression: Expression): FunctionExpression;
1657
+ export function exp(_fieldName: string): FunctionExpression;
1658
+ export function exp(_exprOrField: Expression | string): FunctionExpression {
1659
+ return callFunctionHelper('exp', arguments);
1660
+ }
1661
+
1662
+ export function join(_arrayFieldName: string, _delimiter: string): Expression;
1663
+ export function join(_arrayExpression: Expression, _delimiterExpression: Expression): Expression;
1664
+ export function join(_arrayExpression: Expression, _delimiter: string): Expression;
1665
+ export function join(_arrayFieldName: string, _delimiterExpression: Expression): Expression;
1666
+ export function join(
1667
+ _arrayOrField: string | Expression,
1668
+ _delimiter: string | Expression,
1669
+ ): Expression {
1670
+ return callExpressionHelper('join', arguments);
1671
+ }
1672
+
1673
+ export function like(_fieldName: string, _pattern: string): BooleanExpression;
1674
+ export function like(_fieldName: string, _pattern: Expression): BooleanExpression;
1675
+ export function like(_stringExpression: Expression, _pattern: string): BooleanExpression;
1676
+ export function like(_stringExpression: Expression, _pattern: Expression): BooleanExpression;
1677
+ export function like(
1678
+ _fieldOrExpr: string | Expression,
1679
+ _pattern: string | Expression,
1680
+ ): BooleanExpression {
1681
+ return callBooleanHelper('like', arguments);
1682
+ }
1683
+
1684
+ export function ln(_fieldName: string): FunctionExpression;
1685
+ export function ln(_expression: Expression): FunctionExpression;
1686
+ export function ln(_fieldOrExpr: string | Expression): FunctionExpression {
1687
+ return callFunctionHelper('ln', arguments);
1688
+ }
1689
+
1690
+ export function log(_expression: Expression, _base: number): FunctionExpression;
1691
+ export function log(_expression: Expression, _base: Expression): FunctionExpression;
1692
+ export function log(_fieldName: string, _base: number): FunctionExpression;
1693
+ export function log(_fieldName: string, _base: Expression): FunctionExpression;
1694
+ export function log(
1695
+ _exprOrField: Expression | string,
1696
+ _base: number | Expression,
1697
+ ): FunctionExpression {
1698
+ return callFunctionHelper('log', arguments);
1699
+ }
1700
+
1701
+ export function log10(_fieldName: string): FunctionExpression;
1702
+ export function log10(_expression: Expression): FunctionExpression;
1703
+ export function log10(_fieldOrExpr: string | Expression): FunctionExpression {
1704
+ return callFunctionHelper('log10', arguments);
1705
+ }
1706
+
1707
+ export function maximum(_expression: Expression): AggregateFunction;
1708
+ export function maximum(_fieldName: string): AggregateFunction;
1709
+ export function maximum(_exprOrField: Expression | string): AggregateFunction {
1710
+ return callAggregateHelper('maximum', arguments);
1711
+ }
1712
+
1713
+ export function minimum(_expression: Expression): AggregateFunction;
1714
+ export function minimum(_fieldName: string): AggregateFunction;
1715
+ export function minimum(_exprOrField: Expression | string): AggregateFunction {
1716
+ return callAggregateHelper('minimum', arguments);
1717
+ }
1718
+
1719
+ export function pow(_base: Expression, _exponent: Expression): FunctionExpression;
1720
+ export function pow(_base: Expression, _exponent: number): FunctionExpression;
1721
+ export function pow(_base: string, _exponent: Expression): FunctionExpression;
1722
+ export function pow(_base: string, _exponent: number): FunctionExpression;
1723
+ export function pow(
1724
+ _base: Expression | string,
1725
+ _exponent: Expression | number,
1726
+ ): FunctionExpression {
1727
+ return callFunctionHelper('pow', arguments);
1728
+ }
1729
+
1730
+ export function reverse(_stringExpression: Expression): FunctionExpression;
1731
+ export function reverse(_field: string): FunctionExpression;
1732
+ export function reverse(_exprOrField: Expression | string): FunctionExpression {
1733
+ return callFunctionHelper('reverse', arguments);
1734
+ }
1735
+
1736
+ export function split(_fieldName: string, _delimiter: string): FunctionExpression;
1737
+ export function split(_fieldName: string, _delimiter: Expression): FunctionExpression;
1738
+ export function split(_expression: Expression, _delimiter: string): FunctionExpression;
1739
+ export function split(_expression: Expression, _delimiter: Expression): FunctionExpression;
1740
+ export function split(
1741
+ _fieldOrExpr: string | Expression,
1742
+ _delimiter: string | Expression,
1743
+ ): FunctionExpression {
1744
+ return callFunctionHelper('split', arguments);
1745
+ }
1746
+
1747
+ // --- Batch 2: cosineDistance, dotProduct, equalAny, euclideanDistance, isAbsent, isError, isType, logicalMaximum, logicalMinimum, ltrim, notEqualAny, rand, rtrim, stringConcat ---
1748
+
1749
+ export function cosineDistance(
1750
+ _fieldName: string,
1751
+ _vector: number[] | VectorValue,
1752
+ ): FunctionExpression;
1753
+ export function cosineDistance(
1754
+ _fieldName: string,
1755
+ _vectorExpression: Expression,
1756
+ ): FunctionExpression;
1757
+ export function cosineDistance(
1758
+ _vectorExpression: Expression,
1759
+ _vector: number[] | VectorValue,
1760
+ ): FunctionExpression;
1761
+ export function cosineDistance(
1762
+ _vectorExpression: Expression,
1763
+ _otherVectorExpression: Expression,
1764
+ ): FunctionExpression;
1765
+ export function cosineDistance(
1766
+ _fieldOrExpr: string | Expression,
1767
+ _vectorOrExpr: number[] | VectorValue | Expression,
1768
+ ): FunctionExpression {
1769
+ return callFunctionHelper('cosineDistance', arguments);
1770
+ }
1771
+
1772
+ export function dotProduct(_fieldName: string, _vector: number[] | VectorValue): FunctionExpression;
1773
+ export function dotProduct(_fieldName: string, _vectorExpression: Expression): FunctionExpression;
1774
+ export function dotProduct(
1775
+ _vectorExpression: Expression,
1776
+ _vector: number[] | VectorValue,
1777
+ ): FunctionExpression;
1778
+ export function dotProduct(
1779
+ _vectorExpression: Expression,
1780
+ _otherVectorExpression: Expression,
1781
+ ): FunctionExpression;
1782
+ export function dotProduct(
1783
+ _fieldOrExpr: string | Expression,
1784
+ _vectorOrExpr: number[] | VectorValue | Expression,
1785
+ ): FunctionExpression {
1786
+ return callFunctionHelper('dotProduct', arguments);
1787
+ }
1788
+
1789
+ export function equalAny(
1790
+ _expression: Expression,
1791
+ _values: Array<Expression | unknown>,
1792
+ ): BooleanExpression;
1793
+ export function equalAny(_expression: Expression, _arrayExpression: Expression): BooleanExpression;
1794
+ export function equalAny(
1795
+ _fieldName: string,
1796
+ _values: Array<Expression | unknown>,
1797
+ ): BooleanExpression;
1798
+ export function equalAny(_fieldName: string, _arrayExpression: Expression): BooleanExpression;
1799
+ export function equalAny(
1800
+ _exprOrField: string | Expression,
1801
+ _valuesOrArray: Array<Expression | unknown> | Expression,
1802
+ ): BooleanExpression {
1803
+ return callBooleanHelper('equalAny', arguments);
1804
+ }
1805
+
1806
+ export function euclideanDistance(
1807
+ _fieldName: string,
1808
+ _vector: number[] | VectorValue,
1809
+ ): FunctionExpression;
1810
+ export function euclideanDistance(
1811
+ _fieldName: string,
1812
+ _vectorExpression: Expression,
1813
+ ): FunctionExpression;
1814
+ export function euclideanDistance(
1815
+ _vectorExpression: Expression,
1816
+ _vector: number[] | VectorValue,
1817
+ ): FunctionExpression;
1818
+ export function euclideanDistance(
1819
+ _vectorExpression: Expression,
1820
+ _otherVectorExpression: Expression,
1821
+ ): FunctionExpression;
1822
+ export function euclideanDistance(
1823
+ _fieldOrExpr: string | Expression,
1824
+ _vectorOrExpr: number[] | VectorValue | Expression,
1825
+ ): FunctionExpression {
1826
+ return callFunctionHelper('euclideanDistance', arguments);
1827
+ }
1828
+
1829
+ export function isAbsent(_value: Expression): BooleanExpression;
1830
+ export function isAbsent(_field: string): BooleanExpression;
1831
+ export function isAbsent(_valueOrField: Expression | string): BooleanExpression {
1832
+ return callBooleanHelper('isAbsent', arguments);
1833
+ }
1834
+
1835
+ export function isError(_value: Expression): BooleanExpression {
1836
+ return callBooleanHelper('isError', arguments);
1837
+ }
1838
+
1839
+ export function isType(_fieldName: string, _type: Type): BooleanExpression;
1840
+ export function isType(_expression: Expression, _type: Type): BooleanExpression;
1841
+ export function isType(_fieldOrExpr: string | Expression, _type: Type): BooleanExpression {
1842
+ return callBooleanHelper('isType', arguments);
1843
+ }
1844
+
1845
+ export function logicalMaximum(
1846
+ _first: Expression,
1847
+ _second: Expression | unknown,
1848
+ ..._others: Array<Expression | unknown>
1849
+ ): FunctionExpression;
1850
+ export function logicalMaximum(
1851
+ _fieldName: string,
1852
+ _second: Expression | unknown,
1853
+ ..._others: Array<Expression | unknown>
1854
+ ): FunctionExpression;
1855
+ export function logicalMaximum(
1856
+ _first: Expression | string,
1857
+ _second: Expression | unknown,
1858
+ ..._others: Array<Expression | unknown>
1859
+ ): FunctionExpression {
1860
+ return callFunctionHelper('logicalMaximum', arguments);
1861
+ }
1862
+
1863
+ export function logicalMinimum(
1864
+ _first: Expression,
1865
+ _second: Expression | unknown,
1866
+ ..._others: Array<Expression | unknown>
1867
+ ): FunctionExpression;
1868
+ export function logicalMinimum(
1869
+ _fieldName: string,
1870
+ _second: Expression | unknown,
1871
+ ..._others: Array<Expression | unknown>
1872
+ ): FunctionExpression;
1873
+ export function logicalMinimum(
1874
+ _first: Expression | string,
1875
+ _second: Expression | unknown,
1876
+ ..._others: Array<Expression | unknown>
1877
+ ): FunctionExpression {
1878
+ return callFunctionHelper('logicalMinimum', arguments);
1879
+ }
1880
+
1881
+ export function ltrim(
1882
+ _fieldName: string,
1883
+ _valueToTrim?: string | Expression | Bytes,
1884
+ ): FunctionExpression;
1885
+ export function ltrim(
1886
+ _expression: Expression,
1887
+ _valueToTrim?: string | Expression | Bytes,
1888
+ ): FunctionExpression;
1889
+ export function ltrim(
1890
+ _fieldOrExpr: string | Expression,
1891
+ _valueToTrim?: string | Expression | Bytes,
1892
+ ): FunctionExpression {
1893
+ return callFunctionHelper('ltrim', arguments);
1894
+ }
1895
+
1896
+ export function notEqualAny(
1897
+ _element: Expression,
1898
+ _values: Array<Expression | unknown>,
1899
+ ): BooleanExpression;
1900
+ export function notEqualAny(
1901
+ _fieldName: string,
1902
+ _values: Array<Expression | unknown>,
1903
+ ): BooleanExpression;
1904
+ export function notEqualAny(_element: Expression, _arrayExpression: Expression): BooleanExpression;
1905
+ export function notEqualAny(_fieldName: string, _arrayExpression: Expression): BooleanExpression;
1906
+ export function notEqualAny(
1907
+ _elemOrField: string | Expression,
1908
+ _valuesOrArray: Array<Expression | unknown> | Expression,
1909
+ ): BooleanExpression {
1910
+ return callBooleanHelper('notEqualAny', arguments);
1911
+ }
1912
+
1913
+ export function rand(): FunctionExpression {
1914
+ return callFunctionHelper('rand', arguments);
1915
+ }
1916
+
1917
+ export function rtrim(
1918
+ _fieldName: string,
1919
+ _valueToTrim?: string | Expression | Bytes,
1920
+ ): FunctionExpression;
1921
+ export function rtrim(
1922
+ _expression: Expression,
1923
+ _valueToTrim?: string | Expression | Bytes,
1924
+ ): FunctionExpression;
1925
+ export function rtrim(
1926
+ _fieldOrExpr: string | Expression,
1927
+ _valueToTrim?: string | Expression | Bytes,
1928
+ ): FunctionExpression {
1929
+ return callFunctionHelper('rtrim', arguments);
1930
+ }
1931
+
1932
+ export function stringConcat(
1933
+ _fieldName: string,
1934
+ _secondString: Expression | string,
1935
+ ..._otherStrings: Array<Expression | string>
1936
+ ): FunctionExpression;
1937
+ export function stringConcat(
1938
+ _firstString: Expression,
1939
+ _secondString: Expression | string,
1940
+ ..._otherStrings: Array<Expression | string>
1941
+ ): FunctionExpression;
1942
+ export function stringConcat(
1943
+ _first: string | Expression,
1944
+ _second: Expression | string,
1945
+ ..._others: Array<Expression | string>
1946
+ ): FunctionExpression {
1947
+ return callFunctionHelper('stringConcat', arguments);
1948
+ }
1949
+
1950
+ // --- Batch 3: map*, regex*, stringContains, stringIndexOf, stringRepeat, stringReplaceAll ---
1951
+
1952
+ export function mapEntries(_mapField: string): FunctionExpression;
1953
+ export function mapEntries(_mapExpression: Expression): FunctionExpression;
1954
+ export function mapEntries(_mapOrExpr: string | Expression): FunctionExpression {
1955
+ return callFunctionHelper('mapEntries', arguments);
1956
+ }
1957
+
1958
+ export function mapGet(_fieldName: string, _subField: string): FunctionExpression;
1959
+ export function mapGet(_mapExpression: Expression, _subField: string): FunctionExpression;
1960
+ export function mapGet(_mapOrExpr: string | Expression, _subField: string): FunctionExpression {
1961
+ return callFunctionHelper('mapGet', arguments);
1962
+ }
1963
+
1964
+ export function mapKeys(_mapField: string): FunctionExpression;
1965
+ export function mapKeys(_mapExpression: Expression): FunctionExpression;
1966
+ export function mapKeys(_mapOrExpr: string | Expression): FunctionExpression {
1967
+ return callFunctionHelper('mapKeys', arguments);
1968
+ }
1969
+
1970
+ export function mapMerge(
1971
+ _mapField: string,
1972
+ _secondMap: Record<string, unknown> | Expression,
1973
+ ..._otherMaps: Array<Record<string, unknown> | Expression>
1974
+ ): FunctionExpression;
1975
+ export function mapMerge(
1976
+ _firstMap: Record<string, unknown> | Expression,
1977
+ _secondMap: Record<string, unknown> | Expression,
1978
+ ..._otherMaps: Array<Record<string, unknown> | Expression>
1979
+ ): FunctionExpression;
1980
+ export function mapMerge(
1981
+ _first: string | Record<string, unknown> | Expression,
1982
+ _second: Record<string, unknown> | Expression,
1983
+ ..._others: Array<Record<string, unknown> | Expression>
1984
+ ): FunctionExpression {
1985
+ return callFunctionHelper('mapMerge', arguments);
1986
+ }
1987
+
1988
+ export function mapRemove(_mapField: string, _key: string): FunctionExpression;
1989
+ export function mapRemove(_mapExpr: Expression, _key: string): FunctionExpression;
1990
+ export function mapRemove(_mapField: string, _keyExpr: Expression): FunctionExpression;
1991
+ export function mapRemove(_mapExpr: Expression, _keyExpr: Expression): FunctionExpression;
1992
+ export function mapRemove(
1993
+ _mapOrExpr: string | Expression,
1994
+ _keyOrExpr: string | Expression,
1995
+ ): FunctionExpression {
1996
+ return callFunctionHelper('mapRemove', arguments);
1997
+ }
1998
+
1999
+ export function mapSet(
2000
+ _mapField: string,
2001
+ _key: string | Expression,
2002
+ _value: unknown,
2003
+ ..._moreKeyValues: unknown[]
2004
+ ): FunctionExpression;
2005
+ export function mapSet(
2006
+ _mapExpression: Expression,
2007
+ _key: string | Expression,
2008
+ _value: unknown,
2009
+ ..._moreKeyValues: unknown[]
2010
+ ): FunctionExpression;
2011
+ export function mapSet(
2012
+ _mapOrExpr: string | Expression,
2013
+ _key: string | Expression,
2014
+ _value: unknown,
2015
+ ..._more: unknown[]
2016
+ ): FunctionExpression {
2017
+ return callFunctionHelper('mapSet', arguments);
2018
+ }
2019
+
2020
+ export function mapValues(_mapField: string): FunctionExpression;
2021
+ export function mapValues(_mapExpression: Expression): FunctionExpression;
2022
+ export function mapValues(_mapOrExpr: string | Expression): FunctionExpression {
2023
+ return callFunctionHelper('mapValues', arguments);
2024
+ }
2025
+
2026
+ export function regexContains(_fieldName: string, _pattern: string): BooleanExpression;
2027
+ export function regexContains(_fieldName: string, _pattern: Expression): BooleanExpression;
2028
+ export function regexContains(_stringExpression: Expression, _pattern: string): BooleanExpression;
2029
+ export function regexContains(
2030
+ _stringExpression: Expression,
2031
+ _pattern: Expression,
2032
+ ): BooleanExpression;
2033
+ export function regexContains(
2034
+ _fieldOrExpr: string | Expression,
2035
+ _pattern: string | Expression,
2036
+ ): BooleanExpression {
2037
+ return callBooleanHelper('regexContains', arguments);
2038
+ }
2039
+
2040
+ export function regexFind(_fieldName: string, _pattern: string): FunctionExpression;
2041
+ export function regexFind(_fieldName: string, _pattern: Expression): FunctionExpression;
2042
+ export function regexFind(_stringExpression: Expression, _pattern: string): FunctionExpression;
2043
+ export function regexFind(_stringExpression: Expression, _pattern: Expression): FunctionExpression;
2044
+ export function regexFind(
2045
+ _fieldOrExpr: string | Expression,
2046
+ _pattern: string | Expression,
2047
+ ): FunctionExpression {
2048
+ return callFunctionHelper('regexFind', arguments);
2049
+ }
2050
+
2051
+ export function regexFindAll(_fieldName: string, _pattern: string): FunctionExpression;
2052
+ export function regexFindAll(_fieldName: string, _pattern: Expression): FunctionExpression;
2053
+ export function regexFindAll(_stringExpression: Expression, _pattern: string): FunctionExpression;
2054
+ export function regexFindAll(
2055
+ _stringExpression: Expression,
2056
+ _pattern: Expression,
2057
+ ): FunctionExpression;
2058
+ export function regexFindAll(
2059
+ _fieldOrExpr: string | Expression,
2060
+ _pattern: string | Expression,
2061
+ ): FunctionExpression {
2062
+ return callFunctionHelper('regexFindAll', arguments);
2063
+ }
2064
+
2065
+ export function regexMatch(_fieldName: string, _pattern: string): BooleanExpression;
2066
+ export function regexMatch(_fieldName: string, _pattern: Expression): BooleanExpression;
2067
+ export function regexMatch(_stringExpression: Expression, _pattern: string): BooleanExpression;
2068
+ export function regexMatch(_stringExpression: Expression, _pattern: Expression): BooleanExpression;
2069
+ export function regexMatch(
2070
+ _fieldOrExpr: string | Expression,
2071
+ _pattern: string | Expression,
2072
+ ): BooleanExpression {
2073
+ return callBooleanHelper('regexMatch', arguments);
2074
+ }
2075
+
2076
+ export function stringContains(_fieldName: string, _substring: string): BooleanExpression;
2077
+ export function stringContains(_fieldName: string, _substring: Expression): BooleanExpression;
2078
+ export function stringContains(
2079
+ _stringExpression: Expression,
2080
+ _substring: string,
2081
+ ): BooleanExpression;
2082
+ export function stringContains(
2083
+ _stringExpression: Expression,
2084
+ _substring: Expression,
2085
+ ): BooleanExpression;
2086
+ export function stringContains(
2087
+ _fieldOrExpr: string | Expression,
2088
+ _substring: string | Expression,
2089
+ ): BooleanExpression {
2090
+ return callBooleanHelper('stringContains', arguments);
2091
+ }
2092
+
2093
+ export function stringIndexOf(
2094
+ _fieldName: string,
2095
+ _search: string | Expression | Bytes,
2096
+ ): FunctionExpression;
2097
+ export function stringIndexOf(
2098
+ _expression: Expression,
2099
+ _search: string | Expression | Bytes,
2100
+ ): FunctionExpression;
2101
+ export function stringIndexOf(
2102
+ _fieldOrExpr: string | Expression,
2103
+ _search: string | Expression | Bytes,
2104
+ ): FunctionExpression {
2105
+ return callFunctionHelper('stringIndexOf', arguments);
2106
+ }
2107
+
2108
+ export function stringRepeat(
2109
+ _fieldName: string,
2110
+ _repetitions: number | Expression,
2111
+ ): FunctionExpression;
2112
+ export function stringRepeat(
2113
+ _expression: Expression,
2114
+ _repetitions: number | Expression,
2115
+ ): FunctionExpression;
2116
+ export function stringRepeat(
2117
+ _fieldOrExpr: string | Expression,
2118
+ _repetitions: number | Expression,
2119
+ ): FunctionExpression {
2120
+ return callFunctionHelper('stringRepeat', arguments);
2121
+ }
2122
+
2123
+ export function stringReplaceAll(
2124
+ _fieldName: string,
2125
+ _find: string | Expression | Bytes,
2126
+ _replacement: string | Expression | Bytes,
2127
+ ): FunctionExpression;
2128
+ export function stringReplaceAll(
2129
+ _expression: Expression,
2130
+ _find: string | Expression | Bytes,
2131
+ _replacement: string | Expression | Bytes,
2132
+ ): FunctionExpression;
2133
+ export function stringReplaceAll(
2134
+ _fieldOrExpr: string | Expression,
2135
+ _find: string | Expression | Bytes,
2136
+ _replacement: string | Expression | Bytes,
2137
+ ): FunctionExpression {
2138
+ return callFunctionHelper('stringReplaceAll', arguments);
2139
+ }
2140
+
2141
+ // --- Batch 4: stringReplaceOne, stringReverse, timestamp*, trunc, type, unix*ToTimestamp, vectorLength, xor ---
2142
+
2143
+ type TimestampUnit = 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day';
2144
+
2145
+ export function stringReplaceOne(
2146
+ _fieldName: string,
2147
+ _find: string | Expression | Bytes,
2148
+ _replacement: string | Expression | Bytes,
2149
+ ): FunctionExpression;
2150
+ export function stringReplaceOne(
2151
+ _expression: Expression,
2152
+ _find: string | Expression | Bytes,
2153
+ _replacement: string | Expression | Bytes,
2154
+ ): FunctionExpression;
2155
+ export function stringReplaceOne(
2156
+ _fieldOrExpr: string | Expression,
2157
+ _find: string | Expression | Bytes,
2158
+ _replacement: string | Expression | Bytes,
2159
+ ): FunctionExpression {
2160
+ return callFunctionHelper('stringReplaceOne', arguments);
2161
+ }
2162
+
2163
+ export function stringReverse(_stringExpression: Expression): FunctionExpression;
2164
+ export function stringReverse(_field: string): FunctionExpression;
2165
+ export function stringReverse(_exprOrField: Expression | string): FunctionExpression {
2166
+ return callFunctionHelper('stringReverse', arguments);
2167
+ }
2168
+
2169
+ export function timestampAdd(
2170
+ _timestamp: Expression,
2171
+ _unit: Expression,
2172
+ _amount: Expression,
2173
+ ): FunctionExpression;
2174
+ export function timestampAdd(
2175
+ _timestamp: Expression,
2176
+ _unit: TimestampUnit,
2177
+ _amount: number,
2178
+ ): FunctionExpression;
2179
+ export function timestampAdd(
2180
+ _fieldName: string,
2181
+ _unit: TimestampUnit,
2182
+ _amount: number,
2183
+ ): FunctionExpression;
2184
+ export function timestampAdd(
2185
+ _tsOrField: Expression | string,
2186
+ _unit: Expression | TimestampUnit,
2187
+ _amount: Expression | number,
2188
+ ): FunctionExpression {
2189
+ return callFunctionHelper('timestampAdd', arguments);
2190
+ }
2191
+
2192
+ export function timestampSubtract(
2193
+ _timestamp: Expression,
2194
+ _unit: Expression,
2195
+ _amount: Expression,
2196
+ ): FunctionExpression;
2197
+ export function timestampSubtract(
2198
+ _timestamp: Expression,
2199
+ _unit: TimestampUnit,
2200
+ _amount: number,
2201
+ ): FunctionExpression;
2202
+ export function timestampSubtract(
2203
+ _fieldName: string,
2204
+ _unit: TimestampUnit,
2205
+ _amount: number,
2206
+ ): FunctionExpression;
2207
+ export function timestampSubtract(
2208
+ _tsOrField: Expression | string,
2209
+ _unit: Expression | TimestampUnit,
2210
+ _amount: Expression | number,
2211
+ ): FunctionExpression {
2212
+ return callFunctionHelper('timestampSubtract', arguments);
2213
+ }
2214
+
2215
+ export function timestampToUnixMicros(_expr: Expression): FunctionExpression;
2216
+ export function timestampToUnixMicros(_fieldName: string): FunctionExpression;
2217
+ export function timestampToUnixMicros(_exprOrField: Expression | string): FunctionExpression {
2218
+ return callFunctionHelper('timestampToUnixMicros', arguments);
2219
+ }
2220
+
2221
+ export function timestampToUnixMillis(_expr: Expression): FunctionExpression;
2222
+ export function timestampToUnixMillis(_fieldName: string): FunctionExpression;
2223
+ export function timestampToUnixMillis(_exprOrField: Expression | string): FunctionExpression {
2224
+ return callFunctionHelper('timestampToUnixMillis', arguments);
2225
+ }
2226
+
2227
+ export function timestampToUnixSeconds(_expr: Expression): FunctionExpression;
2228
+ export function timestampToUnixSeconds(_fieldName: string): FunctionExpression;
2229
+ export function timestampToUnixSeconds(_exprOrField: Expression | string): FunctionExpression {
2230
+ return callFunctionHelper('timestampToUnixSeconds', arguments);
2231
+ }
2232
+
2233
+ export function timestampTruncate(
2234
+ _fieldName: string,
2235
+ _granularity: TimeGranularity,
2236
+ _timezone?: string | Expression,
2237
+ ): FunctionExpression;
2238
+ export function timestampTruncate(
2239
+ _fieldName: string,
2240
+ _granularity: Expression,
2241
+ _timezone?: string | Expression,
2242
+ ): FunctionExpression;
2243
+ export function timestampTruncate(
2244
+ _timestampExpression: Expression,
2245
+ _granularity: TimeGranularity,
2246
+ _timezone?: string | Expression,
2247
+ ): FunctionExpression;
2248
+ export function timestampTruncate(
2249
+ _timestampExpression: Expression,
2250
+ _granularity: Expression,
2251
+ _timezone?: string | Expression,
2252
+ ): FunctionExpression;
2253
+ export function timestampTruncate(
2254
+ _fieldOrExpr: string | Expression,
2255
+ _granularity: TimeGranularity | Expression,
2256
+ _timezone?: string | Expression,
2257
+ ): FunctionExpression {
2258
+ return callFunctionHelper('timestampTruncate', arguments);
2259
+ }
2260
+
2261
+ export function trunc(_fieldName: string): FunctionExpression;
2262
+ export function trunc(_expression: Expression): FunctionExpression;
2263
+ export function trunc(_fieldName: string, _decimalPlaces: number | Expression): FunctionExpression;
2264
+ export function trunc(
2265
+ _expression: Expression,
2266
+ _decimalPlaces: number | Expression,
2267
+ ): FunctionExpression;
2268
+ export function trunc(
2269
+ _fieldOrExpr: string | Expression,
2270
+ _decimalPlaces?: number | Expression,
2271
+ ): FunctionExpression {
2272
+ return callFunctionHelper('trunc', arguments);
2273
+ }
2274
+
2275
+ export function type(_fieldName: string): FunctionExpression;
2276
+ export function type(_expression: Expression): FunctionExpression;
2277
+ export function type(_fieldOrExpr: string | Expression): FunctionExpression {
2278
+ return callFunctionHelper('type', arguments);
2279
+ }
2280
+
2281
+ export function unixMicrosToTimestamp(_expr: Expression): FunctionExpression;
2282
+ export function unixMicrosToTimestamp(_fieldName: string): FunctionExpression;
2283
+ export function unixMicrosToTimestamp(_exprOrField: Expression | string): FunctionExpression {
2284
+ return callFunctionHelper('unixMicrosToTimestamp', arguments);
2285
+ }
2286
+
2287
+ export function unixMillisToTimestamp(_expr: Expression): FunctionExpression;
2288
+ export function unixMillisToTimestamp(_fieldName: string): FunctionExpression;
2289
+ export function unixMillisToTimestamp(_exprOrField: Expression | string): FunctionExpression {
2290
+ return callFunctionHelper('unixMillisToTimestamp', arguments);
2291
+ }
2292
+
2293
+ export function unixSecondsToTimestamp(_expr: Expression): FunctionExpression;
2294
+ export function unixSecondsToTimestamp(_fieldName: string): FunctionExpression;
2295
+ export function unixSecondsToTimestamp(_exprOrField: Expression | string): FunctionExpression {
2296
+ return callFunctionHelper('unixSecondsToTimestamp', arguments);
2297
+ }
2298
+
2299
+ export function vectorLength(_vectorExpression: Expression): FunctionExpression;
2300
+ export function vectorLength(_fieldName: string): FunctionExpression;
2301
+ export function vectorLength(_exprOrField: Expression | string): FunctionExpression {
2302
+ return callFunctionHelper('vectorLength', arguments);
2303
+ }
2304
+
2305
+ export function xor(
2306
+ _first: BooleanExpression,
2307
+ _second: BooleanExpression,
2308
+ ..._additionalConditions: BooleanExpression[]
2309
+ ): BooleanExpression {
2310
+ return callBooleanHelper('xor', arguments);
2311
+ }
2312
+
2313
+ /**
2314
+ * @beta
2315
+ * Length of string, array, map, vector, or bytes (field or expression).
2316
+ */
2317
+ export function length(_fieldName: string): FunctionExpression;
2318
+ export function length(_expression: Expression): FunctionExpression;
2319
+ export function length(_fieldOrExpr: string | Expression): FunctionExpression {
2320
+ return callFunctionHelper('length', arguments);
2321
+ }