react-query-firebase 2.4.0 → 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/react-native/firestore/useDocReferences.d.ts +1 -1
- package/react-native/firestore/utils/getDocRef.d.ts +1 -1
- package/react-native/firestore/utils/getDocRef.js +2 -2
- package/react-native/firestore/utils/getDocRef.ts +2 -2
- 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/web/firestore/useDocReferences.d.ts +1 -1
- package/web/firestore/utils/getDocRef.d.ts +1 -1
- package/web/firestore/utils/getDocRef.js +2 -2
- package/web/firestore/utils/getDocRef.ts +6 -6
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
|
+
};
|
|
@@ -25,4 +25,4 @@ export type UseDocReferencesOptions<AppModelType extends AppModel = AppModel> =
|
|
|
25
25
|
* };
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export declare const useDocReferences: <AppModelType extends AppModel = AppModel>({ references }: UseDocReferencesOptions<AppModelType>) => import("@react-native-firebase/firestore").FirebaseFirestoreTypes.DocumentReference<AppModelType>[];
|
|
28
|
+
export declare const useDocReferences: <AppModelType extends AppModel = AppModel>({ references }: UseDocReferencesOptions<AppModelType>) => (import("@react-native-firebase/firestore").FirebaseFirestoreTypes.DocumentReference<AppModelType> | null)[];
|
|
@@ -19,4 +19,4 @@ export type GetDocRefOptions<AppModelType extends AppModel = AppModel> = {
|
|
|
19
19
|
*
|
|
20
20
|
* @returns {DocumentReference<AppModelType, AppModelType>} Returns a document reference
|
|
21
21
|
*/
|
|
22
|
-
export declare const getDocRef: <AppModelType extends AppModel = AppModel>({ db, reference, path, pathSegments }: GetDocRefOptions<AppModelType>) => FirebaseFirestoreTypes.DocumentReference<AppModelType
|
|
22
|
+
export declare const getDocRef: <AppModelType extends AppModel = AppModel>({ db, reference, path, pathSegments }: GetDocRefOptions<AppModelType>) => FirebaseFirestoreTypes.DocumentReference<AppModelType> | null;
|
|
@@ -10,8 +10,8 @@ import { doc } from "@react-native-firebase/firestore";
|
|
|
10
10
|
* @returns {DocumentReference<AppModelType, AppModelType>} Returns a document reference
|
|
11
11
|
*/
|
|
12
12
|
export const getDocRef = ({ db, reference, path, pathSegments }) => {
|
|
13
|
-
if (!reference && !path) {
|
|
14
|
-
|
|
13
|
+
if ((!reference && !path) || (reference && !path)) {
|
|
14
|
+
return null;
|
|
15
15
|
}
|
|
16
16
|
const docRef = !reference
|
|
17
17
|
? doc(db, path, ...(pathSegments || []))
|
|
@@ -29,8 +29,8 @@ export const getDocRef = <AppModelType extends AppModel = AppModel>({
|
|
|
29
29
|
path,
|
|
30
30
|
pathSegments
|
|
31
31
|
}: GetDocRefOptions<AppModelType>) => {
|
|
32
|
-
if (!reference && !path) {
|
|
33
|
-
|
|
32
|
+
if ((!reference && !path) || (reference && !path)) {
|
|
33
|
+
return null;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const docRef = !reference
|
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
|
+
};
|
|
@@ -25,4 +25,4 @@ export type UseDocReferencesOptions<AppModelType extends AppModel = AppModel> =
|
|
|
25
25
|
* };
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export declare const useDocReferences: <AppModelType extends AppModel = AppModel>({ references }: UseDocReferencesOptions<AppModelType>) => import("@firebase/firestore").DocumentReference<AppModelType, AppModelType>[];
|
|
28
|
+
export declare const useDocReferences: <AppModelType extends AppModel = AppModel>({ references }: UseDocReferencesOptions<AppModelType>) => (import("@firebase/firestore").DocumentReference<AppModelType, AppModelType> | null)[];
|
|
@@ -19,4 +19,4 @@ export type GetDocRefOptions<AppModelType extends AppModel = AppModel> = {
|
|
|
19
19
|
*
|
|
20
20
|
* @returns {DocumentReference<AppModelType, AppModelType>} Returns a document reference
|
|
21
21
|
*/
|
|
22
|
-
export declare const getDocRef: <AppModelType extends AppModel = AppModel>({ db, reference, path, pathSegments }: GetDocRefOptions<AppModelType>) => DocumentReference<AppModelType, AppModelType
|
|
22
|
+
export declare const getDocRef: <AppModelType extends AppModel = AppModel>({ db, reference, path, pathSegments }: GetDocRefOptions<AppModelType>) => DocumentReference<AppModelType, AppModelType> | null;
|
|
@@ -10,8 +10,8 @@ import { doc } from "firebase/firestore";
|
|
|
10
10
|
* @returns {DocumentReference<AppModelType, AppModelType>} Returns a document reference
|
|
11
11
|
*/
|
|
12
12
|
export const getDocRef = ({ db, reference, path, pathSegments }) => {
|
|
13
|
-
if (!reference && !path) {
|
|
14
|
-
|
|
13
|
+
if ((!reference && !path) || (reference && !path)) {
|
|
14
|
+
return null;
|
|
15
15
|
}
|
|
16
16
|
const docRef = !reference
|
|
17
17
|
? doc(db, path, ...(pathSegments || []))
|
|
@@ -27,17 +27,17 @@ export const getDocRef = <AppModelType extends AppModel = AppModel>({
|
|
|
27
27
|
path,
|
|
28
28
|
pathSegments
|
|
29
29
|
}: GetDocRefOptions<AppModelType>) => {
|
|
30
|
-
if (!reference && !path) {
|
|
31
|
-
|
|
30
|
+
if ((!reference && !path) || (reference && !path)) {
|
|
31
|
+
return null;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const docRef = !reference
|
|
35
|
-
? doc(db, path as string, ...(pathSegments || []))
|
|
35
|
+
? (doc(db, path as string, ...(pathSegments || [])) as DocumentReference<AppModelType, AppModelType>)
|
|
36
36
|
: reference.type === "collection"
|
|
37
|
-
? doc(reference, path, ...(pathSegments || []))
|
|
37
|
+
? (doc(reference, path, ...(pathSegments || [])) as DocumentReference<AppModelType, AppModelType>)
|
|
38
38
|
: reference.type === "document"
|
|
39
|
-
? doc(reference, path as string, ...(pathSegments || []))
|
|
39
|
+
? (doc(reference, path as string, ...(pathSegments || [])) as DocumentReference<AppModelType, AppModelType>)
|
|
40
40
|
: null;
|
|
41
41
|
|
|
42
|
-
return docRef
|
|
42
|
+
return docRef;
|
|
43
43
|
};
|