@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.
Files changed (59) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/dist/definitions/helpers/flatten-object-keys/index.d.ts.map +1 -1
  3. package/dist/esm/index.js +6 -6
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/hooks/accessControl/useCan/index.d.ts.map +1 -1
  6. package/dist/hooks/auditLog/useLogList/index.d.ts.map +1 -1
  7. package/dist/hooks/auth/useOnError/index.d.ts.map +1 -1
  8. package/dist/hooks/data/useCreate.d.ts.map +1 -1
  9. package/dist/hooks/data/useCreateMany.d.ts.map +1 -1
  10. package/dist/hooks/data/useDelete.d.ts.map +1 -1
  11. package/dist/hooks/data/useDeleteMany.d.ts.map +1 -1
  12. package/dist/hooks/data/useInfiniteList.d.ts.map +1 -1
  13. package/dist/hooks/data/useList.d.ts.map +1 -1
  14. package/dist/hooks/data/useMany.d.ts.map +1 -1
  15. package/dist/hooks/data/useOne.d.ts.map +1 -1
  16. package/dist/hooks/data/useUpdate.d.ts.map +1 -1
  17. package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
  18. package/dist/hooks/router/use-go/index.d.ts +2 -0
  19. package/dist/hooks/router/use-go/index.d.ts.map +1 -1
  20. package/dist/hooks/useMeta/index.d.ts +2 -0
  21. package/dist/hooks/useMeta/index.d.ts.map +1 -1
  22. package/dist/iife/index.js +6 -6
  23. package/dist/iife/index.js.map +1 -1
  24. package/dist/index.js +6 -6
  25. package/dist/index.js.map +1 -1
  26. package/dist/interfaces/auth.d.ts +6 -6
  27. package/dist/interfaces/auth.d.ts.map +1 -1
  28. package/dist/interfaces/metaData/graphqlQueryOptions.d.ts +6 -0
  29. package/dist/interfaces/metaData/graphqlQueryOptions.d.ts.map +1 -0
  30. package/dist/interfaces/metaData/metaQuery.d.ts +2 -1
  31. package/dist/interfaces/metaData/metaQuery.d.ts.map +1 -1
  32. package/package.json +2 -1
  33. package/src/definitions/helpers/flatten-object-keys/index.ts +2 -0
  34. package/src/hooks/accessControl/useCan/index.ts +10 -12
  35. package/src/hooks/auditLog/useLogList/index.ts +10 -12
  36. package/src/hooks/auth/useForgotPassword/index.ts +51 -54
  37. package/src/hooks/auth/useGetIdentity/index.ts +23 -26
  38. package/src/hooks/auth/useIsAuthenticated/index.ts +20 -20
  39. package/src/hooks/auth/useLogin/index.ts +33 -35
  40. package/src/hooks/auth/useLogout/index.ts +32 -34
  41. package/src/hooks/auth/useOnError/index.ts +29 -33
  42. package/src/hooks/auth/usePermissions/index.ts +19 -22
  43. package/src/hooks/auth/useRegister/index.ts +60 -66
  44. package/src/hooks/auth/useUpdatePassword/index.ts +51 -54
  45. package/src/hooks/data/useCreate.ts +115 -117
  46. package/src/hooks/data/useCreateMany.ts +113 -118
  47. package/src/hooks/data/useDelete.ts +212 -223
  48. package/src/hooks/data/useDeleteMany.ts +230 -244
  49. package/src/hooks/data/useInfiniteList.ts +36 -42
  50. package/src/hooks/data/useList.ts +56 -62
  51. package/src/hooks/data/useMany.ts +36 -37
  52. package/src/hooks/data/useOne.ts +54 -55
  53. package/src/hooks/data/useUpdate.ts +288 -311
  54. package/src/hooks/data/useUpdateMany.ts +294 -320
  55. package/src/hooks/menu/useMenu.tsx +1 -1
  56. package/src/hooks/router/use-go/index.tsx +3 -0
  57. package/src/interfaces/auth.tsx +6 -6
  58. package/src/interfaces/metaData/graphqlQueryOptions.ts +6 -0
  59. package/src/interfaces/metaData/metaQuery.ts +3 -1
@@ -227,8 +227,8 @@ export const useList = <
227
227
  GetListResponse<TQueryFnData>,
228
228
  TError,
229
229
  GetListResponse<TData>
230
- >(
231
- keys()
230
+ >({
231
+ queryKey: keys()
232
232
  .data(pickedDataProvider)
233
233
  .resource(identifier ?? "")
234
234
  .action("list")
@@ -247,7 +247,7 @@ export const useList = <
247
247
  }),
248
248
  })
249
249
  .get(preferLegacyKeys),
250
- ({ queryKey, pageParam, signal }) => {
250
+ queryFn: ({ queryKey, pageParam, signal }) => {
251
251
  return getList<TQueryFnData>({
252
252
  resource: resource?.name ?? "",
253
253
  pagination: prefferedPagination,
@@ -273,74 +273,68 @@ export const useList = <
273
273
  },
274
274
  });
275
275
  },
276
- {
277
- ...queryOptions,
278
- enabled:
279
- typeof queryOptions?.enabled !== "undefined"
280
- ? queryOptions?.enabled
281
- : !!resource?.name,
282
- select: (rawData) => {
283
- let data = rawData;
276
+ ...queryOptions,
277
+ enabled:
278
+ typeof queryOptions?.enabled !== "undefined"
279
+ ? queryOptions?.enabled
280
+ : !!resource?.name,
281
+ select: (rawData) => {
282
+ let data = rawData;
284
283
 
285
- const { current, mode, pageSize } = prefferedPagination;
284
+ const { current, mode, pageSize } = prefferedPagination;
286
285
 
287
- if (mode === "client") {
288
- data = {
289
- ...data,
290
- data: data.data.slice(
291
- (current - 1) * pageSize,
292
- current * pageSize,
293
- ),
294
- total: data.total,
295
- };
296
- }
286
+ if (mode === "client") {
287
+ data = {
288
+ ...data,
289
+ data: data.data.slice(
290
+ (current - 1) * pageSize,
291
+ current * pageSize,
292
+ ),
293
+ total: data.total,
294
+ };
295
+ }
297
296
 
298
- if (queryOptions?.select) {
299
- return queryOptions?.select?.(data);
300
- }
297
+ if (queryOptions?.select) {
298
+ return queryOptions?.select?.(data);
299
+ }
301
300
 
302
- return data as unknown as GetListResponse<TData>;
303
- },
304
- onSuccess: (data) => {
305
- queryOptions?.onSuccess?.(data);
301
+ return data as unknown as GetListResponse<TData>;
302
+ },
303
+ onSuccess: (data) => {
304
+ queryOptions?.onSuccess?.(data);
306
305
 
307
- const notificationConfig =
308
- typeof successNotification === "function"
309
- ? successNotification(
310
- data,
311
- notificationValues,
312
- identifier,
313
- )
314
- : successNotification;
306
+ const notificationConfig =
307
+ typeof successNotification === "function"
308
+ ? successNotification(data, notificationValues, identifier)
309
+ : successNotification;
315
310
 
316
- handleNotification(notificationConfig);
317
- },
318
- onError: (err: TError) => {
319
- checkError(err);
320
- queryOptions?.onError?.(err);
311
+ handleNotification(notificationConfig);
312
+ },
313
+ onError: (err: TError) => {
314
+ checkError(err);
315
+ queryOptions?.onError?.(err);
321
316
 
322
- const notificationConfig =
323
- typeof errorNotification === "function"
324
- ? errorNotification(err, notificationValues, identifier)
325
- : errorNotification;
317
+ const notificationConfig =
318
+ typeof errorNotification === "function"
319
+ ? errorNotification(err, notificationValues, identifier)
320
+ : errorNotification;
326
321
 
327
- handleNotification(notificationConfig, {
328
- key: `${identifier}-useList-notification`,
329
- message: translate(
330
- "notifications.error",
331
- { statusCode: err.statusCode },
332
- `Error (status code: ${err.statusCode})`,
333
- ),
334
- description: err.message,
335
- type: "error",
336
- });
337
- },
338
- meta: {
339
- ...queryOptions?.meta,
340
- ...getXRay("useList", preferLegacyKeys),
341
- },
322
+ handleNotification(notificationConfig, {
323
+ key: `${identifier}-useList-notification`,
324
+ message: translate(
325
+ "notifications.error",
326
+ { statusCode: err.statusCode },
327
+ `Error (status code: ${err.statusCode})`,
328
+ ),
329
+ description: err.message,
330
+ type: "error",
331
+ });
342
332
  },
343
- );
333
+ meta: {
334
+ ...queryOptions?.meta,
335
+ ...getXRay("useList", preferLegacyKeys),
336
+ },
337
+ });
344
338
 
345
339
  const { elapsedTime } = useLoadingOvertime({
346
340
  isLoading: queryResponse.isFetching,
@@ -103,7 +103,8 @@ export const useMany = <
103
103
  dataProviderName,
104
104
  overtimeOptions,
105
105
  }: UseManyProps<TQueryFnData, TError, TData>): QueryObserverResult<
106
- GetManyResponse<TData>, TError
106
+ GetManyResponse<TData>,
107
+ TError
107
108
  > &
108
109
  UseLoadingOvertimeReturnType => {
109
110
  const { resources, resource, identifier } = useResource(resourceFromProp);
@@ -155,8 +156,8 @@ export const useMany = <
155
156
  GetManyResponse<TQueryFnData>,
156
157
  TError,
157
158
  GetManyResponse<TData>
158
- >(
159
- keys()
159
+ >({
160
+ queryKey: keys()
160
161
  .data(pickedDataProvider)
161
162
  .resource(identifier)
162
163
  .action("many")
@@ -165,7 +166,7 @@ export const useMany = <
165
166
  ...(preferredMeta || {}),
166
167
  })
167
168
  .get(preferLegacyKeys),
168
- ({ queryKey, pageParam, signal }) => {
169
+ queryFn: ({ queryKey, pageParam, signal }) => {
169
170
  if (getMany) {
170
171
  return getMany({
171
172
  resource: resource?.name,
@@ -214,44 +215,42 @@ export const useMany = <
214
215
  );
215
216
  }
216
217
  },
217
- {
218
- ...queryOptions,
219
- onSuccess: (data) => {
220
- queryOptions?.onSuccess?.(data);
218
+ ...queryOptions,
219
+ onSuccess: (data) => {
220
+ queryOptions?.onSuccess?.(data);
221
221
 
222
- const notificationConfig =
223
- typeof successNotification === "function"
224
- ? successNotification(data, ids, identifier)
225
- : successNotification;
222
+ const notificationConfig =
223
+ typeof successNotification === "function"
224
+ ? successNotification(data, ids, identifier)
225
+ : successNotification;
226
226
 
227
- handleNotification(notificationConfig);
228
- },
229
- onError: (err: TError) => {
230
- checkError(err);
231
- queryOptions?.onError?.(err);
227
+ handleNotification(notificationConfig);
228
+ },
229
+ onError: (err: TError) => {
230
+ checkError(err);
231
+ queryOptions?.onError?.(err);
232
232
 
233
- const notificationConfig =
234
- typeof errorNotification === "function"
235
- ? errorNotification(err, ids, identifier)
236
- : errorNotification;
233
+ const notificationConfig =
234
+ typeof errorNotification === "function"
235
+ ? errorNotification(err, ids, identifier)
236
+ : errorNotification;
237
237
 
238
- handleNotification(notificationConfig, {
239
- key: `${ids[0]}-${identifier}-getMany-notification`,
240
- message: translate(
241
- "notifications.error",
242
- { statusCode: err.statusCode },
243
- `Error (status code: ${err.statusCode})`,
244
- ),
245
- description: err.message,
246
- type: "error",
247
- });
248
- },
249
- meta: {
250
- ...queryOptions?.meta,
251
- ...getXRay("useMany", preferLegacyKeys),
252
- },
238
+ handleNotification(notificationConfig, {
239
+ key: `${ids[0]}-${identifier}-getMany-notification`,
240
+ message: translate(
241
+ "notifications.error",
242
+ { statusCode: err.statusCode },
243
+ `Error (status code: ${err.statusCode})`,
244
+ ),
245
+ description: err.message,
246
+ type: "error",
247
+ });
253
248
  },
254
- );
249
+ meta: {
250
+ ...queryOptions?.meta,
251
+ ...getXRay("useMany", preferLegacyKeys),
252
+ },
253
+ });
255
254
 
256
255
  const { elapsedTime } = useLoadingOvertime({
257
256
  isLoading: queryResponse.isFetching,
@@ -107,7 +107,8 @@ export const useOne = <
107
107
  dataProviderName,
108
108
  overtimeOptions,
109
109
  }: UseOneProps<TQueryFnData, TError, TData>): QueryObserverResult<
110
- GetOneResponse<TData>, TError
110
+ GetOneResponse<TData>,
111
+ TError
111
112
  > &
112
113
  UseLoadingOvertimeReturnType => {
113
114
  const { resources, resource, identifier } = useResource(resourceFromProp);
@@ -163,8 +164,8 @@ export const useOne = <
163
164
  GetOneResponse<TQueryFnData>,
164
165
  TError,
165
166
  GetOneResponse<TData>
166
- >(
167
- keys()
167
+ >({
168
+ queryKey: keys()
168
169
  .data(pickedDataProvider)
169
170
  .resource(identifier ?? "")
170
171
  .action("one")
@@ -173,7 +174,7 @@ export const useOne = <
173
174
  ...(preferredMeta || {}),
174
175
  })
175
176
  .get(preferLegacyKeys),
176
- ({ queryKey, pageParam, signal }) =>
177
+ queryFn: ({ queryKey, pageParam, signal }) =>
177
178
  getOne<TQueryFnData>({
178
179
  resource: resource?.name ?? "",
179
180
  id: id!,
@@ -194,62 +195,60 @@ export const useOne = <
194
195
  },
195
196
  },
196
197
  }),
197
- {
198
- ...queryOptions,
199
- enabled:
200
- typeof queryOptions?.enabled !== "undefined"
201
- ? queryOptions?.enabled
202
- : typeof id !== "undefined",
203
- onSuccess: (data) => {
204
- queryOptions?.onSuccess?.(data);
198
+ ...queryOptions,
199
+ enabled:
200
+ typeof queryOptions?.enabled !== "undefined"
201
+ ? queryOptions?.enabled
202
+ : typeof id !== "undefined",
203
+ onSuccess: (data) => {
204
+ queryOptions?.onSuccess?.(data);
205
205
 
206
- const notificationConfig =
207
- typeof successNotification === "function"
208
- ? successNotification(
209
- data,
210
- {
211
- id,
212
- ...combinedMeta,
213
- },
214
- identifier,
215
- )
216
- : successNotification;
206
+ const notificationConfig =
207
+ typeof successNotification === "function"
208
+ ? successNotification(
209
+ data,
210
+ {
211
+ id,
212
+ ...combinedMeta,
213
+ },
214
+ identifier,
215
+ )
216
+ : successNotification;
217
217
 
218
- handleNotification(notificationConfig);
219
- },
220
- onError: (err: TError) => {
221
- checkError(err);
222
- queryOptions?.onError?.(err);
218
+ handleNotification(notificationConfig);
219
+ },
220
+ onError: (err: TError) => {
221
+ checkError(err);
222
+ queryOptions?.onError?.(err);
223
223
 
224
- const notificationConfig =
225
- typeof errorNotification === "function"
226
- ? errorNotification(
227
- err,
228
- {
229
- id,
230
- ...combinedMeta,
231
- },
232
- identifier,
233
- )
234
- : errorNotification;
224
+ const notificationConfig =
225
+ typeof errorNotification === "function"
226
+ ? errorNotification(
227
+ err,
228
+ {
229
+ id,
230
+ ...combinedMeta,
231
+ },
232
+ identifier,
233
+ )
234
+ : errorNotification;
235
235
 
236
- handleNotification(notificationConfig, {
237
- key: `${id}-${identifier}-getOne-notification`,
238
- message: translate(
239
- "notifications.error",
240
- { statusCode: err.statusCode },
241
- `Error (status code: ${err.statusCode})`,
242
- ),
243
- description: err.message,
244
- type: "error",
245
- });
246
- },
247
- meta: {
248
- ...queryOptions?.meta,
249
- ...getXRay("useOne", preferLegacyKeys),
250
- },
236
+ handleNotification(notificationConfig, {
237
+ key: `${id}-${identifier}-getOne-notification`,
238
+ message: translate(
239
+ "notifications.error",
240
+ { statusCode: err.statusCode },
241
+ `Error (status code: ${err.statusCode})`,
242
+ ),
243
+ description: err.message,
244
+ type: "error",
245
+ });
251
246
  },
252
- );
247
+ meta: {
248
+ ...queryOptions?.meta,
249
+ ...getXRay("useOne", preferLegacyKeys),
250
+ },
251
+ });
253
252
 
254
253
  const { elapsedTime } = useLoadingOvertime({
255
254
  isLoading: queryResponse.isFetching,