@refinedev/core 4.46.1 → 4.46.3-alpha.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 +70 -1
- package/README.md +1 -1
- package/dist/components/authenticated/index.d.ts +3 -3
- package/dist/components/authenticated/index.d.ts.map +1 -1
- package/dist/components/canAccess/index.d.ts +5 -5
- package/dist/components/canAccess/index.d.ts.map +1 -1
- package/dist/components/containers/refine/index.d.ts +3 -3
- package/dist/components/gh-banner/index.d.ts +2 -2
- package/dist/components/gh-banner/index.d.ts.map +1 -1
- package/dist/components/pages/auth/components/forgotPassword/index.d.ts +1 -1
- package/dist/components/pages/auth/components/forgotPassword/index.d.ts.map +1 -1
- package/dist/components/pages/auth/components/login/index.d.ts +1 -1
- package/dist/components/pages/auth/components/login/index.d.ts.map +1 -1
- package/dist/components/pages/auth/components/register/index.d.ts +1 -1
- package/dist/components/pages/auth/components/register/index.d.ts.map +1 -1
- package/dist/components/pages/auth/components/updatePassword/index.d.ts +1 -1
- package/dist/components/pages/auth/components/updatePassword/index.d.ts.map +1 -1
- package/dist/components/pages/auth/index.d.ts +3 -3
- package/dist/components/pages/auth/index.d.ts.map +1 -1
- package/dist/components/routeChangeHandler/index.d.ts +0 -1
- package/dist/components/routeChangeHandler/index.d.ts.map +1 -1
- package/dist/contexts/accessControl/IAccessControlContext.d.ts +3 -3
- package/dist/contexts/accessControl/IAccessControlContext.d.ts.map +1 -1
- package/dist/contexts/auditLog/IAuditLogContext.d.ts +3 -3
- package/dist/contexts/auditLog/IAuditLogContext.d.ts.map +1 -1
- package/dist/contexts/auth/IAuthContext.d.ts +6 -6
- package/dist/contexts/auth/IAuthContext.d.ts.map +1 -1
- package/dist/contexts/data/IDataContext.d.ts +9 -9
- package/dist/contexts/data/IDataContext.d.ts.map +1 -1
- package/dist/contexts/legacy-router/IRouterContext.d.ts +1 -1
- package/dist/contexts/legacy-router/IRouterContext.d.ts.map +1 -1
- package/dist/contexts/live/ILiveContext.d.ts +2 -3
- package/dist/contexts/live/ILiveContext.d.ts.map +1 -1
- package/dist/contexts/notification/INotificationContext.d.ts +1 -1
- package/dist/contexts/notification/INotificationContext.d.ts.map +1 -1
- package/dist/contexts/resource/IResourceContext.d.ts +5 -5
- package/dist/contexts/resource/IResourceContext.d.ts.map +1 -1
- package/dist/contexts/translation/ITranslationContext.d.ts +2 -2
- package/dist/contexts/translation/ITranslationContext.d.ts.map +1 -1
- package/dist/contexts/undoableQueue/IUndoableQueueContext.d.ts +0 -1
- package/dist/contexts/undoableQueue/IUndoableQueueContext.d.ts.map +1 -1
- package/dist/definitions/helpers/flatten-object-keys/index.d.ts.map +1 -1
- package/dist/definitions/helpers/handlePaginationParams/index.d.ts +1 -1
- package/dist/definitions/helpers/handlePaginationParams/index.d.ts.map +1 -1
- package/dist/definitions/helpers/handleRefineOptions/index.d.ts +2 -2
- package/dist/definitions/helpers/handleRefineOptions/index.d.ts.map +1 -1
- package/dist/definitions/helpers/keys/index.d.ts +10 -10
- package/dist/definitions/helpers/keys/index.d.ts.map +1 -1
- package/dist/definitions/helpers/menu/create-tree.d.ts +2 -2
- package/dist/definitions/helpers/menu/create-tree.d.ts.map +1 -1
- package/dist/definitions/helpers/redirectPage/index.d.ts +1 -1
- package/dist/definitions/helpers/redirectPage/index.d.ts.map +1 -1
- package/dist/definitions/helpers/router/get-action-routes-from-resource.d.ts +1 -1
- package/dist/definitions/helpers/router/get-action-routes-from-resource.d.ts.map +1 -1
- package/dist/definitions/helpers/sequentialPromises/index.d.ts +2 -2
- package/dist/definitions/helpers/sequentialPromises/index.d.ts.map +1 -1
- package/dist/esm/index.js +7 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/accessControl/useCan/index.d.ts +1 -1
- package/dist/hooks/accessControl/useCan/index.d.ts.map +1 -1
- package/dist/hooks/auditLog/useLog/index.d.ts +3 -3
- package/dist/hooks/auditLog/useLog/index.d.ts.map +1 -1
- package/dist/hooks/auditLog/useLogList/index.d.ts +1 -1
- package/dist/hooks/auditLog/useLogList/index.d.ts.map +1 -1
- package/dist/hooks/auth/useForgotPassword/index.d.ts +6 -6
- package/dist/hooks/auth/useForgotPassword/index.d.ts.map +1 -1
- package/dist/hooks/auth/useGetIdentity/index.d.ts +6 -6
- package/dist/hooks/auth/useGetIdentity/index.d.ts.map +1 -1
- package/dist/hooks/auth/useIsAuthenticated/index.d.ts +6 -6
- package/dist/hooks/auth/useIsAuthenticated/index.d.ts.map +1 -1
- package/dist/hooks/auth/useLogin/index.d.ts +6 -6
- package/dist/hooks/auth/useLogin/index.d.ts.map +1 -1
- package/dist/hooks/auth/useLogout/index.d.ts +7 -7
- package/dist/hooks/auth/useLogout/index.d.ts.map +1 -1
- package/dist/hooks/auth/useOnError/index.d.ts +6 -6
- package/dist/hooks/auth/useOnError/index.d.ts.map +1 -1
- package/dist/hooks/auth/usePermissions/index.d.ts +6 -6
- package/dist/hooks/auth/usePermissions/index.d.ts.map +1 -1
- package/dist/hooks/auth/useRegister/index.d.ts +6 -6
- package/dist/hooks/auth/useRegister/index.d.ts.map +1 -1
- package/dist/hooks/auth/useUpdatePassword/index.d.ts +6 -6
- package/dist/hooks/auth/useUpdatePassword/index.d.ts.map +1 -1
- package/dist/hooks/breadcrumb/index.d.ts +3 -3
- package/dist/hooks/breadcrumb/index.d.ts.map +1 -1
- package/dist/hooks/data/useCreate.d.ts +3 -3
- package/dist/hooks/data/useCreate.d.ts.map +1 -1
- package/dist/hooks/data/useCreateMany.d.ts +3 -3
- package/dist/hooks/data/useCreateMany.d.ts.map +1 -1
- package/dist/hooks/data/useCustom.d.ts +1 -1
- package/dist/hooks/data/useCustom.d.ts.map +1 -1
- package/dist/hooks/data/useCustomMutation.d.ts +3 -3
- package/dist/hooks/data/useCustomMutation.d.ts.map +1 -1
- package/dist/hooks/data/useDelete.d.ts +3 -3
- package/dist/hooks/data/useDelete.d.ts.map +1 -1
- package/dist/hooks/data/useDeleteMany.d.ts +3 -3
- 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 +2 -2
- 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 +3 -3
- package/dist/hooks/data/useUpdate.d.ts.map +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts +3 -3
- package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
- package/dist/hooks/export/csvDownload.interface.d.ts +4 -4
- package/dist/hooks/export/csvDownload.interface.d.ts.map +1 -1
- package/dist/hooks/export/index.d.ts +2 -2
- package/dist/hooks/export/index.d.ts.map +1 -1
- package/dist/hooks/form/useForm.d.ts +4 -4
- package/dist/hooks/form/useForm.d.ts.map +1 -1
- package/dist/hooks/import/index.d.ts +9 -10
- package/dist/hooks/import/index.d.ts.map +1 -1
- package/dist/hooks/invalidate/index.d.ts +1 -1
- package/dist/hooks/invalidate/index.d.ts.map +1 -1
- package/dist/hooks/legacy-router/useRouterContext.d.ts +0 -1
- package/dist/hooks/legacy-router/useRouterContext.d.ts.map +1 -1
- package/dist/hooks/live/useResourceSubscription/index.d.ts +2 -2
- package/dist/hooks/live/useResourceSubscription/index.d.ts.map +1 -1
- package/dist/hooks/live/useSubscription/index.d.ts +1 -1
- package/dist/hooks/live/useSubscription/index.d.ts.map +1 -1
- package/dist/hooks/menu/useMenu.d.ts +3 -3
- package/dist/hooks/menu/useMenu.d.ts.map +1 -1
- package/dist/hooks/modal/useModal/index.d.ts +2 -2
- package/dist/hooks/modal/useModal/index.d.ts.map +1 -1
- package/dist/hooks/navigation/index.d.ts +1 -1
- package/dist/hooks/navigation/index.d.ts.map +1 -1
- package/dist/hooks/notification/useCancelNotification/index.d.ts +1 -2
- package/dist/hooks/notification/useCancelNotification/index.d.ts.map +1 -1
- package/dist/hooks/redirection/index.d.ts +1 -1
- package/dist/hooks/redirection/index.d.ts.map +1 -1
- package/dist/hooks/refine/useMutationMode.d.ts +1 -1
- package/dist/hooks/refine/useMutationMode.d.ts.map +1 -1
- package/dist/hooks/refine/useRefineContext.d.ts +0 -1
- package/dist/hooks/refine/useRefineContext.d.ts.map +1 -1
- package/dist/hooks/refine/useSyncWithLocation.d.ts +1 -1
- package/dist/hooks/refine/useSyncWithLocation.d.ts.map +1 -1
- package/dist/hooks/refine/useTitle.d.ts +0 -1
- package/dist/hooks/refine/useTitle.d.ts.map +1 -1
- package/dist/hooks/refine/useWarnAboutChange/index.d.ts +1 -1
- package/dist/hooks/refine/useWarnAboutChange/index.d.ts.map +1 -1
- package/dist/hooks/resource/useResource/index.d.ts +5 -5
- package/dist/hooks/resource/useResource/index.d.ts.map +1 -1
- package/dist/hooks/resource/useResourceWithRoute/index.d.ts +1 -1
- package/dist/hooks/resource/useResourceWithRoute/index.d.ts.map +1 -1
- package/dist/hooks/router/use-get-to-path/index.d.ts +2 -2
- package/dist/hooks/router/use-get-to-path/index.d.ts.map +1 -1
- package/dist/hooks/router/use-go/index.d.ts +6 -4
- package/dist/hooks/router/use-go/index.d.ts.map +1 -1
- package/dist/hooks/router/use-parse/index.d.ts +1 -1
- package/dist/hooks/router/use-parse/index.d.ts.map +1 -1
- package/dist/hooks/router/use-to-path/index.d.ts +1 -1
- package/dist/hooks/router/use-to-path/index.d.ts.map +1 -1
- package/dist/hooks/show/useShow.d.ts +2 -2
- package/dist/hooks/show/useShow.d.ts.map +1 -1
- package/dist/hooks/translate/useGetLocale.d.ts +1 -1
- package/dist/hooks/translate/useGetLocale.d.ts.map +1 -1
- package/dist/hooks/useLoadingOvertime/index.d.ts +6 -6
- package/dist/hooks/useLoadingOvertime/index.d.ts.map +1 -1
- package/dist/hooks/useSelect/index.d.ts +2 -2
- package/dist/hooks/useSelect/index.d.ts.map +1 -1
- package/dist/hooks/useTable/index.d.ts +5 -5
- package/dist/hooks/useTable/index.d.ts.map +1 -1
- package/dist/iife/index.js +7 -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 +7 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/actions.d.ts +6 -6
- package/dist/interfaces/actions.d.ts.map +1 -1
- package/dist/interfaces/auditLog/logData.d.ts +1 -1
- package/dist/interfaces/auditLog/logData.d.ts.map +1 -1
- package/dist/interfaces/auth.d.ts +12 -12
- package/dist/interfaces/auth.d.ts.map +1 -1
- package/dist/interfaces/autoSave.d.ts +4 -4
- package/dist/interfaces/autoSave.d.ts.map +1 -1
- package/dist/interfaces/bindings/access-control.d.ts +3 -3
- package/dist/interfaces/bindings/access-control.d.ts.map +1 -1
- package/dist/interfaces/bindings/auth.d.ts +8 -7
- package/dist/interfaces/bindings/auth.d.ts.map +1 -1
- package/dist/interfaces/bindings/data.d.ts +3 -3
- package/dist/interfaces/bindings/data.d.ts.map +1 -1
- package/dist/interfaces/bindings/i18n.d.ts +4 -4
- package/dist/interfaces/bindings/i18n.d.ts.map +1 -1
- package/dist/interfaces/bindings/index.d.ts +1 -1
- package/dist/interfaces/bindings/index.d.ts.map +1 -1
- package/dist/interfaces/bindings/live.d.ts +5 -5
- package/dist/interfaces/bindings/live.d.ts.map +1 -1
- package/dist/interfaces/bindings/notifications.d.ts +1 -1
- package/dist/interfaces/bindings/notifications.d.ts.map +1 -1
- package/dist/interfaces/bindings/resource.d.ts +7 -7
- package/dist/interfaces/bindings/resource.d.ts.map +1 -1
- package/dist/interfaces/bindings/router.d.ts +7 -8
- package/dist/interfaces/bindings/router.d.ts.map +1 -1
- package/dist/interfaces/customComponents.d.ts +3 -3
- package/dist/interfaces/customComponents.d.ts.map +1 -1
- package/dist/interfaces/errors/RefineError.d.ts +1 -1
- package/dist/interfaces/errors/RefineError.d.ts.map +1 -1
- package/dist/interfaces/form-url-params.d.ts +1 -1
- package/dist/interfaces/form-url-params.d.ts.map +1 -1
- package/dist/interfaces/index.d.ts +5 -5
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/live/LiveEvent.d.ts +1 -1
- package/dist/interfaces/live/LiveEvent.d.ts.map +1 -1
- package/dist/interfaces/live/LiveModeProps.d.ts +2 -2
- package/dist/interfaces/live/LiveModeProps.d.ts.map +1 -1
- package/dist/interfaces/metaData/fields.d.ts +1 -1
- package/dist/interfaces/metaData/fields.d.ts.map +1 -1
- package/dist/interfaces/metaData/graphqlQueryOptions.d.ts +48 -1
- package/dist/interfaces/metaData/graphqlQueryOptions.d.ts.map +1 -1
- package/dist/interfaces/metaData/metaDataQuery.d.ts +1 -1
- package/dist/interfaces/metaData/metaDataQuery.d.ts.map +1 -1
- package/dist/interfaces/metaData/metaQuery.d.ts +1 -1
- package/dist/interfaces/metaData/metaQuery.d.ts.map +1 -1
- package/dist/interfaces/metaData/nestedField.d.ts +1 -1
- package/dist/interfaces/metaData/nestedField.d.ts.map +1 -1
- package/dist/interfaces/metaData/variableOptions.d.ts +1 -1
- package/dist/interfaces/metaData/variableOptions.d.ts.map +1 -1
- package/dist/interfaces/mutationMode.d.ts +6 -6
- package/dist/interfaces/mutationMode.d.ts.map +1 -1
- package/dist/interfaces/optimistic-update-map.d.ts +2 -2
- package/dist/interfaces/optimistic-update-map.d.ts.map +1 -1
- package/dist/interfaces/prettify.d.ts +1 -1
- package/dist/interfaces/prettify.d.ts.map +1 -1
- package/dist/interfaces/resourceErrorRouterParams.d.ts +1 -1
- package/dist/interfaces/resourceErrorRouterParams.d.ts.map +1 -1
- package/dist/interfaces/resourceRouterParams.d.ts +1 -1
- package/dist/interfaces/resourceRouterParams.d.ts.map +1 -1
- package/dist/interfaces/successErrorNotification.d.ts +1 -1
- package/dist/interfaces/successErrorNotification.d.ts.map +1 -1
- package/dist/interfaces/telemetry.d.ts +1 -1
- package/dist/interfaces/telemetry.d.ts.map +1 -1
- package/dist/interfaces/textTransformers.d.ts +1 -1
- package/dist/interfaces/textTransformers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/containers/refine/index.tsx +3 -3
- package/src/contexts/auth/IAuthContext.ts +1 -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 -227
- package/src/hooks/data/useDeleteMany.ts +230 -248
- 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 -315
- package/src/hooks/data/useUpdateMany.ts +294 -325
- package/src/hooks/menu/useMenu.tsx +1 -1
- package/src/hooks/router/use-go/index.tsx +3 -0
- package/src/index.tsx +1 -0
- package/src/interfaces/auth.tsx +6 -6
- package/src/interfaces/bindings/auth.ts +3 -1
- package/src/interfaces/bindings/index.ts +1 -0
- package/src/interfaces/metaData/graphqlQueryOptions.ts +47 -0
|
@@ -56,20 +56,22 @@ export function useIsAuthenticated({
|
|
|
56
56
|
const { check } = useAuthBindingsContext();
|
|
57
57
|
const { keys, preferLegacyKeys } = useKeys();
|
|
58
58
|
|
|
59
|
-
const queryResponse = useQuery(
|
|
60
|
-
keys()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
const queryResponse = useQuery({
|
|
60
|
+
queryKey: keys()
|
|
61
|
+
.auth()
|
|
62
|
+
.action("check")
|
|
63
|
+
.params(params)
|
|
64
|
+
.get(preferLegacyKeys),
|
|
65
|
+
queryFn: async () => (await check?.(params)) ?? {},
|
|
66
|
+
retry: false,
|
|
67
|
+
enabled: !v3LegacyAuthProviderCompatible,
|
|
68
|
+
meta: {
|
|
69
|
+
...getXRay("useIsAuthenticated", preferLegacyKeys),
|
|
68
70
|
},
|
|
69
|
-
);
|
|
71
|
+
});
|
|
70
72
|
|
|
71
|
-
const legacyQueryResponse = useQuery(
|
|
72
|
-
[
|
|
73
|
+
const legacyQueryResponse = useQuery({
|
|
74
|
+
queryKey: [
|
|
73
75
|
...keys()
|
|
74
76
|
.auth()
|
|
75
77
|
.action("check")
|
|
@@ -77,15 +79,13 @@ export function useIsAuthenticated({
|
|
|
77
79
|
.get(preferLegacyKeys),
|
|
78
80
|
"v3LegacyAuthProviderCompatible",
|
|
79
81
|
],
|
|
80
|
-
async () => (await checkAuth?.(params)) ?? {},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
...getXRay("useIsAuthenticated", preferLegacyKeys),
|
|
86
|
-
},
|
|
82
|
+
queryFn: async () => (await checkAuth?.(params)) ?? {},
|
|
83
|
+
retry: false,
|
|
84
|
+
enabled: v3LegacyAuthProviderCompatible,
|
|
85
|
+
meta: {
|
|
86
|
+
...getXRay("useIsAuthenticated", preferLegacyKeys),
|
|
87
87
|
},
|
|
88
|
-
);
|
|
88
|
+
});
|
|
89
89
|
|
|
90
90
|
return v3LegacyAuthProviderCompatible ? legacyQueryResponse : queryResponse;
|
|
91
91
|
}
|
|
@@ -145,7 +145,9 @@ export function useLogin<TVariables = {}>({
|
|
|
145
145
|
Error | RefineError,
|
|
146
146
|
TVariables,
|
|
147
147
|
unknown
|
|
148
|
-
>(
|
|
148
|
+
>({
|
|
149
|
+
mutationKey: keys().auth().action("login").get(preferLegacyKeys),
|
|
150
|
+
mutationFn: loginFromContext,
|
|
149
151
|
onSuccess: async ({ success, redirectTo, error }) => {
|
|
150
152
|
if (success) {
|
|
151
153
|
close?.("login-error");
|
|
@@ -192,50 +194,46 @@ export function useLogin<TVariables = {}>({
|
|
|
192
194
|
Error | RefineError,
|
|
193
195
|
TVariables,
|
|
194
196
|
unknown
|
|
195
|
-
>(
|
|
196
|
-
[
|
|
197
|
+
>({
|
|
198
|
+
mutationKey: [
|
|
197
199
|
...keys().auth().action("login").get(preferLegacyKeys),
|
|
198
200
|
"v3LegacyAuthProviderCompatible",
|
|
199
201
|
],
|
|
200
|
-
legacyLoginFromContext,
|
|
201
|
-
{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
202
|
+
mutationFn: legacyLoginFromContext,
|
|
203
|
+
onSuccess: async (redirectPathFromAuth) => {
|
|
204
|
+
if (to) {
|
|
205
|
+
replace(to as string);
|
|
206
|
+
}
|
|
206
207
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
} else {
|
|
212
|
-
go({ to: redirectPathFromAuth, type: "replace" });
|
|
213
|
-
}
|
|
208
|
+
if (redirectPathFromAuth !== false && !to) {
|
|
209
|
+
if (typeof redirectPathFromAuth === "string") {
|
|
210
|
+
if (routerType === "legacy") {
|
|
211
|
+
replace(redirectPathFromAuth);
|
|
214
212
|
} else {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
213
|
+
go({ to: redirectPathFromAuth, type: "replace" });
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
if (routerType === "legacy") {
|
|
217
|
+
replace("/");
|
|
218
|
+
} else {
|
|
219
|
+
go({ to: "/", type: "replace" });
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
+
}
|
|
222
223
|
|
|
223
|
-
|
|
224
|
+
await invalidateAuthStore();
|
|
224
225
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
},
|
|
230
|
-
...(v3LegacyAuthProviderCompatible ? mutationOptions : {}),
|
|
231
|
-
meta: {
|
|
232
|
-
...(v3LegacyAuthProviderCompatible
|
|
233
|
-
? mutationOptions?.meta
|
|
234
|
-
: {}),
|
|
235
|
-
...getXRay("useLogin", preferLegacyKeys),
|
|
236
|
-
},
|
|
226
|
+
close?.("login-error");
|
|
227
|
+
},
|
|
228
|
+
onError: (error: any) => {
|
|
229
|
+
open?.(buildNotification(error));
|
|
237
230
|
},
|
|
238
|
-
|
|
231
|
+
...(v3LegacyAuthProviderCompatible ? mutationOptions : {}),
|
|
232
|
+
meta: {
|
|
233
|
+
...(v3LegacyAuthProviderCompatible ? mutationOptions?.meta : {}),
|
|
234
|
+
...getXRay("useLogin", preferLegacyKeys),
|
|
235
|
+
},
|
|
236
|
+
});
|
|
239
237
|
|
|
240
238
|
return v3LegacyAuthProviderCompatible
|
|
241
239
|
? v3LegacyAuthProviderCompatibleMutation
|
|
@@ -118,7 +118,9 @@ export function useLogout<TVariables = {}>({
|
|
|
118
118
|
Error | RefineError,
|
|
119
119
|
(TVariables & Variables) | void,
|
|
120
120
|
unknown
|
|
121
|
-
>(
|
|
121
|
+
>({
|
|
122
|
+
mutationKey: keys().auth().action("logout").get(preferLegacyKeys),
|
|
123
|
+
mutationFn: logoutFromContext,
|
|
122
124
|
onSuccess: async (data, variables) => {
|
|
123
125
|
const { success, error, redirectTo } = data;
|
|
124
126
|
const { redirectPath } = variables ?? {};
|
|
@@ -162,49 +164,45 @@ export function useLogout<TVariables = {}>({
|
|
|
162
164
|
Error | RefineError,
|
|
163
165
|
(TVariables & Variables) | void,
|
|
164
166
|
unknown
|
|
165
|
-
>(
|
|
166
|
-
[
|
|
167
|
+
>({
|
|
168
|
+
mutationKey: [
|
|
167
169
|
...keys().auth().action("logout").get(preferLegacyKeys),
|
|
168
170
|
"v3LegacyAuthProviderCompatible",
|
|
169
171
|
],
|
|
170
|
-
legacyLogoutFromContext,
|
|
171
|
-
{
|
|
172
|
-
|
|
173
|
-
const redirectPath = variables?.redirectPath ?? data;
|
|
174
|
-
|
|
175
|
-
if (redirectPath === false) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
172
|
+
mutationFn: legacyLogoutFromContext,
|
|
173
|
+
onSuccess: async (data, variables) => {
|
|
174
|
+
const redirectPath = variables?.redirectPath ?? data;
|
|
178
175
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
} else {
|
|
183
|
-
go({ to: redirectPath });
|
|
184
|
-
}
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
176
|
+
if (redirectPath === false) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
187
179
|
|
|
180
|
+
if (redirectPath) {
|
|
188
181
|
if (routerType === "legacy") {
|
|
189
|
-
push(
|
|
182
|
+
push(redirectPath);
|
|
190
183
|
} else {
|
|
191
|
-
go({ to:
|
|
184
|
+
go({ to: redirectPath });
|
|
192
185
|
}
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
193
188
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
...getXRay("useLogout", preferLegacyKeys),
|
|
205
|
-
},
|
|
189
|
+
if (routerType === "legacy") {
|
|
190
|
+
push("/login");
|
|
191
|
+
} else {
|
|
192
|
+
go({ to: "/login" });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
await invalidateAuthStore();
|
|
196
|
+
},
|
|
197
|
+
onError: (error: any) => {
|
|
198
|
+
open?.(buildNotification(error));
|
|
206
199
|
},
|
|
207
|
-
|
|
200
|
+
...(v3LegacyAuthProviderCompatible ? mutationOptions : {}),
|
|
201
|
+
meta: {
|
|
202
|
+
...(v3LegacyAuthProviderCompatible ? mutationOptions?.meta : {}),
|
|
203
|
+
...getXRay("useLogout", preferLegacyKeys),
|
|
204
|
+
},
|
|
205
|
+
});
|
|
208
206
|
|
|
209
207
|
return v3LegacyAuthProviderCompatible
|
|
210
208
|
? v3LegacyAuthProviderCompatibleMutation
|
|
@@ -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
|