@refinedev/core 4.8.3 → 4.9.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/CHANGELOG.md +69 -0
- package/dist/definitions/helpers/router/compose-route.d.ts +2 -2
- package/dist/definitions/helpers/router/compose-route.d.ts.map +1 -1
- package/dist/definitions/helpers/router/prepare-route-params.d.ts +1 -2
- package/dist/definitions/helpers/router/prepare-route-params.d.ts.map +1 -1
- package/dist/esm/index.js +6 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/breadcrumb/index.d.ts.map +1 -1
- package/dist/hooks/data/useCreate.d.ts.map +1 -1
- package/dist/hooks/data/useCreateMany.d.ts.map +1 -1
- package/dist/hooks/data/useCustom.d.ts.map +1 -1
- package/dist/hooks/data/useCustomMutation.d.ts.map +1 -1
- package/dist/hooks/data/useDelete.d.ts.map +1 -1
- package/dist/hooks/data/useDeleteMany.d.ts.map +1 -1
- package/dist/hooks/data/useInfiniteList.d.ts.map +1 -1
- package/dist/hooks/data/useList.d.ts.map +1 -1
- package/dist/hooks/data/useMany.d.ts.map +1 -1
- package/dist/hooks/data/useOne.d.ts.map +1 -1
- package/dist/hooks/data/useUpdate.d.ts.map +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
- package/dist/hooks/form/useForm.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/navigation/index.d.ts.map +1 -1
- package/dist/hooks/router/use-get-to-path/index.d.ts.map +1 -1
- package/dist/hooks/show/useShow.d.ts.map +1 -1
- package/dist/hooks/useMeta/index.d.ts +33 -0
- package/dist/hooks/useMeta/index.d.ts.map +1 -0
- package/dist/hooks/useSelect/index.d.ts.map +1 -1
- package/dist/hooks/useTable/index.d.ts.map +1 -1
- package/dist/iife/index.js +6 -6
- package/dist/iife/index.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/definitions/helpers/router/__tests__/compose-route.ts +9 -5
- package/src/definitions/helpers/router/__tests__/prepare-route-params.ts +5 -2
- package/src/definitions/helpers/router/compose-route.ts +16 -5
- package/src/definitions/helpers/router/prepare-route-params.ts +4 -16
- package/src/hooks/breadcrumb/index.ts +6 -1
- package/src/hooks/data/useCreate.ts +8 -4
- package/src/hooks/data/useCreateMany.ts +10 -5
- package/src/hooks/data/useCustom.ts +20 -6
- package/src/hooks/data/useCustomMutation.ts +8 -2
- package/src/hooks/data/useDelete.ts +10 -3
- package/src/hooks/data/useDeleteMany.ts +10 -6
- package/src/hooks/data/useInfiniteList.ts +8 -4
- package/src/hooks/data/useList.ts +11 -6
- package/src/hooks/data/useMany.ts +23 -17
- package/src/hooks/data/useOne.ts +21 -14
- package/src/hooks/data/useUpdate.ts +10 -4
- package/src/hooks/data/useUpdateMany.ts +10 -5
- package/src/hooks/form/useForm.ts +13 -6
- package/src/hooks/index.ts +1 -0
- package/src/hooks/navigation/index.ts +54 -19
- package/src/hooks/router/use-get-to-path/index.ts +6 -1
- package/src/hooks/show/useShow.ts +14 -3
- package/src/hooks/useMeta/index.ts +26 -0
- package/src/hooks/useSelect/index.ts +11 -5
- package/src/hooks/useTable/index.ts +9 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refinedev/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0",
|
|
4
4
|
"description": "refine is a React-based framework for building internal tools, rapidly. It ships with Ant Design System, an enterprise-level UI toolkit.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,12 +20,15 @@ describe("composeRoute", () => {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it("should return the route with multiple params replaced", () => {
|
|
23
|
-
const result = composeRoute(
|
|
24
|
-
id
|
|
25
|
-
|
|
23
|
+
const result = composeRoute(
|
|
24
|
+
"/users/:id/:name",
|
|
25
|
+
{ name: "Jane" },
|
|
26
|
+
{ id: 5 },
|
|
27
|
+
{
|
|
28
|
+
id: 1,
|
|
26
29
|
name: "John",
|
|
27
30
|
},
|
|
28
|
-
|
|
31
|
+
);
|
|
29
32
|
|
|
30
33
|
expect(result).toEqual("/users/1/John");
|
|
31
34
|
});
|
|
@@ -33,7 +36,8 @@ describe("composeRoute", () => {
|
|
|
33
36
|
it("should return the route with multiple params by prioritizing meta params", () => {
|
|
34
37
|
const result = composeRoute(
|
|
35
38
|
"/users/:id/:name",
|
|
36
|
-
{
|
|
39
|
+
{},
|
|
40
|
+
{ id: 1 },
|
|
37
41
|
{ name: "Doe" },
|
|
38
42
|
);
|
|
39
43
|
|
|
@@ -10,14 +10,17 @@ describe("prepareRouteParams", () => {
|
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
it("should prioritize meta over params", () => {
|
|
13
|
-
expect(prepareRouteParams(["id"], { id: "
|
|
13
|
+
expect(prepareRouteParams(["id"], { id: "2" })).toEqual({
|
|
14
14
|
id: "2",
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
it("should combine params and meta", () => {
|
|
19
19
|
expect(
|
|
20
|
-
prepareRouteParams(["id", "action"], {
|
|
20
|
+
prepareRouteParams(["id", "action"], {
|
|
21
|
+
...{ id: "1" },
|
|
22
|
+
...{ action: "2" },
|
|
23
|
+
}),
|
|
21
24
|
).toEqual({ id: "1", action: "2" });
|
|
22
25
|
});
|
|
23
26
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { MetaQuery, ParseResponse } from "src/interfaces";
|
|
3
2
|
import { pickRouteParams } from "./pick-route-params";
|
|
4
3
|
import { prepareRouteParams } from "./prepare-route-params";
|
|
5
4
|
|
|
@@ -12,13 +11,25 @@ import { prepareRouteParams } from "./prepare-route-params";
|
|
|
12
11
|
*/
|
|
13
12
|
export const composeRoute = (
|
|
14
13
|
designatedRoute: string,
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
resourceMeta: MetaQuery = {},
|
|
15
|
+
parsed: ParseResponse = {},
|
|
16
|
+
meta: Record<string, unknown> = {},
|
|
17
17
|
): string => {
|
|
18
18
|
// pickRouteParams (from the route)
|
|
19
19
|
const routeParams = pickRouteParams(designatedRoute);
|
|
20
20
|
// prepareRouteParams (from route params, params and meta)
|
|
21
|
-
const preparedRouteParams = prepareRouteParams(routeParams,
|
|
21
|
+
const preparedRouteParams = prepareRouteParams(routeParams, {
|
|
22
|
+
...resourceMeta,
|
|
23
|
+
...(typeof parsed?.id !== "undefined" ? { id: parsed.id } : {}),
|
|
24
|
+
...(typeof parsed?.action !== "undefined"
|
|
25
|
+
? { action: parsed.action }
|
|
26
|
+
: {}),
|
|
27
|
+
...(typeof parsed?.resource !== "undefined"
|
|
28
|
+
? { resource: parsed.resource }
|
|
29
|
+
: {}),
|
|
30
|
+
...parsed?.params,
|
|
31
|
+
...meta,
|
|
32
|
+
});
|
|
22
33
|
// replace route params with prepared route params
|
|
23
34
|
return designatedRoute.replace(/:([^\/]+)/g, (match, key) => {
|
|
24
35
|
const fromParams = preparedRouteParams[key];
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { MetaDataQuery, ParseResponse } from "../../../interfaces";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Prepares the route params by checking the existing params and meta data.
|
|
5
3
|
* Meta data is prioritized over params.
|
|
@@ -7,25 +5,15 @@ import { MetaDataQuery, ParseResponse } from "../../../interfaces";
|
|
|
7
5
|
* This means, we can use `meta` for user supplied params (both manually or from the query string)
|
|
8
6
|
*/
|
|
9
7
|
export const prepareRouteParams = <
|
|
10
|
-
TRouteParams extends Record<
|
|
11
|
-
string,
|
|
12
|
-
string | number | undefined | Symbol
|
|
13
|
-
> = Record<string, string | number | undefined | Symbol>,
|
|
8
|
+
TRouteParams extends Record<string, unknown> = Record<string, unknown>,
|
|
14
9
|
>(
|
|
15
10
|
routeParams: (keyof TRouteParams)[],
|
|
16
|
-
|
|
17
|
-
meta: MetaDataQuery = {},
|
|
11
|
+
meta: Record<string, unknown> = {},
|
|
18
12
|
): Partial<TRouteParams> => {
|
|
19
|
-
// meta is prioritized over params
|
|
20
13
|
return routeParams.reduce((acc, key) => {
|
|
21
|
-
const value =
|
|
22
|
-
meta[key as string] ||
|
|
23
|
-
params.params?.[key as string] ||
|
|
24
|
-
(key === "id" ? params.id : undefined) ||
|
|
25
|
-
(key === "action" ? params.action : undefined) ||
|
|
26
|
-
(key === "resource" ? params.resource : undefined);
|
|
14
|
+
const value = meta[key as string];
|
|
27
15
|
if (typeof value !== "undefined") {
|
|
28
|
-
acc[key] = value;
|
|
16
|
+
acc[key] = value as TRouteParams[keyof TRouteParams];
|
|
29
17
|
}
|
|
30
18
|
return acc;
|
|
31
19
|
}, {} as Partial<TRouteParams>);
|
|
@@ -77,7 +77,12 @@ export const useBreadcrumb = ({
|
|
|
77
77
|
const href = hrefRaw
|
|
78
78
|
? routerType === "legacy"
|
|
79
79
|
? hrefRaw
|
|
80
|
-
: composeRoute(
|
|
80
|
+
: composeRoute(
|
|
81
|
+
hrefRaw,
|
|
82
|
+
parentResource?.meta,
|
|
83
|
+
parsed,
|
|
84
|
+
metaFromProps,
|
|
85
|
+
)
|
|
81
86
|
: undefined;
|
|
82
87
|
|
|
83
88
|
breadcrumbs.push({
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
useLog,
|
|
28
28
|
useInvalidate,
|
|
29
29
|
useOnError,
|
|
30
|
+
useMeta,
|
|
30
31
|
} from "@hooks";
|
|
31
32
|
|
|
32
33
|
type useCreateParams<TData, TError, TVariables> = {
|
|
@@ -114,13 +115,12 @@ export const useCreate = <
|
|
|
114
115
|
});
|
|
115
116
|
const dataProvider = useDataProvider();
|
|
116
117
|
const invalidateStore = useInvalidate();
|
|
117
|
-
|
|
118
118
|
const { resources } = useResource();
|
|
119
|
-
|
|
120
119
|
const translate = useTranslate();
|
|
121
120
|
const publish = usePublish();
|
|
122
121
|
const { log } = useLog();
|
|
123
122
|
const handleNotification = useHandleNotification();
|
|
123
|
+
const getMeta = useMeta();
|
|
124
124
|
|
|
125
125
|
const mutation = useMutation<
|
|
126
126
|
CreateResponse<TData>,
|
|
@@ -135,13 +135,17 @@ export const useCreate = <
|
|
|
135
135
|
metaData,
|
|
136
136
|
dataProviderName,
|
|
137
137
|
}: useCreateParams<TData, TError, TVariables>) => {
|
|
138
|
+
const combinedMeta = getMeta({
|
|
139
|
+
meta: pickNotDeprecated(meta, metaData),
|
|
140
|
+
});
|
|
141
|
+
|
|
138
142
|
return dataProvider(
|
|
139
143
|
pickDataProvider(resource, dataProviderName, resources),
|
|
140
144
|
).create<TData, TVariables>({
|
|
141
145
|
resource,
|
|
142
146
|
variables: values,
|
|
143
|
-
meta:
|
|
144
|
-
metaData:
|
|
147
|
+
meta: combinedMeta,
|
|
148
|
+
metaData: combinedMeta,
|
|
145
149
|
});
|
|
146
150
|
},
|
|
147
151
|
{
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
useDataProvider,
|
|
22
22
|
useInvalidate,
|
|
23
23
|
useLog,
|
|
24
|
+
useMeta,
|
|
24
25
|
} from "@hooks";
|
|
25
26
|
import {
|
|
26
27
|
handleMultiple,
|
|
@@ -87,13 +88,13 @@ export const useCreateMany = <
|
|
|
87
88
|
TVariables
|
|
88
89
|
> => {
|
|
89
90
|
const dataProvider = useDataProvider();
|
|
90
|
-
|
|
91
91
|
const { resources } = useResource();
|
|
92
92
|
const translate = useTranslate();
|
|
93
93
|
const publish = usePublish();
|
|
94
94
|
const handleNotification = useHandleNotification();
|
|
95
95
|
const invalidateStore = useInvalidate();
|
|
96
96
|
const { log } = useLog();
|
|
97
|
+
const getMeta = useMeta();
|
|
97
98
|
|
|
98
99
|
const mutation = useMutation<
|
|
99
100
|
CreateManyResponse<TData>,
|
|
@@ -107,6 +108,10 @@ export const useCreateMany = <
|
|
|
107
108
|
metaData,
|
|
108
109
|
dataProviderName,
|
|
109
110
|
}: useCreateManyParams<TData, TError, TVariables>) => {
|
|
111
|
+
const combinedMeta = getMeta({
|
|
112
|
+
meta: pickNotDeprecated(meta, metaData),
|
|
113
|
+
});
|
|
114
|
+
|
|
110
115
|
const selectedDataProvider = dataProvider(
|
|
111
116
|
pickDataProvider(resource, dataProviderName, resources),
|
|
112
117
|
);
|
|
@@ -115,8 +120,8 @@ export const useCreateMany = <
|
|
|
115
120
|
return selectedDataProvider.createMany<TData, TVariables>({
|
|
116
121
|
resource,
|
|
117
122
|
variables: values,
|
|
118
|
-
meta:
|
|
119
|
-
metaData:
|
|
123
|
+
meta: combinedMeta,
|
|
124
|
+
metaData: combinedMeta,
|
|
120
125
|
});
|
|
121
126
|
} else {
|
|
122
127
|
return handleMultiple(
|
|
@@ -124,8 +129,8 @@ export const useCreateMany = <
|
|
|
124
129
|
selectedDataProvider.create<TData, TVariables>({
|
|
125
130
|
resource,
|
|
126
131
|
variables: val,
|
|
127
|
-
meta:
|
|
128
|
-
metaData:
|
|
132
|
+
meta: combinedMeta,
|
|
133
|
+
metaData: combinedMeta,
|
|
129
134
|
}),
|
|
130
135
|
),
|
|
131
136
|
);
|
|
@@ -8,6 +8,7 @@ import { pickNotDeprecated, useActiveAuthProvider } from "@definitions/helpers";
|
|
|
8
8
|
import {
|
|
9
9
|
useDataProvider,
|
|
10
10
|
useHandleNotification,
|
|
11
|
+
useMeta,
|
|
11
12
|
useOnError,
|
|
12
13
|
useTranslate,
|
|
13
14
|
} from "@hooks";
|
|
@@ -113,14 +114,19 @@ export const useCustom = <
|
|
|
113
114
|
TData
|
|
114
115
|
>): QueryObserverResult<CustomResponse<TData>, TError> => {
|
|
115
116
|
const dataProvider = useDataProvider();
|
|
116
|
-
|
|
117
|
-
const { custom } = dataProvider(dataProviderName);
|
|
118
117
|
const authProvider = useActiveAuthProvider();
|
|
119
118
|
const { mutate: checkError } = useOnError({
|
|
120
119
|
v3LegacyAuthProviderCompatible: Boolean(authProvider?.isLegacy),
|
|
121
120
|
});
|
|
122
121
|
const translate = useTranslate();
|
|
123
122
|
const handleNotification = useHandleNotification();
|
|
123
|
+
const getMeta = useMeta();
|
|
124
|
+
|
|
125
|
+
const preferredMeta = pickNotDeprecated(meta, metaData);
|
|
126
|
+
|
|
127
|
+
const { custom } = dataProvider(dataProviderName);
|
|
128
|
+
|
|
129
|
+
const combinedMeta = getMeta({ meta: preferredMeta });
|
|
124
130
|
|
|
125
131
|
if (custom) {
|
|
126
132
|
const queryResponse = useQuery<
|
|
@@ -133,15 +139,23 @@ export const useCustom = <
|
|
|
133
139
|
"custom",
|
|
134
140
|
method,
|
|
135
141
|
url,
|
|
136
|
-
{ ...config, ...(
|
|
142
|
+
{ ...config, ...(preferredMeta || {}) },
|
|
137
143
|
],
|
|
138
144
|
queryFn: ({ queryKey, pageParam, signal }) =>
|
|
139
145
|
custom<TQueryFnData>({
|
|
140
146
|
url,
|
|
141
147
|
method,
|
|
142
148
|
...config,
|
|
149
|
+
meta: {
|
|
150
|
+
...(combinedMeta || {}),
|
|
151
|
+
queryContext: {
|
|
152
|
+
queryKey,
|
|
153
|
+
pageParam,
|
|
154
|
+
signal,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
143
157
|
metaData: {
|
|
144
|
-
...(
|
|
158
|
+
...(combinedMeta || {}),
|
|
145
159
|
queryContext: {
|
|
146
160
|
queryKey,
|
|
147
161
|
pageParam,
|
|
@@ -157,7 +171,7 @@ export const useCustom = <
|
|
|
157
171
|
typeof successNotification === "function"
|
|
158
172
|
? successNotification(data, {
|
|
159
173
|
...config,
|
|
160
|
-
...(
|
|
174
|
+
...(combinedMeta || {}),
|
|
161
175
|
})
|
|
162
176
|
: successNotification;
|
|
163
177
|
|
|
@@ -171,7 +185,7 @@ export const useCustom = <
|
|
|
171
185
|
typeof errorNotification === "function"
|
|
172
186
|
? errorNotification(err, {
|
|
173
187
|
...config,
|
|
174
|
-
...(
|
|
188
|
+
...(combinedMeta || {}),
|
|
175
189
|
})
|
|
176
190
|
: errorNotification;
|
|
177
191
|
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
useHandleNotification,
|
|
10
10
|
useTranslate,
|
|
11
11
|
useOnError,
|
|
12
|
+
useMeta,
|
|
12
13
|
} from "@hooks";
|
|
13
14
|
import {
|
|
14
15
|
CreateResponse,
|
|
@@ -103,6 +104,7 @@ export const useCustomMutation = <
|
|
|
103
104
|
const handleNotification = useHandleNotification();
|
|
104
105
|
const dataProvider = useDataProvider();
|
|
105
106
|
const translate = useTranslate();
|
|
107
|
+
const getMeta = useMeta();
|
|
106
108
|
|
|
107
109
|
const mutation = useMutation<
|
|
108
110
|
CreateResponse<TData>,
|
|
@@ -119,6 +121,10 @@ export const useCustomMutation = <
|
|
|
119
121
|
dataProviderName,
|
|
120
122
|
config,
|
|
121
123
|
}: useCustomMutationParams<TData, TError, TVariables>) => {
|
|
124
|
+
const combinedMeta = getMeta({
|
|
125
|
+
meta: pickNotDeprecated(meta, metaData),
|
|
126
|
+
});
|
|
127
|
+
|
|
122
128
|
const { custom } = dataProvider(dataProviderName);
|
|
123
129
|
|
|
124
130
|
if (custom) {
|
|
@@ -126,8 +132,8 @@ export const useCustomMutation = <
|
|
|
126
132
|
url,
|
|
127
133
|
method,
|
|
128
134
|
payload: values,
|
|
129
|
-
meta:
|
|
130
|
-
metaData:
|
|
135
|
+
meta: combinedMeta,
|
|
136
|
+
metaData: combinedMeta,
|
|
131
137
|
headers: { ...config?.headers },
|
|
132
138
|
});
|
|
133
139
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
useLog,
|
|
18
18
|
useInvalidate,
|
|
19
19
|
useOnError,
|
|
20
|
+
useMeta,
|
|
20
21
|
} from "@hooks";
|
|
21
22
|
import { ActionTypes } from "@contexts/undoableQueue";
|
|
22
23
|
import {
|
|
@@ -125,6 +126,7 @@ export const useDelete = <
|
|
|
125
126
|
const { log } = useLog();
|
|
126
127
|
const handleNotification = useHandleNotification();
|
|
127
128
|
const invalidateStore = useInvalidate();
|
|
129
|
+
const getMeta = useMeta();
|
|
128
130
|
|
|
129
131
|
const mutation = useMutation<
|
|
130
132
|
DeleteOneResponse<TData>,
|
|
@@ -143,6 +145,10 @@ export const useDelete = <
|
|
|
143
145
|
dataProviderName,
|
|
144
146
|
values,
|
|
145
147
|
}) => {
|
|
148
|
+
const combinedMeta = getMeta({
|
|
149
|
+
meta: pickNotDeprecated(meta, metaData),
|
|
150
|
+
});
|
|
151
|
+
|
|
146
152
|
const mutationModePropOrContext =
|
|
147
153
|
mutationMode ?? mutationModeContext;
|
|
148
154
|
|
|
@@ -155,8 +161,8 @@ export const useDelete = <
|
|
|
155
161
|
).deleteOne<TData, TVariables>({
|
|
156
162
|
resource,
|
|
157
163
|
id,
|
|
158
|
-
meta:
|
|
159
|
-
metaData:
|
|
164
|
+
meta: combinedMeta,
|
|
165
|
+
metaData: combinedMeta,
|
|
160
166
|
variables: values,
|
|
161
167
|
});
|
|
162
168
|
}
|
|
@@ -174,7 +180,8 @@ export const useDelete = <
|
|
|
174
180
|
.deleteOne<TData, TVariables>({
|
|
175
181
|
resource,
|
|
176
182
|
id,
|
|
177
|
-
meta:
|
|
183
|
+
meta: combinedMeta,
|
|
184
|
+
metaData: combinedMeta,
|
|
178
185
|
variables: values,
|
|
179
186
|
})
|
|
180
187
|
.then((result) => resolve(result))
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
useInvalidate,
|
|
31
31
|
useLog,
|
|
32
32
|
useOnError,
|
|
33
|
+
useMeta,
|
|
33
34
|
} from "@hooks";
|
|
34
35
|
import { ActionTypes } from "@contexts/undoableQueue";
|
|
35
36
|
import {
|
|
@@ -116,16 +117,15 @@ export const useDeleteMany = <
|
|
|
116
117
|
undoableTimeout: undoableTimeoutContext,
|
|
117
118
|
} = useMutationMode();
|
|
118
119
|
const dataProvider = useDataProvider();
|
|
119
|
-
|
|
120
120
|
const { notificationDispatch } = useCancelNotification();
|
|
121
121
|
const translate = useTranslate();
|
|
122
122
|
const publish = usePublish();
|
|
123
123
|
const handleNotification = useHandleNotification();
|
|
124
124
|
const invalidateStore = useInvalidate();
|
|
125
125
|
const { log } = useLog();
|
|
126
|
-
|
|
127
126
|
const { resources } = useResource();
|
|
128
127
|
const queryClient = useQueryClient();
|
|
128
|
+
const getMeta = useMeta();
|
|
129
129
|
|
|
130
130
|
const mutation = useMutation<
|
|
131
131
|
DeleteManyResponse<TData>,
|
|
@@ -144,6 +144,10 @@ export const useDeleteMany = <
|
|
|
144
144
|
dataProviderName,
|
|
145
145
|
values,
|
|
146
146
|
}: DeleteManyParams<TData, TError, TVariables>) => {
|
|
147
|
+
const combinedMeta = getMeta({
|
|
148
|
+
meta: pickNotDeprecated(meta, metaData),
|
|
149
|
+
});
|
|
150
|
+
|
|
147
151
|
const mutationModePropOrContext =
|
|
148
152
|
mutationMode ?? mutationModeContext;
|
|
149
153
|
|
|
@@ -159,8 +163,8 @@ export const useDeleteMany = <
|
|
|
159
163
|
return selectedDataProvider.deleteMany<TData, TVariables>({
|
|
160
164
|
resource,
|
|
161
165
|
ids,
|
|
162
|
-
meta:
|
|
163
|
-
metaData:
|
|
166
|
+
meta: combinedMeta,
|
|
167
|
+
metaData: combinedMeta,
|
|
164
168
|
variables: values,
|
|
165
169
|
});
|
|
166
170
|
} else {
|
|
@@ -169,8 +173,8 @@ export const useDeleteMany = <
|
|
|
169
173
|
selectedDataProvider.deleteOne<TData, TVariables>({
|
|
170
174
|
resource,
|
|
171
175
|
id,
|
|
172
|
-
meta:
|
|
173
|
-
metaData:
|
|
176
|
+
meta: combinedMeta,
|
|
177
|
+
metaData: combinedMeta,
|
|
174
178
|
variables: values,
|
|
175
179
|
}),
|
|
176
180
|
),
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
useTranslate,
|
|
24
24
|
useDataProvider,
|
|
25
25
|
useOnError,
|
|
26
|
+
useMeta,
|
|
26
27
|
} from "@hooks";
|
|
27
28
|
import {
|
|
28
29
|
queryKeys,
|
|
@@ -147,6 +148,7 @@ export const useInfiniteList = <
|
|
|
147
148
|
v3LegacyAuthProviderCompatible: Boolean(authProvider?.isLegacy),
|
|
148
149
|
});
|
|
149
150
|
const handleNotification = useHandleNotification();
|
|
151
|
+
const getMeta = useMeta();
|
|
150
152
|
|
|
151
153
|
const pickedDataProvider = pickDataProvider(
|
|
152
154
|
resource,
|
|
@@ -189,14 +191,16 @@ export const useInfiniteList = <
|
|
|
189
191
|
preferredMeta,
|
|
190
192
|
);
|
|
191
193
|
|
|
194
|
+
const combinedMeta = getMeta({ meta: preferredMeta });
|
|
195
|
+
|
|
192
196
|
const { getList } = dataProvider(pickedDataProvider);
|
|
193
197
|
|
|
194
198
|
useResourceSubscription({
|
|
195
199
|
resource,
|
|
196
200
|
types: ["*"],
|
|
197
201
|
params: {
|
|
198
|
-
meta:
|
|
199
|
-
metaData:
|
|
202
|
+
meta: combinedMeta,
|
|
203
|
+
metaData: combinedMeta,
|
|
200
204
|
pagination: prefferedPagination,
|
|
201
205
|
hasPagination: isServerPagination,
|
|
202
206
|
sort: prefferedSorters,
|
|
@@ -243,7 +247,7 @@ export const useInfiniteList = <
|
|
|
243
247
|
sort: prefferedSorters,
|
|
244
248
|
sorters: prefferedSorters,
|
|
245
249
|
meta: {
|
|
246
|
-
...(
|
|
250
|
+
...(combinedMeta || {}),
|
|
247
251
|
queryContext: {
|
|
248
252
|
queryKey,
|
|
249
253
|
pageParam,
|
|
@@ -251,7 +255,7 @@ export const useInfiniteList = <
|
|
|
251
255
|
},
|
|
252
256
|
},
|
|
253
257
|
metaData: {
|
|
254
|
-
...(
|
|
258
|
+
...(combinedMeta || {}),
|
|
255
259
|
queryContext: {
|
|
256
260
|
queryKey,
|
|
257
261
|
pageParam,
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
useTranslate,
|
|
23
23
|
useDataProvider,
|
|
24
24
|
useOnError,
|
|
25
|
+
useMeta,
|
|
25
26
|
} from "@hooks";
|
|
26
27
|
import {
|
|
27
28
|
queryKeys,
|
|
@@ -144,6 +145,7 @@ export const useList = <
|
|
|
144
145
|
v3LegacyAuthProviderCompatible: Boolean(authProvider?.isLegacy),
|
|
145
146
|
});
|
|
146
147
|
const handleNotification = useHandleNotification();
|
|
148
|
+
const getMeta = useMeta();
|
|
147
149
|
|
|
148
150
|
const pickedDataProvider = pickDataProvider(
|
|
149
151
|
resource,
|
|
@@ -163,9 +165,12 @@ export const useList = <
|
|
|
163
165
|
hasPagination: prefferedHasPagination,
|
|
164
166
|
});
|
|
165
167
|
const isServerPagination = prefferedPagination.mode === "server";
|
|
168
|
+
|
|
169
|
+
const combinedMeta = getMeta({ meta: preferredMeta });
|
|
170
|
+
|
|
166
171
|
const notificationValues = {
|
|
167
|
-
meta:
|
|
168
|
-
metaData:
|
|
172
|
+
meta: combinedMeta,
|
|
173
|
+
metaData: combinedMeta,
|
|
169
174
|
filters: prefferedFilters,
|
|
170
175
|
hasPagination: isServerPagination,
|
|
171
176
|
pagination: prefferedPagination,
|
|
@@ -192,8 +197,8 @@ export const useList = <
|
|
|
192
197
|
resource,
|
|
193
198
|
types: ["*"],
|
|
194
199
|
params: {
|
|
195
|
-
meta:
|
|
196
|
-
metaData:
|
|
200
|
+
meta: combinedMeta,
|
|
201
|
+
metaData: combinedMeta,
|
|
197
202
|
pagination: prefferedPagination,
|
|
198
203
|
hasPagination: isServerPagination,
|
|
199
204
|
sort: prefferedSorters,
|
|
@@ -235,7 +240,7 @@ export const useList = <
|
|
|
235
240
|
sort: prefferedSorters,
|
|
236
241
|
sorters: prefferedSorters,
|
|
237
242
|
meta: {
|
|
238
|
-
...(
|
|
243
|
+
...(combinedMeta || {}),
|
|
239
244
|
queryContext: {
|
|
240
245
|
queryKey,
|
|
241
246
|
pageParam,
|
|
@@ -243,7 +248,7 @@ export const useList = <
|
|
|
243
248
|
},
|
|
244
249
|
},
|
|
245
250
|
metaData: {
|
|
246
|
-
...(
|
|
251
|
+
...(combinedMeta || {}),
|
|
247
252
|
queryContext: {
|
|
248
253
|
queryKey,
|
|
249
254
|
pageParam,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
useHandleNotification,
|
|
21
21
|
useDataProvider,
|
|
22
22
|
useOnError,
|
|
23
|
+
useMeta,
|
|
23
24
|
} from "@hooks";
|
|
24
25
|
import {
|
|
25
26
|
queryKeys,
|
|
@@ -98,34 +99,39 @@ export const useMany = <
|
|
|
98
99
|
> => {
|
|
99
100
|
const { resources } = useResource();
|
|
100
101
|
const dataProvider = useDataProvider();
|
|
101
|
-
const queryKey = queryKeys(
|
|
102
|
-
resource,
|
|
103
|
-
pickDataProvider(resource, dataProviderName, resources),
|
|
104
|
-
pickNotDeprecated(meta, metaData),
|
|
105
|
-
pickNotDeprecated(meta, metaData),
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const { getMany, getOne } = dataProvider(
|
|
109
|
-
pickDataProvider(resource, dataProviderName, resources),
|
|
110
|
-
);
|
|
111
|
-
|
|
112
102
|
const translate = useTranslate();
|
|
113
103
|
const authProvider = useActiveAuthProvider();
|
|
114
104
|
const { mutate: checkError } = useOnError({
|
|
115
105
|
v3LegacyAuthProviderCompatible: Boolean(authProvider?.isLegacy),
|
|
116
106
|
});
|
|
117
107
|
const handleNotification = useHandleNotification();
|
|
108
|
+
const getMeta = useMeta();
|
|
109
|
+
|
|
110
|
+
const preferredMeta = pickNotDeprecated(meta, metaData);
|
|
118
111
|
|
|
119
112
|
const isEnabled =
|
|
120
113
|
queryOptions?.enabled === undefined || queryOptions?.enabled === true;
|
|
121
114
|
|
|
115
|
+
const queryKey = queryKeys(
|
|
116
|
+
resource,
|
|
117
|
+
pickDataProvider(resource, dataProviderName, resources),
|
|
118
|
+
preferredMeta,
|
|
119
|
+
preferredMeta,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const { getMany, getOne } = dataProvider(
|
|
123
|
+
pickDataProvider(resource, dataProviderName, resources),
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const combinedMeta = getMeta({ meta: preferredMeta });
|
|
127
|
+
|
|
122
128
|
useResourceSubscription({
|
|
123
129
|
resource,
|
|
124
130
|
types: ["*"],
|
|
125
131
|
params: {
|
|
126
132
|
ids: ids ?? [],
|
|
127
|
-
meta:
|
|
128
|
-
metaData:
|
|
133
|
+
meta: combinedMeta,
|
|
134
|
+
metaData: combinedMeta,
|
|
129
135
|
subscriptionType: "useMany",
|
|
130
136
|
...liveParams,
|
|
131
137
|
},
|
|
@@ -147,7 +153,7 @@ export const useMany = <
|
|
|
147
153
|
resource,
|
|
148
154
|
ids,
|
|
149
155
|
meta: {
|
|
150
|
-
...(
|
|
156
|
+
...(combinedMeta || {}),
|
|
151
157
|
queryContext: {
|
|
152
158
|
queryKey,
|
|
153
159
|
pageParam,
|
|
@@ -155,7 +161,7 @@ export const useMany = <
|
|
|
155
161
|
},
|
|
156
162
|
},
|
|
157
163
|
metaData: {
|
|
158
|
-
...(
|
|
164
|
+
...(combinedMeta || {}),
|
|
159
165
|
queryContext: {
|
|
160
166
|
queryKey,
|
|
161
167
|
pageParam,
|
|
@@ -170,7 +176,7 @@ export const useMany = <
|
|
|
170
176
|
resource,
|
|
171
177
|
id,
|
|
172
178
|
meta: {
|
|
173
|
-
...(
|
|
179
|
+
...(combinedMeta || {}),
|
|
174
180
|
queryContext: {
|
|
175
181
|
queryKey,
|
|
176
182
|
pageParam,
|
|
@@ -178,7 +184,7 @@ export const useMany = <
|
|
|
178
184
|
},
|
|
179
185
|
},
|
|
180
186
|
metaData: {
|
|
181
|
-
...(
|
|
187
|
+
...(combinedMeta || {}),
|
|
182
188
|
queryContext: {
|
|
183
189
|
queryKey,
|
|
184
190
|
pageParam,
|