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 +1 -1
- package/react-native/auth/index.d.ts +1 -0
- package/react-native/auth/index.js +1 -0
- package/react-native/auth/index.ts +1 -0
- package/react-native/auth/mutation-keys.d.ts +1 -0
- package/react-native/auth/mutation-keys.js +1 -0
- package/react-native/auth/mutation-keys.ts +1 -0
- package/react-native/auth/useSignInAnonymouslyMutation.d.ts +36 -0
- package/react-native/auth/useSignInAnonymouslyMutation.js +35 -0
- package/react-native/auth/useSignInAnonymouslyMutation.ts +52 -0
- package/web/auth/index.d.ts +1 -0
- package/web/auth/index.js +1 -0
- package/web/auth/index.ts +1 -0
- package/web/auth/mutation-keys.d.ts +1 -0
- package/web/auth/mutation-keys.js +1 -0
- package/web/auth/mutation-keys.ts +1 -0
- package/web/auth/useSignInAnonymouslyMutation.d.ts +36 -0
- package/web/auth/useSignInAnonymouslyMutation.js +35 -0
- package/web/auth/useSignInAnonymouslyMutation.ts +49 -0
package/package.json
CHANGED
|
@@ -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
|
+
};
|
package/web/auth/index.d.ts
CHANGED
package/web/auth/index.js
CHANGED
package/web/auth/index.ts
CHANGED
|
@@ -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
|
+
};
|