@refinedev/core 4.46.0 → 4.46.2
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 +109 -0
- package/dist/definitions/helpers/flatten-object-keys/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/useLogList/index.d.ts.map +1 -1
- package/dist/hooks/auth/useOnError/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/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/router/use-go/index.d.ts +2 -0
- package/dist/hooks/router/use-go/index.d.ts.map +1 -1
- package/dist/hooks/useMeta/index.d.ts +2 -0
- package/dist/hooks/useMeta/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/dist/interfaces/auth.d.ts +6 -6
- package/dist/interfaces/auth.d.ts.map +1 -1
- package/dist/interfaces/metaData/graphqlQueryOptions.d.ts +6 -0
- package/dist/interfaces/metaData/graphqlQueryOptions.d.ts.map +1 -0
- package/dist/interfaces/metaData/metaQuery.d.ts +2 -1
- package/dist/interfaces/metaData/metaQuery.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/definitions/helpers/flatten-object-keys/index.ts +2 -0
- package/src/hooks/accessControl/useCan/index.ts +10 -12
- package/src/hooks/auditLog/useLogList/index.ts +10 -12
- package/src/hooks/auth/useForgotPassword/index.ts +51 -54
- package/src/hooks/auth/useGetIdentity/index.ts +23 -26
- package/src/hooks/auth/useIsAuthenticated/index.ts +20 -20
- package/src/hooks/auth/useLogin/index.ts +33 -35
- package/src/hooks/auth/useLogout/index.ts +32 -34
- package/src/hooks/auth/useOnError/index.ts +29 -33
- package/src/hooks/auth/usePermissions/index.ts +19 -22
- package/src/hooks/auth/useRegister/index.ts +60 -66
- package/src/hooks/auth/useUpdatePassword/index.ts +51 -54
- package/src/hooks/data/useCreate.ts +115 -117
- package/src/hooks/data/useCreateMany.ts +113 -118
- package/src/hooks/data/useDelete.ts +212 -223
- package/src/hooks/data/useDeleteMany.ts +230 -244
- package/src/hooks/data/useInfiniteList.ts +36 -42
- package/src/hooks/data/useList.ts +56 -62
- package/src/hooks/data/useMany.ts +36 -37
- package/src/hooks/data/useOne.ts +54 -55
- package/src/hooks/data/useUpdate.ts +288 -311
- package/src/hooks/data/useUpdateMany.ts +294 -320
- package/src/hooks/menu/useMenu.tsx +1 -1
- package/src/hooks/router/use-go/index.tsx +3 -0
- package/src/interfaces/auth.tsx +6 -6
- package/src/interfaces/metaData/graphqlQueryOptions.ts +6 -0
- package/src/interfaces/metaData/metaQuery.ts +3 -1
|
@@ -75,46 +75,42 @@ export function useOnError({
|
|
|
75
75
|
v3LegacyAuthProviderCompatible: Boolean(v3LegacyAuthProviderCompatible),
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
const mutation = useMutation(
|
|
79
|
-
keys().auth().action("onError").get(preferLegacyKeys),
|
|
80
|
-
onErrorFromContext,
|
|
81
|
-
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
const mutation = useMutation({
|
|
79
|
+
mutationKey: keys().auth().action("onError").get(preferLegacyKeys),
|
|
80
|
+
mutationFn: onErrorFromContext,
|
|
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" });
|
|
86
92
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
go({ to: redirectTo, type: "replace" });
|
|
93
|
-
}
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
meta: {
|
|
98
|
-
...getXRay("useOnError", preferLegacyKeys),
|
|
99
|
-
},
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
meta: {
|
|
97
|
+
...getXRay("useOnError", preferLegacyKeys),
|
|
100
98
|
},
|
|
101
|
-
);
|
|
99
|
+
});
|
|
102
100
|
|
|
103
|
-
const v3LegacyAuthProviderCompatibleMutation = useMutation(
|
|
104
|
-
[
|
|
101
|
+
const v3LegacyAuthProviderCompatibleMutation = useMutation({
|
|
102
|
+
mutationKey: [
|
|
105
103
|
...keys().auth().action("onError").get(preferLegacyKeys),
|
|
106
104
|
"v3LegacyAuthProviderCompatible",
|
|
107
105
|
],
|
|
108
|
-
legacyCheckErrorFromContext,
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
...getXRay("useOnError", preferLegacyKeys),
|
|
115
|
-
},
|
|
106
|
+
mutationFn: legacyCheckErrorFromContext,
|
|
107
|
+
onError: (redirectPath?: string) => {
|
|
108
|
+
legacyLogout({ redirectPath });
|
|
109
|
+
},
|
|
110
|
+
meta: {
|
|
111
|
+
...getXRay("useOnError", preferLegacyKeys),
|
|
116
112
|
},
|
|
117
|
-
);
|
|
113
|
+
});
|
|
118
114
|
|
|
119
115
|
return v3LegacyAuthProviderCompatible
|
|
120
116
|
? v3LegacyAuthProviderCompatibleMutation
|
|
@@ -67,37 +67,34 @@ export function usePermissions<TData = any>({
|
|
|
67
67
|
const { getPermissions } = useAuthBindingsContext();
|
|
68
68
|
const { keys, preferLegacyKeys } = useKeys();
|
|
69
69
|
|
|
70
|
-
const queryResponse = useQuery<TData>(
|
|
71
|
-
keys().auth().action("permissions").get(preferLegacyKeys),
|
|
70
|
+
const queryResponse = useQuery<TData>({
|
|
71
|
+
queryKey: keys().auth().action("permissions").get(preferLegacyKeys),
|
|
72
72
|
// 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.
|
|
73
|
-
|
|
73
|
+
queryFn:
|
|
74
|
+
(getPermissions as (params?: unknown) => Promise<TData>) ??
|
|
74
75
|
(() => Promise.resolve(undefined)),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
...getXRay("usePermissions", preferLegacyKeys),
|
|
81
|
-
},
|
|
76
|
+
enabled: !v3LegacyAuthProviderCompatible && !!getPermissions,
|
|
77
|
+
...(v3LegacyAuthProviderCompatible ? {} : options),
|
|
78
|
+
meta: {
|
|
79
|
+
...(v3LegacyAuthProviderCompatible ? {} : options?.meta),
|
|
80
|
+
...getXRay("usePermissions", preferLegacyKeys),
|
|
82
81
|
},
|
|
83
|
-
);
|
|
82
|
+
});
|
|
84
83
|
|
|
85
|
-
const legacyQueryResponse = useQuery<TData>(
|
|
86
|
-
[
|
|
84
|
+
const legacyQueryResponse = useQuery<TData>({
|
|
85
|
+
queryKey: [
|
|
87
86
|
...keys().auth().action("permissions").get(preferLegacyKeys),
|
|
88
87
|
"v3LegacyAuthProviderCompatible",
|
|
89
88
|
],
|
|
90
89
|
// 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.
|
|
91
|
-
legacyGetPermission ?? (() => Promise.resolve(undefined)),
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
meta: {
|
|
96
|
-
|
|
97
|
-
...getXRay("usePermissions", preferLegacyKeys),
|
|
98
|
-
},
|
|
90
|
+
queryFn: legacyGetPermission ?? (() => Promise.resolve(undefined)),
|
|
91
|
+
enabled: v3LegacyAuthProviderCompatible && !!legacyGetPermission,
|
|
92
|
+
...(v3LegacyAuthProviderCompatible ? options : {}),
|
|
93
|
+
meta: {
|
|
94
|
+
...(v3LegacyAuthProviderCompatible ? options?.meta : {}),
|
|
95
|
+
...getXRay("usePermissions", preferLegacyKeys),
|
|
99
96
|
},
|
|
100
|
-
);
|
|
97
|
+
});
|
|
101
98
|
|
|
102
99
|
return v3LegacyAuthProviderCompatible ? legacyQueryResponse : queryResponse;
|
|
103
100
|
}
|
|
@@ -120,91 +120,85 @@ export function useRegister<TVariables = {}>({
|
|
|
120
120
|
Error | RefineError,
|
|
121
121
|
TVariables,
|
|
122
122
|
unknown
|
|
123
|
-
>(
|
|
124
|
-
keys().auth().action("register").get(preferLegacyKeys),
|
|
125
|
-
registerFromContext,
|
|
126
|
-
{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
123
|
+
>({
|
|
124
|
+
mutationKey: keys().auth().action("register").get(preferLegacyKeys),
|
|
125
|
+
mutationFn: registerFromContext,
|
|
126
|
+
onSuccess: async ({ success, redirectTo, error }) => {
|
|
127
|
+
if (success) {
|
|
128
|
+
close?.("register-error");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (error || !success) {
|
|
132
|
+
open?.(buildNotification(error));
|
|
133
|
+
}
|
|
135
134
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} else {
|
|
140
|
-
go({ to: redirectTo, type: "replace" });
|
|
141
|
-
}
|
|
135
|
+
if (redirectTo) {
|
|
136
|
+
if (routerType === "legacy") {
|
|
137
|
+
replace(redirectTo);
|
|
142
138
|
} else {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
go({ to: redirectTo, type: "replace" });
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
if (routerType === "legacy") {
|
|
143
|
+
replace("/");
|
|
146
144
|
}
|
|
145
|
+
}
|
|
147
146
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
},
|
|
153
|
-
...(v3LegacyAuthProviderCompatible === true ? {} : mutationOptions),
|
|
154
|
-
meta: {
|
|
155
|
-
...(v3LegacyAuthProviderCompatible === true
|
|
156
|
-
? {}
|
|
157
|
-
: mutationOptions?.meta),
|
|
158
|
-
...getXRay("useRegister", preferLegacyKeys),
|
|
159
|
-
},
|
|
147
|
+
await invalidateAuthStore();
|
|
148
|
+
},
|
|
149
|
+
onError: (error: any) => {
|
|
150
|
+
open?.(buildNotification(error));
|
|
160
151
|
},
|
|
161
|
-
|
|
152
|
+
...(v3LegacyAuthProviderCompatible === true ? {} : mutationOptions),
|
|
153
|
+
meta: {
|
|
154
|
+
...(v3LegacyAuthProviderCompatible === true
|
|
155
|
+
? {}
|
|
156
|
+
: mutationOptions?.meta),
|
|
157
|
+
...getXRay("useRegister", preferLegacyKeys),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
162
160
|
|
|
163
161
|
const v3LegacyAuthProviderCompatibleMutation = useMutation<
|
|
164
162
|
TRegisterData,
|
|
165
163
|
Error | RefineError,
|
|
166
164
|
TVariables,
|
|
167
165
|
unknown
|
|
168
|
-
>(
|
|
169
|
-
[
|
|
166
|
+
>({
|
|
167
|
+
mutationKey: [
|
|
170
168
|
...keys().auth().action("register").get(preferLegacyKeys),
|
|
171
169
|
"v3LegacyAuthProviderCompatible",
|
|
172
170
|
],
|
|
173
|
-
legacyRegisterFromContext,
|
|
174
|
-
{
|
|
175
|
-
|
|
176
|
-
if (redirectPathFromAuth
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
171
|
+
mutationFn: legacyRegisterFromContext,
|
|
172
|
+
onSuccess: async (redirectPathFromAuth) => {
|
|
173
|
+
if (redirectPathFromAuth !== false) {
|
|
174
|
+
if (redirectPathFromAuth) {
|
|
175
|
+
if (routerType === "legacy") {
|
|
176
|
+
replace(redirectPathFromAuth);
|
|
177
|
+
} else {
|
|
178
|
+
go({ to: redirectPathFromAuth, type: "replace" });
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
if (routerType === "legacy") {
|
|
182
|
+
replace("/");
|
|
183
183
|
} else {
|
|
184
|
-
|
|
185
|
-
replace("/");
|
|
186
|
-
} else {
|
|
187
|
-
go({ to: "/", type: "replace" });
|
|
188
|
-
}
|
|
184
|
+
go({ to: "/", type: "replace" });
|
|
189
185
|
}
|
|
186
|
+
}
|
|
190
187
|
|
|
191
|
-
|
|
188
|
+
await invalidateAuthStore();
|
|
192
189
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
: {}),
|
|
204
|
-
...getXRay("useRegister", preferLegacyKeys),
|
|
205
|
-
},
|
|
190
|
+
close?.("register-error");
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
onError: (error: any) => {
|
|
194
|
+
open?.(buildNotification(error));
|
|
195
|
+
},
|
|
196
|
+
...(v3LegacyAuthProviderCompatible ? mutationOptions : {}),
|
|
197
|
+
meta: {
|
|
198
|
+
...(v3LegacyAuthProviderCompatible ? mutationOptions?.meta : {}),
|
|
199
|
+
...getXRay("useRegister", preferLegacyKeys),
|
|
206
200
|
},
|
|
207
|
-
);
|
|
201
|
+
});
|
|
208
202
|
|
|
209
203
|
return v3LegacyAuthProviderCompatible
|
|
210
204
|
? v3LegacyAuthProviderCompatibleMutation
|
|
@@ -159,86 +159,83 @@ export function useUpdatePassword<
|
|
|
159
159
|
Error,
|
|
160
160
|
TVariables,
|
|
161
161
|
unknown
|
|
162
|
-
>(
|
|
163
|
-
keys()
|
|
164
|
-
|
|
162
|
+
>({
|
|
163
|
+
mutationKey: keys()
|
|
164
|
+
.auth()
|
|
165
|
+
.action("updatePassword")
|
|
166
|
+
.get(preferLegacyKeys),
|
|
167
|
+
mutationFn: async (variables) => {
|
|
165
168
|
return updatePasswordFromContext?.({
|
|
166
169
|
...params,
|
|
167
170
|
...variables,
|
|
168
171
|
}) as Promise<AuthActionResponse>;
|
|
169
172
|
},
|
|
170
|
-
{
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
173
|
+
onSuccess: ({ success, redirectTo, error }) => {
|
|
174
|
+
if (success) {
|
|
175
|
+
close?.("update-password-error");
|
|
176
|
+
}
|
|
175
177
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
if (error || !success) {
|
|
179
|
+
open?.(buildNotification(error));
|
|
180
|
+
}
|
|
179
181
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
182
|
+
if (redirectTo) {
|
|
183
|
+
if (routerType === "legacy") {
|
|
184
|
+
replace(redirectTo);
|
|
185
|
+
} else {
|
|
186
|
+
go({ to: redirectTo, type: "replace" });
|
|
186
187
|
}
|
|
187
|
-
}
|
|
188
|
-
onError: (error: any) => {
|
|
189
|
-
open?.(buildNotification(error));
|
|
190
|
-
},
|
|
191
|
-
...(v3LegacyAuthProviderCompatible === true ? {} : mutationOptions),
|
|
192
|
-
meta: {
|
|
193
|
-
...(v3LegacyAuthProviderCompatible === true
|
|
194
|
-
? {}
|
|
195
|
-
: mutationOptions?.meta),
|
|
196
|
-
...getXRay("useUpdatePassword", preferLegacyKeys),
|
|
197
|
-
},
|
|
188
|
+
}
|
|
198
189
|
},
|
|
199
|
-
|
|
190
|
+
onError: (error: any) => {
|
|
191
|
+
open?.(buildNotification(error));
|
|
192
|
+
},
|
|
193
|
+
...(v3LegacyAuthProviderCompatible === true ? {} : mutationOptions),
|
|
194
|
+
meta: {
|
|
195
|
+
...(v3LegacyAuthProviderCompatible === true
|
|
196
|
+
? {}
|
|
197
|
+
: mutationOptions?.meta),
|
|
198
|
+
...getXRay("useUpdatePassword", preferLegacyKeys),
|
|
199
|
+
},
|
|
200
|
+
});
|
|
200
201
|
|
|
201
202
|
const v3LegacyAuthProviderCompatibleMutation = useMutation<
|
|
202
203
|
TUpdatePasswordData,
|
|
203
204
|
Error | RefineError,
|
|
204
205
|
TVariables,
|
|
205
206
|
unknown
|
|
206
|
-
>(
|
|
207
|
-
[
|
|
207
|
+
>({
|
|
208
|
+
mutationKey: [
|
|
208
209
|
...keys().auth().action("updatePassword").get(preferLegacyKeys),
|
|
209
210
|
"v3LegacyAuthProviderCompatible",
|
|
210
211
|
],
|
|
211
|
-
async (variables) => {
|
|
212
|
+
mutationFn: async (variables) => {
|
|
212
213
|
return legacyUpdatePasswordFromContext?.({
|
|
213
214
|
...params,
|
|
214
215
|
...variables,
|
|
215
216
|
});
|
|
216
217
|
},
|
|
217
|
-
{
|
|
218
|
-
|
|
219
|
-
if (redirectPathFromAuth
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
go({ to: redirectPathFromAuth, type: "replace" });
|
|
225
|
-
}
|
|
218
|
+
onSuccess: (redirectPathFromAuth) => {
|
|
219
|
+
if (redirectPathFromAuth !== false) {
|
|
220
|
+
if (redirectPathFromAuth) {
|
|
221
|
+
if (routerType === "legacy") {
|
|
222
|
+
replace(redirectPathFromAuth);
|
|
223
|
+
} else {
|
|
224
|
+
go({ to: redirectPathFromAuth, type: "replace" });
|
|
226
225
|
}
|
|
227
226
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
...getXRay("useUpdatePassword", preferLegacyKeys),
|
|
239
|
-
},
|
|
227
|
+
}
|
|
228
|
+
close?.("update-password-error");
|
|
229
|
+
},
|
|
230
|
+
onError: (error: any) => {
|
|
231
|
+
open?.(buildNotification(error));
|
|
232
|
+
},
|
|
233
|
+
...(v3LegacyAuthProviderCompatible ? mutationOptions : {}),
|
|
234
|
+
meta: {
|
|
235
|
+
...(v3LegacyAuthProviderCompatible ? mutationOptions?.meta : {}),
|
|
236
|
+
...getXRay("useUpdatePassword", preferLegacyKeys),
|
|
240
237
|
},
|
|
241
|
-
);
|
|
238
|
+
});
|
|
242
239
|
|
|
243
240
|
return v3LegacyAuthProviderCompatible
|
|
244
241
|
? v3LegacyAuthProviderCompatibleMutation
|