@refinedev/core 4.22.0 → 4.24.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +180 -0
  2. package/dist/components/canAccess/index.d.ts.map +1 -1
  3. package/dist/contexts/refine/IRefineContext.d.ts +3 -0
  4. package/dist/contexts/refine/IRefineContext.d.ts.map +1 -1
  5. package/dist/contexts/refine/index.d.ts.map +1 -1
  6. package/dist/definitions/helpers/generateDocumentTitle/index.d.ts.map +1 -1
  7. package/dist/definitions/helpers/handleRefineOptions/index.d.ts.map +1 -1
  8. package/dist/definitions/helpers/pick-resource/index.d.ts.map +1 -1
  9. package/dist/esm/index.js +6 -6
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/hooks/data/useCreate.d.ts +3 -2
  12. package/dist/hooks/data/useCreate.d.ts.map +1 -1
  13. package/dist/hooks/data/useCreateMany.d.ts +3 -2
  14. package/dist/hooks/data/useCreateMany.d.ts.map +1 -1
  15. package/dist/hooks/data/useCustom.d.ts +3 -2
  16. package/dist/hooks/data/useCustom.d.ts.map +1 -1
  17. package/dist/hooks/data/useCustomMutation.d.ts +3 -2
  18. package/dist/hooks/data/useCustomMutation.d.ts.map +1 -1
  19. package/dist/hooks/data/useDelete.d.ts +4 -3
  20. package/dist/hooks/data/useDelete.d.ts.map +1 -1
  21. package/dist/hooks/data/useDeleteMany.d.ts +4 -3
  22. package/dist/hooks/data/useDeleteMany.d.ts.map +1 -1
  23. package/dist/hooks/data/useInfiniteList.d.ts +3 -2
  24. package/dist/hooks/data/useInfiniteList.d.ts.map +1 -1
  25. package/dist/hooks/data/useList.d.ts +3 -2
  26. package/dist/hooks/data/useList.d.ts.map +1 -1
  27. package/dist/hooks/data/useMany.d.ts +3 -2
  28. package/dist/hooks/data/useMany.d.ts.map +1 -1
  29. package/dist/hooks/data/useOne.d.ts +3 -2
  30. package/dist/hooks/data/useOne.d.ts.map +1 -1
  31. package/dist/hooks/data/useUpdate.d.ts +4 -3
  32. package/dist/hooks/data/useUpdate.d.ts.map +1 -1
  33. package/dist/hooks/data/useUpdateMany.d.ts +4 -3
  34. package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
  35. package/dist/hooks/export/index.d.ts.map +1 -1
  36. package/dist/hooks/form/useForm.d.ts +4 -3
  37. package/dist/hooks/form/useForm.d.ts.map +1 -1
  38. package/dist/hooks/index.d.ts +1 -0
  39. package/dist/hooks/index.d.ts.map +1 -1
  40. package/dist/hooks/live/useResourceSubscription/index.d.ts +1 -1
  41. package/dist/hooks/live/useResourceSubscription/index.d.ts.map +1 -1
  42. package/dist/hooks/resource/useResource/index.d.ts +11 -1
  43. package/dist/hooks/resource/useResource/index.d.ts.map +1 -1
  44. package/dist/hooks/show/useShow.d.ts +4 -3
  45. package/dist/hooks/show/useShow.d.ts.map +1 -1
  46. package/dist/hooks/useLoadingOvertime/index.d.ts +49 -0
  47. package/dist/hooks/useLoadingOvertime/index.d.ts.map +1 -0
  48. package/dist/hooks/useSelect/index.d.ts +3 -2
  49. package/dist/hooks/useSelect/index.d.ts.map +1 -1
  50. package/dist/hooks/useTable/index.d.ts +4 -3
  51. package/dist/hooks/useTable/index.d.ts.map +1 -1
  52. package/dist/iife/index.js +6 -6
  53. package/dist/iife/index.js.map +1 -1
  54. package/dist/index.js +6 -6
  55. package/dist/index.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/components/canAccess/index.tsx +17 -92
  58. package/src/contexts/refine/IRefineContext.ts +3 -0
  59. package/src/contexts/refine/index.tsx +3 -0
  60. package/src/definitions/helpers/generateDocumentTitle/index.ts +5 -3
  61. package/src/definitions/helpers/handleRefineOptions/index.ts +1 -0
  62. package/src/definitions/helpers/pick-resource/index.ts +4 -3
  63. package/src/hooks/data/useCreate.ts +49 -23
  64. package/src/hooks/data/useCreateMany.ts +54 -26
  65. package/src/hooks/data/useCustom.ts +17 -3
  66. package/src/hooks/data/useCustomMutation.ts +16 -3
  67. package/src/hooks/data/useDelete.ts +60 -31
  68. package/src/hooks/data/useDeleteMany.ts +64 -31
  69. package/src/hooks/data/useInfiniteList.ts +30 -14
  70. package/src/hooks/data/useList.ts +30 -20
  71. package/src/hooks/data/useMany.ts +34 -23
  72. package/src/hooks/data/useOne.ts +36 -22
  73. package/src/hooks/data/useUpdate.ts +55 -32
  74. package/src/hooks/data/useUpdateMany.ts +69 -33
  75. package/src/hooks/export/index.ts +12 -11
  76. package/src/hooks/form/useForm.ts +46 -98
  77. package/src/hooks/import/index.tsx +17 -17
  78. package/src/hooks/index.ts +1 -0
  79. package/src/hooks/live/useResourceSubscription/index.ts +6 -3
  80. package/src/hooks/resource/useResource/index.ts +48 -1
  81. package/src/hooks/show/useShow.ts +34 -80
  82. package/src/hooks/useLoadingOvertime/index.ts +114 -0
  83. package/src/hooks/useSelect/index.ts +21 -14
  84. package/src/hooks/useTable/index.ts +22 -8
@@ -35,6 +35,12 @@ import {
35
35
  handlePaginationParams,
36
36
  } from "@definitions/helpers";
37
37
 
38
+ import {
39
+ useLoadingOvertime,
40
+ UseLoadingOvertimeOptionsProps,
41
+ UseLoadingOvertimeReturnType,
42
+ } from "../useLoadingOvertime";
43
+
38
44
  export interface UseInfiniteListConfig {
39
45
  pagination?: Pagination;
40
46
  hasPagination?: boolean;
@@ -100,7 +106,8 @@ export type UseInfiniteListProps<TQueryFnData, TError, TData> = {
100
106
  TError,
101
107
  Prettify<BaseInfiniteListProps>
102
108
  > &
103
- LiveModeProps;
109
+ LiveModeProps &
110
+ UseLoadingOvertimeOptionsProps;
104
111
 
105
112
  /**
106
113
  * `useInfiniteList` is a modified version of `react-query`'s {@link https://tanstack.com/query/latest/docs/react/guides/infinite-queries `useInfiniteQuery`} used for retrieving items from a `resource` with pagination, sort, and filter configurations.
@@ -120,7 +127,7 @@ export const useInfiniteList = <
120
127
  TError extends HttpError = HttpError,
121
128
  TData extends BaseRecord = TQueryFnData,
122
129
  >({
123
- resource,
130
+ resource: resourceFromProp,
124
131
  config,
125
132
  filters,
126
133
  hasPagination,
@@ -135,12 +142,15 @@ export const useInfiniteList = <
135
142
  onLiveEvent,
136
143
  liveParams,
137
144
  dataProviderName,
145
+ overtimeOptions,
138
146
  }: UseInfiniteListProps<
139
147
  TQueryFnData,
140
148
  TError,
141
149
  TData
142
- >): InfiniteQueryObserverResult<GetListResponse<TData>, TError> => {
143
- const { resources } = useResource();
150
+ >): InfiniteQueryObserverResult<GetListResponse<TData>, TError> &
151
+ UseLoadingOvertimeReturnType => {
152
+ const { resources, resource, identifier } = useResource(resourceFromProp);
153
+
144
154
  const dataProvider = useDataProvider();
145
155
  const translate = useTranslate();
146
156
  const authProvider = useActiveAuthProvider();
@@ -151,7 +161,7 @@ export const useInfiniteList = <
151
161
  const getMeta = useMeta();
152
162
 
153
163
  const pickedDataProvider = pickDataProvider(
154
- resource,
164
+ identifier,
155
165
  dataProviderName,
156
166
  resources,
157
167
  );
@@ -185,18 +195,18 @@ export const useInfiniteList = <
185
195
  queryOptions?.enabled === undefined || queryOptions?.enabled === true;
186
196
 
187
197
  const queryKey = queryKeys(
188
- resource,
198
+ identifier,
189
199
  pickedDataProvider,
190
200
  preferredMeta,
191
201
  preferredMeta,
192
202
  );
193
203
 
194
- const combinedMeta = getMeta({ meta: preferredMeta });
204
+ const combinedMeta = getMeta({ resource, meta: preferredMeta });
195
205
 
196
206
  const { getList } = dataProvider(pickedDataProvider);
197
207
 
198
208
  useResourceSubscription({
199
- resource,
209
+ resource: identifier,
200
210
  types: ["*"],
201
211
  params: {
202
212
  meta: combinedMeta,
@@ -209,7 +219,7 @@ export const useInfiniteList = <
209
219
  subscriptionType: "useList",
210
220
  ...liveParams,
211
221
  },
212
- channel: `resources/${resource}`,
222
+ channel: `resources/${resource.name}`,
213
223
  enabled: isEnabled,
214
224
  liveMode,
215
225
  onLiveEvent,
@@ -240,7 +250,7 @@ export const useInfiniteList = <
240
250
  };
241
251
 
242
252
  return getList<TQueryFnData>({
243
- resource,
253
+ resource: resource.name,
244
254
  pagination: paginationProperties,
245
255
  hasPagination: isServerPagination,
246
256
  filters: prefferedFilters,
@@ -283,7 +293,7 @@ export const useInfiniteList = <
283
293
  ? successNotification(
284
294
  data,
285
295
  notificationValues,
286
- resource,
296
+ identifier,
287
297
  )
288
298
  : successNotification;
289
299
 
@@ -295,11 +305,11 @@ export const useInfiniteList = <
295
305
 
296
306
  const notificationConfig =
297
307
  typeof errorNotification === "function"
298
- ? errorNotification(err, notificationValues, resource)
308
+ ? errorNotification(err, notificationValues, identifier)
299
309
  : errorNotification;
300
310
 
301
311
  handleNotification(notificationConfig, {
302
- key: `${resource}-useInfiniteList-notification`,
312
+ key: `${identifier}-useInfiniteList-notification`,
303
313
  message: translate(
304
314
  "notifications.error",
305
315
  { statusCode: err.statusCode },
@@ -312,5 +322,11 @@ export const useInfiniteList = <
312
322
  },
313
323
  );
314
324
 
315
- return queryResponse;
325
+ const { elapsedTime } = useLoadingOvertime({
326
+ isLoading: queryResponse.isFetching,
327
+ interval: overtimeOptions?.interval,
328
+ onInterval: overtimeOptions?.onInterval,
329
+ });
330
+
331
+ return { ...queryResponse, overtime: { elapsedTime } };
316
332
  };
@@ -31,6 +31,11 @@ import {
31
31
  useActiveAuthProvider,
32
32
  handlePaginationParams,
33
33
  } from "@definitions/helpers";
34
+ import {
35
+ useLoadingOvertime,
36
+ UseLoadingOvertimeOptionsProps,
37
+ UseLoadingOvertimeReturnType,
38
+ } from "../useLoadingOvertime";
34
39
 
35
40
  export interface UseListConfig {
36
41
  pagination?: Pagination;
@@ -98,7 +103,8 @@ export type UseListProps<TQueryFnData, TError, TData> = {
98
103
  TError,
99
104
  Prettify<BaseListProps>
100
105
  > &
101
- LiveModeProps;
106
+ LiveModeProps &
107
+ UseLoadingOvertimeOptionsProps;
102
108
 
103
109
  /**
104
110
  * `useList` is a modified version of `react-query`'s {@link https://react-query.tanstack.com/guides/queries `useQuery`} used for retrieving items from a `resource` with pagination, sort, and filter configurations.
@@ -118,7 +124,7 @@ export const useList = <
118
124
  TError extends HttpError = HttpError,
119
125
  TData extends BaseRecord = TQueryFnData,
120
126
  >({
121
- resource,
127
+ resource: resourceFromProp,
122
128
  config,
123
129
  filters,
124
130
  hasPagination,
@@ -133,11 +139,14 @@ export const useList = <
133
139
  onLiveEvent,
134
140
  liveParams,
135
141
  dataProviderName,
142
+ overtimeOptions,
136
143
  }: UseListProps<TQueryFnData, TError, TData>): QueryObserverResult<
137
144
  GetListResponse<TData>,
138
145
  TError
139
- > => {
140
- const { resources } = useResource();
146
+ > &
147
+ UseLoadingOvertimeReturnType => {
148
+ const { resources, resource, identifier } = useResource(resourceFromProp);
149
+
141
150
  const dataProvider = useDataProvider();
142
151
  const translate = useTranslate();
143
152
  const authProvider = useActiveAuthProvider();
@@ -148,7 +157,7 @@ export const useList = <
148
157
  const getMeta = useMeta();
149
158
 
150
159
  const pickedDataProvider = pickDataProvider(
151
- resource,
160
+ identifier,
152
161
  dataProviderName,
153
162
  resources,
154
163
  );
@@ -166,7 +175,7 @@ export const useList = <
166
175
  });
167
176
  const isServerPagination = prefferedPagination.mode === "server";
168
177
 
169
- const combinedMeta = getMeta({ meta: preferredMeta });
178
+ const combinedMeta = getMeta({ resource, meta: preferredMeta });
170
179
 
171
180
  const notificationValues = {
172
181
  meta: combinedMeta,
@@ -184,17 +193,12 @@ export const useList = <
184
193
  const isEnabled =
185
194
  queryOptions?.enabled === undefined || queryOptions?.enabled === true;
186
195
 
187
- const queryKey = queryKeys(
188
- resource,
189
- pickedDataProvider,
190
- preferredMeta,
191
- preferredMeta,
192
- );
196
+ const queryKey = queryKeys(identifier, pickedDataProvider, preferredMeta);
193
197
 
194
198
  const { getList } = dataProvider(pickedDataProvider);
195
199
 
196
200
  useResourceSubscription({
197
- resource,
201
+ resource: identifier,
198
202
  types: ["*"],
199
203
  params: {
200
204
  meta: combinedMeta,
@@ -207,7 +211,7 @@ export const useList = <
207
211
  subscriptionType: "useList",
208
212
  ...liveParams,
209
213
  },
210
- channel: `resources/${resource}`,
214
+ channel: `resources/${resource?.name}`,
211
215
  enabled: isEnabled,
212
216
  liveMode,
213
217
  onLiveEvent,
@@ -233,7 +237,7 @@ export const useList = <
233
237
  }),
234
238
  ({ queryKey, pageParam, signal }) => {
235
239
  return getList<TQueryFnData>({
236
- resource: resource!,
240
+ resource: resource?.name ?? "",
237
241
  pagination: prefferedPagination,
238
242
  hasPagination: isServerPagination,
239
243
  filters: prefferedFilters,
@@ -262,7 +266,7 @@ export const useList = <
262
266
  enabled:
263
267
  typeof queryOptions?.enabled !== "undefined"
264
268
  ? queryOptions?.enabled
265
- : !!resource,
269
+ : !!resource?.name,
266
270
  select: (rawData) => {
267
271
  let data = rawData;
268
272
 
@@ -293,7 +297,7 @@ export const useList = <
293
297
  ? successNotification(
294
298
  data,
295
299
  notificationValues,
296
- resource,
300
+ identifier,
297
301
  )
298
302
  : successNotification;
299
303
 
@@ -305,11 +309,11 @@ export const useList = <
305
309
 
306
310
  const notificationConfig =
307
311
  typeof errorNotification === "function"
308
- ? errorNotification(err, notificationValues, resource)
312
+ ? errorNotification(err, notificationValues, identifier)
309
313
  : errorNotification;
310
314
 
311
315
  handleNotification(notificationConfig, {
312
- key: `${resource}-useList-notification`,
316
+ key: `${identifier}-useList-notification`,
313
317
  message: translate(
314
318
  "notifications.error",
315
319
  { statusCode: err.statusCode },
@@ -322,5 +326,11 @@ export const useList = <
322
326
  },
323
327
  );
324
328
 
325
- return queryResponse;
329
+ const { elapsedTime } = useLoadingOvertime({
330
+ isLoading: queryResponse.isFetching,
331
+ interval: overtimeOptions?.interval,
332
+ onInterval: overtimeOptions?.onInterval,
333
+ });
334
+
335
+ return { ...queryResponse, overtime: { elapsedTime } };
326
336
  };
@@ -29,6 +29,11 @@ import {
29
29
  pickNotDeprecated,
30
30
  useActiveAuthProvider,
31
31
  } from "@definitions/helpers";
32
+ import {
33
+ useLoadingOvertime,
34
+ UseLoadingOvertimeOptionsProps,
35
+ UseLoadingOvertimeReturnType,
36
+ } from "../useLoadingOvertime";
32
37
 
33
38
  export type UseManyProps<TQueryFnData, TError, TData> = {
34
39
  /**
@@ -63,7 +68,8 @@ export type UseManyProps<TQueryFnData, TError, TData> = {
63
68
  */
64
69
  dataProviderName?: string;
65
70
  } & SuccessErrorNotification<GetManyResponse<TData>, TError, BaseKey[]> &
66
- LiveModeProps;
71
+ LiveModeProps &
72
+ UseLoadingOvertimeOptionsProps;
67
73
 
68
74
  /**
69
75
  * `useMany` is a modified version of `react-query`'s {@link https://react-query.tanstack.com/guides/queries `useQuery`} used for retrieving multiple items from a `resource`.
@@ -83,7 +89,7 @@ export const useMany = <
83
89
  TError extends HttpError = HttpError,
84
90
  TData extends BaseRecord = TQueryFnData,
85
91
  >({
86
- resource,
92
+ resource: resourceFromProp,
87
93
  ids,
88
94
  queryOptions,
89
95
  successNotification,
@@ -94,10 +100,12 @@ export const useMany = <
94
100
  onLiveEvent,
95
101
  liveParams,
96
102
  dataProviderName,
103
+ overtimeOptions,
97
104
  }: UseManyProps<TQueryFnData, TError, TData>): QueryObserverResult<
98
105
  GetManyResponse<TData>
99
- > => {
100
- const { resources } = useResource();
106
+ > &
107
+ UseLoadingOvertimeReturnType => {
108
+ const { resources, resource, identifier } = useResource(resourceFromProp);
101
109
  const dataProvider = useDataProvider();
102
110
  const translate = useTranslate();
103
111
  const authProvider = useActiveAuthProvider();
@@ -108,25 +116,22 @@ export const useMany = <
108
116
  const getMeta = useMeta();
109
117
 
110
118
  const preferredMeta = pickNotDeprecated(meta, metaData);
111
-
119
+ const pickedDataProvider = pickDataProvider(
120
+ identifier,
121
+ dataProviderName,
122
+ resources,
123
+ );
112
124
  const isEnabled =
113
125
  queryOptions?.enabled === undefined || queryOptions?.enabled === true;
114
126
 
115
- const queryKey = queryKeys(
116
- resource,
117
- pickDataProvider(resource, dataProviderName, resources),
118
- preferredMeta,
119
- preferredMeta,
120
- );
127
+ const queryKey = queryKeys(identifier, pickedDataProvider, preferredMeta);
121
128
 
122
- const { getMany, getOne } = dataProvider(
123
- pickDataProvider(resource, dataProviderName, resources),
124
- );
129
+ const { getMany, getOne } = dataProvider(pickedDataProvider);
125
130
 
126
- const combinedMeta = getMeta({ meta: preferredMeta });
131
+ const combinedMeta = getMeta({ resource, meta: preferredMeta });
127
132
 
128
133
  useResourceSubscription({
129
- resource,
134
+ resource: identifier,
130
135
  types: ["*"],
131
136
  params: {
132
137
  ids: ids,
@@ -135,7 +140,7 @@ export const useMany = <
135
140
  subscriptionType: "useMany",
136
141
  ...liveParams,
137
142
  },
138
- channel: `resources/${resource}`,
143
+ channel: `resources/${resource.name}`,
139
144
  enabled: isEnabled,
140
145
  liveMode,
141
146
  onLiveEvent,
@@ -150,7 +155,7 @@ export const useMany = <
150
155
  ({ queryKey, pageParam, signal }) => {
151
156
  if (getMany) {
152
157
  return getMany({
153
- resource,
158
+ resource: resource?.name,
154
159
  ids,
155
160
  meta: {
156
161
  ...combinedMeta,
@@ -173,7 +178,7 @@ export const useMany = <
173
178
  return handleMultiple(
174
179
  ids.map((id) =>
175
180
  getOne<TQueryFnData>({
176
- resource,
181
+ resource: resource?.name,
177
182
  id,
178
183
  meta: {
179
184
  ...combinedMeta,
@@ -203,7 +208,7 @@ export const useMany = <
203
208
 
204
209
  const notificationConfig =
205
210
  typeof successNotification === "function"
206
- ? successNotification(data, ids, resource)
211
+ ? successNotification(data, ids, identifier)
207
212
  : successNotification;
208
213
 
209
214
  handleNotification(notificationConfig);
@@ -214,11 +219,11 @@ export const useMany = <
214
219
 
215
220
  const notificationConfig =
216
221
  typeof errorNotification === "function"
217
- ? errorNotification(err, ids, resource)
222
+ ? errorNotification(err, ids, identifier)
218
223
  : errorNotification;
219
224
 
220
225
  handleNotification(notificationConfig, {
221
- key: `${ids[0]}-${resource}-getMany-notification`,
226
+ key: `${ids[0]}-${identifier}-getMany-notification`,
222
227
  message: translate(
223
228
  "notifications.error",
224
229
  { statusCode: err.statusCode },
@@ -231,5 +236,11 @@ export const useMany = <
231
236
  },
232
237
  );
233
238
 
234
- return queryResponse;
239
+ const { elapsedTime } = useLoadingOvertime({
240
+ isLoading: queryResponse.isFetching,
241
+ interval: overtimeOptions?.interval,
242
+ onInterval: overtimeOptions?.onInterval,
243
+ });
244
+
245
+ return { ...queryResponse, overtime: { elapsedTime } };
235
246
  };
@@ -29,6 +29,11 @@ import {
29
29
  pickNotDeprecated,
30
30
  useActiveAuthProvider,
31
31
  } from "@definitions";
32
+ import {
33
+ useLoadingOvertime,
34
+ UseLoadingOvertimeOptionsProps,
35
+ UseLoadingOvertimeReturnType,
36
+ } from "../useLoadingOvertime";
32
37
 
33
38
  export type UseOneProps<TQueryFnData, TError, TData> = {
34
39
  /**
@@ -67,7 +72,8 @@ export type UseOneProps<TQueryFnData, TError, TData> = {
67
72
  TError,
68
73
  Prettify<{ id?: BaseKey } & MetaQuery>
69
74
  > &
70
- LiveModeProps;
75
+ LiveModeProps &
76
+ UseLoadingOvertimeOptionsProps;
71
77
 
72
78
  /**
73
79
  * `useOne` is a modified version of `react-query`'s {@link https://react-query.tanstack.com/guides/queries `useQuery`} used for retrieving single items from a `resource`.
@@ -87,7 +93,7 @@ export const useOne = <
87
93
  TError extends HttpError = HttpError,
88
94
  TData extends BaseRecord = TQueryFnData,
89
95
  >({
90
- resource,
96
+ resource: resourceFromProp,
91
97
  id,
92
98
  queryOptions,
93
99
  successNotification,
@@ -98,10 +104,13 @@ export const useOne = <
98
104
  onLiveEvent,
99
105
  liveParams,
100
106
  dataProviderName,
107
+ overtimeOptions,
101
108
  }: UseOneProps<TQueryFnData, TError, TData>): QueryObserverResult<
102
109
  GetOneResponse<TData>
103
- > => {
104
- const { resources } = useResource();
110
+ > &
111
+ UseLoadingOvertimeReturnType => {
112
+ const { resources, resource, identifier } = useResource(resourceFromProp);
113
+
105
114
  const dataProvider = useDataProvider();
106
115
  const translate = useTranslate();
107
116
  const authProvider = useActiveAuthProvider();
@@ -112,24 +121,22 @@ export const useOne = <
112
121
  const getMeta = useMeta();
113
122
 
114
123
  const preferredMeta = pickNotDeprecated(meta, metaData);
115
-
116
- const queryKey = queryKeys(
117
- resource,
118
- pickDataProvider(resource, dataProviderName, resources),
119
- preferredMeta,
120
- preferredMeta,
124
+ const pickedDataProvider = pickDataProvider(
125
+ identifier,
126
+ dataProviderName,
127
+ resources,
121
128
  );
122
129
 
123
- const { getOne } = dataProvider(
124
- pickDataProvider(resource, dataProviderName, resources),
125
- );
130
+ const queryKey = queryKeys(identifier, pickedDataProvider, preferredMeta);
131
+
132
+ const { getOne } = dataProvider(pickedDataProvider);
126
133
 
127
- const combinedMeta = getMeta({ meta: preferredMeta });
134
+ const combinedMeta = getMeta({ resource, meta: preferredMeta });
128
135
 
129
136
  useResourceSubscription({
130
- resource,
137
+ resource: identifier,
131
138
  types: ["*"],
132
- channel: `resources/${resource}`,
139
+ channel: `resources/${resource?.name}`,
133
140
  params: {
134
141
  ids: id ? [id] : [],
135
142
  id: id,
@@ -141,7 +148,8 @@ export const useOne = <
141
148
  enabled:
142
149
  typeof queryOptions?.enabled !== "undefined"
143
150
  ? queryOptions?.enabled
144
- : typeof resource !== "undefined" && typeof id !== "undefined",
151
+ : typeof resource?.name !== "undefined" &&
152
+ typeof id !== "undefined",
145
153
  liveMode,
146
154
  onLiveEvent,
147
155
  });
@@ -154,7 +162,7 @@ export const useOne = <
154
162
  queryKey.detail(id),
155
163
  ({ queryKey, pageParam, signal }) =>
156
164
  getOne<TQueryFnData>({
157
- resource: resource!,
165
+ resource: resource?.name ?? "",
158
166
  id: id!,
159
167
  meta: {
160
168
  ...combinedMeta,
@@ -190,7 +198,7 @@ export const useOne = <
190
198
  id,
191
199
  ...combinedMeta,
192
200
  },
193
- resource,
201
+ identifier,
194
202
  )
195
203
  : successNotification;
196
204
 
@@ -208,12 +216,12 @@ export const useOne = <
208
216
  id,
209
217
  ...combinedMeta,
210
218
  },
211
- resource,
219
+ identifier,
212
220
  )
213
221
  : errorNotification;
214
222
 
215
223
  handleNotification(notificationConfig, {
216
- key: `${id}-${resource}-getOne-notification`,
224
+ key: `${id}-${identifier}-getOne-notification`,
217
225
  message: translate(
218
226
  "notifications.error",
219
227
  { statusCode: err.statusCode },
@@ -226,5 +234,11 @@ export const useOne = <
226
234
  },
227
235
  );
228
236
 
229
- return queryResponse;
237
+ const { elapsedTime } = useLoadingOvertime({
238
+ isLoading: queryResponse.isFetching,
239
+ interval: overtimeOptions?.interval,
240
+ onInterval: overtimeOptions?.onInterval,
241
+ });
242
+
243
+ return { ...queryResponse, overtime: { elapsedTime } };
230
244
  };