react-query-firebase 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/react-native/firestore/index.ts +1 -0
- package/react-native/firestore/useCompositeFilter.ts +4 -4
- package/react-native/firestore/useQueryConstraints.ts +84 -0
- package/react-native/index.d.ts +0 -4
- package/react-native/index.js +0 -4
- package/react-native/index.ts +0 -4
- package/web/firestore/index.ts +1 -0
- package/web/firestore/useCompositeFilter.ts +4 -4
- package/web/firestore/useQueryConstraints.ts +93 -0
- package/web/index.d.ts +0 -4
- package/web/index.js +0 -4
- package/web/index.ts +0 -4
- package/react-native/analytics/index.d.ts +0 -3
- package/react-native/analytics/index.js +0 -3
- package/react-native/analytics/useAnalytics.d.ts +0 -5
- package/react-native/analytics/useAnalytics.js +0 -10
- package/react-native/analytics/useLogEvent.d.ts +0 -17
- package/react-native/analytics/useLogEvent.js +0 -21
- package/react-native/analytics/useSetAnalyticsCollectionEnabled.d.ts +0 -10
- package/react-native/analytics/useSetAnalyticsCollectionEnabled.js +0 -16
- package/react-native/auth/index.d.ts +0 -12
- package/react-native/auth/index.js +0 -12
- package/react-native/auth/mutation-keys.d.ts +0 -7
- package/react-native/auth/mutation-keys.js +0 -19
- package/react-native/auth/useAuth.d.ts +0 -5
- package/react-native/auth/useAuth.js +0 -10
- package/react-native/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +0 -15
- package/react-native/auth/useCreateUserWitEmailAndPasswordMutation.js +0 -19
- package/react-native/auth/useCurrentUser.d.ts +0 -6
- package/react-native/auth/useCurrentUser.js +0 -20
- package/react-native/auth/useIdToken.d.ts +0 -30
- package/react-native/auth/useIdToken.js +0 -66
- package/react-native/auth/useReauthenticateWitCredentialMutation.d.ts +0 -16
- package/react-native/auth/useReauthenticateWitCredentialMutation.js +0 -18
- package/react-native/auth/useReauthenticateWitRedirectMutation.d.ts +0 -17
- package/react-native/auth/useReauthenticateWitRedirectMutation.js +0 -18
- package/react-native/auth/useSendEmailVerificationMutation.d.ts +0 -13
- package/react-native/auth/useSendEmailVerificationMutation.js +0 -16
- package/react-native/auth/useSignInWitEmailAndPasswordMutation.d.ts +0 -15
- package/react-native/auth/useSignInWitEmailAndPasswordMutation.js +0 -19
- package/react-native/auth/useSignInWitRedirectMutation.d.ts +0 -14
- package/react-native/auth/useSignInWitRedirectMutation.js +0 -18
- package/react-native/auth/useSignOutMutation.d.ts +0 -10
- package/react-native/auth/useSignOutMutation.js +0 -19
- package/react-native/auth/useUpdateProfileMutation.d.ts +0 -15
- package/react-native/auth/useUpdateProfileMutation.js +0 -17
- package/react-native/firestore/index.d.ts +0 -16
- package/react-native/firestore/index.js +0 -16
- package/react-native/firestore/useAddDocMutation.d.ts +0 -21
- package/react-native/firestore/useAddDocMutation.js +0 -25
- package/react-native/firestore/useBatchWrite.d.ts +0 -15
- package/react-native/firestore/useBatchWrite.js +0 -21
- package/react-native/firestore/useCollectionReference.d.ts +0 -18
- package/react-native/firestore/useCollectionReference.js +0 -22
- package/react-native/firestore/useCompositeFilter.d.ts +0 -32
- package/react-native/firestore/useCompositeFilter.js +0 -42
- package/react-native/firestore/useCountQuery.d.ts +0 -23
- package/react-native/firestore/useCountQuery.js +0 -30
- package/react-native/firestore/useDeleteDocMutation.d.ts +0 -18
- package/react-native/firestore/useDeleteDocMutation.js +0 -23
- package/react-native/firestore/useDocReference.d.ts +0 -19
- package/react-native/firestore/useDocReference.js +0 -36
- package/react-native/firestore/useDocReferences.d.ts +0 -23
- package/react-native/firestore/useDocReferences.js +0 -29
- package/react-native/firestore/useFirestore.d.ts +0 -7
- package/react-native/firestore/useFirestore.js +0 -12
- package/react-native/firestore/useGetDocData.d.ts +0 -18
- package/react-native/firestore/useGetDocData.js +0 -18
- package/react-native/firestore/useGetRealtimeDocData.d.ts +0 -57
- package/react-native/firestore/useGetRealtimeDocData.js +0 -56
- package/react-native/firestore/useInfiniteQuery.d.ts +0 -17
- package/react-native/firestore/useInfiniteQuery.js +0 -28
- package/react-native/firestore/useQuery.d.ts +0 -24
- package/react-native/firestore/useQuery.js +0 -34
- package/react-native/firestore/useRunTransaction.d.ts +0 -15
- package/react-native/firestore/useRunTransaction.js +0 -19
- package/react-native/firestore/useSetDocMutation.d.ts +0 -20
- package/react-native/firestore/useSetDocMutation.js +0 -25
- package/react-native/firestore/useUpdateDocMutation.d.ts +0 -30
- package/react-native/firestore/useUpdateDocMutation.js +0 -37
- package/react-native/firestore/utils/getDocData.d.ts +0 -18
- package/react-native/firestore/utils/getDocData.js +0 -22
- package/react-native/firestore/utils/getDocRef.d.ts +0 -19
- package/react-native/firestore/utils/getDocRef.js +0 -21
- package/react-native/firestore/utils/getDocSnap.d.ts +0 -20
- package/react-native/firestore/utils/getDocSnap.js +0 -25
- package/react-native/remoteConfig/index.d.ts +0 -3
- package/react-native/remoteConfig/index.js +0 -3
- package/react-native/remoteConfig/useFetchAndActivate.d.ts +0 -11
- package/react-native/remoteConfig/useFetchAndActivate.js +0 -31
- package/react-native/remoteConfig/useGetValue.d.ts +0 -7
- package/react-native/remoteConfig/useGetValue.js +0 -15
- package/react-native/remoteConfig/useRemoteConfig.d.ts +0 -5
- package/react-native/remoteConfig/useRemoteConfig.js +0 -10
- package/web/analytics/index.d.ts +0 -3
- package/web/analytics/index.js +0 -3
- package/web/analytics/useAnalytics.d.ts +0 -5
- package/web/analytics/useAnalytics.js +0 -10
- package/web/analytics/useLogEvent.d.ts +0 -17
- package/web/analytics/useLogEvent.js +0 -21
- package/web/analytics/useSetAnalyticsCollectionEnabled.d.ts +0 -10
- package/web/analytics/useSetAnalyticsCollectionEnabled.js +0 -16
- package/web/auth/index.d.ts +0 -13
- package/web/auth/index.js +0 -13
- package/web/auth/mutation-keys.d.ts +0 -7
- package/web/auth/mutation-keys.js +0 -19
- package/web/auth/useAuth.d.ts +0 -5
- package/web/auth/useAuth.js +0 -10
- package/web/auth/useAuthStateReady.d.ts +0 -6
- package/web/auth/useAuthStateReady.js +0 -19
- package/web/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +0 -15
- package/web/auth/useCreateUserWitEmailAndPasswordMutation.js +0 -19
- package/web/auth/useCurrentUser.d.ts +0 -6
- package/web/auth/useCurrentUser.js +0 -20
- package/web/auth/useIdToken.d.ts +0 -30
- package/web/auth/useIdToken.js +0 -66
- package/web/auth/useReauthenticateWitCredentialMutation.d.ts +0 -16
- package/web/auth/useReauthenticateWitCredentialMutation.js +0 -18
- package/web/auth/useReauthenticateWitRedirectMutation.d.ts +0 -17
- package/web/auth/useReauthenticateWitRedirectMutation.js +0 -18
- package/web/auth/useSendEmailVerificationMutation.d.ts +0 -13
- package/web/auth/useSendEmailVerificationMutation.js +0 -16
- package/web/auth/useSignInWitEmailAndPasswordMutation.d.ts +0 -15
- package/web/auth/useSignInWitEmailAndPasswordMutation.js +0 -19
- package/web/auth/useSignInWitRedirectMutation.d.ts +0 -14
- package/web/auth/useSignInWitRedirectMutation.js +0 -18
- package/web/auth/useSignOutMutation.d.ts +0 -10
- package/web/auth/useSignOutMutation.js +0 -19
- package/web/auth/useUpdateProfileMutation.d.ts +0 -15
- package/web/auth/useUpdateProfileMutation.js +0 -17
- package/web/firestore/index.d.ts +0 -16
- package/web/firestore/index.js +0 -16
- package/web/firestore/useAddDocMutation.d.ts +0 -23
- package/web/firestore/useAddDocMutation.js +0 -26
- package/web/firestore/useBatchWrite.d.ts +0 -15
- package/web/firestore/useBatchWrite.js +0 -21
- package/web/firestore/useCollectionReference.d.ts +0 -18
- package/web/firestore/useCollectionReference.js +0 -24
- package/web/firestore/useCompositeFilter.d.ts +0 -32
- package/web/firestore/useCompositeFilter.js +0 -41
- package/web/firestore/useCountQuery.d.ts +0 -23
- package/web/firestore/useCountQuery.js +0 -30
- package/web/firestore/useDeleteDocMutation.d.ts +0 -18
- package/web/firestore/useDeleteDocMutation.js +0 -23
- package/web/firestore/useDocReference.d.ts +0 -19
- package/web/firestore/useDocReference.js +0 -45
- package/web/firestore/useDocReferences.d.ts +0 -23
- package/web/firestore/useDocReferences.js +0 -31
- package/web/firestore/useFirestore.d.ts +0 -7
- package/web/firestore/useFirestore.js +0 -12
- package/web/firestore/useGetDocData.d.ts +0 -18
- package/web/firestore/useGetDocData.js +0 -18
- package/web/firestore/useGetRealtimeDocData.d.ts +0 -57
- package/web/firestore/useGetRealtimeDocData.js +0 -56
- package/web/firestore/useInfiniteQuery.d.ts +0 -18
- package/web/firestore/useInfiniteQuery.js +0 -28
- package/web/firestore/useQuery.d.ts +0 -25
- package/web/firestore/useQuery.js +0 -34
- package/web/firestore/useRunTransaction.d.ts +0 -15
- package/web/firestore/useRunTransaction.js +0 -19
- package/web/firestore/useSetDocMutation.d.ts +0 -20
- package/web/firestore/useSetDocMutation.js +0 -25
- package/web/firestore/useUpdateDocMutation.d.ts +0 -31
- package/web/firestore/useUpdateDocMutation.js +0 -37
- package/web/firestore/utils/getDocData.d.ts +0 -18
- package/web/firestore/utils/getDocData.js +0 -22
- package/web/firestore/utils/getDocRef.d.ts +0 -19
- package/web/firestore/utils/getDocRef.js +0 -25
- package/web/firestore/utils/getDocSnap.d.ts +0 -20
- package/web/firestore/utils/getDocSnap.js +0 -25
- package/web/remoteConfig/index.d.ts +0 -3
- package/web/remoteConfig/index.js +0 -3
- package/web/remoteConfig/useFetchAndActivate.d.ts +0 -11
- package/web/remoteConfig/useFetchAndActivate.js +0 -31
- package/web/remoteConfig/useGetValue.d.ts +0 -7
- package/web/remoteConfig/useGetValue.js +0 -15
- package/web/remoteConfig/useRemoteConfig.d.ts +0 -5
- package/web/remoteConfig/useRemoteConfig.js +0 -10
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { doc } from "@react-native-firebase/firestore";
|
|
2
|
-
/**
|
|
3
|
-
* Retrieves a document reference based on provided database options.
|
|
4
|
-
* Either `reference` or `path` must be provided, not both.
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} options - The options for getting a document reference.
|
|
7
|
-
* @param {FirebaseFirestoreTypes.Module} options.db - The Firestore database instance.
|
|
8
|
-
* @param {FirebaseFirestoreTypes.DocumentReference | FirebaseFirestoreTypes.CollectionReference | null} [options.reference] - Reference to a document or collection.
|
|
9
|
-
* @param {string | null} [options.path] - Path to the document.
|
|
10
|
-
* @param {string[] | null} [options.pathSegments] - Additional path segments if any.
|
|
11
|
-
* @returns {FirebaseFirestoreTypes.DocumentReference<AppModelType>} The document reference.
|
|
12
|
-
*/
|
|
13
|
-
export const getDocRef = async ({ db, reference, path, pathSegments }) => {
|
|
14
|
-
if (!reference && !path) {
|
|
15
|
-
throw new Error("One of the options must be provided: path or reference.");
|
|
16
|
-
}
|
|
17
|
-
const docRef = !reference
|
|
18
|
-
? doc(db, path, ...(pathSegments || []))
|
|
19
|
-
: doc(reference, path, ...(pathSegments || []));
|
|
20
|
-
return docRef;
|
|
21
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FirebaseFirestoreTypes } from "@react-native-firebase/firestore";
|
|
2
|
-
import { GetDocRefOptions } from "./getDocRef";
|
|
3
|
-
export type GetDocSnapOptions<AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData> = GetDocRefOptions<AppModelType>;
|
|
4
|
-
/**
|
|
5
|
-
* Asynchronously retrieves a document snapshot from Firestore using a specified document reference
|
|
6
|
-
* or path information. This function handles getting the appropriate document reference based on
|
|
7
|
-
* the parameters provided, and then fetches the document data from Firestore.
|
|
8
|
-
*
|
|
9
|
-
* @param {GetDocSnapOptions<AppModelType, DbModelType>} options - An object containing options
|
|
10
|
-
* for retrieving the document
|
|
11
|
-
* snapshot.
|
|
12
|
-
* @param {DocumentData} options.db - The Firestore database instance to perform the operation on.
|
|
13
|
-
* @param {string} options.reference - A string representing a direct Firestore document reference.
|
|
14
|
-
* @param {string} options.path - A Firestore path string leading to the document.
|
|
15
|
-
* @param {string[]} options.pathSegments - An array of path segments to build the Firestore path.
|
|
16
|
-
* @returns {Promise<FirebaseFirestoreTypes.DocumentData | null>} A promise that resolves to the document data if the
|
|
17
|
-
* document exists, or `null` if the document does not exist
|
|
18
|
-
* or if the reference could not be obtained.
|
|
19
|
-
*/
|
|
20
|
-
export declare const getDocSnap: <AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData>({ db, reference, path, pathSegments }: GetDocSnapOptions<AppModelType>) => Promise<FirebaseFirestoreTypes.DocumentSnapshot<AppModelType> | null>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getDoc as firestoreGetDoc } from "@react-native-firebase/firestore";
|
|
2
|
-
import { getDocRef } from "./getDocRef";
|
|
3
|
-
/**
|
|
4
|
-
* Asynchronously retrieves a document snapshot from Firestore using a specified document reference
|
|
5
|
-
* or path information. This function handles getting the appropriate document reference based on
|
|
6
|
-
* the parameters provided, and then fetches the document data from Firestore.
|
|
7
|
-
*
|
|
8
|
-
* @param {GetDocSnapOptions<AppModelType, DbModelType>} options - An object containing options
|
|
9
|
-
* for retrieving the document
|
|
10
|
-
* snapshot.
|
|
11
|
-
* @param {DocumentData} options.db - The Firestore database instance to perform the operation on.
|
|
12
|
-
* @param {string} options.reference - A string representing a direct Firestore document reference.
|
|
13
|
-
* @param {string} options.path - A Firestore path string leading to the document.
|
|
14
|
-
* @param {string[]} options.pathSegments - An array of path segments to build the Firestore path.
|
|
15
|
-
* @returns {Promise<FirebaseFirestoreTypes.DocumentData | null>} A promise that resolves to the document data if the
|
|
16
|
-
* document exists, or `null` if the document does not exist
|
|
17
|
-
* or if the reference could not be obtained.
|
|
18
|
-
*/
|
|
19
|
-
export const getDocSnap = async ({ db, reference, path, pathSegments }) => {
|
|
20
|
-
const docRef = await getDocRef({ db, reference, path, pathSegments });
|
|
21
|
-
if (docRef) {
|
|
22
|
-
return await firestoreGetDoc(docRef);
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom hook to fetch and activate remote configuration settings.
|
|
3
|
-
* Initializes remote configuration, fetches, activates it, and tracks the fetch status.
|
|
4
|
-
* @returns {Object} An object containing:
|
|
5
|
-
* - {Function} fetchAndActivate - Callback function to fetch and activate remote configuration.
|
|
6
|
-
* - {Boolean} isFetched - Boolean representing whether the fetch-and-activate process completed.
|
|
7
|
-
*/
|
|
8
|
-
export declare const useFetchAndActivate: () => {
|
|
9
|
-
fetchAndActivate: () => Promise<void>;
|
|
10
|
-
isFetched: boolean;
|
|
11
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useRemoteConfig } from "./useRemoteConfig";
|
|
2
|
-
import { ensureInitialized, fetchAndActivate } from "@react-native-firebase/remote-config";
|
|
3
|
-
import { useCallback, useMemo, useState } from "react";
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook to fetch and activate remote configuration settings.
|
|
6
|
-
* Initializes remote configuration, fetches, activates it, and tracks the fetch status.
|
|
7
|
-
* @returns {Object} An object containing:
|
|
8
|
-
* - {Function} fetchAndActivate - Callback function to fetch and activate remote configuration.
|
|
9
|
-
* - {Boolean} isFetched - Boolean representing whether the fetch-and-activate process completed.
|
|
10
|
-
*/
|
|
11
|
-
export const useFetchAndActivate = () => {
|
|
12
|
-
const remoteConfig = useRemoteConfig();
|
|
13
|
-
const [isFetched, setIsFetched] = useState(false);
|
|
14
|
-
const fetchAndActivateCallback = useCallback(async () => {
|
|
15
|
-
try {
|
|
16
|
-
if (remoteConfig) {
|
|
17
|
-
await ensureInitialized(remoteConfig);
|
|
18
|
-
await fetchAndActivate(remoteConfig);
|
|
19
|
-
setIsFetched(true);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
setIsFetched(true);
|
|
24
|
-
console.log(`Cannot read remote config: ${e?.message}`);
|
|
25
|
-
}
|
|
26
|
-
}, [remoteConfig]);
|
|
27
|
-
return useMemo(() => ({
|
|
28
|
-
fetchAndActivate: fetchAndActivateCallback,
|
|
29
|
-
isFetched
|
|
30
|
-
}), [isFetched, fetchAndActivateCallback]);
|
|
31
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom hook to retrieve a value associated with a specified key from remote configuration.
|
|
3
|
-
* Utilizes memoization to optimize performance by recalculating the result only if dependencies change.
|
|
4
|
-
* @param {string} key - The key for which the corresponding value is to be fetched from the remote configuration.
|
|
5
|
-
* @returns {any | null} The value associated with the specified key if available, otherwise null.
|
|
6
|
-
*/
|
|
7
|
-
export declare const useGetValue: (key: string) => import("@react-native-firebase/remote-config").FirebaseRemoteConfigTypes.ConfigValue | null;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getValue } from "@react-native-firebase/remote-config";
|
|
2
|
-
import { useRemoteConfig } from "./useRemoteConfig";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook to retrieve a value associated with a specified key from remote configuration.
|
|
6
|
-
* Utilizes memoization to optimize performance by recalculating the result only if dependencies change.
|
|
7
|
-
* @param {string} key - The key for which the corresponding value is to be fetched from the remote configuration.
|
|
8
|
-
* @returns {any | null} The value associated with the specified key if available, otherwise null.
|
|
9
|
-
*/
|
|
10
|
-
export const useGetValue = (key) => {
|
|
11
|
-
const remoteConfig = useRemoteConfig();
|
|
12
|
-
return useMemo(() => {
|
|
13
|
-
return remoteConfig ? getValue(remoteConfig, key) : null;
|
|
14
|
-
}, [remoteConfig, key]);
|
|
15
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to access the Firebase Remote Config instance from the context.
|
|
3
|
-
* @returns {RemoteConfig} The remoteConfig object from the Firebase context.
|
|
4
|
-
*/
|
|
5
|
-
export declare const useRemoteConfig: () => import("@react-native-firebase/remote-config").FirebaseRemoteConfigTypes.Module;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { FirebaseContext } from "../context/FirebaseContext";
|
|
3
|
-
/**
|
|
4
|
-
* Hook to access the Firebase Remote Config instance from the context.
|
|
5
|
-
* @returns {RemoteConfig} The remoteConfig object from the Firebase context.
|
|
6
|
-
*/
|
|
7
|
-
export const useRemoteConfig = () => {
|
|
8
|
-
const { remoteConfig } = useContext(FirebaseContext);
|
|
9
|
-
return remoteConfig;
|
|
10
|
-
};
|
package/web/analytics/index.d.ts
DELETED
package/web/analytics/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { FirebaseContext } from "../context/FirebaseContext";
|
|
3
|
-
/**
|
|
4
|
-
* Hook to access Firebase analytics from the Firebase context.
|
|
5
|
-
* @returns {any} The analytics object from the Firebase context.
|
|
6
|
-
*/
|
|
7
|
-
export const useAnalytics = () => {
|
|
8
|
-
const { analytics } = useContext(FirebaseContext);
|
|
9
|
-
return analytics;
|
|
10
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
type UseLogEventOptions = {
|
|
2
|
-
eventName: string;
|
|
3
|
-
eventParams?: {
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Custom hook to create a log event function that logs an analytics event with specified parameters.
|
|
9
|
-
* @param {Object} options - The options for the log event.
|
|
10
|
-
* @param {string} options.eventName - The name of the event to be logged.
|
|
11
|
-
* @param {Object} options.eventParams - The parameters to be sent along with the event.
|
|
12
|
-
* @returns {Object} An object containing a `logEvent` function that, when called, logs the event.
|
|
13
|
-
*/
|
|
14
|
-
export declare const useLogEvent: ({ eventName, eventParams }: UseLogEventOptions) => {
|
|
15
|
-
logEvent: () => void;
|
|
16
|
-
};
|
|
17
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { logEvent } from "firebase/analytics";
|
|
2
|
-
import { useAnalytics } from "./useAnalytics";
|
|
3
|
-
import { useCallback, useMemo } from "react";
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook to create a log event function that logs an analytics event with specified parameters.
|
|
6
|
-
* @param {Object} options - The options for the log event.
|
|
7
|
-
* @param {string} options.eventName - The name of the event to be logged.
|
|
8
|
-
* @param {Object} options.eventParams - The parameters to be sent along with the event.
|
|
9
|
-
* @returns {Object} An object containing a `logEvent` function that, when called, logs the event.
|
|
10
|
-
*/
|
|
11
|
-
export const useLogEvent = ({ eventName, eventParams }) => {
|
|
12
|
-
const analytics = useAnalytics();
|
|
13
|
-
const logEventCallback = useCallback(() => {
|
|
14
|
-
if (analytics) {
|
|
15
|
-
logEvent(analytics, eventName, eventParams);
|
|
16
|
-
}
|
|
17
|
-
}, [eventName, eventParams, analytics]);
|
|
18
|
-
return useMemo(() => ({
|
|
19
|
-
logEvent: logEventCallback
|
|
20
|
-
}), [logEventCallback]);
|
|
21
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type UseSetAnalyticsCollectionEnabledOptions = {
|
|
2
|
-
enabled?: boolean;
|
|
3
|
-
};
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook to enable or disable analytics collection
|
|
6
|
-
* @param {Object} options - The options for hook.
|
|
7
|
-
* @param {string} options.enabled - Flag that identifies if analytics collection is enabled.
|
|
8
|
-
*/
|
|
9
|
-
export declare const useSetAnalyticsCollectionEnabled: ({ enabled }: UseSetAnalyticsCollectionEnabledOptions) => void;
|
|
10
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { setAnalyticsCollectionEnabled } from "firebase/analytics";
|
|
2
|
-
import { useAnalytics } from "./useAnalytics";
|
|
3
|
-
import { useEffect } from "react";
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook to enable or disable analytics collection
|
|
6
|
-
* @param {Object} options - The options for hook.
|
|
7
|
-
* @param {string} options.enabled - Flag that identifies if analytics collection is enabled.
|
|
8
|
-
*/
|
|
9
|
-
export const useSetAnalyticsCollectionEnabled = ({ enabled = false }) => {
|
|
10
|
-
const analytics = useAnalytics();
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (analytics) {
|
|
13
|
-
setAnalyticsCollectionEnabled(analytics, enabled);
|
|
14
|
-
}
|
|
15
|
-
}, [analytics, enabled]);
|
|
16
|
-
};
|
package/web/auth/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from "./mutation-keys";
|
|
2
|
-
export * from "./useAuth";
|
|
3
|
-
export * from "./useCreateUserWitEmailAndPasswordMutation";
|
|
4
|
-
export * from "./useSendEmailVerificationMutation";
|
|
5
|
-
export * from "./useSignInWitEmailAndPasswordMutation";
|
|
6
|
-
export * from "./useCurrentUser";
|
|
7
|
-
export * from "./useAuthStateReady";
|
|
8
|
-
export * from "./useSignInWitRedirectMutation";
|
|
9
|
-
export * from "./useUpdateProfileMutation";
|
|
10
|
-
export * from "./useSignOutMutation";
|
|
11
|
-
export * from "./useIdToken";
|
|
12
|
-
export * from "./useReauthenticateWitCredentialMutation";
|
|
13
|
-
export * from "./useReauthenticateWitRedirectMutation";
|
package/web/auth/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from "./mutation-keys";
|
|
2
|
-
export * from "./useAuth";
|
|
3
|
-
export * from "./useCreateUserWitEmailAndPasswordMutation";
|
|
4
|
-
export * from "./useSendEmailVerificationMutation";
|
|
5
|
-
export * from "./useSignInWitEmailAndPasswordMutation";
|
|
6
|
-
export * from "./useCurrentUser";
|
|
7
|
-
export * from "./useAuthStateReady";
|
|
8
|
-
export * from "./useSignInWitRedirectMutation";
|
|
9
|
-
export * from "./useUpdateProfileMutation";
|
|
10
|
-
export * from "./useSignOutMutation";
|
|
11
|
-
export * from "./useIdToken";
|
|
12
|
-
export * from "./useReauthenticateWitCredentialMutation";
|
|
13
|
-
export * from "./useReauthenticateWitRedirectMutation";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"];
|
|
2
|
-
export declare const SEND_EMAIL_VERIFICATION_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"];
|
|
3
|
-
export declare const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"];
|
|
4
|
-
export declare const SIGN_IN_WITH_REDIRECT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"];
|
|
5
|
-
export declare const SIGN_OUT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_OUT"];
|
|
6
|
-
export declare const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"];
|
|
7
|
-
export declare const REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_CREDENTIAL"];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
|
|
2
|
-
"FIREBASE",
|
|
3
|
-
"AUTH",
|
|
4
|
-
"CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"
|
|
5
|
-
];
|
|
6
|
-
export const SEND_EMAIL_VERIFICATION_MUTATION_KEY = ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"];
|
|
7
|
-
export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
|
|
8
|
-
"FIREBASE",
|
|
9
|
-
"AUTH",
|
|
10
|
-
"SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"
|
|
11
|
-
];
|
|
12
|
-
export const SIGN_IN_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"];
|
|
13
|
-
export const SIGN_OUT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_OUT"];
|
|
14
|
-
export const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"];
|
|
15
|
-
export const REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY = [
|
|
16
|
-
"FIREBASE",
|
|
17
|
-
"AUTH",
|
|
18
|
-
"REAUTHENTICATE_WITH_CREDENTIAL"
|
|
19
|
-
];
|
package/web/auth/useAuth.d.ts
DELETED
package/web/auth/useAuth.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { FirebaseContext } from "../context/FirebaseContext";
|
|
3
|
-
/**
|
|
4
|
-
* Custom hook to retrieve the authentication object from the Firebase context.
|
|
5
|
-
* @returns {Auth} The authentication object from the Firebase context.
|
|
6
|
-
*/
|
|
7
|
-
export const useAuth = () => {
|
|
8
|
-
const { auth } = useContext(FirebaseContext);
|
|
9
|
-
return auth;
|
|
10
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A custom hook that determines if the Firebase authentication state is ready.
|
|
3
|
-
* It uses Firebase authentication to check if the auth state is ready and updates the state accordingly.
|
|
4
|
-
* @returns {boolean} Indicates whether the authentication state is ready.
|
|
5
|
-
*/
|
|
6
|
-
export declare const useAuthStateReady: () => boolean;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "./useAuth";
|
|
2
|
-
import { useCallback, useEffect, useState } from "react";
|
|
3
|
-
/**
|
|
4
|
-
* A custom hook that determines if the Firebase authentication state is ready.
|
|
5
|
-
* It uses Firebase authentication to check if the auth state is ready and updates the state accordingly.
|
|
6
|
-
* @returns {boolean} Indicates whether the authentication state is ready.
|
|
7
|
-
*/
|
|
8
|
-
export const useAuthStateReady = () => {
|
|
9
|
-
const firebaseAuth = useAuth();
|
|
10
|
-
const [isAuthStateReady, setIsAuthStateReady] = useState(false);
|
|
11
|
-
const callback = useCallback(async () => {
|
|
12
|
-
await firebaseAuth.authStateReady();
|
|
13
|
-
setIsAuthStateReady(true);
|
|
14
|
-
}, [firebaseAuth]);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
callback();
|
|
17
|
-
}, [callback]);
|
|
18
|
-
return isAuthStateReady;
|
|
19
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
-
import { UserCredential } from "firebase/auth";
|
|
3
|
-
import { FirebaseError } from "firebase/app";
|
|
4
|
-
export type UseCreateUserWitEmailAndPasswordMutationVariables = {
|
|
5
|
-
email: string;
|
|
6
|
-
password: string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Custom hook to initiate a user creation process using email and password with Firebase authentication.
|
|
10
|
-
* This hook utilizes the `useMutation` functionality to support creating new user credentials asynchronously.
|
|
11
|
-
*
|
|
12
|
-
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional settings to customize the mutation behavior, excluding `mutationKey` and `mutationFn`.
|
|
13
|
-
* @returns {UseMutationResult<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>} The result of the mutation which includes status, user credentials, and error information if any.
|
|
14
|
-
*/
|
|
15
|
-
export declare const useCreateUserWitEmailAndPasswordMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useMutation } from "@tanstack/react-query";
|
|
2
|
-
import { createUserWithEmailAndPassword } from "firebase/auth";
|
|
3
|
-
import { useAuth } from "./useAuth";
|
|
4
|
-
import { CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY } from "./mutation-keys";
|
|
5
|
-
/**
|
|
6
|
-
* Custom hook to initiate a user creation process using email and password with Firebase authentication.
|
|
7
|
-
* This hook utilizes the `useMutation` functionality to support creating new user credentials asynchronously.
|
|
8
|
-
*
|
|
9
|
-
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional settings to customize the mutation behavior, excluding `mutationKey` and `mutationFn`.
|
|
10
|
-
* @returns {UseMutationResult<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>} The result of the mutation which includes status, user credentials, and error information if any.
|
|
11
|
-
*/
|
|
12
|
-
export const useCreateUserWitEmailAndPasswordMutation = (options = {}) => {
|
|
13
|
-
const firebaseAuth = useAuth();
|
|
14
|
-
return useMutation({
|
|
15
|
-
...options,
|
|
16
|
-
mutationFn: async ({ email, password }) => await createUserWithEmailAndPassword(firebaseAuth, email, password),
|
|
17
|
-
mutationKey: CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY
|
|
18
|
-
});
|
|
19
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook that provides the current authenticated user from Firebase Auth.
|
|
3
|
-
* It listens for changes in the authentication state and updates the user accordingly.
|
|
4
|
-
* @returns {Object|null} The current authenticated user object or null if no user is authenticated.
|
|
5
|
-
*/
|
|
6
|
-
export declare const useCurrentUser: () => import("@firebase/auth").User | null;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useAuth } from "./useAuth";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
/**
|
|
4
|
-
* Hook that provides the current authenticated user from Firebase Auth.
|
|
5
|
-
* It listens for changes in the authentication state and updates the user accordingly.
|
|
6
|
-
* @returns {Object|null} The current authenticated user object or null if no user is authenticated.
|
|
7
|
-
*/
|
|
8
|
-
export const useCurrentUser = () => {
|
|
9
|
-
const firebaseAuth = useAuth();
|
|
10
|
-
const [currentUser, setCurrentUser] = useState(firebaseAuth.currentUser);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
const unsubscribe = firebaseAuth.onAuthStateChanged((user) => {
|
|
13
|
-
setCurrentUser(user);
|
|
14
|
-
});
|
|
15
|
-
return () => {
|
|
16
|
-
unsubscribe();
|
|
17
|
-
};
|
|
18
|
-
}, [currentUser?.uid, firebaseAuth]);
|
|
19
|
-
return currentUser;
|
|
20
|
-
};
|
package/web/auth/useIdToken.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @inline
|
|
3
|
-
*/
|
|
4
|
-
export type UseIdTokenResult = {
|
|
5
|
-
idToken: string;
|
|
6
|
-
refresh: () => Promise<string | undefined>;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* A hook to manage the ID token.
|
|
10
|
-
* It monitors changes to the ID token and provides the token itself along with a refresh method to update the token when needed.
|
|
11
|
-
*
|
|
12
|
-
* @group Hook
|
|
13
|
-
*
|
|
14
|
-
* @returns {UseIdTokenResult}
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```jsx
|
|
18
|
-
* export const MyComponent = () => {
|
|
19
|
-
* const result = useIdToken();
|
|
20
|
-
* useEffect(() => {
|
|
21
|
-
* const timeout = setTimeout(() => {
|
|
22
|
-
* result.refresh();
|
|
23
|
-
* }, 5000);
|
|
24
|
-
* return () => clearTimeout();
|
|
25
|
-
* }, [])
|
|
26
|
-
* console.log(resilt.idToken);
|
|
27
|
-
* };
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export declare const useIdToken: () => UseIdTokenResult;
|
package/web/auth/useIdToken.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
import { useCurrentUser } from "./useCurrentUser";
|
|
3
|
-
import { onIdTokenChanged } from "firebase/auth";
|
|
4
|
-
import { useAuth } from "./useAuth";
|
|
5
|
-
/**
|
|
6
|
-
* A hook to manage the ID token.
|
|
7
|
-
* It monitors changes to the ID token and provides the token itself along with a refresh method to update the token when needed.
|
|
8
|
-
*
|
|
9
|
-
* @group Hook
|
|
10
|
-
*
|
|
11
|
-
* @returns {UseIdTokenResult}
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```jsx
|
|
15
|
-
* export const MyComponent = () => {
|
|
16
|
-
* const result = useIdToken();
|
|
17
|
-
* useEffect(() => {
|
|
18
|
-
* const timeout = setTimeout(() => {
|
|
19
|
-
* result.refresh();
|
|
20
|
-
* }, 5000);
|
|
21
|
-
* return () => clearTimeout();
|
|
22
|
-
* }, [])
|
|
23
|
-
* console.log(resilt.idToken);
|
|
24
|
-
* };
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export const useIdToken = () => {
|
|
28
|
-
const auth = useAuth();
|
|
29
|
-
const currentUser = useCurrentUser();
|
|
30
|
-
const [idToken, setIdToken] = useState("");
|
|
31
|
-
const callback = useCallback(async () => {
|
|
32
|
-
if (!currentUser) {
|
|
33
|
-
setIdToken("");
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const idToken = await currentUser.getIdToken();
|
|
37
|
-
setIdToken(idToken);
|
|
38
|
-
}, [currentUser]);
|
|
39
|
-
const refresh = useCallback(async () => {
|
|
40
|
-
if (!currentUser) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const idToken = await currentUser.getIdToken(true);
|
|
44
|
-
return idToken;
|
|
45
|
-
}, [currentUser]);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
callback();
|
|
48
|
-
}, [callback]);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
const unsubscribe = onIdTokenChanged(auth, (user) => {
|
|
51
|
-
if (user) {
|
|
52
|
-
user.getIdToken().then((idToken) => {
|
|
53
|
-
setIdToken(idToken);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
setIdToken("");
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return () => unsubscribe();
|
|
61
|
-
}, [setIdToken, auth]);
|
|
62
|
-
return {
|
|
63
|
-
idToken,
|
|
64
|
-
refresh
|
|
65
|
-
};
|
|
66
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
-
import { User, AuthCredential, UserCredential } from "firebase/auth";
|
|
3
|
-
import { FirebaseError } from "firebase/app";
|
|
4
|
-
export type UseReauthenticateWitCredentialMutationVariables = {
|
|
5
|
-
credential: AuthCredential;
|
|
6
|
-
user: User;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Custom hook to create a mutation for re-authenticating a user with a given credential.
|
|
10
|
-
* This hook utilizes useMutation from React Query to manage the asynchronous re-authentication
|
|
11
|
-
* process with Firebase credentials. It omits the default "mutationKey" and "mutationFn" options.
|
|
12
|
-
*
|
|
13
|
-
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional mutation options excluding "mutationKey" and "mutationFn".
|
|
14
|
-
* @returns {UseMutationResult<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>} A useMutation result object managing the loading, error, and result state of the re-authentication mutation.
|
|
15
|
-
*/
|
|
16
|
-
export declare const useReauthenticateWitCredentialMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useMutation } from "@tanstack/react-query";
|
|
2
|
-
import { reauthenticateWithCredential } from "firebase/auth";
|
|
3
|
-
import { REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY } from "./mutation-keys";
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook to create a mutation for re-authenticating a user with a given credential.
|
|
6
|
-
* This hook utilizes useMutation from React Query to manage the asynchronous re-authentication
|
|
7
|
-
* process with Firebase credentials. It omits the default "mutationKey" and "mutationFn" options.
|
|
8
|
-
*
|
|
9
|
-
* @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional mutation options excluding "mutationKey" and "mutationFn".
|
|
10
|
-
* @returns {UseMutationResult<UserCredential, FirebaseError, UseReauthenticateWitCredentialMutationVariables, TContext>} A useMutation result object managing the loading, error, and result state of the re-authentication mutation.
|
|
11
|
-
*/
|
|
12
|
-
export const useReauthenticateWitCredentialMutation = (options = {}) => {
|
|
13
|
-
return useMutation({
|
|
14
|
-
...options,
|
|
15
|
-
mutationFn: async ({ credential, user }) => reauthenticateWithCredential(user, credential),
|
|
16
|
-
mutationKey: REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY
|
|
17
|
-
});
|
|
18
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
-
import { AuthProvider, PopupRedirectResolver, User } from "firebase/auth";
|
|
3
|
-
import { FirebaseError } from "firebase/app";
|
|
4
|
-
export type UseReauthenticateWitRedirectMutationVariables = {
|
|
5
|
-
authProvider: AuthProvider;
|
|
6
|
-
popupRedirectResolver?: PopupRedirectResolver;
|
|
7
|
-
user: User;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Custom hook that provides a mutation to reauthenticate a user with a given authentication provider using redirection.
|
|
11
|
-
* This hook uses the `useMutation` hook from the React Query library to handle async mutation logic.
|
|
12
|
-
*
|
|
13
|
-
* @param {Omit<UseMutationOptions<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configuration object for the mutation. It provides the ability to pass options to customize the behavior of the mutation.
|
|
14
|
-
* @template TContext - The type of any additional context you wish to pass to the mutation.
|
|
15
|
-
* @returns {UseMutationResult<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>} A mutation result object containing methods and state of the mutation.
|
|
16
|
-
*/
|
|
17
|
-
export declare const useReauthenticateWitRedirectMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useMutation } from "@tanstack/react-query";
|
|
2
|
-
import { reauthenticateWithRedirect } from "firebase/auth";
|
|
3
|
-
import { REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY } from "./mutation-keys";
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook that provides a mutation to reauthenticate a user with a given authentication provider using redirection.
|
|
6
|
-
* This hook uses the `useMutation` hook from the React Query library to handle async mutation logic.
|
|
7
|
-
*
|
|
8
|
-
* @param {Omit<UseMutationOptions<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configuration object for the mutation. It provides the ability to pass options to customize the behavior of the mutation.
|
|
9
|
-
* @template TContext - The type of any additional context you wish to pass to the mutation.
|
|
10
|
-
* @returns {UseMutationResult<void, FirebaseError, UseReauthenticateWitRedirectMutationVariables, TContext>} A mutation result object containing methods and state of the mutation.
|
|
11
|
-
*/
|
|
12
|
-
export const useReauthenticateWitRedirectMutation = (options = {}) => {
|
|
13
|
-
return useMutation({
|
|
14
|
-
...options,
|
|
15
|
-
mutationFn: async ({ authProvider, user, popupRedirectResolver }) => reauthenticateWithRedirect(user, authProvider, popupRedirectResolver),
|
|
16
|
-
mutationKey: REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY
|
|
17
|
-
});
|
|
18
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { UseMutationOptions } from "@tanstack/react-query";
|
|
2
|
-
import { User } from "firebase/auth";
|
|
3
|
-
import { FirebaseError } from "firebase/app";
|
|
4
|
-
export type UseSendEmailVerificationMutationVariables = {
|
|
5
|
-
user: User;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* A custom hook to create a mutation for sending an email verification to a user using Firebase.
|
|
9
|
-
* This uses the `useMutation` hook from a query library and wraps it with specific configuration options.
|
|
10
|
-
* @param {Omit<UseMutationOptions<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>, "queryKey" | "queryFn">} options - Configuration options for the mutation, excluding `queryKey` and `queryFn`.
|
|
11
|
-
* @returns {UseMutationResult<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>} An object containing mutation state and functions for managing the mutation lifecycle.
|
|
12
|
-
*/
|
|
13
|
-
export declare const useSendEmailVerificationMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseMutationResult<void, FirebaseError, UseSendEmailVerificationMutationVariables, TContext>;
|