@refinedev/core 4.1.2 → 4.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@refinedev/core",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "description": "refine is a React-based framework for building internal tools, rapidly. It ships with Ant Design System, an enterprise-level UI toolkit.",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -1,13 +1,13 @@
1
- import { useContext } from "react";
2
1
  import {
3
2
  useQuery,
4
- UseQueryResult,
5
3
  UseQueryOptions,
4
+ UseQueryResult,
6
5
  } from "@tanstack/react-query";
6
+ import { useContext } from "react";
7
7
 
8
8
  import { AccessControlContext } from "@contexts/accessControl";
9
- import { CanParams, CanReturnType } from "../../../interfaces";
10
9
  import { sanitizeResource } from "@definitions/helpers/sanitize-resource";
10
+ import { CanParams, CanReturnType } from "../../../interfaces";
11
11
 
12
12
  export type UseCanProps = CanParams & {
13
13
  /**
@@ -40,8 +40,8 @@ export const useCan = ({
40
40
 
41
41
  /* eslint-disable @typescript-eslint/no-unused-vars */
42
42
  const sanitizedResource = sanitizeResource(_resource ?? {});
43
- /* eslint-enable @typescript-eslint/no-unused-vars */
44
43
 
44
+ /* eslint-enable @typescript-eslint/no-unused-vars */
45
45
  const queryResponse = useQuery<CanReturnType>(
46
46
  [
47
47
  "useCan",
@@ -54,7 +54,7 @@ export const useCan = ({
54
54
  ],
55
55
  // Enabled check for `can` is enough to be sure that it's defined in the query function but TS is not smart enough to know that.
56
56
  () =>
57
- can?.({ action, resource, params }) ??
57
+ can?.({ action, resource, params: paramsRest }) ??
58
58
  Promise.resolve({ can: true }),
59
59
  {
60
60
  enabled: typeof can !== "undefined",
@@ -4,22 +4,22 @@ import {
4
4
  UseQueryOptions,
5
5
  } from "@tanstack/react-query";
6
6
 
7
+ import { pickNotDeprecated, useActiveAuthProvider } from "@definitions/helpers";
8
+ import {
9
+ useDataProvider,
10
+ useHandleNotification,
11
+ useOnError,
12
+ useTranslate,
13
+ } from "@hooks";
7
14
  import {
8
- CustomResponse,
9
- CrudSorting,
10
- CrudFilters,
11
15
  BaseRecord,
16
+ CrudFilters,
17
+ CrudSorting,
18
+ CustomResponse,
12
19
  HttpError,
13
20
  MetaQuery,
14
21
  SuccessErrorNotification,
15
22
  } from "../../interfaces";
16
- import {
17
- useTranslate,
18
- useHandleNotification,
19
- useDataProvider,
20
- useOnError,
21
- } from "@hooks";
22
- import { pickNotDeprecated, useActiveAuthProvider } from "@definitions/helpers";
23
23
 
24
24
  interface UseCustomConfig<TQuery, TPayload> {
25
25
  /**
@@ -108,15 +108,15 @@ export const useCustom = <
108
108
  const handleNotification = useHandleNotification();
109
109
 
110
110
  if (custom) {
111
- const queryResponse = useQuery<CustomResponse<TData>, TError>(
112
- [
111
+ const queryResponse = useQuery<CustomResponse<TData>, TError>({
112
+ queryKey: [
113
113
  dataProviderName,
114
114
  "custom",
115
115
  method,
116
116
  url,
117
117
  { ...config, ...(pickNotDeprecated(meta, metaData) || {}) },
118
118
  ],
119
- ({ queryKey, pageParam, signal }) =>
119
+ queryFn: ({ queryKey, pageParam, signal }) =>
120
120
  custom<TData>({
121
121
  url,
122
122
  method,
@@ -130,46 +130,44 @@ export const useCustom = <
130
130
  },
131
131
  },
132
132
  }),
133
- {
134
- ...queryOptions,
135
- onSuccess: (data) => {
136
- queryOptions?.onSuccess?.(data);
133
+ ...queryOptions,
134
+ onSuccess: (data) => {
135
+ queryOptions?.onSuccess?.(data);
137
136
 
138
- const notificationConfig =
139
- typeof successNotification === "function"
140
- ? successNotification(data, {
141
- ...config,
142
- ...(pickNotDeprecated(meta, metaData) || {}),
143
- })
144
- : successNotification;
137
+ const notificationConfig =
138
+ typeof successNotification === "function"
139
+ ? successNotification(data, {
140
+ ...config,
141
+ ...(pickNotDeprecated(meta, metaData) || {}),
142
+ })
143
+ : successNotification;
145
144
 
146
- handleNotification(notificationConfig);
147
- },
148
- onError: (err: TError) => {
149
- checkError(err);
150
- queryOptions?.onError?.(err);
145
+ handleNotification(notificationConfig);
146
+ },
147
+ onError: (err: TError) => {
148
+ checkError(err);
149
+ queryOptions?.onError?.(err);
151
150
 
152
- const notificationConfig =
153
- typeof errorNotification === "function"
154
- ? errorNotification(err, {
155
- ...config,
156
- ...(pickNotDeprecated(meta, metaData) || {}),
157
- })
158
- : errorNotification;
151
+ const notificationConfig =
152
+ typeof errorNotification === "function"
153
+ ? errorNotification(err, {
154
+ ...config,
155
+ ...(pickNotDeprecated(meta, metaData) || {}),
156
+ })
157
+ : errorNotification;
159
158
 
160
- handleNotification(notificationConfig, {
161
- key: `${method}-notification`,
162
- message: translate(
163
- "notifications.error",
164
- { statusCode: err.statusCode },
165
- `Error (status code: ${err.statusCode})`,
166
- ),
167
- description: err.message,
168
- type: "error",
169
- });
170
- },
159
+ handleNotification(notificationConfig, {
160
+ key: `${method}-notification`,
161
+ message: translate(
162
+ "notifications.error",
163
+ { statusCode: err.statusCode },
164
+ `Error (status code: ${err.statusCode})`,
165
+ ),
166
+ description: err.message,
167
+ type: "error",
168
+ });
171
169
  },
172
- );
170
+ });
173
171
  return queryResponse;
174
172
  } else {
175
173
  throw Error("Not implemented custom on data provider.");