@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
|
@@ -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
|
-
|
|
278
|
-
enabled
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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
|
-
|
|
284
|
+
const { current, mode, pageSize } = prefferedPagination;
|
|
286
285
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
|
|
299
|
-
|
|
300
|
-
|
|
297
|
+
if (queryOptions?.select) {
|
|
298
|
+
return queryOptions?.select?.(data);
|
|
299
|
+
}
|
|
301
300
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
301
|
+
return data as unknown as GetListResponse<TData>;
|
|
302
|
+
},
|
|
303
|
+
onSuccess: (data) => {
|
|
304
|
+
queryOptions?.onSuccess?.(data);
|
|
306
305
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
notificationValues,
|
|
312
|
-
identifier,
|
|
313
|
-
)
|
|
314
|
-
: successNotification;
|
|
306
|
+
const notificationConfig =
|
|
307
|
+
typeof successNotification === "function"
|
|
308
|
+
? successNotification(data, notificationValues, identifier)
|
|
309
|
+
: successNotification;
|
|
315
310
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
311
|
+
handleNotification(notificationConfig);
|
|
312
|
+
},
|
|
313
|
+
onError: (err: TError) => {
|
|
314
|
+
checkError(err);
|
|
315
|
+
queryOptions?.onError?.(err);
|
|
321
316
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
317
|
+
const notificationConfig =
|
|
318
|
+
typeof errorNotification === "function"
|
|
319
|
+
? errorNotification(err, notificationValues, identifier)
|
|
320
|
+
: errorNotification;
|
|
326
321
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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>,
|
|
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
|
-
|
|
219
|
-
onSuccess
|
|
220
|
-
queryOptions?.onSuccess?.(data);
|
|
218
|
+
...queryOptions,
|
|
219
|
+
onSuccess: (data) => {
|
|
220
|
+
queryOptions?.onSuccess?.(data);
|
|
221
221
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
const notificationConfig =
|
|
223
|
+
typeof successNotification === "function"
|
|
224
|
+
? successNotification(data, ids, identifier)
|
|
225
|
+
: successNotification;
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
handleNotification(notificationConfig);
|
|
228
|
+
},
|
|
229
|
+
onError: (err: TError) => {
|
|
230
|
+
checkError(err);
|
|
231
|
+
queryOptions?.onError?.(err);
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
const notificationConfig =
|
|
234
|
+
typeof errorNotification === "function"
|
|
235
|
+
? errorNotification(err, ids, identifier)
|
|
236
|
+
: errorNotification;
|
|
237
237
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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,
|
package/src/hooks/data/useOne.ts
CHANGED
|
@@ -107,7 +107,8 @@ export const useOne = <
|
|
|
107
107
|
dataProviderName,
|
|
108
108
|
overtimeOptions,
|
|
109
109
|
}: UseOneProps<TQueryFnData, TError, TData>): QueryObserverResult<
|
|
110
|
-
GetOneResponse<TData>,
|
|
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
|
-
|
|
199
|
-
enabled
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
onSuccess
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
handleNotification(notificationConfig);
|
|
219
|
+
},
|
|
220
|
+
onError: (err: TError) => {
|
|
221
|
+
checkError(err);
|
|
222
|
+
queryOptions?.onError?.(err);
|
|
223
223
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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,
|