@refinedev/core 4.44.3 → 4.44.5
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 +104 -0
- package/dist/contexts/live/ILiveContext.d.ts +9 -0
- package/dist/contexts/live/ILiveContext.d.ts.map +1 -1
- package/dist/esm/index.js +6 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/data/useCreate.d.ts +1 -1
- package/dist/hooks/data/useCreate.d.ts.map +1 -1
- package/dist/hooks/data/useCreateMany.d.ts +1 -1
- package/dist/hooks/data/useCreateMany.d.ts.map +1 -1
- package/dist/hooks/data/useDelete.d.ts +2 -2
- package/dist/hooks/data/useDelete.d.ts.map +1 -1
- package/dist/hooks/data/useDeleteMany.d.ts +2 -2
- package/dist/hooks/data/useDeleteMany.d.ts.map +1 -1
- package/dist/hooks/data/useInfiniteList.d.ts +2 -2
- package/dist/hooks/data/useInfiniteList.d.ts.map +1 -1
- package/dist/hooks/data/useList.d.ts +1 -1
- 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 +1 -1
- package/dist/hooks/data/useOne.d.ts.map +1 -1
- package/dist/hooks/data/useUpdate.d.ts +1 -1
- package/dist/hooks/data/useUpdate.d.ts.map +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
- package/dist/hooks/live/useResourceSubscription/index.d.ts +10 -1
- package/dist/hooks/live/useResourceSubscription/index.d.ts.map +1 -1
- package/dist/hooks/live/useSubscription/index.d.ts +8 -3
- package/dist/hooks/live/useSubscription/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 +5 -5
- package/dist/index.js.map +1 -1
- package/dist/interfaces/live/LiveEvent.d.ts +4 -1
- package/dist/interfaces/live/LiveEvent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/contexts/live/ILiveContext.ts +7 -0
- package/src/hooks/data/useCreate.ts +45 -41
- package/src/hooks/data/useCreateMany.ts +41 -38
- package/src/hooks/data/useDelete.ts +48 -40
- package/src/hooks/data/useDeleteMany.ts +52 -43
- package/src/hooks/data/useInfiniteList.ts +30 -27
- package/src/hooks/data/useList.ts +26 -23
- package/src/hooks/data/useMany.ts +23 -20
- package/src/hooks/data/useOne.ts +23 -20
- package/src/hooks/data/useUpdate.ts +52 -39
- package/src/hooks/data/useUpdateMany.ts +48 -40
- package/src/hooks/live/useResourceSubscription/index.ts +23 -6
- package/src/hooks/live/useSubscription/index.ts +10 -2
- package/src/interfaces/live/LiveEvent.ts +4 -1
|
@@ -1,48 +1,47 @@
|
|
|
1
|
+
import { getXRay } from "@refinedev/devtools-internal";
|
|
1
2
|
import {
|
|
3
|
+
InfiniteData,
|
|
4
|
+
InfiniteQueryObserverResult,
|
|
2
5
|
useInfiniteQuery,
|
|
3
6
|
UseInfiniteQueryOptions,
|
|
4
|
-
InfiniteQueryObserverResult,
|
|
5
|
-
InfiniteData,
|
|
6
7
|
} from "@tanstack/react-query";
|
|
7
|
-
import { getXRay } from "@refinedev/devtools-internal";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
LiveModeProps,
|
|
18
|
-
GetListResponse,
|
|
19
|
-
Prettify,
|
|
20
|
-
} from "../../interfaces";
|
|
10
|
+
getNextPageParam,
|
|
11
|
+
getPreviousPageParam,
|
|
12
|
+
handlePaginationParams,
|
|
13
|
+
pickDataProvider,
|
|
14
|
+
pickNotDeprecated,
|
|
15
|
+
useActiveAuthProvider,
|
|
16
|
+
} from "@definitions/helpers";
|
|
21
17
|
import {
|
|
22
|
-
|
|
18
|
+
useDataProvider,
|
|
23
19
|
useHandleNotification,
|
|
20
|
+
useMeta,
|
|
21
|
+
useOnError,
|
|
22
|
+
useResource,
|
|
24
23
|
useResourceSubscription,
|
|
25
24
|
useTranslate,
|
|
26
|
-
useDataProvider,
|
|
27
|
-
useOnError,
|
|
28
|
-
useMeta,
|
|
29
25
|
} from "@hooks";
|
|
30
26
|
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
BaseRecord,
|
|
28
|
+
CrudFilters,
|
|
29
|
+
CrudSorting,
|
|
30
|
+
GetListResponse,
|
|
31
|
+
HttpError,
|
|
32
|
+
LiveModeProps,
|
|
33
|
+
MetaQuery,
|
|
34
|
+
Pagination,
|
|
35
|
+
Prettify,
|
|
36
|
+
SuccessErrorNotification,
|
|
37
|
+
} from "../../interfaces";
|
|
39
38
|
|
|
39
|
+
import { useKeys } from "@hooks/useKeys";
|
|
40
40
|
import {
|
|
41
41
|
useLoadingOvertime,
|
|
42
42
|
UseLoadingOvertimeOptionsProps,
|
|
43
43
|
UseLoadingOvertimeReturnType,
|
|
44
44
|
} from "../useLoadingOvertime";
|
|
45
|
-
import { useKeys } from "@hooks/useKeys";
|
|
46
45
|
|
|
47
46
|
export interface UseInfiniteListConfig {
|
|
48
47
|
pagination?: Pagination;
|
|
@@ -221,6 +220,10 @@ export const useInfiniteList = <
|
|
|
221
220
|
liveMode,
|
|
222
221
|
onLiveEvent,
|
|
223
222
|
dataProviderName: pickedDataProvider,
|
|
223
|
+
meta: {
|
|
224
|
+
...combinedMeta,
|
|
225
|
+
dataProviderName,
|
|
226
|
+
},
|
|
224
227
|
});
|
|
225
228
|
|
|
226
229
|
const queryResponse = useInfiniteQuery<
|
|
@@ -1,44 +1,43 @@
|
|
|
1
|
+
import { getXRay } from "@refinedev/devtools-internal";
|
|
1
2
|
import {
|
|
2
3
|
QueryObserverResult,
|
|
3
4
|
useQuery,
|
|
4
5
|
UseQueryOptions,
|
|
5
6
|
} from "@tanstack/react-query";
|
|
6
|
-
import { getXRay } from "@refinedev/devtools-internal";
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
CrudSorting,
|
|
15
|
-
MetaQuery,
|
|
16
|
-
SuccessErrorNotification,
|
|
17
|
-
LiveModeProps,
|
|
18
|
-
Prettify,
|
|
19
|
-
} from "../../interfaces";
|
|
9
|
+
handlePaginationParams,
|
|
10
|
+
pickDataProvider,
|
|
11
|
+
pickNotDeprecated,
|
|
12
|
+
useActiveAuthProvider,
|
|
13
|
+
} from "@definitions/helpers";
|
|
20
14
|
import {
|
|
21
|
-
|
|
15
|
+
useDataProvider,
|
|
22
16
|
useHandleNotification,
|
|
17
|
+
useMeta,
|
|
18
|
+
useOnError,
|
|
19
|
+
useResource,
|
|
23
20
|
useResourceSubscription,
|
|
24
21
|
useTranslate,
|
|
25
|
-
useDataProvider,
|
|
26
|
-
useOnError,
|
|
27
|
-
useMeta,
|
|
28
22
|
} from "@hooks";
|
|
23
|
+
import { useKeys } from "@hooks/useKeys";
|
|
29
24
|
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
BaseRecord,
|
|
26
|
+
CrudFilters,
|
|
27
|
+
CrudSorting,
|
|
28
|
+
GetListResponse,
|
|
29
|
+
HttpError,
|
|
30
|
+
LiveModeProps,
|
|
31
|
+
MetaQuery,
|
|
32
|
+
Pagination,
|
|
33
|
+
Prettify,
|
|
34
|
+
SuccessErrorNotification,
|
|
35
|
+
} from "../../interfaces";
|
|
36
36
|
import {
|
|
37
37
|
useLoadingOvertime,
|
|
38
38
|
UseLoadingOvertimeOptionsProps,
|
|
39
39
|
UseLoadingOvertimeReturnType,
|
|
40
40
|
} from "../useLoadingOvertime";
|
|
41
|
-
import { useKeys } from "@hooks/useKeys";
|
|
42
41
|
|
|
43
42
|
export interface UseListConfig {
|
|
44
43
|
pagination?: Pagination;
|
|
@@ -218,6 +217,10 @@ export const useList = <
|
|
|
218
217
|
liveMode,
|
|
219
218
|
onLiveEvent,
|
|
220
219
|
dataProviderName: pickedDataProvider,
|
|
220
|
+
meta: {
|
|
221
|
+
...meta,
|
|
222
|
+
dataProviderName,
|
|
223
|
+
},
|
|
221
224
|
});
|
|
222
225
|
|
|
223
226
|
const queryResponse = useQuery<
|
|
@@ -1,41 +1,40 @@
|
|
|
1
|
+
import { getXRay } from "@refinedev/devtools-internal";
|
|
1
2
|
import {
|
|
2
3
|
QueryObserverResult,
|
|
3
4
|
useQuery,
|
|
4
5
|
UseQueryOptions,
|
|
5
6
|
} from "@tanstack/react-query";
|
|
6
|
-
import { getXRay } from "@refinedev/devtools-internal";
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
-
|
|
9
|
+
handleMultiple,
|
|
10
|
+
pickDataProvider,
|
|
11
|
+
pickNotDeprecated,
|
|
12
|
+
useActiveAuthProvider,
|
|
13
|
+
} from "@definitions/helpers";
|
|
14
|
+
import {
|
|
15
|
+
useDataProvider,
|
|
16
|
+
useHandleNotification,
|
|
17
|
+
useMeta,
|
|
18
|
+
useOnError,
|
|
19
|
+
useResource,
|
|
20
|
+
useResourceSubscription,
|
|
21
|
+
useTranslate,
|
|
22
|
+
} from "@hooks";
|
|
23
|
+
import { useKeys } from "@hooks/useKeys";
|
|
24
|
+
import {
|
|
10
25
|
BaseKey,
|
|
26
|
+
BaseRecord,
|
|
11
27
|
GetManyResponse,
|
|
12
28
|
HttpError,
|
|
13
29
|
LiveModeProps,
|
|
14
|
-
SuccessErrorNotification,
|
|
15
30
|
MetaQuery,
|
|
31
|
+
SuccessErrorNotification,
|
|
16
32
|
} from "../../interfaces";
|
|
17
|
-
import {
|
|
18
|
-
useResource,
|
|
19
|
-
useTranslate,
|
|
20
|
-
useResourceSubscription,
|
|
21
|
-
useHandleNotification,
|
|
22
|
-
useDataProvider,
|
|
23
|
-
useOnError,
|
|
24
|
-
useMeta,
|
|
25
|
-
} from "@hooks";
|
|
26
|
-
import {
|
|
27
|
-
queryKeys,
|
|
28
|
-
pickDataProvider,
|
|
29
|
-
handleMultiple,
|
|
30
|
-
pickNotDeprecated,
|
|
31
|
-
useActiveAuthProvider,
|
|
32
|
-
} from "@definitions/helpers";
|
|
33
33
|
import {
|
|
34
34
|
useLoadingOvertime,
|
|
35
35
|
UseLoadingOvertimeOptionsProps,
|
|
36
36
|
UseLoadingOvertimeReturnType,
|
|
37
37
|
} from "../useLoadingOvertime";
|
|
38
|
-
import { useKeys } from "@hooks/useKeys";
|
|
39
38
|
|
|
40
39
|
export type UseManyProps<TQueryFnData, TError, TData> = {
|
|
41
40
|
/**
|
|
@@ -146,6 +145,10 @@ export const useMany = <
|
|
|
146
145
|
liveMode,
|
|
147
146
|
onLiveEvent,
|
|
148
147
|
dataProviderName: pickedDataProvider,
|
|
148
|
+
meta: {
|
|
149
|
+
...meta,
|
|
150
|
+
dataProviderName,
|
|
151
|
+
},
|
|
149
152
|
});
|
|
150
153
|
|
|
151
154
|
const queryResponse = useQuery<
|
package/src/hooks/data/useOne.ts
CHANGED
|
@@ -1,41 +1,40 @@
|
|
|
1
|
+
import { getXRay } from "@refinedev/devtools-internal";
|
|
1
2
|
import {
|
|
2
3
|
QueryObserverResult,
|
|
3
4
|
useQuery,
|
|
4
5
|
UseQueryOptions,
|
|
5
6
|
} from "@tanstack/react-query";
|
|
6
|
-
import { getXRay } from "@refinedev/devtools-internal";
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
+
pickDataProvider,
|
|
10
|
+
pickNotDeprecated,
|
|
11
|
+
useActiveAuthProvider,
|
|
12
|
+
} from "@definitions";
|
|
13
|
+
import {
|
|
14
|
+
useDataProvider,
|
|
15
|
+
useHandleNotification,
|
|
16
|
+
useMeta,
|
|
17
|
+
useOnError,
|
|
18
|
+
useResource,
|
|
19
|
+
useResourceSubscription,
|
|
20
|
+
useTranslate,
|
|
21
|
+
} from "@hooks";
|
|
22
|
+
import { useKeys } from "@hooks/useKeys";
|
|
23
|
+
import {
|
|
24
|
+
BaseKey,
|
|
25
|
+
BaseRecord,
|
|
9
26
|
GetOneResponse,
|
|
10
27
|
HttpError,
|
|
11
|
-
BaseRecord,
|
|
12
|
-
BaseKey,
|
|
13
28
|
LiveModeProps,
|
|
14
|
-
SuccessErrorNotification,
|
|
15
29
|
MetaQuery,
|
|
16
30
|
Prettify,
|
|
31
|
+
SuccessErrorNotification,
|
|
17
32
|
} from "../../interfaces";
|
|
18
|
-
import {
|
|
19
|
-
useResource,
|
|
20
|
-
useTranslate,
|
|
21
|
-
useResourceSubscription,
|
|
22
|
-
useHandleNotification,
|
|
23
|
-
useDataProvider,
|
|
24
|
-
useOnError,
|
|
25
|
-
useMeta,
|
|
26
|
-
} from "@hooks";
|
|
27
|
-
import {
|
|
28
|
-
queryKeys,
|
|
29
|
-
pickDataProvider,
|
|
30
|
-
pickNotDeprecated,
|
|
31
|
-
useActiveAuthProvider,
|
|
32
|
-
} from "@definitions";
|
|
33
33
|
import {
|
|
34
34
|
useLoadingOvertime,
|
|
35
35
|
UseLoadingOvertimeOptionsProps,
|
|
36
36
|
UseLoadingOvertimeReturnType,
|
|
37
37
|
} from "../useLoadingOvertime";
|
|
38
|
-
import { useKeys } from "@hooks/useKeys";
|
|
39
38
|
|
|
40
39
|
export type UseOneProps<TQueryFnData, TError, TData> = {
|
|
41
40
|
/**
|
|
@@ -154,6 +153,10 @@ export const useOne = <
|
|
|
154
153
|
liveMode,
|
|
155
154
|
onLiveEvent,
|
|
156
155
|
dataProviderName: pickedDataProvider,
|
|
156
|
+
meta: {
|
|
157
|
+
...meta,
|
|
158
|
+
dataProviderName,
|
|
159
|
+
},
|
|
157
160
|
});
|
|
158
161
|
|
|
159
162
|
const queryResponse = useQuery<
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
+
import { getXRay } from "@refinedev/devtools-internal";
|
|
1
2
|
import {
|
|
2
3
|
useMutation,
|
|
3
4
|
UseMutationOptions,
|
|
4
5
|
UseMutationResult,
|
|
5
6
|
useQueryClient,
|
|
6
7
|
} from "@tanstack/react-query";
|
|
7
|
-
import { getXRay } from "@refinedev/devtools-internal";
|
|
8
8
|
|
|
9
9
|
import { ActionTypes } from "@contexts/undoableQueue";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
HttpError,
|
|
17
|
-
SuccessErrorNotification,
|
|
18
|
-
MetaQuery,
|
|
19
|
-
PreviousQuery,
|
|
20
|
-
GetListResponse,
|
|
21
|
-
IQueryKeys,
|
|
22
|
-
OptimisticUpdateMapType,
|
|
23
|
-
GetManyResponse,
|
|
24
|
-
GetOneResponse,
|
|
25
|
-
} from "../../interfaces";
|
|
11
|
+
pickDataProvider,
|
|
12
|
+
pickNotDeprecated,
|
|
13
|
+
queryKeysReplacement,
|
|
14
|
+
useActiveAuthProvider,
|
|
15
|
+
} from "@definitions/helpers";
|
|
26
16
|
import {
|
|
27
|
-
useResource,
|
|
28
|
-
useMutationMode,
|
|
29
17
|
useCancelNotification,
|
|
30
|
-
useTranslate,
|
|
31
|
-
usePublish,
|
|
32
|
-
useHandleNotification,
|
|
33
18
|
useDataProvider,
|
|
34
|
-
|
|
19
|
+
useHandleNotification,
|
|
35
20
|
useInvalidate,
|
|
36
|
-
|
|
21
|
+
useLog,
|
|
37
22
|
useMeta,
|
|
23
|
+
useMutationMode,
|
|
24
|
+
useOnError,
|
|
25
|
+
usePublish,
|
|
38
26
|
useRefineContext,
|
|
27
|
+
useResource,
|
|
28
|
+
useTranslate,
|
|
39
29
|
} from "@hooks";
|
|
30
|
+
import { useKeys } from "@hooks/useKeys";
|
|
40
31
|
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
BaseKey,
|
|
33
|
+
BaseRecord,
|
|
34
|
+
GetListResponse,
|
|
35
|
+
GetManyResponse,
|
|
36
|
+
GetOneResponse,
|
|
37
|
+
HttpError,
|
|
38
|
+
IQueryKeys,
|
|
39
|
+
MetaQuery,
|
|
40
|
+
MutationMode,
|
|
41
|
+
OptimisticUpdateMapType,
|
|
42
|
+
PrevContext as UpdateContext,
|
|
43
|
+
PreviousQuery,
|
|
44
|
+
SuccessErrorNotification,
|
|
45
|
+
UpdateResponse,
|
|
46
|
+
} from "../../interfaces";
|
|
46
47
|
import {
|
|
47
48
|
useLoadingOvertime,
|
|
48
49
|
UseLoadingOvertimeOptionsProps,
|
|
49
50
|
UseLoadingOvertimeReturnType,
|
|
50
51
|
} from "../useLoadingOvertime";
|
|
51
|
-
import { useKeys } from "@hooks/useKeys";
|
|
52
52
|
|
|
53
53
|
export type UpdateParams<TData, TError, TVariables> = {
|
|
54
54
|
/**
|
|
@@ -480,7 +480,7 @@ export const useUpdate = <
|
|
|
480
480
|
id,
|
|
481
481
|
resource: resourceName,
|
|
482
482
|
successNotification,
|
|
483
|
-
dataProviderName,
|
|
483
|
+
dataProviderName: dataProviderNameFromProp,
|
|
484
484
|
values,
|
|
485
485
|
meta,
|
|
486
486
|
metaData,
|
|
@@ -488,9 +488,19 @@ export const useUpdate = <
|
|
|
488
488
|
context,
|
|
489
489
|
) => {
|
|
490
490
|
const { resource, identifier } = select(resourceName);
|
|
491
|
-
|
|
492
491
|
const resourceSingular = textTransformers.singular(identifier);
|
|
493
492
|
|
|
493
|
+
const dataProviderName = pickDataProvider(
|
|
494
|
+
identifier,
|
|
495
|
+
dataProviderNameFromProp,
|
|
496
|
+
resources,
|
|
497
|
+
);
|
|
498
|
+
|
|
499
|
+
const combinedMeta = getMeta({
|
|
500
|
+
resource,
|
|
501
|
+
meta: pickNotDeprecated(meta, metaData),
|
|
502
|
+
});
|
|
503
|
+
|
|
494
504
|
const notificationConfig =
|
|
495
505
|
typeof successNotification === "function"
|
|
496
506
|
? successNotification(data, { id, values }, identifier)
|
|
@@ -522,6 +532,10 @@ export const useUpdate = <
|
|
|
522
532
|
ids: data.data?.id ? [data.data.id] : undefined,
|
|
523
533
|
},
|
|
524
534
|
date: new Date(),
|
|
535
|
+
meta: {
|
|
536
|
+
...combinedMeta,
|
|
537
|
+
dataProviderName,
|
|
538
|
+
},
|
|
525
539
|
});
|
|
526
540
|
|
|
527
541
|
let previousData: any;
|
|
@@ -539,9 +553,12 @@ export const useUpdate = <
|
|
|
539
553
|
);
|
|
540
554
|
}
|
|
541
555
|
|
|
542
|
-
const {
|
|
543
|
-
|
|
544
|
-
|
|
556
|
+
const {
|
|
557
|
+
fields: _fields,
|
|
558
|
+
operation: _operation,
|
|
559
|
+
variables: _variables,
|
|
560
|
+
...rest
|
|
561
|
+
} = combinedMeta || {};
|
|
545
562
|
log?.mutate({
|
|
546
563
|
action: "update",
|
|
547
564
|
resource: resource.name,
|
|
@@ -549,11 +566,7 @@ export const useUpdate = <
|
|
|
549
566
|
previousData,
|
|
550
567
|
meta: {
|
|
551
568
|
id,
|
|
552
|
-
dataProviderName
|
|
553
|
-
identifier,
|
|
554
|
-
dataProviderName,
|
|
555
|
-
resources,
|
|
556
|
-
),
|
|
569
|
+
dataProviderName,
|
|
557
570
|
...rest,
|
|
558
571
|
},
|
|
559
572
|
});
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
+
import { getXRay } from "@refinedev/devtools-internal";
|
|
1
2
|
import {
|
|
2
3
|
useMutation,
|
|
3
4
|
UseMutationOptions,
|
|
4
5
|
UseMutationResult,
|
|
5
6
|
useQueryClient,
|
|
6
7
|
} from "@tanstack/react-query";
|
|
7
|
-
import { getXRay } from "@refinedev/devtools-internal";
|
|
8
8
|
|
|
9
|
+
import { ActionTypes } from "@contexts/undoableQueue";
|
|
10
|
+
import {
|
|
11
|
+
handleMultiple,
|
|
12
|
+
pickDataProvider,
|
|
13
|
+
pickNotDeprecated,
|
|
14
|
+
queryKeysReplacement,
|
|
15
|
+
useActiveAuthProvider,
|
|
16
|
+
} from "@definitions/helpers";
|
|
9
17
|
import {
|
|
10
|
-
useResource,
|
|
11
18
|
useCancelNotification,
|
|
12
|
-
useMutationMode,
|
|
13
|
-
useTranslate,
|
|
14
|
-
usePublish,
|
|
15
|
-
useHandleNotification,
|
|
16
19
|
useDataProvider,
|
|
20
|
+
useHandleNotification,
|
|
17
21
|
useInvalidate,
|
|
18
22
|
useLog,
|
|
19
|
-
useOnError,
|
|
20
23
|
useMeta,
|
|
24
|
+
useMutationMode,
|
|
25
|
+
useOnError,
|
|
26
|
+
usePublish,
|
|
21
27
|
useRefineContext,
|
|
28
|
+
useResource,
|
|
29
|
+
useTranslate,
|
|
22
30
|
} from "@hooks";
|
|
23
|
-
import {
|
|
31
|
+
import { useKeys } from "@hooks/useKeys";
|
|
24
32
|
import {
|
|
25
|
-
BaseRecord,
|
|
26
33
|
BaseKey,
|
|
27
|
-
|
|
34
|
+
BaseRecord,
|
|
35
|
+
GetListResponse,
|
|
36
|
+
GetManyResponse,
|
|
37
|
+
GetOneResponse,
|
|
28
38
|
HttpError,
|
|
39
|
+
IQueryKeys,
|
|
40
|
+
MetaQuery,
|
|
29
41
|
MutationMode,
|
|
30
|
-
|
|
42
|
+
OptimisticUpdateManyMapType,
|
|
31
43
|
PrevContext as UpdateContext,
|
|
44
|
+
QueryResponse,
|
|
32
45
|
SuccessErrorNotification,
|
|
33
|
-
|
|
34
|
-
GetListResponse,
|
|
35
|
-
IQueryKeys,
|
|
36
|
-
OptimisticUpdateManyMapType,
|
|
37
|
-
GetManyResponse,
|
|
38
|
-
GetOneResponse,
|
|
46
|
+
UpdateManyResponse,
|
|
39
47
|
} from "../../interfaces";
|
|
40
|
-
import {
|
|
41
|
-
queryKeysReplacement,
|
|
42
|
-
pickDataProvider,
|
|
43
|
-
handleMultiple,
|
|
44
|
-
pickNotDeprecated,
|
|
45
|
-
useActiveAuthProvider,
|
|
46
|
-
} from "@definitions/helpers";
|
|
47
48
|
import {
|
|
48
49
|
useLoadingOvertime,
|
|
49
50
|
UseLoadingOvertimeOptionsProps,
|
|
50
51
|
UseLoadingOvertimeReturnType,
|
|
51
52
|
} from "../useLoadingOvertime";
|
|
52
|
-
import { useKeys } from "@hooks/useKeys";
|
|
53
53
|
|
|
54
54
|
type UpdateManyParams<TData, TError, TVariables> = {
|
|
55
55
|
/**
|
|
@@ -508,16 +508,26 @@ export const useUpdateMany = <
|
|
|
508
508
|
resource: resourceName,
|
|
509
509
|
meta,
|
|
510
510
|
metaData,
|
|
511
|
-
dataProviderName,
|
|
511
|
+
dataProviderName: dataProviderNameFromProp,
|
|
512
512
|
successNotification,
|
|
513
513
|
values,
|
|
514
514
|
},
|
|
515
515
|
context,
|
|
516
516
|
) => {
|
|
517
517
|
const { resource, identifier } = select(resourceName);
|
|
518
|
-
|
|
519
518
|
const resourceSingular = textTransformers.singular(identifier);
|
|
520
519
|
|
|
520
|
+
const dataProviderName = pickDataProvider(
|
|
521
|
+
identifier,
|
|
522
|
+
dataProviderNameFromProp,
|
|
523
|
+
resources,
|
|
524
|
+
);
|
|
525
|
+
|
|
526
|
+
const combinedMeta = getMeta({
|
|
527
|
+
resource,
|
|
528
|
+
meta: pickNotDeprecated(meta, metaData),
|
|
529
|
+
});
|
|
530
|
+
|
|
521
531
|
const notificationConfig =
|
|
522
532
|
typeof successNotification === "function"
|
|
523
533
|
? successNotification(data, { ids, values }, identifier)
|
|
@@ -549,6 +559,10 @@ export const useUpdateMany = <
|
|
|
549
559
|
ids: ids.map(String),
|
|
550
560
|
},
|
|
551
561
|
date: new Date(),
|
|
562
|
+
meta: {
|
|
563
|
+
...combinedMeta,
|
|
564
|
+
dataProviderName,
|
|
565
|
+
},
|
|
552
566
|
});
|
|
553
567
|
|
|
554
568
|
const previousData: any[] = [];
|
|
@@ -570,14 +584,12 @@ export const useUpdateMany = <
|
|
|
570
584
|
});
|
|
571
585
|
}
|
|
572
586
|
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
combinedMeta || {};
|
|
580
|
-
|
|
587
|
+
const {
|
|
588
|
+
fields: _fields,
|
|
589
|
+
operation: _operation,
|
|
590
|
+
variables: _variables,
|
|
591
|
+
...rest
|
|
592
|
+
} = combinedMeta || {};
|
|
581
593
|
log?.mutate({
|
|
582
594
|
action: "updateMany",
|
|
583
595
|
resource: resource.name,
|
|
@@ -585,11 +597,7 @@ export const useUpdateMany = <
|
|
|
585
597
|
previousData,
|
|
586
598
|
meta: {
|
|
587
599
|
ids,
|
|
588
|
-
dataProviderName
|
|
589
|
-
identifier,
|
|
590
|
-
dataProviderName,
|
|
591
|
-
resources,
|
|
592
|
-
),
|
|
600
|
+
dataProviderName,
|
|
593
601
|
...rest,
|
|
594
602
|
},
|
|
595
603
|
});
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { LiveContext } from "@contexts/live";
|
|
2
|
+
import { RefineContext } from "@contexts/refine";
|
|
3
|
+
import { useInvalidate } from "@hooks/invalidate";
|
|
4
|
+
import { useResource } from "@hooks/resource";
|
|
1
5
|
import { useContext, useEffect } from "react";
|
|
2
6
|
import {
|
|
3
7
|
BaseKey,
|
|
@@ -10,16 +14,15 @@ import {
|
|
|
10
14
|
MetaQuery,
|
|
11
15
|
Pagination,
|
|
12
16
|
} from "../../../interfaces";
|
|
13
|
-
import { LiveContext } from "@contexts/live";
|
|
14
|
-
import { RefineContext } from "@contexts/refine";
|
|
15
|
-
import { useResource } from "@hooks/resource";
|
|
16
|
-
import { useInvalidate } from "@hooks/invalidate";
|
|
17
17
|
|
|
18
18
|
export type UseResourceSubscriptionProps = {
|
|
19
19
|
channel: string;
|
|
20
20
|
params?: {
|
|
21
21
|
ids?: BaseKey[];
|
|
22
22
|
id?: BaseKey;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated `params.meta` is depcerated. Use `meta` directly from the root level instead.
|
|
25
|
+
*/
|
|
23
26
|
meta?: MetaQuery;
|
|
24
27
|
/**
|
|
25
28
|
* @deprecated `metaData` is deprecated with refine@4, refine will pass `meta` instead, however, we still support `metaData` for backward compatibility.
|
|
@@ -42,7 +45,11 @@ export type UseResourceSubscriptionProps = {
|
|
|
42
45
|
types: LiveEvent["type"][];
|
|
43
46
|
resource?: string;
|
|
44
47
|
enabled?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated use `meta.dataProviderName` instead.
|
|
50
|
+
*/
|
|
45
51
|
dataProviderName?: string;
|
|
52
|
+
meta?: MetaQuery & { dataProviderName?: string };
|
|
46
53
|
} & LiveModeProps;
|
|
47
54
|
|
|
48
55
|
export type PublishType = {
|
|
@@ -57,7 +64,8 @@ export const useResourceSubscription = ({
|
|
|
57
64
|
enabled = true,
|
|
58
65
|
liveMode: liveModeFromProp,
|
|
59
66
|
onLiveEvent,
|
|
60
|
-
dataProviderName,
|
|
67
|
+
dataProviderName: dataProviderNameFromProps,
|
|
68
|
+
meta,
|
|
61
69
|
}: UseResourceSubscriptionProps): void => {
|
|
62
70
|
const { resource, identifier } = useResource(resourceFromProp);
|
|
63
71
|
|
|
@@ -71,6 +79,11 @@ export const useResourceSubscription = ({
|
|
|
71
79
|
|
|
72
80
|
const invalidate = useInvalidate();
|
|
73
81
|
|
|
82
|
+
const dataProviderName =
|
|
83
|
+
dataProviderNameFromProps ??
|
|
84
|
+
meta?.dataProviderName ??
|
|
85
|
+
resource?.meta?.dataProviderName;
|
|
86
|
+
|
|
74
87
|
useEffect(() => {
|
|
75
88
|
let subscription: any;
|
|
76
89
|
|
|
@@ -78,7 +91,7 @@ export const useResourceSubscription = ({
|
|
|
78
91
|
if (liveMode === "auto") {
|
|
79
92
|
invalidate({
|
|
80
93
|
resource: identifier,
|
|
81
|
-
dataProviderName
|
|
94
|
+
dataProviderName,
|
|
82
95
|
invalidates: ["resourceAll"],
|
|
83
96
|
invalidationFilters: {
|
|
84
97
|
type: "active",
|
|
@@ -102,6 +115,10 @@ export const useResourceSubscription = ({
|
|
|
102
115
|
types,
|
|
103
116
|
callback,
|
|
104
117
|
dataProviderName,
|
|
118
|
+
meta: {
|
|
119
|
+
...meta,
|
|
120
|
+
dataProviderName,
|
|
121
|
+
},
|
|
105
122
|
});
|
|
106
123
|
}
|
|
107
124
|
|