react-query-firebase 2.3.1 → 2.3.3
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/firestore/useGetRealtimeDocData.d.ts +4 -3
- package/react-native/firestore/useGetRealtimeDocData.ts +4 -9
- package/react-native/firestore/useInfiniteQuery.d.ts +3 -3
- package/react-native/firestore/useInfiniteQuery.ts +5 -15
- package/react-native/firestore/useQueryConstraints.d.ts +3 -2
- package/react-native/firestore/useQueryConstraints.ts +12 -3
- package/web/firestore/useGetRealtimeDocData.d.ts +6 -5
- package/web/firestore/useGetRealtimeDocData.js +1 -1
- package/web/firestore/useGetRealtimeDocData.ts +7 -6
- package/web/firestore/useInfiniteQuery.d.ts +1 -1
- package/web/firestore/useInfiniteQuery.ts +2 -2
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FirebaseFirestoreTypes } from "@react-native-firebase/firestore";
|
|
2
2
|
import { ReactNativeFirebase } from "@react-native-firebase/app";
|
|
3
|
+
import { AppModel } from "../../types";
|
|
3
4
|
/**
|
|
4
5
|
* @inline
|
|
5
6
|
*/
|
|
6
|
-
export type UseGetRealtimeDocDataOptions<AppModelType extends
|
|
7
|
+
export type UseGetRealtimeDocDataOptions<AppModelType extends AppModel = AppModel> = {
|
|
7
8
|
/**
|
|
8
9
|
* A slash-separated path to a document. Has to be omitted to use
|
|
9
10
|
*/
|
|
@@ -11,7 +12,7 @@ export type UseGetRealtimeDocDataOptions<AppModelType extends FirebaseFirestoreT
|
|
|
11
12
|
/**
|
|
12
13
|
* A reference to a collection.
|
|
13
14
|
*/
|
|
14
|
-
reference?: FirebaseFirestoreTypes.
|
|
15
|
+
reference?: FirebaseFirestoreTypes.DocumentReference<AppModelType>;
|
|
15
16
|
/**
|
|
16
17
|
* Additional path segments that will be applied relative
|
|
17
18
|
* to the first argument.
|
|
@@ -54,4 +55,4 @@ export type UseGetRealtimeDocDataResult<AppModelType> = {
|
|
|
54
55
|
* };
|
|
55
56
|
* ```
|
|
56
57
|
*/
|
|
57
|
-
export declare const useGetRealtimeDocData: <AppModelType extends
|
|
58
|
+
export declare const useGetRealtimeDocData: <AppModelType extends AppModel = AppModel>({ path, pathSegments, reference, onError }: UseGetRealtimeDocDataOptions<AppModelType>) => UseGetRealtimeDocDataResult<AppModelType>;
|
|
@@ -3,13 +3,12 @@ import { FirebaseFirestoreTypes, onSnapshot } from "@react-native-firebase/fires
|
|
|
3
3
|
import { useEffect, useMemo, useState } from "react";
|
|
4
4
|
import { ReactNativeFirebase } from "@react-native-firebase/app";
|
|
5
5
|
import { useDocReference } from "./useDocReference";
|
|
6
|
+
import { AppModel } from "../../types";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @inline
|
|
9
10
|
*/
|
|
10
|
-
export type UseGetRealtimeDocDataOptions<
|
|
11
|
-
AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData
|
|
12
|
-
> = {
|
|
11
|
+
export type UseGetRealtimeDocDataOptions<AppModelType extends AppModel = AppModel> = {
|
|
13
12
|
/**
|
|
14
13
|
* A slash-separated path to a document. Has to be omitted to use
|
|
15
14
|
*/
|
|
@@ -17,9 +16,7 @@ export type UseGetRealtimeDocDataOptions<
|
|
|
17
16
|
/**
|
|
18
17
|
* A reference to a collection.
|
|
19
18
|
*/
|
|
20
|
-
reference?:
|
|
21
|
-
| FirebaseFirestoreTypes.CollectionReference<AppModelType>
|
|
22
|
-
| FirebaseFirestoreTypes.DocumentReference<AppModelType>;
|
|
19
|
+
reference?: FirebaseFirestoreTypes.DocumentReference<AppModelType>;
|
|
23
20
|
/**
|
|
24
21
|
* Additional path segments that will be applied relative
|
|
25
22
|
* to the first argument.
|
|
@@ -64,9 +61,7 @@ export type UseGetRealtimeDocDataResult<AppModelType> = {
|
|
|
64
61
|
* };
|
|
65
62
|
* ```
|
|
66
63
|
*/
|
|
67
|
-
export const useGetRealtimeDocData = <
|
|
68
|
-
AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData
|
|
69
|
-
>({
|
|
64
|
+
export const useGetRealtimeDocData = <AppModelType extends AppModel = AppModel>({
|
|
70
65
|
path,
|
|
71
66
|
pathSegments,
|
|
72
67
|
reference,
|
|
@@ -5,11 +5,11 @@ import { AppModel } from "../../types";
|
|
|
5
5
|
/**
|
|
6
6
|
* @inline
|
|
7
7
|
*/
|
|
8
|
-
type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey extends QueryKey = QueryKey
|
|
8
|
+
type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey extends QueryKey = QueryKey> = {
|
|
9
9
|
/**
|
|
10
10
|
* Reqct-query options that must include queryKey and shall not define queryFn
|
|
11
11
|
*/
|
|
12
|
-
options: Omit<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey,
|
|
12
|
+
options: Omit<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey, QueryNonFilterConstraint>, "queryFn"> & Required<Pick<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey, QueryNonFilterConstraint>, "queryKey">>;
|
|
13
13
|
/**
|
|
14
14
|
* Reference to a Firestore collection
|
|
15
15
|
*/
|
|
@@ -45,5 +45,5 @@ type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey
|
|
|
45
45
|
* };
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
|
-
export declare const useInfiniteQuery: <AppModelType extends AppModel = AppModel, TQueryKey extends QueryKey = QueryKey
|
|
48
|
+
export declare const useInfiniteQuery: <AppModelType extends AppModel = AppModel, TQueryKey extends QueryKey = QueryKey>({ options, collectionReference, queryConstraints, compositeFilter }: UseInfiniteQueryOptions<AppModelType, TQueryKey>) => UseInfiniteQueryResult<InfiniteData<AppModelType[]>>;
|
|
49
49
|
export {};
|
|
@@ -19,11 +19,7 @@ import { AppModel } from "../../types";
|
|
|
19
19
|
/**
|
|
20
20
|
* @inline
|
|
21
21
|
*/
|
|
22
|
-
type UseInfiniteQueryOptions<
|
|
23
|
-
AppModelType extends AppModel = AppModel,
|
|
24
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
25
|
-
TPageParam = unknown
|
|
26
|
-
> = {
|
|
22
|
+
type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey extends QueryKey = QueryKey> = {
|
|
27
23
|
/**
|
|
28
24
|
* Reqct-query options that must include queryKey and shall not define queryFn
|
|
29
25
|
*/
|
|
@@ -34,7 +30,7 @@ type UseInfiniteQueryOptions<
|
|
|
34
30
|
InfiniteData<AppModelType[]>,
|
|
35
31
|
AppModelType[],
|
|
36
32
|
TQueryKey,
|
|
37
|
-
|
|
33
|
+
QueryNonFilterConstraint
|
|
38
34
|
>,
|
|
39
35
|
"queryFn"
|
|
40
36
|
> &
|
|
@@ -46,7 +42,7 @@ type UseInfiniteQueryOptions<
|
|
|
46
42
|
InfiniteData<AppModelType[]>,
|
|
47
43
|
AppModelType[],
|
|
48
44
|
TQueryKey,
|
|
49
|
-
|
|
45
|
+
QueryNonFilterConstraint
|
|
50
46
|
>,
|
|
51
47
|
"queryKey"
|
|
52
48
|
>
|
|
@@ -90,18 +86,12 @@ type UseInfiniteQueryOptions<
|
|
|
90
86
|
* };
|
|
91
87
|
* ```
|
|
92
88
|
*/
|
|
93
|
-
export const useInfiniteQuery = <
|
|
94
|
-
AppModelType extends AppModel = AppModel,
|
|
95
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
96
|
-
TPageParam = unknown
|
|
97
|
-
>({
|
|
89
|
+
export const useInfiniteQuery = <AppModelType extends AppModel = AppModel, TQueryKey extends QueryKey = QueryKey>({
|
|
98
90
|
options,
|
|
99
91
|
collectionReference,
|
|
100
92
|
queryConstraints = [],
|
|
101
93
|
compositeFilter
|
|
102
|
-
}: UseInfiniteQueryOptions<AppModelType, TQueryKey
|
|
103
|
-
InfiniteData<AppModelType[]>
|
|
104
|
-
> => {
|
|
94
|
+
}: UseInfiniteQueryOptions<AppModelType, TQueryKey>): UseInfiniteQueryResult<InfiniteData<AppModelType[]>> => {
|
|
105
95
|
return useInfiniteReactQuery({
|
|
106
96
|
...options,
|
|
107
97
|
queryFn: async ({ pageParam }) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type QueryNonFilterConstraint } from "@react-native-firebase/firestore";
|
|
1
2
|
import { AppModel } from "../../types/AppModel";
|
|
2
3
|
import { type NonFilterQueryConstraint } from "../../types/QueryConstraints";
|
|
3
4
|
/**
|
|
@@ -29,7 +30,7 @@ export type UseQueryConstraints<AppModelType extends AppModel = AppModel> = {
|
|
|
29
30
|
* };
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
export declare const buildQueryConstraint: <AppModelType extends AppModel = AppModel>(constraint: NonFilterQueryConstraint<AppModelType>) =>
|
|
33
|
+
export declare const buildQueryConstraint: <AppModelType extends AppModel = AppModel>(constraint: NonFilterQueryConstraint<AppModelType>) => QueryNonFilterConstraint;
|
|
33
34
|
/**
|
|
34
35
|
* A hook to build a list of non-filter query constraints for firebase queries.
|
|
35
36
|
* It uses buildQueryConstraint method and useMemo hook.
|
|
@@ -51,4 +52,4 @@ export declare const buildQueryConstraint: <AppModelType extends AppModel = AppM
|
|
|
51
52
|
* ]};
|
|
52
53
|
* ```
|
|
53
54
|
*/
|
|
54
|
-
export declare const useQueryConstraints: <AppModelType extends AppModel = AppModel>({ constraints }: UseQueryConstraints<AppModelType>) =>
|
|
55
|
+
export declare const useQueryConstraints: <AppModelType extends AppModel = AppModel>({ constraints }: UseQueryConstraints<AppModelType>) => QueryNonFilterConstraint[];
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
startAt,
|
|
3
|
+
orderBy,
|
|
4
|
+
limit,
|
|
5
|
+
limitToLast,
|
|
6
|
+
startAfter,
|
|
7
|
+
endAt,
|
|
8
|
+
endBefore,
|
|
9
|
+
type QueryNonFilterConstraint
|
|
10
|
+
} from "@react-native-firebase/firestore";
|
|
2
11
|
import { useMemo } from "react";
|
|
3
12
|
import { AppModel } from "../../types/AppModel";
|
|
4
13
|
import { type NonFilterQueryConstraint } from "../../types/QueryConstraints";
|
|
@@ -35,7 +44,7 @@ export type UseQueryConstraints<AppModelType extends AppModel = AppModel> = {
|
|
|
35
44
|
*/
|
|
36
45
|
export const buildQueryConstraint = <AppModelType extends AppModel = AppModel>(
|
|
37
46
|
constraint: NonFilterQueryConstraint<AppModelType>
|
|
38
|
-
) => {
|
|
47
|
+
): QueryNonFilterConstraint => {
|
|
39
48
|
switch (constraint.type) {
|
|
40
49
|
case "orderBy":
|
|
41
50
|
return orderBy(constraint.fieldPath as string, constraint.directionStr);
|
|
@@ -77,7 +86,7 @@ export const buildQueryConstraint = <AppModelType extends AppModel = AppModel>(
|
|
|
77
86
|
*/
|
|
78
87
|
export const useQueryConstraints = <AppModelType extends AppModel = AppModel>({
|
|
79
88
|
constraints
|
|
80
|
-
}: UseQueryConstraints<AppModelType>) => {
|
|
89
|
+
}: UseQueryConstraints<AppModelType>): QueryNonFilterConstraint[] => {
|
|
81
90
|
return useMemo(() => {
|
|
82
91
|
return constraints.map(buildQueryConstraint);
|
|
83
92
|
}, [constraints]);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocumentReference } from "firebase/firestore";
|
|
2
2
|
import { FirebaseError } from "firebase/app";
|
|
3
|
+
import { AppModel } from "../../types";
|
|
3
4
|
/**
|
|
4
5
|
* @inline
|
|
5
6
|
*/
|
|
6
|
-
export type UseGetRealtimeDocDataOptions<AppModelType
|
|
7
|
+
export type UseGetRealtimeDocDataOptions<AppModelType extends AppModel = AppModel> = {
|
|
7
8
|
/**
|
|
8
9
|
* A slash-separated path to a document. Has to be omitted to use
|
|
9
10
|
*/
|
|
@@ -11,7 +12,7 @@ export type UseGetRealtimeDocDataOptions<AppModelType, DbModelType extends Docum
|
|
|
11
12
|
/**
|
|
12
13
|
* A reference to a collection.
|
|
13
14
|
*/
|
|
14
|
-
reference?:
|
|
15
|
+
reference?: DocumentReference<AppModelType, AppModelType>;
|
|
15
16
|
/**
|
|
16
17
|
* Additional path segments that will be applied relative
|
|
17
18
|
* to the first argument.
|
|
@@ -37,7 +38,7 @@ export type UseGetRealtimeDocDataResult<AppModelType> = {
|
|
|
37
38
|
*
|
|
38
39
|
* @group Hook
|
|
39
40
|
*
|
|
40
|
-
* @param {UseGetRealtimeDocDataOptions<AppModelType
|
|
41
|
+
* @param {UseGetRealtimeDocDataOptions<AppModelType>} options
|
|
41
42
|
*
|
|
42
43
|
* @returns {UseGetRealtimeDocDataResult<AppModelType>}
|
|
43
44
|
*
|
|
@@ -54,4 +55,4 @@ export type UseGetRealtimeDocDataResult<AppModelType> = {
|
|
|
54
55
|
* };
|
|
55
56
|
* ```
|
|
56
57
|
*/
|
|
57
|
-
export declare const useGetRealtimeDocData: <AppModelType
|
|
58
|
+
export declare const useGetRealtimeDocData: <AppModelType extends AppModel = AppModel>({ path, pathSegments, reference, onError }: UseGetRealtimeDocDataOptions<AppModelType>) => UseGetRealtimeDocDataResult<AppModelType>;
|
|
@@ -6,7 +6,7 @@ import { useDocReference } from "./useDocReference";
|
|
|
6
6
|
*
|
|
7
7
|
* @group Hook
|
|
8
8
|
*
|
|
9
|
-
* @param {UseGetRealtimeDocDataOptions<AppModelType
|
|
9
|
+
* @param {UseGetRealtimeDocDataOptions<AppModelType>} options
|
|
10
10
|
*
|
|
11
11
|
* @returns {UseGetRealtimeDocDataResult<AppModelType>}
|
|
12
12
|
*
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocumentReference, onSnapshot } from "firebase/firestore";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useMemo, useState } from "react";
|
|
4
4
|
import { FirebaseError } from "firebase/app";
|
|
5
5
|
import { useDocReference } from "./useDocReference";
|
|
6
|
+
import { AppModel } from "../../types";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @inline
|
|
9
10
|
*/
|
|
10
|
-
export type UseGetRealtimeDocDataOptions<AppModelType
|
|
11
|
+
export type UseGetRealtimeDocDataOptions<AppModelType extends AppModel = AppModel> = {
|
|
11
12
|
/**
|
|
12
13
|
* A slash-separated path to a document. Has to be omitted to use
|
|
13
14
|
*/
|
|
@@ -15,7 +16,7 @@ export type UseGetRealtimeDocDataOptions<AppModelType, DbModelType extends Docum
|
|
|
15
16
|
/**
|
|
16
17
|
* A reference to a collection.
|
|
17
18
|
*/
|
|
18
|
-
reference?:
|
|
19
|
+
reference?: DocumentReference<AppModelType, AppModelType>;
|
|
19
20
|
/**
|
|
20
21
|
* Additional path segments that will be applied relative
|
|
21
22
|
* to the first argument.
|
|
@@ -43,7 +44,7 @@ export type UseGetRealtimeDocDataResult<AppModelType> = {
|
|
|
43
44
|
*
|
|
44
45
|
* @group Hook
|
|
45
46
|
*
|
|
46
|
-
* @param {UseGetRealtimeDocDataOptions<AppModelType
|
|
47
|
+
* @param {UseGetRealtimeDocDataOptions<AppModelType>} options
|
|
47
48
|
*
|
|
48
49
|
* @returns {UseGetRealtimeDocDataResult<AppModelType>}
|
|
49
50
|
*
|
|
@@ -60,12 +61,12 @@ export type UseGetRealtimeDocDataResult<AppModelType> = {
|
|
|
60
61
|
* };
|
|
61
62
|
* ```
|
|
62
63
|
*/
|
|
63
|
-
export const useGetRealtimeDocData = <AppModelType
|
|
64
|
+
export const useGetRealtimeDocData = <AppModelType extends AppModel = AppModel>({
|
|
64
65
|
path,
|
|
65
66
|
pathSegments,
|
|
66
67
|
reference,
|
|
67
68
|
onError
|
|
68
|
-
}: UseGetRealtimeDocDataOptions<AppModelType
|
|
69
|
+
}: UseGetRealtimeDocDataOptions<AppModelType>): UseGetRealtimeDocDataResult<AppModelType> => {
|
|
69
70
|
const ref = useDocReference({ path, reference, pathSegments });
|
|
70
71
|
const [doc, setDoc] = useState<AppModelType | null>(null);
|
|
71
72
|
const [isError, setIsError] = useState(false);
|
|
@@ -9,7 +9,7 @@ type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey
|
|
|
9
9
|
/**
|
|
10
10
|
* Reqct-query options that must include queryKey and shall not define queryFn
|
|
11
11
|
*/
|
|
12
|
-
options: Omit<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey,
|
|
12
|
+
options: Omit<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey, QueryNonFilterConstraint>, "queryFn"> & Required<Pick<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey, QueryNonFilterConstraint>, "queryKey">>;
|
|
13
13
|
/**
|
|
14
14
|
* Reference to a Firestore collection
|
|
15
15
|
*/
|
|
@@ -31,7 +31,7 @@ type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey
|
|
|
31
31
|
InfiniteData<AppModelType[]>,
|
|
32
32
|
AppModelType[],
|
|
33
33
|
TQueryKey,
|
|
34
|
-
|
|
34
|
+
QueryNonFilterConstraint
|
|
35
35
|
>,
|
|
36
36
|
"queryFn"
|
|
37
37
|
> &
|
|
@@ -43,7 +43,7 @@ type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey
|
|
|
43
43
|
InfiniteData<AppModelType[]>,
|
|
44
44
|
AppModelType[],
|
|
45
45
|
TQueryKey,
|
|
46
|
-
|
|
46
|
+
QueryNonFilterConstraint
|
|
47
47
|
>,
|
|
48
48
|
"queryKey"
|
|
49
49
|
>
|