@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
@@ -1,62 +1,47 @@
1
1
  import { useAxios } from "../useAxios.js";
2
+ import { useEntityInfiniteQuery } from "../useEntityInfiniteQuery.js";
3
+ import { buildQueryKey, missingWorkspaceError } from "../../api/entityQuery.js";
2
4
  import { listWorkflows } from "../../api/workflow.js";
3
- import { useMemo } from "react";
4
- import { useInfiniteQuery } from "@tanstack/react-query";
5
5
  //#region src/hooks/workflow/useFetchWorkflows.ts
6
- var defaultQueryOptions = {
7
- refetchOnMount: "always",
8
- staleTime: 0,
9
- gcTime: 0
10
- };
11
6
  /**
12
7
  * useFetchWorkflows
13
8
  *
14
- * Data-fetching hook built on TanStack Query's `useInfiniteQuery` to retrieve
15
- * workflows with cursor-based pagination using the legacy method (workspace as query param).
9
+ * Lists workflows with cursor pagination; `query.data` is every loaded page merged, or
10
+ * whatever `select` makes of it. `select` and `fetchAllPages` behave as in
11
+ * `useFetchDatastores`. This endpoint takes a workspace and a text `search` rather than
12
+ * filters.
16
13
  *
17
- * Automatically flattens all pages into a single `Workflow[]` via `select`.
14
+ * A missing workspace fails loudly, without a request, as in every other hook. This hook used to
15
+ * allow one, documented as listing the account's workflows; the API reads `main` instead.
18
16
  *
19
- * Note: `query.data` returns a flat `Workflow[]` with all fetched items merged across pages.
20
- *
21
- * @param {string} [workspace]
22
- * Current workspace name. Sent as a query param via the legacy method, required by some API configurations.
23
- *
24
- * @param {number} [pageSize=10]
25
- * Number of workflows to fetch per page.
26
- *
27
- * @param {InfiniteOptions<Workflow[]>} [queryOptions]
28
- * TanStack Query options passed through to `useInfiniteQuery`
29
- * (e.g., enabled, staleTime, gcTime, etc.).
30
- *
31
- * @returns {{ query, queryKey }}
32
- * - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)
33
- * - `queryKey`: the cache key used by React Query
34
- *
35
- * @example
36
- * ```ts
37
- * const { query } = useFetchWorkflows({ workspace: "ws-1", pageSize: 20 });
38
- *
39
- * // Flat list of all fetched workflows
40
- * const workflows = query.data ?? [];
41
- * ```
17
+ * @param {FetchWorkflowsProps} props - Workspace, search, page size, `select`,
18
+ * `fetchAllPages` and TanStack `queryOptions`.
19
+ * @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
42
20
  */
43
- function useFetchWorkflows({ workspace, pageSize = 10, queryOptions }) {
21
+ function useFetchWorkflows({ workspace, search, pageSize = 10, select, fetchAllPages = false, queryOptions }) {
44
22
  const { api } = useAxios();
45
- const queryKey = ["workflows", workspace ?? null];
46
- const mergedQueryOptions = useMemo(() => ({
47
- ...defaultQueryOptions,
48
- ...queryOptions ?? {}
49
- }), [queryOptions]);
23
+ const queryKey = buildQueryKey([
24
+ "workflows",
25
+ workspace,
26
+ search ?? null
27
+ ], [], {
28
+ pageSize,
29
+ fetchAllPages
30
+ });
50
31
  return {
51
- query: useInfiniteQuery({
32
+ query: useEntityInfiniteQuery({
52
33
  queryKey,
53
- initialPageParam: null,
54
- getNextPageParam: (lastPage) => lastPage.next_page_token ?? void 0,
55
- queryFn: async ({ pageParam }) => {
56
- return await listWorkflows(api, workspace, pageSize, pageParam ?? void 0);
57
- },
58
- select: (data) => data.pages.flatMap((p) => p.workflows),
59
- ...mergedQueryOptions
34
+ itemsKey: "workflows",
35
+ fetchPage: (pageToken, signal) => listWorkflows(api, {
36
+ workspace,
37
+ search,
38
+ pageSize,
39
+ pageToken: pageToken ?? void 0
40
+ }, signal),
41
+ select,
42
+ fetchAllPages,
43
+ configError: workspace ? void 0 : missingWorkspaceError("useFetchWorkflows"),
44
+ queryOptions
60
45
  }),
61
46
  queryKey
62
47
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchWorkflows.js","names":[],"sources":["../../../src/hooks/workflow/useFetchWorkflows.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useInfiniteQuery, type UseInfiniteQueryOptions, type QueryKey } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { listWorkflows } from \"@/api/workflow\";\nimport type { Workflow, WorkflowListResponse } from \"@/types/workflow\";\n\ntype PageToken = string | null;\n\ntype InfiniteOptions<TData> = Omit<UseInfiniteQueryOptions<WorkflowListResponse, Error, TData, QueryKey, PageToken>,\"queryKey\" | \"queryFn\" | \"initialPageParam\" | \"getNextPageParam\">;\n\nexport type FetchInfiniteWorkflowProps = {\n workspace?: string;\n pageSize?: number;\n queryOptions?: InfiniteOptions<Workflow[]>;\n};\n\nconst defaultQueryOptions: InfiniteOptions<Workflow[]> = {\n refetchOnMount: \"always\",\n staleTime: 0,\n gcTime: 0,\n};\n\n/**\n * useFetchWorkflows\n *\n * Data-fetching hook built on TanStack Query's `useInfiniteQuery` to retrieve\n * workflows with cursor-based pagination using the legacy method (workspace as query param).\n *\n * Automatically flattens all pages into a single `Workflow[]` via `select`.\n *\n * Note: `query.data` returns a flat `Workflow[]` with all fetched items merged across pages.\n *\n * @param {string} [workspace]\n * Current workspace name. Sent as a query param via the legacy method, required by some API configurations.\n *\n * @param {number} [pageSize=10]\n * Number of workflows to fetch per page.\n *\n * @param {InfiniteOptions<Workflow[]>} [queryOptions]\n * TanStack Query options passed through to `useInfiniteQuery`\n * (e.g., enabled, staleTime, gcTime, etc.).\n *\n * @returns {{ query, queryKey }}\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 } = useFetchWorkflows({ workspace: \"ws-1\", pageSize: 20 });\n *\n * // Flat list of all fetched workflows\n * const workflows = query.data ?? [];\n * ```\n */\nexport function useFetchWorkflows({ workspace, pageSize = 10, queryOptions }: FetchInfiniteWorkflowProps) {\n const { api } = useAxios();\n\n const queryKey: QueryKey = [\"workflows\", workspace ?? null];\n\n const mergedQueryOptions = useMemo<InfiniteOptions<Workflow[]>>(() => ({\n ...defaultQueryOptions,\n ...(queryOptions ?? {}),\n }), [queryOptions]);\n\n const query = useInfiniteQuery<WorkflowListResponse, Error, Workflow[], QueryKey, PageToken>({\n queryKey,\n initialPageParam: null,\n getNextPageParam: (lastPage) => lastPage.next_page_token ?? undefined,\n\n queryFn: async ({ pageParam }) => {\n return await listWorkflows(api, workspace, pageSize, pageParam ?? undefined);\n },\n\n select: (data) => data.pages.flatMap((p) => p.workflows),\n\n ...mergedQueryOptions,\n });\n\n return {\n query,\n queryKey,\n };\n}\n"],"mappings":";;;;;AAiBA,IAAM,sBAAmD;CACrD,gBAAgB;CAChB,WAAW;CACX,QAAQ;AACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,kBAAkB,EAAE,WAAW,WAAW,IAAI,gBAA4C;CACtG,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,WAAqB,CAAC,aAAa,aAAa,IAAI;CAE1D,MAAM,qBAAqB,eAA4C;EACnE,GAAG;EACH,GAAI,gBAAgB,CAAC;CACzB,IAAI,CAAC,YAAY,CAAC;CAgBlB,OAAO;EACH,OAfU,iBAA+E;GACzF;GACA,kBAAkB;GAClB,mBAAmB,aAAa,SAAS,mBAAmB,KAAA;GAE5D,SAAS,OAAO,EAAE,gBAAgB;IAC9B,OAAO,MAAM,cAAc,KAAK,WAAW,UAAU,aAAa,KAAA,CAAS;GAC/E;GAEA,SAAS,SAAS,KAAK,MAAM,SAAS,MAAM,EAAE,SAAS;GAEvD,GAAG;EACP,CAGI;EACA;CACJ;AACJ"}
1
+ {"version":3,"file":"useFetchWorkflows.js","names":[],"sources":["../../../src/hooks/workflow/useFetchWorkflows.ts"],"sourcesContent":["import { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityInfiniteQuery } from \"@/hooks/useEntityInfiniteQuery\";\nimport { listWorkflows } from \"@/api/workflow\";\nimport { buildQueryKey, missingWorkspaceError } from \"@/api/entityQuery\";\nimport type { Workflow, WorkflowListResponse } from \"@/types/workflow\";\nimport type { FetchEntitiesProps, ListCache } from \"@/types/entityQuery\";\n\n/** The query cache of `useFetchWorkflows`, for typing `setQueryData`. */\nexport type WorkflowsCache = ListCache<WorkflowListResponse>;\n\nexport type FetchWorkflowsProps<TData = Workflow[]> = FetchEntitiesProps<\n Workflow,\n TData,\n WorkflowListResponse\n> & {\n /** Workspace to list. Required: without one the API reads `main`, not the account. */\n workspace: string;\n /** A name prefix, an id, `#tag #tag` (every tag), or `&link_uid`. */\n search?: string;\n};\n\n/**\n * useFetchWorkflows\n *\n * Lists workflows with cursor pagination; `query.data` is every loaded page merged, or\n * whatever `select` makes of it. `select` and `fetchAllPages` behave as in\n * `useFetchDatastores`. This endpoint takes a workspace and a text `search` rather than\n * filters.\n *\n * A missing workspace fails loudly, without a request, as in every other hook. This hook used to\n * allow one, documented as listing the account's workflows; the API reads `main` instead.\n *\n * @param {FetchWorkflowsProps} props - Workspace, search, page size, `select`,\n * `fetchAllPages` and TanStack `queryOptions`.\n * @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.\n */\nexport function useFetchWorkflows<TData = Workflow[]>({\n workspace,\n search,\n pageSize = 10,\n select,\n fetchAllPages = false,\n queryOptions,\n}: FetchWorkflowsProps<TData>) {\n const { api } = useAxios();\n\n const queryKey = buildQueryKey([\"workflows\", workspace, search ?? null], [], {\n pageSize,\n fetchAllPages,\n });\n\n const query = useEntityInfiniteQuery<WorkflowListResponse, \"workflows\", TData>({\n queryKey,\n itemsKey: \"workflows\",\n fetchPage: (pageToken, signal) =>\n listWorkflows(\n api,\n { workspace, search, pageSize, pageToken: pageToken ?? undefined },\n signal,\n ),\n select,\n fetchAllPages,\n configError: workspace ? undefined : missingWorkspaceError(\"useFetchWorkflows\"),\n queryOptions,\n });\n\n return { query, queryKey };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,kBAAsC,EAClD,WACA,QACA,WAAW,IACX,QACA,gBAAgB,OAChB,gBAC2B;CAC3B,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,WAAW,cAAc;EAAC;EAAa;EAAW,UAAU;CAAI,GAAG,CAAC,GAAG;EACzE;EACA;CACJ,CAAC;CAiBD,OAAO;EAAE,OAfK,uBAAiE;GAC3E;GACA,UAAU;GACV,YAAY,WAAW,WACnB,cACI,KACA;IAAE;IAAW;IAAQ;IAAU,WAAW,aAAa,KAAA;GAAU,GACjE,MACJ;GACJ;GACA;GACA,aAAa,YAAY,KAAA,IAAY,sBAAsB,mBAAmB;GAC9E;EACJ,CAES;EAAO;CAAS;AAC7B"}
@@ -1,30 +1,35 @@
1
+ import { type WorkflowWaitOptions } from "../../lib/workflowRun.js";
1
2
  import type { AnyRecord } from "../../types/anyRecord.d.ts";
2
- import type { PollWorkflowExecutionOptions } from "../../api/workflow.js";
3
+ import type { WorkflowResult } from "../../types/workflow.d.ts";
3
4
  type RunWorkflowProps = {
4
5
  id: string;
5
6
  workspace: string;
6
7
  parameters: AnyRecord;
7
- pollOptions?: PollWorkflowExecutionOptions;
8
+ /** How the run is waited for; see `WorkflowWaitOptions`. */
9
+ waitOptions?: WorkflowWaitOptions;
8
10
  };
9
11
  /**
10
12
  * useRunWorkflow
11
13
  *
12
- * TanStack Query mutations to run a workflow. Synchronous execution (`synchronous: true`) is
13
- * intentionally not used; instead the workflow is started asynchronously and, when the result
14
- * is needed, its execution is polled until it reaches a terminal state.
14
+ * A TanStack Query mutation that starts a workflow run, waits for it to end, then reads the
15
+ * Ender's worker execution. Resolves with `{ execution, workerExecution, result }` (`result` is
16
+ * `null` when the run has no output), and fails unless the run ended `SUCCEEDED`.
15
17
  *
16
- * - `runAsync`: starts the workflow and returns immediately (fire-and-forget). Use when you do
17
- * not need to wait for completion or consume the output.
18
- * - `runAndGetResult`: starts the workflow, polls until it finishes, then fetches the output of
19
- * the ender worker. Resolves with `{ execution, workerExecution, result }`; `result` is `null`
20
- * when the workflow produces no output. This is the replacement for the old synchronous flow.
18
+ * It waits over the websocket (see `runWorkflowToEnd`), not by polling: the backend announces
19
+ * each worker and the run's end on the app's channel, and the end itself is then read from the
20
+ * API. So it requires `WebSocketProvider`, and throws on render without it. To start a run
21
+ * without waiting, and without a websocket, use `useTriggerWorkflow`.
21
22
  *
22
- * Both surface the standard mutation helpers (`mutate`, `mutateAsync`, `isPending`, `data`, ...)
23
- * and report failures through `useAppAlert`.
23
+ * Leaving the screen stops it — listening, reads in flight and the result read — and so does
24
+ * `waitOptions.signal`. Neither is alerted: there is no screen left, or the app asked for it. Both
25
+ * fail the mutation with a `WorkflowRunAbortedError`, the signal's reason as the cause. The run itself goes
26
+ * on on the server. `waitOptions.timeoutMs` bounds only the wait for the end; the result read
27
+ * after it is a single request that the timeout does not cover. Any other failure is shown as an
28
+ * error alert through `useAppAlert`, and logged with its cause, which says why a wait timed out.
29
+ *
30
+ * @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters, waitOptions })`
31
+ * starts a run and waits for it.
24
32
  */
25
- export declare const useRunWorkflow: () => {
26
- runAsync: import("@tanstack/react-query").UseMutationResult<AnyRecord, Error, RunWorkflowProps, unknown>;
27
- runAndGetResult: import("@tanstack/react-query").UseMutationResult<import("../../api/workflow.js").WorkflowResult, Error, RunWorkflowProps, unknown>;
28
- };
33
+ export declare const useRunWorkflow: () => import("@tanstack/react-query").UseMutationResult<WorkflowResult, Error, RunWorkflowProps, unknown>;
29
34
  export {};
30
35
  //# sourceMappingURL=useRunWorkflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRunWorkflow.d.ts","sourceRoot":"","sources":["../../../src/hooks/workflow/useRunWorkflow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAGnE,KAAK,gBAAgB,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,4BAA4B,CAAC;CAC9C,CAAC;AAKF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc;;;CA2B1B,CAAC"}
1
+ {"version":3,"file":"useRunWorkflow.d.ts","sourceRoot":"","sources":["../../../src/hooks/workflow/useRunWorkflow.ts"],"names":[],"mappings":"AAaA,OAAO,EAIH,KAAK,mBAAmB,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,KAAK,gBAAgB,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,SAAS,CAAC;IACtB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,2GAuD1B,CAAC"}
@@ -1,48 +1,85 @@
1
1
  import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
2
2
  import { useAxios } from "../useAxios.js";
3
- import { runWorkflow, runWorkflowAndGetResult } from "../../api/workflow.js";
3
+ import { getWorkerExecution, getWorkflowExecution, runWorkflow, terminalRunStatusOf } from "../../api/workflow.js";
4
+ import { useWebSocket } from "../../contexts/webSocketContext/hooks/useWebSocket/index.js";
5
+ import { anySignal, unlessAborted } from "../../lib/abort.js";
6
+ import { WorkflowRunAbortedError, runWorkflowToEnd } from "../../lib/workflowRun.js";
7
+ import { useEffect, useRef } from "react";
4
8
  import { useMutation } from "@tanstack/react-query";
5
9
  //#region src/hooks/workflow/useRunWorkflow.ts
6
- var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? err.message : fallback;
7
10
  /**
8
11
  * useRunWorkflow
9
12
  *
10
- * TanStack Query mutations to run a workflow. Synchronous execution (`synchronous: true`) is
11
- * intentionally not used; instead the workflow is started asynchronously and, when the result
12
- * is needed, its execution is polled until it reaches a terminal state.
13
+ * A TanStack Query mutation that starts a workflow run, waits for it to end, then reads the
14
+ * Ender's worker execution. Resolves with `{ execution, workerExecution, result }` (`result` is
15
+ * `null` when the run has no output), and fails unless the run ended `SUCCEEDED`.
13
16
  *
14
- * - `runAsync`: starts the workflow and returns immediately (fire-and-forget). Use when you do
15
- * not need to wait for completion or consume the output.
16
- * - `runAndGetResult`: starts the workflow, polls until it finishes, then fetches the output of
17
- * the ender worker. Resolves with `{ execution, workerExecution, result }`; `result` is `null`
18
- * when the workflow produces no output. This is the replacement for the old synchronous flow.
17
+ * It waits over the websocket (see `runWorkflowToEnd`), not by polling: the backend announces
18
+ * each worker and the run's end on the app's channel, and the end itself is then read from the
19
+ * API. So it requires `WebSocketProvider`, and throws on render without it. To start a run
20
+ * without waiting, and without a websocket, use `useTriggerWorkflow`.
19
21
  *
20
- * Both surface the standard mutation helpers (`mutate`, `mutateAsync`, `isPending`, `data`, ...)
21
- * and report failures through `useAppAlert`.
22
+ * Leaving the screen stops it — listening, reads in flight and the result read — and so does
23
+ * `waitOptions.signal`. Neither is alerted: there is no screen left, or the app asked for it. Both
24
+ * fail the mutation with a `WorkflowRunAbortedError`, the signal's reason as the cause. The run itself goes
25
+ * on on the server. `waitOptions.timeoutMs` bounds only the wait for the end; the result read
26
+ * after it is a single request that the timeout does not cover. Any other failure is shown as an
27
+ * error alert through `useAppAlert`, and logged with its cause, which says why a wait timed out.
28
+ *
29
+ * @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters, waitOptions })`
30
+ * starts a run and waits for it.
22
31
  */
23
32
  var useRunWorkflow = () => {
24
33
  const { api } = useAxios();
25
34
  const { showAlert } = useAppAlert();
26
- return {
27
- runAsync: useMutation({
28
- mutationFn: ({ id, workspace, parameters }) => runWorkflow(api, id, workspace, parameters),
29
- onError: (err) => {
30
- showAlert({
31
- severity: "error",
32
- message: getErrorMessage(err, "Unable to run the workflow. Please try again.")
35
+ const socket = useWebSocket();
36
+ const unmounted = useRef(void 0);
37
+ useEffect(() => {
38
+ const controller = new AbortController();
39
+ unmounted.current = controller.signal;
40
+ return () => controller.abort();
41
+ }, []);
42
+ return useMutation({
43
+ mutationFn: async ({ id, workspace, parameters, waitOptions }) => {
44
+ const { signal, dispose } = anySignal([waitOptions?.signal, unmounted.current]);
45
+ try {
46
+ const execution = await runWorkflowToEnd({
47
+ startRun: () => runWorkflow(api, id, workspace, parameters),
48
+ getExecution: (workflowExecutionId, readSignal) => getWorkflowExecution(api, id, workflowExecutionId, workspace, readSignal),
49
+ subscribeToEvents: socket.subscribe,
50
+ subscribeToStatus: socket.subscribeStatus,
51
+ ...waitOptions,
52
+ signal
33
53
  });
34
- }
35
- }),
36
- runAndGetResult: useMutation({
37
- mutationFn: ({ id, workspace, parameters, pollOptions }) => runWorkflowAndGetResult(api, id, workspace, parameters, pollOptions),
38
- onError: (err) => {
39
- showAlert({
40
- severity: "error",
41
- message: getErrorMessage(err, "Unable to run the workflow. Please try again.")
54
+ const runStatus = terminalRunStatusOf(execution.run_status);
55
+ if (runStatus !== "SUCCEEDED") throw new Error(`Workflow execution ${runStatus?.toLowerCase()}`);
56
+ const enderId = execution.ender_worker_execution_id;
57
+ if (!enderId) return {
58
+ execution,
59
+ workerExecution: null,
60
+ result: null
61
+ };
62
+ const workerExecution = await unlessAborted(getWorkerExecution(api, id, enderId, workspace, signal), signal).catch((error) => {
63
+ throw signal.aborted ? new WorkflowRunAbortedError(signal.reason) : error;
42
64
  });
65
+ return {
66
+ execution,
67
+ workerExecution,
68
+ result: workerExecution.result ?? null
69
+ };
70
+ } finally {
71
+ dispose();
43
72
  }
44
- })
45
- };
73
+ },
74
+ onError: (error) => {
75
+ if (error instanceof WorkflowRunAbortedError || unmounted.current?.aborted) return;
76
+ console.error("Workflow run failed:", error);
77
+ showAlert({
78
+ severity: "error",
79
+ message: error.message || "Unable to run the workflow. Please try again."
80
+ });
81
+ }
82
+ });
46
83
  };
47
84
  //#endregion
48
85
  export { useRunWorkflow };
@@ -1 +1 @@
1
- {"version":3,"file":"useRunWorkflow.js","names":[],"sources":["../../../src/hooks/workflow/useRunWorkflow.ts"],"sourcesContent":["import { useMutation } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { PollWorkflowExecutionOptions } from \"@/api/workflow\";\nimport { runWorkflow, runWorkflowAndGetResult } from \"@/api/workflow\";\n\ntype RunWorkflowProps = {\n id: string;\n workspace: string;\n parameters: AnyRecord;\n pollOptions?: PollWorkflowExecutionOptions;\n};\n\nconst getErrorMessage = (err: unknown, fallback: string) =>\n err instanceof Error && err.message ? err.message : fallback;\n\n/**\n * useRunWorkflow\n *\n * TanStack Query mutations to run a workflow. Synchronous execution (`synchronous: true`) is\n * intentionally not used; instead the workflow is started asynchronously and, when the result\n * is needed, its execution is polled until it reaches a terminal state.\n *\n * - `runAsync`: starts the workflow and returns immediately (fire-and-forget). Use when you do\n * not need to wait for completion or consume the output.\n * - `runAndGetResult`: starts the workflow, polls until it finishes, then fetches the output of\n * the ender worker. Resolves with `{ execution, workerExecution, result }`; `result` is `null`\n * when the workflow produces no output. This is the replacement for the old synchronous flow.\n *\n * Both surface the standard mutation helpers (`mutate`, `mutateAsync`, `isPending`, `data`, ...)\n * and report failures through `useAppAlert`.\n */\nexport const useRunWorkflow = () => {\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n\n const runAsync = useMutation({\n mutationFn: ({ id, workspace, parameters }: RunWorkflowProps) =>\n runWorkflow(api, id, workspace, parameters),\n onError: (err) => {\n showAlert({\n severity: \"error\",\n message: getErrorMessage(err, \"Unable to run the workflow. Please try again.\"),\n });\n },\n });\n\n const runAndGetResult = useMutation({\n mutationFn: ({ id, workspace, parameters, pollOptions }: RunWorkflowProps) =>\n runWorkflowAndGetResult(api, id, workspace, parameters, pollOptions),\n onError: (err) => {\n showAlert({\n severity: \"error\",\n message: getErrorMessage(err, \"Unable to run the workflow. Please try again.\"),\n });\n },\n });\n\n return { runAsync, runAndGetResult };\n};\n"],"mappings":";;;;;AAeA,IAAM,mBAAmB,KAAc,aACnC,eAAe,SAAS,IAAI,UAAU,IAAI,UAAU;;;;;;;;;;;;;;;;;AAkBxD,IAAa,uBAAuB;CAChC,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAwBlC,OAAO;EAAE,UAtBQ,YAAY;GACzB,aAAa,EAAE,IAAI,WAAW,iBAC1B,YAAY,KAAK,IAAI,WAAW,UAAU;GAC9C,UAAU,QAAQ;IACd,UAAU;KACN,UAAU;KACV,SAAS,gBAAgB,KAAK,+CAA+C;IACjF,CAAC;GACL;EACJ,CAaS;EAAU,iBAXK,YAAY;GAChC,aAAa,EAAE,IAAI,WAAW,YAAY,kBACtC,wBAAwB,KAAK,IAAI,WAAW,YAAY,WAAW;GACvE,UAAU,QAAQ;IACd,UAAU;KACN,UAAU;KACV,SAAS,gBAAgB,KAAK,+CAA+C;IACjF,CAAC;GACL;EACJ,CAEmB;CAAgB;AACvC"}
1
+ {"version":3,"file":"useRunWorkflow.js","names":[],"sources":["../../../src/hooks/workflow/useRunWorkflow.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useMutation } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport { useWebSocket } from \"@/contexts/webSocketContext/hooks/useWebSocket\";\nimport {\n getWorkerExecution,\n getWorkflowExecution,\n runWorkflow,\n terminalRunStatusOf,\n} from \"@/api/workflow\";\nimport { anySignal, unlessAborted } from \"@/lib/abort\";\nimport {\n RUN_FAILED_MESSAGE,\n WorkflowRunAbortedError,\n runWorkflowToEnd,\n type WorkflowWaitOptions,\n} from \"@/lib/workflowRun\";\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { WorkflowResult } from \"@/types/workflow\";\n\ntype RunWorkflowProps = {\n id: string;\n workspace: string;\n parameters: AnyRecord;\n /** How the run is waited for; see `WorkflowWaitOptions`. */\n waitOptions?: WorkflowWaitOptions;\n};\n\n/**\n * useRunWorkflow\n *\n * A TanStack Query mutation that starts a workflow run, waits for it to end, then reads the\n * Ender's worker execution. Resolves with `{ execution, workerExecution, result }` (`result` is\n * `null` when the run has no output), and fails unless the run ended `SUCCEEDED`.\n *\n * It waits over the websocket (see `runWorkflowToEnd`), not by polling: the backend announces\n * each worker and the run's end on the app's channel, and the end itself is then read from the\n * API. So it requires `WebSocketProvider`, and throws on render without it. To start a run\n * without waiting, and without a websocket, use `useTriggerWorkflow`.\n *\n * Leaving the screen stops it — listening, reads in flight and the result read — and so does\n * `waitOptions.signal`. Neither is alerted: there is no screen left, or the app asked for it. Both\n * fail the mutation with a `WorkflowRunAbortedError`, the signal's reason as the cause. The run itself goes\n * on on the server. `waitOptions.timeoutMs` bounds only the wait for the end; the result read\n * after it is a single request that the timeout does not cover. Any other failure is shown as an\n * error alert through `useAppAlert`, and logged with its cause, which says why a wait timed out.\n *\n * @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters, waitOptions })`\n * starts a run and waits for it.\n */\nexport const useRunWorkflow = () => {\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n const socket = useWebSocket();\n const unmounted = useRef<AbortSignal | undefined>(undefined);\n\n useEffect(() => {\n const controller = new AbortController();\n unmounted.current = controller.signal;\n return () => controller.abort();\n }, []);\n\n return useMutation({\n mutationFn: async ({\n id,\n workspace,\n parameters,\n waitOptions,\n }: RunWorkflowProps): Promise<WorkflowResult> => {\n const { signal, dispose } = anySignal([waitOptions?.signal, unmounted.current]);\n try {\n const execution = await runWorkflowToEnd({\n startRun: () => runWorkflow(api, id, workspace, parameters),\n getExecution: (workflowExecutionId, readSignal) =>\n getWorkflowExecution(api, id, workflowExecutionId, workspace, readSignal),\n subscribeToEvents: socket.subscribe,\n subscribeToStatus: socket.subscribeStatus,\n ...waitOptions,\n signal,\n });\n\n const runStatus = terminalRunStatusOf(execution.run_status);\n if (runStatus !== \"SUCCEEDED\")\n throw new Error(`Workflow execution ${runStatus?.toLowerCase()}`);\n\n const enderId = execution.ender_worker_execution_id;\n if (!enderId) return { execution, workerExecution: null, result: null };\n\n const workerExecution = await unlessAborted(\n getWorkerExecution(api, id, enderId, workspace, signal),\n signal,\n ).catch((error: unknown) => {\n throw signal.aborted ? new WorkflowRunAbortedError(signal.reason) : error;\n });\n return { execution, workerExecution, result: workerExecution.result ?? null };\n } finally {\n dispose();\n }\n },\n onError: (error) => {\n if (error instanceof WorkflowRunAbortedError || unmounted.current?.aborted) return;\n console.error(\"Workflow run failed:\", error);\n showAlert({ severity: \"error\", message: error.message || RUN_FAILED_MESSAGE });\n },\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,uBAAuB;CAChC,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAClC,MAAM,SAAS,aAAa;CAC5B,MAAM,YAAY,OAAgC,KAAA,CAAS;CAE3D,gBAAgB;EACZ,MAAM,aAAa,IAAI,gBAAgB;EACvC,UAAU,UAAU,WAAW;EAC/B,aAAa,WAAW,MAAM;CAClC,GAAG,CAAC,CAAC;CAEL,OAAO,YAAY;EACf,YAAY,OAAO,EACf,IACA,WACA,YACA,kBAC6C;GAC7C,MAAM,EAAE,QAAQ,YAAY,UAAU,CAAC,aAAa,QAAQ,UAAU,OAAO,CAAC;GAC9E,IAAI;IACA,MAAM,YAAY,MAAM,iBAAiB;KACrC,gBAAgB,YAAY,KAAK,IAAI,WAAW,UAAU;KAC1D,eAAe,qBAAqB,eAChC,qBAAqB,KAAK,IAAI,qBAAqB,WAAW,UAAU;KAC5E,mBAAmB,OAAO;KAC1B,mBAAmB,OAAO;KAC1B,GAAG;KACH;IACJ,CAAC;IAED,MAAM,YAAY,oBAAoB,UAAU,UAAU;IAC1D,IAAI,cAAc,aACd,MAAM,IAAI,MAAM,sBAAsB,WAAW,YAAY,GAAG;IAEpE,MAAM,UAAU,UAAU;IAC1B,IAAI,CAAC,SAAS,OAAO;KAAE;KAAW,iBAAiB;KAAM,QAAQ;IAAK;IAEtE,MAAM,kBAAkB,MAAM,cAC1B,mBAAmB,KAAK,IAAI,SAAS,WAAW,MAAM,GACtD,MACJ,CAAC,CAAC,OAAO,UAAmB;KACxB,MAAM,OAAO,UAAU,IAAI,wBAAwB,OAAO,MAAM,IAAI;IACxE,CAAC;IACD,OAAO;KAAE;KAAW;KAAiB,QAAQ,gBAAgB,UAAU;IAAK;GAChF,UAAU;IACN,QAAQ;GACZ;EACJ;EACA,UAAU,UAAU;GAChB,IAAI,iBAAiB,2BAA2B,UAAU,SAAS,SAAS;GAC5E,QAAQ,MAAM,wBAAwB,KAAK;GAC3C,UAAU;IAAE,UAAU;IAAS,SAAS,MAAM,WAAA;GAA8B,CAAC;EACjF;CACJ,CAAC;AACL"}
@@ -0,0 +1,20 @@
1
+ import type { AnyRecord } from "../../types/anyRecord.d.ts";
2
+ type TriggerWorkflowProps = {
3
+ id: string;
4
+ workspace: string;
5
+ parameters: AnyRecord;
6
+ };
7
+ /**
8
+ * useTriggerWorkflow
9
+ *
10
+ * A TanStack Query mutation that starts a workflow run and resolves with the execution it started,
11
+ * still `RUNNING`. Fire-and-forget, for when nothing waits for the output; it needs no websocket.
12
+ * To wait for the run and read its result, use `useRunWorkflow`.
13
+ *
14
+ * A failure is shown as an error alert through `useAppAlert`.
15
+ *
16
+ * @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters })` starts a run.
17
+ */
18
+ export declare const useTriggerWorkflow: () => import("@tanstack/react-query").UseMutationResult<import("../..").WorkflowExecution, Error, TriggerWorkflowProps, unknown>;
19
+ export {};
20
+ //# sourceMappingURL=useTriggerWorkflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTriggerWorkflow.d.ts","sourceRoot":"","sources":["../../../src/hooks/workflow/useTriggerWorkflow.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,KAAK,oBAAoB,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,SAAS,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,kIAU9B,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
2
+ import { useAxios } from "../useAxios.js";
3
+ import { runWorkflow } from "../../api/workflow.js";
4
+ import "../../lib/workflowRun.js";
5
+ import { useMutation } from "@tanstack/react-query";
6
+ //#region src/hooks/workflow/useTriggerWorkflow.ts
7
+ /**
8
+ * useTriggerWorkflow
9
+ *
10
+ * A TanStack Query mutation that starts a workflow run and resolves with the execution it started,
11
+ * still `RUNNING`. Fire-and-forget, for when nothing waits for the output; it needs no websocket.
12
+ * To wait for the run and read its result, use `useRunWorkflow`.
13
+ *
14
+ * A failure is shown as an error alert through `useAppAlert`.
15
+ *
16
+ * @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters })` starts a run.
17
+ */
18
+ var useTriggerWorkflow = () => {
19
+ const { api } = useAxios();
20
+ const { showAlert } = useAppAlert();
21
+ return useMutation({
22
+ mutationFn: ({ id, workspace, parameters }) => runWorkflow(api, id, workspace, parameters),
23
+ onError: (error) => showAlert({
24
+ severity: "error",
25
+ message: error.message || "Unable to run the workflow. Please try again."
26
+ })
27
+ });
28
+ };
29
+ //#endregion
30
+ export { useTriggerWorkflow };
31
+
32
+ //# sourceMappingURL=useTriggerWorkflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTriggerWorkflow.js","names":[],"sources":["../../../src/hooks/workflow/useTriggerWorkflow.ts"],"sourcesContent":["import { useMutation } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport { runWorkflow } from \"@/api/workflow\";\nimport { RUN_FAILED_MESSAGE } from \"@/lib/workflowRun\";\nimport type { AnyRecord } from \"@/types/anyRecord\";\n\ntype TriggerWorkflowProps = {\n id: string;\n workspace: string;\n parameters: AnyRecord;\n};\n\n/**\n * useTriggerWorkflow\n *\n * A TanStack Query mutation that starts a workflow run and resolves with the execution it started,\n * still `RUNNING`. Fire-and-forget, for when nothing waits for the output; it needs no websocket.\n * To wait for the run and read its result, use `useRunWorkflow`.\n *\n * A failure is shown as an error alert through `useAppAlert`.\n *\n * @returns {UseMutationResult} The mutation; `mutate({ id, workspace, parameters })` starts a run.\n */\nexport const useTriggerWorkflow = () => {\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n\n return useMutation({\n mutationFn: ({ id, workspace, parameters }: TriggerWorkflowProps) =>\n runWorkflow(api, id, workspace, parameters),\n onError: (error) =>\n showAlert({ severity: \"error\", message: error.message || RUN_FAILED_MESSAGE }),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,IAAa,2BAA2B;CACpC,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAElC,OAAO,YAAY;EACf,aAAa,EAAE,IAAI,WAAW,iBAC1B,YAAY,KAAK,IAAI,WAAW,UAAU;EAC9C,UAAU,UACN,UAAU;GAAE,UAAU;GAAS,SAAS,MAAM,WAAA;EAA8B,CAAC;CACrF,CAAC;AACL"}
@@ -1,39 +1,24 @@
1
1
  import type { Workspace } from "../../types/workspace.d.ts";
2
- import type { EntityQueryOptions } from "../../types/entityQuery.d.ts";
3
- export type FetchWorkspaceProps<TData = Workspace, TSelected = TData> = {
2
+ import type { FetchEntityProps } from "../../types/entityQuery.d.ts";
3
+ export type FetchWorkspaceProps<TData = Workspace, TSelected = TData> = FetchEntityProps<TData, TSelected> & {
4
4
  name: string;
5
- queryOptions?: EntityQueryOptions<TData, TSelected>;
6
5
  };
7
6
  /**
8
7
  * useFetchWorkspace
9
8
  *
10
- * Data-fetching hook built on TanStack Query to retrieve a single workspace by name.
9
+ * Fetches one workspace by name; `data` is the workspace, or whatever `select` makes of it.
11
10
  *
12
- * It also:
13
- * - builds a stable React Query `queryKey` that can be reused by mutation hooks for cache invalidation
14
- * - triggers an error alert via `useAppAlert` whenever `query.error` is present
11
+ * A workspace is identified by its name — the API's `GET /workspaces/:id` takes the name, its
12
+ * UID — so `name` is this hook's id, and like the other hooks' id it usually comes from a
13
+ * selection the user has not made yet: while it is empty the hook stays idle, rather than fail
14
+ * as a misconfigured app. A failure is shown as an error alert.
15
15
  *
16
- * Parameters (FetchWorkspaceProps):
17
- * @param {string} name
18
- * Workspace name (required).
19
- *
20
- * @param queryOptions
21
- * TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
22
- *
23
- * Returns:
24
- * @returns {object}
25
- * TanStack Query's `query` object extended with:
26
- * - `queryKey`: the cache key used by React Query
27
- *
28
- * Example:
29
- * ```ts
30
- * const { data, isLoading } = useFetchWorkspace({ name: "main" });
31
- * // data -> Workspace
32
- * ```
16
+ * @param {FetchWorkspaceProps} props - `name`, `select` and TanStack `queryOptions`.
17
+ * @returns {object} The `useQuery` result, plus `queryKey`.
33
18
  */
34
- export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceProps) => {
19
+ export declare const useFetchWorkspace: <TSelected = Workspace>({ name, select, queryOptions, }: FetchWorkspaceProps<Workspace, TSelected>) => {
35
20
  queryKey: string[];
36
- data: Workspace;
21
+ data: TSelected;
37
22
  error: Error;
38
23
  isError: true;
39
24
  isPending: false;
@@ -56,11 +41,11 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
56
41
  isRefetching: boolean;
57
42
  isStale: boolean;
58
43
  isEnabled: boolean;
59
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Workspace, Error>>;
44
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
60
45
  fetchStatus: import("@tanstack/query-core").FetchStatus;
61
46
  } | {
62
47
  queryKey: string[];
63
- data: Workspace;
48
+ data: TSelected;
64
49
  error: null;
65
50
  isError: false;
66
51
  isPending: false;
@@ -83,7 +68,7 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
83
68
  isRefetching: boolean;
84
69
  isStale: boolean;
85
70
  isEnabled: boolean;
86
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Workspace, Error>>;
71
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
87
72
  fetchStatus: import("@tanstack/query-core").FetchStatus;
88
73
  } | {
89
74
  queryKey: string[];
@@ -110,7 +95,7 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
110
95
  isRefetching: boolean;
111
96
  isStale: boolean;
112
97
  isEnabled: boolean;
113
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Workspace, Error>>;
98
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
114
99
  fetchStatus: import("@tanstack/query-core").FetchStatus;
115
100
  } | {
116
101
  queryKey: string[];
@@ -137,7 +122,7 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
137
122
  isRefetching: boolean;
138
123
  isStale: boolean;
139
124
  isEnabled: boolean;
140
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Workspace, Error>>;
125
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
141
126
  fetchStatus: import("@tanstack/query-core").FetchStatus;
142
127
  } | {
143
128
  queryKey: string[];
@@ -164,11 +149,11 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
164
149
  isRefetching: boolean;
165
150
  isStale: boolean;
166
151
  isEnabled: boolean;
167
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Workspace, Error>>;
152
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
168
153
  fetchStatus: import("@tanstack/query-core").FetchStatus;
169
154
  } | {
170
155
  queryKey: string[];
171
- data: Workspace;
156
+ data: TSelected;
172
157
  isError: false;
173
158
  error: null;
174
159
  isPending: false;
@@ -191,7 +176,7 @@ export declare const useFetchWorkspace: ({ name, queryOptions }: FetchWorkspaceP
191
176
  isRefetching: boolean;
192
177
  isStale: boolean;
193
178
  isEnabled: boolean;
194
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Workspace, Error>>;
179
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
195
180
  fetchStatus: import("@tanstack/query-core").FetchStatus;
196
181
  };
197
182
  //# sourceMappingURL=useFetchWorkspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchWorkspace.d.ts","sourceRoot":"","sources":["../../../src/hooks/workspace/useFetchWorkspace.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,MAAM,mBAAmB,CAAC,KAAK,GAAG,SAAS,EAAE,SAAS,GAAG,KAAK,IAAI;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,kBAAkB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACvD,CAAC;AAQF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,iBAAiB,GAAI,wBAA8C,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BlG,CAAC"}
1
+ {"version":3,"file":"useFetchWorkspace.d.ts","sourceRoot":"","sources":["../../../src/hooks/workspace/useFetchWorkspace.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,MAAM,mBAAmB,CAAC,KAAK,GAAG,SAAS,EAAE,SAAS,GAAG,KAAK,IAAI,gBAAgB,CACpF,KAAK,EACL,SAAS,CACZ,GAAG;IACA,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,GAAG,SAAS,EAAE,iCAItD,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAc3C,CAAC"}
@@ -1,61 +1,31 @@
1
- import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
2
1
  import { useAxios } from "../useAxios.js";
2
+ import { useEntityQuery } from "../useEntityQuery.js";
3
3
  import { getWorkspace } from "../../api/workspace.js";
4
- import { useEffect } from "react";
5
- import { useQuery } from "@tanstack/react-query";
6
4
  //#region src/hooks/workspace/useFetchWorkspace.ts
7
- var defaultQueryOptions = {
8
- refetchOnMount: "always",
9
- staleTime: 0,
10
- gcTime: 0
11
- };
12
5
  /**
13
6
  * useFetchWorkspace
14
7
  *
15
- * Data-fetching hook built on TanStack Query to retrieve a single workspace by name.
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
- * Parameters (FetchWorkspaceProps):
22
- * @param {string} name
23
- * Workspace name (required).
24
- *
25
- * @param queryOptions
26
- * TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
8
+ * Fetches one workspace by name; `data` is the workspace, or whatever `select` makes of it.
27
9
  *
28
- * Returns:
29
- * @returns {object}
30
- * TanStack Query's `query` object extended with:
31
- * - `queryKey`: the cache key used by React Query
10
+ * A workspace is identified by its name — the API's `GET /workspaces/:id` takes the name, its
11
+ * UID — so `name` is this hook's id, and like the other hooks' id it usually comes from a
12
+ * selection the user has not made yet: while it is empty the hook stays idle, rather than fail
13
+ * as a misconfigured app. A failure is shown as an error alert.
32
14
  *
33
- * Example:
34
- * ```ts
35
- * const { data, isLoading } = useFetchWorkspace({ name: "main" });
36
- * // data -> Workspace
37
- * ```
15
+ * @param {FetchWorkspaceProps} props - `name`, `select` and TanStack `queryOptions`.
16
+ * @returns {object} The `useQuery` result, plus `queryKey`.
38
17
  */
39
- var useFetchWorkspace = ({ name, queryOptions = defaultQueryOptions }) => {
18
+ var useFetchWorkspace = ({ name, select, queryOptions }) => {
40
19
  const { api } = useAxios();
41
- const { showAlert } = useAppAlert();
42
20
  const queryKey = ["workspace", name];
43
- const query = useQuery({
44
- queryKey,
45
- queryFn: async () => {
46
- return await getWorkspace(api, name);
47
- },
48
- ...queryOptions ?? {}
49
- });
50
- useEffect(() => {
51
- if (!query.error) return;
52
- showAlert({
53
- severity: "error",
54
- message: query.error.message
55
- });
56
- }, [query.error, showAlert]);
57
21
  return {
58
- ...query,
22
+ ...useEntityQuery({
23
+ queryKey,
24
+ fetchEntity: (signal) => getWorkspace(api, name, signal),
25
+ select,
26
+ enabled: Boolean(name),
27
+ queryOptions
28
+ }),
59
29
  queryKey
60
30
  };
61
31
  };