react-query-firebase 2.13.2 → 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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/react-native/analytics/index.d.ts +3 -0
- package/dist/react-native/analytics/index.js +3 -0
- package/{react-native/analytics/useAnalytics.ts → dist/react-native/analytics/useAnalytics.js} +1 -3
- package/{react-native → dist/react-native}/analytics/useLogEvent.js +1 -1
- package/{react-native → dist/react-native}/analytics/useSetAnalyticsCollectionEnabled.js +1 -1
- package/dist/react-native/auth/index.d.ts +19 -0
- package/dist/react-native/auth/index.js +19 -0
- package/{react-native/auth/useAuth.ts → dist/react-native/auth/useAuth.js} +1 -3
- package/{react-native → dist/react-native}/auth/useAuthStateReady.js +1 -1
- package/{react-native → dist/react-native}/auth/useCreateUserWitEmailAndPasswordMutation.js +2 -2
- package/{react-native → dist/react-native}/auth/useCurrentUser.js +1 -1
- package/{react-native → dist/react-native}/auth/useIdToken.js +3 -3
- package/{react-native → dist/react-native}/auth/useLinkWithCredentialMutation.js +1 -1
- package/{react-native → dist/react-native}/auth/useReauthenticateWitCredentialMutation.js +1 -1
- package/{react-native → dist/react-native}/auth/useReauthenticateWitRedirectMutation.js +1 -1
- package/{react-native → dist/react-native}/auth/useSendEmailVerificationMutation.js +1 -1
- package/{react-native → dist/react-native}/auth/useSignInAnonymouslyMutation.js +2 -2
- package/{react-native → dist/react-native}/auth/useSignInWitEmailAndPasswordMutation.js +2 -2
- package/{react-native → dist/react-native}/auth/useSignInWitRedirectMutation.js +2 -2
- package/{react-native → dist/react-native}/auth/useSignInWithCredentialMutation.js +2 -2
- package/{react-native → dist/react-native}/auth/useSignOutMutation.js +2 -2
- package/{react-native → dist/react-native}/auth/useUpdateProfileMutation.js +1 -1
- package/{react-native → dist/react-native}/context/FirebaseContextProvider.js +2 -2
- package/dist/react-native/context/index.d.ts +1 -0
- package/dist/react-native/context/index.js +1 -0
- package/dist/react-native/firestore/index.d.ts +23 -0
- package/dist/react-native/firestore/index.js +23 -0
- package/{react-native → dist/react-native}/firestore/useAddDocMutation.d.ts +1 -1
- package/{react-native → dist/react-native}/firestore/useBatchWrite.js +1 -1
- package/{react-native → dist/react-native}/firestore/useCollectionReference.d.ts +1 -1
- package/{react-native → dist/react-native}/firestore/useCollectionReference.js +1 -1
- package/{react-native → dist/react-native}/firestore/useCompositeFilter.d.ts +2 -2
- package/{react-native → dist/react-native}/firestore/useCompositeFilter.js +1 -1
- package/{react-native → dist/react-native}/firestore/useCountQuery.d.ts +2 -2
- package/{react-native → dist/react-native}/firestore/useDeleteDocMutation.d.ts +1 -1
- package/{react-native → dist/react-native}/firestore/useDocReference.d.ts +3 -4
- package/{react-native → dist/react-native}/firestore/useDocReference.js +6 -8
- package/{react-native → dist/react-native}/firestore/useDocReferences.d.ts +2 -2
- package/{react-native → dist/react-native}/firestore/useDocReferences.js +2 -2
- package/{web → dist/react-native}/firestore/useEnsureDoc.d.ts +2 -2
- package/{react-native → dist/react-native}/firestore/useEnsureDoc.js +3 -3
- package/{react-native/firestore/useFirestore.ts → dist/react-native/firestore/useFirestore.js} +1 -2
- package/{react-native → dist/react-native}/firestore/useGetDocData.d.ts +2 -2
- package/{web → dist/react-native}/firestore/useGetDocData.js +2 -2
- package/{react-native → dist/react-native}/firestore/useGetRealtimeDocData.d.ts +1 -1
- package/{react-native → dist/react-native}/firestore/useGetRealtimeDocData.js +1 -1
- package/{react-native → dist/react-native}/firestore/useInfiniteQuery.d.ts +2 -2
- package/{react-native → dist/react-native}/firestore/useQuery.d.ts +2 -2
- package/{react-native → dist/react-native}/firestore/useQueryConstraints.d.ts +2 -2
- package/{react-native → dist/react-native}/firestore/useQueryConstraints.js +1 -1
- package/{react-native → dist/react-native}/firestore/useRunTransaction.js +1 -1
- package/{react-native → dist/react-native}/firestore/useSetDocMutation.d.ts +1 -1
- package/{react-native → dist/react-native}/firestore/useUpdateDocMutation.d.ts +1 -1
- package/{react-native → dist/react-native}/firestore/utils/buildCompositeFilter.d.ts +1 -1
- package/{react-native → dist/react-native}/firestore/utils/buildQueryConstraint.d.ts +1 -1
- package/{react-native → dist/react-native}/firestore/utils/getDocData.d.ts +2 -2
- package/{react-native → dist/react-native}/firestore/utils/getDocData.js +1 -1
- package/{react-native → dist/react-native}/firestore/utils/getDocRef.d.ts +1 -1
- package/{react-native → dist/react-native}/firestore/utils/getDocSnap.d.ts +2 -2
- package/{react-native → dist/react-native}/firestore/utils/getDocSnap.js +1 -1
- package/dist/react-native/index.d.ts +1 -0
- package/dist/react-native/index.js +1 -0
- package/dist/react-native/remoteConfig/index.d.ts +3 -0
- package/dist/react-native/remoteConfig/index.js +3 -0
- package/{react-native → dist/react-native}/remoteConfig/useFetchAndActivate.js +1 -1
- package/{react-native → dist/react-native}/remoteConfig/useGetValue.js +1 -1
- package/{react-native/remoteConfig/useRemoteConfig.ts → dist/react-native/remoteConfig/useRemoteConfig.js} +1 -2
- package/{types → dist/types}/QueryConstraints.d.ts +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/web/analytics/index.d.ts +3 -0
- package/dist/web/analytics/index.js +3 -0
- package/{web/analytics/useAnalytics.ts → dist/web/analytics/useAnalytics.js} +1 -3
- package/{web → dist/web}/analytics/useLogEvent.js +1 -1
- package/{web → dist/web}/analytics/useSetAnalyticsCollectionEnabled.js +1 -1
- package/dist/web/auth/index.d.ts +20 -0
- package/dist/web/auth/index.js +20 -0
- package/{web/auth/useAuth.ts → dist/web/auth/useAuth.js} +1 -3
- package/{web → dist/web}/auth/useAuthStateReady.js +4 -8
- package/{web → dist/web}/auth/useCreateUserWitEmailAndPasswordMutation.js +2 -2
- package/{web → dist/web}/auth/useCurrentUser.js +1 -1
- package/{web → dist/web}/auth/useGetRedirectResultMutation.js +2 -2
- package/{web → dist/web}/auth/useIdToken.js +3 -3
- package/{web → dist/web}/auth/useLinkWithCredentialMutation.js +1 -1
- package/{web → dist/web}/auth/useReauthenticateWitCredentialMutation.js +1 -1
- package/{web → dist/web}/auth/useReauthenticateWitRedirectMutation.js +1 -1
- package/{web → dist/web}/auth/useSendEmailVerificationMutation.js +1 -1
- package/{web → dist/web}/auth/useSignInAnonymouslyMutation.js +2 -2
- package/{web → dist/web}/auth/useSignInWitEmailAndPasswordMutation.js +2 -2
- package/{web → dist/web}/auth/useSignInWitRedirectMutation.js +2 -2
- package/{web → dist/web}/auth/useSignInWithCredentialMutation.js +2 -2
- package/{web → dist/web}/auth/useSignOutMutation.js +2 -2
- package/{web → dist/web}/auth/useUpdateProfileMutation.js +1 -1
- package/{web → dist/web}/context/FirebaseContextProvider.js +2 -2
- package/dist/web/context/index.d.ts +1 -0
- package/dist/web/context/index.js +1 -0
- package/dist/web/firestore/index.d.ts +23 -0
- package/dist/web/firestore/index.js +23 -0
- package/{web → dist/web}/firestore/useAddDocMutation.d.ts +1 -1
- package/{web → dist/web}/firestore/useBatchWrite.js +1 -1
- package/{web → dist/web}/firestore/useCollectionReference.d.ts +1 -1
- package/{web → dist/web}/firestore/useCollectionReference.js +1 -1
- package/{web → dist/web}/firestore/useCompositeFilter.d.ts +2 -2
- package/{web → dist/web}/firestore/useCompositeFilter.js +1 -1
- package/{web → dist/web}/firestore/useCountQuery.d.ts +2 -2
- package/{web → dist/web}/firestore/useDeleteDocMutation.d.ts +1 -1
- package/{web → dist/web}/firestore/useDocReference.d.ts +3 -4
- package/{web → dist/web}/firestore/useDocReference.js +6 -8
- package/{web → dist/web}/firestore/useDocReferences.d.ts +2 -2
- package/{web → dist/web}/firestore/useDocReferences.js +2 -2
- package/{react-native → dist/web}/firestore/useEnsureDoc.d.ts +2 -2
- package/{web → dist/web}/firestore/useEnsureDoc.js +3 -3
- package/{web/firestore/useFirestore.ts → dist/web/firestore/useFirestore.js} +1 -2
- package/{web → dist/web}/firestore/useGetDocData.d.ts +2 -2
- package/{react-native → dist/web}/firestore/useGetDocData.js +2 -2
- package/{web → dist/web}/firestore/useGetRealtimeDocData.d.ts +1 -1
- package/{web → dist/web}/firestore/useGetRealtimeDocData.js +1 -1
- package/{web → dist/web}/firestore/useInfiniteQuery.d.ts +2 -2
- package/{web → dist/web}/firestore/useQuery.d.ts +2 -2
- package/{web → dist/web}/firestore/useQueryConstraints.d.ts +2 -2
- package/{web → dist/web}/firestore/useQueryConstraints.js +1 -1
- package/{web → dist/web}/firestore/useRunTransaction.js +1 -1
- package/{web → dist/web}/firestore/useSetDocMutation.d.ts +1 -1
- package/{web → dist/web}/firestore/useUpdateDocMutation.d.ts +1 -1
- package/{web → dist/web}/firestore/utils/buildCompositeFilter.d.ts +1 -1
- package/{web → dist/web}/firestore/utils/buildQueryConstraint.d.ts +1 -1
- package/{web → dist/web}/firestore/utils/getDocData.d.ts +2 -2
- package/{web → dist/web}/firestore/utils/getDocData.js +1 -1
- package/{web → dist/web}/firestore/utils/getDocRef.d.ts +1 -1
- package/{web → dist/web}/firestore/utils/getDocSnap.d.ts +2 -2
- package/{web → dist/web}/firestore/utils/getDocSnap.js +1 -1
- package/dist/web/index.d.ts +1 -0
- package/dist/web/index.js +1 -0
- package/dist/web/remoteConfig/index.d.ts +3 -0
- package/dist/web/remoteConfig/index.js +3 -0
- package/{web → dist/web}/remoteConfig/useFetchAndActivate.js +1 -1
- package/{web → dist/web}/remoteConfig/useGetValue.js +1 -1
- package/{web/remoteConfig/useRemoteConfig.ts → dist/web/remoteConfig/useRemoteConfig.js} +1 -2
- package/package.json +45 -16
- package/react-native/analytics/index.d.ts +0 -3
- package/react-native/analytics/index.js +0 -3
- package/react-native/analytics/index.ts +0 -3
- package/react-native/analytics/useAnalytics.js +0 -10
- package/react-native/analytics/useLogEvent.ts +0 -34
- package/react-native/analytics/useSetAnalyticsCollectionEnabled.ts +0 -22
- package/react-native/auth/index.d.ts +0 -19
- package/react-native/auth/index.js +0 -19
- package/react-native/auth/index.ts +0 -19
- package/react-native/auth/mutation-keys.ts +0 -22
- package/react-native/auth/useAppleAuthProviderCredential.ts +0 -31
- package/react-native/auth/useAuth.js +0 -10
- package/react-native/auth/useAuthStateReady.ts +0 -39
- package/react-native/auth/useCreateUserWitEmailAndPasswordMutation.ts +0 -38
- package/react-native/auth/useCurrentUser.ts +0 -26
- package/react-native/auth/useEmailAuthProviderCredential.ts +0 -38
- package/react-native/auth/useFacebookAuthProviderCredential.ts +0 -31
- package/react-native/auth/useIdToken.ts +0 -83
- package/react-native/auth/useLinkWithCredentialMutation.ts +0 -35
- package/react-native/auth/useReauthenticateWitCredentialMutation.ts +0 -36
- package/react-native/auth/useReauthenticateWitRedirectMutation.ts +0 -42
- package/react-native/auth/useSendEmailVerificationMutation.ts +0 -33
- package/react-native/auth/useSignInAnonymouslyMutation.ts +0 -52
- package/react-native/auth/useSignInWitEmailAndPasswordMutation.ts +0 -39
- package/react-native/auth/useSignInWitRedirectMutation.ts +0 -38
- package/react-native/auth/useSignInWithCredentialMutation.ts +0 -36
- package/react-native/auth/useSignOutMutation.ts +0 -28
- package/react-native/auth/useUpdateProfileMutation.ts +0 -30
- package/react-native/context/FirebaseContext.ts +0 -25
- package/react-native/context/FirebaseContextProvider.tsx +0 -264
- package/react-native/context/index.d.ts +0 -1
- package/react-native/context/index.js +0 -1
- package/react-native/context/index.ts +0 -1
- package/react-native/firestore/index.d.ts +0 -23
- package/react-native/firestore/index.js +0 -23
- package/react-native/firestore/index.ts +0 -23
- package/react-native/firestore/useAddDocMutation.ts +0 -80
- package/react-native/firestore/useBatchWrite.ts +0 -58
- package/react-native/firestore/useCollectionReference.ts +0 -58
- package/react-native/firestore/useCompositeFilter.ts +0 -60
- package/react-native/firestore/useCountQuery.ts +0 -85
- package/react-native/firestore/useDeleteDocMutation.ts +0 -71
- package/react-native/firestore/useDocReference.ts +0 -50
- package/react-native/firestore/useDocReferences.ts +0 -40
- package/react-native/firestore/useEnsureDoc.ts +0 -79
- package/react-native/firestore/useFirestore.js +0 -13
- package/react-native/firestore/useGetDocData.ts +0 -52
- package/react-native/firestore/useGetRealtimeDocData.ts +0 -106
- package/react-native/firestore/useInfiniteQuery.ts +0 -115
- package/react-native/firestore/useQuery.ts +0 -89
- package/react-native/firestore/useQueryConstraints.ts +0 -44
- package/react-native/firestore/useRunTransaction.ts +0 -55
- package/react-native/firestore/useSetDocMutation.ts +0 -76
- package/react-native/firestore/useUpdateDocMutation.ts +0 -77
- package/react-native/firestore/utils/buildCompositeFilter.ts +0 -75
- package/react-native/firestore/utils/buildQueryConstraint.ts +0 -54
- package/react-native/firestore/utils/getDocData.ts +0 -33
- package/react-native/firestore/utils/getDocRef.ts +0 -41
- package/react-native/firestore/utils/getDocSnap.ts +0 -34
- package/react-native/index.d.ts +0 -1
- package/react-native/index.js +0 -1
- package/react-native/index.ts +0 -1
- package/react-native/remoteConfig/index.d.ts +0 -3
- package/react-native/remoteConfig/index.js +0 -3
- package/react-native/remoteConfig/index.ts +0 -3
- package/react-native/remoteConfig/useFetchAndActivate.ts +0 -36
- package/react-native/remoteConfig/useGetValue.ts +0 -16
- package/react-native/remoteConfig/useRemoteConfig.js +0 -10
- package/types/AppModel.ts +0 -10
- package/types/QueryConstraints.ts +0 -57
- package/types/index.d.ts +0 -2
- package/types/index.js +0 -2
- package/types/index.ts +0 -2
- package/web/analytics/index.d.ts +0 -3
- package/web/analytics/index.js +0 -3
- package/web/analytics/index.ts +0 -3
- package/web/analytics/useAnalytics.js +0 -10
- package/web/analytics/useLogEvent.ts +0 -34
- package/web/analytics/useSetAnalyticsCollectionEnabled.ts +0 -22
- package/web/auth/index.d.ts +0 -20
- package/web/auth/index.js +0 -20
- package/web/auth/index.ts +0 -20
- package/web/auth/mutation-keys.ts +0 -23
- package/web/auth/useAppleAuthProviderCredential.ts +0 -32
- package/web/auth/useAuth.js +0 -10
- package/web/auth/useAuthStateReady.ts +0 -35
- package/web/auth/useCreateUserWitEmailAndPasswordMutation.ts +0 -33
- package/web/auth/useCurrentUser.ts +0 -25
- package/web/auth/useEmailAuthProviderCredential.ts +0 -38
- package/web/auth/useFacebookAuthProviderCredential.ts +0 -31
- package/web/auth/useGetRedirectResultMutation.ts +0 -27
- package/web/auth/useIdToken.ts +0 -83
- package/web/auth/useLinkWithCredentialMutation.ts +0 -30
- package/web/auth/useReauthenticateWitCredentialMutation.ts +0 -31
- package/web/auth/useReauthenticateWitRedirectMutation.ts +0 -37
- package/web/auth/useSendEmailVerificationMutation.ts +0 -28
- package/web/auth/useSignInAnonymouslyMutation.ts +0 -49
- package/web/auth/useSignInWitEmailAndPasswordMutation.ts +0 -34
- package/web/auth/useSignInWitRedirectMutation.ts +0 -33
- package/web/auth/useSignInWithCredentialMutation.ts +0 -31
- package/web/auth/useSignOutMutation.ts +0 -25
- package/web/auth/useUpdateProfileMutation.ts +0 -30
- package/web/context/FirebaseContext.ts +0 -25
- package/web/context/FirebaseContextProvider.tsx +0 -263
- package/web/context/index.d.ts +0 -1
- package/web/context/index.js +0 -1
- package/web/context/index.ts +0 -1
- package/web/firestore/index.d.ts +0 -23
- package/web/firestore/index.js +0 -23
- package/web/firestore/index.ts +0 -23
- package/web/firestore/useAddDocMutation.ts +0 -74
- package/web/firestore/useBatchWrite.ts +0 -58
- package/web/firestore/useCollectionReference.ts +0 -58
- package/web/firestore/useCompositeFilter.ts +0 -55
- package/web/firestore/useCountQuery.ts +0 -90
- package/web/firestore/useDeleteDocMutation.ts +0 -69
- package/web/firestore/useDocReference.ts +0 -50
- package/web/firestore/useDocReferences.ts +0 -40
- package/web/firestore/useEnsureDoc.ts +0 -92
- package/web/firestore/useFirestore.js +0 -13
- package/web/firestore/useGetDocData.ts +0 -52
- package/web/firestore/useGetRealtimeDocData.ts +0 -105
- package/web/firestore/useInfiniteQuery.ts +0 -117
- package/web/firestore/useQuery.ts +0 -94
- package/web/firestore/useQueryConstraints.ts +0 -44
- package/web/firestore/useRunTransaction.ts +0 -56
- package/web/firestore/useSetDocMutation.ts +0 -77
- package/web/firestore/useUpdateDocMutation.ts +0 -78
- package/web/firestore/utils/buildCompositeFilter.ts +0 -73
- package/web/firestore/utils/buildQueryConstraint.ts +0 -55
- package/web/firestore/utils/getDocData.ts +0 -33
- package/web/firestore/utils/getDocRef.ts +0 -43
- package/web/firestore/utils/getDocSnap.ts +0 -34
- package/web/index.d.ts +0 -1
- package/web/index.js +0 -1
- package/web/index.ts +0 -1
- package/web/remoteConfig/index.d.ts +0 -3
- package/web/remoteConfig/index.js +0 -3
- package/web/remoteConfig/index.ts +0 -3
- package/web/remoteConfig/useFetchAndActivate.ts +0 -36
- package/web/remoteConfig/useGetValue.ts +0 -16
- package/web/remoteConfig/useRemoteConfig.js +0 -10
- /package/{react-native → dist/react-native}/analytics/useAnalytics.d.ts +0 -0
- /package/{react-native → dist/react-native}/analytics/useLogEvent.d.ts +0 -0
- /package/{react-native → dist/react-native}/analytics/useSetAnalyticsCollectionEnabled.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/mutation-keys.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/mutation-keys.js +0 -0
- /package/{react-native → dist/react-native}/auth/useAppleAuthProviderCredential.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useAppleAuthProviderCredential.js +0 -0
- /package/{react-native → dist/react-native}/auth/useAuth.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useAuthStateReady.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useCurrentUser.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useEmailAuthProviderCredential.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useEmailAuthProviderCredential.js +0 -0
- /package/{react-native → dist/react-native}/auth/useFacebookAuthProviderCredential.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useFacebookAuthProviderCredential.js +0 -0
- /package/{react-native → dist/react-native}/auth/useIdToken.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useLinkWithCredentialMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useReauthenticateWitCredentialMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useReauthenticateWitRedirectMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useSendEmailVerificationMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useSignInAnonymouslyMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useSignInWitEmailAndPasswordMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useSignInWitRedirectMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useSignInWithCredentialMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useSignOutMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/auth/useUpdateProfileMutation.d.ts +0 -0
- /package/{react-native → dist/react-native}/context/FirebaseContext.d.ts +0 -0
- /package/{react-native → dist/react-native}/context/FirebaseContext.js +0 -0
- /package/{react-native → dist/react-native}/context/FirebaseContextProvider.d.ts +0 -0
- /package/{react-native → dist/react-native}/firestore/useAddDocMutation.js +0 -0
- /package/{react-native → dist/react-native}/firestore/useBatchWrite.d.ts +0 -0
- /package/{react-native → dist/react-native}/firestore/useCountQuery.js +0 -0
- /package/{react-native → dist/react-native}/firestore/useDeleteDocMutation.js +0 -0
- /package/{react-native → dist/react-native}/firestore/useFirestore.d.ts +0 -0
- /package/{react-native → dist/react-native}/firestore/useInfiniteQuery.js +0 -0
- /package/{react-native → dist/react-native}/firestore/useQuery.js +0 -0
- /package/{react-native → dist/react-native}/firestore/useRunTransaction.d.ts +0 -0
- /package/{react-native → dist/react-native}/firestore/useSetDocMutation.js +0 -0
- /package/{react-native → dist/react-native}/firestore/useUpdateDocMutation.js +0 -0
- /package/{react-native → dist/react-native}/firestore/utils/buildCompositeFilter.js +0 -0
- /package/{react-native → dist/react-native}/firestore/utils/buildQueryConstraint.js +0 -0
- /package/{react-native → dist/react-native}/firestore/utils/getDocRef.js +0 -0
- /package/{react-native → dist/react-native}/remoteConfig/useFetchAndActivate.d.ts +0 -0
- /package/{react-native → dist/react-native}/remoteConfig/useGetValue.d.ts +0 -0
- /package/{react-native → dist/react-native}/remoteConfig/useRemoteConfig.d.ts +0 -0
- /package/{types → dist/types}/AppModel.d.ts +0 -0
- /package/{types → dist/types}/AppModel.js +0 -0
- /package/{types → dist/types}/QueryConstraints.js +0 -0
- /package/{web → dist/web}/analytics/useAnalytics.d.ts +0 -0
- /package/{web → dist/web}/analytics/useLogEvent.d.ts +0 -0
- /package/{web → dist/web}/analytics/useSetAnalyticsCollectionEnabled.d.ts +0 -0
- /package/{web → dist/web}/auth/mutation-keys.d.ts +0 -0
- /package/{web → dist/web}/auth/mutation-keys.js +0 -0
- /package/{web → dist/web}/auth/useAppleAuthProviderCredential.d.ts +0 -0
- /package/{web → dist/web}/auth/useAppleAuthProviderCredential.js +0 -0
- /package/{web → dist/web}/auth/useAuth.d.ts +0 -0
- /package/{web → dist/web}/auth/useAuthStateReady.d.ts +0 -0
- /package/{web → dist/web}/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useCurrentUser.d.ts +0 -0
- /package/{web → dist/web}/auth/useEmailAuthProviderCredential.d.ts +0 -0
- /package/{web → dist/web}/auth/useEmailAuthProviderCredential.js +0 -0
- /package/{web → dist/web}/auth/useFacebookAuthProviderCredential.d.ts +0 -0
- /package/{web → dist/web}/auth/useFacebookAuthProviderCredential.js +0 -0
- /package/{web → dist/web}/auth/useGetRedirectResultMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useIdToken.d.ts +0 -0
- /package/{web → dist/web}/auth/useLinkWithCredentialMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useReauthenticateWitCredentialMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useReauthenticateWitRedirectMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useSendEmailVerificationMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useSignInAnonymouslyMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useSignInWitEmailAndPasswordMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useSignInWitRedirectMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useSignInWithCredentialMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useSignOutMutation.d.ts +0 -0
- /package/{web → dist/web}/auth/useUpdateProfileMutation.d.ts +0 -0
- /package/{web → dist/web}/context/FirebaseContext.d.ts +0 -0
- /package/{web → dist/web}/context/FirebaseContext.js +0 -0
- /package/{web → dist/web}/context/FirebaseContextProvider.d.ts +0 -0
- /package/{web → dist/web}/firestore/useAddDocMutation.js +0 -0
- /package/{web → dist/web}/firestore/useBatchWrite.d.ts +0 -0
- /package/{web → dist/web}/firestore/useCountQuery.js +0 -0
- /package/{web → dist/web}/firestore/useDeleteDocMutation.js +0 -0
- /package/{web → dist/web}/firestore/useFirestore.d.ts +0 -0
- /package/{web → dist/web}/firestore/useInfiniteQuery.js +0 -0
- /package/{web → dist/web}/firestore/useQuery.js +0 -0
- /package/{web → dist/web}/firestore/useRunTransaction.d.ts +0 -0
- /package/{web → dist/web}/firestore/useSetDocMutation.js +0 -0
- /package/{web → dist/web}/firestore/useUpdateDocMutation.js +0 -0
- /package/{web → dist/web}/firestore/utils/buildCompositeFilter.js +0 -0
- /package/{web → dist/web}/firestore/utils/buildQueryConstraint.js +0 -0
- /package/{web → dist/web}/firestore/utils/getDocRef.js +0 -0
- /package/{web → dist/web}/remoteConfig/useFetchAndActivate.d.ts +0 -0
- /package/{web → dist/web}/remoteConfig/useGetValue.d.ts +0 -0
- /package/{web → dist/web}/remoteConfig/useRemoteConfig.d.ts +0 -0
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CollectionReference,
|
|
3
|
-
getDocs,
|
|
4
|
-
query,
|
|
5
|
-
QueryCompositeFilterConstraint,
|
|
6
|
-
QueryConstraint,
|
|
7
|
-
QueryNonFilterConstraint
|
|
8
|
-
} from "firebase/firestore";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
useInfiniteQuery as useInfiniteReactQuery,
|
|
12
|
-
UseInfiniteQueryOptions as UseReactInfiniteQueryOptions,
|
|
13
|
-
QueryKey,
|
|
14
|
-
UseInfiniteQueryResult,
|
|
15
|
-
InfiniteData
|
|
16
|
-
} from "@tanstack/react-query";
|
|
17
|
-
import { QueryFilterConstraint } from "./utils/buildCompositeFilter";
|
|
18
|
-
import { AppModel } from "../../types";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @inline
|
|
22
|
-
*/
|
|
23
|
-
type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey extends QueryKey = QueryKey> = {
|
|
24
|
-
/**
|
|
25
|
-
* Reqct-query options that must include queryKey and shall not define queryFn
|
|
26
|
-
*/
|
|
27
|
-
options: Omit<
|
|
28
|
-
UseReactInfiniteQueryOptions<
|
|
29
|
-
AppModelType[],
|
|
30
|
-
Error,
|
|
31
|
-
InfiniteData<AppModelType[]>,
|
|
32
|
-
TQueryKey,
|
|
33
|
-
QueryNonFilterConstraint
|
|
34
|
-
>,
|
|
35
|
-
"queryFn"
|
|
36
|
-
> &
|
|
37
|
-
Required<
|
|
38
|
-
Pick<
|
|
39
|
-
UseReactInfiniteQueryOptions<
|
|
40
|
-
AppModelType[],
|
|
41
|
-
Error,
|
|
42
|
-
InfiniteData<AppModelType[]>,
|
|
43
|
-
TQueryKey,
|
|
44
|
-
QueryNonFilterConstraint
|
|
45
|
-
>,
|
|
46
|
-
"queryKey"
|
|
47
|
-
>
|
|
48
|
-
>;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Reference to a Firestore collection
|
|
52
|
-
*/
|
|
53
|
-
collectionReference: CollectionReference<AppModelType, AppModelType>;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Non composite filter constraints such as limit, order, where
|
|
57
|
-
*/
|
|
58
|
-
queryConstraints?: QueryConstraint[] | QueryNonFilterConstraint[];
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Composite filter
|
|
62
|
-
*/
|
|
63
|
-
compositeFilter?: QueryFilterConstraint;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Executes an infinite query on a Firestore data source and returns the resulting documents as an array.
|
|
68
|
-
*
|
|
69
|
-
* @group Hook
|
|
70
|
-
*
|
|
71
|
-
* @param {UseInfiniteQueryOptions<AppModelType, TQueryKey>} options - Configuration options for the query.
|
|
72
|
-
*
|
|
73
|
-
* @returns {UseInfiniteQueryResult<InfiniteData<AppModelType[]>>} An object containing documents that match the query.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```jsx
|
|
77
|
-
* export const MyComponent = () => {
|
|
78
|
-
* const docs = useInfiniteQuery({
|
|
79
|
-
* options: {
|
|
80
|
-
* queryKey: ['key']
|
|
81
|
-
* },
|
|
82
|
-
* collectionReference: collection(),
|
|
83
|
-
* });
|
|
84
|
-
* console.log(docs);
|
|
85
|
-
* };
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
export const useInfiniteQuery = <AppModelType extends AppModel = AppModel, TQueryKey extends QueryKey = QueryKey>({
|
|
89
|
-
options,
|
|
90
|
-
collectionReference,
|
|
91
|
-
queryConstraints = [],
|
|
92
|
-
compositeFilter
|
|
93
|
-
}: UseInfiniteQueryOptions<AppModelType, TQueryKey>): UseInfiniteQueryResult<InfiniteData<AppModelType[]>> => {
|
|
94
|
-
return useInfiniteReactQuery({
|
|
95
|
-
...options,
|
|
96
|
-
queryFn: async ({ pageParam }) => {
|
|
97
|
-
const allQueryConstraints = [...queryConstraints, ...(pageParam ? [pageParam] : [])];
|
|
98
|
-
const queryToExecute = compositeFilter
|
|
99
|
-
? query(
|
|
100
|
-
collectionReference,
|
|
101
|
-
compositeFilter as QueryCompositeFilterConstraint,
|
|
102
|
-
...(allQueryConstraints as QueryNonFilterConstraint[])
|
|
103
|
-
)
|
|
104
|
-
: query(collectionReference, ...allQueryConstraints);
|
|
105
|
-
|
|
106
|
-
const querySnapshot = await getDocs(queryToExecute);
|
|
107
|
-
const docs: AppModelType[] = [];
|
|
108
|
-
|
|
109
|
-
if (querySnapshot) {
|
|
110
|
-
querySnapshot.forEach((doc) => {
|
|
111
|
-
docs.push({ ...doc.data(), uid: doc.id });
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
return docs;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDocs,
|
|
3
|
-
CollectionReference,
|
|
4
|
-
query,
|
|
5
|
-
QueryCompositeFilterConstraint,
|
|
6
|
-
QueryConstraint,
|
|
7
|
-
QueryNonFilterConstraint
|
|
8
|
-
} from "firebase/firestore";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
UseQueryResult,
|
|
12
|
-
useQuery as useReactQuery,
|
|
13
|
-
UseQueryOptions as UseReactQueryOptions
|
|
14
|
-
} from "@tanstack/react-query";
|
|
15
|
-
import { QueryFilterConstraint } from "./utils/buildCompositeFilter";
|
|
16
|
-
import { AppModel } from "../../types";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @inline
|
|
20
|
-
*/
|
|
21
|
-
type UseQueryOptions<AppModelType extends AppModel = AppModel> = {
|
|
22
|
-
/**
|
|
23
|
-
* Reqct-query options that must include queryKey and shall not define queryFn
|
|
24
|
-
*/
|
|
25
|
-
options: Omit<UseReactQueryOptions<AppModelType[], Error, AppModelType[]>, "queryFn"> &
|
|
26
|
-
Required<Pick<UseReactQueryOptions<AppModelType[], Error, AppModelType[]>, "queryKey">>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Reference to a Firestore collection
|
|
30
|
-
*/
|
|
31
|
-
collectionReference: CollectionReference<AppModelType, AppModelType>;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Non composite filter constraints such as limit, order, where
|
|
35
|
-
*/
|
|
36
|
-
queryConstraints?: QueryConstraint[] | QueryNonFilterConstraint[];
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Composite filter
|
|
40
|
-
*/
|
|
41
|
-
compositeFilter?: QueryFilterConstraint;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Executes a query on a Firestore data source and returns the resulting documents as an array.
|
|
46
|
-
*
|
|
47
|
-
* @group Hook
|
|
48
|
-
*
|
|
49
|
-
* @param {UseQueryOptions<AppModelType>} options - Configuration options for the query.
|
|
50
|
-
*
|
|
51
|
-
* @returns {UseQueryResult<AppModelType[]>} An object containing documents that match the query.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```jsx
|
|
55
|
-
* export const MyComponent = () => {
|
|
56
|
-
* const docs = useQuery({
|
|
57
|
-
* options: {
|
|
58
|
-
* queryKey: ['key']
|
|
59
|
-
* },
|
|
60
|
-
* collectionReference: collection(),
|
|
61
|
-
* });
|
|
62
|
-
* console.log(docs);
|
|
63
|
-
* };
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
export const useQuery = <AppModelType extends AppModel = AppModel>({
|
|
67
|
-
options,
|
|
68
|
-
collectionReference,
|
|
69
|
-
queryConstraints = [],
|
|
70
|
-
compositeFilter
|
|
71
|
-
}: UseQueryOptions<AppModelType>): UseQueryResult<AppModelType[]> => {
|
|
72
|
-
return useReactQuery({
|
|
73
|
-
...options,
|
|
74
|
-
queryFn: async () => {
|
|
75
|
-
const queryToExecute = compositeFilter
|
|
76
|
-
? query(
|
|
77
|
-
collectionReference,
|
|
78
|
-
compositeFilter as QueryCompositeFilterConstraint,
|
|
79
|
-
...(queryConstraints as QueryNonFilterConstraint[])
|
|
80
|
-
)
|
|
81
|
-
: query(collectionReference, ...queryConstraints);
|
|
82
|
-
|
|
83
|
-
const querySnapshot = await getDocs(queryToExecute);
|
|
84
|
-
const docs: AppModelType[] = [];
|
|
85
|
-
|
|
86
|
-
if (querySnapshot) {
|
|
87
|
-
querySnapshot.forEach((doc) => {
|
|
88
|
-
docs.push({ ...doc.data(), uid: doc.id });
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
return docs;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { QueryNonFilterConstraint } from "firebase/firestore";
|
|
2
|
-
import { AppModel } from "../../types/AppModel";
|
|
3
|
-
import { NonFilterQueryConstraint } from "../../types/QueryConstraints";
|
|
4
|
-
import { useMemo } from "react";
|
|
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>} constraints
|
|
24
|
-
*
|
|
25
|
-
* @returns {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
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { useMutation, UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
-
import { runTransaction, Transaction } from "firebase/firestore";
|
|
3
|
-
|
|
4
|
-
import { FirebaseError } from "firebase/app";
|
|
5
|
-
import { useFirestore } from "./useFirestore";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @inline
|
|
9
|
-
*/
|
|
10
|
-
export type UseRunTransactionValues = <T = unknown>(transaction: Transaction) => T;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @inline
|
|
14
|
-
*/
|
|
15
|
-
export type UseRunTransactionOptions<T = unknown, TContext = unknown> = {
|
|
16
|
-
/**
|
|
17
|
-
* Reqct-mutation options that shall omit mutationFn
|
|
18
|
-
*/
|
|
19
|
-
options?: Omit<UseMutationOptions<T, FirebaseError, UseRunTransactionValues, TContext>, "mutationFn">;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Executes a Firestore transaction
|
|
24
|
-
*
|
|
25
|
-
* @group Hook
|
|
26
|
-
*
|
|
27
|
-
* @param {UseRunTransactionOptions<T>} options - Configuration options for the mutation.
|
|
28
|
-
*
|
|
29
|
-
* @returns {UseMutationResult<T, Error>} An object representing mutation
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```jsx
|
|
33
|
-
* export const MyComponent = () => {
|
|
34
|
-
* const doc = useGetDocData({
|
|
35
|
-
* options: {
|
|
36
|
-
* queryKey: ['key']
|
|
37
|
-
* },
|
|
38
|
-
* reference: collection(),
|
|
39
|
-
* path: 'id'
|
|
40
|
-
* });
|
|
41
|
-
* console.log(doc);
|
|
42
|
-
* };
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export const useRunTransaction = <T = unknown, TContext = unknown>({
|
|
46
|
-
options = {}
|
|
47
|
-
}: UseRunTransactionOptions<T, TContext>) => {
|
|
48
|
-
const db = useFirestore();
|
|
49
|
-
|
|
50
|
-
return useMutation({
|
|
51
|
-
...options,
|
|
52
|
-
mutationFn: async (transactionFn) => {
|
|
53
|
-
return runTransaction<T>(db, transactionFn);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { useMutation, UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
-
import { DocumentReference, getDoc, setDoc, WithFieldValue } from "firebase/firestore";
|
|
3
|
-
|
|
4
|
-
import { FirebaseError } from "firebase/app";
|
|
5
|
-
import { useMemo } from "react";
|
|
6
|
-
import { AppModel } from "../../types";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @inline
|
|
10
|
-
*/
|
|
11
|
-
export type UseSetDocMutationValues<AppModelType extends AppModel = AppModel> = {
|
|
12
|
-
/**
|
|
13
|
-
* Data to write
|
|
14
|
-
*/
|
|
15
|
-
data: WithFieldValue<AppModelType>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @inline
|
|
20
|
-
*/
|
|
21
|
-
export type UseSetDocMutationOptions<AppModelType extends AppModel = AppModel, TContext = unknown> = {
|
|
22
|
-
/**
|
|
23
|
-
* Reference to a document that must be written
|
|
24
|
-
*/
|
|
25
|
-
reference: DocumentReference<AppModelType, AppModelType> | null;
|
|
26
|
-
/**
|
|
27
|
-
* Options for useMutation hook excluding mutationFn.
|
|
28
|
-
*/
|
|
29
|
-
options?: Omit<
|
|
30
|
-
UseMutationOptions<AppModelType, FirebaseError, UseSetDocMutationValues<AppModelType>, TContext>,
|
|
31
|
-
"mutationFn"
|
|
32
|
-
>;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Executes a mutation and returns added document
|
|
37
|
-
*
|
|
38
|
-
* @group Hook
|
|
39
|
-
*
|
|
40
|
-
* @param {UseSetDocMutationOptions<AppModelType>} options - Configuration options for mutation.
|
|
41
|
-
*
|
|
42
|
-
* @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```jsx
|
|
46
|
-
* export const MyComponent = () => {
|
|
47
|
-
* const {mutate} = useSetDocMutation({
|
|
48
|
-
* options: {
|
|
49
|
-
* },
|
|
50
|
-
* reference: collection().doc(),
|
|
51
|
-
* });
|
|
52
|
-
*
|
|
53
|
-
* // ....
|
|
54
|
-
* mutate({data: {test: 'value'}});
|
|
55
|
-
* // ....
|
|
56
|
-
* };
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export const useSetDocMutation = <AppModelType extends AppModel = AppModel, TContext = unknown>({
|
|
60
|
-
reference,
|
|
61
|
-
options
|
|
62
|
-
}: UseSetDocMutationOptions<AppModelType, TContext>) => {
|
|
63
|
-
const mutationKey = useMemo(() => [reference?.path], [reference?.path]);
|
|
64
|
-
|
|
65
|
-
return useMutation({
|
|
66
|
-
...options,
|
|
67
|
-
mutationKey,
|
|
68
|
-
mutationFn: async ({ data }) => {
|
|
69
|
-
if (!reference) {
|
|
70
|
-
throw new Error("Reference is undefined");
|
|
71
|
-
}
|
|
72
|
-
await setDoc<AppModelType, AppModelType>(reference, data);
|
|
73
|
-
const docSnap = await getDoc(reference);
|
|
74
|
-
return { ...(docSnap.data() as AppModelType), uid: docSnap.id };
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { useMutation, UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
-
import { updateDoc, getDoc, DocumentReference, UpdateData } from "firebase/firestore";
|
|
3
|
-
|
|
4
|
-
import { FirebaseError } from "firebase/app";
|
|
5
|
-
import { useMemo } from "react";
|
|
6
|
-
import { AppModel } from "../../types";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @inline
|
|
10
|
-
*/
|
|
11
|
-
export type UseUpdateDocMutationValues<AppModelType extends AppModel = AppModel> = {
|
|
12
|
-
/**
|
|
13
|
-
* Data to write
|
|
14
|
-
*/
|
|
15
|
-
data: UpdateData<AppModelType>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @inline
|
|
20
|
-
*/
|
|
21
|
-
export type UseUpdateDocMutationOptions<AppModelType extends AppModel = AppModel, TContext = unknown> = {
|
|
22
|
-
/**
|
|
23
|
-
* Reference to a document that must be updated
|
|
24
|
-
*/
|
|
25
|
-
reference: DocumentReference<AppModelType, AppModelType> | null;
|
|
26
|
-
/**
|
|
27
|
-
* Options for useMutation hook excluding mutationFn.
|
|
28
|
-
*/
|
|
29
|
-
options?: Omit<
|
|
30
|
-
UseMutationOptions<AppModelType, FirebaseError, UseUpdateDocMutationValues<AppModelType>, TContext>,
|
|
31
|
-
"mutationFn"
|
|
32
|
-
>;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Executes a mutation and returns updated document
|
|
37
|
-
*
|
|
38
|
-
* @group Hook
|
|
39
|
-
*
|
|
40
|
-
* @param {UseUpdateDocMutationOptions<AppModelType>} options - Configuration options for mutation.
|
|
41
|
-
*
|
|
42
|
-
* @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```jsx
|
|
46
|
-
* export const MyComponent = () => {
|
|
47
|
-
* const {mutate} = useUpdateDocMutation({
|
|
48
|
-
* options: {
|
|
49
|
-
* },
|
|
50
|
-
* reference: collection().doc(),
|
|
51
|
-
* });
|
|
52
|
-
*
|
|
53
|
-
* // ....
|
|
54
|
-
* mutate({data: {test: 'value'}});
|
|
55
|
-
* // ....
|
|
56
|
-
* };
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export const useUpdateDocMutation = <AppModelType extends AppModel = AppModel, TContext = unknown>({
|
|
60
|
-
reference,
|
|
61
|
-
options = {}
|
|
62
|
-
}: UseUpdateDocMutationOptions<AppModelType, TContext>) => {
|
|
63
|
-
const mutationKey = useMemo(() => [reference?.path], [reference?.path]);
|
|
64
|
-
|
|
65
|
-
return useMutation({
|
|
66
|
-
...options,
|
|
67
|
-
mutationFn: async ({ data }) => {
|
|
68
|
-
if (!reference) {
|
|
69
|
-
throw new Error("Reference is undefined");
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
await updateDoc<AppModelType, AppModelType>(reference, data);
|
|
73
|
-
const docSnap = await getDoc(reference);
|
|
74
|
-
return { ...(docSnap.data() as AppModelType), uid: docSnap.id };
|
|
75
|
-
},
|
|
76
|
-
mutationKey
|
|
77
|
-
});
|
|
78
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
QueryFilterConstraint as FBQueryFilterConstraint,
|
|
3
|
-
QueryCompositeFilterConstraint as FBQueryCompositeFilterConstraint,
|
|
4
|
-
WhereFilterOp,
|
|
5
|
-
or,
|
|
6
|
-
and,
|
|
7
|
-
where,
|
|
8
|
-
documentId
|
|
9
|
-
} from "firebase/firestore";
|
|
10
|
-
import { AppModel } from "../../../types/AppModel";
|
|
11
|
-
|
|
12
|
-
export type QueryFilterConstraint = FBQueryFilterConstraint | FBQueryCompositeFilterConstraint;
|
|
13
|
-
|
|
14
|
-
export type QueryElement<AppModelType extends AppModel = AppModel> = {
|
|
15
|
-
operator?: "OR" | "AND";
|
|
16
|
-
children?: QueryElement[];
|
|
17
|
-
field?: keyof (AppModelType & { documentId?: string[] });
|
|
18
|
-
value?: AppModelType[keyof AppModelType];
|
|
19
|
-
op?: WhereFilterOp;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type CompositeFilter<AppModelType extends AppModel = AppModel> = {
|
|
23
|
-
operator: "OR" | "AND";
|
|
24
|
-
children: QueryElement<AppModelType & { documentId?: string[] }>[];
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Constructs a composite or where query filter based on the provided query structure.
|
|
28
|
-
* It recursively builds query constraints using logical "or" or "and" operators.
|
|
29
|
-
*
|
|
30
|
-
* @group Utility
|
|
31
|
-
*
|
|
32
|
-
* @param {QueryElement<AppModelType>} query
|
|
33
|
-
*
|
|
34
|
-
* @returns {QueryFilterConstraint | null}
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```jsx
|
|
38
|
-
* export const MyComponent = () => {
|
|
39
|
-
* const filter = buildCompositeFilter({
|
|
40
|
-
* operator: "AND",
|
|
41
|
-
* children: [
|
|
42
|
-
* {
|
|
43
|
-
* field: "field",
|
|
44
|
-
* value: "value",
|
|
45
|
-
* op: "=="
|
|
46
|
-
* },
|
|
47
|
-
* ...(query ? [query] : [])
|
|
48
|
-
* ]
|
|
49
|
-
* });
|
|
50
|
-
* console.log(filter);
|
|
51
|
-
* };
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
export const buildCompositeFilter = <AppModelType extends AppModel = AppModel>(
|
|
56
|
-
query: QueryElement<AppModelType>
|
|
57
|
-
): QueryFilterConstraint | null => {
|
|
58
|
-
if (query.children) {
|
|
59
|
-
const queryConstraints = query.children.map(buildCompositeFilter).filter((constraint) => !!constraint);
|
|
60
|
-
|
|
61
|
-
if (queryConstraints.length <= 0) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return (query as CompositeFilter).operator === "OR" ? or(...queryConstraints) : and(...queryConstraints);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (query.field && query.op) {
|
|
69
|
-
return where(query.field === "documentId" ? documentId() : (query.field as string), query.op, query.value);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return null;
|
|
73
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
QueryNonFilterConstraint,
|
|
3
|
-
orderBy,
|
|
4
|
-
startAt,
|
|
5
|
-
startAfter,
|
|
6
|
-
endAt,
|
|
7
|
-
endBefore,
|
|
8
|
-
limit,
|
|
9
|
-
limitToLast
|
|
10
|
-
} from "firebase/firestore";
|
|
11
|
-
import { AppModel, NonFilterQueryConstraint } from "../../../types";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A generic mothod to build query constraints for firebase
|
|
15
|
-
*
|
|
16
|
-
* @group Utility
|
|
17
|
-
*
|
|
18
|
-
* @param {NonFilterQueryConstraint<AppModelType>} constraint
|
|
19
|
-
*
|
|
20
|
-
* @returns {QueryNonFilterConstraint}
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```jsx
|
|
24
|
-
* const firebaseConfig = {};
|
|
25
|
-
* export const constraint = useMemo(() => {
|
|
26
|
-
* return buildQueryConstraint({
|
|
27
|
-
* type: 'limit',
|
|
28
|
-
* limit: 1
|
|
29
|
-
* });
|
|
30
|
-
* };
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
export const buildQueryConstraint = <AppModelType extends AppModel = AppModel>(
|
|
35
|
-
constraint: NonFilterQueryConstraint<AppModelType>
|
|
36
|
-
): QueryNonFilterConstraint => {
|
|
37
|
-
switch (constraint.type) {
|
|
38
|
-
case "orderBy":
|
|
39
|
-
return orderBy(constraint.fieldPath as string, constraint.directionStr);
|
|
40
|
-
case "startAt":
|
|
41
|
-
return startAt(...constraint.arguments);
|
|
42
|
-
case "startAfter":
|
|
43
|
-
return startAfter(...constraint.arguments);
|
|
44
|
-
case "endAt":
|
|
45
|
-
return endAt(...constraint.arguments);
|
|
46
|
-
case "endBefore":
|
|
47
|
-
return endBefore(...constraint.arguments);
|
|
48
|
-
case "limit":
|
|
49
|
-
return limit(constraint.limit);
|
|
50
|
-
case "limitToLast":
|
|
51
|
-
return limitToLast(constraint.limit);
|
|
52
|
-
default:
|
|
53
|
-
throw new Error(`Unsupported constaint ${JSON.stringify(constraint)}`);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { getDocSnap, GetDocSnapOptions } from "./getDocSnap";
|
|
2
|
-
import { AppModel } from "../../../types";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @inline
|
|
6
|
-
*/
|
|
7
|
-
export type GetDocDataOptions<AppModelType extends AppModel = AppModel> = GetDocSnapOptions<AppModelType>;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Asynchronously retrieves document data from a specified database reference.
|
|
11
|
-
* Utilizes the helper function `getDocSnap` to fetch the document snapshot and
|
|
12
|
-
* checks if the document exists before returning its data.
|
|
13
|
-
*
|
|
14
|
-
* @group Utility
|
|
15
|
-
*
|
|
16
|
-
* @param {GetDocDataOptions<AppModelType>} options - The options for fetching document data.
|
|
17
|
-
*
|
|
18
|
-
* @returns {Promise<AppModelType | null>} Returns a promise that resolves to the document data if it exists, or null if the document does not exist.
|
|
19
|
-
*/
|
|
20
|
-
export const getDocData = async <AppModelType extends AppModel = AppModel>({
|
|
21
|
-
db,
|
|
22
|
-
reference,
|
|
23
|
-
path,
|
|
24
|
-
pathSegments
|
|
25
|
-
}: GetDocDataOptions<AppModelType>) => {
|
|
26
|
-
const docSnap = await getDocSnap<AppModelType>({ db, reference, path, pathSegments });
|
|
27
|
-
|
|
28
|
-
if (docSnap && docSnap.exists()) {
|
|
29
|
-
return { ...docSnap.data(), uid: docSnap.id };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return null;
|
|
33
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { CollectionReference, doc, DocumentReference, Firestore } from "firebase/firestore";
|
|
2
|
-
import { AppModel } from "../../../types";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @inline
|
|
6
|
-
*/
|
|
7
|
-
export type GetDocRefOptions<AppModelType extends AppModel = AppModel> = {
|
|
8
|
-
db: Firestore;
|
|
9
|
-
reference?: CollectionReference<AppModelType, AppModelType> | DocumentReference<AppModelType, AppModelType>;
|
|
10
|
-
path?: string;
|
|
11
|
-
pathSegments?: string[];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Retrieves a document reference based on provided database options.
|
|
16
|
-
* Either `reference` or `path`.
|
|
17
|
-
*
|
|
18
|
-
* @group Utility
|
|
19
|
-
*
|
|
20
|
-
* @param {GetDocRefOptions<AppModelType>} options - The options for building doc reference.
|
|
21
|
-
*
|
|
22
|
-
* @returns {DocumentReference<AppModelType, AppModelType>} Returns a document reference
|
|
23
|
-
*/
|
|
24
|
-
export const getDocRef = <AppModelType extends AppModel = AppModel>({
|
|
25
|
-
db,
|
|
26
|
-
reference,
|
|
27
|
-
path,
|
|
28
|
-
pathSegments
|
|
29
|
-
}: GetDocRefOptions<AppModelType>) => {
|
|
30
|
-
if ((!reference && !path) || (reference && !path)) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const docRef = !reference
|
|
35
|
-
? (doc(db, path as string, ...(pathSegments || [])) as DocumentReference<AppModelType, AppModelType>)
|
|
36
|
-
: reference.type === "collection"
|
|
37
|
-
? (doc(reference, path, ...(pathSegments || [])) as DocumentReference<AppModelType, AppModelType>)
|
|
38
|
-
: reference.type === "document"
|
|
39
|
-
? (doc(reference, path as string, ...(pathSegments || [])) as DocumentReference<AppModelType, AppModelType>)
|
|
40
|
-
: null;
|
|
41
|
-
|
|
42
|
-
return docRef;
|
|
43
|
-
};
|