react-query-firebase 2.4.1 → 2.5.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 CHANGED
@@ -74,5 +74,5 @@
74
74
  "docs:build": "vitepress build docs",
75
75
  "docs:preview": "vitepress preview docs"
76
76
  },
77
- "version": "2.4.1"
77
+ "version": "2.5.0"
78
78
  }
@@ -11,3 +11,4 @@ export * from "./useIdToken";
11
11
  export * from "./useReauthenticateWitCredentialMutation";
12
12
  export * from "./useReauthenticateWitRedirectMutation";
13
13
  export * from "./useAuthStateReady";
14
+ export * from "./useSignInAnonymouslyMutation";
@@ -11,3 +11,4 @@ export * from "./useIdToken";
11
11
  export * from "./useReauthenticateWitCredentialMutation";
12
12
  export * from "./useReauthenticateWitRedirectMutation";
13
13
  export * from "./useAuthStateReady";
14
+ export * from "./useSignInAnonymouslyMutation";
@@ -11,3 +11,4 @@ export * from "./useIdToken";
11
11
  export * from "./useReauthenticateWitCredentialMutation";
12
12
  export * from "./useReauthenticateWitRedirectMutation";
13
13
  export * from "./useAuthStateReady";
14
+ export * from "./useSignInAnonymouslyMutation";
@@ -1,5 +1,6 @@
1
1
  export declare const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"];
2
2
  export declare const SEND_EMAIL_VERIFICATION_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"];
3
+ export declare const SIGN_IN_ANONYMOUSLY_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_ANONYMOUSLY_MUTATION"];
3
4
  export declare const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"];
4
5
  export declare const SIGN_IN_WITH_REDIRECT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"];
5
6
  export declare const SIGN_OUT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_OUT"];
@@ -4,6 +4,7 @@ export const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
4
4
  "CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"
5
5
  ];
6
6
  export const SEND_EMAIL_VERIFICATION_MUTATION_KEY = ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"];
7
+ export const SIGN_IN_ANONYMOUSLY_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_ANONYMOUSLY_MUTATION"];
7
8
  export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
8
9
  "FIREBASE",
9
10
  "AUTH",
@@ -4,6 +4,7 @@ export const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
4
4
  "CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"
5
5
  ] as const;
6
6
  export const SEND_EMAIL_VERIFICATION_MUTATION_KEY = ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"] as const;
7
+ export const SIGN_IN_ANONYMOUSLY_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_ANONYMOUSLY_MUTATION"] as const;
7
8
  export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
8
9
  "FIREBASE",
9
10
  "AUTH",
@@ -0,0 +1,36 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { FirebaseAuthTypes } from "@react-native-firebase/auth";
3
+ import { ReactNativeFirebase } from "@react-native-firebase/app";
4
+ /**
5
+ * @inline
6
+ */
7
+ export type UseSignInAnonymouslyMutationOptions = {
8
+ /**
9
+ * Options for useMutation hook excluding mutationFn. MutationKey will be equal to reference.path by default.
10
+ */
11
+ options?: Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, void>, "mutationFn">;
12
+ };
13
+ /**
14
+ * Executes a mutation and returns users credentials
15
+ *
16
+ * @group Hook
17
+ *
18
+ * @param {useSignInAnonymouslyMutation} options - Configuration options for the mutation.
19
+ *
20
+ * @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
21
+ *
22
+ * @example
23
+ * ```jsx
24
+ * export const MyComponent = () => {
25
+ * const {mutate} = useSignInAnonymouslyMutation({
26
+ * options: {
27
+ * },
28
+ * });
29
+ *
30
+ * // ....
31
+ * mutate();
32
+ * // ....
33
+ * };
34
+ * ```
35
+ */
36
+ export declare const useSignInAnonymouslyMutation: ({ options }?: UseSignInAnonymouslyMutationOptions) => import("@tanstack/react-query").UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, void, unknown>;
@@ -0,0 +1,35 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { signInAnonymously } from "@react-native-firebase/auth";
3
+ import { useAuth } from "./useAuth";
4
+ import { SIGN_IN_ANONYMOUSLY_MUTATION_KEY } from "./mutation-keys";
5
+ /**
6
+ * Executes a mutation and returns users credentials
7
+ *
8
+ * @group Hook
9
+ *
10
+ * @param {useSignInAnonymouslyMutation} options - Configuration options for the mutation.
11
+ *
12
+ * @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
13
+ *
14
+ * @example
15
+ * ```jsx
16
+ * export const MyComponent = () => {
17
+ * const {mutate} = useSignInAnonymouslyMutation({
18
+ * options: {
19
+ * },
20
+ * });
21
+ *
22
+ * // ....
23
+ * mutate();
24
+ * // ....
25
+ * };
26
+ * ```
27
+ */
28
+ export const useSignInAnonymouslyMutation = ({ options = {} } = {}) => {
29
+ const firebaseAuth = useAuth();
30
+ return useMutation({
31
+ ...options,
32
+ mutationKey: SIGN_IN_ANONYMOUSLY_MUTATION_KEY,
33
+ mutationFn: async () => signInAnonymously(firebaseAuth)
34
+ });
35
+ };
@@ -0,0 +1,52 @@
1
+ import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
+ import { signInAnonymously, FirebaseAuthTypes } from "@react-native-firebase/auth";
3
+
4
+ import { useAuth } from "./useAuth";
5
+ import { SIGN_IN_ANONYMOUSLY_MUTATION_KEY } from "./mutation-keys";
6
+ import { ReactNativeFirebase } from "@react-native-firebase/app";
7
+
8
+ /**
9
+ * @inline
10
+ */
11
+ export type UseSignInAnonymouslyMutationOptions = {
12
+ /**
13
+ * Options for useMutation hook excluding mutationFn. MutationKey will be equal to reference.path by default.
14
+ */
15
+ options?: Omit<
16
+ UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, void>,
17
+ "mutationFn"
18
+ >;
19
+ };
20
+
21
+ /**
22
+ * Executes a mutation and returns users credentials
23
+ *
24
+ * @group Hook
25
+ *
26
+ * @param {useSignInAnonymouslyMutation} options - Configuration options for the mutation.
27
+ *
28
+ * @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
29
+ *
30
+ * @example
31
+ * ```jsx
32
+ * export const MyComponent = () => {
33
+ * const {mutate} = useSignInAnonymouslyMutation({
34
+ * options: {
35
+ * },
36
+ * });
37
+ *
38
+ * // ....
39
+ * mutate();
40
+ * // ....
41
+ * };
42
+ * ```
43
+ */
44
+ export const useSignInAnonymouslyMutation = ({ options = {} }: UseSignInAnonymouslyMutationOptions = {}) => {
45
+ const firebaseAuth = useAuth();
46
+
47
+ return useMutation({
48
+ ...options,
49
+ mutationKey: SIGN_IN_ANONYMOUSLY_MUTATION_KEY,
50
+ mutationFn: async () => signInAnonymously(firebaseAuth)
51
+ });
52
+ };
@@ -11,3 +11,4 @@ export * from "./useSignOutMutation";
11
11
  export * from "./useIdToken";
12
12
  export * from "./useReauthenticateWitCredentialMutation";
13
13
  export * from "./useReauthenticateWitRedirectMutation";
14
+ export * from "./useSignInAnonymouslyMutation";
package/web/auth/index.js CHANGED
@@ -11,3 +11,4 @@ export * from "./useSignOutMutation";
11
11
  export * from "./useIdToken";
12
12
  export * from "./useReauthenticateWitCredentialMutation";
13
13
  export * from "./useReauthenticateWitRedirectMutation";
14
+ export * from "./useSignInAnonymouslyMutation";
package/web/auth/index.ts CHANGED
@@ -11,3 +11,4 @@ export * from "./useSignOutMutation";
11
11
  export * from "./useIdToken";
12
12
  export * from "./useReauthenticateWitCredentialMutation";
13
13
  export * from "./useReauthenticateWitRedirectMutation";
14
+ export * from "./useSignInAnonymouslyMutation";
@@ -1,5 +1,6 @@
1
1
  export declare const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"];
2
2
  export declare const SEND_EMAIL_VERIFICATION_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"];
3
+ export declare const SIGN_IN_ANONYMOUSLY_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_ANONYMOUSLY_MUTATION"];
3
4
  export declare const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"];
4
5
  export declare const SIGN_IN_WITH_REDIRECT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"];
5
6
  export declare const SIGN_OUT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_OUT"];
@@ -4,6 +4,7 @@ export const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
4
4
  "CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"
5
5
  ];
6
6
  export const SEND_EMAIL_VERIFICATION_MUTATION_KEY = ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"];
7
+ export const SIGN_IN_ANONYMOUSLY_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_ANONYMOUSLY_MUTATION"];
7
8
  export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
8
9
  "FIREBASE",
9
10
  "AUTH",
@@ -4,6 +4,7 @@ export const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
4
4
  "CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"
5
5
  ] as const;
6
6
  export const SEND_EMAIL_VERIFICATION_MUTATION_KEY = ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"] as const;
7
+ export const SIGN_IN_ANONYMOUSLY_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_ANONYMOUSLY_MUTATION"] as const;
7
8
  export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
8
9
  "FIREBASE",
9
10
  "AUTH",
@@ -0,0 +1,36 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { UserCredential } from "firebase/auth";
3
+ import { ReactNativeFirebase } from "@react-native-firebase/app";
4
+ /**
5
+ * @inline
6
+ */
7
+ export type UseSignInAnonymouslyMutationOptions = {
8
+ /**
9
+ * Options for useMutation hook excluding mutationFn. MutationKey will be equal to reference.path by default.
10
+ */
11
+ options?: Omit<UseMutationOptions<UserCredential, ReactNativeFirebase.NativeFirebaseError, void>, "mutationFn">;
12
+ };
13
+ /**
14
+ * Executes a mutation and returns users credentials
15
+ *
16
+ * @group Hook
17
+ *
18
+ * @param {useSignInAnonymouslyMutation} options - Configuration options for the mutation.
19
+ *
20
+ * @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
21
+ *
22
+ * @example
23
+ * ```jsx
24
+ * export const MyComponent = () => {
25
+ * const {mutate} = useSignInAnonymouslyMutation({
26
+ * options: {
27
+ * },
28
+ * });
29
+ *
30
+ * // ....
31
+ * mutate();
32
+ * // ....
33
+ * };
34
+ * ```
35
+ */
36
+ export declare const useSignInAnonymouslyMutation: ({ options }?: UseSignInAnonymouslyMutationOptions) => import("@tanstack/react-query").UseMutationResult<UserCredential, ReactNativeFirebase.NativeFirebaseError, void, unknown>;
@@ -0,0 +1,35 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { signInAnonymously } from "firebase/auth";
3
+ import { useAuth } from "./useAuth";
4
+ import { SIGN_IN_ANONYMOUSLY_MUTATION_KEY } from "./mutation-keys";
5
+ /**
6
+ * Executes a mutation and returns users credentials
7
+ *
8
+ * @group Hook
9
+ *
10
+ * @param {useSignInAnonymouslyMutation} options - Configuration options for the mutation.
11
+ *
12
+ * @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
13
+ *
14
+ * @example
15
+ * ```jsx
16
+ * export const MyComponent = () => {
17
+ * const {mutate} = useSignInAnonymouslyMutation({
18
+ * options: {
19
+ * },
20
+ * });
21
+ *
22
+ * // ....
23
+ * mutate();
24
+ * // ....
25
+ * };
26
+ * ```
27
+ */
28
+ export const useSignInAnonymouslyMutation = ({ options = {} } = {}) => {
29
+ const firebaseAuth = useAuth();
30
+ return useMutation({
31
+ ...options,
32
+ mutationKey: SIGN_IN_ANONYMOUSLY_MUTATION_KEY,
33
+ mutationFn: async () => signInAnonymously(firebaseAuth)
34
+ });
35
+ };
@@ -0,0 +1,49 @@
1
+ import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
+ import { signInAnonymously, UserCredential } from "firebase/auth";
3
+
4
+ import { useAuth } from "./useAuth";
5
+ import { SIGN_IN_ANONYMOUSLY_MUTATION_KEY } from "./mutation-keys";
6
+ import { ReactNativeFirebase } from "@react-native-firebase/app";
7
+
8
+ /**
9
+ * @inline
10
+ */
11
+ export type UseSignInAnonymouslyMutationOptions = {
12
+ /**
13
+ * Options for useMutation hook excluding mutationFn. MutationKey will be equal to reference.path by default.
14
+ */
15
+ options?: Omit<UseMutationOptions<UserCredential, ReactNativeFirebase.NativeFirebaseError, void>, "mutationFn">;
16
+ };
17
+
18
+ /**
19
+ * Executes a mutation and returns users credentials
20
+ *
21
+ * @group Hook
22
+ *
23
+ * @param {useSignInAnonymouslyMutation} options - Configuration options for the mutation.
24
+ *
25
+ * @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
26
+ *
27
+ * @example
28
+ * ```jsx
29
+ * export const MyComponent = () => {
30
+ * const {mutate} = useSignInAnonymouslyMutation({
31
+ * options: {
32
+ * },
33
+ * });
34
+ *
35
+ * // ....
36
+ * mutate();
37
+ * // ....
38
+ * };
39
+ * ```
40
+ */
41
+ export const useSignInAnonymouslyMutation = ({ options = {} }: UseSignInAnonymouslyMutationOptions = {}) => {
42
+ const firebaseAuth = useAuth();
43
+
44
+ return useMutation({
45
+ ...options,
46
+ mutationKey: SIGN_IN_ANONYMOUSLY_MUTATION_KEY,
47
+ mutationFn: async () => signInAnonymously(firebaseAuth)
48
+ });
49
+ };