@everysk/apps-sdk 0.2.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 +298 -12
  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 +1 -1
  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,93 +1,58 @@
1
- import { useEffect } from "react";
2
-
3
- import { useQuery } from "@tanstack/react-query";
1
+ import { useCallback } from "react";
4
2
 
5
3
  import { useAxios } from "@/hooks/useAxios";
6
- import type { EveryskFile } from "@/types/file";
7
- import { useAppAlert } from "@/contexts/appAlertContext/useAppAlert";
4
+ import { useEntityQuery } from "@/hooks/useEntityQuery";
5
+ import { missingWorkspaceError } from "@/api/entityQuery";
8
6
  import { getFile } from "@/api/file";
9
- import type { EntityQueryOptions, FetchEntityParams } from "@/types/entityQuery";
10
-
11
- export type FetchFileProps<TData = EveryskFile, TSelected = TData> = FetchEntityParams<TData, TSelected>;
7
+ import type { EveryskFile } from "@/types/file";
8
+ import type { FetchEntityByIdProps } from "@/types/entityQuery";
9
+ import { withoutData, type FileDataProps } from "./fileData";
12
10
 
13
- const defaultQueryOptions: EntityQueryOptions<EveryskFile> = {
14
- refetchOnMount: "always",
15
- staleTime: 0,
16
- gcTime: 0
17
- }
11
+ export type FetchFileProps<TData = EveryskFile, TSelected = TData> = FetchEntityByIdProps<
12
+ TData,
13
+ TSelected
14
+ > &
15
+ FileDataProps;
18
16
 
19
17
  /**
20
18
  * useFetchFile
21
19
  *
22
- * Data-fetching hook built on TanStack Query to retrieve a single file by ID.
23
- *
24
- * It also:
25
- * - builds a stable React Query `queryKey` that can be reused by mutation hooks for cache invalidation
26
- * - triggers an error alert via `useAppAlert` whenever `query.error` is present
27
- *
28
- * Important notes:
29
- * - Always returns a single `EveryskFile` object.
30
- * - `EveryskFile.data` represents the file content and is expected to be a Base64-encoded string
31
- * when provided by the API (or when sending content through mutations).
32
- *
33
- * Parameters (FetchFileProps):
34
- * @param {string} id
35
- * EveryskFile identifier (required).
36
- *
37
- * @param {string} workspace
38
- * Workspace the file belongs to (required by `getFile`).
39
- *
40
- * @param {EntityQueryOptions<any>} [queryOptions=defaultQueryOptions]
41
- * TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
20
+ * Fetches one file; `data` is the file, or whatever `select` makes of it. Idle while `id` is
21
+ * empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error
22
+ * alert. The file comes without its content unless `withData` asks for it: show or download it
23
+ * through its `url`.
42
24
  *
43
- * Returns:
44
- * @returns {object}
45
- * TanStack Query's `query` object extended with:
46
- * - `queryKey`: the cache key used by React Query
47
- *
48
- * Tip:
49
- * - The returned `queryKey` can be reused by mutation hooks for cache invalidation:
50
- * ```ts
51
- * const fetch = useFetchFile({ id: "file-123", workspace: "ws-1" });
52
- * useFileMutations({ queryKey: fetch.queryKey });
53
- * ```
54
- *
55
- * Example:
56
- * ```ts
57
- * const { data, isLoading } = useFetchFile({
58
- * id: "file-123",
59
- * workspace: "ws-1",
60
- * });
61
- * // data -> EveryskFile
62
- * ```
25
+ * @param {FetchFileProps} props - `id`, `workspace`, `withData`, `select` and TanStack
26
+ * `queryOptions`.
27
+ * @returns {object} The `useQuery` result, plus `queryKey`.
63
28
  */
64
- export const useFetchFile = ({ id, workspace, queryOptions = defaultQueryOptions }: FetchFileProps) => {
65
-
29
+ export const useFetchFile = <TSelected = EveryskFile>({
30
+ id,
31
+ workspace,
32
+ select,
33
+ queryOptions,
34
+ withData = false,
35
+ }: FetchFileProps<EveryskFile, TSelected>) => {
66
36
  const { api } = useAxios();
67
- const { showAlert } = useAppAlert();
68
37
 
69
- const queryKey = ["file", id, workspace];
38
+ const queryKey = ["file", id, workspace, { withData }];
70
39
 
71
- const query = useQuery<EveryskFile>({
72
- queryKey,
73
- queryFn: async () => {
74
- const file = await getFile(api, id, workspace);
75
- return file;
40
+ const selectFile = useCallback(
41
+ (file: EveryskFile): TSelected => {
42
+ const visible = withData ? file : withoutData(file);
43
+ return select ? select(visible) : (visible as TSelected);
76
44
  },
77
- ...queryOptions ?? {}
78
- });
45
+ [withData, select],
46
+ );
79
47
 
80
- useEffect(() => {
81
- if (!query.error) return;
82
-
83
- showAlert({
84
- severity: "error",
85
- message: query.error.message,
86
- });
87
- }, [query.error, showAlert]);
88
-
89
- return {
90
- ...query,
48
+ const query = useEntityQuery<EveryskFile, TSelected>({
91
49
  queryKey,
92
- };
50
+ fetchEntity: (signal) => getFile(api, id, workspace, { withData }, signal),
51
+ select: selectFile,
52
+ enabled: Boolean(id),
53
+ configError: workspace ? undefined : missingWorkspaceError("useFetchFile"),
54
+ queryOptions,
55
+ });
56
+
57
+ return { ...query, queryKey };
93
58
  };
@@ -1,109 +1,114 @@
1
- import { useMemo } from "react";
2
- import { useInfiniteQuery, type UseInfiniteQueryOptions, type QueryKey } from "@tanstack/react-query";
1
+ import { useCallback } from "react";
3
2
 
4
3
  import { useAxios } from "@/hooks/useAxios";
4
+ import { useEntityInfiniteQuery } from "@/hooks/useEntityInfiniteQuery";
5
5
  import { listFiles } from "@/api/file";
6
6
  import type { EveryskFile, FileListResponse } from "@/types/file";
7
- import type { FetchEntitiesParams } from "@/types/entityQuery";
8
- import { buildQueryKey, buildQueryObject } from "@/api/entityQuery";
7
+ import type {
8
+ FetchEntitiesProps,
9
+ ListQueryProps,
10
+ ListCache,
11
+ Projection,
12
+ } from "@/types/entityQuery";
13
+ import {
14
+ buildQueryKey,
15
+ buildQueryObject,
16
+ hasWorkspaceFilter,
17
+ missingWorkspaceError,
18
+ } from "@/api/entityQuery";
19
+ import { withoutData, type FileDataProps } from "./fileData";
9
20
 
10
- type PageToken = string | null;
21
+ /** The query cache of `useFetchFiles`, for typing `setQueryData`. */
22
+ export type FilesCache = ListCache<FileListResponse>;
11
23
 
12
- type InfiniteOptions<TData> = Omit<
13
- UseInfiniteQueryOptions<FileListResponse, Error, TData, QueryKey, PageToken>,
14
- "queryKey" | "queryFn" | "initialPageParam" | "getNextPageParam"
15
- >;
24
+ export type FetchFilesProps<TData = EveryskFile[]> = ListQueryProps &
25
+ FetchEntitiesProps<EveryskFile, TData, FileListResponse> &
26
+ FileDataProps;
16
27
 
17
- export type FetchInfiniteFileProps = FetchEntitiesParams<EveryskFile[], InfiniteOptions<EveryskFile[]>> & {
18
- pageSize?: number;
19
- };
28
+ /** What leaves the content out of a list: the JSON query returns `data` in full otherwise. */
29
+ const WITHOUT_DATA_PROJECTION = "-data";
30
+
31
+ /**
32
+ * The projection a list read sends. The content is left out unless asked for: alone when the app
33
+ * gave no projection, and added to one that only excludes fields. A projection that includes
34
+ * fields is sent as given, since mixing an inclusion with an exclusion is a 500; it then decides
35
+ * itself whether `data` is read.
36
+ */
37
+ const projectionToSend = (projection: Projection, withData: boolean): Projection => {
38
+ if (withData) return projection;
20
39
 
21
- const defaultQueryOptions: InfiniteOptions<EveryskFile[]> = {
22
- refetchOnMount: "always",
23
- staleTime: 0,
24
- gcTime: 0,
40
+ const fields = typeof projection === "string" ? [projection].filter(Boolean) : projection;
41
+ if (fields.length === 0) return WITHOUT_DATA_PROJECTION;
42
+ if (!fields.every((field) => field.startsWith("-")) || fields.includes(WITHOUT_DATA_PROJECTION))
43
+ return projection;
44
+ return [...fields, WITHOUT_DATA_PROJECTION];
25
45
  };
26
46
 
27
47
  /**
28
48
  * useFetchFiles
29
49
  *
30
- * Data-fetching hook built on TanStack Query's `useInfiniteQuery` to retrieve
31
- * files with cursor-based pagination.
32
- *
33
- * It also:
34
- * - flattens all pages into a single `EveryskFile[]` via `select`
35
- *
36
- * Important notes:
37
- * - `query.data` returns a flat `EveryskFile[]` (all pages merged).
38
- *
39
- * Parameters (FetchInfiniteFileProps):
40
- * @param {FilterClause[]} [filters=[]]
41
- * Filters applied to every page request. Must include a `workspace` filter.
42
- *
43
- * @param {string[]} [order=[]]
44
- * Sorting applied to every page request.
45
- *
46
- * @param {string} [projection=""]
47
- * Single field to project: `"field"` returns only that field (others come back null),
48
- * `"-field"` returns every field except that one. One field only — lists 500. Omitted when empty.
49
- *
50
- * @param {number} [pageSize=10]
51
- * Number of files to fetch per page.
52
- *
53
- * @param {InfiniteOptions<EveryskFile[]>} [queryOptions]
54
- * TanStack Query options passed through to `useInfiniteQuery`
55
- * (e.g., enabled, staleTime, gcTime, etc.).
50
+ * Lists files with cursor pagination; `query.data` is every loaded page merged, or whatever
51
+ * `select` makes of it. Paging, `select`, `fetchAllPages` and the missing-workspace error
52
+ * behave as in `useFetchDatastores`. The files come without their content unless `withData`
53
+ * asks for it: show or download each through its `url`. The exclusion of `data` is added to a
54
+ * `projection` of the app's own that only excludes fields; one that includes fields is sent as
55
+ * given (see `projectionToSend`). Either way the content is left out of what the hook returns
56
+ * unless `withData` asks for it.
56
57
  *
57
- * Returns:
58
- * @returns {object}
59
- * - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)
60
- * - `queryKey`: the cache key used by React Query
61
- *
62
- * Example:
63
- * ```ts
64
- * const { query } = useFetchFiles({
65
- * filters: [{ field: "workspace", value: "ws-1" }],
66
- * pageSize: 20,
67
- * });
68
- *
69
- * // Flat list of all fetched files
70
- * const files = query.data ?? [];
71
- * ```
58
+ * @param {FetchFilesProps} props - Filters (one must be `workspace`), order, projection,
59
+ * page size, `withData`, `select`, `fetchAllPages` and TanStack `queryOptions`.
60
+ * @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
72
61
  */
73
- export function useFetchFiles({ filters = [], order = [], projection = "", pageSize = 10, queryOptions }: FetchInfiniteFileProps) {
62
+ export function useFetchFiles<TData = EveryskFile[]>({
63
+ filters = [],
64
+ order = [],
65
+ projection = "",
66
+ pageSize = 10,
67
+ select,
68
+ fetchAllPages = false,
69
+ queryOptions,
70
+ withData = false,
71
+ }: FetchFilesProps<TData>) {
74
72
  const { api } = useAxios();
73
+ const sentProjection = projectionToSend(projection, withData);
75
74
 
76
- const queryKey = buildQueryKey(["files"], filters);
77
-
78
- const mergedQueryOptions = useMemo<InfiniteOptions<EveryskFile[]>>(() => ({
79
- ...defaultQueryOptions,
80
- ...(queryOptions ?? {}),
81
- }), [queryOptions]);
82
-
83
- const query = useInfiniteQuery<FileListResponse, Error, EveryskFile[], QueryKey, PageToken>({
84
- queryKey,
85
- initialPageParam: null,
86
- getNextPageParam: (lastPage) => lastPage.next_page_token ?? undefined,
87
-
88
- queryFn: async ({ pageParam }) => {
89
- const queryFilter = buildQueryObject({
90
- filters,
91
- order,
92
- projection,
93
- pageSize,
94
- pageToken: pageParam ?? undefined,
95
- });
75
+ const queryKey = buildQueryKey(["files"], filters, {
76
+ order,
77
+ projection: sentProjection,
78
+ pageSize,
79
+ fetchAllPages,
80
+ });
96
81
 
97
- return await listFiles(api, queryFilter);
82
+ const selectFiles = useCallback(
83
+ (files: EveryskFile[]): TData => {
84
+ const visible = withData ? files : files.map(withoutData);
85
+ return select ? select(visible) : (visible as TData);
98
86
  },
87
+ [withData, select],
88
+ );
99
89
 
100
- select: (data) => data.pages.flatMap((p) => p.files),
101
-
102
- ...mergedQueryOptions,
90
+ const query = useEntityInfiniteQuery<FileListResponse, "files", TData>({
91
+ queryKey,
92
+ itemsKey: "files",
93
+ fetchPage: (pageToken, signal) =>
94
+ listFiles(
95
+ api,
96
+ buildQueryObject({
97
+ filters,
98
+ order,
99
+ projection: sentProjection,
100
+ pageSize,
101
+ pageToken,
102
+ }),
103
+ signal,
104
+ ),
105
+ select: selectFiles,
106
+ fetchAllPages,
107
+ configError: hasWorkspaceFilter(filters)
108
+ ? undefined
109
+ : missingWorkspaceError("useFetchFiles"),
110
+ queryOptions,
103
111
  });
104
112
 
105
- return {
106
- query,
107
- queryKey,
108
- };
109
- }
113
+ return { query, queryKey };
114
+ }
@@ -1,7 +1,5 @@
1
- import { useMutation, useQueryClient } from "@tanstack/react-query";
2
-
3
1
  import { useAxios } from "@/hooks/useAxios";
4
- import { useAppAlert } from "@/contexts/appAlertContext/useAppAlert";
2
+ import { useEntityMutation } from "@/hooks/useEntityMutation";
5
3
  import type { EveryskFile } from "@/types/file";
6
4
  import { deleteFile, createFile, updateFile } from "@/api/file";
7
5
 
@@ -23,9 +21,6 @@ type UseFileMutationsProps = {
23
21
  queryKey?: unknown[];
24
22
  };
25
23
 
26
- const getErrorMessage = (err: unknown, fallback: string) =>
27
- err instanceof Error && err.message ? err.message : fallback;
28
-
29
24
  /**
30
25
  * useFileMutations
31
26
  *
@@ -44,10 +39,11 @@ const getErrorMessage = (err: unknown, fallback: string) =>
44
39
  * mutations and show alerts, but it will NOT invalidate any cached queries.
45
40
  * - `remove` requires a `workspace` parameter because the underlying API helper `deleteFile(api, id, workspace)`
46
41
  * expects it as a query param.
47
- *
42
+ *
48
43
  * - EveryskFile content (`data`):
49
44
  * - When creating/updating a file, the file content must be provided in `data` as a Base64-encoded string.
50
- * - Send only the raw Base64 content (do not include a data URL prefix like `data:<mime>;base64,`)
45
+ * - Send only the raw Base64 content (do not include a data URL prefix like `data:<mime>;base64,`):
46
+ * `fileToBase64(file)` gives it from a `File`, and a data URL is refused before the request
51
47
  * - `content_type` should match the file MIME type (e.g., "text/csv", "application/pdf").
52
48
  *
53
49
  * Parameters (UseFileMutationsProps):
@@ -64,19 +60,19 @@ const getErrorMessage = (err: unknown, fallback: string) =>
64
60
  * - `create`:
65
61
  * - mutationFn: `createFile(api, data)`
66
62
  * - variables: `{ data: Partial<EveryskFile> }`
67
- * - success message: "EveryskFile created successfully."
63
+ * - success message: "File created successfully."
68
64
  * - error message: "Unable to create the file. Please try again." (fallback)
69
65
  *
70
66
  * - `update`:
71
67
  * - mutationFn: `updateFile(api, id, data)`
72
68
  * - variables: `{ id: string; data: Partial<EveryskFile> }`
73
- * - success message: "EveryskFile updated successfully."
69
+ * - success message: "File updated successfully."
74
70
  * - error message: "Unable to update the file. Please try again." (fallback)
75
71
  *
76
72
  * - `remove`:
77
73
  * - mutationFn: `deleteFile(api, id, workspace)`
78
74
  * - variables: `{ id: string; workspace: string }`
79
- * - success message: "EveryskFile deleted successfully."
75
+ * - success message: "File deleted successfully."
80
76
  * - error message: "Unable to delete the file. Please try again." (fallback)
81
77
  *
82
78
  * Return value:
@@ -84,7 +80,7 @@ const getErrorMessage = (err: unknown, fallback: string) =>
84
80
  * Returns an object with the three TanStack Query mutation results:
85
81
  * - `create`: UseMutationResult<EveryskFile, Error, CreateFileProps, unknown>
86
82
  * - `update`: UseMutationResult<EveryskFile, Error, UpdateFileProps, unknown>
87
- * - `remove`: UseMutationResult<EveryskFile, Error, DeleteFileProps, unknown>
83
+ * - `remove`: UseMutationResult<DeletedEntity, Error, DeleteFileProps, unknown>
88
84
  *
89
85
  * Each mutation includes standard TanStack Query helpers:
90
86
  * - `mutate(variables, options?)`
@@ -168,72 +164,26 @@ const getErrorMessage = (err: unknown, fallback: string) =>
168
164
 
169
165
  export const useFileMutations = ({ queryKey }: UseFileMutationsProps) => {
170
166
  const { api } = useAxios();
171
- const { showAlert } = useAppAlert();
172
- const queryClient = useQueryClient();
173
-
174
- const invalidate = async () => {
175
- if (!queryKey?.length) return;
176
- await queryClient.invalidateQueries({ queryKey });
177
- };
178
167
 
179
- const create = useMutation({
180
- mutationFn: async ({ data }: CreateFileProps) => createFile(api, data),
181
- onSuccess: async () => {
182
- await invalidate();
183
- showAlert({
184
- severity: "success",
185
- message: "EveryskFile created successfully.",
186
- });
187
- },
188
- onError: (err: unknown) => {
189
- showAlert({
190
- severity: "error",
191
- message: getErrorMessage(
192
- err,
193
- "Unable to create the file. Please try again."
194
- ),
195
- });
196
- },
168
+ const create = useEntityMutation({
169
+ mutationFn: ({ data }: CreateFileProps) => createFile(api, data),
170
+ queryKey,
171
+ successMessage: "File created successfully.",
172
+ errorMessage: "Unable to create the file. Please try again.",
197
173
  });
198
174
 
199
- const update = useMutation({
200
- mutationFn: async ({ id, data }: UpdateFileProps) => updateFile(api, id, data),
201
- onSuccess: async () => {
202
- await invalidate();
203
- showAlert({
204
- severity: "success",
205
- message: "EveryskFile updated successfully.",
206
- });
207
- },
208
- onError: (err: unknown) => {
209
- showAlert({
210
- severity: "error",
211
- message: getErrorMessage(
212
- err,
213
- "Unable to update the file. Please try again."
214
- ),
215
- });
216
- },
175
+ const update = useEntityMutation({
176
+ mutationFn: ({ id, data }: UpdateFileProps) => updateFile(api, id, data),
177
+ queryKey,
178
+ successMessage: "File updated successfully.",
179
+ errorMessage: "Unable to update the file. Please try again.",
217
180
  });
218
181
 
219
- const remove = useMutation({
220
- mutationFn: async ({ id, workspace }: DeleteFileProps) => deleteFile(api, id, workspace),
221
- onSuccess: async () => {
222
- await invalidate();
223
- showAlert({
224
- severity: "success",
225
- message: "EveryskFile deleted successfully.",
226
- });
227
- },
228
- onError: (err: unknown) => {
229
- showAlert({
230
- severity: "error",
231
- message: getErrorMessage(
232
- err,
233
- "Unable to delete the file. Please try again."
234
- ),
235
- });
236
- },
182
+ const remove = useEntityMutation({
183
+ mutationFn: ({ id, workspace }: DeleteFileProps) => deleteFile(api, id, workspace),
184
+ queryKey,
185
+ successMessage: "File deleted successfully.",
186
+ errorMessage: "Unable to delete the file. Please try again.",
237
187
  });
238
188
 
239
189
  return { create, update, remove };
@@ -1,94 +1,42 @@
1
- import { useEffect } from "react";
2
- import { useQuery } from "@tanstack/react-query";
3
-
4
1
  import { useAxios } from "@/hooks/useAxios";
5
- import { useAppAlert } from "@/contexts/appAlertContext/useAppAlert";
6
- import type { Portfolio } from "@/types/portfolio";
2
+ import { useEntityQuery } from "@/hooks/useEntityQuery";
3
+ import { missingWorkspaceError } from "@/api/entityQuery";
7
4
  import { getPortfolio } from "@/api/portfolio";
8
- import type { EntityQueryOptions, FetchEntityParams } from "@/types/entityQuery";
9
-
10
- export type FetchPortfolioProps<TData = Portfolio, TSelected = TData> = FetchEntityParams<TData, TSelected>;
5
+ import type { Portfolio } from "@/types/portfolio";
6
+ import type { FetchEntityByIdProps } from "@/types/entityQuery";
11
7
 
12
- const defaultQueryOptions: EntityQueryOptions<Portfolio> = {
13
- refetchOnMount: "always",
14
- staleTime: 0,
15
- gcTime: 0
16
- }
8
+ export type FetchPortfolioProps<TData = Portfolio, TSelected = TData> = FetchEntityByIdProps<
9
+ TData,
10
+ TSelected
11
+ >;
17
12
 
18
13
  /**
19
14
  * useFetchPortfolio
20
15
  *
21
- * Data-fetching hook built on TanStack Query to retrieve a single portfolio by ID.
22
- *
23
- * It also:
24
- * - builds a stable React Query `queryKey` that can be reused by mutation hooks for cache invalidation
25
- * - triggers an error alert via `useAppAlert` whenever `query.error` is present
26
- *
27
- * Important notes:
28
- * - Always returns a single `Portfolio` object.
29
- *
30
- * Parameters (FetchPortfolioProps):
31
- * @param {string} id
32
- * Portfolio identifier (required).
33
- *
34
- * @param {string} workspace
35
- * Workspace the portfolio belongs to (required by `getPortfolio`).
16
+ * Fetches one portfolio; `data` is the portfolio, or whatever `select` makes of it. Idle while
17
+ * `id` is empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error alert.
36
18
  *
37
- * @param {EntityQueryOptions<Portfolio>} [queryOptions=defaultQueryOptions]
38
- * TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
39
- *
40
- * Returns:
41
- * @returns {object}
42
- * TanStack Query's `query` object extended with:
43
- * - `queryKey`: the cache key used by React Query
44
- *
45
- * Tip:
46
- * - The returned `queryKey` can be reused by mutation hooks for cache invalidation:
47
- * ```ts
48
- * const fetch = useFetchPortfolio({ id: "pf-123", workspace: "ws-1" });
49
- * usePortfolioMutations({ queryKey: fetch.queryKey });
50
- * ```
51
- *
52
- * Example:
53
- * ```ts
54
- * const { data, isLoading } = useFetchPortfolio({
55
- * id: "pf-123",
56
- * workspace: "ws-1",
57
- * });
58
- * // data -> Portfolio
59
- * ```
19
+ * @param {FetchPortfolioProps} props - `id`, `workspace`, `select` and TanStack `queryOptions`.
20
+ * @returns {object} The `useQuery` result, plus `queryKey`.
60
21
  */
61
- export const useFetchPortfolio = ({ id, workspace, queryOptions = defaultQueryOptions }: FetchPortfolioProps) => {
62
-
22
+ export const useFetchPortfolio = <TSelected = Portfolio>({
23
+ id,
24
+ workspace,
25
+ select,
26
+ queryOptions,
27
+ }: FetchPortfolioProps<Portfolio, TSelected>) => {
63
28
  const { api } = useAxios();
64
- const { showAlert } = useAppAlert();
65
29
 
66
- const queryKey = [
67
- "portfolio",
68
- id,
69
- workspace
70
- ];
30
+ const queryKey = ["portfolio", id, workspace];
71
31
 
72
- const query = useQuery<Portfolio>({
32
+ const query = useEntityQuery<Portfolio, TSelected>({
73
33
  queryKey,
74
- queryFn: async () => {
75
- const response = await getPortfolio(api, id, workspace);
76
- return response.portfolio;
77
- },
78
- ...queryOptions ?? {}
34
+ fetchEntity: (signal) => getPortfolio(api, id, workspace, signal),
35
+ select,
36
+ enabled: Boolean(id),
37
+ configError: workspace ? undefined : missingWorkspaceError("useFetchPortfolio"),
38
+ queryOptions,
79
39
  });
80
40
 
81
- useEffect(() => {
82
- if (!query.error) return;
83
-
84
- showAlert({
85
- severity: "error",
86
- message: query.error.message,
87
- });
88
- }, [query.error, showAlert]);
89
-
90
- return {
91
- ...query,
92
- queryKey,
93
- };
41
+ return { ...query, queryKey };
94
42
  };