@refinedev/core 4.5.7 → 4.5.9
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/CHANGELOG.md +35 -0
- package/dist/esm/index.js +6 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/auth/useForgotPassword/index.d.ts +7 -7
- package/dist/hooks/auth/useForgotPassword/index.d.ts.map +1 -1
- package/dist/hooks/auth/useLogin/index.d.ts +7 -7
- package/dist/hooks/auth/useLogin/index.d.ts.map +1 -1
- package/dist/hooks/auth/useLogout/index.d.ts +7 -7
- package/dist/hooks/auth/useLogout/index.d.ts.map +1 -1
- package/dist/hooks/auth/useRegister/index.d.ts +7 -7
- package/dist/hooks/auth/useRegister/index.d.ts.map +1 -1
- package/dist/hooks/auth/useUpdatePassword/index.d.ts +7 -7
- package/dist/hooks/auth/useUpdatePassword/index.d.ts.map +1 -1
- package/dist/hooks/data/useCreate.d.ts +4 -4
- package/dist/hooks/data/useCreate.d.ts.map +1 -1
- package/dist/hooks/data/useCreateMany.d.ts +4 -4
- package/dist/hooks/data/useCreateMany.d.ts.map +1 -1
- package/dist/hooks/data/useCustom.d.ts +2 -2
- package/dist/hooks/data/useCustom.d.ts.map +1 -1
- package/dist/hooks/data/useCustomMutation.d.ts +5 -5
- package/dist/hooks/data/useCustomMutation.d.ts.map +1 -1
- package/dist/hooks/data/useDelete.d.ts +4 -4
- package/dist/hooks/data/useDelete.d.ts.map +1 -1
- package/dist/hooks/data/useDeleteMany.d.ts +4 -4
- package/dist/hooks/data/useDeleteMany.d.ts.map +1 -1
- package/dist/hooks/data/useInfiniteList.d.ts +20 -17
- package/dist/hooks/data/useInfiniteList.d.ts.map +1 -1
- package/dist/hooks/data/useList.d.ts +13 -11
- package/dist/hooks/data/useList.d.ts.map +1 -1
- package/dist/hooks/data/useMany.d.ts +1 -1
- package/dist/hooks/data/useMany.d.ts.map +1 -1
- package/dist/hooks/data/useOne.d.ts +4 -2
- package/dist/hooks/data/useOne.d.ts.map +1 -1
- package/dist/hooks/data/useUpdate.d.ts +7 -4
- package/dist/hooks/data/useUpdate.d.ts.map +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts +7 -4
- package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
- package/dist/hooks/form/useForm.d.ts +4 -1
- package/dist/hooks/form/useForm.d.ts.map +1 -1
- package/dist/hooks/show/useShow.d.ts +5 -3
- package/dist/hooks/show/useShow.d.ts.map +1 -1
- package/dist/hooks/useSelect/index.d.ts +2 -1
- package/dist/hooks/useSelect/index.d.ts.map +1 -1
- package/dist/hooks/useTable/index.d.ts +3 -2
- package/dist/hooks/useTable/index.d.ts.map +1 -1
- package/dist/iife/index.js +5 -5
- package/dist/iife/index.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/bindings/auth.d.ts +4 -3
- package/dist/interfaces/bindings/auth.d.ts.map +1 -1
- package/dist/interfaces/errors/HttpError.d.ts.map +1 -0
- package/dist/interfaces/errors/RefineError.d.ts +3 -0
- package/dist/interfaces/errors/RefineError.d.ts.map +1 -0
- package/dist/interfaces/errors/index.d.ts +3 -0
- package/dist/interfaces/errors/index.d.ts.map +1 -0
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/hooks/auth/useForgotPassword/index.ts +22 -9
- package/src/hooks/auth/useLogin/index.ts +27 -11
- package/src/hooks/auth/useLogout/index.ts +16 -10
- package/src/hooks/auth/useRegister/index.ts +22 -9
- package/src/hooks/auth/useUpdatePassword/index.ts +31 -8
- package/src/hooks/data/useCreate.ts +6 -6
- package/src/hooks/data/useCreateMany.ts +6 -6
- package/src/hooks/data/useCustom.ts +6 -1
- package/src/hooks/data/useCustomMutation.ts +11 -6
- package/src/hooks/data/useDelete.ts +5 -5
- package/src/hooks/data/useDeleteMany.ts +6 -6
- package/src/hooks/data/useInfiniteList.ts +25 -15
- package/src/hooks/data/useList.ts +20 -10
- package/src/hooks/data/useMany.ts +1 -1
- package/src/hooks/data/useOne.ts +6 -1
- package/src/hooks/data/useUpdate.ts +9 -5
- package/src/hooks/data/useUpdateMany.ts +10 -6
- package/src/hooks/form/useForm.ts +6 -2
- package/src/hooks/show/useShow.ts +8 -3
- package/src/hooks/useSelect/index.ts +6 -1
- package/src/hooks/useTable/index.ts +8 -3
- package/src/interfaces/bindings/auth.ts +5 -3
- package/src/interfaces/errors/RefineError.ts +3 -0
- package/src/interfaces/errors/index.ts +2 -0
- package/src/interfaces/index.ts +1 -1
- package/dist/interfaces/HttpError.d.ts.map +0 -1
- /package/dist/interfaces/{HttpError.d.ts → errors/HttpError.d.ts} +0 -0
- /package/src/interfaces/{HttpError.ts → errors/HttpError.ts} +0 -0
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
CustomResponse,
|
|
19
19
|
HttpError,
|
|
20
20
|
MetaQuery,
|
|
21
|
+
Prettify,
|
|
21
22
|
SuccessErrorNotification,
|
|
22
23
|
} from "../../interfaces";
|
|
23
24
|
|
|
@@ -63,7 +64,11 @@ export type UseCustomProps<TData, TError, TQuery, TPayload> = {
|
|
|
63
64
|
* If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use.
|
|
64
65
|
*/
|
|
65
66
|
dataProviderName?: string;
|
|
66
|
-
} & SuccessErrorNotification
|
|
67
|
+
} & SuccessErrorNotification<
|
|
68
|
+
CustomResponse<TData>,
|
|
69
|
+
TError,
|
|
70
|
+
Prettify<UseCustomConfig<TQuery, TPayload> & MetaQuery>
|
|
71
|
+
>;
|
|
67
72
|
|
|
68
73
|
/**
|
|
69
74
|
* `useCustom` is a modified version of `react-query`'s {@link https://react-query.tanstack.com/guides/queries `useQuery`} used for custom requests.
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
HttpError,
|
|
17
17
|
SuccessErrorNotification,
|
|
18
18
|
MetaQuery,
|
|
19
|
+
Prettify,
|
|
19
20
|
} from "../../interfaces";
|
|
20
21
|
import { pickNotDeprecated, useActiveAuthProvider } from "@definitions/helpers";
|
|
21
22
|
|
|
@@ -23,7 +24,7 @@ interface UseCustomMutationConfig {
|
|
|
23
24
|
headers?: {};
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
type useCustomMutationParams<TVariables> = {
|
|
27
|
+
type useCustomMutationParams<TData, TError, TVariables> = {
|
|
27
28
|
url: string;
|
|
28
29
|
method: "post" | "put" | "patch" | "delete";
|
|
29
30
|
values: TVariables;
|
|
@@ -38,7 +39,11 @@ type useCustomMutationParams<TVariables> = {
|
|
|
38
39
|
metaData?: MetaQuery;
|
|
39
40
|
dataProviderName?: string;
|
|
40
41
|
config?: UseCustomMutationConfig;
|
|
41
|
-
} & SuccessErrorNotification
|
|
42
|
+
} & SuccessErrorNotification<
|
|
43
|
+
CreateResponse<TData>,
|
|
44
|
+
TError,
|
|
45
|
+
Prettify<UseCustomMutationConfig & MetaQuery>
|
|
46
|
+
>;
|
|
42
47
|
|
|
43
48
|
export type UseCustomMutationReturnType<
|
|
44
49
|
TData extends BaseRecord = BaseRecord,
|
|
@@ -47,7 +52,7 @@ export type UseCustomMutationReturnType<
|
|
|
47
52
|
> = UseMutationResult<
|
|
48
53
|
CreateResponse<TData>,
|
|
49
54
|
TError,
|
|
50
|
-
useCustomMutationParams<TVariables>,
|
|
55
|
+
useCustomMutationParams<TData, TError, TVariables>,
|
|
51
56
|
unknown
|
|
52
57
|
>;
|
|
53
58
|
|
|
@@ -60,7 +65,7 @@ export type UseCustomMutationProps<
|
|
|
60
65
|
UseMutationOptions<
|
|
61
66
|
CreateResponse<TData>,
|
|
62
67
|
TError,
|
|
63
|
-
useCustomMutationParams<TVariables>,
|
|
68
|
+
useCustomMutationParams<TData, TError, TVariables>,
|
|
64
69
|
unknown
|
|
65
70
|
>,
|
|
66
71
|
"mutationFn" | "onError" | "onSuccess"
|
|
@@ -102,7 +107,7 @@ export const useCustomMutation = <
|
|
|
102
107
|
const mutation = useMutation<
|
|
103
108
|
CreateResponse<TData>,
|
|
104
109
|
TError,
|
|
105
|
-
useCustomMutationParams<TVariables>,
|
|
110
|
+
useCustomMutationParams<TData, TError, TVariables>,
|
|
106
111
|
unknown
|
|
107
112
|
>(
|
|
108
113
|
({
|
|
@@ -113,7 +118,7 @@ export const useCustomMutation = <
|
|
|
113
118
|
metaData,
|
|
114
119
|
dataProviderName,
|
|
115
120
|
config,
|
|
116
|
-
}: useCustomMutationParams<TVariables>) => {
|
|
121
|
+
}: useCustomMutationParams<TData, TError, TVariables>) => {
|
|
117
122
|
const { custom } = dataProvider(dataProviderName);
|
|
118
123
|
|
|
119
124
|
if (custom) {
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
useActiveAuthProvider,
|
|
40
40
|
} from "@definitions/helpers";
|
|
41
41
|
|
|
42
|
-
export type DeleteParams<TVariables> = {
|
|
42
|
+
export type DeleteParams<TData, TError, TVariables> = {
|
|
43
43
|
id: BaseKey;
|
|
44
44
|
resource: string;
|
|
45
45
|
mutationMode?: MutationMode;
|
|
@@ -53,7 +53,7 @@ export type DeleteParams<TVariables> = {
|
|
|
53
53
|
dataProviderName?: string;
|
|
54
54
|
invalidates?: Array<keyof IQueryKeys>;
|
|
55
55
|
values?: TVariables;
|
|
56
|
-
} & SuccessErrorNotification
|
|
56
|
+
} & SuccessErrorNotification<DeleteOneResponse<TData>, TError, BaseKey>;
|
|
57
57
|
|
|
58
58
|
export type UseDeleteReturnType<
|
|
59
59
|
TData extends BaseRecord = BaseRecord,
|
|
@@ -62,7 +62,7 @@ export type UseDeleteReturnType<
|
|
|
62
62
|
> = UseMutationResult<
|
|
63
63
|
DeleteOneResponse<TData>,
|
|
64
64
|
TError,
|
|
65
|
-
DeleteParams<TVariables>,
|
|
65
|
+
DeleteParams<TData, TError, TVariables>,
|
|
66
66
|
DeleteContext<TData>
|
|
67
67
|
>;
|
|
68
68
|
|
|
@@ -75,7 +75,7 @@ export type UseDeleteProps<
|
|
|
75
75
|
UseMutationOptions<
|
|
76
76
|
DeleteOneResponse<TData>,
|
|
77
77
|
TError,
|
|
78
|
-
DeleteParams<TVariables>,
|
|
78
|
+
DeleteParams<TData, TError, TVariables>,
|
|
79
79
|
DeleteContext<TData>
|
|
80
80
|
>,
|
|
81
81
|
"mutationFn" | "onError" | "onSuccess" | "onSettled" | "onMutate"
|
|
@@ -129,7 +129,7 @@ export const useDelete = <
|
|
|
129
129
|
const mutation = useMutation<
|
|
130
130
|
DeleteOneResponse<TData>,
|
|
131
131
|
TError,
|
|
132
|
-
DeleteParams<TVariables>,
|
|
132
|
+
DeleteParams<TData, TError, TVariables>,
|
|
133
133
|
DeleteContext<TData>
|
|
134
134
|
>(
|
|
135
135
|
({
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
useActiveAuthProvider,
|
|
41
41
|
} from "@definitions";
|
|
42
42
|
|
|
43
|
-
export type DeleteManyParams<TVariables> = {
|
|
43
|
+
export type DeleteManyParams<TData, TError, TVariables> = {
|
|
44
44
|
ids: BaseKey[];
|
|
45
45
|
resource: string;
|
|
46
46
|
mutationMode?: MutationMode;
|
|
@@ -54,7 +54,7 @@ export type DeleteManyParams<TVariables> = {
|
|
|
54
54
|
dataProviderName?: string;
|
|
55
55
|
invalidates?: Array<keyof IQueryKeys>;
|
|
56
56
|
values?: TVariables;
|
|
57
|
-
} & SuccessErrorNotification
|
|
57
|
+
} & SuccessErrorNotification<DeleteManyResponse<TData>, TError, BaseKey[]>;
|
|
58
58
|
|
|
59
59
|
export type UseDeleteManyReturnType<
|
|
60
60
|
TData extends BaseRecord = BaseRecord,
|
|
@@ -63,7 +63,7 @@ export type UseDeleteManyReturnType<
|
|
|
63
63
|
> = UseMutationResult<
|
|
64
64
|
DeleteManyResponse<TData>,
|
|
65
65
|
TError,
|
|
66
|
-
DeleteManyParams<TVariables>,
|
|
66
|
+
DeleteManyParams<TData, TError, TVariables>,
|
|
67
67
|
unknown
|
|
68
68
|
>;
|
|
69
69
|
|
|
@@ -76,7 +76,7 @@ export type UseDeleteManyProps<
|
|
|
76
76
|
UseMutationOptions<
|
|
77
77
|
DeleteManyResponse<TData>,
|
|
78
78
|
TError,
|
|
79
|
-
DeleteManyParams<TVariables>,
|
|
79
|
+
DeleteManyParams<TData, TError, TVariables>,
|
|
80
80
|
DeleteContext<TData>
|
|
81
81
|
>,
|
|
82
82
|
"mutationFn" | "onError" | "onSuccess" | "onSettled" | "onMutate"
|
|
@@ -130,7 +130,7 @@ export const useDeleteMany = <
|
|
|
130
130
|
const mutation = useMutation<
|
|
131
131
|
DeleteManyResponse<TData>,
|
|
132
132
|
TError,
|
|
133
|
-
DeleteManyParams<TVariables>,
|
|
133
|
+
DeleteManyParams<TData, TError, TVariables>,
|
|
134
134
|
DeleteContext<TData>
|
|
135
135
|
>(
|
|
136
136
|
({
|
|
@@ -143,7 +143,7 @@ export const useDeleteMany = <
|
|
|
143
143
|
metaData,
|
|
144
144
|
dataProviderName,
|
|
145
145
|
values,
|
|
146
|
-
}: DeleteManyParams<TVariables>) => {
|
|
146
|
+
}: DeleteManyParams<TData, TError, TVariables>) => {
|
|
147
147
|
const mutationModePropOrContext =
|
|
148
148
|
mutationMode ?? mutationModeContext;
|
|
149
149
|
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
useInfiniteQuery,
|
|
3
3
|
UseInfiniteQueryOptions,
|
|
4
4
|
InfiniteQueryObserverResult,
|
|
5
|
+
InfiniteData,
|
|
5
6
|
} from "@tanstack/react-query";
|
|
6
7
|
import {
|
|
7
8
|
CrudFilters,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
SuccessErrorNotification,
|
|
14
15
|
LiveModeProps,
|
|
15
16
|
GetListResponse,
|
|
17
|
+
Prettify,
|
|
16
18
|
} from "../../interfaces";
|
|
17
19
|
import {
|
|
18
20
|
useResource,
|
|
@@ -39,11 +41,16 @@ export interface UseInfiniteListConfig {
|
|
|
39
41
|
filters?: CrudFilters;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
type BaseInfiniteListProps = {
|
|
43
45
|
/**
|
|
44
|
-
*
|
|
46
|
+
* Metadata query for `dataProvider`
|
|
45
47
|
*/
|
|
46
|
-
|
|
48
|
+
meta?: MetaQuery;
|
|
49
|
+
/**
|
|
50
|
+
* Metadata query for `dataProvider`
|
|
51
|
+
* @deprecated `metaData` is deprecated with refine@4, refine will pass `meta` instead, however, we still support `metaData` for backward compatibility.
|
|
52
|
+
*/
|
|
53
|
+
metaData?: MetaQuery;
|
|
47
54
|
/**
|
|
48
55
|
* Configuration for pagination, sorting and filtering
|
|
49
56
|
* @type [`useInfiniteListConfig`](/docs/api-reference/core/hooks/data/useInfiniteList/#config-parameters)
|
|
@@ -68,23 +75,26 @@ export type UseInfiniteListProps<TData, TError> = {
|
|
|
68
75
|
*/
|
|
69
76
|
filters?: CrudFilters;
|
|
70
77
|
/**
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
73
|
-
queryOptions?: UseInfiniteQueryOptions<GetListResponse<TData>, TError>;
|
|
74
|
-
/**
|
|
75
|
-
* Metadata query for `dataProvider`
|
|
78
|
+
* If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use
|
|
76
79
|
*/
|
|
77
|
-
|
|
80
|
+
dataProviderName?: string;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type UseInfiniteListProps<TData, TError> = {
|
|
78
84
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @deprecated `metaData` is deprecated with refine@4, refine will pass `meta` instead, however, we still support `metaData` for backward compatibility.
|
|
85
|
+
* Resource name for API data interactions
|
|
81
86
|
*/
|
|
82
|
-
|
|
87
|
+
resource: string;
|
|
83
88
|
/**
|
|
84
|
-
*
|
|
89
|
+
* Tanstack Query's [useInfiniteQuery](https://tanstack.com/query/v4/docs/react/reference/useInfiniteQuery) options
|
|
85
90
|
*/
|
|
86
|
-
|
|
87
|
-
} &
|
|
91
|
+
queryOptions?: UseInfiniteQueryOptions<GetListResponse<TData>, TError>;
|
|
92
|
+
} & BaseInfiniteListProps &
|
|
93
|
+
SuccessErrorNotification<
|
|
94
|
+
InfiniteData<GetListResponse<TData>>,
|
|
95
|
+
TError,
|
|
96
|
+
Prettify<BaseInfiniteListProps>
|
|
97
|
+
> &
|
|
88
98
|
LiveModeProps;
|
|
89
99
|
|
|
90
100
|
/**
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
MetaQuery,
|
|
14
14
|
SuccessErrorNotification,
|
|
15
15
|
LiveModeProps,
|
|
16
|
+
Prettify,
|
|
16
17
|
} from "../../interfaces";
|
|
17
18
|
import {
|
|
18
19
|
useResource,
|
|
@@ -37,11 +38,7 @@ export interface UseListConfig {
|
|
|
37
38
|
filters?: CrudFilters;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export type
|
|
41
|
-
/**
|
|
42
|
-
* Resource name for API data interactions
|
|
43
|
-
*/
|
|
44
|
-
resource?: string;
|
|
41
|
+
export type BaseListProps = {
|
|
45
42
|
/**
|
|
46
43
|
* Configuration for pagination, sorting and filtering
|
|
47
44
|
* @type [`UseListConfig`](/docs/api-reference/core/hooks/data/useList/#config-parameters)
|
|
@@ -65,10 +62,6 @@ export type UseListProps<TData, TError> = {
|
|
|
65
62
|
* Filter parameters
|
|
66
63
|
*/
|
|
67
64
|
filters?: CrudFilters;
|
|
68
|
-
/**
|
|
69
|
-
* Tanstack Query's [useQuery](https://tanstack.com/query/v4/docs/reference/useQuery) options
|
|
70
|
-
*/
|
|
71
|
-
queryOptions?: UseQueryOptions<GetListResponse<TData>, TError>;
|
|
72
65
|
/**
|
|
73
66
|
* Meta data query for `dataProvider`
|
|
74
67
|
*/
|
|
@@ -82,7 +75,24 @@ export type UseListProps<TData, TError> = {
|
|
|
82
75
|
* If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use
|
|
83
76
|
*/
|
|
84
77
|
dataProviderName?: string;
|
|
85
|
-
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type UseListProps<TData, TError> = {
|
|
81
|
+
/**
|
|
82
|
+
* Resource name for API data interactions
|
|
83
|
+
*/
|
|
84
|
+
resource?: string;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Tanstack Query's [useQuery](https://tanstack.com/query/v4/docs/reference/useQuery) options
|
|
88
|
+
*/
|
|
89
|
+
queryOptions?: UseQueryOptions<GetListResponse<TData>, TError>;
|
|
90
|
+
} & BaseListProps &
|
|
91
|
+
SuccessErrorNotification<
|
|
92
|
+
GetListResponse<TData>,
|
|
93
|
+
TError,
|
|
94
|
+
Prettify<BaseListProps>
|
|
95
|
+
> &
|
|
86
96
|
LiveModeProps;
|
|
87
97
|
|
|
88
98
|
/**
|
package/src/hooks/data/useOne.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
LiveModeProps,
|
|
13
13
|
SuccessErrorNotification,
|
|
14
14
|
MetaQuery,
|
|
15
|
+
Prettify,
|
|
15
16
|
} from "../../interfaces";
|
|
16
17
|
import {
|
|
17
18
|
useResource,
|
|
@@ -56,7 +57,11 @@ export type UseOneProps<TData, TError> = {
|
|
|
56
57
|
* @default `"default"``
|
|
57
58
|
*/
|
|
58
59
|
dataProviderName?: string;
|
|
59
|
-
} & SuccessErrorNotification
|
|
60
|
+
} & SuccessErrorNotification<
|
|
61
|
+
GetOneResponse<TData>,
|
|
62
|
+
TError,
|
|
63
|
+
Prettify<{ id?: BaseKey } & MetaQuery>
|
|
64
|
+
> &
|
|
60
65
|
LiveModeProps;
|
|
61
66
|
|
|
62
67
|
/**
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
useActiveAuthProvider,
|
|
40
40
|
} from "@definitions/helpers";
|
|
41
41
|
|
|
42
|
-
export type UpdateParams<TVariables> = {
|
|
42
|
+
export type UpdateParams<TData, TError, TVariables> = {
|
|
43
43
|
/**
|
|
44
44
|
* Resource name for API data interactions
|
|
45
45
|
*/
|
|
@@ -82,7 +82,11 @@ export type UpdateParams<TVariables> = {
|
|
|
82
82
|
* You can use it to manage the invalidations that will occur at the end of the mutation.
|
|
83
83
|
*/
|
|
84
84
|
invalidates?: Array<keyof IQueryKeys>;
|
|
85
|
-
} & SuccessErrorNotification
|
|
85
|
+
} & SuccessErrorNotification<
|
|
86
|
+
UpdateResponse<TData>,
|
|
87
|
+
TError,
|
|
88
|
+
{ id: BaseKey; values: TVariables }
|
|
89
|
+
>;
|
|
86
90
|
|
|
87
91
|
export type UseUpdateReturnType<
|
|
88
92
|
TData extends BaseRecord = BaseRecord,
|
|
@@ -91,7 +95,7 @@ export type UseUpdateReturnType<
|
|
|
91
95
|
> = UseMutationResult<
|
|
92
96
|
UpdateResponse<TData>,
|
|
93
97
|
TError,
|
|
94
|
-
UpdateParams<TVariables>,
|
|
98
|
+
UpdateParams<TData, TError, TVariables>,
|
|
95
99
|
UpdateContext<TData>
|
|
96
100
|
>;
|
|
97
101
|
|
|
@@ -104,7 +108,7 @@ export type UseUpdateProps<
|
|
|
104
108
|
UseMutationOptions<
|
|
105
109
|
UpdateResponse<TData>,
|
|
106
110
|
TError,
|
|
107
|
-
UpdateParams<TVariables>,
|
|
111
|
+
UpdateParams<TData, TError, TVariables>,
|
|
108
112
|
UpdateContext<TData>
|
|
109
113
|
>,
|
|
110
114
|
"mutationFn" | "onError" | "onSuccess" | "onSettled" | "onMutate"
|
|
@@ -156,7 +160,7 @@ export const useUpdate = <
|
|
|
156
160
|
const mutation = useMutation<
|
|
157
161
|
UpdateResponse<TData>,
|
|
158
162
|
TError,
|
|
159
|
-
UpdateParams<TVariables>,
|
|
163
|
+
UpdateParams<TData, TError, TVariables>,
|
|
160
164
|
UpdateContext<TData>
|
|
161
165
|
>(
|
|
162
166
|
({
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
useActiveAuthProvider,
|
|
41
41
|
} from "@definitions/helpers";
|
|
42
42
|
|
|
43
|
-
type UpdateManyParams<TVariables> = {
|
|
43
|
+
type UpdateManyParams<TData, TError, TVariables> = {
|
|
44
44
|
ids: BaseKey[];
|
|
45
45
|
resource: string;
|
|
46
46
|
mutationMode?: MutationMode;
|
|
@@ -58,7 +58,11 @@ type UpdateManyParams<TVariables> = {
|
|
|
58
58
|
metaData?: MetaQuery;
|
|
59
59
|
dataProviderName?: string;
|
|
60
60
|
invalidates?: Array<keyof IQueryKeys>;
|
|
61
|
-
} & SuccessErrorNotification
|
|
61
|
+
} & SuccessErrorNotification<
|
|
62
|
+
UpdateManyResponse<TData>,
|
|
63
|
+
TError,
|
|
64
|
+
{ ids: BaseKey[]; values: TVariables }
|
|
65
|
+
>;
|
|
62
66
|
|
|
63
67
|
type UseUpdateManyReturnType<
|
|
64
68
|
TData extends BaseRecord = BaseRecord,
|
|
@@ -67,7 +71,7 @@ type UseUpdateManyReturnType<
|
|
|
67
71
|
> = UseMutationResult<
|
|
68
72
|
UpdateManyResponse<TData>,
|
|
69
73
|
TError,
|
|
70
|
-
UpdateManyParams<TVariables>,
|
|
74
|
+
UpdateManyParams<TData, TError, TVariables>,
|
|
71
75
|
UpdateContext<TData>
|
|
72
76
|
>;
|
|
73
77
|
|
|
@@ -80,7 +84,7 @@ export type UseUpdateManyProps<
|
|
|
80
84
|
UseMutationOptions<
|
|
81
85
|
UpdateManyResponse<TData>,
|
|
82
86
|
TError,
|
|
83
|
-
UpdateManyParams<TVariables>,
|
|
87
|
+
UpdateManyParams<TData, TError, TVariables>,
|
|
84
88
|
UpdateContext<TData>
|
|
85
89
|
>,
|
|
86
90
|
"mutationFn" | "onError" | "onSuccess" | "onSettled" | "onMutate"
|
|
@@ -132,7 +136,7 @@ export const useUpdateMany = <
|
|
|
132
136
|
const mutation = useMutation<
|
|
133
137
|
UpdateManyResponse<TData>,
|
|
134
138
|
TError,
|
|
135
|
-
UpdateManyParams<TVariables>,
|
|
139
|
+
UpdateManyParams<TData, TError, TVariables>,
|
|
136
140
|
UpdateContext<TData>
|
|
137
141
|
>(
|
|
138
142
|
({
|
|
@@ -145,7 +149,7 @@ export const useUpdateMany = <
|
|
|
145
149
|
meta,
|
|
146
150
|
metaData,
|
|
147
151
|
dataProviderName,
|
|
148
|
-
}: UpdateManyParams<TVariables>) => {
|
|
152
|
+
}: UpdateManyParams<TData, TError, TVariables>) => {
|
|
149
153
|
const mutationModePropOrContext =
|
|
150
154
|
mutationMode ?? mutationModeContext;
|
|
151
155
|
|
|
@@ -138,7 +138,11 @@ type ActionFormProps<
|
|
|
138
138
|
TError,
|
|
139
139
|
TVariables
|
|
140
140
|
>["mutationOptions"];
|
|
141
|
-
} & SuccessErrorNotification
|
|
141
|
+
} & SuccessErrorNotification<
|
|
142
|
+
UpdateResponse<TData> | CreateResponse<TData>,
|
|
143
|
+
TError,
|
|
144
|
+
{ id: BaseKey; values: TVariables } | TVariables
|
|
145
|
+
> &
|
|
142
146
|
ActionParams &
|
|
143
147
|
LiveModeProps;
|
|
144
148
|
|
|
@@ -442,7 +446,7 @@ export const useForm = <
|
|
|
442
446
|
|
|
443
447
|
if (!resource) return;
|
|
444
448
|
|
|
445
|
-
const variables: UpdateParams<TVariables> = {
|
|
449
|
+
const variables: UpdateParams<TData, TError, TVariables> = {
|
|
446
450
|
id: id ?? "",
|
|
447
451
|
values,
|
|
448
452
|
resource: resource.name,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
BaseKey,
|
|
15
15
|
HttpError,
|
|
16
16
|
IResourceItem,
|
|
17
|
+
Prettify,
|
|
17
18
|
} from "../../interfaces";
|
|
18
19
|
import { useRouterType } from "@contexts/router-picker";
|
|
19
20
|
import { useParsed } from "@hooks/router/use-parsed";
|
|
@@ -44,7 +45,7 @@ export type useShowProps<
|
|
|
44
45
|
/**
|
|
45
46
|
* react-query's [useQuery](https://tanstack.com/query/v4/docs/reference/useQuery) options
|
|
46
47
|
*/
|
|
47
|
-
queryOptions?: UseQueryOptions<GetOneResponse<TData>,
|
|
48
|
+
queryOptions?: UseQueryOptions<GetOneResponse<TData>, TError>;
|
|
48
49
|
/**
|
|
49
50
|
* Additional meta data to pass to the data provider's `getOne`
|
|
50
51
|
*/
|
|
@@ -60,7 +61,11 @@ export type useShowProps<
|
|
|
60
61
|
*/
|
|
61
62
|
dataProviderName?: string;
|
|
62
63
|
} & LiveModeProps &
|
|
63
|
-
SuccessErrorNotification
|
|
64
|
+
SuccessErrorNotification<
|
|
65
|
+
GetOneResponse<TData>,
|
|
66
|
+
TError,
|
|
67
|
+
Prettify<{ id?: BaseKey } & MetaQuery>
|
|
68
|
+
>;
|
|
64
69
|
|
|
65
70
|
/**
|
|
66
71
|
* `useShow` hook allows you to fetch the desired record.
|
|
@@ -165,7 +170,7 @@ export const useShow = <
|
|
|
165
170
|
`See https://refine.dev/docs/api-reference/core/hooks/show/useShow/#resource`,
|
|
166
171
|
);
|
|
167
172
|
|
|
168
|
-
const queryResult = useOne<TData>({
|
|
173
|
+
const queryResult = useOne<TData, TError>({
|
|
169
174
|
resource: resource?.name,
|
|
170
175
|
id: showId ?? "",
|
|
171
176
|
queryOptions: {
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
import { pickNotDeprecated } from "@definitions/helpers";
|
|
24
24
|
import { pickResource } from "@definitions/helpers/pick-resource";
|
|
25
25
|
import { useResource } from "../resource/useResource/index";
|
|
26
|
+
import { BaseListProps } from "../data/useList";
|
|
26
27
|
|
|
27
28
|
export type UseSelectProps<TData, TError> = {
|
|
28
29
|
/**
|
|
@@ -115,7 +116,11 @@ export type UseSelectProps<TData, TError> = {
|
|
|
115
116
|
* @default `undefined`
|
|
116
117
|
*/
|
|
117
118
|
fetchSize?: number;
|
|
118
|
-
} & SuccessErrorNotification
|
|
119
|
+
} & SuccessErrorNotification<
|
|
120
|
+
GetListResponse<TData>,
|
|
121
|
+
TError,
|
|
122
|
+
Prettify<BaseListProps>
|
|
123
|
+
> &
|
|
119
124
|
LiveModeProps;
|
|
120
125
|
|
|
121
126
|
export type UseSelectReturnType<TData extends BaseRecord = BaseRecord> = {
|
|
@@ -3,6 +3,7 @@ import { QueryObserverResult, UseQueryOptions } from "@tanstack/react-query";
|
|
|
3
3
|
import qs from "qs";
|
|
4
4
|
import differenceWith from "lodash/differenceWith";
|
|
5
5
|
import isEqual from "lodash/isEqual";
|
|
6
|
+
import warnOnce from "warn-once";
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
useRouterContext,
|
|
@@ -34,10 +35,10 @@ import {
|
|
|
34
35
|
MetaQuery,
|
|
35
36
|
LiveModeProps,
|
|
36
37
|
Pagination,
|
|
38
|
+
Prettify,
|
|
37
39
|
} from "../../interfaces";
|
|
38
|
-
import { useParse } from "@hooks/router/use-parse";
|
|
39
40
|
import { useGo } from "@hooks/router/use-go";
|
|
40
|
-
import
|
|
41
|
+
import { BaseListProps } from "../data/useList";
|
|
41
42
|
|
|
42
43
|
type SetFilterBehavior = "merge" | "replace";
|
|
43
44
|
|
|
@@ -152,7 +153,11 @@ export type useTableProps<TData, TError> = {
|
|
|
152
153
|
* If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use.
|
|
153
154
|
*/
|
|
154
155
|
dataProviderName?: string;
|
|
155
|
-
} & SuccessErrorNotification
|
|
156
|
+
} & SuccessErrorNotification<
|
|
157
|
+
GetListResponse<TData>,
|
|
158
|
+
TError,
|
|
159
|
+
Prettify<BaseListProps>
|
|
160
|
+
> &
|
|
156
161
|
LiveModeProps;
|
|
157
162
|
|
|
158
163
|
type ReactSetState<T> = React.Dispatch<React.SetStateAction<T>>;
|
|
@@ -31,23 +31,25 @@
|
|
|
31
31
|
* Same goes for `onError` function, it should always resolve.
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
+
import { RefineError } from "../errors";
|
|
35
|
+
|
|
34
36
|
export type CheckResponse = {
|
|
35
37
|
authenticated: boolean;
|
|
36
38
|
redirectTo?: string;
|
|
37
39
|
logout?: boolean;
|
|
38
|
-
error?: Error;
|
|
40
|
+
error?: RefineError | Error;
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export type OnErrorResponse = {
|
|
42
44
|
redirectTo?: string;
|
|
43
45
|
logout?: boolean;
|
|
44
|
-
error?: Error;
|
|
46
|
+
error?: RefineError | Error;
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
export type AuthActionResponse = {
|
|
48
50
|
success: boolean;
|
|
49
51
|
redirectTo?: string;
|
|
50
|
-
error?: Error;
|
|
52
|
+
error?: RefineError | Error;
|
|
51
53
|
[key: string]: unknown;
|
|
52
54
|
};
|
|
53
55
|
|
package/src/interfaces/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpError.d.ts","sourceRoot":"","sources":["../../src/interfaces/HttpError.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAU,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACtB"}
|
|
File without changes
|
|
File without changes
|