@refinedev/core 4.34.0 → 4.36.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 +25 -1
- package/dist/contexts/refine/IRefineContext.d.ts +2 -0
- package/dist/contexts/refine/IRefineContext.d.ts.map +1 -1
- package/dist/definitions/helpers/handleRefineOptions/index.d.ts.map +1 -1
- package/dist/definitions/helpers/index.d.ts +3 -1
- package/dist/definitions/helpers/index.d.ts.map +1 -1
- package/dist/definitions/helpers/keys/index.d.ts +75 -0
- package/dist/definitions/helpers/keys/index.d.ts.map +1 -0
- package/dist/definitions/helpers/queryKeys/index.d.ts +4 -0
- package/dist/definitions/helpers/queryKeys/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/accessControl/useCan/index.d.ts.map +1 -1
- package/dist/hooks/auditLog/useLog/index.d.ts.map +1 -1
- package/dist/hooks/auditLog/useLogList/index.d.ts.map +1 -1
- package/dist/hooks/auth/useForgotPassword/index.d.ts.map +1 -1
- package/dist/hooks/auth/useGetIdentity/index.d.ts.map +1 -1
- package/dist/hooks/auth/useInvalidateAuthStore/index.d.ts.map +1 -1
- package/dist/hooks/auth/useIsAuthenticated/index.d.ts.map +1 -1
- package/dist/hooks/auth/useLogin/index.d.ts.map +1 -1
- package/dist/hooks/auth/useLogout/index.d.ts.map +1 -1
- package/dist/hooks/auth/useOnError/index.d.ts.map +1 -1
- package/dist/hooks/auth/usePermissions/index.d.ts.map +1 -1
- package/dist/hooks/auth/useRegister/index.d.ts.map +1 -1
- package/dist/hooks/auth/useUpdatePassword/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/invalidate/index.d.ts.map +1 -1
- package/dist/hooks/live/useResourceSubscription/index.d.ts.map +1 -1
- package/dist/hooks/useKeys/index.d.ts +5 -0
- package/dist/hooks/useKeys/index.d.ts.map +1 -0
- package/dist/iife/index.js +6 -6
- package/dist/iife/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/mutationMode.d.ts +3 -0
- package/dist/interfaces/mutationMode.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/contexts/refine/IRefineContext.ts +2 -0
- package/src/definitions/helpers/handleRefineOptions/index.ts +1 -0
- package/src/definitions/helpers/index.ts +3 -1
- package/src/definitions/helpers/keys/index.ts +336 -0
- package/src/definitions/helpers/queryKeys/index.ts +68 -0
- package/src/hooks/accessControl/useCan/index.ts +9 -7
- package/src/hooks/auditLog/useLog/index.ts +15 -8
- package/src/hooks/auditLog/useLogList/index.ts +8 -4
- package/src/hooks/auth/useForgotPassword/index.ts +29 -20
- package/src/hooks/auth/useGetIdentity/index.ts +7 -2
- package/src/hooks/auth/useInvalidateAuthStore/index.ts +11 -3
- package/src/hooks/auth/useIsAuthenticated/index.ts +11 -2
- package/src/hooks/auth/useLogin/index.ts +35 -26
- package/src/hooks/auth/useLogout/index.ts +7 -2
- package/src/hooks/auth/useOnError/index.ts +26 -16
- package/src/hooks/auth/usePermissions/index.ts +7 -2
- package/src/hooks/auth/useRegister/index.ts +34 -24
- package/src/hooks/auth/useUpdatePassword/index.ts +8 -2
- package/src/hooks/data/useCreate.ts +3 -0
- package/src/hooks/data/useCreateMany.ts +6 -0
- package/src/hooks/data/useCustom.ts +12 -7
- package/src/hooks/data/useCustomMutation.ts +6 -0
- package/src/hooks/data/useDelete.ts +24 -6
- package/src/hooks/data/useDeleteMany.ts +32 -7
- package/src/hooks/data/useInfiniteList.ts +21 -20
- package/src/hooks/data/useList.ts +21 -15
- package/src/hooks/data/useMany.ts +11 -3
- package/src/hooks/data/useOne.ts +11 -3
- package/src/hooks/data/useUpdate.ts +29 -7
- package/src/hooks/data/useUpdateMany.ts +31 -7
- package/src/hooks/invalidate/index.tsx +24 -10
- package/src/hooks/live/useResourceSubscription/index.ts +8 -3
- package/src/hooks/useKeys/index.tsx +13 -0
- package/src/index.tsx +2 -0
- package/src/interfaces/mutationMode.ts +3 -0
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
|
|
7
7
|
import { useAuthBindingsContext, useLegacyAuthContext } from "@contexts/auth";
|
|
8
8
|
import { IdentityResponse } from "../../../interfaces";
|
|
9
|
+
import { useKeys } from "@hooks/useKeys";
|
|
9
10
|
|
|
10
11
|
export type UseGetIdentityLegacyProps<TData> = {
|
|
11
12
|
v3LegacyAuthProviderCompatible: true;
|
|
@@ -64,9 +65,10 @@ export function useGetIdentity<TData = any>({
|
|
|
64
65
|
| UseGetIdentityLegacyReturnType<TData> {
|
|
65
66
|
const { getUserIdentity: legacyGetUserIdentity } = useLegacyAuthContext();
|
|
66
67
|
const { getIdentity } = useAuthBindingsContext();
|
|
68
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
67
69
|
|
|
68
70
|
const queryResponse = useQuery<TData>(
|
|
69
|
-
|
|
71
|
+
keys().auth().action("identity").get(preferLegacyKeys),
|
|
70
72
|
// Enabled check for `getIdentity` is enough to be sure that it's defined in the query function but TS is not smart enough to know that.
|
|
71
73
|
(getIdentity as (params?: unknown) => Promise<TData>) ??
|
|
72
74
|
(() => Promise.resolve({})),
|
|
@@ -78,7 +80,10 @@ export function useGetIdentity<TData = any>({
|
|
|
78
80
|
);
|
|
79
81
|
|
|
80
82
|
const legacyQueryResponse = useQuery<TData>(
|
|
81
|
-
[
|
|
83
|
+
[
|
|
84
|
+
...keys().auth().action("identity").get(preferLegacyKeys),
|
|
85
|
+
"v3LegacyAuthProviderCompatible",
|
|
86
|
+
],
|
|
82
87
|
// Enabled check for `getUserIdentity` is enough to be sure that it's defined in the query function but TS is not smart enough to know that.
|
|
83
88
|
legacyGetUserIdentity ?? (() => Promise.resolve({})),
|
|
84
89
|
{
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import { useKeys } from "@hooks/useKeys";
|
|
1
2
|
import { useQueryClient } from "@tanstack/react-query";
|
|
2
3
|
|
|
3
4
|
export const useInvalidateAuthStore = () => {
|
|
4
5
|
const queryClient = useQueryClient();
|
|
6
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
5
7
|
|
|
6
8
|
const invalidate = async () => {
|
|
7
9
|
await Promise.all([
|
|
8
|
-
queryClient.invalidateQueries(
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
queryClient.invalidateQueries(
|
|
11
|
+
keys().auth().action("check").get(preferLegacyKeys),
|
|
12
|
+
),
|
|
13
|
+
queryClient.invalidateQueries(
|
|
14
|
+
keys().auth().action("identity").get(preferLegacyKeys),
|
|
15
|
+
),
|
|
16
|
+
queryClient.invalidateQueries(
|
|
17
|
+
keys().auth().action("permissions").get(preferLegacyKeys),
|
|
18
|
+
),
|
|
11
19
|
]);
|
|
12
20
|
};
|
|
13
21
|
|
|
@@ -2,6 +2,7 @@ import { useQuery, UseQueryResult } from "@tanstack/react-query";
|
|
|
2
2
|
|
|
3
3
|
import { useAuthBindingsContext, useLegacyAuthContext } from "@contexts/auth";
|
|
4
4
|
import { CheckResponse } from "../../../interfaces";
|
|
5
|
+
import { useKeys } from "@hooks/useKeys";
|
|
5
6
|
|
|
6
7
|
export type UseIsAuthenticatedLegacyProps = {
|
|
7
8
|
v3LegacyAuthProviderCompatible: true;
|
|
@@ -52,9 +53,10 @@ export function useIsAuthenticated({
|
|
|
52
53
|
| UseIsAuthenticatedLegacyReturnType {
|
|
53
54
|
const { checkAuth } = useLegacyAuthContext();
|
|
54
55
|
const { check } = useAuthBindingsContext();
|
|
56
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
55
57
|
|
|
56
58
|
const queryResponse = useQuery(
|
|
57
|
-
|
|
59
|
+
keys().auth().action("check").params(params).get(preferLegacyKeys),
|
|
58
60
|
async () => (await check?.(params)) ?? {},
|
|
59
61
|
{
|
|
60
62
|
retry: false,
|
|
@@ -63,7 +65,14 @@ export function useIsAuthenticated({
|
|
|
63
65
|
);
|
|
64
66
|
|
|
65
67
|
const legacyQueryResponse = useQuery(
|
|
66
|
-
[
|
|
68
|
+
[
|
|
69
|
+
...keys()
|
|
70
|
+
.auth()
|
|
71
|
+
.action("check")
|
|
72
|
+
.params(params)
|
|
73
|
+
.get(preferLegacyKeys),
|
|
74
|
+
"v3LegacyAuthProviderCompatible",
|
|
75
|
+
],
|
|
67
76
|
async () => (await checkAuth?.(params)) ?? {},
|
|
68
77
|
{
|
|
69
78
|
retry: false,
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
} from "../../../interfaces";
|
|
24
24
|
import { AuthActionResponse } from "src/interfaces/bindings/auth";
|
|
25
25
|
import { useInvalidateAuthStore } from "../useInvalidateAuthStore";
|
|
26
|
+
import { useKeys } from "@hooks/useKeys";
|
|
26
27
|
|
|
27
28
|
export type UseLoginLegacyProps<TVariables> = {
|
|
28
29
|
v3LegacyAuthProviderCompatible: true;
|
|
@@ -125,6 +126,7 @@ export function useLogin<TVariables = {}>({
|
|
|
125
126
|
const { close, open } = useNotification();
|
|
126
127
|
const { login: legacyLoginFromContext } = useLegacyAuthContext();
|
|
127
128
|
const { login: loginFromContext } = useAuthBindingsContext();
|
|
129
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
128
130
|
|
|
129
131
|
const to = React.useMemo(() => {
|
|
130
132
|
if (routerType === "legacy") {
|
|
@@ -142,7 +144,7 @@ export function useLogin<TVariables = {}>({
|
|
|
142
144
|
Error | RefineError,
|
|
143
145
|
TVariables,
|
|
144
146
|
unknown
|
|
145
|
-
>(
|
|
147
|
+
>(keys().auth().action("login").get(preferLegacyKeys), loginFromContext, {
|
|
146
148
|
onSuccess: async ({ success, redirectTo, error }) => {
|
|
147
149
|
if (success) {
|
|
148
150
|
close?.("login-error");
|
|
@@ -183,37 +185,44 @@ export function useLogin<TVariables = {}>({
|
|
|
183
185
|
Error | RefineError,
|
|
184
186
|
TVariables,
|
|
185
187
|
unknown
|
|
186
|
-
>(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
>(
|
|
189
|
+
[
|
|
190
|
+
...keys().auth().action("login").get(preferLegacyKeys),
|
|
191
|
+
"v3LegacyAuthProviderCompatible",
|
|
192
|
+
],
|
|
193
|
+
legacyLoginFromContext,
|
|
194
|
+
{
|
|
195
|
+
onSuccess: async (redirectPathFromAuth) => {
|
|
196
|
+
await invalidateAuthStore();
|
|
197
|
+
|
|
198
|
+
if (to) {
|
|
199
|
+
replace(to as string);
|
|
200
|
+
}
|
|
193
201
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
} else {
|
|
202
|
-
if (routerType === "legacy") {
|
|
203
|
-
replace("/");
|
|
202
|
+
if (redirectPathFromAuth !== false && !to) {
|
|
203
|
+
if (typeof redirectPathFromAuth === "string") {
|
|
204
|
+
if (routerType === "legacy") {
|
|
205
|
+
replace(redirectPathFromAuth);
|
|
206
|
+
} else {
|
|
207
|
+
go({ to: redirectPathFromAuth, type: "replace" });
|
|
208
|
+
}
|
|
204
209
|
} else {
|
|
205
|
-
|
|
210
|
+
if (routerType === "legacy") {
|
|
211
|
+
replace("/");
|
|
212
|
+
} else {
|
|
213
|
+
go({ to: "/", type: "replace" });
|
|
214
|
+
}
|
|
206
215
|
}
|
|
207
216
|
}
|
|
208
|
-
}
|
|
209
217
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
218
|
+
close?.("login-error");
|
|
219
|
+
},
|
|
220
|
+
onError: (error: any) => {
|
|
221
|
+
open?.(buildNotification(error));
|
|
222
|
+
},
|
|
223
|
+
...(v3LegacyAuthProviderCompatible ? mutationOptions : {}),
|
|
214
224
|
},
|
|
215
|
-
|
|
216
|
-
});
|
|
225
|
+
);
|
|
217
226
|
|
|
218
227
|
return v3LegacyAuthProviderCompatible
|
|
219
228
|
? v3LegacyAuthProviderCompatibleMutation
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "../../../interfaces";
|
|
14
14
|
import { AuthActionResponse } from "src/interfaces/bindings/auth";
|
|
15
15
|
import { useInvalidateAuthStore } from "../useInvalidateAuthStore";
|
|
16
|
+
import { useKeys } from "@hooks/useKeys";
|
|
16
17
|
|
|
17
18
|
type Variables = {
|
|
18
19
|
redirectPath?: string | false;
|
|
@@ -109,13 +110,14 @@ export function useLogout<TVariables = {}>({
|
|
|
109
110
|
const { open, close } = useNotification();
|
|
110
111
|
const { logout: legacyLogoutFromContext } = useLegacyAuthContext();
|
|
111
112
|
const { logout: logoutFromContext } = useAuthBindingsContext();
|
|
113
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
112
114
|
|
|
113
115
|
const mutation = useMutation<
|
|
114
116
|
AuthActionResponse,
|
|
115
117
|
Error | RefineError,
|
|
116
118
|
(TVariables & Variables) | void,
|
|
117
119
|
unknown
|
|
118
|
-
>(
|
|
120
|
+
>(keys().auth().action("logout").get(preferLegacyKeys), logoutFromContext, {
|
|
119
121
|
onSuccess: async (data, variables) => {
|
|
120
122
|
const { success, error, redirectTo } = data;
|
|
121
123
|
const { redirectPath } = variables ?? {};
|
|
@@ -154,7 +156,10 @@ export function useLogout<TVariables = {}>({
|
|
|
154
156
|
(TVariables & Variables) | void,
|
|
155
157
|
unknown
|
|
156
158
|
>(
|
|
157
|
-
[
|
|
159
|
+
[
|
|
160
|
+
...keys().auth().action("logout").get(preferLegacyKeys),
|
|
161
|
+
"v3LegacyAuthProviderCompatible",
|
|
162
|
+
],
|
|
158
163
|
legacyLogoutFromContext,
|
|
159
164
|
{
|
|
160
165
|
onSuccess: async (data, variables) => {
|
|
@@ -3,6 +3,7 @@ import { useMutation, UseMutationResult } from "@tanstack/react-query";
|
|
|
3
3
|
import { useAuthBindingsContext, useLegacyAuthContext } from "@contexts/auth";
|
|
4
4
|
import { OnErrorResponse } from "../../../interfaces";
|
|
5
5
|
import { useGo, useLogout, useNavigation, useRouterType } from "@hooks";
|
|
6
|
+
import { useKeys } from "@hooks/useKeys";
|
|
6
7
|
|
|
7
8
|
export type UseOnErrorLegacyProps = {
|
|
8
9
|
v3LegacyAuthProviderCompatible: true;
|
|
@@ -64,6 +65,8 @@ export function useOnError({
|
|
|
64
65
|
const { checkError: legacyCheckErrorFromContext } = useLegacyAuthContext();
|
|
65
66
|
const { onError: onErrorFromContext } = useAuthBindingsContext();
|
|
66
67
|
|
|
68
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
69
|
+
|
|
67
70
|
const { mutate: legacyLogout } = useLogout({
|
|
68
71
|
v3LegacyAuthProviderCompatible: Boolean(v3LegacyAuthProviderCompatible),
|
|
69
72
|
});
|
|
@@ -71,26 +74,33 @@ export function useOnError({
|
|
|
71
74
|
v3LegacyAuthProviderCompatible: Boolean(v3LegacyAuthProviderCompatible),
|
|
72
75
|
});
|
|
73
76
|
|
|
74
|
-
const mutation = useMutation(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
const mutation = useMutation(
|
|
78
|
+
keys().auth().action("onError").get(preferLegacyKeys),
|
|
79
|
+
onErrorFromContext,
|
|
80
|
+
{
|
|
81
|
+
onSuccess: ({ logout: shouldLogout, redirectTo }) => {
|
|
82
|
+
if (shouldLogout) {
|
|
83
|
+
logout({ redirectPath: redirectTo });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (redirectTo) {
|
|
88
|
+
if (routerType === "legacy") {
|
|
89
|
+
replace(redirectTo);
|
|
90
|
+
} else {
|
|
91
|
+
go({ to: redirectTo, type: "replace" });
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
86
94
|
}
|
|
87
|
-
|
|
88
|
-
}
|
|
95
|
+
},
|
|
89
96
|
},
|
|
90
|
-
|
|
97
|
+
);
|
|
91
98
|
|
|
92
99
|
const v3LegacyAuthProviderCompatibleMutation = useMutation(
|
|
93
|
-
[
|
|
100
|
+
[
|
|
101
|
+
...keys().auth().action("onError").get(preferLegacyKeys),
|
|
102
|
+
"v3LegacyAuthProviderCompatible",
|
|
103
|
+
],
|
|
94
104
|
legacyCheckErrorFromContext,
|
|
95
105
|
{
|
|
96
106
|
onError: (redirectPath?: string) => {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
UseQueryResult,
|
|
6
6
|
UseQueryOptions,
|
|
7
7
|
} from "@tanstack/react-query";
|
|
8
|
+
import { useKeys } from "@hooks/useKeys";
|
|
8
9
|
|
|
9
10
|
export type UsePermissionsLegacyProps<TData = any> = {
|
|
10
11
|
v3LegacyAuthProviderCompatible: true;
|
|
@@ -61,9 +62,10 @@ export function usePermissions<TData = any>({
|
|
|
61
62
|
| UsePermissionsLegacyReturnType<TData> {
|
|
62
63
|
const { getPermissions: legacyGetPermission } = useLegacyAuthContext();
|
|
63
64
|
const { getPermissions } = useAuthBindingsContext();
|
|
65
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
64
66
|
|
|
65
67
|
const queryResponse = useQuery<TData>(
|
|
66
|
-
|
|
68
|
+
keys().auth().action("permissions").get(preferLegacyKeys),
|
|
67
69
|
// Enabled check for `getPermissions` is enough to be sure that it's defined in the query function but TS is not smart enough to know that.
|
|
68
70
|
(getPermissions as (params?: unknown) => Promise<TData>) ??
|
|
69
71
|
(() => Promise.resolve(undefined)),
|
|
@@ -74,7 +76,10 @@ export function usePermissions<TData = any>({
|
|
|
74
76
|
);
|
|
75
77
|
|
|
76
78
|
const legacyQueryResponse = useQuery<TData>(
|
|
77
|
-
[
|
|
79
|
+
[
|
|
80
|
+
...keys().auth().action("permissions").get(preferLegacyKeys),
|
|
81
|
+
"v3LegacyAuthProviderCompatible",
|
|
82
|
+
],
|
|
78
83
|
// Enabled check for `getPermissions` is enough to be sure that it's defined in the query function but TS is not smart enough to know that.
|
|
79
84
|
legacyGetPermission ?? (() => Promise.resolve(undefined)),
|
|
80
85
|
{
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
TRegisterData,
|
|
16
16
|
} from "../../../interfaces";
|
|
17
17
|
import { useInvalidateAuthStore } from "../useInvalidateAuthStore";
|
|
18
|
+
import { useKeys } from "@hooks/useKeys";
|
|
18
19
|
|
|
19
20
|
export type UseRegisterLegacyProps<TVariables> = {
|
|
20
21
|
v3LegacyAuthProviderCompatible: true;
|
|
@@ -111,40 +112,46 @@ export function useRegister<TVariables = {}>({
|
|
|
111
112
|
const { register: registerFromContext } = useAuthBindingsContext();
|
|
112
113
|
const { close, open } = useNotification();
|
|
113
114
|
|
|
115
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
116
|
+
|
|
114
117
|
const mutation = useMutation<
|
|
115
118
|
AuthActionResponse,
|
|
116
119
|
Error | RefineError,
|
|
117
120
|
TVariables,
|
|
118
121
|
unknown
|
|
119
|
-
>(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
122
|
+
>(
|
|
123
|
+
keys().auth().action("register").get(preferLegacyKeys),
|
|
124
|
+
registerFromContext,
|
|
125
|
+
{
|
|
126
|
+
onSuccess: async ({ success, redirectTo, error }) => {
|
|
127
|
+
if (success) {
|
|
128
|
+
close?.("register-error");
|
|
129
|
+
}
|
|
124
130
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
if (error || !success) {
|
|
132
|
+
open?.(buildNotification(error));
|
|
133
|
+
}
|
|
128
134
|
|
|
129
|
-
|
|
135
|
+
await invalidateAuthStore();
|
|
130
136
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
if (redirectTo) {
|
|
138
|
+
if (routerType === "legacy") {
|
|
139
|
+
replace(redirectTo);
|
|
140
|
+
} else {
|
|
141
|
+
go({ to: redirectTo, type: "replace" });
|
|
142
|
+
}
|
|
134
143
|
} else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (routerType === "legacy") {
|
|
139
|
-
replace("/");
|
|
144
|
+
if (routerType === "legacy") {
|
|
145
|
+
replace("/");
|
|
146
|
+
}
|
|
140
147
|
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
},
|
|
149
|
+
onError: (error: any) => {
|
|
150
|
+
open?.(buildNotification(error));
|
|
151
|
+
},
|
|
152
|
+
...(v3LegacyAuthProviderCompatible === true ? {} : mutationOptions),
|
|
145
153
|
},
|
|
146
|
-
|
|
147
|
-
});
|
|
154
|
+
);
|
|
148
155
|
|
|
149
156
|
const v3LegacyAuthProviderCompatibleMutation = useMutation<
|
|
150
157
|
TRegisterData,
|
|
@@ -152,7 +159,10 @@ export function useRegister<TVariables = {}>({
|
|
|
152
159
|
TVariables,
|
|
153
160
|
unknown
|
|
154
161
|
>(
|
|
155
|
-
[
|
|
162
|
+
[
|
|
163
|
+
...keys().auth().action("register").get(preferLegacyKeys),
|
|
164
|
+
"v3LegacyAuthProviderCompatible",
|
|
165
|
+
],
|
|
156
166
|
legacyRegisterFromContext,
|
|
157
167
|
{
|
|
158
168
|
onSuccess: async (redirectPathFromAuth) => {
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
TUpdatePasswordData,
|
|
23
23
|
UpdatePasswordFormTypes,
|
|
24
24
|
} from "../../../interfaces";
|
|
25
|
+
import { useKeys } from "@hooks/useKeys";
|
|
25
26
|
|
|
26
27
|
export type UseUpdatePasswordLegacyProps<
|
|
27
28
|
TVariables extends UpdatePasswordFormTypes,
|
|
@@ -135,6 +136,8 @@ export function useUpdatePassword<
|
|
|
135
136
|
useAuthBindingsContext();
|
|
136
137
|
const { close, open } = useNotification();
|
|
137
138
|
|
|
139
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
140
|
+
|
|
138
141
|
const parsed = useParsed();
|
|
139
142
|
const { useLocation } = useRouterContext();
|
|
140
143
|
const { search } = useLocation();
|
|
@@ -156,7 +159,7 @@ export function useUpdatePassword<
|
|
|
156
159
|
TVariables,
|
|
157
160
|
unknown
|
|
158
161
|
>(
|
|
159
|
-
|
|
162
|
+
keys().auth().action("updatePassword").get(preferLegacyKeys),
|
|
160
163
|
async (variables) => {
|
|
161
164
|
return updatePasswordFromContext?.({
|
|
162
165
|
...params,
|
|
@@ -194,7 +197,10 @@ export function useUpdatePassword<
|
|
|
194
197
|
TVariables,
|
|
195
198
|
unknown
|
|
196
199
|
>(
|
|
197
|
-
[
|
|
200
|
+
[
|
|
201
|
+
...keys().auth().action("updatePassword").get(preferLegacyKeys),
|
|
202
|
+
"v3LegacyAuthProviderCompatible",
|
|
203
|
+
],
|
|
198
204
|
async (variables) => {
|
|
199
205
|
return legacyUpdatePasswordFromContext?.({
|
|
200
206
|
...params,
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
UseLoadingOvertimeOptionsProps,
|
|
35
35
|
UseLoadingOvertimeReturnType,
|
|
36
36
|
} from "../useLoadingOvertime";
|
|
37
|
+
import { useKeys } from "@hooks/useKeys";
|
|
37
38
|
|
|
38
39
|
type useCreateParams<TData, TError, TVariables> = {
|
|
39
40
|
/**
|
|
@@ -131,6 +132,7 @@ export const useCreate = <
|
|
|
131
132
|
const {
|
|
132
133
|
options: { textTransformers },
|
|
133
134
|
} = useRefineContext();
|
|
135
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
134
136
|
|
|
135
137
|
const mutation = useMutation<
|
|
136
138
|
CreateResponse<TData>,
|
|
@@ -277,6 +279,7 @@ export const useCreate = <
|
|
|
277
279
|
type: "error",
|
|
278
280
|
});
|
|
279
281
|
},
|
|
282
|
+
mutationKey: keys().data().mutation("create").get(preferLegacyKeys),
|
|
280
283
|
...mutationOptions,
|
|
281
284
|
},
|
|
282
285
|
);
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
UseLoadingOvertimeOptionsProps,
|
|
34
34
|
UseLoadingOvertimeReturnType,
|
|
35
35
|
} from "../useLoadingOvertime";
|
|
36
|
+
import { useKeys } from "@hooks/useKeys";
|
|
36
37
|
|
|
37
38
|
type useCreateManyParams<TData, TError, TVariables> = {
|
|
38
39
|
resource: string;
|
|
@@ -105,6 +106,7 @@ export const useCreateMany = <
|
|
|
105
106
|
const {
|
|
106
107
|
options: { textTransformers },
|
|
107
108
|
} = useRefineContext();
|
|
109
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
108
110
|
|
|
109
111
|
const mutation = useMutation<
|
|
110
112
|
CreateManyResponse<TData>,
|
|
@@ -261,6 +263,10 @@ export const useCreateMany = <
|
|
|
261
263
|
type: "error",
|
|
262
264
|
});
|
|
263
265
|
},
|
|
266
|
+
mutationKey: keys()
|
|
267
|
+
.data()
|
|
268
|
+
.mutation("createMany")
|
|
269
|
+
.get(preferLegacyKeys),
|
|
264
270
|
...mutationOptions,
|
|
265
271
|
},
|
|
266
272
|
);
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
UseLoadingOvertimeOptionsProps,
|
|
28
28
|
UseLoadingOvertimeReturnType,
|
|
29
29
|
} from "../useLoadingOvertime";
|
|
30
|
+
import { useKeys } from "@hooks/useKeys";
|
|
30
31
|
|
|
31
32
|
interface UseCustomConfig<TQuery, TPayload> {
|
|
32
33
|
/**
|
|
@@ -129,6 +130,7 @@ export const useCustom = <
|
|
|
129
130
|
const translate = useTranslate();
|
|
130
131
|
const handleNotification = useHandleNotification();
|
|
131
132
|
const getMeta = useMeta();
|
|
133
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
132
134
|
|
|
133
135
|
const preferredMeta = pickNotDeprecated(meta, metaData);
|
|
134
136
|
|
|
@@ -142,13 +144,16 @@ export const useCustom = <
|
|
|
142
144
|
TError,
|
|
143
145
|
CustomResponse<TData>
|
|
144
146
|
>({
|
|
145
|
-
queryKey:
|
|
146
|
-
dataProviderName
|
|
147
|
-
"custom"
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
queryKey: keys()
|
|
148
|
+
.data(dataProviderName)
|
|
149
|
+
.mutation("custom")
|
|
150
|
+
.params({
|
|
151
|
+
method,
|
|
152
|
+
url,
|
|
153
|
+
...config,
|
|
154
|
+
...(preferredMeta || {}),
|
|
155
|
+
})
|
|
156
|
+
.get(preferLegacyKeys),
|
|
152
157
|
queryFn: ({ queryKey, pageParam, signal }) =>
|
|
153
158
|
custom<TQueryFnData>({
|
|
154
159
|
url,
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
UseLoadingOvertimeOptionsProps,
|
|
26
26
|
UseLoadingOvertimeReturnType,
|
|
27
27
|
} from "../useLoadingOvertime";
|
|
28
|
+
import { useKeys } from "@hooks/useKeys";
|
|
28
29
|
|
|
29
30
|
interface UseCustomMutationConfig {
|
|
30
31
|
headers?: {};
|
|
@@ -112,6 +113,7 @@ export const useCustomMutation = <
|
|
|
112
113
|
const dataProvider = useDataProvider();
|
|
113
114
|
const translate = useTranslate();
|
|
114
115
|
const getMeta = useMeta();
|
|
116
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
115
117
|
|
|
116
118
|
const mutation = useMutation<
|
|
117
119
|
CreateResponse<TData>,
|
|
@@ -198,6 +200,10 @@ export const useCustomMutation = <
|
|
|
198
200
|
type: "error",
|
|
199
201
|
});
|
|
200
202
|
},
|
|
203
|
+
mutationKey: keys()
|
|
204
|
+
.data()
|
|
205
|
+
.mutation("customMutation")
|
|
206
|
+
.get(preferLegacyKeys),
|
|
201
207
|
...mutationOptions,
|
|
202
208
|
},
|
|
203
209
|
);
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
MetaQuery,
|
|
35
35
|
} from "../../interfaces";
|
|
36
36
|
import {
|
|
37
|
-
|
|
37
|
+
queryKeysReplacement,
|
|
38
38
|
pickDataProvider,
|
|
39
39
|
pickNotDeprecated,
|
|
40
40
|
useActiveAuthProvider,
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
UseLoadingOvertimeOptionsProps,
|
|
45
45
|
UseLoadingOvertimeReturnType,
|
|
46
46
|
} from "../useLoadingOvertime";
|
|
47
|
+
import { useKeys } from "@hooks/useKeys";
|
|
47
48
|
|
|
48
49
|
export type DeleteParams<TData, TError, TVariables> = {
|
|
49
50
|
/**
|
|
@@ -165,6 +166,7 @@ export const useDelete = <
|
|
|
165
166
|
const {
|
|
166
167
|
options: { textTransformers },
|
|
167
168
|
} = useRefineContext();
|
|
169
|
+
const { keys, preferLegacyKeys } = useKeys();
|
|
168
170
|
|
|
169
171
|
const mutation = useMutation<
|
|
170
172
|
DeleteOneResponse<TData>,
|
|
@@ -265,17 +267,27 @@ export const useDelete = <
|
|
|
265
267
|
|
|
266
268
|
const preferredMeta = pickNotDeprecated(meta, metaData);
|
|
267
269
|
|
|
268
|
-
const queryKey =
|
|
270
|
+
const queryKey = queryKeysReplacement(preferLegacyKeys)(
|
|
269
271
|
identifier,
|
|
270
272
|
pickDataProvider(identifier, dataProviderName, resources),
|
|
271
273
|
preferredMeta,
|
|
272
274
|
);
|
|
273
275
|
|
|
276
|
+
const resourceKeys = keys()
|
|
277
|
+
.data(
|
|
278
|
+
pickDataProvider(
|
|
279
|
+
identifier,
|
|
280
|
+
dataProviderName,
|
|
281
|
+
resources,
|
|
282
|
+
),
|
|
283
|
+
)
|
|
284
|
+
.resource(identifier);
|
|
285
|
+
|
|
274
286
|
const mutationModePropOrContext =
|
|
275
287
|
mutationMode ?? mutationModeContext;
|
|
276
288
|
|
|
277
289
|
await queryClient.cancelQueries(
|
|
278
|
-
|
|
290
|
+
resourceKeys.get(preferLegacyKeys),
|
|
279
291
|
undefined,
|
|
280
292
|
{
|
|
281
293
|
silent: true,
|
|
@@ -283,12 +295,17 @@ export const useDelete = <
|
|
|
283
295
|
);
|
|
284
296
|
|
|
285
297
|
const previousQueries: PreviousQuery<TData>[] =
|
|
286
|
-
queryClient.getQueriesData(
|
|
298
|
+
queryClient.getQueriesData(
|
|
299
|
+
resourceKeys.get(preferLegacyKeys),
|
|
300
|
+
);
|
|
287
301
|
|
|
288
302
|
if (mutationModePropOrContext !== "pessimistic") {
|
|
289
303
|
// Set the previous queries to the new ones:
|
|
290
304
|
queryClient.setQueriesData(
|
|
291
|
-
|
|
305
|
+
resourceKeys
|
|
306
|
+
.action("list")
|
|
307
|
+
.params(preferredMeta ?? {})
|
|
308
|
+
.get(preferLegacyKeys),
|
|
292
309
|
(previous?: GetListResponse<TData> | null) => {
|
|
293
310
|
if (!previous) {
|
|
294
311
|
return null;
|
|
@@ -306,7 +323,7 @@ export const useDelete = <
|
|
|
306
323
|
);
|
|
307
324
|
|
|
308
325
|
queryClient.setQueriesData(
|
|
309
|
-
|
|
326
|
+
resourceKeys.action("many").get(preferLegacyKeys),
|
|
310
327
|
(previous?: GetListResponse<TData> | null) => {
|
|
311
328
|
if (!previous) {
|
|
312
329
|
return null;
|
|
@@ -474,6 +491,7 @@ export const useDelete = <
|
|
|
474
491
|
});
|
|
475
492
|
}
|
|
476
493
|
},
|
|
494
|
+
mutationKey: keys().data().mutation("delete").get(preferLegacyKeys),
|
|
477
495
|
...mutationOptions,
|
|
478
496
|
},
|
|
479
497
|
);
|