@everysk/apps-sdk 0.2.0 → 0.3.0-beta-20261019175049

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 (378) hide show
  1. package/README.md +342 -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/msw/fakeApi.d.ts +43 -0
  204. package/dist/test/msw/fakeApi.d.ts.map +1 -0
  205. package/dist/test/msw/fakeApi.js +74 -0
  206. package/dist/test/msw/fakeApi.js.map +1 -0
  207. package/dist/test/msw/handlers.d.ts +20 -0
  208. package/dist/test/msw/handlers.d.ts.map +1 -0
  209. package/dist/test/msw/handlers.js +279 -0
  210. package/dist/test/msw/handlers.js.map +1 -0
  211. package/dist/test/msw/index.d.ts +5 -0
  212. package/dist/test/msw/index.d.ts.map +1 -0
  213. package/dist/test/msw/index.js +2 -0
  214. package/dist/test/msw/query.d.ts +34 -0
  215. package/dist/test/msw/query.d.ts.map +1 -0
  216. package/dist/test/msw/query.js +96 -0
  217. package/dist/test/msw/query.js.map +1 -0
  218. package/dist/test/msw/recorder.d.ts +30 -0
  219. package/dist/test/msw/recorder.d.ts.map +1 -0
  220. package/dist/test/msw/recorder.js +65 -0
  221. package/dist/test/msw/recorder.js.map +1 -0
  222. package/dist/test/msw/store.d.ts +57 -0
  223. package/dist/test/msw/store.d.ts.map +1 -0
  224. package/dist/test/msw/store.js +145 -0
  225. package/dist/test/msw/store.js.map +1 -0
  226. package/dist/test/renderWithProviders.d.ts +2 -2
  227. package/dist/test/renderWithProviders.d.ts.map +1 -1
  228. package/dist/test/renderWithProviders.js.map +1 -1
  229. package/dist/test/setup.js.map +1 -1
  230. package/dist/theme/index.d.ts +1 -1
  231. package/dist/theme/index.d.ts.map +1 -1
  232. package/dist/theme/overrides/index.d.ts +4 -2
  233. package/dist/theme/overrides/index.d.ts.map +1 -1
  234. package/dist/theme/overrides/index.js +5 -3
  235. package/dist/theme/overrides/index.js.map +1 -1
  236. package/dist/theme/overrides/muiButton.d.ts +2 -2
  237. package/dist/theme/overrides/muiButton.js.map +1 -1
  238. package/dist/theme/overrides/muiCssBaseline.d.ts.map +1 -1
  239. package/dist/theme/overrides/muiCssBaseline.js.map +1 -1
  240. package/dist/theme/overrides/muiDatePicker.js.map +1 -1
  241. package/dist/theme/overrides/muiFormControl.js.map +1 -1
  242. package/dist/theme/overrides/muiIconButton.d.ts +2 -2
  243. package/dist/theme/overrides/muiIconButton.js.map +1 -1
  244. package/dist/theme/overrides/muiSelect.d.ts.map +1 -1
  245. package/dist/theme/overrides/muiSelect.js.map +1 -1
  246. package/dist/theme/overrides/muiSvgIcon.d.ts.map +1 -1
  247. package/dist/theme/overrides/muiSvgIcon.js.map +1 -1
  248. package/dist/theme/overrides/muiTextField.js.map +1 -1
  249. package/dist/theme/overrides/muiToggleButton.d.ts +2 -2
  250. package/dist/theme/overrides/muiToggleButton.js.map +1 -1
  251. package/dist/theme/overrides/muiToggleButtonGroup.d.ts +2 -2
  252. package/dist/theme/overrides/muiToggleButtonGroup.js.map +1 -1
  253. package/dist/theme/themes/DefaultDark.js +2 -2
  254. package/dist/theme/themes/DefaultDark.js.map +1 -1
  255. package/dist/theme/themes/DefaultLight.js +2 -2
  256. package/dist/theme/themes/DefaultLight.js.map +1 -1
  257. package/dist/theme/themes/EveryskDark.js +2 -2
  258. package/dist/theme/themes/EveryskDark.js.map +1 -1
  259. package/dist/theme/themes/EveryskLight.js +2 -2
  260. package/dist/theme/themes/EveryskLight.js.map +1 -1
  261. package/dist/theme/themes/MidnightEmber.js +2 -2
  262. package/dist/theme/themes/MidnightEmber.js.map +1 -1
  263. package/dist/types/anyRecord.d.ts.map +1 -1
  264. package/dist/types/datastore.d.ts +35 -5
  265. package/dist/types/datastore.d.ts.map +1 -1
  266. package/dist/types/datastoreDataFormat.d.ts +13 -0
  267. package/dist/types/datastoreDataFormat.d.ts.map +1 -0
  268. package/dist/types/entityQuery.d.ts +86 -16
  269. package/dist/types/entityQuery.d.ts.map +1 -1
  270. package/dist/types/file.d.ts +7 -3
  271. package/dist/types/file.d.ts.map +1 -1
  272. package/dist/types/portfolio.d.ts +1 -3
  273. package/dist/types/portfolio.d.ts.map +1 -1
  274. package/dist/types/profile.d.ts +0 -10
  275. package/dist/types/profile.d.ts.map +1 -1
  276. package/dist/types/workflow.d.ts +35 -6
  277. package/dist/types/workflow.d.ts.map +1 -1
  278. package/dist/types/workspace.d.ts +1 -2
  279. package/dist/types/workspace.d.ts.map +1 -1
  280. package/dist/ui/index.d.ts +1 -1
  281. package/dist/ui/index.d.ts.map +1 -1
  282. package/dist/workflow/index.d.ts +2 -0
  283. package/dist/workflow/index.d.ts.map +1 -1
  284. package/package.json +10 -1
  285. package/src/EveryskApp.tsx +53 -2
  286. package/src/agGrid/handleRowsScrollEnd.ts +71 -0
  287. package/src/agGrid/index.ts +5 -1
  288. package/src/api/datastore.ts +79 -107
  289. package/src/api/entityQuery.ts +86 -17
  290. package/src/api/file.ts +110 -103
  291. package/src/api/portfolio.ts +82 -125
  292. package/src/api/profile.ts +25 -18
  293. package/src/api/request.ts +168 -0
  294. package/src/api/websocketsConfig.ts +11 -19
  295. package/src/api/workflow.ts +232 -334
  296. package/src/api/workspace.ts +43 -43
  297. package/src/components/ui/Footer/index.tsx +8 -7
  298. package/src/components/ui/GlobalLoading/index.tsx +13 -3
  299. package/src/components/ui/PageContainer/index.tsx +9 -2
  300. package/src/components/ui/Toolbar/index.tsx +105 -30
  301. package/src/contexts/appAlertContext/provider.tsx +1 -1
  302. package/src/contexts/appAlertContext/types.ts +3 -3
  303. package/src/contexts/appConfigContext/index.tsx +1 -1
  304. package/src/contexts/appConfigContext/provider.tsx +1 -5
  305. package/src/contexts/webSocketContext/handler.ts +8 -2
  306. package/src/contexts/webSocketContext/hooks/useWebSocket/index.ts +1 -1
  307. package/src/contexts/webSocketContext/provider.tsx +64 -14
  308. package/src/contexts/webSocketContext/types.ts +7 -6
  309. package/src/file/index.ts +2 -0
  310. package/src/hooks/datastore/useDatastoreMutations.ts +19 -60
  311. package/src/hooks/datastore/useFetchDatastore.ts +45 -73
  312. package/src/hooks/datastore/useFetchDatastores.ts +106 -131
  313. package/src/hooks/file/fileData.ts +19 -0
  314. package/src/hooks/file/useFetchFile.ts +41 -76
  315. package/src/hooks/file/useFetchFiles.ts +92 -87
  316. package/src/hooks/file/useFileMutations.ts +23 -73
  317. package/src/hooks/portfolio/useFetchPortfolio.ts +26 -78
  318. package/src/hooks/portfolio/useFetchPortfolios.ts +50 -93
  319. package/src/hooks/portfolio/usePortfolioMutations.ts +22 -72
  320. package/src/hooks/profile/useFetchProfile.ts +24 -65
  321. package/src/hooks/useAxios.ts +5 -5
  322. package/src/hooks/useEntityInfiniteQuery.ts +193 -0
  323. package/src/hooks/useEntityMutation.ts +70 -0
  324. package/src/hooks/useEntityQuery.ts +117 -0
  325. package/src/hooks/workflow/useFetchWorkerExecution.ts +27 -56
  326. package/src/hooks/workflow/useFetchWorkerExecutions.ts +54 -79
  327. package/src/hooks/workflow/useFetchWorkflow.ts +24 -58
  328. package/src/hooks/workflow/useFetchWorkflowExecution.ts +27 -57
  329. package/src/hooks/workflow/useFetchWorkflowExecutions.ts +64 -73
  330. package/src/hooks/workflow/useFetchWorkflows.ts +48 -64
  331. package/src/hooks/workflow/useRunWorkflow.ts +82 -36
  332. package/src/hooks/workflow/useTriggerWorkflow.ts +36 -0
  333. package/src/hooks/workspace/useFetchWorkspace.ts +25 -58
  334. package/src/hooks/workspace/useFetchWorkspaces.ts +38 -69
  335. package/src/index.ts +34 -19
  336. package/src/lib/abort.ts +131 -0
  337. package/src/lib/datastoreTable.ts +127 -74
  338. package/src/lib/file.ts +67 -0
  339. package/src/lib/queryClient.ts +11 -13
  340. package/src/lib/workflowRun.ts +329 -0
  341. package/src/socket/index.ts +1 -3
  342. package/src/test/mocks/index.ts +1 -5
  343. package/src/test/msw/fakeApi.ts +83 -0
  344. package/src/test/msw/handlers.ts +350 -0
  345. package/src/test/msw/index.ts +9 -0
  346. package/src/test/msw/query.ts +134 -0
  347. package/src/test/msw/recorder.ts +88 -0
  348. package/src/test/msw/store.ts +182 -0
  349. package/src/test/renderWithProviders.tsx +8 -3
  350. package/src/test/setup.ts +16 -16
  351. package/src/theme/index.ts +1 -1
  352. package/src/theme/overrides/index.ts +5 -3
  353. package/src/theme/overrides/muiButton.ts +3 -3
  354. package/src/theme/overrides/muiCssBaseline.ts +11 -12
  355. package/src/theme/overrides/muiDatePicker.ts +2 -2
  356. package/src/theme/overrides/muiFormControl.ts +2 -2
  357. package/src/theme/overrides/muiIconButton.ts +3 -3
  358. package/src/theme/overrides/muiSelect.ts +2 -2
  359. package/src/theme/overrides/muiSvgIcon.ts +2 -2
  360. package/src/theme/overrides/muiTextField.ts +1 -1
  361. package/src/theme/overrides/muiToggleButton.ts +4 -4
  362. package/src/theme/overrides/muiToggleButtonGroup.ts +4 -4
  363. package/src/theme/themes/DefaultDark.ts +2 -2
  364. package/src/theme/themes/DefaultLight.ts +2 -2
  365. package/src/theme/themes/EveryskDark.ts +2 -2
  366. package/src/theme/themes/EveryskLight.ts +2 -2
  367. package/src/theme/themes/MidnightEmber.ts +15 -15
  368. package/src/types/anyRecord.ts +2 -2
  369. package/src/types/datastore.ts +56 -22
  370. package/src/types/datastoreDataFormat.ts +12 -0
  371. package/src/types/entityQuery.ts +122 -38
  372. package/src/types/file.ts +8 -6
  373. package/src/types/portfolio.ts +70 -74
  374. package/src/types/profile.ts +0 -11
  375. package/src/types/workflow.ts +38 -9
  376. package/src/types/workspace.ts +2 -4
  377. package/src/ui/index.ts +1 -1
  378. package/src/workflow/index.ts +5 -0
package/src/api/file.ts CHANGED
@@ -1,11 +1,30 @@
1
- import { isAxiosError, type AxiosInstance, type AxiosResponse } from "axios";
1
+ import type { AxiosInstance } from "axios";
2
2
 
3
- import type { AnyRecord } from "@/types/anyRecord";
4
- import type { DeleteFileResponse, EveryskFile, FileListResponse, FileSingleResponse } from "@/types/file";
5
- import type { DeleteEntityDefaultResponse, FilterExpression, QueryObject } from "@/types/entityQuery";
3
+ import type { EveryskFile, FileListResponse } from "@/types/file";
4
+ import type {
5
+ DeletedEntity,
6
+ DeleteEntityResponse,
7
+ EntitySingleResponse,
8
+ QueryObject,
9
+ } from "@/types/entityQuery";
10
+ import { listParams, request, requireWorkspace } from "./request";
6
11
 
7
12
  const baseUrl = "files";
8
13
 
14
+ /** The endpoint's envelopes, private: every function here returns the entity itself. */
15
+ type FileSingleResponse = EntitySingleResponse<"file", EveryskFile>;
16
+ type DeleteFileResponse = DeleteEntityResponse<"file">;
17
+
18
+ export type GetFileParams = {
19
+ /**
20
+ * `false` leaves `data` out (`null`): sent as `with_data=false`, which the API reads as the
21
+ * projection `-data` (everysk/client `EveryskAPIEngine_V2._get_entity_by_id`). The content
22
+ * comes as base64, a third larger than the file. The file hooks leave it out by default;
23
+ * this function, which mirrors the API, includes it.
24
+ */
25
+ withData?: boolean;
26
+ };
27
+
9
28
  /**
10
29
  * getFile
11
30
  *
@@ -14,27 +33,27 @@ const baseUrl = "files";
14
33
  * @param {AxiosInstance} api - Axios instance.
15
34
  * @param {string} id - EveryskFile identifier.
16
35
  * @param {string} workspace - Workspace the file belongs to.
36
+ * @param {GetFileParams} [options] - Whether to include the content.
37
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
17
38
  * @returns {Promise<EveryskFile>} The fetched file.
18
39
  *
19
40
  * @throws {Error} If the request fails.
20
41
  */
21
- export const getFile = async (api: AxiosInstance, id: string, workspace: string): Promise<EveryskFile> => {
22
- const params: AnyRecord = { workspace };
23
-
24
- try {
25
- const response: AxiosResponse<FileSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });
26
- return response.data.file;
27
- } catch (error: unknown) {
28
- if (isAxiosError<AnyRecord>(error)) {
29
- throw new Error(error.message || "Error while fetching file", { cause: error });
30
- }
31
-
32
- if (error instanceof Error) {
33
- throw error;
34
- }
35
-
36
- throw new Error("Error while fetching file", { cause: error });
37
- }
42
+ export const getFile = async (
43
+ api: AxiosInstance,
44
+ id: string,
45
+ workspace: string,
46
+ { withData }: GetFileParams = {},
47
+ signal?: AbortSignal,
48
+ ): Promise<EveryskFile> => {
49
+ requireWorkspace(workspace, "fetch a file");
50
+
51
+ const params = { workspace, ...(withData === false && { with_data: false }) };
52
+ const body = await request(
53
+ () => api.get<FileSingleResponse>(`${baseUrl}/${id}`, { params, signal }),
54
+ "Error fetching file",
55
+ );
56
+ return body.file;
38
57
  };
39
58
 
40
59
  /**
@@ -47,34 +66,36 @@ export const getFile = async (api: AxiosInstance, id: string, workspace: string)
47
66
  *
48
67
  * @param {AxiosInstance} api - Axios instance.
49
68
  * @param {QueryObject} query - Query object built via `buildQueryObject`.
50
- * @returns {Promise<EveryskFile[]>} List of files. Returns an empty array if none found.
69
+ * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
70
+ * @returns {Promise<FileListResponse>} Paginated list of files.
51
71
  *
72
+ * @throws {Error} If the query has no workspace filter.
52
73
  * @throws {Error} If the request fails.
53
74
  */
54
- export const listFiles = async (api: AxiosInstance, query: QueryObject): Promise<FileListResponse> => {
55
- const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === "workspace");
56
- const workspace = workspaceFilter?.[workspaceFilter.length - 1];
57
-
58
- if (!workspace) throw new Error("Workspace filter is required to list files");
59
-
60
- const params: AnyRecord = {
61
- workspace,
62
- ...(query ? { query: JSON.stringify(query) } : {}),
63
- };
75
+ export const listFiles = async (
76
+ api: AxiosInstance,
77
+ query: QueryObject,
78
+ signal?: AbortSignal,
79
+ ): Promise<FileListResponse> => {
80
+ const params = listParams(query, "list files");
81
+
82
+ return request(
83
+ () => api.get<FileListResponse>(baseUrl, { params, signal }),
84
+ "Error listing files",
85
+ );
86
+ };
64
87
 
65
- try {
66
- const response: AxiosResponse<FileListResponse> = await api.get(baseUrl, { params });
67
- return response.data;
68
- } catch (error: unknown) {
69
- if (isAxiosError<AnyRecord>(error)) {
70
- throw new Error(error.message || "Error while fetching files", { cause: error });
71
- }
72
- if (error instanceof Error) {
73
- throw error;
88
+ /**
89
+ * Refuses content sent as a data URL. The API stores `data` as given, so the
90
+ * `data:<type>;base64,` prefix `FileReader` puts in front would become part of the file, which
91
+ * then comes out corrupt with no error anywhere.
92
+ */
93
+ const requireRawBase64 = ({ data }: Partial<EveryskFile>) => {
94
+ if (data?.startsWith("data:")) {
95
+ throw new Error(
96
+ "A file's data must be raw base64, without the data: prefix: read it with fileToBase64",
97
+ );
74
98
  }
75
-
76
- throw new Error("Error while fetching files", { cause: error });
77
- }
78
99
  };
79
100
 
80
101
  /**
@@ -83,30 +104,25 @@ export const listFiles = async (api: AxiosInstance, query: QueryObject): Promise
83
104
  * Creates a new file.
84
105
  *
85
106
  * @param {AxiosInstance} api - Axios instance.
86
- * @param {Partial<EveryskFile>} data - EveryskFile payload.
107
+ * @param {Partial<EveryskFile>} data - EveryskFile payload. Its `data` is the content as raw
108
+ * base64, as `fileToBase64` returns it from a `File`.
87
109
  * @returns {Promise<EveryskFile>} The created file.
88
110
  *
111
+ * @throws {Error} If `workspace` is missing, or `data` is a data URL rather than raw base64.
89
112
  * @throws {Error} If the request fails.
90
113
  */
91
- export const createFile = async (api: AxiosInstance, data: Partial<EveryskFile>): Promise<EveryskFile> => {
92
-
93
- const { workspace } = data;
94
- if (!workspace) throw new Error("Workspace filter is required to create a file");
95
-
96
- try {
97
- const response: AxiosResponse<FileSingleResponse> = await api.post(baseUrl, data);
98
- return response.data.file;
99
- } catch (error: unknown) {
100
- if (isAxiosError<AnyRecord>(error)) {
101
- throw new Error(error.message || "Error while creating file", { cause: error });
102
- }
103
-
104
- if (error instanceof Error) {
105
- throw error;
106
- }
107
-
108
- throw new Error("Error while creating file", { cause: error });
109
- }
114
+ export const createFile = async (
115
+ api: AxiosInstance,
116
+ data: Partial<EveryskFile>,
117
+ ): Promise<EveryskFile> => {
118
+ requireWorkspace(data.workspace, "create a file");
119
+ requireRawBase64(data);
120
+
121
+ const body = await request(
122
+ () => api.post<FileSingleResponse>(baseUrl, data),
123
+ "Error creating file",
124
+ );
125
+ return body.file;
110
126
  };
111
127
 
112
128
  /**
@@ -116,30 +132,26 @@ export const createFile = async (api: AxiosInstance, data: Partial<EveryskFile>)
116
132
  *
117
133
  * @param {AxiosInstance} api - Axios instance.
118
134
  * @param {string} id - EveryskFile identifier.
119
- * @param {Partial<EveryskFile>} data - Fields to update.
135
+ * @param {Partial<EveryskFile>} data - Fields to update. A new `data` is the content as raw
136
+ * base64, as `fileToBase64` returns it from a `File`.
120
137
  * @returns {Promise<EveryskFile>} The updated file.
121
138
  *
139
+ * @throws {Error} If `workspace` is missing, or `data` is a data URL rather than raw base64.
122
140
  * @throws {Error} If the request fails.
123
141
  */
124
- export const updateFile = async (api: AxiosInstance, id: string, data: Partial<EveryskFile>): Promise<EveryskFile> => {
125
-
126
- const { workspace } = data;
127
- if (!workspace) throw new Error("Workspace filter is required to update a file");
128
-
129
- try {
130
- const response: AxiosResponse<FileSingleResponse> = await api.put(`${baseUrl}/${id}`, data);
131
- return response.data.file;
132
- } catch (error: unknown) {
133
- if (isAxiosError<AnyRecord>(error)) {
134
- throw new Error(error.message || "Error while updating file", { cause: error });
135
- }
136
-
137
- if (error instanceof Error) {
138
- throw error;
139
- }
140
-
141
- throw new Error("Error while updating file", { cause: error });
142
- }
142
+ export const updateFile = async (
143
+ api: AxiosInstance,
144
+ id: string,
145
+ data: Partial<EveryskFile>,
146
+ ): Promise<EveryskFile> => {
147
+ requireWorkspace(data.workspace, "update a file");
148
+ requireRawBase64(data);
149
+
150
+ const body = await request(
151
+ () => api.put<FileSingleResponse>(`${baseUrl}/${id}`, data),
152
+ "Error updating file",
153
+ );
154
+ return body.file;
143
155
  };
144
156
 
145
157
  /**
@@ -150,25 +162,20 @@ export const updateFile = async (api: AxiosInstance, id: string, data: Partial<E
150
162
  * @param {AxiosInstance} api - Axios instance.
151
163
  * @param {string} id - EveryskFile identifier.
152
164
  * @param {string} workspace - Workspace the file belongs to.
153
- * @returns {Promise<DeleteEntityDefaultResponse[]>} List of deleted entity records.
165
+ * @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.
154
166
  *
155
167
  * @throws {Error} If the request fails.
156
168
  */
157
- export const deleteFile = async (api: AxiosInstance, id: string, workspace: string): Promise<DeleteEntityDefaultResponse[]> => {
158
- const params: AnyRecord = { workspace };
159
-
160
- try {
161
- const response: AxiosResponse<DeleteFileResponse> = await api.delete(`${baseUrl}/${id}`, { params });
162
- return response.data.files;
163
- } catch (error: unknown) {
164
- if (isAxiosError<AnyRecord>(error)) {
165
- throw new Error(error.message || "Error while deleting file", { cause: error });
166
- }
167
-
168
- if (error instanceof Error) {
169
- throw error;
170
- }
171
-
172
- throw new Error("Error while deleting file", { cause: error });
173
- }
174
- };
169
+ export const deleteFile = async (
170
+ api: AxiosInstance,
171
+ id: string,
172
+ workspace: string,
173
+ ): Promise<DeletedEntity> => {
174
+ requireWorkspace(workspace, "delete a file");
175
+
176
+ const body = await request(
177
+ () => api.delete<DeleteFileResponse>(`${baseUrl}/${id}`, { params: { workspace } }),
178
+ "Error deleting file",
179
+ );
180
+ return body.file;
181
+ };
@@ -1,12 +1,20 @@
1
- import { isAxiosError, type AxiosInstance, type AxiosResponse } from "axios";
1
+ import type { AxiosInstance } from "axios";
2
2
 
3
- import type { QueryObject } from "@/types/entityQuery";
4
- import type { AnyRecord } from "@/types/anyRecord";
5
- import type { FilterExpression } from "@/types/entityQuery";
6
- import type { Portfolio, PortfolioListResponse, PortfolioSingleResponse } from "@/types/portfolio";
3
+ import type {
4
+ DeletedEntity,
5
+ DeleteEntityResponse,
6
+ EntitySingleResponse,
7
+ QueryObject,
8
+ } from "@/types/entityQuery";
9
+ import type { Portfolio, PortfolioListResponse } from "@/types/portfolio";
10
+ import { listParams, request, requireWorkspace } from "./request";
7
11
 
8
12
  const baseUrl = "portfolios";
9
13
 
14
+ /** The endpoint's envelopes, private: every function here returns the entity itself. */
15
+ type PortfolioSingleResponse = EntitySingleResponse<"portfolio", Portfolio>;
16
+ type DeletePortfolioResponse = DeleteEntityResponse<"portfolio">;
17
+
10
18
  /**
11
19
  * getPortfolio
12
20
  *
@@ -15,31 +23,25 @@ const baseUrl = "portfolios";
15
23
  * @param {AxiosInstance} api - Axios instance.
16
24
  * @param {string} id - Portfolio identifier.
17
25
  * @param {string} workspace - Workspace the portfolio belongs to.
18
- * @returns {Promise<PortfolioSingleResponse>} The fetched portfolio response.
26
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
27
+ * @returns {Promise<Portfolio>} The fetched portfolio.
19
28
  *
20
29
  * @throws {Error} If the request fails.
21
30
  */
22
- export const getPortfolio = async (api: AxiosInstance, id: string, workspace: string): Promise<PortfolioSingleResponse> => {
23
- const params: AnyRecord = { workspace };
24
-
25
- if(!workspace){
26
- throw new Error("Workspace is required to fetch a portfolio");
27
- }
28
-
29
- try {
30
- const response: AxiosResponse<PortfolioSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });
31
- return response.data;
32
- } catch (error: unknown) {
33
- if (isAxiosError<AnyRecord>(error)) {
34
- throw new Error(error.message || "Error while fetching portfolio", { cause: error });
35
- }
36
-
37
- if (error instanceof Error) {
38
- throw error;
39
- }
40
-
41
- throw new Error("Error while fetching portfolio", { cause: error });
42
- }
31
+ export const getPortfolio = async (
32
+ api: AxiosInstance,
33
+ id: string,
34
+ workspace: string,
35
+ signal?: AbortSignal,
36
+ ): Promise<Portfolio> => {
37
+ requireWorkspace(workspace, "fetch a portfolio");
38
+
39
+ const body = await request(
40
+ () =>
41
+ api.get<PortfolioSingleResponse>(`${baseUrl}/${id}`, { params: { workspace }, signal }),
42
+ "Error fetching portfolio",
43
+ );
44
+ return body.portfolio;
43
45
  };
44
46
 
45
47
  /**
@@ -49,38 +51,24 @@ export const getPortfolio = async (api: AxiosInstance, id: string, workspace: st
49
51
  *
50
52
  * @param {AxiosInstance} api - Axios instance.
51
53
  * @param {QueryObject} query - Query object built via `buildQueryObject`.
54
+ * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
52
55
  * @returns {Promise<PortfolioListResponse>} List of portfolios.
53
56
  *
57
+ * @throws {Error} If the query has no workspace filter.
54
58
  * @throws {Error} If the request fails.
55
59
  */
56
- export const listPortfolios = async (api: AxiosInstance, query: QueryObject): Promise<PortfolioListResponse> => {
57
- const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === "workspace");
58
- const workspace = workspaceFilter?.[workspaceFilter.length - 1];
59
-
60
- if (!workspace) {
61
- throw new Error("Workspace is required to fetch portfolios");
62
- }
63
-
64
- const params: AnyRecord = {
65
- workspace,
66
- ...(query ? { query: JSON.stringify(query) } : {}),
67
- };
68
-
69
- try {
70
- const response: AxiosResponse<PortfolioListResponse> = await api.get(baseUrl, { params });
71
- return response.data;
72
- } catch (error: unknown) {
73
- if (isAxiosError<AnyRecord>(error)) {
74
- throw new Error(error.message || "Error while fetching portfolios", { cause: error });
75
- }
76
-
77
- if (error instanceof Error) {
78
- throw error;
79
- }
80
-
81
- throw new Error("Error while fetching portfolios", { cause: error });
82
- }
83
- }
60
+ export const listPortfolios = async (
61
+ api: AxiosInstance,
62
+ query: QueryObject,
63
+ signal?: AbortSignal,
64
+ ): Promise<PortfolioListResponse> => {
65
+ const params = listParams(query, "list portfolios");
66
+
67
+ return request(
68
+ () => api.get<PortfolioListResponse>(baseUrl, { params, signal }),
69
+ "Error listing portfolios",
70
+ );
71
+ };
84
72
 
85
73
  /**
86
74
  * createPortfolio
@@ -93,29 +81,18 @@ export const listPortfolios = async (api: AxiosInstance, query: QueryObject): Pr
93
81
  *
94
82
  * @throws {Error} If the request fails.
95
83
  */
96
- export const createPortfolio = async (api: AxiosInstance, data: Partial<Portfolio>): Promise<Portfolio> => {
97
-
98
- const { workspace } = data;
99
-
100
- if (!workspace) {
101
- throw new Error("Workspace is required to post a portfolio");
102
- }
103
-
104
- try {
105
- const response: AxiosResponse<Portfolio> = await api.post(baseUrl, data);
106
- return response.data;
107
- } catch (error: unknown) {
108
- if (isAxiosError<AnyRecord>(error)) {
109
- throw new Error(error.message || "Error while creating portfolio", { cause: error });
110
- }
111
-
112
- if (error instanceof Error) {
113
- throw error;
114
- }
115
-
116
- throw new Error("Error while creating portfolio", { cause: error });
117
- }
118
- }
84
+ export const createPortfolio = async (
85
+ api: AxiosInstance,
86
+ data: Partial<Portfolio>,
87
+ ): Promise<Portfolio> => {
88
+ requireWorkspace(data.workspace, "create a portfolio");
89
+
90
+ const body = await request(
91
+ () => api.post<PortfolioSingleResponse>(baseUrl, data),
92
+ "Error creating portfolio",
93
+ );
94
+ return body.portfolio;
95
+ };
119
96
 
120
97
  /**
121
98
  * updatePortfolio
@@ -129,29 +106,19 @@ export const createPortfolio = async (api: AxiosInstance, data: Partial<Portfoli
129
106
  *
130
107
  * @throws {Error} If the request fails.
131
108
  */
132
- export const updatePortfolio = async (api: AxiosInstance, id: string, data: Partial<Portfolio>): Promise<Portfolio> => {
133
-
134
- const { workspace } = data;
135
-
136
- if(!workspace) {
137
- throw new Error("Workspace is required to delete a portfolio");
138
- }
139
-
140
- try {
141
- const response: AxiosResponse<Portfolio> = await api.put(`${baseUrl}/${id}`, data);
142
- return response.data;
143
- } catch (error: unknown) {
144
- if (isAxiosError<AnyRecord>(error)) {
145
- throw new Error(error.message || "Error while updating portfolio", { cause: error });
146
- }
147
-
148
- if (error instanceof Error) {
149
- throw error;
150
- }
151
-
152
- throw new Error("Error while updating portfolio", { cause: error });
153
- }
154
- }
109
+ export const updatePortfolio = async (
110
+ api: AxiosInstance,
111
+ id: string,
112
+ data: Partial<Portfolio>,
113
+ ): Promise<Portfolio> => {
114
+ requireWorkspace(data.workspace, "update a portfolio");
115
+
116
+ const body = await request(
117
+ () => api.put<PortfolioSingleResponse>(`${baseUrl}/${id}`, data),
118
+ "Error updating portfolio",
119
+ );
120
+ return body.portfolio;
121
+ };
155
122
 
156
123
  /**
157
124
  * deletePortfolio
@@ -161,30 +128,20 @@ export const updatePortfolio = async (api: AxiosInstance, id: string, data: Part
161
128
  * @param {AxiosInstance} api - Axios instance.
162
129
  * @param {string} id - Portfolio identifier.
163
130
  * @param {string} workspace - Workspace the portfolio belongs to.
164
- * @returns {Promise<Portfolio>} The deleted portfolio.
131
+ * @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.
165
132
  *
166
133
  * @throws {Error} If the request fails.
167
134
  */
168
- export const deletePortfolio = async (api: AxiosInstance, id: string, workspace: string): Promise<Portfolio> => {
169
-
170
- if(!workspace) {
171
- throw new Error("Workspace is required to delete a portfolio");
172
- }
173
-
174
- const params: AnyRecord = { workspace };
175
-
176
- try {
177
- const response: AxiosResponse<Portfolio> = await api.delete(`${baseUrl}/${id}`, { params });
178
- return response.data;
179
- } catch (error: unknown) {
180
- if (isAxiosError<AnyRecord>(error)) {
181
- throw new Error(error.message || "Error while deleting portfolio", { cause: error });
182
- }
183
-
184
- if (error instanceof Error) {
185
- throw error;
186
- }
187
-
188
- throw new Error("Error while deleting portfolio", { cause: error });
189
- }
190
- }
135
+ export const deletePortfolio = async (
136
+ api: AxiosInstance,
137
+ id: string,
138
+ workspace: string,
139
+ ): Promise<DeletedEntity> => {
140
+ requireWorkspace(workspace, "delete a portfolio");
141
+
142
+ const body = await request(
143
+ () => api.delete<DeletePortfolioResponse>(`${baseUrl}/${id}`, { params: { workspace } }),
144
+ "Error deleting portfolio",
145
+ );
146
+ return body.portfolio;
147
+ };
@@ -1,10 +1,21 @@
1
- import { isAxiosError, type AxiosInstance, type AxiosResponse } from "axios";
1
+ import type { AxiosInstance } from "axios";
2
2
 
3
- import type { AnyRecord } from "@/types/anyRecord";
4
- import type { Profile, ProfileResponse } from "@/types/profile";
3
+ import type { Profile } from "@/types/profile";
4
+ import { request } from "./request";
5
5
 
6
6
  const baseUrl = "profile";
7
7
 
8
+ /**
9
+ * The endpoint's envelope, private: `getProfile` returns the profile itself.
10
+ *
11
+ * It does not follow `EntitySingleResponse`: `/api/profile` is an app-only route rather than an
12
+ * entity, and carries a `status` beside the profile.
13
+ */
14
+ type ProfileResponse = {
15
+ status: string;
16
+ profile: Profile;
17
+ };
18
+
8
19
  /**
9
20
  * DEV_PROFILE — the profile served while running the dev server.
10
21
  *
@@ -56,25 +67,21 @@ export const DEV_PROFILE: Profile = {
56
67
  *
57
68
  * @param {AxiosInstance} api - Axios instance.
58
69
  * @param {Profile} [fallback] - Returned instead of calling the API, when present.
70
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
59
71
  * @returns {Promise<Profile>} The logged user's profile.
60
72
  *
61
73
  * @throws {Error} If the request fails.
62
74
  */
63
- export const getProfile = async (api: AxiosInstance, fallback?: Profile): Promise<Profile> => {
75
+ export const getProfile = async (
76
+ api: AxiosInstance,
77
+ fallback?: Profile,
78
+ signal?: AbortSignal,
79
+ ): Promise<Profile> => {
64
80
  if (fallback) return fallback;
65
81
 
66
- try {
67
- const response: AxiosResponse<ProfileResponse> = await api.get(baseUrl);
68
- return response.data.profile;
69
- } catch (error: unknown) {
70
- if (isAxiosError<AnyRecord>(error)) {
71
- throw new Error(error.message || "Error while fetching profile", { cause: error });
72
- }
73
-
74
- if (error instanceof Error) {
75
- throw error;
76
- }
77
-
78
- throw new Error("Error while fetching profile", { cause: error });
79
- }
82
+ const body = await request(
83
+ () => api.get<ProfileResponse>(baseUrl, { signal }),
84
+ "Error fetching profile",
85
+ );
86
+ return body.profile;
80
87
  };