react-query-firebase 1.3.2 → 2.0.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/src/analytics/useAnalytics.d.ts +1 -1
  2. package/dist/src/analytics/useLogEvent.js +1 -1
  3. package/dist/src/analytics/useSetAnalyticsCollectionEnabled.js +1 -1
  4. package/dist/src/auth/index.d.ts +0 -1
  5. package/dist/src/auth/index.js +0 -1
  6. package/dist/src/auth/useAuth.d.ts +1 -1
  7. package/dist/src/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +5 -5
  8. package/dist/src/auth/useCreateUserWitEmailAndPasswordMutation.js +3 -3
  9. package/dist/src/auth/useCurrentUser.d.ts +1 -1
  10. package/dist/src/auth/useCurrentUser.js +4 -4
  11. package/dist/src/auth/useIdToken.d.ts +26 -8
  12. package/dist/src/auth/useIdToken.js +21 -7
  13. package/dist/src/auth/useReauthenticateWitCredentialMutation.d.ts +7 -7
  14. package/dist/src/auth/useReauthenticateWitCredentialMutation.js +3 -3
  15. package/dist/src/auth/useReauthenticateWitRedirectMutation.d.ts +7 -7
  16. package/dist/src/auth/useReauthenticateWitRedirectMutation.js +3 -3
  17. package/dist/src/auth/useSendEmailVerificationMutation.d.ts +6 -6
  18. package/dist/src/auth/useSendEmailVerificationMutation.js +3 -3
  19. package/dist/src/auth/useSignInWitEmailAndPasswordMutation.d.ts +4 -4
  20. package/dist/src/auth/useSignInWitEmailAndPasswordMutation.js +2 -2
  21. package/dist/src/auth/useSignInWitRedirectMutation.d.ts +6 -6
  22. package/dist/src/auth/useSignInWitRedirectMutation.js +3 -3
  23. package/dist/src/auth/useSignOutMutation.d.ts +4 -4
  24. package/dist/src/auth/useSignOutMutation.js +3 -3
  25. package/dist/src/auth/useUpdateProfileMutation.d.ts +6 -6
  26. package/dist/src/auth/useUpdateProfileMutation.js +3 -3
  27. package/dist/src/context/FirebaseContext.d.ts +6 -10
  28. package/dist/src/context/FirebaseContextProvider.d.ts +25 -7
  29. package/dist/src/context/FirebaseContextProvider.js +41 -41
  30. package/dist/src/firestore/useAddDocMutation.d.ts +7 -9
  31. package/dist/src/firestore/useAddDocMutation.js +4 -5
  32. package/dist/src/firestore/useBatchWrite.d.ts +5 -5
  33. package/dist/src/firestore/useBatchWrite.js +1 -1
  34. package/dist/src/firestore/useCollectionReference.d.ts +5 -5
  35. package/dist/src/firestore/useCollectionReference.js +3 -5
  36. package/dist/src/firestore/useCompositeFilter.d.ts +6 -6
  37. package/dist/src/firestore/useCompositeFilter.js +12 -9
  38. package/dist/src/firestore/useCountQuery.d.ts +7 -7
  39. package/dist/src/firestore/useCountQuery.js +3 -3
  40. package/dist/src/firestore/useDeleteDocMutation.d.ts +6 -6
  41. package/dist/src/firestore/useDeleteDocMutation.js +1 -1
  42. package/dist/src/firestore/useDocReference.d.ts +6 -6
  43. package/dist/src/firestore/useDocReference.js +6 -10
  44. package/dist/src/firestore/useDocReferences.d.ts +6 -6
  45. package/dist/src/firestore/useDocReferences.js +4 -6
  46. package/dist/src/firestore/useFirestore.d.ts +1 -1
  47. package/dist/src/firestore/useGetDocData.d.ts +5 -5
  48. package/dist/src/firestore/useGetRealtimeDocData.d.ts +7 -7
  49. package/dist/src/firestore/useGetRealtimeDocData.js +1 -1
  50. package/dist/src/firestore/useInfiniteQuery.d.ts +5 -6
  51. package/dist/src/firestore/useInfiniteQuery.js +3 -3
  52. package/dist/src/firestore/useQuery.d.ts +7 -8
  53. package/dist/src/firestore/useQuery.js +5 -5
  54. package/dist/src/firestore/useRunTransaction.d.ts +5 -5
  55. package/dist/src/firestore/useRunTransaction.js +1 -1
  56. package/dist/src/firestore/useSetDocMutation.d.ts +7 -7
  57. package/dist/src/firestore/useSetDocMutation.js +2 -2
  58. package/dist/src/firestore/useUpdateDocMutation.d.ts +7 -8
  59. package/dist/src/firestore/useUpdateDocMutation.js +4 -4
  60. package/dist/src/firestore/utils/getDocData.d.ts +3 -3
  61. package/dist/src/firestore/utils/getDocData.js +1 -1
  62. package/dist/src/firestore/utils/getDocRef.d.ts +8 -8
  63. package/dist/src/firestore/utils/getDocRef.js +5 -9
  64. package/dist/src/firestore/utils/getDocSnap.d.ts +4 -4
  65. package/dist/src/firestore/utils/getDocSnap.js +2 -2
  66. package/dist/src/remoteConfig/useFetchAndActivate.js +1 -1
  67. package/dist/src/remoteConfig/useGetValue.d.ts +1 -1
  68. package/dist/src/remoteConfig/useGetValue.js +1 -1
  69. package/dist/src/remoteConfig/useRemoteConfig.d.ts +1 -1
  70. package/package.json +15 -5
  71. package/src/analytics/useLogEvent.ts +1 -1
  72. package/src/analytics/useSetAnalyticsCollectionEnabled.ts +1 -1
  73. package/src/auth/index.ts +0 -1
  74. package/src/auth/useCreateUserWitEmailAndPasswordMutation.ts +10 -5
  75. package/src/auth/useCurrentUser.ts +4 -4
  76. package/src/auth/useIdToken.ts +31 -9
  77. package/src/auth/useReauthenticateWitCredentialMutation.ts +12 -7
  78. package/src/auth/useReauthenticateWitRedirectMutation.ts +12 -7
  79. package/src/auth/useSendEmailVerificationMutation.ts +11 -6
  80. package/src/auth/useSignInWitEmailAndPasswordMutation.ts +9 -4
  81. package/src/auth/useSignInWitRedirectMutation.ts +11 -6
  82. package/src/auth/useSignOutMutation.ts +5 -5
  83. package/src/auth/useUpdateProfileMutation.ts +6 -6
  84. package/src/context/FirebaseContext.ts +6 -10
  85. package/src/context/FirebaseContextProvider.tsx +71 -44
  86. package/src/firestore/useAddDocMutation.ts +15 -22
  87. package/src/firestore/useBatchWrite.ts +7 -4
  88. package/src/firestore/useCollectionReference.ts +13 -9
  89. package/src/firestore/useCompositeFilter.ts +22 -27
  90. package/src/firestore/useCountQuery.ts +9 -13
  91. package/src/firestore/useDeleteDocMutation.ts +11 -10
  92. package/src/firestore/useDocReference.ts +23 -19
  93. package/src/firestore/useDocReferences.ts +15 -11
  94. package/src/firestore/useGetDocData.ts +14 -15
  95. package/src/firestore/useGetRealtimeDocData.ts +16 -10
  96. package/src/firestore/useInfiniteQuery.ts +9 -16
  97. package/src/firestore/useQuery.ts +11 -20
  98. package/src/firestore/useRunTransaction.ts +9 -4
  99. package/src/firestore/useSetDocMutation.ts +14 -11
  100. package/src/firestore/useUpdateDocMutation.ts +15 -21
  101. package/src/firestore/utils/getDocData.ts +7 -9
  102. package/src/firestore/utils/getDocRef.ts +13 -17
  103. package/src/firestore/utils/getDocSnap.ts +7 -9
  104. package/src/remoteConfig/useFetchAndActivate.ts +1 -1
  105. package/src/remoteConfig/useGetValue.ts +1 -1
  106. package/dist/src/auth/useAuthStateReady.d.ts +0 -6
  107. package/dist/src/auth/useAuthStateReady.js +0 -19
  108. package/src/auth/useAuthStateReady.ts +0 -24
@@ -1,13 +1,10 @@
1
1
  import {
2
- DocumentData,
3
- FirestoreDataConverter,
2
+ FirebaseFirestoreTypes,
4
3
  getDocs,
5
- Query,
6
4
  query,
7
- QueryCompositeFilterConstraint,
8
5
  QueryConstraint,
9
6
  QueryNonFilterConstraint
10
- } from "firebase/firestore";
7
+ } from "@react-native-firebase/firestore";
11
8
 
12
9
  import {
13
10
  UseQueryResult,
@@ -15,16 +12,12 @@ import {
15
12
  UseQueryOptions as UseReactQueryOptions
16
13
  } from "@tanstack/react-query";
17
14
 
18
- type UseQueryOptions<
19
- AppModelType extends DocumentData = DocumentData,
20
- DbModelType extends DocumentData = DocumentData
21
- > = {
15
+ type UseQueryOptions<AppModelType extends FirebaseFirestoreTypes.DocumentData> = {
22
16
  options: Omit<UseReactQueryOptions<AppModelType[], Error, AppModelType[]>, "queryFn"> &
23
17
  Required<Pick<UseReactQueryOptions<AppModelType[], Error, AppModelType[]>, "queryKey">>;
24
- query: Query<AppModelType, DbModelType>;
18
+ query: FirebaseFirestoreTypes.Query<AppModelType>;
25
19
  queryConstraints?: QueryConstraint[] | QueryNonFilterConstraint[];
26
- compositeFilter?: QueryCompositeFilterConstraint;
27
- converter?: FirestoreDataConverter<AppModelType, DbModelType>;
20
+ compositeFilter?: FirebaseFirestoreTypes.QueryCompositeFilterConstraint;
28
21
  };
29
22
 
30
23
  /**
@@ -33,8 +26,8 @@ type UseQueryOptions<
33
26
  * This hook utilizes an abstraction over React Query to asynchronously fetch data based on the provided query
34
27
  * reference and constraints. It supports optional filtering, conversion, and additional query constraints.
35
28
  *
36
- * @param {UseQueryOptions<AppModelType, DbModelType>} options - Configuration options for the query.
37
- * @param {DocumentReference<AppModelType>} queryReference - The reference to the query to be executed.
29
+ * @param {UseQueryOptions<AppModelType>} options - Configuration options for the query.
30
+ * @param {FirebaseFirestoreTypes.DocumentReference<AppModelType>} queryReference - The reference to the query to be executed.
38
31
  * @param {QueryConstraint[]} queryConstraints - Additional constraints to fine-tune the query.
39
32
  * @param {QueryConstraint} compositeFilter - Optional composite filter to apply to the query.
40
33
  * @param {FirestoreDataConverter<AppModelType>} converter - Optional data converter for transforming snapshots.
@@ -42,15 +35,13 @@ type UseQueryOptions<
42
35
  * @returns {UseQueryResult<AppModelType[]>} Result containing an array of documents that match the query criteria.
43
36
  */
44
37
  export const useQuery = <
45
- AppModelType extends DocumentData = DocumentData,
46
- DbModelType extends DocumentData = DocumentData
38
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData
47
39
  >({
48
40
  options,
49
41
  query: queryReference,
50
42
  queryConstraints = [],
51
- compositeFilter,
52
- converter
53
- }: UseQueryOptions<AppModelType, DbModelType>): UseQueryResult<AppModelType[]> => {
43
+ compositeFilter
44
+ }: UseQueryOptions<AppModelType>): UseQueryResult<AppModelType[]> => {
54
45
  return useReactQuery({
55
46
  ...options,
56
47
  queryFn: async () => {
@@ -58,7 +49,7 @@ export const useQuery = <
58
49
  ? query(queryReference, compositeFilter, ...(queryConstraints as QueryNonFilterConstraint[]))
59
50
  : query(queryReference, ...queryConstraints);
60
51
 
61
- const querySnapshot = await getDocs(converter ? queryToExecute.withConverter(converter) : queryToExecute);
52
+ const querySnapshot = await getDocs(queryToExecute);
62
53
  const docs: AppModelType[] = [];
63
54
 
64
55
  if (querySnapshot) {
@@ -1,13 +1,18 @@
1
1
  import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
- import { runTransaction, Transaction } from "firebase/firestore";
2
+ import { runTransaction, FirebaseFirestoreTypes } from "@react-native-firebase/firestore";
3
3
 
4
- import { FirebaseError } from "firebase/app";
4
+ import { ReactNativeFirebase } from "@react-native-firebase/app";
5
5
  import { useFirestore } from "./useFirestore";
6
6
 
7
- export type UseRunTransactionValues = <AppModelType = unknown>(transaction: Transaction) => AppModelType;
7
+ export type UseRunTransactionValues = <AppModelType = unknown>(
8
+ transaction: FirebaseFirestoreTypes.Transaction
9
+ ) => AppModelType;
8
10
 
9
11
  export type UseRunTransactionOptions<AppModelType = unknown, TContext = unknown> = {
10
- options?: Omit<UseMutationOptions<AppModelType, FirebaseError, UseRunTransactionValues, TContext>, "mutationFn">;
12
+ options?: Omit<
13
+ UseMutationOptions<AppModelType, ReactNativeFirebase.NativeFirebaseError, UseRunTransactionValues, TContext>,
14
+ "mutationFn"
15
+ >;
11
16
  };
12
17
 
13
18
  /**
@@ -1,7 +1,7 @@
1
1
  import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
- import { DocumentData, DocumentReference, setDoc, WithFieldValue } from "firebase/firestore";
2
+ import { FirebaseFirestoreTypes, setDoc, WithFieldValue } from "@react-native-firebase/firestore";
3
3
 
4
- import { FirebaseError } from "firebase/app";
4
+ import { ReactNativeFirebase } from "@react-native-firebase/app";
5
5
  import { useMemo } from "react";
6
6
 
7
7
  export type UseSetDocMutationValues<AppModelType> = {
@@ -9,13 +9,17 @@ export type UseSetDocMutationValues<AppModelType> = {
9
9
  };
10
10
 
11
11
  export type UseSetDocMutationOptions<
12
- AppModelType = unknown,
13
- DbModelType extends DocumentData = DocumentData,
12
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData,
14
13
  TContext = unknown
15
14
  > = {
16
- reference: DocumentReference<AppModelType, DbModelType> | null;
15
+ reference: FirebaseFirestoreTypes.DocumentReference<AppModelType> | null;
17
16
  options?: Omit<
18
- UseMutationOptions<void, FirebaseError, UseSetDocMutationValues<AppModelType>, TContext>,
17
+ UseMutationOptions<
18
+ void,
19
+ ReactNativeFirebase.NativeFirebaseError,
20
+ UseSetDocMutationValues<AppModelType>,
21
+ TContext
22
+ >,
19
23
  "mutationFn" | "mutationKey"
20
24
  >;
21
25
  };
@@ -24,19 +28,18 @@ export type UseSetDocMutationOptions<
24
28
  * Custom hook to create a mutation for setting a document in a Firestore-like database.
25
29
  * The mutation can be configured with options and reference to specific document path.
26
30
  *
27
- * @param {UseSetDocMutationOptions<AppModelType, DbModelType, TContext>} param0 - The options for configuring the mutation, including the document reference and additional mutation options.
31
+ * @param {UseSetDocMutationOptions<AppModelType, TContext>} param0 - The options for configuring the mutation, including the document reference and additional mutation options.
28
32
  * @param {Object} param0.reference - The reference object that contains the path to the document.
29
33
  * @param {Object} param0.options - Additional options for the mutation, can configure aspects like onSuccess or onError callbacks.
30
34
  * @returns {MutationResult} The result of the mutation operation, which includes states like isLoading, isSuccess, isError, and methods to control the mutation process.
31
35
  */
32
36
  export const useSetDocMutation = <
33
- AppModelType = unknown,
34
- DbModelType extends DocumentData = DocumentData,
37
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData,
35
38
  TContext = unknown
36
39
  >({
37
40
  reference,
38
41
  options
39
- }: UseSetDocMutationOptions<AppModelType, DbModelType, TContext>) => {
42
+ }: UseSetDocMutationOptions<AppModelType, TContext>) => {
40
43
  const mutationKey = useMemo(() => [reference?.path], [reference?.path]);
41
44
 
42
45
  return useMutation({
@@ -45,7 +48,7 @@ export const useSetDocMutation = <
45
48
  if (!reference) {
46
49
  throw new Error("Reference is undefined");
47
50
  }
48
- return setDoc<AppModelType, DbModelType>(reference, data);
51
+ return setDoc<AppModelType>(reference, data);
49
52
  },
50
53
  mutationKey
51
54
  });
@@ -1,14 +1,7 @@
1
1
  import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
- import {
3
- DocumentData,
4
- updateDoc,
5
- getDoc,
6
- FirestoreDataConverter,
7
- DocumentReference,
8
- UpdateData
9
- } from "firebase/firestore";
2
+ import { FirebaseFirestoreTypes, updateDoc, getDoc, UpdateData } from "@react-native-firebase/firestore";
10
3
 
11
- import { FirebaseError } from "firebase/app";
4
+ import { ReactNativeFirebase } from "@react-native-firebase/app";
12
5
  import { useMemo } from "react";
13
6
 
14
7
  export type UseUpdateDocMutationValues<DbModelType> = {
@@ -16,14 +9,17 @@ export type UseUpdateDocMutationValues<DbModelType> = {
16
9
  };
17
10
 
18
11
  export type UseUpdateDocMutationOptions<
19
- AppModelType extends DocumentData = DocumentData,
20
- DbModelType extends DocumentData = DocumentData,
12
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData,
21
13
  TContext = unknown
22
14
  > = {
23
- reference: DocumentReference<AppModelType, DbModelType> | null;
24
- converter?: FirestoreDataConverter<AppModelType, DbModelType>;
15
+ reference: FirebaseFirestoreTypes.DocumentReference<AppModelType> | null;
25
16
  options?: Omit<
26
- UseMutationOptions<AppModelType, FirebaseError, UseUpdateDocMutationValues<DbModelType>, TContext>,
17
+ UseMutationOptions<
18
+ AppModelType,
19
+ ReactNativeFirebase.NativeFirebaseError,
20
+ UseUpdateDocMutationValues<AppModelType>,
21
+ TContext
22
+ >,
27
23
  "mutationFn" | "mutationKey"
28
24
  >;
29
25
  };
@@ -35,7 +31,7 @@ export type UseUpdateDocMutationOptions<
35
31
  * and retrieve the latest data snapshot. The update functionality can be configured with a custom
36
32
  * converter if needed.
37
33
  *
38
- * @param {UseUpdateDocMutationOptions<AppModelType, DbModelType, TContext>} options - Configuration options for the mutation,
34
+ * @param {UseUpdateDocMutationOptions<AppModelType, TContext>} options - Configuration options for the mutation,
39
35
  * including Firestore reference, an optional Firestore data converter, and additional mutation options.
40
36
  *
41
37
  * `reference` - The Firestore document reference that identifies the document to be updated.
@@ -48,14 +44,12 @@ export type UseUpdateDocMutationOptions<
48
44
  * which includes functions to start the mutation and properties that represent the different states of the mutation.
49
45
  */
50
46
  export const useUpdateDocMutation = <
51
- AppModelType extends DocumentData = DocumentData,
52
- DbModelType extends DocumentData = DocumentData,
47
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData,
53
48
  TContext = unknown
54
49
  >({
55
50
  reference,
56
- converter,
57
51
  options = {}
58
- }: UseUpdateDocMutationOptions<AppModelType, DbModelType, TContext>) => {
52
+ }: UseUpdateDocMutationOptions<AppModelType, TContext>) => {
59
53
  const mutationKey = useMemo(() => [reference?.path], [reference?.path]);
60
54
 
61
55
  return useMutation({
@@ -65,8 +59,8 @@ export const useUpdateDocMutation = <
65
59
  throw new Error("Reference is undefined");
66
60
  }
67
61
 
68
- await updateDoc<AppModelType, DbModelType>(reference, data);
69
- const docSnap = await getDoc(converter ? reference.withConverter(converter) : reference);
62
+ await updateDoc<AppModelType>(reference, data);
63
+ const docSnap = await getDoc(reference);
70
64
  return docSnap.data() as AppModelType;
71
65
  },
72
66
  mutationKey
@@ -1,10 +1,9 @@
1
- import { DocumentData } from "firebase/firestore";
1
+ import { FirebaseFirestoreTypes } from "@react-native-firebase/firestore";
2
2
  import { getDocSnap, GetDocSnapOptions } from "./getDocSnap";
3
3
 
4
4
  export type GetDocDataOptions<
5
- AppModelType extends DocumentData = DocumentData,
6
- DbModelType extends DocumentData = DocumentData
7
- > = GetDocSnapOptions<AppModelType, DbModelType>;
5
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData
6
+ > = GetDocSnapOptions<AppModelType>;
8
7
 
9
8
  /**
10
9
  * Asynchronously retrieves document data from a specified database and reference.
@@ -21,17 +20,16 @@ export type GetDocDataOptions<
21
20
  * or null if the document does not exist.
22
21
  */
23
22
  export const getDocData = async <
24
- AppModelType extends DocumentData = DocumentData,
25
- DbModelType extends DocumentData = DocumentData
23
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData
26
24
  >({
27
25
  db,
28
26
  reference,
29
27
  path,
30
28
  pathSegments
31
- }: GetDocDataOptions<AppModelType, DbModelType>) => {
32
- const docSnap = await getDocSnap<AppModelType, DbModelType>({ db, reference, path, pathSegments });
29
+ }: GetDocDataOptions<AppModelType>) => {
30
+ const docSnap = await getDocSnap<AppModelType>({ db, reference, path, pathSegments });
33
31
 
34
- if (docSnap && docSnap.exists()) {
32
+ if (docSnap && docSnap?.exists) {
35
33
  return docSnap.data();
36
34
  }
37
35
 
@@ -1,11 +1,12 @@
1
- import { CollectionReference, doc, DocumentData, DocumentReference, Firestore } from "firebase/firestore";
1
+ import { doc, FirebaseFirestoreTypes } from "@react-native-firebase/firestore";
2
2
 
3
3
  export type GetDocRefOptions<
4
- AppModelType extends DocumentData = DocumentData,
5
- DbModelType extends DocumentData = DocumentData
4
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData
6
5
  > = {
7
- db: Firestore;
8
- reference?: CollectionReference<AppModelType, DbModelType> | DocumentReference<AppModelType, DbModelType>;
6
+ db: FirebaseFirestoreTypes.Module;
7
+ reference?:
8
+ | FirebaseFirestoreTypes.CollectionReference<AppModelType>
9
+ | FirebaseFirestoreTypes.DocumentReference<AppModelType>;
9
10
  path?: string;
10
11
  pathSegments?: string[];
11
12
  };
@@ -15,32 +16,27 @@ export type GetDocRefOptions<
15
16
  * Either `reference` or `path` must be provided, not both.
16
17
  *
17
18
  * @param {Object} options - The options for getting a document reference.
18
- * @param {Firestore} options.db - The Firestore database instance.
19
- * @param {DocumentReference | CollectionReference | null} [options.reference] - Reference to a document or collection.
19
+ * @param {FirebaseFirestoreTypes.Module} options.db - The Firestore database instance.
20
+ * @param {FirebaseFirestoreTypes.DocumentReference | FirebaseFirestoreTypes.CollectionReference | null} [options.reference] - Reference to a document or collection.
20
21
  * @param {string | null} [options.path] - Path to the document.
21
22
  * @param {string[] | null} [options.pathSegments] - Additional path segments if any.
22
- * @returns {DocumentReference<AppModelType, DbModelType>} The document reference.
23
+ * @returns {FirebaseFirestoreTypes.DocumentReference<AppModelType>} The document reference.
23
24
  */
24
25
  export const getDocRef = async <
25
- AppModelType extends DocumentData = DocumentData,
26
- DbModelType extends DocumentData = DocumentData
26
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData
27
27
  >({
28
28
  db,
29
29
  reference,
30
30
  path,
31
31
  pathSegments
32
- }: GetDocRefOptions<AppModelType, DbModelType>) => {
32
+ }: GetDocRefOptions<AppModelType>) => {
33
33
  if (!reference && !path) {
34
34
  throw new Error("One of the options must be provided: path or reference.");
35
35
  }
36
36
 
37
37
  const docRef = !reference
38
38
  ? doc(db, path as string, ...(pathSegments || []))
39
- : reference.type === "collection"
40
- ? doc(reference, path, ...(pathSegments || []))
41
- : reference.type === "document"
42
- ? doc(reference, path as string, ...(pathSegments || []))
43
- : null;
39
+ : doc(reference, path, ...(pathSegments || []));
44
40
 
45
- return docRef as DocumentReference<AppModelType, DbModelType>;
41
+ return docRef as FirebaseFirestoreTypes.DocumentReference<AppModelType>;
46
42
  };
@@ -1,10 +1,9 @@
1
- import { DocumentData, getDoc as firestoreGetDoc } from "firebase/firestore";
1
+ import { FirebaseFirestoreTypes, getDoc as firestoreGetDoc } from "@react-native-firebase/firestore";
2
2
  import { getDocRef, GetDocRefOptions } from "./getDocRef";
3
3
 
4
4
  export type GetDocSnapOptions<
5
- AppModelType extends DocumentData = DocumentData,
6
- DbModelType extends DocumentData = DocumentData
7
- > = GetDocRefOptions<AppModelType, DbModelType>;
5
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData
6
+ > = GetDocRefOptions<AppModelType>;
8
7
 
9
8
  /**
10
9
  * Asynchronously retrieves a document snapshot from Firestore using a specified document reference
@@ -18,20 +17,19 @@ export type GetDocSnapOptions<
18
17
  * @param {string} options.reference - A string representing a direct Firestore document reference.
19
18
  * @param {string} options.path - A Firestore path string leading to the document.
20
19
  * @param {string[]} options.pathSegments - An array of path segments to build the Firestore path.
21
- * @returns {Promise<DocumentData | null>} A promise that resolves to the document data if the
20
+ * @returns {Promise<FirebaseFirestoreTypes.DocumentData | null>} A promise that resolves to the document data if the
22
21
  * document exists, or `null` if the document does not exist
23
22
  * or if the reference could not be obtained.
24
23
  */
25
24
  export const getDocSnap = async <
26
- AppModelType extends DocumentData = DocumentData,
27
- DbModelType extends DocumentData = DocumentData
25
+ AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData
28
26
  >({
29
27
  db,
30
28
  reference,
31
29
  path,
32
30
  pathSegments
33
- }: GetDocSnapOptions<AppModelType, DbModelType>) => {
34
- const docRef = await getDocRef<AppModelType, DbModelType>({ db, reference, path, pathSegments });
31
+ }: GetDocSnapOptions<AppModelType>) => {
32
+ const docRef = await getDocRef<AppModelType>({ db, reference, path, pathSegments });
35
33
 
36
34
  if (docRef) {
37
35
  return await firestoreGetDoc(docRef);
@@ -1,5 +1,5 @@
1
1
  import { useRemoteConfig } from "./useRemoteConfig";
2
- import { ensureInitialized, fetchAndActivate } from "firebase/remote-config";
2
+ import { ensureInitialized, fetchAndActivate } from "@react-native-firebase/remote-config";
3
3
  import { useCallback, useMemo, useState } from "react";
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { getValue } from "firebase/remote-config";
1
+ import { getValue } from "@react-native-firebase/remote-config";
2
2
  import { useRemoteConfig } from "./useRemoteConfig";
3
3
  import { useMemo } from "react";
4
4
 
@@ -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
- }, [isAuthStateReady]);
15
- useEffect(() => {
16
- callback();
17
- }, [callback]);
18
- return isAuthStateReady;
19
- };
@@ -1,24 +0,0 @@
1
- import { useAuth } from "./useAuth";
2
- import { useCallback, useEffect, useState } from "react";
3
-
4
- /**
5
- * A custom hook that determines if the Firebase authentication state is ready.
6
- * It uses Firebase authentication to check if the auth state is ready and updates the state accordingly.
7
- * @returns {boolean} Indicates whether the authentication state is ready.
8
- */
9
- export const useAuthStateReady = () => {
10
- const firebaseAuth = useAuth();
11
-
12
- const [isAuthStateReady, setIsAuthStateReady] = useState(false);
13
-
14
- const callback = useCallback(async () => {
15
- await firebaseAuth.authStateReady();
16
- setIsAuthStateReady(true);
17
- }, [isAuthStateReady]);
18
-
19
- useEffect(() => {
20
- callback();
21
- }, [callback]);
22
-
23
- return isAuthStateReady;
24
- };