@everysk/apps-sdk 0.1.0 → 0.3.0-beta-20261016180126

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 (349) hide show
  1. package/README.md +395 -8
  2. package/dist/EveryskApp.d.ts +34 -2
  3. package/dist/EveryskApp.d.ts.map +1 -1
  4. package/dist/EveryskApp.js +35 -2
  5. package/dist/EveryskApp.js.map +1 -1
  6. package/dist/agGrid/handleRowsScrollEnd.d.ts +53 -0
  7. package/dist/agGrid/handleRowsScrollEnd.d.ts.map +1 -0
  8. package/dist/agGrid/handleRowsScrollEnd.js +47 -0
  9. package/dist/agGrid/handleRowsScrollEnd.js.map +1 -0
  10. package/dist/agGrid/index.d.ts +2 -0
  11. package/dist/agGrid/index.d.ts.map +1 -1
  12. package/dist/agGrid/index.js +2 -1
  13. package/dist/api/datastore.d.ts +10 -8
  14. package/dist/api/datastore.d.ts.map +1 -1
  15. package/dist/api/datastore.js +24 -55
  16. package/dist/api/datastore.js.map +1 -1
  17. package/dist/api/entityQuery.d.ts +46 -41
  18. package/dist/api/entityQuery.d.ts.map +1 -1
  19. package/dist/api/entityQuery.js +55 -14
  20. package/dist/api/entityQuery.js.map +1 -1
  21. package/dist/api/file.d.ts +26 -9
  22. package/dist/api/file.d.ts.map +1 -1
  23. package/dist/api/file.js +45 -55
  24. package/dist/api/file.js.map +1 -1
  25. package/dist/api/portfolio.d.ts +11 -8
  26. package/dist/api/portfolio.d.ts.map +1 -1
  27. package/dist/api/portfolio.js +24 -55
  28. package/dist/api/portfolio.js.map +1 -1
  29. package/dist/api/profile.d.ts +3 -2
  30. package/dist/api/profile.d.ts.map +1 -1
  31. package/dist/api/profile.js +4 -9
  32. package/dist/api/profile.js.map +1 -1
  33. package/dist/api/request.d.ts +106 -0
  34. package/dist/api/request.d.ts.map +1 -0
  35. package/dist/api/request.js +132 -0
  36. package/dist/api/request.js.map +1 -0
  37. package/dist/api/websocketsConfig.d.ts +7 -2
  38. package/dist/api/websocketsConfig.d.ts.map +1 -1
  39. package/dist/api/websocketsConfig.js +2 -10
  40. package/dist/api/websocketsConfig.js.map +1 -1
  41. package/dist/api/workflow.d.ts +84 -89
  42. package/dist/api/workflow.d.ts.map +1 -1
  43. package/dist/api/workflow.js +121 -208
  44. package/dist/api/workflow.js.map +1 -1
  45. package/dist/api/workspace.d.ts +18 -8
  46. package/dist/api/workspace.d.ts.map +1 -1
  47. package/dist/api/workspace.js +21 -26
  48. package/dist/api/workspace.js.map +1 -1
  49. package/dist/components/ui/Footer/index.d.ts.map +1 -1
  50. package/dist/components/ui/Footer/index.js.map +1 -1
  51. package/dist/components/ui/GlobalLoading/index.d.ts.map +1 -1
  52. package/dist/components/ui/GlobalLoading/index.js.map +1 -1
  53. package/dist/components/ui/PageContainer/index.d.ts +1 -1
  54. package/dist/components/ui/PageContainer/index.d.ts.map +1 -1
  55. package/dist/components/ui/PageContainer/index.js.map +1 -1
  56. package/dist/components/ui/Toolbar/index.d.ts +40 -3
  57. package/dist/components/ui/Toolbar/index.d.ts.map +1 -1
  58. package/dist/components/ui/Toolbar/index.js +42 -15
  59. package/dist/components/ui/Toolbar/index.js.map +1 -1
  60. package/dist/contexts/appAlertContext/provider.js.map +1 -1
  61. package/dist/contexts/appAlertContext/types.d.ts.map +1 -1
  62. package/dist/contexts/appConfigContext/index.d.ts.map +1 -1
  63. package/dist/contexts/appConfigContext/index.js.map +1 -1
  64. package/dist/contexts/appConfigContext/provider.d.ts.map +1 -1
  65. package/dist/contexts/appConfigContext/provider.js.map +1 -1
  66. package/dist/contexts/webSocketContext/handler.d.ts +3 -2
  67. package/dist/contexts/webSocketContext/handler.d.ts.map +1 -1
  68. package/dist/contexts/webSocketContext/handler.js.map +1 -1
  69. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts +1 -1
  70. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js +1 -1
  71. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js.map +1 -1
  72. package/dist/contexts/webSocketContext/provider.d.ts +6 -3
  73. package/dist/contexts/webSocketContext/provider.d.ts.map +1 -1
  74. package/dist/contexts/webSocketContext/provider.js +42 -7
  75. package/dist/contexts/webSocketContext/provider.js.map +1 -1
  76. package/dist/contexts/webSocketContext/types.d.ts +7 -5
  77. package/dist/contexts/webSocketContext/types.d.ts.map +1 -1
  78. package/dist/file/index.d.ts +2 -0
  79. package/dist/file/index.d.ts.map +1 -1
  80. package/dist/hooks/datastore/useDatastoreMutations.d.ts +4 -4
  81. package/dist/hooks/datastore/useDatastoreMutations.d.ts.map +1 -1
  82. package/dist/hooks/datastore/useDatastoreMutations.js +17 -55
  83. package/dist/hooks/datastore/useDatastoreMutations.js.map +1 -1
  84. package/dist/hooks/datastore/useFetchDatastore.d.ts +30 -41
  85. package/dist/hooks/datastore/useFetchDatastore.d.ts.map +1 -1
  86. package/dist/hooks/datastore/useFetchDatastore.js +25 -59
  87. package/dist/hooks/datastore/useFetchDatastore.js.map +1 -1
  88. package/dist/hooks/datastore/useFetchDatastores.d.ts +47 -52
  89. package/dist/hooks/datastore/useFetchDatastores.d.ts.map +1 -1
  90. package/dist/hooks/datastore/useFetchDatastores.js +55 -70
  91. package/dist/hooks/datastore/useFetchDatastores.js.map +1 -1
  92. package/dist/hooks/file/fileData.d.ts +17 -0
  93. package/dist/hooks/file/fileData.d.ts.map +1 -0
  94. package/dist/hooks/file/fileData.js +10 -0
  95. package/dist/hooks/file/fileData.js.map +1 -0
  96. package/dist/hooks/file/useFetchFile.d.ts +38 -58
  97. package/dist/hooks/file/useFetchFile.d.ts.map +1 -1
  98. package/dist/hooks/file/useFetchFile.js +26 -66
  99. package/dist/hooks/file/useFetchFile.js.map +1 -1
  100. package/dist/hooks/file/useFetchFiles.d.ts +18 -52
  101. package/dist/hooks/file/useFetchFiles.d.ts.map +1 -1
  102. package/dist/hooks/file/useFetchFiles.js +53 -69
  103. package/dist/hooks/file/useFetchFiles.js.map +1 -1
  104. package/dist/hooks/file/useFileMutations.d.ts +9 -8
  105. package/dist/hooks/file/useFileMutations.d.ts.map +1 -1
  106. package/dist/hooks/file/useFileMutations.js +23 -60
  107. package/dist/hooks/file/useFileMutations.js.map +1 -1
  108. package/dist/hooks/portfolio/useFetchPortfolio.d.ts +16 -50
  109. package/dist/hooks/portfolio/useFetchPortfolio.d.ts.map +1 -1
  110. package/dist/hooks/portfolio/useFetchPortfolio.js +15 -63
  111. package/dist/hooks/portfolio/useFetchPortfolio.js.map +1 -1
  112. package/dist/hooks/portfolio/useFetchPortfolios.d.ts +13 -52
  113. package/dist/hooks/portfolio/useFetchPortfolios.d.ts.map +1 -1
  114. package/dist/hooks/portfolio/useFetchPortfolios.js +29 -71
  115. package/dist/hooks/portfolio/useFetchPortfolios.js.map +1 -1
  116. package/dist/hooks/portfolio/usePortfolioMutations.d.ts +8 -8
  117. package/dist/hooks/portfolio/usePortfolioMutations.d.ts.map +1 -1
  118. package/dist/hooks/portfolio/usePortfolioMutations.js +20 -58
  119. package/dist/hooks/portfolio/usePortfolioMutations.js.map +1 -1
  120. package/dist/hooks/profile/useFetchProfile.d.ts +18 -44
  121. package/dist/hooks/profile/useFetchProfile.d.ts.map +1 -1
  122. package/dist/hooks/profile/useFetchProfile.js +16 -48
  123. package/dist/hooks/profile/useFetchProfile.js.map +1 -1
  124. package/dist/hooks/useAxios.js.map +1 -1
  125. package/dist/hooks/useEntityInfiniteQuery.d.ts +88 -0
  126. package/dist/hooks/useEntityInfiniteQuery.d.ts.map +1 -0
  127. package/dist/hooks/useEntityInfiniteQuery.js +111 -0
  128. package/dist/hooks/useEntityInfiniteQuery.js.map +1 -0
  129. package/dist/hooks/useEntityMutation.d.ts +47 -0
  130. package/dist/hooks/useEntityMutation.d.ts.map +1 -0
  131. package/dist/hooks/useEntityMutation.js +58 -0
  132. package/dist/hooks/useEntityMutation.js.map +1 -0
  133. package/dist/hooks/useEntityQuery.d.ts +68 -0
  134. package/dist/hooks/useEntityQuery.d.ts.map +1 -0
  135. package/dist/hooks/useEntityQuery.js +75 -0
  136. package/dist/hooks/useEntityQuery.js.map +1 -0
  137. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts +17 -34
  138. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts.map +1 -1
  139. package/dist/hooks/workflow/useFetchWorkerExecution.js +16 -46
  140. package/dist/hooks/workflow/useFetchWorkerExecution.js.map +1 -1
  141. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts +179 -41
  142. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts.map +1 -1
  143. package/dist/hooks/workflow/useFetchWorkerExecutions.js +29 -62
  144. package/dist/hooks/workflow/useFetchWorkerExecutions.js.map +1 -1
  145. package/dist/hooks/workflow/useFetchWorkflow.d.ts +16 -35
  146. package/dist/hooks/workflow/useFetchWorkflow.d.ts.map +1 -1
  147. package/dist/hooks/workflow/useFetchWorkflow.js +15 -48
  148. package/dist/hooks/workflow/useFetchWorkflow.js.map +1 -1
  149. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts +17 -34
  150. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts.map +1 -1
  151. package/dist/hooks/workflow/useFetchWorkflowExecution.js +16 -46
  152. package/dist/hooks/workflow/useFetchWorkflowExecution.js.map +1 -1
  153. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts +22 -36
  154. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts.map +1 -1
  155. package/dist/hooks/workflow/useFetchWorkflowExecutions.js +43 -56
  156. package/dist/hooks/workflow/useFetchWorkflowExecutions.js.map +1 -1
  157. package/dist/hooks/workflow/useFetchWorkflows.d.ts +20 -37
  158. package/dist/hooks/workflow/useFetchWorkflows.d.ts.map +1 -1
  159. package/dist/hooks/workflow/useFetchWorkflows.js +32 -47
  160. package/dist/hooks/workflow/useFetchWorkflows.js.map +1 -1
  161. package/dist/hooks/workflow/useRunWorkflow.d.ts +21 -16
  162. package/dist/hooks/workflow/useRunWorkflow.d.ts.map +1 -1
  163. package/dist/hooks/workflow/useRunWorkflow.js +66 -29
  164. package/dist/hooks/workflow/useRunWorkflow.js.map +1 -1
  165. package/dist/hooks/workflow/useTriggerWorkflow.d.ts +20 -0
  166. package/dist/hooks/workflow/useTriggerWorkflow.d.ts.map +1 -0
  167. package/dist/hooks/workflow/useTriggerWorkflow.js +32 -0
  168. package/dist/hooks/workflow/useTriggerWorkflow.js.map +1 -0
  169. package/dist/hooks/workspace/useFetchWorkspace.d.ts +19 -34
  170. package/dist/hooks/workspace/useFetchWorkspace.d.ts.map +1 -1
  171. package/dist/hooks/workspace/useFetchWorkspace.js +16 -46
  172. package/dist/hooks/workspace/useFetchWorkspace.js.map +1 -1
  173. package/dist/hooks/workspace/useFetchWorkspaces.d.ts +17 -37
  174. package/dist/hooks/workspace/useFetchWorkspaces.d.ts.map +1 -1
  175. package/dist/hooks/workspace/useFetchWorkspaces.js +25 -47
  176. package/dist/hooks/workspace/useFetchWorkspaces.js.map +1 -1
  177. package/dist/index.d.ts +13 -10
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +13 -11
  180. package/dist/lib/abort.d.ts +58 -0
  181. package/dist/lib/abort.d.ts.map +1 -0
  182. package/dist/lib/abort.js +112 -0
  183. package/dist/lib/abort.js.map +1 -0
  184. package/dist/lib/datastoreTable.d.ts +59 -54
  185. package/dist/lib/datastoreTable.d.ts.map +1 -1
  186. package/dist/lib/datastoreTable.js +58 -62
  187. package/dist/lib/datastoreTable.js.map +1 -1
  188. package/dist/lib/file.d.ts +34 -0
  189. package/dist/lib/file.d.ts.map +1 -0
  190. package/dist/lib/file.js +63 -0
  191. package/dist/lib/file.js.map +1 -0
  192. package/dist/lib/queryClient.d.ts.map +1 -1
  193. package/dist/lib/queryClient.js.map +1 -1
  194. package/dist/lib/workflowRun.d.ts +91 -0
  195. package/dist/lib/workflowRun.d.ts.map +1 -0
  196. package/dist/lib/workflowRun.js +224 -0
  197. package/dist/lib/workflowRun.js.map +1 -0
  198. package/dist/socket/index.d.ts +1 -3
  199. package/dist/socket/index.d.ts.map +1 -1
  200. package/dist/socket/index.js +3 -5
  201. package/dist/test/mocks/index.d.ts +1 -1
  202. package/dist/test/mocks/index.d.ts.map +1 -1
  203. package/dist/test/renderWithProviders.d.ts +2 -2
  204. package/dist/test/renderWithProviders.d.ts.map +1 -1
  205. package/dist/test/renderWithProviders.js.map +1 -1
  206. package/dist/test/setup.js.map +1 -1
  207. package/dist/theme/index.d.ts +1 -1
  208. package/dist/theme/index.d.ts.map +1 -1
  209. package/dist/theme/overrides/index.d.ts +4 -2
  210. package/dist/theme/overrides/index.d.ts.map +1 -1
  211. package/dist/theme/overrides/index.js +5 -3
  212. package/dist/theme/overrides/index.js.map +1 -1
  213. package/dist/theme/overrides/muiButton.d.ts +2 -2
  214. package/dist/theme/overrides/muiButton.js.map +1 -1
  215. package/dist/theme/overrides/muiCssBaseline.d.ts.map +1 -1
  216. package/dist/theme/overrides/muiCssBaseline.js.map +1 -1
  217. package/dist/theme/overrides/muiDatePicker.js.map +1 -1
  218. package/dist/theme/overrides/muiFormControl.js.map +1 -1
  219. package/dist/theme/overrides/muiIconButton.d.ts +2 -2
  220. package/dist/theme/overrides/muiIconButton.js.map +1 -1
  221. package/dist/theme/overrides/muiSelect.d.ts.map +1 -1
  222. package/dist/theme/overrides/muiSelect.js.map +1 -1
  223. package/dist/theme/overrides/muiSvgIcon.d.ts.map +1 -1
  224. package/dist/theme/overrides/muiSvgIcon.js.map +1 -1
  225. package/dist/theme/overrides/muiTextField.js.map +1 -1
  226. package/dist/theme/overrides/muiToggleButton.d.ts +2 -2
  227. package/dist/theme/overrides/muiToggleButton.js.map +1 -1
  228. package/dist/theme/overrides/muiToggleButtonGroup.d.ts +2 -2
  229. package/dist/theme/overrides/muiToggleButtonGroup.js.map +1 -1
  230. package/dist/theme/themes/DefaultDark.js +2 -2
  231. package/dist/theme/themes/DefaultDark.js.map +1 -1
  232. package/dist/theme/themes/DefaultLight.js +2 -2
  233. package/dist/theme/themes/DefaultLight.js.map +1 -1
  234. package/dist/theme/themes/EveryskDark.js +2 -2
  235. package/dist/theme/themes/EveryskDark.js.map +1 -1
  236. package/dist/theme/themes/EveryskLight.js +2 -2
  237. package/dist/theme/themes/EveryskLight.js.map +1 -1
  238. package/dist/theme/themes/MidnightEmber.js +2 -2
  239. package/dist/theme/themes/MidnightEmber.js.map +1 -1
  240. package/dist/types/anyRecord.d.ts.map +1 -1
  241. package/dist/types/datastore.d.ts +35 -5
  242. package/dist/types/datastore.d.ts.map +1 -1
  243. package/dist/types/datastoreDataFormat.d.ts +13 -0
  244. package/dist/types/datastoreDataFormat.d.ts.map +1 -0
  245. package/dist/types/entityQuery.d.ts +86 -16
  246. package/dist/types/entityQuery.d.ts.map +1 -1
  247. package/dist/types/file.d.ts +7 -3
  248. package/dist/types/file.d.ts.map +1 -1
  249. package/dist/types/portfolio.d.ts +1 -3
  250. package/dist/types/portfolio.d.ts.map +1 -1
  251. package/dist/types/profile.d.ts +0 -10
  252. package/dist/types/profile.d.ts.map +1 -1
  253. package/dist/types/workflow.d.ts +35 -6
  254. package/dist/types/workflow.d.ts.map +1 -1
  255. package/dist/types/workspace.d.ts +1 -2
  256. package/dist/types/workspace.d.ts.map +1 -1
  257. package/dist/ui/index.d.ts +1 -1
  258. package/dist/ui/index.d.ts.map +1 -1
  259. package/dist/workflow/index.d.ts +2 -0
  260. package/dist/workflow/index.d.ts.map +1 -1
  261. package/package.json +6 -6
  262. package/src/EveryskApp.tsx +53 -2
  263. package/src/agGrid/handleRowsScrollEnd.ts +71 -0
  264. package/src/agGrid/index.ts +5 -1
  265. package/src/api/datastore.ts +79 -107
  266. package/src/api/entityQuery.ts +86 -17
  267. package/src/api/file.ts +110 -103
  268. package/src/api/portfolio.ts +82 -125
  269. package/src/api/profile.ts +25 -18
  270. package/src/api/request.ts +168 -0
  271. package/src/api/websocketsConfig.ts +11 -19
  272. package/src/api/workflow.ts +232 -334
  273. package/src/api/workspace.ts +43 -43
  274. package/src/components/ui/Footer/index.tsx +8 -7
  275. package/src/components/ui/GlobalLoading/index.tsx +13 -3
  276. package/src/components/ui/PageContainer/index.tsx +9 -2
  277. package/src/components/ui/Toolbar/index.tsx +105 -30
  278. package/src/contexts/appAlertContext/provider.tsx +1 -1
  279. package/src/contexts/appAlertContext/types.ts +3 -3
  280. package/src/contexts/appConfigContext/index.tsx +1 -1
  281. package/src/contexts/appConfigContext/provider.tsx +1 -5
  282. package/src/contexts/webSocketContext/handler.ts +8 -2
  283. package/src/contexts/webSocketContext/hooks/useWebSocket/index.ts +1 -1
  284. package/src/contexts/webSocketContext/provider.tsx +64 -14
  285. package/src/contexts/webSocketContext/types.ts +7 -6
  286. package/src/file/index.ts +2 -0
  287. package/src/hooks/datastore/useDatastoreMutations.ts +19 -60
  288. package/src/hooks/datastore/useFetchDatastore.ts +45 -73
  289. package/src/hooks/datastore/useFetchDatastores.ts +106 -131
  290. package/src/hooks/file/fileData.ts +19 -0
  291. package/src/hooks/file/useFetchFile.ts +41 -76
  292. package/src/hooks/file/useFetchFiles.ts +92 -87
  293. package/src/hooks/file/useFileMutations.ts +23 -73
  294. package/src/hooks/portfolio/useFetchPortfolio.ts +26 -78
  295. package/src/hooks/portfolio/useFetchPortfolios.ts +50 -93
  296. package/src/hooks/portfolio/usePortfolioMutations.ts +22 -72
  297. package/src/hooks/profile/useFetchProfile.ts +24 -65
  298. package/src/hooks/useAxios.ts +5 -5
  299. package/src/hooks/useEntityInfiniteQuery.ts +193 -0
  300. package/src/hooks/useEntityMutation.ts +70 -0
  301. package/src/hooks/useEntityQuery.ts +117 -0
  302. package/src/hooks/workflow/useFetchWorkerExecution.ts +27 -56
  303. package/src/hooks/workflow/useFetchWorkerExecutions.ts +54 -79
  304. package/src/hooks/workflow/useFetchWorkflow.ts +24 -58
  305. package/src/hooks/workflow/useFetchWorkflowExecution.ts +27 -57
  306. package/src/hooks/workflow/useFetchWorkflowExecutions.ts +64 -73
  307. package/src/hooks/workflow/useFetchWorkflows.ts +48 -64
  308. package/src/hooks/workflow/useRunWorkflow.ts +82 -36
  309. package/src/hooks/workflow/useTriggerWorkflow.ts +36 -0
  310. package/src/hooks/workspace/useFetchWorkspace.ts +25 -58
  311. package/src/hooks/workspace/useFetchWorkspaces.ts +38 -69
  312. package/src/index.ts +34 -19
  313. package/src/lib/abort.ts +131 -0
  314. package/src/lib/datastoreTable.ts +127 -74
  315. package/src/lib/file.ts +67 -0
  316. package/src/lib/queryClient.ts +11 -13
  317. package/src/lib/workflowRun.ts +329 -0
  318. package/src/socket/index.ts +1 -3
  319. package/src/test/mocks/index.ts +1 -5
  320. package/src/test/renderWithProviders.tsx +8 -3
  321. package/src/test/setup.ts +16 -16
  322. package/src/theme/index.ts +1 -1
  323. package/src/theme/overrides/index.ts +5 -3
  324. package/src/theme/overrides/muiButton.ts +3 -3
  325. package/src/theme/overrides/muiCssBaseline.ts +11 -12
  326. package/src/theme/overrides/muiDatePicker.ts +2 -2
  327. package/src/theme/overrides/muiFormControl.ts +2 -2
  328. package/src/theme/overrides/muiIconButton.ts +3 -3
  329. package/src/theme/overrides/muiSelect.ts +2 -2
  330. package/src/theme/overrides/muiSvgIcon.ts +2 -2
  331. package/src/theme/overrides/muiTextField.ts +1 -1
  332. package/src/theme/overrides/muiToggleButton.ts +4 -4
  333. package/src/theme/overrides/muiToggleButtonGroup.ts +4 -4
  334. package/src/theme/themes/DefaultDark.ts +2 -2
  335. package/src/theme/themes/DefaultLight.ts +2 -2
  336. package/src/theme/themes/EveryskDark.ts +2 -2
  337. package/src/theme/themes/EveryskLight.ts +2 -2
  338. package/src/theme/themes/MidnightEmber.ts +15 -15
  339. package/src/types/anyRecord.ts +2 -2
  340. package/src/types/datastore.ts +56 -22
  341. package/src/types/datastoreDataFormat.ts +12 -0
  342. package/src/types/entityQuery.ts +122 -38
  343. package/src/types/file.ts +8 -6
  344. package/src/types/portfolio.ts +70 -74
  345. package/src/types/profile.ts +0 -11
  346. package/src/types/workflow.ts +38 -9
  347. package/src/types/workspace.ts +2 -4
  348. package/src/ui/index.ts +1 -1
  349. package/src/workflow/index.ts +5 -0
@@ -1,83 +1,43 @@
1
- import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
2
1
  import { useAxios } from "../useAxios.js";
2
+ import { useEntityQuery } from "../useEntityQuery.js";
3
+ import { missingWorkspaceError } from "../../api/entityQuery.js";
3
4
  import { getFile } from "../../api/file.js";
4
- import { useEffect } from "react";
5
- import { useQuery } from "@tanstack/react-query";
5
+ import { withoutData } from "./fileData.js";
6
+ import { useCallback } from "react";
6
7
  //#region src/hooks/file/useFetchFile.ts
7
- var defaultQueryOptions = {
8
- refetchOnMount: "always",
9
- staleTime: 0,
10
- gcTime: 0
11
- };
12
8
  /**
13
9
  * useFetchFile
14
10
  *
15
- * Data-fetching hook built on TanStack Query to retrieve a single file by ID.
16
- *
17
- * It also:
18
- * - builds a stable React Query `queryKey` that can be reused by mutation hooks for cache invalidation
19
- * - triggers an error alert via `useAppAlert` whenever `query.error` is present
20
- *
21
- * Important notes:
22
- * - Always returns a single `EveryskFile` object.
23
- * - `EveryskFile.data` represents the file content and is expected to be a Base64-encoded string
24
- * when provided by the API (or when sending content through mutations).
25
- *
26
- * Parameters (FetchFileProps):
27
- * @param {string} id
28
- * EveryskFile identifier (required).
29
- *
30
- * @param {string} workspace
31
- * Workspace the file belongs to (required by `getFile`).
32
- *
33
- * @param {EntityQueryOptions<any>} [queryOptions=defaultQueryOptions]
34
- * TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
35
- *
36
- * Returns:
37
- * @returns {object}
38
- * TanStack Query's `query` object extended with:
39
- * - `queryKey`: the cache key used by React Query
40
- *
41
- * Tip:
42
- * - The returned `queryKey` can be reused by mutation hooks for cache invalidation:
43
- * ```ts
44
- * const fetch = useFetchFile({ id: "file-123", workspace: "ws-1" });
45
- * useFileMutations({ queryKey: fetch.queryKey });
46
- * ```
11
+ * Fetches one file; `data` is the file, or whatever `select` makes of it. Idle while `id` is
12
+ * empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error
13
+ * alert. The file comes without its content unless `withData` asks for it: show or download it
14
+ * through its `url`.
47
15
  *
48
- * Example:
49
- * ```ts
50
- * const { data, isLoading } = useFetchFile({
51
- * id: "file-123",
52
- * workspace: "ws-1",
53
- * });
54
- * // data -> EveryskFile
55
- * ```
16
+ * @param {FetchFileProps} props - `id`, `workspace`, `withData`, `select` and TanStack
17
+ * `queryOptions`.
18
+ * @returns {object} The `useQuery` result, plus `queryKey`.
56
19
  */
57
- var useFetchFile = ({ id, workspace, queryOptions = defaultQueryOptions }) => {
20
+ var useFetchFile = ({ id, workspace, select, queryOptions, withData = false }) => {
58
21
  const { api } = useAxios();
59
- const { showAlert } = useAppAlert();
60
22
  const queryKey = [
61
23
  "file",
62
24
  id,
63
- workspace
25
+ workspace,
26
+ { withData }
64
27
  ];
65
- const query = useQuery({
66
- queryKey,
67
- queryFn: async () => {
68
- return await getFile(api, id, workspace);
69
- },
70
- ...queryOptions ?? {}
71
- });
72
- useEffect(() => {
73
- if (!query.error) return;
74
- showAlert({
75
- severity: "error",
76
- message: query.error.message
77
- });
78
- }, [query.error, showAlert]);
28
+ const selectFile = useCallback((file) => {
29
+ const visible = withData ? file : withoutData(file);
30
+ return select ? select(visible) : visible;
31
+ }, [withData, select]);
79
32
  return {
80
- ...query,
33
+ ...useEntityQuery({
34
+ queryKey,
35
+ fetchEntity: (signal) => getFile(api, id, workspace, { withData }, signal),
36
+ select: selectFile,
37
+ enabled: Boolean(id),
38
+ configError: workspace ? void 0 : missingWorkspaceError("useFetchFile"),
39
+ queryOptions
40
+ }),
81
41
  queryKey
82
42
  };
83
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchFile.js","names":[],"sources":["../../../src/hooks/file/useFetchFile.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { useQuery } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport type { EveryskFile } from \"@/types/file\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport { getFile } from \"@/api/file\";\nimport type { EntityQueryOptions, FetchEntityParams } from \"@/types/entityQuery\";\n\nexport type FetchFileProps<TData = EveryskFile, TSelected = TData> = FetchEntityParams<TData, TSelected>;\n\nconst defaultQueryOptions: EntityQueryOptions<EveryskFile> = {\n refetchOnMount: \"always\",\n staleTime: 0,\n gcTime: 0\n}\n\n/**\n * useFetchFile\n *\n * Data-fetching hook built on TanStack Query to retrieve a single file by ID.\n *\n * It also:\n * - builds a stable React Query `queryKey` that can be reused by mutation hooks for cache invalidation\n * - triggers an error alert via `useAppAlert` whenever `query.error` is present\n *\n * Important notes:\n * - Always returns a single `EveryskFile` object.\n * - `EveryskFile.data` represents the file content and is expected to be a Base64-encoded string\n * when provided by the API (or when sending content through mutations).\n *\n * Parameters (FetchFileProps):\n * @param {string} id\n * EveryskFile identifier (required).\n *\n * @param {string} workspace\n * Workspace the file belongs to (required by `getFile`).\n *\n * @param {EntityQueryOptions<any>} [queryOptions=defaultQueryOptions]\n * TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).\n *\n * Returns:\n * @returns {object}\n * TanStack Query's `query` object extended with:\n * - `queryKey`: the cache key used by React Query\n *\n * Tip:\n * - The returned `queryKey` can be reused by mutation hooks for cache invalidation:\n * ```ts\n * const fetch = useFetchFile({ id: \"file-123\", workspace: \"ws-1\" });\n * useFileMutations({ queryKey: fetch.queryKey });\n * ```\n *\n * Example:\n * ```ts\n * const { data, isLoading } = useFetchFile({\n * id: \"file-123\",\n * workspace: \"ws-1\",\n * });\n * // data -> EveryskFile\n * ```\n */\nexport const useFetchFile = ({ id, workspace, queryOptions = defaultQueryOptions }: FetchFileProps) => {\n\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n\n const queryKey = [\"file\", id, workspace];\n\n const query = useQuery<EveryskFile>({\n queryKey,\n queryFn: async () => {\n const file = await getFile(api, id, workspace);\n return file;\n },\n ...queryOptions ?? {}\n });\n\n useEffect(() => {\n if (!query.error) return;\n\n showAlert({\n severity: \"error\",\n message: query.error.message,\n });\n }, [query.error, showAlert]);\n\n return {\n ...query,\n queryKey,\n };\n};\n"],"mappings":";;;;;;AAYA,IAAM,sBAAuD;CACzD,gBAAgB;CAChB,WAAW;CACX,QAAQ;AACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,IAAa,gBAAgB,EAAE,IAAI,WAAW,eAAe,0BAA0C;CAEnG,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAElC,MAAM,WAAW;EAAC;EAAQ;EAAI;CAAS;CAEvC,MAAM,QAAQ,SAAsB;EAChC;EACA,SAAS,YAAY;GAEjB,OAAO,MADY,QAAQ,KAAK,IAAI,SAAS;EAEjD;EACA,GAAG,gBAAgB,CAAC;CACxB,CAAC;CAED,gBAAgB;EACZ,IAAI,CAAC,MAAM,OAAO;EAElB,UAAU;GACN,UAAU;GACV,SAAS,MAAM,MAAM;EACzB,CAAC;CACL,GAAG,CAAC,MAAM,OAAO,SAAS,CAAC;CAE3B,OAAO;EACH,GAAG;EACH;CACJ;AACJ"}
1
+ {"version":3,"file":"useFetchFile.js","names":[],"sources":["../../../src/hooks/file/useFetchFile.ts"],"sourcesContent":["import { useCallback } from \"react\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityQuery } from \"@/hooks/useEntityQuery\";\nimport { missingWorkspaceError } from \"@/api/entityQuery\";\nimport { getFile } from \"@/api/file\";\nimport type { EveryskFile } from \"@/types/file\";\nimport type { FetchEntityByIdProps } from \"@/types/entityQuery\";\nimport { withoutData, type FileDataProps } from \"./fileData\";\n\nexport type FetchFileProps<TData = EveryskFile, TSelected = TData> = FetchEntityByIdProps<\n TData,\n TSelected\n> &\n FileDataProps;\n\n/**\n * useFetchFile\n *\n * Fetches one file; `data` is the file, or whatever `select` makes of it. Idle while `id` is\n * empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error\n * alert. The file comes without its content unless `withData` asks for it: show or download it\n * through its `url`.\n *\n * @param {FetchFileProps} props - `id`, `workspace`, `withData`, `select` and TanStack\n * `queryOptions`.\n * @returns {object} The `useQuery` result, plus `queryKey`.\n */\nexport const useFetchFile = <TSelected = EveryskFile>({\n id,\n workspace,\n select,\n queryOptions,\n withData = false,\n}: FetchFileProps<EveryskFile, TSelected>) => {\n const { api } = useAxios();\n\n const queryKey = [\"file\", id, workspace, { withData }];\n\n const selectFile = useCallback(\n (file: EveryskFile): TSelected => {\n const visible = withData ? file : withoutData(file);\n return select ? select(visible) : (visible as TSelected);\n },\n [withData, select],\n );\n\n const query = useEntityQuery<EveryskFile, TSelected>({\n queryKey,\n fetchEntity: (signal) => getFile(api, id, workspace, { withData }, signal),\n select: selectFile,\n enabled: Boolean(id),\n configError: workspace ? undefined : missingWorkspaceError(\"useFetchFile\"),\n queryOptions,\n });\n\n return { ...query, queryKey };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BA,IAAa,gBAAyC,EAClD,IACA,WACA,QACA,cACA,WAAW,YAC+B;CAC1C,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,WAAW;EAAC;EAAQ;EAAI;EAAW,EAAE,SAAS;CAAC;CAErD,MAAM,aAAa,aACd,SAAiC;EAC9B,MAAM,UAAU,WAAW,OAAO,YAAY,IAAI;EAClD,OAAO,SAAS,OAAO,OAAO,IAAK;CACvC,GACA,CAAC,UAAU,MAAM,CACrB;CAWA,OAAO;EAAE,GATK,eAAuC;GACjD;GACA,cAAc,WAAW,QAAQ,KAAK,IAAI,WAAW,EAAE,SAAS,GAAG,MAAM;GACzE,QAAQ;GACR,SAAS,QAAQ,EAAE;GACnB,aAAa,YAAY,KAAA,IAAY,sBAAsB,cAAc;GACzE;EACJ,CAEY;EAAO;CAAS;AAChC"}
@@ -1,60 +1,26 @@
1
- import { type UseInfiniteQueryOptions, type QueryKey } from "@tanstack/react-query";
2
1
  import type { EveryskFile, FileListResponse } from "../../types/file.d.ts";
3
- import type { FetchEntitiesParams } from "../../types/entityQuery.d.ts";
4
- type PageToken = string | null;
5
- type InfiniteOptions<TData> = Omit<UseInfiniteQueryOptions<FileListResponse, Error, TData, QueryKey, PageToken>, "queryKey" | "queryFn" | "initialPageParam" | "getNextPageParam">;
6
- export type FetchInfiniteFileProps = FetchEntitiesParams<EveryskFile[], InfiniteOptions<EveryskFile[]>> & {
7
- pageSize?: number;
8
- };
2
+ import type { FetchEntitiesProps, ListQueryProps, ListCache } from "../../types/entityQuery.d.ts";
3
+ import { type FileDataProps } from "./fileData";
4
+ /** The query cache of `useFetchFiles`, for typing `setQueryData`. */
5
+ export type FilesCache = ListCache<FileListResponse>;
6
+ export type FetchFilesProps<TData = EveryskFile[]> = ListQueryProps & FetchEntitiesProps<EveryskFile, TData, FileListResponse> & FileDataProps;
9
7
  /**
10
8
  * useFetchFiles
11
9
  *
12
- * Data-fetching hook built on TanStack Query's `useInfiniteQuery` to retrieve
13
- * files with cursor-based pagination.
14
- *
15
- * It also:
16
- * - flattens all pages into a single `EveryskFile[]` via `select`
17
- *
18
- * Important notes:
19
- * - `query.data` returns a flat `EveryskFile[]` (all pages merged).
20
- *
21
- * Parameters (FetchInfiniteFileProps):
22
- * @param {FilterClause[]} [filters=[]]
23
- * Filters applied to every page request. Must include a `workspace` filter.
24
- *
25
- * @param {string[]} [order=[]]
26
- * Sorting applied to every page request.
27
- *
28
- * @param {string} [projection=""]
29
- * Single field to project: `"field"` returns only that field (others come back null),
30
- * `"-field"` returns every field except that one. One field only — lists 500. Omitted when empty.
31
- *
32
- * @param {number} [pageSize=10]
33
- * Number of files to fetch per page.
34
- *
35
- * @param {InfiniteOptions<EveryskFile[]>} [queryOptions]
36
- * TanStack Query options passed through to `useInfiniteQuery`
37
- * (e.g., enabled, staleTime, gcTime, etc.).
38
- *
39
- * Returns:
40
- * @returns {object}
41
- * - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)
42
- * - `queryKey`: the cache key used by React Query
43
- *
44
- * Example:
45
- * ```ts
46
- * const { query } = useFetchFiles({
47
- * filters: [{ field: "workspace", value: "ws-1" }],
48
- * pageSize: 20,
49
- * });
50
- *
51
- * // Flat list of all fetched files
52
- * const files = query.data ?? [];
53
- * ```
10
+ * Lists files with cursor pagination; `query.data` is every loaded page merged, or whatever
11
+ * `select` makes of it. Paging, `select`, `fetchAllPages` and the missing-workspace error
12
+ * behave as in `useFetchDatastores`. The files come without their content unless `withData`
13
+ * asks for it: show or download each through its `url`. The exclusion of `data` is added to a
14
+ * `projection` of the app's own that only excludes fields; one that includes fields is sent as
15
+ * given (see `projectionToSend`). Either way the content is left out of what the hook returns
16
+ * unless `withData` asks for it.
17
+ *
18
+ * @param {FetchFilesProps} props - Filters (one must be `workspace`), order, projection,
19
+ * page size, `withData`, `select`, `fetchAllPages` and TanStack `queryOptions`.
20
+ * @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
54
21
  */
55
- export declare function useFetchFiles({ filters, order, projection, pageSize, queryOptions }: FetchInfiniteFileProps): {
56
- query: import("@tanstack/react-query").UseInfiniteQueryResult<EveryskFile[], Error>;
22
+ export declare function useFetchFiles<TData = EveryskFile[]>({ filters, order, projection, pageSize, select, fetchAllPages, queryOptions, withData, }: FetchFilesProps<TData>): {
23
+ query: import("@tanstack/react-query").UseInfiniteQueryResult<TData, Error>;
57
24
  queryKey: unknown[];
58
25
  };
59
- export {};
60
26
  //# sourceMappingURL=useFetchFiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchFiles.d.ts","sourceRoot":"","sources":["../../../src/hooks/file/useFetchFiles.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,KAAK,uBAAuB,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAItG,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,KAAK,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;AAE/B,KAAK,eAAe,CAAC,KAAK,IAAI,IAAI,CAC9B,uBAAuB,CAAC,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,EAC5E,UAAU,GAAG,SAAS,GAAG,kBAAkB,GAAG,kBAAkB,CACnE,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,WAAW,EAAE,EAAE,eAAe,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAQF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAgB,aAAa,CAAC,EAAE,OAAY,EAAE,KAAU,EAAE,UAAe,EAAE,QAAa,EAAE,YAAY,EAAE,EAAE,sBAAsB;;;EAoC/H"}
1
+ {"version":3,"file":"useFetchFiles.d.ts","sourceRoot":"","sources":["../../../src/hooks/file/useFetchFiles.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,EACR,kBAAkB,EAClB,cAAc,EACd,SAAS,EAEZ,MAAM,qBAAqB,CAAC;AAO7B,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7D,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC;AAErD,MAAM,MAAM,eAAe,CAAC,KAAK,GAAG,WAAW,EAAE,IAAI,cAAc,GAC/D,kBAAkB,CAAC,WAAW,EAAE,KAAK,EAAE,gBAAgB,CAAC,GACxD,aAAa,CAAC;AAqBlB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,KAAK,GAAG,WAAW,EAAE,EAAE,EACjD,OAAY,EACZ,KAAU,EACV,UAAe,EACf,QAAa,EACb,MAAM,EACN,aAAqB,EACrB,YAAY,EACZ,QAAgB,GACnB,EAAE,eAAe,CAAC,KAAK,CAAC;;;EA2CxB"}
@@ -1,84 +1,68 @@
1
1
  import { useAxios } from "../useAxios.js";
2
- import { buildQueryKey, buildQueryObject } from "../../api/entityQuery.js";
2
+ import { useEntityInfiniteQuery } from "../useEntityInfiniteQuery.js";
3
+ import { buildQueryKey, buildQueryObject, hasWorkspaceFilter, missingWorkspaceError } from "../../api/entityQuery.js";
3
4
  import { listFiles } from "../../api/file.js";
4
- import { useMemo } from "react";
5
- import { useInfiniteQuery } from "@tanstack/react-query";
5
+ import { withoutData } from "./fileData.js";
6
+ import { useCallback } from "react";
6
7
  //#region src/hooks/file/useFetchFiles.ts
7
- var defaultQueryOptions = {
8
- refetchOnMount: "always",
9
- staleTime: 0,
10
- gcTime: 0
8
+ /** What leaves the content out of a list: the JSON query returns `data` in full otherwise. */
9
+ var WITHOUT_DATA_PROJECTION = "-data";
10
+ /**
11
+ * The projection a list read sends. The content is left out unless asked for: alone when the app
12
+ * gave no projection, and added to one that only excludes fields. A projection that includes
13
+ * fields is sent as given, since mixing an inclusion with an exclusion is a 500; it then decides
14
+ * itself whether `data` is read.
15
+ */
16
+ var projectionToSend = (projection, withData) => {
17
+ if (withData) return projection;
18
+ const fields = typeof projection === "string" ? [projection].filter(Boolean) : projection;
19
+ if (fields.length === 0) return WITHOUT_DATA_PROJECTION;
20
+ if (!fields.every((field) => field.startsWith("-")) || fields.includes(WITHOUT_DATA_PROJECTION)) return projection;
21
+ return [...fields, WITHOUT_DATA_PROJECTION];
11
22
  };
12
23
  /**
13
24
  * useFetchFiles
14
25
  *
15
- * Data-fetching hook built on TanStack Query's `useInfiniteQuery` to retrieve
16
- * files with cursor-based pagination.
17
- *
18
- * It also:
19
- * - flattens all pages into a single `EveryskFile[]` via `select`
20
- *
21
- * Important notes:
22
- * - `query.data` returns a flat `EveryskFile[]` (all pages merged).
23
- *
24
- * Parameters (FetchInfiniteFileProps):
25
- * @param {FilterClause[]} [filters=[]]
26
- * Filters applied to every page request. Must include a `workspace` filter.
27
- *
28
- * @param {string[]} [order=[]]
29
- * Sorting applied to every page request.
30
- *
31
- * @param {string} [projection=""]
32
- * Single field to project: `"field"` returns only that field (others come back null),
33
- * `"-field"` returns every field except that one. One field only — lists 500. Omitted when empty.
34
- *
35
- * @param {number} [pageSize=10]
36
- * Number of files to fetch per page.
37
- *
38
- * @param {InfiniteOptions<EveryskFile[]>} [queryOptions]
39
- * TanStack Query options passed through to `useInfiniteQuery`
40
- * (e.g., enabled, staleTime, gcTime, etc.).
41
- *
42
- * Returns:
43
- * @returns {object}
44
- * - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)
45
- * - `queryKey`: the cache key used by React Query
46
- *
47
- * Example:
48
- * ```ts
49
- * const { query } = useFetchFiles({
50
- * filters: [{ field: "workspace", value: "ws-1" }],
51
- * pageSize: 20,
52
- * });
26
+ * Lists files with cursor pagination; `query.data` is every loaded page merged, or whatever
27
+ * `select` makes of it. Paging, `select`, `fetchAllPages` and the missing-workspace error
28
+ * behave as in `useFetchDatastores`. The files come without their content unless `withData`
29
+ * asks for it: show or download each through its `url`. The exclusion of `data` is added to a
30
+ * `projection` of the app's own that only excludes fields; one that includes fields is sent as
31
+ * given (see `projectionToSend`). Either way the content is left out of what the hook returns
32
+ * unless `withData` asks for it.
53
33
  *
54
- * // Flat list of all fetched files
55
- * const files = query.data ?? [];
56
- * ```
34
+ * @param {FetchFilesProps} props - Filters (one must be `workspace`), order, projection,
35
+ * page size, `withData`, `select`, `fetchAllPages` and TanStack `queryOptions`.
36
+ * @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
57
37
  */
58
- function useFetchFiles({ filters = [], order = [], projection = "", pageSize = 10, queryOptions }) {
38
+ function useFetchFiles({ filters = [], order = [], projection = "", pageSize = 10, select, fetchAllPages = false, queryOptions, withData = false }) {
59
39
  const { api } = useAxios();
60
- const queryKey = buildQueryKey(["files"], filters);
61
- const mergedQueryOptions = useMemo(() => ({
62
- ...defaultQueryOptions,
63
- ...queryOptions ?? {}
64
- }), [queryOptions]);
40
+ const sentProjection = projectionToSend(projection, withData);
41
+ const queryKey = buildQueryKey(["files"], filters, {
42
+ order,
43
+ projection: sentProjection,
44
+ pageSize,
45
+ fetchAllPages
46
+ });
47
+ const selectFiles = useCallback((files) => {
48
+ const visible = withData ? files : files.map(withoutData);
49
+ return select ? select(visible) : visible;
50
+ }, [withData, select]);
65
51
  return {
66
- query: useInfiniteQuery({
52
+ query: useEntityInfiniteQuery({
67
53
  queryKey,
68
- initialPageParam: null,
69
- getNextPageParam: (lastPage) => lastPage.next_page_token ?? void 0,
70
- queryFn: async ({ pageParam }) => {
71
- const queryFilter = buildQueryObject({
72
- filters,
73
- order,
74
- projection,
75
- pageSize,
76
- pageToken: pageParam ?? void 0
77
- });
78
- return await listFiles(api, queryFilter);
79
- },
80
- select: (data) => data.pages.flatMap((p) => p.files),
81
- ...mergedQueryOptions
54
+ itemsKey: "files",
55
+ fetchPage: (pageToken, signal) => listFiles(api, buildQueryObject({
56
+ filters,
57
+ order,
58
+ projection: sentProjection,
59
+ pageSize,
60
+ pageToken
61
+ }), signal),
62
+ select: selectFiles,
63
+ fetchAllPages,
64
+ configError: hasWorkspaceFilter(filters) ? void 0 : missingWorkspaceError("useFetchFiles"),
65
+ queryOptions
82
66
  }),
83
67
  queryKey
84
68
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchFiles.js","names":[],"sources":["../../../src/hooks/file/useFetchFiles.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useInfiniteQuery, type UseInfiniteQueryOptions, type QueryKey } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { listFiles } from \"@/api/file\";\nimport type { EveryskFile, FileListResponse } from \"@/types/file\";\nimport type { FetchEntitiesParams } from \"@/types/entityQuery\";\nimport { buildQueryKey, buildQueryObject } from \"@/api/entityQuery\";\n\ntype PageToken = string | null;\n\ntype InfiniteOptions<TData> = Omit<\n UseInfiniteQueryOptions<FileListResponse, Error, TData, QueryKey, PageToken>,\n \"queryKey\" | \"queryFn\" | \"initialPageParam\" | \"getNextPageParam\"\n>;\n\nexport type FetchInfiniteFileProps = FetchEntitiesParams<EveryskFile[], InfiniteOptions<EveryskFile[]>> & {\n pageSize?: number;\n};\n\nconst defaultQueryOptions: InfiniteOptions<EveryskFile[]> = {\n refetchOnMount: \"always\",\n staleTime: 0,\n gcTime: 0,\n};\n\n/**\n * useFetchFiles\n *\n * Data-fetching hook built on TanStack Query's `useInfiniteQuery` to retrieve\n * files with cursor-based pagination.\n *\n * It also:\n * - flattens all pages into a single `EveryskFile[]` via `select`\n *\n * Important notes:\n * - `query.data` returns a flat `EveryskFile[]` (all pages merged).\n *\n * Parameters (FetchInfiniteFileProps):\n * @param {FilterClause[]} [filters=[]]\n * Filters applied to every page request. Must include a `workspace` filter.\n *\n * @param {string[]} [order=[]]\n * Sorting applied to every page request.\n *\n * @param {string} [projection=\"\"]\n * Single field to project: `\"field\"` returns only that field (others come back null),\n * `\"-field\"` returns every field except that one. One field only — lists 500. Omitted when empty.\n *\n * @param {number} [pageSize=10]\n * Number of files to fetch per page.\n *\n * @param {InfiniteOptions<EveryskFile[]>} [queryOptions]\n * TanStack Query options passed through to `useInfiniteQuery`\n * (e.g., enabled, staleTime, gcTime, etc.).\n *\n * Returns:\n * @returns {object}\n * - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)\n * - `queryKey`: the cache key used by React Query\n *\n * Example:\n * ```ts\n * const { query } = useFetchFiles({\n * filters: [{ field: \"workspace\", value: \"ws-1\" }],\n * pageSize: 20,\n * });\n *\n * // Flat list of all fetched files\n * const files = query.data ?? [];\n * ```\n */\nexport function useFetchFiles({ filters = [], order = [], projection = \"\", pageSize = 10, queryOptions }: FetchInfiniteFileProps) {\n const { api } = useAxios();\n\n const queryKey = buildQueryKey([\"files\"], filters);\n\n const mergedQueryOptions = useMemo<InfiniteOptions<EveryskFile[]>>(() => ({\n ...defaultQueryOptions,\n ...(queryOptions ?? {}),\n }), [queryOptions]);\n\n const query = useInfiniteQuery<FileListResponse, Error, EveryskFile[], QueryKey, PageToken>({\n queryKey,\n initialPageParam: null,\n getNextPageParam: (lastPage) => lastPage.next_page_token ?? undefined,\n\n queryFn: async ({ pageParam }) => {\n const queryFilter = buildQueryObject({\n filters,\n order,\n projection,\n pageSize,\n pageToken: pageParam ?? undefined,\n });\n\n return await listFiles(api, queryFilter);\n },\n\n select: (data) => data.pages.flatMap((p) => p.files),\n\n ...mergedQueryOptions,\n });\n\n return {\n query,\n queryKey,\n };\n}"],"mappings":";;;;;;AAoBA,IAAM,sBAAsD;CACxD,gBAAgB;CAChB,WAAW;CACX,QAAQ;AACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,cAAc,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,GAAG,aAAa,IAAI,WAAW,IAAI,gBAAwC;CAC9H,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,WAAW,cAAc,CAAC,OAAO,GAAG,OAAO;CAEjD,MAAM,qBAAqB,eAA+C;EACtE,GAAG;EACH,GAAI,gBAAgB,CAAC;CACzB,IAAI,CAAC,YAAY,CAAC;CAwBlB,OAAO;EACH,OAvBU,iBAA8E;GACxF;GACA,kBAAkB;GAClB,mBAAmB,aAAa,SAAS,mBAAmB,KAAA;GAE5D,SAAS,OAAO,EAAE,gBAAgB;IAC9B,MAAM,cAAc,iBAAiB;KACjC;KACA;KACA;KACA;KACA,WAAW,aAAa,KAAA;IAC5B,CAAC;IAED,OAAO,MAAM,UAAU,KAAK,WAAW;GAC3C;GAEA,SAAS,SAAS,KAAK,MAAM,SAAS,MAAM,EAAE,KAAK;GAEnD,GAAG;EACP,CAGI;EACA;CACJ;AACJ"}
1
+ {"version":3,"file":"useFetchFiles.js","names":[],"sources":["../../../src/hooks/file/useFetchFiles.ts"],"sourcesContent":["import { useCallback } from \"react\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityInfiniteQuery } from \"@/hooks/useEntityInfiniteQuery\";\nimport { listFiles } from \"@/api/file\";\nimport type { EveryskFile, FileListResponse } from \"@/types/file\";\nimport type {\n FetchEntitiesProps,\n ListQueryProps,\n ListCache,\n Projection,\n} from \"@/types/entityQuery\";\nimport {\n buildQueryKey,\n buildQueryObject,\n hasWorkspaceFilter,\n missingWorkspaceError,\n} from \"@/api/entityQuery\";\nimport { withoutData, type FileDataProps } from \"./fileData\";\n\n/** The query cache of `useFetchFiles`, for typing `setQueryData`. */\nexport type FilesCache = ListCache<FileListResponse>;\n\nexport type FetchFilesProps<TData = EveryskFile[]> = ListQueryProps &\n FetchEntitiesProps<EveryskFile, TData, FileListResponse> &\n FileDataProps;\n\n/** What leaves the content out of a list: the JSON query returns `data` in full otherwise. */\nconst WITHOUT_DATA_PROJECTION = \"-data\";\n\n/**\n * The projection a list read sends. The content is left out unless asked for: alone when the app\n * gave no projection, and added to one that only excludes fields. A projection that includes\n * fields is sent as given, since mixing an inclusion with an exclusion is a 500; it then decides\n * itself whether `data` is read.\n */\nconst projectionToSend = (projection: Projection, withData: boolean): Projection => {\n if (withData) return projection;\n\n const fields = typeof projection === \"string\" ? [projection].filter(Boolean) : projection;\n if (fields.length === 0) return WITHOUT_DATA_PROJECTION;\n if (!fields.every((field) => field.startsWith(\"-\")) || fields.includes(WITHOUT_DATA_PROJECTION))\n return projection;\n return [...fields, WITHOUT_DATA_PROJECTION];\n};\n\n/**\n * useFetchFiles\n *\n * Lists files with cursor pagination; `query.data` is every loaded page merged, or whatever\n * `select` makes of it. Paging, `select`, `fetchAllPages` and the missing-workspace error\n * behave as in `useFetchDatastores`. The files come without their content unless `withData`\n * asks for it: show or download each through its `url`. The exclusion of `data` is added to a\n * `projection` of the app's own that only excludes fields; one that includes fields is sent as\n * given (see `projectionToSend`). Either way the content is left out of what the hook returns\n * unless `withData` asks for it.\n *\n * @param {FetchFilesProps} props - Filters (one must be `workspace`), order, projection,\n * page size, `withData`, `select`, `fetchAllPages` and TanStack `queryOptions`.\n * @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.\n */\nexport function useFetchFiles<TData = EveryskFile[]>({\n filters = [],\n order = [],\n projection = \"\",\n pageSize = 10,\n select,\n fetchAllPages = false,\n queryOptions,\n withData = false,\n}: FetchFilesProps<TData>) {\n const { api } = useAxios();\n const sentProjection = projectionToSend(projection, withData);\n\n const queryKey = buildQueryKey([\"files\"], filters, {\n order,\n projection: sentProjection,\n pageSize,\n fetchAllPages,\n });\n\n const selectFiles = useCallback(\n (files: EveryskFile[]): TData => {\n const visible = withData ? files : files.map(withoutData);\n return select ? select(visible) : (visible as TData);\n },\n [withData, select],\n );\n\n const query = useEntityInfiniteQuery<FileListResponse, \"files\", TData>({\n queryKey,\n itemsKey: \"files\",\n fetchPage: (pageToken, signal) =>\n listFiles(\n api,\n buildQueryObject({\n filters,\n order,\n projection: sentProjection,\n pageSize,\n pageToken,\n }),\n signal,\n ),\n select: selectFiles,\n fetchAllPages,\n configError: hasWorkspaceFilter(filters)\n ? undefined\n : missingWorkspaceError(\"useFetchFiles\"),\n queryOptions,\n });\n\n return { query, queryKey };\n}\n"],"mappings":";;;;;;;;AA4BA,IAAM,0BAA0B;;;;;;;AAQhC,IAAM,oBAAoB,YAAwB,aAAkC;CAChF,IAAI,UAAU,OAAO;CAErB,MAAM,SAAS,OAAO,eAAe,WAAW,CAAC,UAAU,CAAC,CAAC,OAAO,OAAO,IAAI;CAC/E,IAAI,OAAO,WAAW,GAAG,OAAO;CAChC,IAAI,CAAC,OAAO,OAAO,UAAU,MAAM,WAAW,GAAG,CAAC,KAAK,OAAO,SAAS,uBAAuB,GAC1F,OAAO;CACX,OAAO,CAAC,GAAG,QAAQ,uBAAuB;AAC9C;;;;;;;;;;;;;;;;AAiBA,SAAgB,cAAqC,EACjD,UAAU,CAAC,GACX,QAAQ,CAAC,GACT,aAAa,IACb,WAAW,IACX,QACA,gBAAgB,OAChB,cACA,WAAW,SACY;CACvB,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,iBAAiB,iBAAiB,YAAY,QAAQ;CAE5D,MAAM,WAAW,cAAc,CAAC,OAAO,GAAG,SAAS;EAC/C;EACA,YAAY;EACZ;EACA;CACJ,CAAC;CAED,MAAM,cAAc,aACf,UAAgC;EAC7B,MAAM,UAAU,WAAW,QAAQ,MAAM,IAAI,WAAW;EACxD,OAAO,SAAS,OAAO,OAAO,IAAK;CACvC,GACA,CAAC,UAAU,MAAM,CACrB;CAyBA,OAAO;EAAE,OAvBK,uBAAyD;GACnE;GACA,UAAU;GACV,YAAY,WAAW,WACnB,UACI,KACA,iBAAiB;IACb;IACA;IACA,YAAY;IACZ;IACA;GACJ,CAAC,GACD,MACJ;GACJ,QAAQ;GACR;GACA,aAAa,mBAAmB,OAAO,IACjC,KAAA,IACA,sBAAsB,eAAe;GAC3C;EACJ,CAES;EAAO;CAAS;AAC7B"}
@@ -34,7 +34,8 @@ type UseFileMutationsProps = {
34
34
  *
35
35
  * - EveryskFile content (`data`):
36
36
  * - When creating/updating a file, the file content must be provided in `data` as a Base64-encoded string.
37
- * - Send only the raw Base64 content (do not include a data URL prefix like `data:<mime>;base64,`)
37
+ * - Send only the raw Base64 content (do not include a data URL prefix like `data:<mime>;base64,`):
38
+ * `fileToBase64(file)` gives it from a `File`, and a data URL is refused before the request
38
39
  * - `content_type` should match the file MIME type (e.g., "text/csv", "application/pdf").
39
40
  *
40
41
  * Parameters (UseFileMutationsProps):
@@ -51,19 +52,19 @@ type UseFileMutationsProps = {
51
52
  * - `create`:
52
53
  * - mutationFn: `createFile(api, data)`
53
54
  * - variables: `{ data: Partial<EveryskFile> }`
54
- * - success message: "EveryskFile created successfully."
55
+ * - success message: "File created successfully."
55
56
  * - error message: "Unable to create the file. Please try again." (fallback)
56
57
  *
57
58
  * - `update`:
58
59
  * - mutationFn: `updateFile(api, id, data)`
59
60
  * - variables: `{ id: string; data: Partial<EveryskFile> }`
60
- * - success message: "EveryskFile updated successfully."
61
+ * - success message: "File updated successfully."
61
62
  * - error message: "Unable to update the file. Please try again." (fallback)
62
63
  *
63
64
  * - `remove`:
64
65
  * - mutationFn: `deleteFile(api, id, workspace)`
65
66
  * - variables: `{ id: string; workspace: string }`
66
- * - success message: "EveryskFile deleted successfully."
67
+ * - success message: "File deleted successfully."
67
68
  * - error message: "Unable to delete the file. Please try again." (fallback)
68
69
  *
69
70
  * Return value:
@@ -71,7 +72,7 @@ type UseFileMutationsProps = {
71
72
  * Returns an object with the three TanStack Query mutation results:
72
73
  * - `create`: UseMutationResult<EveryskFile, Error, CreateFileProps, unknown>
73
74
  * - `update`: UseMutationResult<EveryskFile, Error, UpdateFileProps, unknown>
74
- * - `remove`: UseMutationResult<EveryskFile, Error, DeleteFileProps, unknown>
75
+ * - `remove`: UseMutationResult<DeletedEntity, Error, DeleteFileProps, unknown>
75
76
  *
76
77
  * Each mutation includes standard TanStack Query helpers:
77
78
  * - `mutate(variables, options?)`
@@ -153,9 +154,9 @@ type UseFileMutationsProps = {
153
154
  * ```
154
155
  */
155
156
  export declare const useFileMutations: ({ queryKey }: UseFileMutationsProps) => {
156
- create: import("@tanstack/react-query").UseMutationResult<EveryskFile, unknown, CreateFileProps, unknown>;
157
- update: import("@tanstack/react-query").UseMutationResult<EveryskFile, unknown, UpdateFileProps, unknown>;
158
- remove: import("@tanstack/react-query").UseMutationResult<import("../..").DeleteEntityDefaultResponse[], unknown, DeleteFileProps, unknown>;
157
+ create: import("@tanstack/react-query").UseMutationResult<EveryskFile, Error, CreateFileProps, unknown>;
158
+ update: import("@tanstack/react-query").UseMutationResult<EveryskFile, Error, UpdateFileProps, unknown>;
159
+ remove: import("@tanstack/react-query").UseMutationResult<import("../..").DeletedEntity, Error, DeleteFileProps, unknown>;
159
160
  };
160
161
  export {};
161
162
  //# sourceMappingURL=useFileMutations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFileMutations.d.ts","sourceRoot":"","sources":["../../../src/hooks/file/useFileMutations.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,eAAe,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,eAAe,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IACzB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB,CAAC;AAKF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0IG;AAEH,eAAO,MAAM,gBAAgB,GAAI,cAAc,qBAAqB;;;;CAuEnE,CAAC"}
1
+ {"version":3,"file":"useFileMutations.d.ts","sourceRoot":"","sources":["../../../src/hooks/file/useFileMutations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,eAAe,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,eAAe,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IACzB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2IG;AAEH,eAAO,MAAM,gBAAgB,GAAI,cAAc,qBAAqB;;;;CAyBnE,CAAC"}
@@ -1,9 +1,7 @@
1
- import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
2
1
  import { useAxios } from "../useAxios.js";
2
+ import { useEntityMutation } from "../useEntityMutation.js";
3
3
  import { createFile, deleteFile, updateFile } from "../../api/file.js";
4
- import { useMutation, useQueryClient } from "@tanstack/react-query";
5
4
  //#region src/hooks/file/useFileMutations.ts
6
- var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? err.message : fallback;
7
5
  /**
8
6
  * useFileMutations
9
7
  *
@@ -22,10 +20,11 @@ var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? e
22
20
  * mutations and show alerts, but it will NOT invalidate any cached queries.
23
21
  * - `remove` requires a `workspace` parameter because the underlying API helper `deleteFile(api, id, workspace)`
24
22
  * expects it as a query param.
25
- *
23
+ *
26
24
  * - EveryskFile content (`data`):
27
25
  * - When creating/updating a file, the file content must be provided in `data` as a Base64-encoded string.
28
- * - Send only the raw Base64 content (do not include a data URL prefix like `data:<mime>;base64,`)
26
+ * - Send only the raw Base64 content (do not include a data URL prefix like `data:<mime>;base64,`):
27
+ * `fileToBase64(file)` gives it from a `File`, and a data URL is refused before the request
29
28
  * - `content_type` should match the file MIME type (e.g., "text/csv", "application/pdf").
30
29
  *
31
30
  * Parameters (UseFileMutationsProps):
@@ -42,19 +41,19 @@ var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? e
42
41
  * - `create`:
43
42
  * - mutationFn: `createFile(api, data)`
44
43
  * - variables: `{ data: Partial<EveryskFile> }`
45
- * - success message: "EveryskFile created successfully."
44
+ * - success message: "File created successfully."
46
45
  * - error message: "Unable to create the file. Please try again." (fallback)
47
46
  *
48
47
  * - `update`:
49
48
  * - mutationFn: `updateFile(api, id, data)`
50
49
  * - variables: `{ id: string; data: Partial<EveryskFile> }`
51
- * - success message: "EveryskFile updated successfully."
50
+ * - success message: "File updated successfully."
52
51
  * - error message: "Unable to update the file. Please try again." (fallback)
53
52
  *
54
53
  * - `remove`:
55
54
  * - mutationFn: `deleteFile(api, id, workspace)`
56
55
  * - variables: `{ id: string; workspace: string }`
57
- * - success message: "EveryskFile deleted successfully."
56
+ * - success message: "File deleted successfully."
58
57
  * - error message: "Unable to delete the file. Please try again." (fallback)
59
58
  *
60
59
  * Return value:
@@ -62,7 +61,7 @@ var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? e
62
61
  * Returns an object with the three TanStack Query mutation results:
63
62
  * - `create`: UseMutationResult<EveryskFile, Error, CreateFileProps, unknown>
64
63
  * - `update`: UseMutationResult<EveryskFile, Error, UpdateFileProps, unknown>
65
- * - `remove`: UseMutationResult<EveryskFile, Error, DeleteFileProps, unknown>
64
+ * - `remove`: UseMutationResult<DeletedEntity, Error, DeleteFileProps, unknown>
66
65
  *
67
66
  * Each mutation includes standard TanStack Query helpers:
68
67
  * - `mutate(variables, options?)`
@@ -145,60 +144,24 @@ var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? e
145
144
  */
146
145
  var useFileMutations = ({ queryKey }) => {
147
146
  const { api } = useAxios();
148
- const { showAlert } = useAppAlert();
149
- const queryClient = useQueryClient();
150
- const invalidate = async () => {
151
- if (!queryKey?.length) return;
152
- await queryClient.invalidateQueries({ queryKey });
153
- };
154
147
  return {
155
- create: useMutation({
156
- mutationFn: async ({ data }) => createFile(api, data),
157
- onSuccess: async () => {
158
- await invalidate();
159
- showAlert({
160
- severity: "success",
161
- message: "EveryskFile created successfully."
162
- });
163
- },
164
- onError: (err) => {
165
- showAlert({
166
- severity: "error",
167
- message: getErrorMessage(err, "Unable to create the file. Please try again.")
168
- });
169
- }
148
+ create: useEntityMutation({
149
+ mutationFn: ({ data }) => createFile(api, data),
150
+ queryKey,
151
+ successMessage: "File created successfully.",
152
+ errorMessage: "Unable to create the file. Please try again."
170
153
  }),
171
- update: useMutation({
172
- mutationFn: async ({ id, data }) => updateFile(api, id, data),
173
- onSuccess: async () => {
174
- await invalidate();
175
- showAlert({
176
- severity: "success",
177
- message: "EveryskFile updated successfully."
178
- });
179
- },
180
- onError: (err) => {
181
- showAlert({
182
- severity: "error",
183
- message: getErrorMessage(err, "Unable to update the file. Please try again.")
184
- });
185
- }
154
+ update: useEntityMutation({
155
+ mutationFn: ({ id, data }) => updateFile(api, id, data),
156
+ queryKey,
157
+ successMessage: "File updated successfully.",
158
+ errorMessage: "Unable to update the file. Please try again."
186
159
  }),
187
- remove: useMutation({
188
- mutationFn: async ({ id, workspace }) => deleteFile(api, id, workspace),
189
- onSuccess: async () => {
190
- await invalidate();
191
- showAlert({
192
- severity: "success",
193
- message: "EveryskFile deleted successfully."
194
- });
195
- },
196
- onError: (err) => {
197
- showAlert({
198
- severity: "error",
199
- message: getErrorMessage(err, "Unable to delete the file. Please try again.")
200
- });
201
- }
160
+ remove: useEntityMutation({
161
+ mutationFn: ({ id, workspace }) => deleteFile(api, id, workspace),
162
+ queryKey,
163
+ successMessage: "File deleted successfully.",
164
+ errorMessage: "Unable to delete the file. Please try again."
202
165
  })
203
166
  };
204
167
  };