react-query-firebase 2.13.3 → 2.13.4

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 (377) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +4 -0
  3. package/dist/react-native/analytics/index.d.ts +3 -0
  4. package/dist/react-native/analytics/index.js +3 -0
  5. package/{react-native/analytics/useAnalytics.ts → dist/react-native/analytics/useAnalytics.js} +1 -3
  6. package/{react-native → dist/react-native}/analytics/useLogEvent.js +1 -1
  7. package/{react-native → dist/react-native}/analytics/useSetAnalyticsCollectionEnabled.js +1 -1
  8. package/dist/react-native/auth/index.d.ts +19 -0
  9. package/dist/react-native/auth/index.js +19 -0
  10. package/{react-native/auth/useAuth.ts → dist/react-native/auth/useAuth.js} +1 -3
  11. package/{react-native → dist/react-native}/auth/useAuthStateReady.js +1 -1
  12. package/{react-native → dist/react-native}/auth/useCreateUserWitEmailAndPasswordMutation.js +2 -2
  13. package/{react-native → dist/react-native}/auth/useCurrentUser.js +1 -1
  14. package/{react-native → dist/react-native}/auth/useIdToken.js +2 -2
  15. package/{react-native → dist/react-native}/auth/useLinkWithCredentialMutation.js +1 -1
  16. package/{react-native → dist/react-native}/auth/useReauthenticateWitCredentialMutation.js +1 -1
  17. package/{react-native → dist/react-native}/auth/useReauthenticateWitRedirectMutation.js +1 -1
  18. package/{react-native → dist/react-native}/auth/useSendEmailVerificationMutation.js +1 -1
  19. package/{react-native → dist/react-native}/auth/useSignInAnonymouslyMutation.js +2 -2
  20. package/{react-native → dist/react-native}/auth/useSignInWitEmailAndPasswordMutation.js +2 -2
  21. package/{react-native → dist/react-native}/auth/useSignInWitRedirectMutation.js +2 -2
  22. package/{react-native → dist/react-native}/auth/useSignInWithCredentialMutation.js +2 -2
  23. package/{react-native → dist/react-native}/auth/useSignOutMutation.js +2 -2
  24. package/{react-native → dist/react-native}/auth/useUpdateProfileMutation.js +1 -1
  25. package/{react-native → dist/react-native}/context/FirebaseContextProvider.js +1 -1
  26. package/dist/react-native/context/index.d.ts +1 -0
  27. package/dist/react-native/context/index.js +1 -0
  28. package/dist/react-native/firestore/index.d.ts +23 -0
  29. package/dist/react-native/firestore/index.js +23 -0
  30. package/{react-native → dist/react-native}/firestore/useAddDocMutation.d.ts +1 -1
  31. package/{react-native → dist/react-native}/firestore/useBatchWrite.js +1 -1
  32. package/{react-native → dist/react-native}/firestore/useCollectionReference.d.ts +1 -1
  33. package/{react-native → dist/react-native}/firestore/useCollectionReference.js +1 -1
  34. package/{react-native → dist/react-native}/firestore/useCompositeFilter.d.ts +2 -2
  35. package/{react-native → dist/react-native}/firestore/useCompositeFilter.js +1 -1
  36. package/{react-native → dist/react-native}/firestore/useCountQuery.d.ts +2 -2
  37. package/{react-native → dist/react-native}/firestore/useDeleteDocMutation.d.ts +1 -1
  38. package/{react-native → dist/react-native}/firestore/useDocReference.d.ts +2 -2
  39. package/{react-native → dist/react-native}/firestore/useDocReference.js +2 -2
  40. package/{react-native → dist/react-native}/firestore/useDocReferences.d.ts +2 -2
  41. package/{react-native → dist/react-native}/firestore/useDocReferences.js +2 -2
  42. package/{web → dist/react-native}/firestore/useEnsureDoc.d.ts +2 -2
  43. package/{react-native → dist/react-native}/firestore/useEnsureDoc.js +3 -3
  44. package/{react-native/firestore/useFirestore.ts → dist/react-native/firestore/useFirestore.js} +1 -2
  45. package/{react-native → dist/react-native}/firestore/useGetDocData.d.ts +2 -2
  46. package/{web → dist/react-native}/firestore/useGetDocData.js +2 -2
  47. package/{react-native → dist/react-native}/firestore/useGetRealtimeDocData.d.ts +1 -1
  48. package/{react-native → dist/react-native}/firestore/useGetRealtimeDocData.js +1 -1
  49. package/{react-native → dist/react-native}/firestore/useInfiniteQuery.d.ts +2 -2
  50. package/{react-native → dist/react-native}/firestore/useQuery.d.ts +2 -2
  51. package/{react-native → dist/react-native}/firestore/useQueryConstraints.d.ts +2 -2
  52. package/{react-native → dist/react-native}/firestore/useQueryConstraints.js +1 -1
  53. package/{react-native → dist/react-native}/firestore/useRunTransaction.js +1 -1
  54. package/{react-native → dist/react-native}/firestore/useSetDocMutation.d.ts +1 -1
  55. package/{react-native → dist/react-native}/firestore/useUpdateDocMutation.d.ts +1 -1
  56. package/{react-native → dist/react-native}/firestore/utils/buildCompositeFilter.d.ts +1 -1
  57. package/{react-native → dist/react-native}/firestore/utils/buildQueryConstraint.d.ts +1 -1
  58. package/{react-native → dist/react-native}/firestore/utils/getDocData.d.ts +2 -2
  59. package/{react-native → dist/react-native}/firestore/utils/getDocData.js +1 -1
  60. package/{react-native → dist/react-native}/firestore/utils/getDocRef.d.ts +1 -1
  61. package/{react-native → dist/react-native}/firestore/utils/getDocSnap.d.ts +2 -2
  62. package/{react-native → dist/react-native}/firestore/utils/getDocSnap.js +1 -1
  63. package/dist/react-native/index.d.ts +1 -0
  64. package/dist/react-native/index.js +1 -0
  65. package/dist/react-native/remoteConfig/index.d.ts +3 -0
  66. package/dist/react-native/remoteConfig/index.js +3 -0
  67. package/{react-native → dist/react-native}/remoteConfig/useFetchAndActivate.js +1 -1
  68. package/{react-native → dist/react-native}/remoteConfig/useGetValue.js +1 -1
  69. package/{react-native/remoteConfig/useRemoteConfig.ts → dist/react-native/remoteConfig/useRemoteConfig.js} +1 -2
  70. package/{types → dist/types}/QueryConstraints.d.ts +1 -1
  71. package/dist/types/index.d.ts +2 -0
  72. package/dist/types/index.js +2 -0
  73. package/dist/web/analytics/index.d.ts +3 -0
  74. package/dist/web/analytics/index.js +3 -0
  75. package/{web/analytics/useAnalytics.ts → dist/web/analytics/useAnalytics.js} +1 -3
  76. package/{web → dist/web}/analytics/useLogEvent.js +1 -1
  77. package/{web → dist/web}/analytics/useSetAnalyticsCollectionEnabled.js +1 -1
  78. package/dist/web/auth/index.d.ts +20 -0
  79. package/dist/web/auth/index.js +20 -0
  80. package/{web/auth/useAuth.ts → dist/web/auth/useAuth.js} +1 -3
  81. package/{web → dist/web}/auth/useAuthStateReady.js +1 -1
  82. package/{web → dist/web}/auth/useCreateUserWitEmailAndPasswordMutation.js +2 -2
  83. package/{web → dist/web}/auth/useCurrentUser.js +1 -1
  84. package/{web → dist/web}/auth/useGetRedirectResultMutation.js +2 -2
  85. package/{web → dist/web}/auth/useIdToken.js +2 -2
  86. package/{web → dist/web}/auth/useLinkWithCredentialMutation.js +1 -1
  87. package/{web → dist/web}/auth/useReauthenticateWitCredentialMutation.js +1 -1
  88. package/{web → dist/web}/auth/useReauthenticateWitRedirectMutation.js +1 -1
  89. package/{web → dist/web}/auth/useSendEmailVerificationMutation.js +1 -1
  90. package/{web → dist/web}/auth/useSignInAnonymouslyMutation.js +2 -2
  91. package/{web → dist/web}/auth/useSignInWitEmailAndPasswordMutation.js +2 -2
  92. package/{web → dist/web}/auth/useSignInWitRedirectMutation.js +2 -2
  93. package/{web → dist/web}/auth/useSignInWithCredentialMutation.js +2 -2
  94. package/{web → dist/web}/auth/useSignOutMutation.js +2 -2
  95. package/{web → dist/web}/auth/useUpdateProfileMutation.js +1 -1
  96. package/{web → dist/web}/context/FirebaseContextProvider.js +1 -1
  97. package/dist/web/context/index.d.ts +1 -0
  98. package/dist/web/context/index.js +1 -0
  99. package/dist/web/firestore/index.d.ts +23 -0
  100. package/dist/web/firestore/index.js +23 -0
  101. package/{web → dist/web}/firestore/useAddDocMutation.d.ts +1 -1
  102. package/{web → dist/web}/firestore/useBatchWrite.js +1 -1
  103. package/{web → dist/web}/firestore/useCollectionReference.d.ts +1 -1
  104. package/{web → dist/web}/firestore/useCollectionReference.js +1 -1
  105. package/{web → dist/web}/firestore/useCompositeFilter.d.ts +2 -2
  106. package/{web → dist/web}/firestore/useCompositeFilter.js +1 -1
  107. package/{web → dist/web}/firestore/useCountQuery.d.ts +2 -2
  108. package/{web → dist/web}/firestore/useDeleteDocMutation.d.ts +1 -1
  109. package/{web → dist/web}/firestore/useDocReference.d.ts +2 -2
  110. package/{web → dist/web}/firestore/useDocReference.js +2 -2
  111. package/{web → dist/web}/firestore/useDocReferences.d.ts +2 -2
  112. package/{web → dist/web}/firestore/useDocReferences.js +2 -2
  113. package/{react-native → dist/web}/firestore/useEnsureDoc.d.ts +2 -2
  114. package/{web → dist/web}/firestore/useEnsureDoc.js +3 -3
  115. package/{web/firestore/useFirestore.ts → dist/web/firestore/useFirestore.js} +1 -2
  116. package/{web → dist/web}/firestore/useGetDocData.d.ts +2 -2
  117. package/{react-native → dist/web}/firestore/useGetDocData.js +2 -2
  118. package/{web → dist/web}/firestore/useGetRealtimeDocData.d.ts +1 -1
  119. package/{web → dist/web}/firestore/useGetRealtimeDocData.js +1 -1
  120. package/{web → dist/web}/firestore/useInfiniteQuery.d.ts +2 -2
  121. package/{web → dist/web}/firestore/useQuery.d.ts +2 -2
  122. package/{web → dist/web}/firestore/useQueryConstraints.d.ts +2 -2
  123. package/{web → dist/web}/firestore/useQueryConstraints.js +1 -1
  124. package/{web → dist/web}/firestore/useRunTransaction.js +1 -1
  125. package/{web → dist/web}/firestore/useSetDocMutation.d.ts +1 -1
  126. package/{web → dist/web}/firestore/useUpdateDocMutation.d.ts +1 -1
  127. package/{web → dist/web}/firestore/utils/buildCompositeFilter.d.ts +1 -1
  128. package/{web → dist/web}/firestore/utils/buildQueryConstraint.d.ts +1 -1
  129. package/{web → dist/web}/firestore/utils/getDocData.d.ts +2 -2
  130. package/{web → dist/web}/firestore/utils/getDocData.js +1 -1
  131. package/{web → dist/web}/firestore/utils/getDocRef.d.ts +1 -1
  132. package/{web → dist/web}/firestore/utils/getDocSnap.d.ts +2 -2
  133. package/{web → dist/web}/firestore/utils/getDocSnap.js +1 -1
  134. package/dist/web/index.d.ts +1 -0
  135. package/dist/web/index.js +1 -0
  136. package/dist/web/remoteConfig/index.d.ts +3 -0
  137. package/dist/web/remoteConfig/index.js +3 -0
  138. package/{web → dist/web}/remoteConfig/useFetchAndActivate.js +1 -1
  139. package/{web → dist/web}/remoteConfig/useGetValue.js +1 -1
  140. package/{web/remoteConfig/useRemoteConfig.ts → dist/web/remoteConfig/useRemoteConfig.js} +1 -2
  141. package/package.json +37 -17
  142. package/react-native/analytics/index.d.ts +0 -3
  143. package/react-native/analytics/index.js +0 -3
  144. package/react-native/analytics/index.ts +0 -3
  145. package/react-native/analytics/useAnalytics.js +0 -10
  146. package/react-native/analytics/useLogEvent.ts +0 -34
  147. package/react-native/analytics/useSetAnalyticsCollectionEnabled.ts +0 -22
  148. package/react-native/auth/index.d.ts +0 -19
  149. package/react-native/auth/index.js +0 -19
  150. package/react-native/auth/index.ts +0 -19
  151. package/react-native/auth/mutation-keys.ts +0 -22
  152. package/react-native/auth/useAppleAuthProviderCredential.ts +0 -31
  153. package/react-native/auth/useAuth.js +0 -10
  154. package/react-native/auth/useAuthStateReady.ts +0 -39
  155. package/react-native/auth/useCreateUserWitEmailAndPasswordMutation.ts +0 -38
  156. package/react-native/auth/useCurrentUser.ts +0 -26
  157. package/react-native/auth/useEmailAuthProviderCredential.ts +0 -38
  158. package/react-native/auth/useFacebookAuthProviderCredential.ts +0 -31
  159. package/react-native/auth/useIdToken.ts +0 -83
  160. package/react-native/auth/useLinkWithCredentialMutation.ts +0 -35
  161. package/react-native/auth/useReauthenticateWitCredentialMutation.ts +0 -36
  162. package/react-native/auth/useReauthenticateWitRedirectMutation.ts +0 -42
  163. package/react-native/auth/useSendEmailVerificationMutation.ts +0 -33
  164. package/react-native/auth/useSignInAnonymouslyMutation.ts +0 -52
  165. package/react-native/auth/useSignInWitEmailAndPasswordMutation.ts +0 -39
  166. package/react-native/auth/useSignInWitRedirectMutation.ts +0 -38
  167. package/react-native/auth/useSignInWithCredentialMutation.ts +0 -36
  168. package/react-native/auth/useSignOutMutation.ts +0 -28
  169. package/react-native/auth/useUpdateProfileMutation.ts +0 -30
  170. package/react-native/context/FirebaseContext.ts +0 -25
  171. package/react-native/context/FirebaseContextProvider.tsx +0 -264
  172. package/react-native/context/index.d.ts +0 -1
  173. package/react-native/context/index.js +0 -1
  174. package/react-native/context/index.ts +0 -1
  175. package/react-native/firestore/index.d.ts +0 -23
  176. package/react-native/firestore/index.js +0 -23
  177. package/react-native/firestore/index.ts +0 -23
  178. package/react-native/firestore/useAddDocMutation.ts +0 -80
  179. package/react-native/firestore/useBatchWrite.ts +0 -58
  180. package/react-native/firestore/useCollectionReference.ts +0 -58
  181. package/react-native/firestore/useCompositeFilter.ts +0 -60
  182. package/react-native/firestore/useCountQuery.ts +0 -85
  183. package/react-native/firestore/useDeleteDocMutation.ts +0 -71
  184. package/react-native/firestore/useDocReference.ts +0 -42
  185. package/react-native/firestore/useDocReferences.ts +0 -40
  186. package/react-native/firestore/useEnsureDoc.ts +0 -79
  187. package/react-native/firestore/useFirestore.js +0 -13
  188. package/react-native/firestore/useGetDocData.ts +0 -52
  189. package/react-native/firestore/useGetRealtimeDocData.ts +0 -106
  190. package/react-native/firestore/useInfiniteQuery.ts +0 -115
  191. package/react-native/firestore/useQuery.ts +0 -89
  192. package/react-native/firestore/useQueryConstraints.ts +0 -44
  193. package/react-native/firestore/useRunTransaction.ts +0 -55
  194. package/react-native/firestore/useSetDocMutation.ts +0 -76
  195. package/react-native/firestore/useUpdateDocMutation.ts +0 -77
  196. package/react-native/firestore/utils/buildCompositeFilter.ts +0 -75
  197. package/react-native/firestore/utils/buildQueryConstraint.ts +0 -54
  198. package/react-native/firestore/utils/getDocData.ts +0 -33
  199. package/react-native/firestore/utils/getDocRef.ts +0 -41
  200. package/react-native/firestore/utils/getDocSnap.ts +0 -34
  201. package/react-native/index.d.ts +0 -1
  202. package/react-native/index.js +0 -1
  203. package/react-native/index.ts +0 -1
  204. package/react-native/remoteConfig/index.d.ts +0 -3
  205. package/react-native/remoteConfig/index.js +0 -3
  206. package/react-native/remoteConfig/index.ts +0 -3
  207. package/react-native/remoteConfig/useFetchAndActivate.ts +0 -36
  208. package/react-native/remoteConfig/useGetValue.ts +0 -16
  209. package/react-native/remoteConfig/useRemoteConfig.js +0 -10
  210. package/types/AppModel.ts +0 -10
  211. package/types/QueryConstraints.ts +0 -57
  212. package/types/index.d.ts +0 -2
  213. package/types/index.js +0 -2
  214. package/types/index.ts +0 -2
  215. package/web/analytics/index.d.ts +0 -3
  216. package/web/analytics/index.js +0 -3
  217. package/web/analytics/index.ts +0 -3
  218. package/web/analytics/useAnalytics.js +0 -10
  219. package/web/analytics/useLogEvent.ts +0 -34
  220. package/web/analytics/useSetAnalyticsCollectionEnabled.ts +0 -22
  221. package/web/auth/index.d.ts +0 -20
  222. package/web/auth/index.js +0 -20
  223. package/web/auth/index.ts +0 -20
  224. package/web/auth/mutation-keys.ts +0 -23
  225. package/web/auth/useAppleAuthProviderCredential.ts +0 -32
  226. package/web/auth/useAuth.js +0 -10
  227. package/web/auth/useAuthStateReady.ts +0 -30
  228. package/web/auth/useCreateUserWitEmailAndPasswordMutation.ts +0 -33
  229. package/web/auth/useCurrentUser.ts +0 -25
  230. package/web/auth/useEmailAuthProviderCredential.ts +0 -38
  231. package/web/auth/useFacebookAuthProviderCredential.ts +0 -31
  232. package/web/auth/useGetRedirectResultMutation.ts +0 -27
  233. package/web/auth/useIdToken.ts +0 -83
  234. package/web/auth/useLinkWithCredentialMutation.ts +0 -30
  235. package/web/auth/useReauthenticateWitCredentialMutation.ts +0 -31
  236. package/web/auth/useReauthenticateWitRedirectMutation.ts +0 -37
  237. package/web/auth/useSendEmailVerificationMutation.ts +0 -28
  238. package/web/auth/useSignInAnonymouslyMutation.ts +0 -49
  239. package/web/auth/useSignInWitEmailAndPasswordMutation.ts +0 -34
  240. package/web/auth/useSignInWitRedirectMutation.ts +0 -33
  241. package/web/auth/useSignInWithCredentialMutation.ts +0 -31
  242. package/web/auth/useSignOutMutation.ts +0 -25
  243. package/web/auth/useUpdateProfileMutation.ts +0 -30
  244. package/web/context/FirebaseContext.ts +0 -25
  245. package/web/context/FirebaseContextProvider.tsx +0 -263
  246. package/web/context/index.d.ts +0 -1
  247. package/web/context/index.js +0 -1
  248. package/web/context/index.ts +0 -1
  249. package/web/firestore/index.d.ts +0 -23
  250. package/web/firestore/index.js +0 -23
  251. package/web/firestore/index.ts +0 -23
  252. package/web/firestore/useAddDocMutation.ts +0 -74
  253. package/web/firestore/useBatchWrite.ts +0 -58
  254. package/web/firestore/useCollectionReference.ts +0 -58
  255. package/web/firestore/useCompositeFilter.ts +0 -55
  256. package/web/firestore/useCountQuery.ts +0 -90
  257. package/web/firestore/useDeleteDocMutation.ts +0 -69
  258. package/web/firestore/useDocReference.ts +0 -43
  259. package/web/firestore/useDocReferences.ts +0 -40
  260. package/web/firestore/useEnsureDoc.ts +0 -92
  261. package/web/firestore/useFirestore.js +0 -13
  262. package/web/firestore/useGetDocData.ts +0 -52
  263. package/web/firestore/useGetRealtimeDocData.ts +0 -105
  264. package/web/firestore/useInfiniteQuery.ts +0 -117
  265. package/web/firestore/useQuery.ts +0 -94
  266. package/web/firestore/useQueryConstraints.ts +0 -44
  267. package/web/firestore/useRunTransaction.ts +0 -56
  268. package/web/firestore/useSetDocMutation.ts +0 -77
  269. package/web/firestore/useUpdateDocMutation.ts +0 -78
  270. package/web/firestore/utils/buildCompositeFilter.ts +0 -73
  271. package/web/firestore/utils/buildQueryConstraint.ts +0 -55
  272. package/web/firestore/utils/getDocData.ts +0 -33
  273. package/web/firestore/utils/getDocRef.ts +0 -43
  274. package/web/firestore/utils/getDocSnap.ts +0 -34
  275. package/web/index.d.ts +0 -1
  276. package/web/index.js +0 -1
  277. package/web/index.ts +0 -1
  278. package/web/remoteConfig/index.d.ts +0 -3
  279. package/web/remoteConfig/index.js +0 -3
  280. package/web/remoteConfig/index.ts +0 -3
  281. package/web/remoteConfig/useFetchAndActivate.ts +0 -36
  282. package/web/remoteConfig/useGetValue.ts +0 -16
  283. package/web/remoteConfig/useRemoteConfig.js +0 -10
  284. /package/{react-native → dist/react-native}/analytics/useAnalytics.d.ts +0 -0
  285. /package/{react-native → dist/react-native}/analytics/useLogEvent.d.ts +0 -0
  286. /package/{react-native → dist/react-native}/analytics/useSetAnalyticsCollectionEnabled.d.ts +0 -0
  287. /package/{react-native → dist/react-native}/auth/mutation-keys.d.ts +0 -0
  288. /package/{react-native → dist/react-native}/auth/mutation-keys.js +0 -0
  289. /package/{react-native → dist/react-native}/auth/useAppleAuthProviderCredential.d.ts +0 -0
  290. /package/{react-native → dist/react-native}/auth/useAppleAuthProviderCredential.js +0 -0
  291. /package/{react-native → dist/react-native}/auth/useAuth.d.ts +0 -0
  292. /package/{react-native → dist/react-native}/auth/useAuthStateReady.d.ts +0 -0
  293. /package/{react-native → dist/react-native}/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +0 -0
  294. /package/{react-native → dist/react-native}/auth/useCurrentUser.d.ts +0 -0
  295. /package/{react-native → dist/react-native}/auth/useEmailAuthProviderCredential.d.ts +0 -0
  296. /package/{react-native → dist/react-native}/auth/useEmailAuthProviderCredential.js +0 -0
  297. /package/{react-native → dist/react-native}/auth/useFacebookAuthProviderCredential.d.ts +0 -0
  298. /package/{react-native → dist/react-native}/auth/useFacebookAuthProviderCredential.js +0 -0
  299. /package/{react-native → dist/react-native}/auth/useIdToken.d.ts +0 -0
  300. /package/{react-native → dist/react-native}/auth/useLinkWithCredentialMutation.d.ts +0 -0
  301. /package/{react-native → dist/react-native}/auth/useReauthenticateWitCredentialMutation.d.ts +0 -0
  302. /package/{react-native → dist/react-native}/auth/useReauthenticateWitRedirectMutation.d.ts +0 -0
  303. /package/{react-native → dist/react-native}/auth/useSendEmailVerificationMutation.d.ts +0 -0
  304. /package/{react-native → dist/react-native}/auth/useSignInAnonymouslyMutation.d.ts +0 -0
  305. /package/{react-native → dist/react-native}/auth/useSignInWitEmailAndPasswordMutation.d.ts +0 -0
  306. /package/{react-native → dist/react-native}/auth/useSignInWitRedirectMutation.d.ts +0 -0
  307. /package/{react-native → dist/react-native}/auth/useSignInWithCredentialMutation.d.ts +0 -0
  308. /package/{react-native → dist/react-native}/auth/useSignOutMutation.d.ts +0 -0
  309. /package/{react-native → dist/react-native}/auth/useUpdateProfileMutation.d.ts +0 -0
  310. /package/{react-native → dist/react-native}/context/FirebaseContext.d.ts +0 -0
  311. /package/{react-native → dist/react-native}/context/FirebaseContext.js +0 -0
  312. /package/{react-native → dist/react-native}/context/FirebaseContextProvider.d.ts +0 -0
  313. /package/{react-native → dist/react-native}/firestore/useAddDocMutation.js +0 -0
  314. /package/{react-native → dist/react-native}/firestore/useBatchWrite.d.ts +0 -0
  315. /package/{react-native → dist/react-native}/firestore/useCountQuery.js +0 -0
  316. /package/{react-native → dist/react-native}/firestore/useDeleteDocMutation.js +0 -0
  317. /package/{react-native → dist/react-native}/firestore/useFirestore.d.ts +0 -0
  318. /package/{react-native → dist/react-native}/firestore/useInfiniteQuery.js +0 -0
  319. /package/{react-native → dist/react-native}/firestore/useQuery.js +0 -0
  320. /package/{react-native → dist/react-native}/firestore/useRunTransaction.d.ts +0 -0
  321. /package/{react-native → dist/react-native}/firestore/useSetDocMutation.js +0 -0
  322. /package/{react-native → dist/react-native}/firestore/useUpdateDocMutation.js +0 -0
  323. /package/{react-native → dist/react-native}/firestore/utils/buildCompositeFilter.js +0 -0
  324. /package/{react-native → dist/react-native}/firestore/utils/buildQueryConstraint.js +0 -0
  325. /package/{react-native → dist/react-native}/firestore/utils/getDocRef.js +0 -0
  326. /package/{react-native → dist/react-native}/remoteConfig/useFetchAndActivate.d.ts +0 -0
  327. /package/{react-native → dist/react-native}/remoteConfig/useGetValue.d.ts +0 -0
  328. /package/{react-native → dist/react-native}/remoteConfig/useRemoteConfig.d.ts +0 -0
  329. /package/{types → dist/types}/AppModel.d.ts +0 -0
  330. /package/{types → dist/types}/AppModel.js +0 -0
  331. /package/{types → dist/types}/QueryConstraints.js +0 -0
  332. /package/{web → dist/web}/analytics/useAnalytics.d.ts +0 -0
  333. /package/{web → dist/web}/analytics/useLogEvent.d.ts +0 -0
  334. /package/{web → dist/web}/analytics/useSetAnalyticsCollectionEnabled.d.ts +0 -0
  335. /package/{web → dist/web}/auth/mutation-keys.d.ts +0 -0
  336. /package/{web → dist/web}/auth/mutation-keys.js +0 -0
  337. /package/{web → dist/web}/auth/useAppleAuthProviderCredential.d.ts +0 -0
  338. /package/{web → dist/web}/auth/useAppleAuthProviderCredential.js +0 -0
  339. /package/{web → dist/web}/auth/useAuth.d.ts +0 -0
  340. /package/{web → dist/web}/auth/useAuthStateReady.d.ts +0 -0
  341. /package/{web → dist/web}/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +0 -0
  342. /package/{web → dist/web}/auth/useCurrentUser.d.ts +0 -0
  343. /package/{web → dist/web}/auth/useEmailAuthProviderCredential.d.ts +0 -0
  344. /package/{web → dist/web}/auth/useEmailAuthProviderCredential.js +0 -0
  345. /package/{web → dist/web}/auth/useFacebookAuthProviderCredential.d.ts +0 -0
  346. /package/{web → dist/web}/auth/useFacebookAuthProviderCredential.js +0 -0
  347. /package/{web → dist/web}/auth/useGetRedirectResultMutation.d.ts +0 -0
  348. /package/{web → dist/web}/auth/useIdToken.d.ts +0 -0
  349. /package/{web → dist/web}/auth/useLinkWithCredentialMutation.d.ts +0 -0
  350. /package/{web → dist/web}/auth/useReauthenticateWitCredentialMutation.d.ts +0 -0
  351. /package/{web → dist/web}/auth/useReauthenticateWitRedirectMutation.d.ts +0 -0
  352. /package/{web → dist/web}/auth/useSendEmailVerificationMutation.d.ts +0 -0
  353. /package/{web → dist/web}/auth/useSignInAnonymouslyMutation.d.ts +0 -0
  354. /package/{web → dist/web}/auth/useSignInWitEmailAndPasswordMutation.d.ts +0 -0
  355. /package/{web → dist/web}/auth/useSignInWitRedirectMutation.d.ts +0 -0
  356. /package/{web → dist/web}/auth/useSignInWithCredentialMutation.d.ts +0 -0
  357. /package/{web → dist/web}/auth/useSignOutMutation.d.ts +0 -0
  358. /package/{web → dist/web}/auth/useUpdateProfileMutation.d.ts +0 -0
  359. /package/{web → dist/web}/context/FirebaseContext.d.ts +0 -0
  360. /package/{web → dist/web}/context/FirebaseContext.js +0 -0
  361. /package/{web → dist/web}/context/FirebaseContextProvider.d.ts +0 -0
  362. /package/{web → dist/web}/firestore/useAddDocMutation.js +0 -0
  363. /package/{web → dist/web}/firestore/useBatchWrite.d.ts +0 -0
  364. /package/{web → dist/web}/firestore/useCountQuery.js +0 -0
  365. /package/{web → dist/web}/firestore/useDeleteDocMutation.js +0 -0
  366. /package/{web → dist/web}/firestore/useFirestore.d.ts +0 -0
  367. /package/{web → dist/web}/firestore/useInfiniteQuery.js +0 -0
  368. /package/{web → dist/web}/firestore/useQuery.js +0 -0
  369. /package/{web → dist/web}/firestore/useRunTransaction.d.ts +0 -0
  370. /package/{web → dist/web}/firestore/useSetDocMutation.js +0 -0
  371. /package/{web → dist/web}/firestore/useUpdateDocMutation.js +0 -0
  372. /package/{web → dist/web}/firestore/utils/buildCompositeFilter.js +0 -0
  373. /package/{web → dist/web}/firestore/utils/buildQueryConstraint.js +0 -0
  374. /package/{web → dist/web}/firestore/utils/getDocRef.js +0 -0
  375. /package/{web → dist/web}/remoteConfig/useFetchAndActivate.d.ts +0 -0
  376. /package/{web → dist/web}/remoteConfig/useGetValue.d.ts +0 -0
  377. /package/{web → dist/web}/remoteConfig/useRemoteConfig.d.ts +0 -0
@@ -1,71 +0,0 @@
1
- import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
- import { FirebaseFirestoreTypes, deleteDoc, WithFieldValue } from "@react-native-firebase/firestore";
3
-
4
- import { useMemo } from "react";
5
- import { AppModel } from "../../types";
6
-
7
- /**
8
- * @inline
9
- */
10
- export type UseDeleteDocMutationValues<AppModelType extends AppModel = AppModel> = {
11
- data: WithFieldValue<AppModelType>;
12
- };
13
-
14
- /**
15
- * @inline
16
- */
17
- export type UseDeleteDocMutationOptions<AppModelType extends AppModel = AppModel, TContext = unknown> = {
18
- /**
19
- * A reference to a firestore document
20
- */
21
- reference: FirebaseFirestoreTypes.DocumentReference<AppModelType> | null;
22
- /**
23
- * Options for useMutation hook excluding mutationFn. MutationKey will be equal to reference.path by default.
24
- */
25
- options?: Omit<UseMutationOptions<void, Error, void, TContext>, "mutationFn">;
26
- };
27
-
28
- /**
29
- * Executes a query with specified constraints and returns the count of matched documents.
30
- *
31
- * @group Hook
32
- *
33
- * @param {UseDeleteDocMutationOptions<AppModelType>} options - Configuration options for the query.
34
- *
35
- * @returns {UseMutationResult<void, Error, UseDeleteDocMutationValues<AppModelType>, TContext>} A mutation result
36
- *
37
- * @example
38
- * ```jsx
39
- * export const MyComponent = () => {
40
- * const {mutate} = useDeleteDocMutation({
41
- * options: {
42
- * },
43
- * reference: document(),
44
- * });
45
- *
46
- * // ....
47
- * mutate();
48
- * // ....
49
- * };
50
- * ```
51
- */
52
- export const useDeleteDocMutation = <
53
- AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData,
54
- TContext = unknown
55
- >({
56
- reference,
57
- options = {}
58
- }: UseDeleteDocMutationOptions<AppModelType, TContext>) => {
59
- const mutationKey = useMemo(() => [reference?.path], [reference?.path]);
60
-
61
- return useMutation({
62
- ...options,
63
- mutationFn: async () => {
64
- if (!reference) {
65
- throw new Error("Reference is undefined");
66
- }
67
- await deleteDoc(reference);
68
- },
69
- mutationKey
70
- });
71
- };
@@ -1,42 +0,0 @@
1
- import { useMemo } from "react";
2
- import { AppModel } from "../../types";
3
- import { useFirestore } from "./useFirestore";
4
- import { getDocRef, GetDocRefOptions } from "./utils/getDocRef";
5
-
6
- /**
7
- * @inline
8
- */
9
- export type UseDocReferenceOptions<AppModelType extends AppModel = AppModel> = Omit<
10
- GetDocRefOptions<AppModelType>,
11
- "db"
12
- >;
13
-
14
- /**
15
- * Gets a `CollectionReference` instance.
16
- *
17
- * @group Hook
18
- *
19
- * @param {UseDocReferenceOptions<AppModelType>} options - Options
20
- *
21
- * @returns {FirebaseFirestoreTypes.DocumentReference<AppModelType, AppModelType> | null} A reference to a Firestore document
22
- *
23
- * @example
24
- * ```jsx
25
- * export const MyComponent = () => {
26
- * const ref = useDocReference({
27
- * reference: collection('todos')
28
- * path: 'first'
29
- * });
30
- * };
31
- * ```
32
- */
33
- export const useDocReference = <AppModelType extends AppModel = AppModel>({
34
- path,
35
- reference,
36
- pathSegments
37
- }: UseDocReferenceOptions<AppModelType>) => {
38
- const db = useFirestore();
39
- return useMemo(() => {
40
- return getDocRef({ db, path, pathSegments, reference });
41
- }, [db, path, pathSegments, reference]);
42
- };
@@ -1,40 +0,0 @@
1
- import { useMemo } from "react";
2
- import { AppModel } from "../../types";
3
- import { useFirestore } from "./useFirestore";
4
- import { getDocRef, GetDocRefOptions } from "./utils/getDocRef";
5
-
6
- /**
7
- * @inline
8
- */
9
- export type UseDocReferencesOptions<AppModelType extends AppModel = AppModel> = {
10
- references: Omit<GetDocRefOptions<AppModelType>, "db">[];
11
- };
12
-
13
- /**
14
- * Gets `CollectionReference` instances
15
- *
16
- * @group Hook
17
- *
18
- * @param {UseDocReferencesOptions<AppModelType>} options - Options
19
- *
20
- * @returns {Array<FirebaseFirestoreTypes.DocumentReference<AppModelType> | null>} A reference to a Firestore document
21
- *
22
- * @example
23
- * ```jsx
24
- * export const MyComponent = () => {
25
- * const ref = useDocReference({
26
- * reference: collection('todos')
27
- * path: 'first'
28
- * });
29
- * };
30
- * ```
31
- */
32
- export const useDocReferences = <AppModelType extends AppModel = AppModel>({
33
- references
34
- }: UseDocReferencesOptions<AppModelType>) => {
35
- const db = useFirestore();
36
-
37
- return useMemo(() => {
38
- return references.map(({ path, reference, pathSegments }) => getDocRef({ db, reference, path, pathSegments }));
39
- }, [references, db]);
40
- };
@@ -1,79 +0,0 @@
1
- import { useQuery, UseQueryOptions } from "@tanstack/react-query";
2
- import { getDoc, setDoc } from "@react-native-firebase/firestore";
3
-
4
- import { AppModel } from "../../types";
5
- import { GetDocDataOptions } from "./utils/getDocData";
6
- import { getDocRef } from "./utils/getDocRef";
7
- import { getDocSnap } from "./utils/getDocSnap";
8
- import { useFirestore } from "./useFirestore";
9
-
10
- /**
11
- * @inline
12
- */
13
- export type UseEnsureDocOptions<AppModelType extends AppModel = AppModel> = {
14
- /**
15
- * Reference to a document that must be written
16
- */
17
- defaults: AppModelType;
18
-
19
- /**
20
- * Options for useMutation hook excluding mutationFn.
21
- */
22
- options: Omit<UseQueryOptions<AppModelType, Error, AppModelType>, "queryFn"> &
23
- Required<Pick<UseQueryOptions<AppModelType, Error, AppModelType>, "queryKey">>;
24
- } & Omit<GetDocDataOptions<AppModelType>, "db">;
25
-
26
- /**
27
- * This hook checks if a doc with a requested reference exists.
28
- * It creates a document with requested data if it does not exist.
29
- *
30
- * @group Hook
31
- *
32
- * @param {UseEnsureDocOptions<AppModelType>} options - Configuration options for mutation.
33
- *
34
- * @returns {UseQueryResult<AppModelType, Error>} A mutation result
35
- *
36
- * @example
37
- * ```jsx
38
- * export const MyComponent = () => {
39
- * const {data} = useEnsureDocQuery({
40
- * options: {
41
- * },
42
- * reference: collection().doc(),
43
- * defaults: {prop1: 'value1'}
44
- * });
45
- *
46
- * };
47
- * ```
48
- */
49
- export const useEnsureDoc = <AppModelType extends AppModel = AppModel>({
50
- reference,
51
- path,
52
- pathSegments,
53
- defaults,
54
- options
55
- }: UseEnsureDocOptions<AppModelType>) => {
56
- const db = useFirestore();
57
-
58
- return useQuery({
59
- ...options,
60
- queryFn: async () => {
61
- const existingDocSnap = await getDocSnap({ db, path, pathSegments, reference });
62
-
63
- if (existingDocSnap?.exists()) {
64
- return { ...(existingDocSnap.data() as AppModelType), uid: existingDocSnap.id };
65
- }
66
-
67
- const docRef = getDocRef({ db, reference, path, pathSegments });
68
- if (!docRef) {
69
- throw new Error(
70
- `Cannot fetch document reference using data: ${reference?.path}, ${path}, ${pathSegments?.join("/")}`
71
- );
72
- }
73
-
74
- await setDoc<AppModelType>(docRef, defaults);
75
- const docSnap = await getDoc(docRef);
76
- return { ...(docSnap.data() as AppModelType), uid: docSnap.id };
77
- }
78
- });
79
- };
@@ -1,13 +0,0 @@
1
- import { useContext } from "react";
2
- import { FirebaseContext } from "../context/FirebaseContext";
3
- /**
4
- * Returns an instance of firestore bound to the closest context.
5
- *
6
- * @group Hook
7
- *
8
- * @returns {Firestore}
9
- */
10
- export const useFirestore = () => {
11
- const { firestore } = useContext(FirebaseContext);
12
- return firestore;
13
- };
@@ -1,52 +0,0 @@
1
- import { useQuery, UseQueryOptions } from "@tanstack/react-query";
2
- import { AppModel } from "../../types";
3
- import { useFirestore } from "./useFirestore";
4
- import { getDocData, GetDocDataOptions } from "./utils/getDocData";
5
-
6
- /**
7
- * @inline
8
- */
9
- type UseGetDocOptions<AppModelType extends AppModel = AppModel> = {
10
- /**
11
- * Reqct-query options that must include queryKey and shall not define queryFn
12
- */
13
- options: Omit<UseQueryOptions<AppModelType | null, Error, AppModelType>, "queryFn"> &
14
- Required<Pick<UseQueryOptions<AppModelType, Error, AppModelType>, "queryKey">>;
15
- } & Omit<GetDocDataOptions<AppModelType>, "db">;
16
-
17
- /**
18
- * Executes a query on a Firestore data source and returns the resulting document.
19
- *
20
- * @group Hook
21
- *
22
- * @param {UseGetDocOptions<AppModelType>} options - Configuration options for the query.
23
- *
24
- * @returns {UseQueryResult<AppModelType, Error>} An object containing document's data
25
- *
26
- * @example
27
- * ```jsx
28
- * export const MyComponent = () => {
29
- * const doc = useGetDocData({
30
- * options: {
31
- * queryKey: ['key']
32
- * },
33
- * reference: collection(),
34
- * path: 'id'
35
- * });
36
- * console.log(doc);
37
- * };
38
- * ```
39
- */
40
- export const useGetDocData = <AppModelType extends AppModel = AppModel>({
41
- options,
42
- reference,
43
- path,
44
- pathSegments
45
- }: UseGetDocOptions<AppModelType>) => {
46
- const db = useFirestore();
47
-
48
- return useQuery({
49
- ...options,
50
- queryFn: () => getDocData<AppModelType>({ db, reference, path, pathSegments })
51
- });
52
- };
@@ -1,106 +0,0 @@
1
- import { FirebaseFirestoreTypes, onSnapshot } from "@react-native-firebase/firestore";
2
-
3
- import { useEffect, useMemo, useState } from "react";
4
- import { ReactNativeFirebase } from "@react-native-firebase/app";
5
- import { AppModel } from "../../types";
6
- import { useDocReference } from "./useDocReference";
7
-
8
- /**
9
- * @inline
10
- */
11
- export type UseGetRealtimeDocDataOptions<AppModelType extends AppModel = AppModel> = {
12
- /**
13
- * A slash-separated path to a document. Has to be omitted to use
14
- */
15
- path?: string;
16
- /**
17
- * A reference to a collection.
18
- */
19
- reference?: FirebaseFirestoreTypes.DocumentReference<AppModelType>;
20
- /**
21
- * Additional path segments that will be applied relative
22
- * to the first argument.
23
- */
24
- pathSegments?: string[];
25
- /**
26
- * A callback to be called if the listen fails or is
27
- * cancelled. No further callbacks will occur.
28
- */
29
- onError?: (error: ReactNativeFirebase.NativeFirebaseError | Error) => unknown;
30
- };
31
-
32
- /**
33
- * @inline
34
- */
35
- export type UseGetRealtimeDocDataResult<AppModelType> = {
36
- data: AppModelType | null;
37
- isError: boolean;
38
- error: ReactNativeFirebase.NativeFirebaseError | Error | null;
39
- isFetching: boolean;
40
- };
41
-
42
- /**
43
- * A hook to get realtime updates to a firestore document.
44
- *
45
- * @group Hook
46
- *
47
- * @param {UseGetRealtimeDocDataOptions<AppModelType, DbModelType>} options
48
- *
49
- * @returns {UseGetRealtimeDocDataResult<AppModelType>}
50
- *
51
- * @example
52
- * ```jsx
53
- * const firebaseConfig = {};
54
- * export const MyComponent = () => {
55
- * const result = useGetRealtimeDocData('collection/documentId');
56
- * return (
57
- * <div>
58
- * {JSON.stringify(result)}
59
- * </div>
60
- * );
61
- * };
62
- * ```
63
- */
64
- export const useGetRealtimeDocData = <AppModelType extends AppModel = AppModel>({
65
- path,
66
- pathSegments,
67
- reference,
68
- onError
69
- }: UseGetRealtimeDocDataOptions<AppModelType>): UseGetRealtimeDocDataResult<AppModelType> => {
70
- const ref = useDocReference({ path, reference, pathSegments });
71
- const [doc, setDoc] = useState<AppModelType | null>(null);
72
- const [isError, setIsError] = useState(false);
73
- const [isFetching, setIsFetching] = useState(true);
74
- const [error, setError] = useState<ReactNativeFirebase.NativeFirebaseError | Error | null>(null);
75
-
76
- useEffect(() => {
77
- const unsubscribe = ref
78
- ? onSnapshot<AppModelType>(ref, {
79
- next: async (snapshot) => {
80
- setIsFetching(false);
81
- setDoc({ ...snapshot.data(), uid: snapshot.id } as AppModelType);
82
- setError(null);
83
- setIsError(false);
84
- },
85
- error: (e) => {
86
- setIsError(true);
87
- setDoc(null);
88
- setError(e);
89
- onError?.(e);
90
- }
91
- })
92
- : () => {};
93
-
94
- return () => unsubscribe();
95
- }, [ref, doc, isError, onError, isFetching, error]);
96
-
97
- return useMemo(
98
- () => ({
99
- data: doc,
100
- isError,
101
- isFetching,
102
- error
103
- }),
104
- [doc, isError, error, isFetching]
105
- );
106
- };
@@ -1,115 +0,0 @@
1
- import {
2
- FirebaseFirestoreTypes,
3
- getDocs,
4
- query,
5
- QueryConstraint,
6
- QueryNonFilterConstraint
7
- } from "@react-native-firebase/firestore";
8
-
9
- import {
10
- useInfiniteQuery as useInfiniteReactQuery,
11
- UseInfiniteQueryOptions as UseReactInfiniteQueryOptions,
12
- QueryKey,
13
- UseInfiniteQueryResult,
14
- InfiniteData
15
- } from "@tanstack/react-query";
16
- import { AppModel } from "../../types";
17
- import { QueryFilterConstraint } from "./utils/buildCompositeFilter";
18
-
19
- /**
20
- * @inline
21
- */
22
- type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey extends QueryKey = QueryKey> = {
23
- /**
24
- * Reqct-query options that must include queryKey and shall not define queryFn
25
- */
26
- options: Omit<
27
- UseReactInfiniteQueryOptions<
28
- AppModelType[],
29
- Error,
30
- InfiniteData<AppModelType[]>,
31
- TQueryKey,
32
- QueryNonFilterConstraint
33
- >,
34
- "queryFn"
35
- > &
36
- Required<
37
- Pick<
38
- UseReactInfiniteQueryOptions<
39
- AppModelType[],
40
- Error,
41
- InfiniteData<AppModelType[]>,
42
- TQueryKey,
43
- QueryNonFilterConstraint
44
- >,
45
- "queryKey"
46
- >
47
- >;
48
-
49
- /**
50
- * Reference to a Firestore collection
51
- */
52
- collectionReference: FirebaseFirestoreTypes.CollectionReference<AppModelType>;
53
-
54
- /**
55
- * Non composite filter constraints such as limit, order, where
56
- */
57
- queryConstraints?: QueryConstraint[] | QueryNonFilterConstraint[];
58
-
59
- /**
60
- * Composite filter
61
- */
62
- compositeFilter?: QueryFilterConstraint;
63
- };
64
-
65
- /**
66
- * Executes an infinite query on a Firestore data source and returns the resulting documents as an array.
67
- *
68
- * @group Hook
69
- *
70
- * @param {UseInfiniteQueryOptions<AppModelType, TQueryKey>} options - Configuration options for the query.
71
- *
72
- * @returns {UseInfiniteQueryResult<InfiniteData<AppModelType[]>>} An object containing documents that match the query.
73
- *
74
- * @example
75
- * ```jsx
76
- * export const MyComponent = () => {
77
- * const docs = useInfiniteQuery({
78
- * options: {
79
- * queryKey: ['key']
80
- * },
81
- * collectionReference: collection(),
82
- * });
83
- * console.log(docs);
84
- * };
85
- * ```
86
- */
87
- export const useInfiniteQuery = <AppModelType extends AppModel = AppModel, TQueryKey extends QueryKey = QueryKey>({
88
- options,
89
- collectionReference,
90
- queryConstraints = [],
91
- compositeFilter
92
- }: UseInfiniteQueryOptions<AppModelType, TQueryKey>): UseInfiniteQueryResult<InfiniteData<AppModelType[]>> => {
93
- return useInfiniteReactQuery({
94
- ...options,
95
- queryFn: async ({ pageParam }) => {
96
- const allQueryConstraints = [...queryConstraints, ...(pageParam ? [pageParam] : [])];
97
- const queryToExecute = compositeFilter
98
- ? query(collectionReference, compositeFilter, ...(allQueryConstraints as QueryNonFilterConstraint[]))
99
- : query(collectionReference, ...(allQueryConstraints as QueryConstraint[]));
100
-
101
- const querySnapshot: FirebaseFirestoreTypes.QuerySnapshot<AppModelType> = await getDocs<
102
- AppModelType,
103
- AppModelType
104
- >(queryToExecute);
105
- const docs: AppModelType[] = [];
106
-
107
- if (querySnapshot) {
108
- querySnapshot.forEach((doc) => {
109
- docs.push({ ...doc.data(), uid: doc.id });
110
- });
111
- }
112
- return docs;
113
- }
114
- });
115
- };
@@ -1,89 +0,0 @@
1
- import {
2
- FirebaseFirestoreTypes,
3
- getDocs,
4
- query,
5
- QueryConstraint,
6
- QueryNonFilterConstraint
7
- } from "@react-native-firebase/firestore";
8
-
9
- import {
10
- UseQueryResult,
11
- useQuery as useReactQuery,
12
- UseQueryOptions as UseReactQueryOptions
13
- } from "@tanstack/react-query";
14
- import { AppModel } from "../../types";
15
- import { QueryFilterConstraint } from "./utils/buildCompositeFilter";
16
-
17
- /**
18
- * @inline
19
- */
20
- type UseQueryOptions<AppModelType extends AppModel = AppModel> = {
21
- /**
22
- * Reqct-query options that must include queryKey and shall not define queryFn
23
- */
24
- options: Omit<UseReactQueryOptions<AppModelType[], Error, AppModelType[]>, "queryFn"> &
25
- Required<Pick<UseReactQueryOptions<AppModelType[], Error, AppModelType[]>, "queryKey">>;
26
-
27
- /**
28
- * Reference to a Firestore collection
29
- */
30
- collectionReference: FirebaseFirestoreTypes.CollectionReference<AppModelType>;
31
-
32
- /**
33
- * Non composite filter constraints such as limit, order, where
34
- */
35
- queryConstraints?: QueryConstraint[] | QueryNonFilterConstraint[];
36
-
37
- /**
38
- * Composite filter
39
- */
40
- compositeFilter?: QueryFilterConstraint;
41
- };
42
-
43
- /**
44
- * Executes a query on a Firestore data source and returns the resulting documents as an array.
45
- *
46
- * @group Hook
47
- *
48
- * @param {UseQueryOptions<AppModelType>} options - Configuration options for the query.
49
- *
50
- * @returns {UseQueryResult<AppModelType[]>} An object containing documents that match the query.
51
- *
52
- * @example
53
- * ```jsx
54
- * export const MyComponent = () => {
55
- * const docs = useQuery({
56
- * options: {
57
- * queryKey: ['key']
58
- * },
59
- * collectionReference: collection(),
60
- * });
61
- * console.log(docs);
62
- * };
63
- * ```
64
- */
65
- export const useQuery = <AppModelType extends AppModel = AppModel>({
66
- options,
67
- collectionReference,
68
- queryConstraints = [],
69
- compositeFilter
70
- }: UseQueryOptions<AppModelType>): UseQueryResult<AppModelType[]> => {
71
- return useReactQuery({
72
- ...options,
73
- queryFn: async () => {
74
- const queryToExecute = compositeFilter
75
- ? query(collectionReference, compositeFilter, ...(queryConstraints as QueryNonFilterConstraint[]))
76
- : query(collectionReference, ...(queryConstraints as QueryConstraint[]));
77
-
78
- const querySnapshot: FirebaseFirestoreTypes.QuerySnapshot<AppModelType> = await getDocs(queryToExecute);
79
- const docs: AppModelType[] = [];
80
-
81
- if (querySnapshot) {
82
- querySnapshot.forEach((doc) => {
83
- docs.push({ ...doc.data(), uid: doc.id });
84
- });
85
- }
86
- return docs;
87
- }
88
- });
89
- };
@@ -1,44 +0,0 @@
1
- import { type QueryNonFilterConstraint } from "@react-native-firebase/firestore";
2
- import { useMemo } from "react";
3
- import { AppModel } from "../../types/AppModel";
4
- import { type NonFilterQueryConstraint } from "../../types/QueryConstraints";
5
- import { buildQueryConstraint } from "./utils/buildQueryConstraint";
6
-
7
- /**
8
- * @inline
9
- */
10
- export type UseQueryConstraints<AppModelType extends AppModel = AppModel> = {
11
- /**
12
- * A list of constraints such as limit, order, offset.
13
- */
14
- constraints: NonFilterQueryConstraint<AppModelType>[];
15
- };
16
-
17
- /**
18
- * A hook to build a list of non-filter query constraints for firebase queries.
19
- * It uses buildQueryConstraint method and useMemo hook.
20
- *
21
- * @group Hook
22
- *
23
- * @param {UseQueryConstraints<AppModelType>} options
24
- *
25
- * @returns {FirebaseFirestoreTypes.QueryNonFilterConstraint}
26
- *
27
- * @example
28
- * ```jsx
29
- * const firebaseConfig = {};
30
- * export const constraint = useQueryConstraints([
31
- * {
32
- * type: 'limit',
33
- * limit: 1
34
- * }
35
- * ]};
36
- * ```
37
- */
38
- export const useQueryConstraints = <AppModelType extends AppModel = AppModel>({
39
- constraints
40
- }: UseQueryConstraints<AppModelType>): QueryNonFilterConstraint[] => {
41
- return useMemo(() => {
42
- return constraints.map(buildQueryConstraint);
43
- }, [constraints]);
44
- };