@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
@@ -140,8 +140,8 @@ export const useCreate = <
140
140
  TError,
141
141
  useCreateParams<TData, TError, TVariables>,
142
142
  unknown
143
- >(
144
- ({
143
+ >({
144
+ mutationFn: ({
145
145
  resource: resourceName,
146
146
  values,
147
147
  meta,
@@ -164,134 +164,132 @@ export const useCreate = <
164
164
  metaData: combinedMeta,
165
165
  });
166
166
  },
167
- {
168
- onSuccess: (
169
- data,
170
- {
171
- resource: resourceName,
172
- successNotification: successNotificationFromProp,
173
- dataProviderName: dataProviderNameFromProp,
174
- invalidates = ["list", "many"],
175
- values,
176
- meta,
177
- metaData,
178
- },
179
- ) => {
180
- const { resource, identifier } = select(resourceName);
181
- const resourceSingular = textTransformers.singular(identifier);
167
+ onSuccess: (
168
+ data,
169
+ {
170
+ resource: resourceName,
171
+ successNotification: successNotificationFromProp,
172
+ dataProviderName: dataProviderNameFromProp,
173
+ invalidates = ["list", "many"],
174
+ values,
175
+ meta,
176
+ metaData,
177
+ },
178
+ ) => {
179
+ const { resource, identifier } = select(resourceName);
180
+ const resourceSingular = textTransformers.singular(identifier);
182
181
 
183
- const dataProviderName = pickDataProvider(
184
- identifier,
185
- dataProviderNameFromProp,
186
- resources,
187
- );
182
+ const dataProviderName = pickDataProvider(
183
+ identifier,
184
+ dataProviderNameFromProp,
185
+ resources,
186
+ );
188
187
 
189
- const combinedMeta = getMeta({
190
- resource,
191
- meta: pickNotDeprecated(meta, metaData),
192
- });
188
+ const combinedMeta = getMeta({
189
+ resource,
190
+ meta: pickNotDeprecated(meta, metaData),
191
+ });
193
192
 
194
- const notificationConfig =
195
- typeof successNotificationFromProp === "function"
196
- ? successNotificationFromProp(data, values, identifier)
197
- : successNotificationFromProp;
193
+ const notificationConfig =
194
+ typeof successNotificationFromProp === "function"
195
+ ? successNotificationFromProp(data, values, identifier)
196
+ : successNotificationFromProp;
198
197
 
199
- handleNotification(notificationConfig, {
200
- key: `create-${identifier}-notification`,
201
- message: translate(
202
- "notifications.createSuccess",
203
- {
204
- resource: translate(
205
- `${identifier}.${identifier}`,
206
- resourceSingular,
207
- ),
208
- },
209
- `Successfully created ${resourceSingular}`,
210
- ),
211
- description: translate("notifications.success", "Success"),
212
- type: "success",
213
- });
198
+ handleNotification(notificationConfig, {
199
+ key: `create-${identifier}-notification`,
200
+ message: translate(
201
+ "notifications.createSuccess",
202
+ {
203
+ resource: translate(
204
+ `${identifier}.${identifier}`,
205
+ resourceSingular,
206
+ ),
207
+ },
208
+ `Successfully created ${resourceSingular}`,
209
+ ),
210
+ description: translate("notifications.success", "Success"),
211
+ type: "success",
212
+ });
214
213
 
215
- invalidateStore({
216
- resource: identifier,
217
- dataProviderName,
218
- invalidates,
219
- });
214
+ invalidateStore({
215
+ resource: identifier,
216
+ dataProviderName,
217
+ invalidates,
218
+ });
220
219
 
221
- publish?.({
222
- channel: `resources/${resource.name}`,
223
- type: "created",
224
- payload: {
225
- ids: data?.data?.id ? [data.data.id] : undefined,
226
- },
227
- date: new Date(),
228
- meta: {
229
- ...combinedMeta,
230
- dataProviderName,
231
- },
232
- });
220
+ publish?.({
221
+ channel: `resources/${resource.name}`,
222
+ type: "created",
223
+ payload: {
224
+ ids: data?.data?.id ? [data.data.id] : undefined,
225
+ },
226
+ date: new Date(),
227
+ meta: {
228
+ ...combinedMeta,
229
+ dataProviderName,
230
+ },
231
+ });
233
232
 
234
- const {
235
- fields: _fields,
236
- operation: _operation,
237
- variables: _variables,
238
- ...rest
239
- } = combinedMeta || {};
240
- log?.mutate({
241
- action: "create",
242
- resource: resource.name,
243
- data: values,
244
- meta: {
245
- dataProviderName,
246
- id: data?.data?.id ?? undefined,
247
- ...rest,
248
- },
249
- });
250
- },
251
- onError: (
252
- err: TError,
253
- {
254
- resource: resourceName,
255
- errorNotification: errorNotificationFromProp,
256
- values,
233
+ const {
234
+ fields: _fields,
235
+ operation: _operation,
236
+ variables: _variables,
237
+ ...rest
238
+ } = combinedMeta || {};
239
+ log?.mutate({
240
+ action: "create",
241
+ resource: resource.name,
242
+ data: values,
243
+ meta: {
244
+ dataProviderName,
245
+ id: data?.data?.id ?? undefined,
246
+ ...rest,
257
247
  },
258
- ) => {
259
- checkError(err);
248
+ });
249
+ },
250
+ onError: (
251
+ err: TError,
252
+ {
253
+ resource: resourceName,
254
+ errorNotification: errorNotificationFromProp,
255
+ values,
256
+ },
257
+ ) => {
258
+ checkError(err);
260
259
 
261
- const { identifier } = select(resourceName);
260
+ const { identifier } = select(resourceName);
262
261
 
263
- const resourceSingular = textTransformers.singular(identifier);
262
+ const resourceSingular = textTransformers.singular(identifier);
264
263
 
265
- const notificationConfig =
266
- typeof errorNotificationFromProp === "function"
267
- ? errorNotificationFromProp(err, values, identifier)
268
- : errorNotificationFromProp;
264
+ const notificationConfig =
265
+ typeof errorNotificationFromProp === "function"
266
+ ? errorNotificationFromProp(err, values, identifier)
267
+ : errorNotificationFromProp;
269
268
 
270
- handleNotification(notificationConfig, {
271
- key: `create-${identifier}-notification`,
272
- description: err.message,
273
- message: translate(
274
- "notifications.createError",
275
- {
276
- resource: translate(
277
- `${identifier}.${identifier}`,
278
- resourceSingular,
279
- ),
280
- statusCode: err.statusCode,
281
- },
282
- `There was an error creating ${resourceSingular} (status code: ${err.statusCode})`,
283
- ),
284
- type: "error",
285
- });
286
- },
287
- mutationKey: keys().data().mutation("create").get(preferLegacyKeys),
288
- ...mutationOptions,
289
- meta: {
290
- ...mutationOptions?.meta,
291
- ...getXRay("useCreate", preferLegacyKeys),
292
- },
269
+ handleNotification(notificationConfig, {
270
+ key: `create-${identifier}-notification`,
271
+ description: err.message,
272
+ message: translate(
273
+ "notifications.createError",
274
+ {
275
+ resource: translate(
276
+ `${identifier}.${identifier}`,
277
+ resourceSingular,
278
+ ),
279
+ statusCode: err.statusCode,
280
+ },
281
+ `There was an error creating ${resourceSingular} (status code: ${err.statusCode})`,
282
+ ),
283
+ type: "error",
284
+ });
285
+ },
286
+ mutationKey: keys().data().mutation("create").get(preferLegacyKeys),
287
+ ...mutationOptions,
288
+ meta: {
289
+ ...mutationOptions?.meta,
290
+ ...getXRay("useCreate", preferLegacyKeys),
293
291
  },
294
- );
292
+ });
295
293
 
296
294
  const { elapsedTime } = useLoadingOvertime({
297
295
  isLoading: mutation.isLoading,
@@ -113,8 +113,8 @@ export const useCreateMany = <
113
113
  CreateManyResponse<TData>,
114
114
  TError,
115
115
  useCreateManyParams<TData, TError, TVariables>
116
- >(
117
- ({
116
+ >({
117
+ mutationFn: ({
118
118
  resource: resourceName,
119
119
  values,
120
120
  meta,
@@ -152,132 +152,127 @@ export const useCreateMany = <
152
152
  );
153
153
  }
154
154
  },
155
- {
156
- onSuccess: (
157
- response,
158
- {
159
- resource: resourceName,
160
- successNotification,
161
- dataProviderName: dataProviderNameFromProp,
162
- invalidates = ["list", "many"],
163
- values,
164
- meta,
165
- metaData,
166
- },
167
- ) => {
168
- const { resource, identifier } = select(resourceName);
169
- const resourcePlural = textTransformers.plural(identifier);
155
+ onSuccess: (
156
+ response,
157
+ {
158
+ resource: resourceName,
159
+ successNotification,
160
+ dataProviderName: dataProviderNameFromProp,
161
+ invalidates = ["list", "many"],
162
+ values,
163
+ meta,
164
+ metaData,
165
+ },
166
+ ) => {
167
+ const { resource, identifier } = select(resourceName);
168
+ const resourcePlural = textTransformers.plural(identifier);
170
169
 
171
- const dataProviderName = pickDataProvider(
172
- identifier,
173
- dataProviderNameFromProp,
174
- resources,
175
- );
170
+ const dataProviderName = pickDataProvider(
171
+ identifier,
172
+ dataProviderNameFromProp,
173
+ resources,
174
+ );
176
175
 
177
- const combinedMeta = getMeta({
178
- resource,
179
- meta: pickNotDeprecated(meta, metaData),
180
- });
176
+ const combinedMeta = getMeta({
177
+ resource,
178
+ meta: pickNotDeprecated(meta, metaData),
179
+ });
181
180
 
182
- const notificationConfig =
183
- typeof successNotification === "function"
184
- ? successNotification(response, values, identifier)
185
- : successNotification;
181
+ const notificationConfig =
182
+ typeof successNotification === "function"
183
+ ? successNotification(response, values, identifier)
184
+ : successNotification;
186
185
 
187
- handleNotification(notificationConfig, {
188
- key: `createMany-${identifier}-notification`,
189
- message: translate(
190
- "notifications.createSuccess",
191
- {
192
- resource: translate(
193
- `${identifier}.${identifier}`,
194
- identifier,
195
- ),
196
- },
197
- `Successfully created ${resourcePlural}`,
198
- ),
199
- description: translate("notifications.success", "Success"),
200
- type: "success",
201
- });
186
+ handleNotification(notificationConfig, {
187
+ key: `createMany-${identifier}-notification`,
188
+ message: translate(
189
+ "notifications.createSuccess",
190
+ {
191
+ resource: translate(
192
+ `${identifier}.${identifier}`,
193
+ identifier,
194
+ ),
195
+ },
196
+ `Successfully created ${resourcePlural}`,
197
+ ),
198
+ description: translate("notifications.success", "Success"),
199
+ type: "success",
200
+ });
202
201
 
203
- invalidateStore({
204
- resource: identifier,
205
- dataProviderName,
206
- invalidates,
207
- });
202
+ invalidateStore({
203
+ resource: identifier,
204
+ dataProviderName,
205
+ invalidates,
206
+ });
208
207
 
209
- const ids = response?.data
210
- .filter((item) => item?.id !== undefined)
211
- .map((item) => item.id!);
212
- publish?.({
213
- channel: `resources/${resource.name}`,
214
- type: "created",
215
- payload: {
216
- ids,
217
- },
218
- date: new Date(),
219
- meta: {
220
- ...combinedMeta,
221
- dataProviderName,
222
- },
223
- });
208
+ const ids = response?.data
209
+ .filter((item) => item?.id !== undefined)
210
+ .map((item) => item.id!);
211
+ publish?.({
212
+ channel: `resources/${resource.name}`,
213
+ type: "created",
214
+ payload: {
215
+ ids,
216
+ },
217
+ date: new Date(),
218
+ meta: {
219
+ ...combinedMeta,
220
+ dataProviderName,
221
+ },
222
+ });
224
223
 
225
- const {
226
- fields: _fields,
227
- operation: _operation,
228
- variables: _variables,
229
- ...rest
230
- } = combinedMeta || {};
231
- log?.mutate({
232
- action: "createMany",
233
- resource: resource.name,
234
- data: values,
235
- meta: {
236
- dataProviderName,
237
- ids,
238
- ...rest,
239
- },
240
- });
241
- },
242
- onError: (
243
- err: TError,
244
- { resource: resourceName, errorNotification, values },
245
- ) => {
246
- const { identifier } = select(resourceName);
224
+ const {
225
+ fields: _fields,
226
+ operation: _operation,
227
+ variables: _variables,
228
+ ...rest
229
+ } = combinedMeta || {};
230
+ log?.mutate({
231
+ action: "createMany",
232
+ resource: resource.name,
233
+ data: values,
234
+ meta: {
235
+ dataProviderName,
236
+ ids,
237
+ ...rest,
238
+ },
239
+ });
240
+ },
241
+ onError: (
242
+ err: TError,
243
+ { resource: resourceName, errorNotification, values },
244
+ ) => {
245
+ const { identifier } = select(resourceName);
247
246
 
248
- const notificationConfig =
249
- typeof errorNotification === "function"
250
- ? errorNotification(err, values, identifier)
251
- : errorNotification;
247
+ const notificationConfig =
248
+ typeof errorNotification === "function"
249
+ ? errorNotification(err, values, identifier)
250
+ : errorNotification;
252
251
 
253
- handleNotification(notificationConfig, {
254
- key: `createMany-${identifier}-notification`,
255
- description: err.message,
256
- message: translate(
257
- "notifications.createError",
258
- {
259
- resource: translate(
260
- `${identifier}.${identifier}`,
261
- identifier,
262
- ),
263
- statusCode: err.statusCode,
264
- },
265
- `There was an error creating ${identifier} (status code: ${err.statusCode}`,
266
- ),
267
- type: "error",
268
- });
269
- },
270
- mutationKey: keys()
271
- .data()
272
- .mutation("createMany")
273
- .get(preferLegacyKeys),
274
- ...mutationOptions,
275
- meta: {
276
- ...mutationOptions?.meta,
277
- ...getXRay("useCreateMany", preferLegacyKeys),
278
- },
252
+ handleNotification(notificationConfig, {
253
+ key: `createMany-${identifier}-notification`,
254
+ description: err.message,
255
+ message: translate(
256
+ "notifications.createError",
257
+ {
258
+ resource: translate(
259
+ `${identifier}.${identifier}`,
260
+ identifier,
261
+ ),
262
+ statusCode: err.statusCode,
263
+ },
264
+ `There was an error creating ${identifier} (status code: ${err.statusCode}`,
265
+ ),
266
+ type: "error",
267
+ });
279
268
  },
280
- );
269
+ mutationKey: keys().data().mutation("createMany").get(preferLegacyKeys),
270
+ ...mutationOptions,
271
+ meta: {
272
+ ...mutationOptions?.meta,
273
+ ...getXRay("useCreateMany", preferLegacyKeys),
274
+ },
275
+ });
281
276
 
282
277
  const { elapsedTime } = useLoadingOvertime({
283
278
  isLoading: mutation.isLoading,