@refinedev/core 4.47.2 → 4.48.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 (409) hide show
  1. package/CHANGELOG.md +2944 -2919
  2. package/dist/components/authenticated/index.d.ts.map +1 -1
  3. package/dist/components/autoSaveIndicator/index.d.ts.map +1 -1
  4. package/dist/components/canAccess/index.d.ts.map +1 -1
  5. package/dist/components/containers/refine/index.d.ts.map +1 -1
  6. package/dist/components/layoutWrapper/index.d.ts.map +1 -1
  7. package/dist/components/pages/auth/components/forgotPassword/index.d.ts.map +1 -1
  8. package/dist/components/pages/auth/components/login/index.d.ts.map +1 -1
  9. package/dist/components/pages/auth/components/register/index.d.ts.map +1 -1
  10. package/dist/components/pages/auth/components/updatePassword/index.d.ts.map +1 -1
  11. package/dist/components/pages/auth/index.d.ts.map +1 -1
  12. package/dist/components/pages/config-error/index.d.ts.map +1 -1
  13. package/dist/components/pages/config-success/index.d.ts.map +1 -1
  14. package/dist/components/pages/login/index.d.ts.map +1 -1
  15. package/dist/components/pages/ready/index.d.ts.map +1 -1
  16. package/dist/components/undoableQueue/index.d.ts.map +1 -1
  17. package/dist/contexts/accessControl/IAccessControlContext.d.ts.map +1 -1
  18. package/dist/contexts/accessControl/index.d.ts.map +1 -1
  19. package/dist/contexts/auditLog/IAuditLogContext.d.ts.map +1 -1
  20. package/dist/contexts/auditLog/index.d.ts.map +1 -1
  21. package/dist/contexts/auth/IAuthContext.d.ts +1 -1
  22. package/dist/contexts/auth/IAuthContext.d.ts.map +1 -1
  23. package/dist/contexts/auth/index.d.ts.map +1 -1
  24. package/dist/contexts/data/IDataContext.d.ts.map +1 -1
  25. package/dist/contexts/data/index.d.ts.map +1 -1
  26. package/dist/contexts/legacy-router/IRouterContext.d.ts.map +1 -1
  27. package/dist/contexts/legacy-router/index.d.ts.map +1 -1
  28. package/dist/contexts/live/ILiveContext.d.ts.map +1 -1
  29. package/dist/contexts/live/index.d.ts.map +1 -1
  30. package/dist/contexts/notification/INotificationContext.d.ts.map +1 -1
  31. package/dist/contexts/notification/index.d.ts.map +1 -1
  32. package/dist/contexts/refine/IRefineContext.d.ts.map +1 -1
  33. package/dist/contexts/refine/index.d.ts.map +1 -1
  34. package/dist/contexts/resource/IResourceContext.d.ts.map +1 -1
  35. package/dist/contexts/resource/index.d.ts.map +1 -1
  36. package/dist/contexts/router/index.d.ts.map +1 -1
  37. package/dist/contexts/translation/ITranslationContext.d.ts.map +1 -1
  38. package/dist/contexts/translation/index.d.ts.map +1 -1
  39. package/dist/contexts/undoableQueue/IUndoableQueueContext.d.ts.map +1 -1
  40. package/dist/contexts/undoableQueue/actionTypes.d.ts.map +1 -1
  41. package/dist/contexts/undoableQueue/index.d.ts.map +1 -1
  42. package/dist/contexts/undoableQueue/undoableQueueContext.d.ts.map +1 -1
  43. package/dist/contexts/unsavedWarn/IUnsavedWarnContext.d.ts.map +1 -1
  44. package/dist/definitions/helpers/check-router-prop-misuse/index.d.ts.map +1 -1
  45. package/dist/definitions/helpers/downloadInBrowser/index.d.ts.map +1 -1
  46. package/dist/definitions/helpers/flatten-object-keys/index.d.ts.map +1 -1
  47. package/dist/definitions/helpers/generateDocumentTitle/index.d.ts.map +1 -1
  48. package/dist/definitions/helpers/handlePaginationParams/index.d.ts.map +1 -1
  49. package/dist/definitions/helpers/handleRefineOptions/index.d.ts.map +1 -1
  50. package/dist/definitions/helpers/hasPermission/index.d.ts.map +1 -1
  51. package/dist/definitions/helpers/importCSVMapper/index.d.ts.map +1 -1
  52. package/dist/definitions/helpers/index.d.ts.map +1 -1
  53. package/dist/definitions/helpers/keys/index.d.ts +0 -11
  54. package/dist/definitions/helpers/keys/index.d.ts.map +1 -1
  55. package/dist/definitions/helpers/legacy-resource-transform/index.d.ts.map +1 -1
  56. package/dist/definitions/helpers/menu/create-resource-key.d.ts.map +1 -1
  57. package/dist/definitions/helpers/menu/create-tree.d.ts.map +1 -1
  58. package/dist/definitions/helpers/pick-resource/index.d.ts.map +1 -1
  59. package/dist/definitions/helpers/pickDataProvider/index.d.ts.map +1 -1
  60. package/dist/definitions/helpers/queryKeys/index.d.ts.map +1 -1
  61. package/dist/definitions/helpers/redirectPage/index.d.ts.map +1 -1
  62. package/dist/definitions/helpers/routeGenerator/index.d.ts.map +1 -1
  63. package/dist/definitions/helpers/router/compose-route.d.ts.map +1 -1
  64. package/dist/definitions/helpers/router/get-action-routes-from-resource.d.ts.map +1 -1
  65. package/dist/definitions/helpers/router/get-default-action-path.d.ts.map +1 -1
  66. package/dist/definitions/helpers/router/get-parent-prefix-for-resource.d.ts.map +1 -1
  67. package/dist/definitions/helpers/router/get-parent-resource.d.ts.map +1 -1
  68. package/dist/definitions/helpers/router/match-resource-from-route.d.ts.map +1 -1
  69. package/dist/definitions/helpers/router/pick-matched-route.d.ts.map +1 -1
  70. package/dist/definitions/helpers/router/prepare-route-params.d.ts.map +1 -1
  71. package/dist/definitions/helpers/safe-translate/index.d.ts.map +1 -1
  72. package/dist/definitions/helpers/sanitize-resource/index.d.ts.map +1 -1
  73. package/dist/definitions/helpers/sequentialPromises/index.d.ts.map +1 -1
  74. package/dist/definitions/helpers/treeView/createTreeView/index.d.ts.map +1 -1
  75. package/dist/definitions/helpers/useActiveAuthProvider/index.d.ts +2 -2
  76. package/dist/definitions/helpers/useUserFriendlyName/index.d.ts.map +1 -1
  77. package/dist/definitions/helpers/userFriendlyResourceName/index.d.ts.map +1 -1
  78. package/dist/definitions/table/index.d.ts.map +1 -1
  79. package/dist/esm/index.js +18 -18
  80. package/dist/esm/index.js.map +1 -1
  81. package/dist/hooks/accessControl/useCan/index.d.ts.map +1 -1
  82. package/dist/hooks/accessControl/useCanWithoutCache.d.ts.map +1 -1
  83. package/dist/hooks/auditLog/useLog/index.d.ts.map +1 -1
  84. package/dist/hooks/auditLog/useLogList/index.d.ts.map +1 -1
  85. package/dist/hooks/auth/useForgotPassword/index.d.ts.map +1 -1
  86. package/dist/hooks/auth/useGetIdentity/index.d.ts.map +1 -1
  87. package/dist/hooks/auth/useIsAuthenticated/index.d.ts.map +1 -1
  88. package/dist/hooks/auth/useLogin/index.d.ts.map +1 -1
  89. package/dist/hooks/auth/useLogout/index.d.ts.map +1 -1
  90. package/dist/hooks/auth/useOnError/index.d.ts.map +1 -1
  91. package/dist/hooks/auth/usePermissions/index.d.ts +9 -6
  92. package/dist/hooks/auth/usePermissions/index.d.ts.map +1 -1
  93. package/dist/hooks/auth/useRegister/index.d.ts.map +1 -1
  94. package/dist/hooks/auth/useUpdatePassword/index.d.ts.map +1 -1
  95. package/dist/hooks/breadcrumb/index.d.ts.map +1 -1
  96. package/dist/hooks/data/useApiUrl.d.ts.map +1 -1
  97. package/dist/hooks/data/useCreate.d.ts.map +1 -1
  98. package/dist/hooks/data/useCreateMany.d.ts.map +1 -1
  99. package/dist/hooks/data/useCustom.d.ts.map +1 -1
  100. package/dist/hooks/data/useCustomMutation.d.ts.map +1 -1
  101. package/dist/hooks/data/useDataProvider.d.ts.map +1 -1
  102. package/dist/hooks/data/useDelete.d.ts.map +1 -1
  103. package/dist/hooks/data/useDeleteMany.d.ts.map +1 -1
  104. package/dist/hooks/data/useInfiniteList.d.ts.map +1 -1
  105. package/dist/hooks/data/useList.d.ts.map +1 -1
  106. package/dist/hooks/data/useMany.d.ts.map +1 -1
  107. package/dist/hooks/data/useOne.d.ts.map +1 -1
  108. package/dist/hooks/data/useUpdate.d.ts.map +1 -1
  109. package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
  110. package/dist/hooks/export/csvDownload.interface.d.ts.map +1 -1
  111. package/dist/hooks/export/index.d.ts +1 -1
  112. package/dist/hooks/export/index.d.ts.map +1 -1
  113. package/dist/hooks/form/useForm.d.ts.map +1 -1
  114. package/dist/hooks/import/index.d.ts.map +1 -1
  115. package/dist/hooks/invalidate/index.d.ts.map +1 -1
  116. package/dist/hooks/live/useLiveMode/index.d.ts.map +1 -1
  117. package/dist/hooks/live/useResourceSubscription/index.d.ts.map +1 -1
  118. package/dist/hooks/live/useSubscription/index.d.ts.map +1 -1
  119. package/dist/hooks/menu/useMenu.d.ts.map +1 -1
  120. package/dist/hooks/modal/useModal/index.d.ts.map +1 -1
  121. package/dist/hooks/navigation/index.d.ts.map +1 -1
  122. package/dist/hooks/notification/useCancelNotification/index.d.ts.map +1 -1
  123. package/dist/hooks/notification/useHandleNotification/index.d.ts.map +1 -1
  124. package/dist/hooks/redirection/index.d.ts.map +1 -1
  125. package/dist/hooks/refine/useMutationMode.d.ts.map +1 -1
  126. package/dist/hooks/refine/useSyncWithLocation.d.ts.map +1 -1
  127. package/dist/hooks/refine/useWarnAboutChange/index.d.ts.map +1 -1
  128. package/dist/hooks/resource/useResource/index.d.ts.map +1 -1
  129. package/dist/hooks/router/use-get-to-path/index.d.ts.map +1 -1
  130. package/dist/hooks/router/use-go/index.d.ts.map +1 -1
  131. package/dist/hooks/router/use-link/index.d.ts.map +1 -1
  132. package/dist/hooks/router/use-parse/index.d.ts.map +1 -1
  133. package/dist/hooks/router/use-to-path/index.d.ts.map +1 -1
  134. package/dist/hooks/show/useShow.d.ts.map +1 -1
  135. package/dist/hooks/translate/useSetLocale.d.ts.map +1 -1
  136. package/dist/hooks/translate/useTranslate.d.ts.map +1 -1
  137. package/dist/hooks/useLoadingOvertime/index.d.ts.map +1 -1
  138. package/dist/hooks/useSelect/index.d.ts +18 -4
  139. package/dist/hooks/useSelect/index.d.ts.map +1 -1
  140. package/dist/hooks/useTable/index.d.ts.map +1 -1
  141. package/dist/iife/index.js +18 -18
  142. package/dist/iife/index.js.map +1 -1
  143. package/dist/index.d.ts.map +1 -1
  144. package/dist/index.js +18 -18
  145. package/dist/index.js.map +1 -1
  146. package/dist/interfaces/actions.d.ts.map +1 -1
  147. package/dist/interfaces/auditLog/logData.d.ts.map +1 -1
  148. package/dist/interfaces/auth.d.ts.map +1 -1
  149. package/dist/interfaces/autoSave.d.ts.map +1 -1
  150. package/dist/interfaces/bindings/access-control.d.ts.map +1 -1
  151. package/dist/interfaces/bindings/auth.d.ts +1 -1
  152. package/dist/interfaces/bindings/auth.d.ts.map +1 -1
  153. package/dist/interfaces/bindings/data.d.ts.map +1 -1
  154. package/dist/interfaces/bindings/i18n.d.ts.map +1 -1
  155. package/dist/interfaces/bindings/index.d.ts.map +1 -1
  156. package/dist/interfaces/bindings/live.d.ts.map +1 -1
  157. package/dist/interfaces/bindings/notifications.d.ts.map +1 -1
  158. package/dist/interfaces/bindings/resource.d.ts.map +1 -1
  159. package/dist/interfaces/bindings/router.d.ts.map +1 -1
  160. package/dist/interfaces/customComponents.d.ts.map +1 -1
  161. package/dist/interfaces/errors/HttpError.d.ts.map +1 -1
  162. package/dist/interfaces/form-url-params.d.ts.map +1 -1
  163. package/dist/interfaces/index.d.ts.map +1 -1
  164. package/dist/interfaces/live/LiveEvent.d.ts.map +1 -1
  165. package/dist/interfaces/live/LiveModeProps.d.ts.map +1 -1
  166. package/dist/interfaces/mapDataFn.d.ts.map +1 -1
  167. package/dist/interfaces/metaData/graphqlQueryOptions.d.ts.map +1 -1
  168. package/dist/interfaces/metaData/metaDataQuery.d.ts.map +1 -1
  169. package/dist/interfaces/metaData/metaQuery.d.ts.map +1 -1
  170. package/dist/interfaces/metaData/nestedField.d.ts.map +1 -1
  171. package/dist/interfaces/metaData/queryBuilderOptions.d.ts.map +1 -1
  172. package/dist/interfaces/metaData/variableOptions.d.ts.map +1 -1
  173. package/dist/interfaces/mutationMode.d.ts.map +1 -1
  174. package/dist/interfaces/notification.d.ts.map +1 -1
  175. package/dist/interfaces/optimistic-update-map.d.ts.map +1 -1
  176. package/dist/interfaces/prettify.d.ts.map +1 -1
  177. package/dist/interfaces/queryKey.d.ts.map +1 -1
  178. package/dist/interfaces/resourceErrorRouterParams.d.ts.map +1 -1
  179. package/dist/interfaces/resourceRouterParams.d.ts.map +1 -1
  180. package/dist/interfaces/successErrorNotification.d.ts +4 -4
  181. package/dist/interfaces/successErrorNotification.d.ts.map +1 -1
  182. package/dist/interfaces/telemetry.d.ts.map +1 -1
  183. package/dist/interfaces/textTransformers.d.ts.map +1 -1
  184. package/package.json +2 -2
  185. package/refine.config.js +99 -102
  186. package/src/components/authenticated/index.tsx +157 -159
  187. package/src/components/autoSaveIndicator/index.tsx +23 -27
  188. package/src/components/canAccess/index.tsx +93 -93
  189. package/src/components/containers/refine/index.tsx +312 -353
  190. package/src/components/gh-banner/index.tsx +235 -242
  191. package/src/components/gh-banner/styles.ts +5 -5
  192. package/src/components/layoutWrapper/defaultLayout/index.tsx +1 -1
  193. package/src/components/layoutWrapper/index.tsx +87 -87
  194. package/src/components/pages/auth/components/forgotPassword/index.tsx +87 -96
  195. package/src/components/pages/auth/components/login/index.tsx +166 -181
  196. package/src/components/pages/auth/components/register/index.tsx +141 -159
  197. package/src/components/pages/auth/components/updatePassword/index.tsx +81 -87
  198. package/src/components/pages/auth/index.tsx +28 -28
  199. package/src/components/pages/config-error/index.tsx +422 -422
  200. package/src/components/pages/config-success/index.tsx +249 -260
  201. package/src/components/pages/error/index.tsx +48 -48
  202. package/src/components/pages/login/index.tsx +59 -73
  203. package/src/components/pages/ready/index.tsx +21 -29
  204. package/src/components/pages/welcome/index.tsx +7 -7
  205. package/src/components/routeChangeHandler/index.tsx +7 -7
  206. package/src/components/telemetry/index.tsx +31 -31
  207. package/src/components/undoableQueue/index.tsx +49 -49
  208. package/src/contexts/accessControl/IAccessControlContext.ts +34 -34
  209. package/src/contexts/accessControl/index.tsx +35 -35
  210. package/src/contexts/auditLog/IAuditLogContext.ts +22 -22
  211. package/src/contexts/auditLog/index.tsx +8 -8
  212. package/src/contexts/auth/IAuthContext.ts +10 -10
  213. package/src/contexts/auth/index.tsx +169 -169
  214. package/src/contexts/data/IDataContext.ts +203 -203
  215. package/src/contexts/data/index.tsx +18 -18
  216. package/src/contexts/legacy-router/IRouterContext.ts +23 -27
  217. package/src/contexts/legacy-router/index.tsx +30 -30
  218. package/src/contexts/live/ILiveContext.ts +49 -49
  219. package/src/contexts/live/index.tsx +5 -7
  220. package/src/contexts/notification/INotificationContext.ts +8 -8
  221. package/src/contexts/notification/index.tsx +8 -8
  222. package/src/contexts/refine/IRefineContext.ts +119 -119
  223. package/src/contexts/refine/index.tsx +80 -80
  224. package/src/contexts/resource/IResourceContext.ts +35 -35
  225. package/src/contexts/resource/index.tsx +16 -16
  226. package/src/contexts/router/index.tsx +7 -7
  227. package/src/contexts/router-picker/index.tsx +2 -2
  228. package/src/contexts/translation/ITranslationContext.ts +7 -7
  229. package/src/contexts/translation/index.tsx +12 -12
  230. package/src/contexts/undoableQueue/IUndoableQueueContext.ts +2 -2
  231. package/src/contexts/undoableQueue/actionTypes.ts +3 -3
  232. package/src/contexts/undoableQueue/index.ts +2 -2
  233. package/src/contexts/undoableQueue/undoableQueueContext.tsx +59 -60
  234. package/src/contexts/unsavedWarn/IUnsavedWarnContext.ts +2 -2
  235. package/src/contexts/unsavedWarn/index.tsx +7 -7
  236. package/src/definitions/helpers/check-router-prop-misuse/index.ts +20 -20
  237. package/src/definitions/helpers/downloadInBrowser/index.ts +19 -20
  238. package/src/definitions/helpers/flatten-object-keys/index.ts +26 -29
  239. package/src/definitions/helpers/generateDocumentTitle/index.ts +39 -45
  240. package/src/definitions/helpers/handleMultiple/index.ts +4 -4
  241. package/src/definitions/helpers/handlePaginationParams/index.ts +17 -18
  242. package/src/definitions/helpers/handleRefineOptions/index.ts +88 -90
  243. package/src/definitions/helpers/handleUseParams/index.tsx +7 -7
  244. package/src/definitions/helpers/hasPermission/index.ts +6 -6
  245. package/src/definitions/helpers/humanizeString/index.ts +9 -9
  246. package/src/definitions/helpers/importCSVMapper/index.ts +8 -8
  247. package/src/definitions/helpers/index.ts +2 -2
  248. package/src/definitions/helpers/keys/index.ts +205 -258
  249. package/src/definitions/helpers/legacy-resource-transform/index.ts +14 -14
  250. package/src/definitions/helpers/menu/create-resource-key.ts +20 -23
  251. package/src/definitions/helpers/menu/create-tree.ts +61 -63
  252. package/src/definitions/helpers/pick-resource/index.ts +25 -25
  253. package/src/definitions/helpers/pickDataProvider/index.ts +15 -15
  254. package/src/definitions/helpers/pickNotDeprecated/index.ts +2 -2
  255. package/src/definitions/helpers/property-path-to-array/index.ts +3 -3
  256. package/src/definitions/helpers/queryKeys/index.ts +92 -92
  257. package/src/definitions/helpers/redirectPage/index.ts +19 -19
  258. package/src/definitions/helpers/routeGenerator/index.ts +15 -15
  259. package/src/definitions/helpers/router/__tests__/check-by-segments.ts +12 -15
  260. package/src/definitions/helpers/router/__tests__/compose-route.ts +48 -48
  261. package/src/definitions/helpers/router/__tests__/get-action-routes-from-resource.ts +152 -152
  262. package/src/definitions/helpers/router/__tests__/get-default-action-path.ts +39 -41
  263. package/src/definitions/helpers/router/__tests__/get-parent-prefix-for-resource.ts +69 -73
  264. package/src/definitions/helpers/router/__tests__/get-parent-resource.ts +40 -40
  265. package/src/definitions/helpers/router/__tests__/is-segment-counts-same.ts +11 -14
  266. package/src/definitions/helpers/router/__tests__/match-resource-from-route.ts +55 -55
  267. package/src/definitions/helpers/router/__tests__/pick-matched-route.ts +74 -74
  268. package/src/definitions/helpers/router/__tests__/pick-route-params.ts +12 -12
  269. package/src/definitions/helpers/router/__tests__/prepare-route-params.ts +18 -18
  270. package/src/definitions/helpers/router/__tests__/remove-leading-trailing-slashes.ts +9 -9
  271. package/src/definitions/helpers/router/__tests__/split-to-segments.ts +9 -9
  272. package/src/definitions/helpers/router/check-by-segments.ts +12 -12
  273. package/src/definitions/helpers/router/compose-route.ts +25 -27
  274. package/src/definitions/helpers/router/get-action-routes-from-resource.ts +41 -47
  275. package/src/definitions/helpers/router/get-default-action-path.ts +19 -19
  276. package/src/definitions/helpers/router/get-parent-prefix-for-resource.ts +22 -24
  277. package/src/definitions/helpers/router/get-parent-resource.ts +18 -18
  278. package/src/definitions/helpers/router/is-parameter.ts +1 -1
  279. package/src/definitions/helpers/router/is-segment-counts-same.ts +3 -3
  280. package/src/definitions/helpers/router/match-resource-from-route.ts +19 -19
  281. package/src/definitions/helpers/router/pick-matched-route.ts +44 -44
  282. package/src/definitions/helpers/router/pick-route-params.ts +7 -7
  283. package/src/definitions/helpers/router/prepare-route-params.ts +13 -10
  284. package/src/definitions/helpers/router/remove-leading-trailing-slashes.ts +1 -1
  285. package/src/definitions/helpers/router/split-to-segments.ts +2 -2
  286. package/src/definitions/helpers/safe-translate/index.ts +12 -12
  287. package/src/definitions/helpers/sanitize-resource/index.ts +26 -27
  288. package/src/definitions/helpers/sequentialPromises/index.ts +21 -21
  289. package/src/definitions/helpers/treeView/createTreeView/index.ts +33 -33
  290. package/src/definitions/helpers/useActiveAuthProvider/index.ts +18 -18
  291. package/src/definitions/helpers/useInfinitePagination/index.ts +16 -16
  292. package/src/definitions/helpers/useMediaQuery/index.ts +11 -11
  293. package/src/definitions/helpers/useUserFriendlyName/index.ts +11 -14
  294. package/src/definitions/helpers/userFriendlyResourceName/index.ts +7 -7
  295. package/src/definitions/helpers/userFriendlySeconds/index.ts +1 -1
  296. package/src/definitions/table/index.ts +127 -130
  297. package/src/definitions/upload/file2Base64/index.ts +15 -15
  298. package/src/hooks/accessControl/useCan/index.ts +52 -54
  299. package/src/hooks/accessControl/useCanWithoutCache.ts +25 -26
  300. package/src/hooks/auditLog/useLog/index.ts +114 -114
  301. package/src/hooks/auditLog/useLogList/index.ts +44 -44
  302. package/src/hooks/auth/useForgotPassword/index.ts +158 -163
  303. package/src/hooks/auth/useGetIdentity/index.ts +55 -57
  304. package/src/hooks/auth/useInvalidateAuthStore/index.ts +12 -12
  305. package/src/hooks/auth/useIsAuthenticated/index.ts +44 -48
  306. package/src/hooks/auth/useIsExistAuthentication/index.ts +3 -3
  307. package/src/hooks/auth/useLogin/index.ts +181 -194
  308. package/src/hooks/auth/useLogout/index.ts +175 -177
  309. package/src/hooks/auth/useOnError/index.ts +76 -76
  310. package/src/hooks/auth/usePermissions/index.ts +94 -61
  311. package/src/hooks/auth/useRegister/index.ts +166 -178
  312. package/src/hooks/auth/useUpdatePassword/index.ts +183 -194
  313. package/src/hooks/breadcrumb/index.ts +99 -106
  314. package/src/hooks/data/useApiUrl.ts +7 -8
  315. package/src/hooks/data/useCreate.ts +241 -241
  316. package/src/hooks/data/useCreateMany.ts +219 -226
  317. package/src/hooks/data/useCustom.ts +181 -182
  318. package/src/hooks/data/useCustomMutation.ts +174 -174
  319. package/src/hooks/data/useDataProvider.tsx +27 -29
  320. package/src/hooks/data/useDelete.ts +447 -454
  321. package/src/hooks/data/useDeleteMany.ts +475 -484
  322. package/src/hooks/data/useInfiniteList.ts +280 -280
  323. package/src/hooks/data/useList.ts +280 -283
  324. package/src/hooks/data/useMany.ts +215 -216
  325. package/src/hooks/data/useOne.ts +210 -211
  326. package/src/hooks/data/useUpdate.ts +529 -556
  327. package/src/hooks/data/useUpdateMany.ts +556 -584
  328. package/src/hooks/deepMemo/index.tsx +5 -5
  329. package/src/hooks/export/csvDownload.interface.ts +13 -13
  330. package/src/hooks/export/index.ts +223 -217
  331. package/src/hooks/form/useForm.ts +543 -560
  332. package/src/hooks/import/index.tsx +254 -260
  333. package/src/hooks/invalidate/index.tsx +75 -75
  334. package/src/hooks/legacy-router/useRouterContext.ts +11 -11
  335. package/src/hooks/live/useLiveMode/index.ts +4 -4
  336. package/src/hooks/live/usePublish/index.ts +2 -2
  337. package/src/hooks/live/useResourceSubscription/index.ts +103 -103
  338. package/src/hooks/live/useSubscription/index.ts +77 -77
  339. package/src/hooks/memoized/index.tsx +6 -6
  340. package/src/hooks/menu/useMenu.tsx +113 -120
  341. package/src/hooks/modal/useModal/index.tsx +16 -16
  342. package/src/hooks/navigation/index.ts +362 -392
  343. package/src/hooks/notification/useCancelNotification/index.tsx +5 -5
  344. package/src/hooks/notification/useHandleNotification/index.ts +17 -17
  345. package/src/hooks/notification/useNotification/index.ts +2 -2
  346. package/src/hooks/redirection/index.ts +45 -46
  347. package/src/hooks/refine/useMutationMode.ts +4 -4
  348. package/src/hooks/refine/useRefineContext.ts +36 -36
  349. package/src/hooks/refine/useSyncWithLocation.ts +3 -3
  350. package/src/hooks/refine/useTitle.tsx +2 -2
  351. package/src/hooks/refine/useWarnAboutChange/index.ts +12 -12
  352. package/src/hooks/resource/useResource/index.ts +141 -146
  353. package/src/hooks/resource/useResourceWithRoute/index.ts +12 -12
  354. package/src/hooks/router/use-back/index.tsx +7 -7
  355. package/src/hooks/router/use-get-to-path/index.ts +35 -35
  356. package/src/hooks/router/use-go/index.tsx +66 -66
  357. package/src/hooks/router/use-link/index.tsx +8 -9
  358. package/src/hooks/router/use-parse/index.tsx +13 -13
  359. package/src/hooks/router/use-parsed/index.tsx +4 -4
  360. package/src/hooks/router/use-router-misuse-warning/index.ts +10 -10
  361. package/src/hooks/router/use-to-path/index.ts +10 -10
  362. package/src/hooks/show/useShow.ts +135 -135
  363. package/src/hooks/translate/useGetLocale.ts +2 -2
  364. package/src/hooks/translate/useSetLocale.ts +2 -2
  365. package/src/hooks/translate/useTranslate.ts +24 -25
  366. package/src/hooks/useKeys/index.tsx +7 -7
  367. package/src/hooks/useLoadingOvertime/index.ts +74 -76
  368. package/src/hooks/useMeta/index.ts +20 -20
  369. package/src/hooks/useSelect/index.ts +317 -277
  370. package/src/hooks/useTable/index.ts +483 -507
  371. package/src/hooks/useTelemetryData/index.ts +48 -48
  372. package/src/index.tsx +125 -125
  373. package/src/interfaces/actions.ts +2 -2
  374. package/src/interfaces/auditLog/logData.ts +9 -9
  375. package/src/interfaces/auth.tsx +176 -176
  376. package/src/interfaces/autoSave.ts +37 -37
  377. package/src/interfaces/bindings/access-control.ts +21 -21
  378. package/src/interfaces/bindings/auth.ts +27 -25
  379. package/src/interfaces/bindings/data.ts +2 -2
  380. package/src/interfaces/bindings/i18n.ts +8 -8
  381. package/src/interfaces/bindings/index.ts +15 -15
  382. package/src/interfaces/bindings/live.ts +28 -28
  383. package/src/interfaces/bindings/notifications.ts +8 -8
  384. package/src/interfaces/bindings/resource.ts +127 -127
  385. package/src/interfaces/bindings/router.ts +26 -26
  386. package/src/interfaces/customComponents.ts +17 -17
  387. package/src/interfaces/errors/HttpError.ts +8 -8
  388. package/src/interfaces/form-url-params.ts +6 -6
  389. package/src/interfaces/index.ts +8 -10
  390. package/src/interfaces/live/LiveEvent.ts +10 -10
  391. package/src/interfaces/live/LiveModeProps.ts +21 -21
  392. package/src/interfaces/mapDataFn.ts +1 -1
  393. package/src/interfaces/metaData/graphqlQueryOptions.ts +49 -49
  394. package/src/interfaces/metaData/metaDataQuery.ts +2 -2
  395. package/src/interfaces/metaData/metaQuery.ts +3 -3
  396. package/src/interfaces/metaData/nestedField.ts +3 -3
  397. package/src/interfaces/metaData/queryBuilderOptions.ts +3 -3
  398. package/src/interfaces/metaData/variableOptions.ts +8 -8
  399. package/src/interfaces/mutationMode.ts +14 -14
  400. package/src/interfaces/notification.ts +7 -7
  401. package/src/interfaces/optimistic-update-map.ts +42 -42
  402. package/src/interfaces/prettify.ts +1 -1
  403. package/src/interfaces/queryKey.ts +16 -16
  404. package/src/interfaces/resourceErrorRouterParams.ts +2 -2
  405. package/src/interfaces/resourceRouterParams.ts +3 -3
  406. package/src/interfaces/successErrorNotification.ts +24 -24
  407. package/src/interfaces/telemetry.ts +13 -13
  408. package/src/interfaces/textTransformers.ts +18 -18
  409. package/tsconfig.json +26 -26
@@ -1,140 +1,140 @@
1
1
  import { getXRay } from "@refinedev/devtools-internal";
2
2
  import {
3
- useMutation,
4
- UseMutationOptions,
5
- UseMutationResult,
6
- useQueryClient,
3
+ useMutation,
4
+ UseMutationOptions,
5
+ UseMutationResult,
6
+ useQueryClient,
7
7
  } from "@tanstack/react-query";
8
8
 
9
9
  import { ActionTypes } from "@contexts/undoableQueue";
10
10
  import {
11
- handleMultiple,
12
- pickDataProvider,
13
- pickNotDeprecated,
14
- queryKeysReplacement,
15
- useActiveAuthProvider,
11
+ handleMultiple,
12
+ pickDataProvider,
13
+ pickNotDeprecated,
14
+ queryKeysReplacement,
15
+ useActiveAuthProvider,
16
16
  } from "@definitions/helpers";
17
17
  import {
18
- useCancelNotification,
19
- useDataProvider,
20
- useHandleNotification,
21
- useInvalidate,
22
- useLog,
23
- useMeta,
24
- useMutationMode,
25
- useOnError,
26
- usePublish,
27
- useRefineContext,
28
- useResource,
29
- useTranslate,
18
+ useCancelNotification,
19
+ useDataProvider,
20
+ useHandleNotification,
21
+ useInvalidate,
22
+ useLog,
23
+ useMeta,
24
+ useMutationMode,
25
+ useOnError,
26
+ usePublish,
27
+ useRefineContext,
28
+ useResource,
29
+ useTranslate,
30
30
  } from "@hooks";
31
31
  import { useKeys } from "@hooks/useKeys";
32
32
  import {
33
- BaseKey,
34
- BaseRecord,
35
- GetListResponse,
36
- GetManyResponse,
37
- GetOneResponse,
38
- HttpError,
39
- IQueryKeys,
40
- MetaQuery,
41
- MutationMode,
42
- OptimisticUpdateManyMapType,
43
- PrevContext as UpdateContext,
44
- QueryResponse,
45
- SuccessErrorNotification,
46
- UpdateManyResponse,
33
+ BaseKey,
34
+ BaseRecord,
35
+ GetListResponse,
36
+ GetManyResponse,
37
+ GetOneResponse,
38
+ HttpError,
39
+ IQueryKeys,
40
+ MetaQuery,
41
+ MutationMode,
42
+ OptimisticUpdateManyMapType,
43
+ PrevContext as UpdateContext,
44
+ QueryResponse,
45
+ SuccessErrorNotification,
46
+ UpdateManyResponse,
47
47
  } from "../../interfaces";
48
48
  import {
49
- useLoadingOvertime,
50
- UseLoadingOvertimeOptionsProps,
51
- UseLoadingOvertimeReturnType,
49
+ useLoadingOvertime,
50
+ UseLoadingOvertimeOptionsProps,
51
+ UseLoadingOvertimeReturnType,
52
52
  } from "../useLoadingOvertime";
53
53
 
54
54
  type UpdateManyParams<TData, TError, TVariables> = {
55
- /**
56
- * ids for mutation function
57
- */
58
- ids: BaseKey[];
59
- /**
60
- * Resource name for API data interactions
61
- */
62
- resource: string;
63
- /**
64
- * [Determines when mutations are executed](/advanced-tutorials/mutation-mode.md)
65
- */
66
- mutationMode?: MutationMode;
67
- /**
68
- * Duration in ms to wait before executing the mutation when `mutationMode = "undoable"`
69
- */
70
- undoableTimeout?: number;
71
- /**
72
- * Provides a function to cancel the mutation when `mutationMode = "undoable"`
73
- */
74
- onCancel?: (cancelMutation: () => void) => void;
75
- /**
76
- * Values for mutation function
77
- */
78
- values: TVariables;
79
- /**
80
- * meta data for `dataProvider`
81
- */
82
- meta?: MetaQuery;
83
- /**
84
- * meta data for `dataProvider`
85
- * @deprecated `metaData` is deprecated with refine@4, refine will pass `meta` instead, however, we still support `metaData` for backward compatibility.
86
- */
87
- metaData?: MetaQuery;
88
- /**
89
- * If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use.
90
- * @default "default"
91
- */
92
- dataProviderName?: string;
93
- /**
94
- * You can use it to manage the invalidations that will occur at the end of the mutation.
95
- */
96
- invalidates?: Array<keyof IQueryKeys>;
97
- /**
98
- * You can use it to manage the invalidations that will occur at the end of the mutation.
99
- * @default {
100
- * list: true,
101
- * many: true,
102
- * detail: true,
103
- * }
104
- */
105
- optimisticUpdateMap?: OptimisticUpdateManyMapType<TData, TVariables>;
55
+ /**
56
+ * ids for mutation function
57
+ */
58
+ ids: BaseKey[];
59
+ /**
60
+ * Resource name for API data interactions
61
+ */
62
+ resource: string;
63
+ /**
64
+ * [Determines when mutations are executed](/advanced-tutorials/mutation-mode.md)
65
+ */
66
+ mutationMode?: MutationMode;
67
+ /**
68
+ * Duration in ms to wait before executing the mutation when `mutationMode = "undoable"`
69
+ */
70
+ undoableTimeout?: number;
71
+ /**
72
+ * Provides a function to cancel the mutation when `mutationMode = "undoable"`
73
+ */
74
+ onCancel?: (cancelMutation: () => void) => void;
75
+ /**
76
+ * Values for mutation function
77
+ */
78
+ values: TVariables;
79
+ /**
80
+ * meta data for `dataProvider`
81
+ */
82
+ meta?: MetaQuery;
83
+ /**
84
+ * meta data for `dataProvider`
85
+ * @deprecated `metaData` is deprecated with refine@4, refine will pass `meta` instead, however, we still support `metaData` for backward compatibility.
86
+ */
87
+ metaData?: MetaQuery;
88
+ /**
89
+ * If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use.
90
+ * @default "default"
91
+ */
92
+ dataProviderName?: string;
93
+ /**
94
+ * You can use it to manage the invalidations that will occur at the end of the mutation.
95
+ */
96
+ invalidates?: Array<keyof IQueryKeys>;
97
+ /**
98
+ * You can use it to manage the invalidations that will occur at the end of the mutation.
99
+ * @default {
100
+ * list: true,
101
+ * many: true,
102
+ * detail: true,
103
+ * }
104
+ */
105
+ optimisticUpdateMap?: OptimisticUpdateManyMapType<TData, TVariables>;
106
106
  } & SuccessErrorNotification<
107
- UpdateManyResponse<TData>,
108
- TError,
109
- { ids: BaseKey[]; values: TVariables }
107
+ UpdateManyResponse<TData>,
108
+ TError,
109
+ { ids: BaseKey[]; values: TVariables }
110
110
  >;
111
111
 
112
112
  type UseUpdateManyReturnType<
113
- TData extends BaseRecord = BaseRecord,
114
- TError extends HttpError = HttpError,
115
- TVariables = {},
113
+ TData extends BaseRecord = BaseRecord,
114
+ TError extends HttpError = HttpError,
115
+ TVariables = {},
116
116
  > = UseMutationResult<
117
- UpdateManyResponse<TData>,
118
- TError,
119
- UpdateManyParams<TData, TError, TVariables>,
120
- UpdateContext<TData>
117
+ UpdateManyResponse<TData>,
118
+ TError,
119
+ UpdateManyParams<TData, TError, TVariables>,
120
+ UpdateContext<TData>
121
121
  > &
122
- UseLoadingOvertimeReturnType;
122
+ UseLoadingOvertimeReturnType;
123
123
 
124
124
  export type UseUpdateManyProps<
125
- TData extends BaseRecord = BaseRecord,
126
- TError extends HttpError = HttpError,
127
- TVariables = {},
125
+ TData extends BaseRecord = BaseRecord,
126
+ TError extends HttpError = HttpError,
127
+ TVariables = {},
128
128
  > = {
129
- mutationOptions?: Omit<
130
- UseMutationOptions<
131
- UpdateManyResponse<TData>,
132
- TError,
133
- UpdateManyParams<TData, TError, TVariables>,
134
- UpdateContext<TData>
135
- >,
136
- "mutationFn" | "onError" | "onSuccess" | "onSettled" | "onMutate"
137
- >;
129
+ mutationOptions?: Omit<
130
+ UseMutationOptions<
131
+ UpdateManyResponse<TData>,
132
+ TError,
133
+ UpdateManyParams<TData, TError, TVariables>,
134
+ UpdateContext<TData>
135
+ >,
136
+ "mutationFn" | "onError" | "onSuccess" | "onSettled" | "onMutate"
137
+ >;
138
138
  } & UseLoadingOvertimeOptionsProps;
139
139
 
140
140
  /**
@@ -150,493 +150,465 @@ export type UseUpdateManyProps<
150
150
  *
151
151
  */
152
152
  export const useUpdateMany = <
153
- TData extends BaseRecord = BaseRecord,
154
- TError extends HttpError = HttpError,
155
- TVariables = {},
153
+ TData extends BaseRecord = BaseRecord,
154
+ TError extends HttpError = HttpError,
155
+ TVariables = {},
156
156
  >({
157
- mutationOptions,
158
- overtimeOptions,
157
+ mutationOptions,
158
+ overtimeOptions,
159
159
  }: UseUpdateManyProps<TData, TError, TVariables> = {}): UseUpdateManyReturnType<
160
- TData,
161
- TError,
162
- TVariables
160
+ TData,
161
+ TError,
162
+ TVariables
163
163
  > => {
164
- const { resources, select } = useResource();
165
- const queryClient = useQueryClient();
166
- const dataProvider = useDataProvider();
167
- const translate = useTranslate();
168
- const {
169
- mutationMode: mutationModeContext,
170
- undoableTimeout: undoableTimeoutContext,
171
- } = useMutationMode();
172
- const authProvider = useActiveAuthProvider();
173
- const { mutate: checkError } = useOnError({
174
- v3LegacyAuthProviderCompatible: Boolean(authProvider?.isLegacy),
175
- });
176
- const { notificationDispatch } = useCancelNotification();
177
- const publish = usePublish();
178
- const handleNotification = useHandleNotification();
179
- const invalidateStore = useInvalidate();
180
- const { log } = useLog();
181
- const getMeta = useMeta();
182
- const {
183
- options: { textTransformers },
184
- } = useRefineContext();
185
- const { keys, preferLegacyKeys } = useKeys();
186
-
187
- const mutation = useMutation<
188
- UpdateManyResponse<TData>,
189
- TError,
190
- UpdateManyParams<TData, TError, TVariables>,
191
- UpdateContext<TData>
192
- >({
193
- mutationFn: ({
164
+ const { resources, select } = useResource();
165
+ const queryClient = useQueryClient();
166
+ const dataProvider = useDataProvider();
167
+ const translate = useTranslate();
168
+ const {
169
+ mutationMode: mutationModeContext,
170
+ undoableTimeout: undoableTimeoutContext,
171
+ } = useMutationMode();
172
+ const authProvider = useActiveAuthProvider();
173
+ const { mutate: checkError } = useOnError({
174
+ v3LegacyAuthProviderCompatible: Boolean(authProvider?.isLegacy),
175
+ });
176
+ const { notificationDispatch } = useCancelNotification();
177
+ const publish = usePublish();
178
+ const handleNotification = useHandleNotification();
179
+ const invalidateStore = useInvalidate();
180
+ const { log } = useLog();
181
+ const getMeta = useMeta();
182
+ const {
183
+ options: { textTransformers },
184
+ } = useRefineContext();
185
+ const { keys, preferLegacyKeys } = useKeys();
186
+
187
+ const mutation = useMutation<
188
+ UpdateManyResponse<TData>,
189
+ TError,
190
+ UpdateManyParams<TData, TError, TVariables>,
191
+ UpdateContext<TData>
192
+ >({
193
+ mutationFn: ({
194
+ ids,
195
+ values,
196
+ resource: resourceName,
197
+ onCancel,
198
+ mutationMode,
199
+ undoableTimeout,
200
+ meta,
201
+ metaData,
202
+ dataProviderName,
203
+ }: UpdateManyParams<TData, TError, TVariables>) => {
204
+ const { resource, identifier } = select(resourceName);
205
+
206
+ const combinedMeta = getMeta({
207
+ resource,
208
+ meta: pickNotDeprecated(meta, metaData),
209
+ });
210
+
211
+ const mutationModePropOrContext = mutationMode ?? mutationModeContext;
212
+
213
+ const undoableTimeoutPropOrContext =
214
+ undoableTimeout ?? undoableTimeoutContext;
215
+
216
+ const selectedDataProvider = dataProvider(
217
+ pickDataProvider(identifier, dataProviderName, resources),
218
+ );
219
+
220
+ const mutationFn = () => {
221
+ if (selectedDataProvider.updateMany) {
222
+ return selectedDataProvider.updateMany<TData, TVariables>({
223
+ resource: resource.name,
194
224
  ids,
195
- values,
196
- resource: resourceName,
197
- onCancel,
198
- mutationMode,
199
- undoableTimeout,
200
- meta,
201
- metaData,
202
- dataProviderName,
203
- }: UpdateManyParams<TData, TError, TVariables>) => {
204
- const { resource, identifier } = select(resourceName);
205
-
206
- const combinedMeta = getMeta({
207
- resource,
208
- meta: pickNotDeprecated(meta, metaData),
209
- });
210
-
211
- const mutationModePropOrContext =
212
- mutationMode ?? mutationModeContext;
213
-
214
- const undoableTimeoutPropOrContext =
215
- undoableTimeout ?? undoableTimeoutContext;
216
-
217
- const selectedDataProvider = dataProvider(
218
- pickDataProvider(identifier, dataProviderName, resources),
219
- );
220
-
221
- const mutationFn = () => {
222
- if (selectedDataProvider.updateMany) {
223
- return selectedDataProvider.updateMany<TData, TVariables>({
224
- resource: resource.name,
225
- ids,
226
- variables: values,
227
- meta: combinedMeta,
228
- metaData: combinedMeta,
229
- });
230
- } else {
231
- return handleMultiple(
232
- ids.map((id) =>
233
- selectedDataProvider.update<TData, TVariables>({
234
- resource: resource.name,
235
- id,
236
- variables: values,
237
- meta: combinedMeta,
238
- metaData: combinedMeta,
239
- }),
240
- ),
241
- );
242
- }
243
- };
244
-
245
- if (!(mutationModePropOrContext === "undoable")) {
246
- return mutationFn();
247
- }
248
-
249
- const updatePromise = new Promise<UpdateManyResponse<TData>>(
250
- (resolve, reject) => {
251
- const doMutation = () => {
252
- mutationFn()
253
- .then((result) => resolve(result))
254
- .catch((err) => reject(err));
255
- };
256
-
257
- const cancelMutation = () => {
258
- reject({ message: "mutationCancelled" });
259
- };
260
-
261
- if (onCancel) {
262
- onCancel(cancelMutation);
263
- }
264
-
265
- notificationDispatch({
266
- type: ActionTypes.ADD,
267
- payload: {
268
- id: ids,
269
- resource: identifier,
270
- cancelMutation: cancelMutation,
271
- doMutation: doMutation,
272
- seconds: undoableTimeoutPropOrContext,
273
- isSilent: !!onCancel,
274
- },
275
- });
276
- },
277
- );
278
- return updatePromise;
225
+ variables: values,
226
+ meta: combinedMeta,
227
+ metaData: combinedMeta,
228
+ });
229
+ }
230
+ return handleMultiple(
231
+ ids.map((id) =>
232
+ selectedDataProvider.update<TData, TVariables>({
233
+ resource: resource.name,
234
+ id,
235
+ variables: values,
236
+ meta: combinedMeta,
237
+ metaData: combinedMeta,
238
+ }),
239
+ ),
240
+ );
241
+ };
242
+
243
+ if (!(mutationModePropOrContext === "undoable")) {
244
+ return mutationFn();
245
+ }
246
+
247
+ const updatePromise = new Promise<UpdateManyResponse<TData>>(
248
+ (resolve, reject) => {
249
+ const doMutation = () => {
250
+ mutationFn()
251
+ .then((result) => resolve(result))
252
+ .catch((err) => reject(err));
253
+ };
254
+
255
+ const cancelMutation = () => {
256
+ reject({ message: "mutationCancelled" });
257
+ };
258
+
259
+ if (onCancel) {
260
+ onCancel(cancelMutation);
261
+ }
262
+
263
+ notificationDispatch({
264
+ type: ActionTypes.ADD,
265
+ payload: {
266
+ id: ids,
267
+ resource: identifier,
268
+ cancelMutation: cancelMutation,
269
+ doMutation: doMutation,
270
+ seconds: undoableTimeoutPropOrContext,
271
+ isSilent: !!onCancel,
272
+ },
273
+ });
279
274
  },
280
- onMutate: async ({
281
- resource: resourceName,
282
- ids,
283
- values,
284
- mutationMode,
285
- dataProviderName,
286
- meta,
287
- metaData,
288
- optimisticUpdateMap = { list: true, many: true, detail: true },
289
- }) => {
290
- const { identifier } = select(resourceName);
291
- const {
292
- gqlMutation: _,
293
- gqlQuery: __,
294
- ...preferredMeta
295
- } = pickNotDeprecated(meta, metaData) ?? {};
296
-
297
- const queryKey = queryKeysReplacement(preferLegacyKeys)(
298
- identifier,
299
- pickDataProvider(identifier, dataProviderName, resources),
300
- preferredMeta,
301
- );
302
-
303
- const resourceKeys = keys()
304
- .data(pickDataProvider(identifier, dataProviderName, resources))
305
- .resource(identifier);
306
-
307
- const mutationModePropOrContext =
308
- mutationMode ?? mutationModeContext;
275
+ );
276
+ return updatePromise;
277
+ },
278
+ onMutate: async ({
279
+ resource: resourceName,
280
+ ids,
281
+ values,
282
+ mutationMode,
283
+ dataProviderName,
284
+ meta,
285
+ metaData,
286
+ optimisticUpdateMap = { list: true, many: true, detail: true },
287
+ }) => {
288
+ const { identifier } = select(resourceName);
289
+ const {
290
+ gqlMutation: _,
291
+ gqlQuery: __,
292
+ ...preferredMeta
293
+ } = pickNotDeprecated(meta, metaData) ?? {};
294
+
295
+ const queryKey = queryKeysReplacement(preferLegacyKeys)(
296
+ identifier,
297
+ pickDataProvider(identifier, dataProviderName, resources),
298
+ preferredMeta,
299
+ );
300
+
301
+ const resourceKeys = keys()
302
+ .data(pickDataProvider(identifier, dataProviderName, resources))
303
+ .resource(identifier);
304
+
305
+ const mutationModePropOrContext = mutationMode ?? mutationModeContext;
306
+
307
+ await queryClient.cancelQueries(
308
+ resourceKeys.get(preferLegacyKeys),
309
+ undefined,
310
+ {
311
+ silent: true,
312
+ },
313
+ );
314
+
315
+ const previousQueries = queryClient.getQueriesData<QueryResponse<TData>>(
316
+ resourceKeys.get(preferLegacyKeys),
317
+ );
318
+
319
+ if (mutationModePropOrContext !== "pessimistic") {
320
+ if (optimisticUpdateMap.list) {
321
+ // Set the previous queries to the new ones:
322
+ queryClient.setQueriesData(
323
+ resourceKeys
324
+ .action("list")
325
+ .params(preferredMeta ?? {})
326
+ .get(preferLegacyKeys),
327
+ (previous?: GetListResponse<TData> | null) => {
328
+ if (typeof optimisticUpdateMap.list === "function") {
329
+ return optimisticUpdateMap.list(previous, values, ids);
330
+ }
331
+
332
+ if (!previous) {
333
+ return null;
334
+ }
335
+
336
+ const data = previous.data.map((record: TData) => {
337
+ if (
338
+ record.id !== undefined &&
339
+ ids
340
+ .filter((id) => id !== undefined)
341
+ .map(String)
342
+ .includes(record.id.toString())
343
+ ) {
344
+ return {
345
+ ...record,
346
+ ...values,
347
+ };
348
+ }
309
349
 
310
- await queryClient.cancelQueries(
311
- resourceKeys.get(preferLegacyKeys),
312
- undefined,
313
- {
314
- silent: true,
315
- },
316
- );
350
+ return record;
351
+ });
317
352
 
318
- const previousQueries = queryClient.getQueriesData<
319
- QueryResponse<TData>
320
- >(resourceKeys.get(preferLegacyKeys));
321
-
322
- if (mutationModePropOrContext !== "pessimistic") {
323
- if (optimisticUpdateMap.list) {
324
- // Set the previous queries to the new ones:
325
- queryClient.setQueriesData(
326
- resourceKeys
327
- .action("list")
328
- .params(preferredMeta ?? {})
329
- .get(preferLegacyKeys),
330
- (previous?: GetListResponse<TData> | null) => {
331
- if (
332
- typeof optimisticUpdateMap.list === "function"
333
- ) {
334
- return optimisticUpdateMap.list(
335
- previous,
336
- values,
337
- ids,
338
- );
339
- }
340
-
341
- if (!previous) {
342
- return null;
343
- }
344
-
345
- const data = previous.data.map((record: TData) => {
346
- if (
347
- record.id !== undefined &&
348
- ids
349
- .filter((id) => id !== undefined)
350
- .map(String)
351
- .includes(record.id.toString())
352
- ) {
353
- return {
354
- ...record,
355
- ...values,
356
- };
357
- }
358
-
359
- return record;
360
- });
361
-
362
- return {
363
- ...previous,
364
- data,
365
- };
366
- },
367
- );
353
+ return {
354
+ ...previous,
355
+ data,
356
+ };
357
+ },
358
+ );
359
+ }
360
+
361
+ if (optimisticUpdateMap.many) {
362
+ queryClient.setQueriesData(
363
+ resourceKeys.action("many").get(preferLegacyKeys),
364
+ (previous?: GetManyResponse<TData> | null) => {
365
+ if (typeof optimisticUpdateMap.many === "function") {
366
+ return optimisticUpdateMap.many(previous, values, ids);
367
+ }
368
+
369
+ if (!previous) {
370
+ return null;
371
+ }
372
+
373
+ const data = previous.data.map((record: TData) => {
374
+ if (
375
+ record.id !== undefined &&
376
+ ids
377
+ .filter((id) => id !== undefined)
378
+ .map(String)
379
+ .includes(record.id.toString())
380
+ ) {
381
+ return {
382
+ ...record,
383
+ ...values,
384
+ };
368
385
  }
369
-
370
- if (optimisticUpdateMap.many) {
371
- queryClient.setQueriesData(
372
- resourceKeys.action("many").get(preferLegacyKeys),
373
- (previous?: GetManyResponse<TData> | null) => {
374
- if (
375
- typeof optimisticUpdateMap.many === "function"
376
- ) {
377
- return optimisticUpdateMap.many(
378
- previous,
379
- values,
380
- ids,
381
- );
382
- }
383
-
384
- if (!previous) {
385
- return null;
386
- }
387
-
388
- const data = previous.data.map((record: TData) => {
389
- if (
390
- record.id !== undefined &&
391
- ids
392
- .filter((id) => id !== undefined)
393
- .map(String)
394
- .includes(record.id.toString())
395
- ) {
396
- return {
397
- ...record,
398
- ...values,
399
- };
400
- }
401
- return record;
402
- });
403
- return {
404
- ...previous,
405
- data,
406
- };
407
- },
408
- );
386
+ return record;
387
+ });
388
+ return {
389
+ ...previous,
390
+ data,
391
+ };
392
+ },
393
+ );
394
+ }
395
+
396
+ if (optimisticUpdateMap.detail) {
397
+ for (const id of ids) {
398
+ queryClient.setQueriesData(
399
+ resourceKeys
400
+ .action("one")
401
+ .id(id)
402
+ .params(preferredMeta ?? {})
403
+ .get(preferLegacyKeys),
404
+ (previous?: GetOneResponse<TData> | null) => {
405
+ if (typeof optimisticUpdateMap.detail === "function") {
406
+ return optimisticUpdateMap.detail(previous, values, id);
409
407
  }
410
408
 
411
- if (optimisticUpdateMap.detail) {
412
- for (const id of ids) {
413
- queryClient.setQueriesData(
414
- resourceKeys
415
- .action("one")
416
- .id(id)
417
- .params(preferredMeta ?? {})
418
- .get(preferLegacyKeys),
419
- (previous?: GetOneResponse<TData> | null) => {
420
- if (
421
- typeof optimisticUpdateMap.detail ===
422
- "function"
423
- ) {
424
- return optimisticUpdateMap.detail(
425
- previous,
426
- values,
427
- id,
428
- );
429
- }
430
-
431
- if (!previous) {
432
- return null;
433
- }
434
-
435
- const data = {
436
- ...previous.data,
437
- ...values,
438
- };
439
- return {
440
- ...previous,
441
- data,
442
- };
443
- },
444
- );
445
- }
409
+ if (!previous) {
410
+ return null;
446
411
  }
447
- }
448
412
 
449
- return {
450
- previousQueries,
451
- queryKey,
452
- };
453
- },
454
- onSettled: (
455
- _data,
456
- _error,
457
- { ids, resource: resourceName, dataProviderName },
458
- ) => {
459
- const { identifier } = select(resourceName);
460
-
461
- // invalidate the cache for the list and many queries:
462
- invalidateStore({
463
- resource: identifier,
464
- invalidates: ["list", "many"],
465
- dataProviderName: pickDataProvider(
466
- identifier,
467
- dataProviderName,
468
- resources,
469
- ),
470
- });
471
-
472
- ids.forEach((id) =>
473
- invalidateStore({
474
- resource: identifier,
475
- invalidates: ["detail"],
476
- dataProviderName: pickDataProvider(
477
- identifier,
478
- dataProviderName,
479
- resources,
480
- ),
481
- id,
482
- }),
413
+ const data = {
414
+ ...previous.data,
415
+ ...values,
416
+ };
417
+ return {
418
+ ...previous,
419
+ data,
420
+ };
421
+ },
483
422
  );
484
-
485
- notificationDispatch({
486
- type: ActionTypes.REMOVE,
487
- payload: { id: ids, resource: identifier },
488
- });
489
- },
490
- onSuccess: (
491
- data,
492
- {
493
- ids,
494
- resource: resourceName,
495
- meta,
496
- metaData,
497
- dataProviderName: dataProviderNameFromProp,
498
- successNotification,
499
- values,
500
- },
501
- context,
502
- ) => {
503
- const { resource, identifier } = select(resourceName);
504
- const resourceSingular = textTransformers.singular(identifier);
505
-
506
- const dataProviderName = pickDataProvider(
507
- identifier,
508
- dataProviderNameFromProp,
509
- resources,
510
- );
511
-
512
- const combinedMeta = getMeta({
513
- resource,
514
- meta: pickNotDeprecated(meta, metaData),
515
- });
516
-
517
- const notificationConfig =
518
- typeof successNotification === "function"
519
- ? successNotification(data, { ids, values }, identifier)
520
- : successNotification;
521
-
522
- handleNotification(notificationConfig, {
523
- key: `${ids}-${identifier}-notification`,
524
- description: translate("notifications.success", "Successful"),
525
- message: translate(
526
- "notifications.editSuccess",
527
- {
528
- resource: translate(
529
- `${identifier}.${identifier}`,
530
- identifier,
531
- ),
532
- },
533
- `Successfully updated ${resourceSingular}`,
534
- ),
535
- type: "success",
536
- });
537
-
538
- publish?.({
539
- channel: `resources/${resource.name}`,
540
- type: "updated",
541
- payload: {
542
- ids: ids.map(String),
543
- },
544
- date: new Date(),
545
- meta: {
546
- ...combinedMeta,
547
- dataProviderName,
548
- },
549
- });
550
-
551
- const previousData: any[] = [];
552
- if (context) {
553
- ids.forEach((id) => {
554
- const queryData = queryClient.getQueryData<
555
- UpdateManyResponse<TData>
556
- >(context.queryKey.detail(id));
557
-
558
- previousData.push(
559
- Object.keys(values || {}).reduce<any>(
560
- (acc, item: any) => {
561
- acc[item] = queryData?.data?.[item];
562
- return acc;
563
- },
564
- {},
565
- ),
566
- );
567
- });
568
- }
569
-
570
- const {
571
- fields: _fields,
572
- operation: _operation,
573
- variables: _variables,
574
- ...rest
575
- } = combinedMeta || {};
576
- log?.mutate({
577
- action: "updateMany",
578
- resource: resource.name,
579
- data: values,
580
- previousData,
581
- meta: {
582
- ids,
583
- dataProviderName,
584
- ...rest,
585
- },
586
- });
423
+ }
424
+ }
425
+ }
426
+
427
+ return {
428
+ previousQueries,
429
+ queryKey,
430
+ };
431
+ },
432
+ onSettled: (
433
+ _data,
434
+ _error,
435
+ { ids, resource: resourceName, dataProviderName },
436
+ ) => {
437
+ const { identifier } = select(resourceName);
438
+
439
+ // invalidate the cache for the list and many queries:
440
+ invalidateStore({
441
+ resource: identifier,
442
+ invalidates: ["list", "many"],
443
+ dataProviderName: pickDataProvider(
444
+ identifier,
445
+ dataProviderName,
446
+ resources,
447
+ ),
448
+ });
449
+
450
+ ids.forEach((id) =>
451
+ invalidateStore({
452
+ resource: identifier,
453
+ invalidates: ["detail"],
454
+ dataProviderName: pickDataProvider(
455
+ identifier,
456
+ dataProviderName,
457
+ resources,
458
+ ),
459
+ id,
460
+ }),
461
+ );
462
+
463
+ notificationDispatch({
464
+ type: ActionTypes.REMOVE,
465
+ payload: { id: ids, resource: identifier },
466
+ });
467
+ },
468
+ onSuccess: (
469
+ data,
470
+ {
471
+ ids,
472
+ resource: resourceName,
473
+ meta,
474
+ metaData,
475
+ dataProviderName: dataProviderNameFromProp,
476
+ successNotification,
477
+ values,
478
+ },
479
+ context,
480
+ ) => {
481
+ const { resource, identifier } = select(resourceName);
482
+ const resourceSingular = textTransformers.singular(identifier);
483
+
484
+ const dataProviderName = pickDataProvider(
485
+ identifier,
486
+ dataProviderNameFromProp,
487
+ resources,
488
+ );
489
+
490
+ const combinedMeta = getMeta({
491
+ resource,
492
+ meta: pickNotDeprecated(meta, metaData),
493
+ });
494
+
495
+ const notificationConfig =
496
+ typeof successNotification === "function"
497
+ ? successNotification(data, { ids, values }, identifier)
498
+ : successNotification;
499
+
500
+ handleNotification(notificationConfig, {
501
+ key: `${ids}-${identifier}-notification`,
502
+ description: translate("notifications.success", "Successful"),
503
+ message: translate(
504
+ "notifications.editSuccess",
505
+ {
506
+ resource: translate(`${identifier}.${identifier}`, identifier),
507
+ },
508
+ `Successfully updated ${resourceSingular}`,
509
+ ),
510
+ type: "success",
511
+ });
512
+
513
+ publish?.({
514
+ channel: `resources/${resource.name}`,
515
+ type: "updated",
516
+ payload: {
517
+ ids: ids.map(String),
587
518
  },
588
- onError: (
589
- err: TError,
590
- { ids, resource: resourceName, errorNotification, values },
591
- context,
592
- ) => {
593
- const { identifier } = select(resourceName);
594
-
595
- // set back the queries to the context:
596
- if (context) {
597
- for (const query of context.previousQueries) {
598
- queryClient.setQueryData(query[0], query[1]);
599
- }
600
- }
601
-
602
- if (err.message !== "mutationCancelled") {
603
- checkError?.(err);
604
-
605
- const resourceSingular = textTransformers.singular(identifier);
606
-
607
- const notificationConfig =
608
- typeof errorNotification === "function"
609
- ? errorNotification(err, { ids, values }, identifier)
610
- : errorNotification;
611
-
612
- handleNotification(notificationConfig, {
613
- key: `${ids}-${identifier}-updateMany-error-notification`,
614
- message: translate(
615
- "notifications.editError",
616
- {
617
- resource: resourceSingular,
618
- statusCode: err.statusCode,
619
- },
620
- `Error when updating ${resourceSingular} (status code: ${err.statusCode})`,
621
- ),
622
- description: err.message,
623
- type: "error",
624
- });
625
- }
519
+ date: new Date(),
520
+ meta: {
521
+ ...combinedMeta,
522
+ dataProviderName,
626
523
  },
627
- mutationKey: keys().data().mutation("updateMany").get(preferLegacyKeys),
628
- ...mutationOptions,
524
+ });
525
+
526
+ const previousData: any[] = [];
527
+ if (context) {
528
+ ids.forEach((id) => {
529
+ const queryData = queryClient.getQueryData<UpdateManyResponse<TData>>(
530
+ context.queryKey.detail(id),
531
+ );
532
+
533
+ previousData.push(
534
+ Object.keys(values || {}).reduce<any>((acc, item: any) => {
535
+ acc[item] = queryData?.data?.[item];
536
+ return acc;
537
+ }, {}),
538
+ );
539
+ });
540
+ }
541
+
542
+ const {
543
+ fields: _fields,
544
+ operation: _operation,
545
+ variables: _variables,
546
+ ...rest
547
+ } = combinedMeta || {};
548
+ log?.mutate({
549
+ action: "updateMany",
550
+ resource: resource.name,
551
+ data: values,
552
+ previousData,
629
553
  meta: {
630
- ...mutationOptions?.meta,
631
- ...getXRay("useUpdateMany", preferLegacyKeys),
554
+ ids,
555
+ dataProviderName,
556
+ ...rest,
632
557
  },
633
- });
634
-
635
- const { elapsedTime } = useLoadingOvertime({
636
- isLoading: mutation.isLoading,
637
- interval: overtimeOptions?.interval,
638
- onInterval: overtimeOptions?.onInterval,
639
- });
640
-
641
- return { ...mutation, overtime: { elapsedTime } };
558
+ });
559
+ },
560
+ onError: (
561
+ err: TError,
562
+ { ids, resource: resourceName, errorNotification, values },
563
+ context,
564
+ ) => {
565
+ const { identifier } = select(resourceName);
566
+
567
+ // set back the queries to the context:
568
+ if (context) {
569
+ for (const query of context.previousQueries) {
570
+ queryClient.setQueryData(query[0], query[1]);
571
+ }
572
+ }
573
+
574
+ if (err.message !== "mutationCancelled") {
575
+ checkError?.(err);
576
+
577
+ const resourceSingular = textTransformers.singular(identifier);
578
+
579
+ const notificationConfig =
580
+ typeof errorNotification === "function"
581
+ ? errorNotification(err, { ids, values }, identifier)
582
+ : errorNotification;
583
+
584
+ handleNotification(notificationConfig, {
585
+ key: `${ids}-${identifier}-updateMany-error-notification`,
586
+ message: translate(
587
+ "notifications.editError",
588
+ {
589
+ resource: resourceSingular,
590
+ statusCode: err.statusCode,
591
+ },
592
+ `Error when updating ${resourceSingular} (status code: ${err.statusCode})`,
593
+ ),
594
+ description: err.message,
595
+ type: "error",
596
+ });
597
+ }
598
+ },
599
+ mutationKey: keys().data().mutation("updateMany").get(preferLegacyKeys),
600
+ ...mutationOptions,
601
+ meta: {
602
+ ...mutationOptions?.meta,
603
+ ...getXRay("useUpdateMany", preferLegacyKeys),
604
+ },
605
+ });
606
+
607
+ const { elapsedTime } = useLoadingOvertime({
608
+ isLoading: mutation.isLoading,
609
+ interval: overtimeOptions?.interval,
610
+ onInterval: overtimeOptions?.onInterval,
611
+ });
612
+
613
+ return { ...mutation, overtime: { elapsedTime } };
642
614
  };