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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (349) hide show
  1. package/README.md +395 -8
  2. package/dist/EveryskApp.d.ts +34 -2
  3. package/dist/EveryskApp.d.ts.map +1 -1
  4. package/dist/EveryskApp.js +35 -2
  5. package/dist/EveryskApp.js.map +1 -1
  6. package/dist/agGrid/handleRowsScrollEnd.d.ts +53 -0
  7. package/dist/agGrid/handleRowsScrollEnd.d.ts.map +1 -0
  8. package/dist/agGrid/handleRowsScrollEnd.js +47 -0
  9. package/dist/agGrid/handleRowsScrollEnd.js.map +1 -0
  10. package/dist/agGrid/index.d.ts +2 -0
  11. package/dist/agGrid/index.d.ts.map +1 -1
  12. package/dist/agGrid/index.js +2 -1
  13. package/dist/api/datastore.d.ts +10 -8
  14. package/dist/api/datastore.d.ts.map +1 -1
  15. package/dist/api/datastore.js +24 -55
  16. package/dist/api/datastore.js.map +1 -1
  17. package/dist/api/entityQuery.d.ts +46 -41
  18. package/dist/api/entityQuery.d.ts.map +1 -1
  19. package/dist/api/entityQuery.js +55 -14
  20. package/dist/api/entityQuery.js.map +1 -1
  21. package/dist/api/file.d.ts +26 -9
  22. package/dist/api/file.d.ts.map +1 -1
  23. package/dist/api/file.js +45 -55
  24. package/dist/api/file.js.map +1 -1
  25. package/dist/api/portfolio.d.ts +11 -8
  26. package/dist/api/portfolio.d.ts.map +1 -1
  27. package/dist/api/portfolio.js +24 -55
  28. package/dist/api/portfolio.js.map +1 -1
  29. package/dist/api/profile.d.ts +3 -2
  30. package/dist/api/profile.d.ts.map +1 -1
  31. package/dist/api/profile.js +4 -9
  32. package/dist/api/profile.js.map +1 -1
  33. package/dist/api/request.d.ts +106 -0
  34. package/dist/api/request.d.ts.map +1 -0
  35. package/dist/api/request.js +132 -0
  36. package/dist/api/request.js.map +1 -0
  37. package/dist/api/websocketsConfig.d.ts +7 -2
  38. package/dist/api/websocketsConfig.d.ts.map +1 -1
  39. package/dist/api/websocketsConfig.js +2 -10
  40. package/dist/api/websocketsConfig.js.map +1 -1
  41. package/dist/api/workflow.d.ts +84 -89
  42. package/dist/api/workflow.d.ts.map +1 -1
  43. package/dist/api/workflow.js +121 -208
  44. package/dist/api/workflow.js.map +1 -1
  45. package/dist/api/workspace.d.ts +18 -8
  46. package/dist/api/workspace.d.ts.map +1 -1
  47. package/dist/api/workspace.js +21 -26
  48. package/dist/api/workspace.js.map +1 -1
  49. package/dist/components/ui/Footer/index.d.ts.map +1 -1
  50. package/dist/components/ui/Footer/index.js.map +1 -1
  51. package/dist/components/ui/GlobalLoading/index.d.ts.map +1 -1
  52. package/dist/components/ui/GlobalLoading/index.js.map +1 -1
  53. package/dist/components/ui/PageContainer/index.d.ts +1 -1
  54. package/dist/components/ui/PageContainer/index.d.ts.map +1 -1
  55. package/dist/components/ui/PageContainer/index.js.map +1 -1
  56. package/dist/components/ui/Toolbar/index.d.ts +40 -3
  57. package/dist/components/ui/Toolbar/index.d.ts.map +1 -1
  58. package/dist/components/ui/Toolbar/index.js +42 -15
  59. package/dist/components/ui/Toolbar/index.js.map +1 -1
  60. package/dist/contexts/appAlertContext/provider.js.map +1 -1
  61. package/dist/contexts/appAlertContext/types.d.ts.map +1 -1
  62. package/dist/contexts/appConfigContext/index.d.ts.map +1 -1
  63. package/dist/contexts/appConfigContext/index.js.map +1 -1
  64. package/dist/contexts/appConfigContext/provider.d.ts.map +1 -1
  65. package/dist/contexts/appConfigContext/provider.js.map +1 -1
  66. package/dist/contexts/webSocketContext/handler.d.ts +3 -2
  67. package/dist/contexts/webSocketContext/handler.d.ts.map +1 -1
  68. package/dist/contexts/webSocketContext/handler.js.map +1 -1
  69. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts +1 -1
  70. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js +1 -1
  71. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js.map +1 -1
  72. package/dist/contexts/webSocketContext/provider.d.ts +6 -3
  73. package/dist/contexts/webSocketContext/provider.d.ts.map +1 -1
  74. package/dist/contexts/webSocketContext/provider.js +42 -7
  75. package/dist/contexts/webSocketContext/provider.js.map +1 -1
  76. package/dist/contexts/webSocketContext/types.d.ts +7 -5
  77. package/dist/contexts/webSocketContext/types.d.ts.map +1 -1
  78. package/dist/file/index.d.ts +2 -0
  79. package/dist/file/index.d.ts.map +1 -1
  80. package/dist/hooks/datastore/useDatastoreMutations.d.ts +4 -4
  81. package/dist/hooks/datastore/useDatastoreMutations.d.ts.map +1 -1
  82. package/dist/hooks/datastore/useDatastoreMutations.js +17 -55
  83. package/dist/hooks/datastore/useDatastoreMutations.js.map +1 -1
  84. package/dist/hooks/datastore/useFetchDatastore.d.ts +30 -41
  85. package/dist/hooks/datastore/useFetchDatastore.d.ts.map +1 -1
  86. package/dist/hooks/datastore/useFetchDatastore.js +25 -59
  87. package/dist/hooks/datastore/useFetchDatastore.js.map +1 -1
  88. package/dist/hooks/datastore/useFetchDatastores.d.ts +47 -52
  89. package/dist/hooks/datastore/useFetchDatastores.d.ts.map +1 -1
  90. package/dist/hooks/datastore/useFetchDatastores.js +55 -70
  91. package/dist/hooks/datastore/useFetchDatastores.js.map +1 -1
  92. package/dist/hooks/file/fileData.d.ts +17 -0
  93. package/dist/hooks/file/fileData.d.ts.map +1 -0
  94. package/dist/hooks/file/fileData.js +10 -0
  95. package/dist/hooks/file/fileData.js.map +1 -0
  96. package/dist/hooks/file/useFetchFile.d.ts +38 -58
  97. package/dist/hooks/file/useFetchFile.d.ts.map +1 -1
  98. package/dist/hooks/file/useFetchFile.js +26 -66
  99. package/dist/hooks/file/useFetchFile.js.map +1 -1
  100. package/dist/hooks/file/useFetchFiles.d.ts +18 -52
  101. package/dist/hooks/file/useFetchFiles.d.ts.map +1 -1
  102. package/dist/hooks/file/useFetchFiles.js +53 -69
  103. package/dist/hooks/file/useFetchFiles.js.map +1 -1
  104. package/dist/hooks/file/useFileMutations.d.ts +9 -8
  105. package/dist/hooks/file/useFileMutations.d.ts.map +1 -1
  106. package/dist/hooks/file/useFileMutations.js +23 -60
  107. package/dist/hooks/file/useFileMutations.js.map +1 -1
  108. package/dist/hooks/portfolio/useFetchPortfolio.d.ts +16 -50
  109. package/dist/hooks/portfolio/useFetchPortfolio.d.ts.map +1 -1
  110. package/dist/hooks/portfolio/useFetchPortfolio.js +15 -63
  111. package/dist/hooks/portfolio/useFetchPortfolio.js.map +1 -1
  112. package/dist/hooks/portfolio/useFetchPortfolios.d.ts +13 -52
  113. package/dist/hooks/portfolio/useFetchPortfolios.d.ts.map +1 -1
  114. package/dist/hooks/portfolio/useFetchPortfolios.js +29 -71
  115. package/dist/hooks/portfolio/useFetchPortfolios.js.map +1 -1
  116. package/dist/hooks/portfolio/usePortfolioMutations.d.ts +8 -8
  117. package/dist/hooks/portfolio/usePortfolioMutations.d.ts.map +1 -1
  118. package/dist/hooks/portfolio/usePortfolioMutations.js +20 -58
  119. package/dist/hooks/portfolio/usePortfolioMutations.js.map +1 -1
  120. package/dist/hooks/profile/useFetchProfile.d.ts +18 -44
  121. package/dist/hooks/profile/useFetchProfile.d.ts.map +1 -1
  122. package/dist/hooks/profile/useFetchProfile.js +16 -48
  123. package/dist/hooks/profile/useFetchProfile.js.map +1 -1
  124. package/dist/hooks/useAxios.js.map +1 -1
  125. package/dist/hooks/useEntityInfiniteQuery.d.ts +88 -0
  126. package/dist/hooks/useEntityInfiniteQuery.d.ts.map +1 -0
  127. package/dist/hooks/useEntityInfiniteQuery.js +111 -0
  128. package/dist/hooks/useEntityInfiniteQuery.js.map +1 -0
  129. package/dist/hooks/useEntityMutation.d.ts +47 -0
  130. package/dist/hooks/useEntityMutation.d.ts.map +1 -0
  131. package/dist/hooks/useEntityMutation.js +58 -0
  132. package/dist/hooks/useEntityMutation.js.map +1 -0
  133. package/dist/hooks/useEntityQuery.d.ts +68 -0
  134. package/dist/hooks/useEntityQuery.d.ts.map +1 -0
  135. package/dist/hooks/useEntityQuery.js +75 -0
  136. package/dist/hooks/useEntityQuery.js.map +1 -0
  137. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts +17 -34
  138. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts.map +1 -1
  139. package/dist/hooks/workflow/useFetchWorkerExecution.js +16 -46
  140. package/dist/hooks/workflow/useFetchWorkerExecution.js.map +1 -1
  141. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts +179 -41
  142. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts.map +1 -1
  143. package/dist/hooks/workflow/useFetchWorkerExecutions.js +29 -62
  144. package/dist/hooks/workflow/useFetchWorkerExecutions.js.map +1 -1
  145. package/dist/hooks/workflow/useFetchWorkflow.d.ts +16 -35
  146. package/dist/hooks/workflow/useFetchWorkflow.d.ts.map +1 -1
  147. package/dist/hooks/workflow/useFetchWorkflow.js +15 -48
  148. package/dist/hooks/workflow/useFetchWorkflow.js.map +1 -1
  149. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts +17 -34
  150. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts.map +1 -1
  151. package/dist/hooks/workflow/useFetchWorkflowExecution.js +16 -46
  152. package/dist/hooks/workflow/useFetchWorkflowExecution.js.map +1 -1
  153. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts +22 -36
  154. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts.map +1 -1
  155. package/dist/hooks/workflow/useFetchWorkflowExecutions.js +43 -56
  156. package/dist/hooks/workflow/useFetchWorkflowExecutions.js.map +1 -1
  157. package/dist/hooks/workflow/useFetchWorkflows.d.ts +20 -37
  158. package/dist/hooks/workflow/useFetchWorkflows.d.ts.map +1 -1
  159. package/dist/hooks/workflow/useFetchWorkflows.js +32 -47
  160. package/dist/hooks/workflow/useFetchWorkflows.js.map +1 -1
  161. package/dist/hooks/workflow/useRunWorkflow.d.ts +21 -16
  162. package/dist/hooks/workflow/useRunWorkflow.d.ts.map +1 -1
  163. package/dist/hooks/workflow/useRunWorkflow.js +66 -29
  164. package/dist/hooks/workflow/useRunWorkflow.js.map +1 -1
  165. package/dist/hooks/workflow/useTriggerWorkflow.d.ts +20 -0
  166. package/dist/hooks/workflow/useTriggerWorkflow.d.ts.map +1 -0
  167. package/dist/hooks/workflow/useTriggerWorkflow.js +32 -0
  168. package/dist/hooks/workflow/useTriggerWorkflow.js.map +1 -0
  169. package/dist/hooks/workspace/useFetchWorkspace.d.ts +19 -34
  170. package/dist/hooks/workspace/useFetchWorkspace.d.ts.map +1 -1
  171. package/dist/hooks/workspace/useFetchWorkspace.js +16 -46
  172. package/dist/hooks/workspace/useFetchWorkspace.js.map +1 -1
  173. package/dist/hooks/workspace/useFetchWorkspaces.d.ts +17 -37
  174. package/dist/hooks/workspace/useFetchWorkspaces.d.ts.map +1 -1
  175. package/dist/hooks/workspace/useFetchWorkspaces.js +25 -47
  176. package/dist/hooks/workspace/useFetchWorkspaces.js.map +1 -1
  177. package/dist/index.d.ts +13 -10
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +13 -11
  180. package/dist/lib/abort.d.ts +58 -0
  181. package/dist/lib/abort.d.ts.map +1 -0
  182. package/dist/lib/abort.js +112 -0
  183. package/dist/lib/abort.js.map +1 -0
  184. package/dist/lib/datastoreTable.d.ts +59 -54
  185. package/dist/lib/datastoreTable.d.ts.map +1 -1
  186. package/dist/lib/datastoreTable.js +58 -62
  187. package/dist/lib/datastoreTable.js.map +1 -1
  188. package/dist/lib/file.d.ts +34 -0
  189. package/dist/lib/file.d.ts.map +1 -0
  190. package/dist/lib/file.js +63 -0
  191. package/dist/lib/file.js.map +1 -0
  192. package/dist/lib/queryClient.d.ts.map +1 -1
  193. package/dist/lib/queryClient.js.map +1 -1
  194. package/dist/lib/workflowRun.d.ts +91 -0
  195. package/dist/lib/workflowRun.d.ts.map +1 -0
  196. package/dist/lib/workflowRun.js +224 -0
  197. package/dist/lib/workflowRun.js.map +1 -0
  198. package/dist/socket/index.d.ts +1 -3
  199. package/dist/socket/index.d.ts.map +1 -1
  200. package/dist/socket/index.js +3 -5
  201. package/dist/test/mocks/index.d.ts +1 -1
  202. package/dist/test/mocks/index.d.ts.map +1 -1
  203. package/dist/test/renderWithProviders.d.ts +2 -2
  204. package/dist/test/renderWithProviders.d.ts.map +1 -1
  205. package/dist/test/renderWithProviders.js.map +1 -1
  206. package/dist/test/setup.js.map +1 -1
  207. package/dist/theme/index.d.ts +1 -1
  208. package/dist/theme/index.d.ts.map +1 -1
  209. package/dist/theme/overrides/index.d.ts +4 -2
  210. package/dist/theme/overrides/index.d.ts.map +1 -1
  211. package/dist/theme/overrides/index.js +5 -3
  212. package/dist/theme/overrides/index.js.map +1 -1
  213. package/dist/theme/overrides/muiButton.d.ts +2 -2
  214. package/dist/theme/overrides/muiButton.js.map +1 -1
  215. package/dist/theme/overrides/muiCssBaseline.d.ts.map +1 -1
  216. package/dist/theme/overrides/muiCssBaseline.js.map +1 -1
  217. package/dist/theme/overrides/muiDatePicker.js.map +1 -1
  218. package/dist/theme/overrides/muiFormControl.js.map +1 -1
  219. package/dist/theme/overrides/muiIconButton.d.ts +2 -2
  220. package/dist/theme/overrides/muiIconButton.js.map +1 -1
  221. package/dist/theme/overrides/muiSelect.d.ts.map +1 -1
  222. package/dist/theme/overrides/muiSelect.js.map +1 -1
  223. package/dist/theme/overrides/muiSvgIcon.d.ts.map +1 -1
  224. package/dist/theme/overrides/muiSvgIcon.js.map +1 -1
  225. package/dist/theme/overrides/muiTextField.js.map +1 -1
  226. package/dist/theme/overrides/muiToggleButton.d.ts +2 -2
  227. package/dist/theme/overrides/muiToggleButton.js.map +1 -1
  228. package/dist/theme/overrides/muiToggleButtonGroup.d.ts +2 -2
  229. package/dist/theme/overrides/muiToggleButtonGroup.js.map +1 -1
  230. package/dist/theme/themes/DefaultDark.js +2 -2
  231. package/dist/theme/themes/DefaultDark.js.map +1 -1
  232. package/dist/theme/themes/DefaultLight.js +2 -2
  233. package/dist/theme/themes/DefaultLight.js.map +1 -1
  234. package/dist/theme/themes/EveryskDark.js +2 -2
  235. package/dist/theme/themes/EveryskDark.js.map +1 -1
  236. package/dist/theme/themes/EveryskLight.js +2 -2
  237. package/dist/theme/themes/EveryskLight.js.map +1 -1
  238. package/dist/theme/themes/MidnightEmber.js +2 -2
  239. package/dist/theme/themes/MidnightEmber.js.map +1 -1
  240. package/dist/types/anyRecord.d.ts.map +1 -1
  241. package/dist/types/datastore.d.ts +35 -5
  242. package/dist/types/datastore.d.ts.map +1 -1
  243. package/dist/types/datastoreDataFormat.d.ts +13 -0
  244. package/dist/types/datastoreDataFormat.d.ts.map +1 -0
  245. package/dist/types/entityQuery.d.ts +86 -16
  246. package/dist/types/entityQuery.d.ts.map +1 -1
  247. package/dist/types/file.d.ts +7 -3
  248. package/dist/types/file.d.ts.map +1 -1
  249. package/dist/types/portfolio.d.ts +1 -3
  250. package/dist/types/portfolio.d.ts.map +1 -1
  251. package/dist/types/profile.d.ts +0 -10
  252. package/dist/types/profile.d.ts.map +1 -1
  253. package/dist/types/workflow.d.ts +35 -6
  254. package/dist/types/workflow.d.ts.map +1 -1
  255. package/dist/types/workspace.d.ts +1 -2
  256. package/dist/types/workspace.d.ts.map +1 -1
  257. package/dist/ui/index.d.ts +1 -1
  258. package/dist/ui/index.d.ts.map +1 -1
  259. package/dist/workflow/index.d.ts +2 -0
  260. package/dist/workflow/index.d.ts.map +1 -1
  261. package/package.json +6 -6
  262. package/src/EveryskApp.tsx +53 -2
  263. package/src/agGrid/handleRowsScrollEnd.ts +71 -0
  264. package/src/agGrid/index.ts +5 -1
  265. package/src/api/datastore.ts +79 -107
  266. package/src/api/entityQuery.ts +86 -17
  267. package/src/api/file.ts +110 -103
  268. package/src/api/portfolio.ts +82 -125
  269. package/src/api/profile.ts +25 -18
  270. package/src/api/request.ts +168 -0
  271. package/src/api/websocketsConfig.ts +11 -19
  272. package/src/api/workflow.ts +232 -334
  273. package/src/api/workspace.ts +43 -43
  274. package/src/components/ui/Footer/index.tsx +8 -7
  275. package/src/components/ui/GlobalLoading/index.tsx +13 -3
  276. package/src/components/ui/PageContainer/index.tsx +9 -2
  277. package/src/components/ui/Toolbar/index.tsx +105 -30
  278. package/src/contexts/appAlertContext/provider.tsx +1 -1
  279. package/src/contexts/appAlertContext/types.ts +3 -3
  280. package/src/contexts/appConfigContext/index.tsx +1 -1
  281. package/src/contexts/appConfigContext/provider.tsx +1 -5
  282. package/src/contexts/webSocketContext/handler.ts +8 -2
  283. package/src/contexts/webSocketContext/hooks/useWebSocket/index.ts +1 -1
  284. package/src/contexts/webSocketContext/provider.tsx +64 -14
  285. package/src/contexts/webSocketContext/types.ts +7 -6
  286. package/src/file/index.ts +2 -0
  287. package/src/hooks/datastore/useDatastoreMutations.ts +19 -60
  288. package/src/hooks/datastore/useFetchDatastore.ts +45 -73
  289. package/src/hooks/datastore/useFetchDatastores.ts +106 -131
  290. package/src/hooks/file/fileData.ts +19 -0
  291. package/src/hooks/file/useFetchFile.ts +41 -76
  292. package/src/hooks/file/useFetchFiles.ts +92 -87
  293. package/src/hooks/file/useFileMutations.ts +23 -73
  294. package/src/hooks/portfolio/useFetchPortfolio.ts +26 -78
  295. package/src/hooks/portfolio/useFetchPortfolios.ts +50 -93
  296. package/src/hooks/portfolio/usePortfolioMutations.ts +22 -72
  297. package/src/hooks/profile/useFetchProfile.ts +24 -65
  298. package/src/hooks/useAxios.ts +5 -5
  299. package/src/hooks/useEntityInfiniteQuery.ts +193 -0
  300. package/src/hooks/useEntityMutation.ts +70 -0
  301. package/src/hooks/useEntityQuery.ts +117 -0
  302. package/src/hooks/workflow/useFetchWorkerExecution.ts +27 -56
  303. package/src/hooks/workflow/useFetchWorkerExecutions.ts +54 -79
  304. package/src/hooks/workflow/useFetchWorkflow.ts +24 -58
  305. package/src/hooks/workflow/useFetchWorkflowExecution.ts +27 -57
  306. package/src/hooks/workflow/useFetchWorkflowExecutions.ts +64 -73
  307. package/src/hooks/workflow/useFetchWorkflows.ts +48 -64
  308. package/src/hooks/workflow/useRunWorkflow.ts +82 -36
  309. package/src/hooks/workflow/useTriggerWorkflow.ts +36 -0
  310. package/src/hooks/workspace/useFetchWorkspace.ts +25 -58
  311. package/src/hooks/workspace/useFetchWorkspaces.ts +38 -69
  312. package/src/index.ts +34 -19
  313. package/src/lib/abort.ts +131 -0
  314. package/src/lib/datastoreTable.ts +127 -74
  315. package/src/lib/file.ts +67 -0
  316. package/src/lib/queryClient.ts +11 -13
  317. package/src/lib/workflowRun.ts +329 -0
  318. package/src/socket/index.ts +1 -3
  319. package/src/test/mocks/index.ts +1 -5
  320. package/src/test/renderWithProviders.tsx +8 -3
  321. package/src/test/setup.ts +16 -16
  322. package/src/theme/index.ts +1 -1
  323. package/src/theme/overrides/index.ts +5 -3
  324. package/src/theme/overrides/muiButton.ts +3 -3
  325. package/src/theme/overrides/muiCssBaseline.ts +11 -12
  326. package/src/theme/overrides/muiDatePicker.ts +2 -2
  327. package/src/theme/overrides/muiFormControl.ts +2 -2
  328. package/src/theme/overrides/muiIconButton.ts +3 -3
  329. package/src/theme/overrides/muiSelect.ts +2 -2
  330. package/src/theme/overrides/muiSvgIcon.ts +2 -2
  331. package/src/theme/overrides/muiTextField.ts +1 -1
  332. package/src/theme/overrides/muiToggleButton.ts +4 -4
  333. package/src/theme/overrides/muiToggleButtonGroup.ts +4 -4
  334. package/src/theme/themes/DefaultDark.ts +2 -2
  335. package/src/theme/themes/DefaultLight.ts +2 -2
  336. package/src/theme/themes/EveryskDark.ts +2 -2
  337. package/src/theme/themes/EveryskLight.ts +2 -2
  338. package/src/theme/themes/MidnightEmber.ts +15 -15
  339. package/src/types/anyRecord.ts +2 -2
  340. package/src/types/datastore.ts +56 -22
  341. package/src/types/datastoreDataFormat.ts +12 -0
  342. package/src/types/entityQuery.ts +122 -38
  343. package/src/types/file.ts +8 -6
  344. package/src/types/portfolio.ts +70 -74
  345. package/src/types/profile.ts +0 -11
  346. package/src/types/workflow.ts +38 -9
  347. package/src/types/workspace.ts +2 -4
  348. package/src/ui/index.ts +1 -1
  349. package/src/workflow/index.ts +5 -0
@@ -1,285 +1,158 @@
1
- import { isAxiosError, type AxiosInstance, type AxiosResponse } from "axios";
1
+ import type { AxiosInstance } from "axios";
2
2
 
3
3
  import type { AnyRecord } from "@/types/anyRecord";
4
- import type { FilterExpression, QueryObject } from "@/types/entityQuery";
5
- import type { WorkerExecution, WorkerExecutionListResponse, WorkerExecutionSingleResponse, Workflow, WorkflowExecution, WorkflowExecutionListResponse, WorkflowExecutionSingleResponse, WorkflowListResponse, WorkflowSingleResponse } from "@/types/workflow";
4
+ import { pageParams, request, requireWorkspace } from "./request";
5
+ import type { EntitySingleResponse } from "@/types/entityQuery";
6
+ import type {
7
+ WorkerExecution,
8
+ WorkerExecutionListResponse,
9
+ Workflow,
10
+ WorkflowExecution,
11
+ WorkflowExecutionListResponse,
12
+ WorkflowListResponse,
13
+ } from "@/types/workflow";
6
14
 
7
15
  const baseUrl = "workflows";
8
16
 
9
- /**
10
- * Runs a workflow asynchronously.
11
- *
12
- * Starts the workflow in a non-blocking way: the response carries a workflow execution
13
- * with a non-terminal status (e.g. "RUNNING"). Use polling to wait for the terminal state.
14
- *
15
- * @param api - Axios instance used to make the HTTP request.
16
- * @param id - The unique identifier of the workflow to run.
17
- * @param workspace - The workspace in which the workflow will be executed.
18
- * @param parameters - Key-value parameters to pass to the workflow.
19
- * @returns A promise that resolves with the workflow execution response data.
20
- * @throws {Error} If `workspace` is not provided.
21
- * @throws {Error} If the request fails.
22
- */
23
- export const runWorkflow = async (api: AxiosInstance, id: string, workspace: string, parameters: AnyRecord): Promise<AnyRecord> => {
24
-
25
- if (!workspace) {
26
- throw new Error("Workspace is required to run workflow");
27
- }
28
-
29
- try {
30
- const body: AnyRecord = {
31
- workspace,
32
- parameters,
33
- };
34
-
35
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- const response: AxiosResponse<any> = await api.post(`${baseUrl}/${id}/run`, body);
37
-
38
- return response.data;
39
- } catch (error: unknown) {
40
- if (isAxiosError<AnyRecord>(error)) {
41
- throw new Error(error.message || "");
42
- }
43
-
44
- if (error instanceof Error) {
45
- throw error;
46
- }
47
-
48
- throw new Error("Error while running workflow");
49
- }
50
- };
17
+ /** The endpoints' envelopes, private: every function here returns the entity itself. */
18
+ type WorkflowSingleResponse = EntitySingleResponse<"workflow", Workflow>;
19
+ type WorkflowExecutionSingleResponse = EntitySingleResponse<
20
+ "workflow_execution",
21
+ WorkflowExecution
22
+ >;
23
+ type WorkerExecutionSingleResponse = EntitySingleResponse<"worker_execution", WorkerExecution>;
51
24
 
52
25
  /**
53
- * Run statuses that indicate a workflow execution has reached a terminal state
54
- * (i.e. it is no longer running and will not change again).
55
- *
56
- * Union of the backend's `WORKFLOW_EXECUTION_STATUS_FINISHED` set and the API's documented
57
- * terminal `run_status` values (`SUCCEEDED`/`FAILED`/`KILLED`). `KILLED` is included so a
58
- * killed execution is detected as terminal instead of polling until timeout.
26
+ * What `POST /workflows/:id/run` answers: the execution it started, still `RUNNING`, and a
27
+ * `result` that is always `null` — the run is asynchronous, and the output is read from the
28
+ * Ender's worker execution once it finishes. Private: `runWorkflow` returns the execution.
59
29
  */
60
- export const TERMINAL_RUN_STATUSES = ["CANCELED", "COMPLETED", "SUCCEEDED", "FAILED", "KILLED"] as const;
61
-
62
- const isTerminalRunStatus = (runStatus: unknown): boolean =>
63
- TERMINAL_RUN_STATUSES.includes(String(runStatus ?? "").toUpperCase() as (typeof TERMINAL_RUN_STATUSES)[number]);
64
-
65
- const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
66
-
67
- export type PollWorkflowExecutionOptions = {
68
- /** Delay between status checks, in milliseconds. Defaults to 2000ms. */
69
- intervalMs?: number;
70
- /** Maximum time to wait for a terminal status before giving up, in milliseconds. Defaults to 5 minutes. */
71
- timeoutMs?: number;
72
- /** Optional abort signal to cancel polling (e.g. on unmount). */
73
- signal?: AbortSignal;
30
+ type RunWorkflowResponse = {
31
+ workflow_execution: WorkflowExecution;
32
+ result: null;
74
33
  };
75
34
 
76
35
  /**
77
- * Polls a workflow execution until it reaches a terminal run status (see {@link TERMINAL_RUN_STATUSES}).
78
- *
79
- * This is the interim, non-blocking replacement for synchronous (`synchronous: true`) execution:
80
- * the workflow is started asynchronously and its status is checked periodically until it completes.
81
- *
82
- * @param api - Axios instance used to make the HTTP request.
83
- * @param workflowId - The unique identifier of the workflow.
84
- * @param executionId - The unique identifier of the workflow execution to poll.
85
- * @param workspace - The workspace in which the workflow execution resides.
86
- * @param options - Polling configuration (interval, timeout, abort signal).
87
- * @returns A promise that resolves with the terminal {@link WorkflowExecution}.
88
- * @throws {Error} If `workspace` is not provided.
89
- * @throws {Error} If polling is aborted via `options.signal`.
90
- * @throws {Error} If a terminal status is not reached before `options.timeoutMs` elapses.
91
- */
92
- export const pollWorkflowExecution = async (
93
- api: AxiosInstance,
94
- workflowId: string,
95
- executionId: string,
96
- workspace: string,
97
- options: PollWorkflowExecutionOptions = {}
98
- ): Promise<WorkflowExecution> => {
99
- if (!workspace) {
100
- throw new Error("Workspace is required to poll a workflow execution");
101
- }
102
-
103
- const { intervalMs = 2000, timeoutMs = 5 * 60 * 1000, signal } = options;
104
- const startedAt = Date.now();
105
-
106
- while (true) {
107
- if (signal?.aborted) {
108
- throw new Error("Workflow execution polling was aborted");
109
- }
110
-
111
- const execution = await getWorkflowExecution(api, workflowId, executionId, workspace);
112
-
113
- if (isTerminalRunStatus(execution.run_status)) {
114
- return execution;
115
- }
116
-
117
- if (Date.now() - startedAt >= timeoutMs) {
118
- throw new Error("Timed out while waiting for the workflow execution to complete");
119
- }
120
-
121
- await sleep(intervalMs);
122
- }
123
- };
124
-
125
- /**
126
- * Starts a workflow asynchronously and polls its execution until completion.
36
+ * Runs a workflow asynchronously.
127
37
  *
128
- * Interim replacement for synchronous execution: instead of holding the request open with
129
- * `synchronous: true`, the workflow is started in a non-blocking way and its status is polled
130
- * until it reaches a terminal state, at which point the final execution (with its result) is returned.
38
+ * Starts the workflow in a non-blocking way: the response carries a workflow execution
39
+ * with a non-terminal status (e.g. "RUNNING"). `useRunWorkflow` waits for the end over
40
+ * the websocket.
131
41
  *
132
42
  * @param api - Axios instance used to make the HTTP request.
133
43
  * @param id - The unique identifier of the workflow to run.
134
44
  * @param workspace - The workspace in which the workflow will be executed.
135
45
  * @param parameters - Key-value parameters to pass to the workflow.
136
- * @param options - Polling configuration (interval, timeout, abort signal).
137
- * @returns A promise that resolves with the terminal {@link WorkflowExecution}.
46
+ * @returns The execution the run started, still `RUNNING`. It used to be the raw body,
47
+ * `{ workflow_execution, result: null }`, where every other function returns the entity.
138
48
  * @throws {Error} If `workspace` is not provided.
139
- * @throws {Error} If the run response does not contain a workflow execution id.
140
- * @throws {Error} If the workflow execution ends in a "FAILED" run status.
141
- * @throws {Error} If polling times out or is aborted.
49
+ * @throws {Error} If the request fails.
142
50
  */
143
- const runWorkflowAndPoll = async (
144
- api: AxiosInstance,
145
- id: string,
146
- workspace: string,
147
- parameters: AnyRecord,
148
- options: PollWorkflowExecutionOptions = {}
51
+ export const runWorkflow = async (
52
+ api: AxiosInstance,
53
+ id: string,
54
+ workspace: string,
55
+ parameters: AnyRecord,
149
56
  ): Promise<WorkflowExecution> => {
150
- if (!workspace) {
151
- throw new Error("Workspace is required to run workflow");
152
- }
153
-
154
- // Start the workflow asynchronously (non-blocking).
155
- const startResponse = await runWorkflow(api, id, workspace, parameters);
156
- const executionId = (startResponse.workflow_execution as WorkflowExecution | undefined)?.id;
157
-
158
- if (!executionId) {
159
- throw new Error("Workflow run did not return an execution id to poll");
160
- }
57
+ requireWorkspace(workspace, "run a workflow");
161
58
 
162
- // Poll the execution status until it completes, then consume the result.
163
- const execution = await pollWorkflowExecution(api, id, executionId, workspace, options);
164
-
165
- if (String(execution.run_status ?? "").toUpperCase() === "FAILED") {
166
- throw new Error("Workflow execution failed");
167
- }
168
-
169
- return execution;
59
+ const body = await request(
60
+ () => api.post<RunWorkflowResponse>(`${baseUrl}/${id}/run`, { workspace, parameters }),
61
+ "Error running workflow",
62
+ );
63
+ return body.workflow_execution;
170
64
  };
171
65
 
172
66
  /**
173
- * The terminal workflow execution together with the output produced by its final (ender) worker.
67
+ * The run statuses a workflow execution can end with. The backend writes `RUNNING` when the run
68
+ * starts, and `SUCCEEDED` or `FAILED` once its Ender finishes; `CANCELED` is reserved for a
69
+ * cancellation it does not write yet. This list used to carry `KILLED`, which the backend never
70
+ * writes, and `COMPLETED`, the value of the deprecated `status` field, seen in `run_status` only
71
+ * on executions from before 2024-10-03.
174
72
  */
175
- export type WorkflowResult = {
176
- /** The terminal workflow execution. */
177
- execution: WorkflowExecution;
178
- /** The ender worker execution, or `null` if the execution did not reference one. */
179
- workerExecution: WorkerExecution | null;
180
- /** The output data produced by the ender worker (`workerExecution.result`), or `null`. */
181
- result: Record<string, unknown> | null;
182
- };
73
+ export const TERMINAL_RUN_STATUSES = ["SUCCEEDED", "FAILED", "CANCELED"] as const;
74
+
75
+ export type TerminalRunStatus = (typeof TERMINAL_RUN_STATUSES)[number];
183
76
 
184
77
  /**
185
- * Starts a workflow, polls it to completion, then fetches the output produced by its final worker.
186
- *
187
- * A workflow execution does not carry the output payload itself — it references the final worker via
188
- * `ender_worker_execution_id`, and that worker execution's `result` field holds the actual data.
189
- * This helper performs the full flow: start (async) → poll → fetch ender worker → return its `result`.
190
- *
191
- * @param api - Axios instance used to make the HTTP request.
192
- * @param id - The unique identifier of the workflow to run.
193
- * @param workspace - The workspace in which the workflow will be executed.
194
- * @param parameters - Key-value parameters to pass to the workflow.
195
- * @param options - Polling configuration (interval, timeout, abort signal).
196
- * @returns A promise that resolves with the {@link WorkflowResult} (execution, ender worker execution, and its result).
197
- * @throws {Error} If `workspace` is not provided.
198
- * @throws {Error} If the workflow execution ends in a "FAILED" run status.
199
- * @throws {Error} If polling times out or is aborted.
78
+ * The status a run ended with, read whatever its case; `null` while it has not ended. A missing
79
+ * status — a projection can drop the field, and JSON can carry it as `null` — is a run not known
80
+ * to have ended. The one place a run's status is read, so a comparison against it is typed.
200
81
  */
201
- export const runWorkflowAndGetResult = async (
202
- api: AxiosInstance,
203
- id: string,
204
- workspace: string,
205
- parameters: AnyRecord,
206
- options: PollWorkflowExecutionOptions = {}
207
- ): Promise<WorkflowResult> => {
208
- const execution = await runWorkflowAndPoll(api, id, workspace, parameters, options);
209
-
210
- const enderWorkerExecutionId = execution.ender_worker_execution_id;
211
- if (!enderWorkerExecutionId) {
212
- return { execution, workerExecution: null, result: null };
213
- }
214
-
215
- const workerExecution = await getWorkerExecution(api, id, enderWorkerExecutionId, workspace);
216
-
217
- return { execution, workerExecution, result: workerExecution.result ?? null };
82
+ export const terminalRunStatusOf = (
83
+ runStatus: string | null | undefined,
84
+ ): TerminalRunStatus | null => {
85
+ const upper = runStatus?.toUpperCase();
86
+ return TERMINAL_RUN_STATUSES.find((status) => status === upper) ?? null;
218
87
  };
219
88
 
89
+ /** Whether a run with this `run_status` has ended; see `terminalRunStatusOf`. */
90
+ export const isTerminalRunStatus = (runStatus: string | null | undefined): boolean =>
91
+ terminalRunStatusOf(runStatus) !== null;
92
+
220
93
  /**
221
94
  * Fetches a single workflow by ID.
222
95
  *
223
96
  * @param api - Axios instance used to make the HTTP request.
224
97
  * @param id - The unique identifier of the workflow to fetch.
225
98
  * @param workspace - The workspace in which the workflow resides.
99
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
226
100
  * @returns A promise that resolves with the {@link Workflow} object.
227
101
  * @throws {Error} If `workspace` is not provided.
228
102
  * @throws {Error} If the request fails.
229
103
  */
230
- export const getWorkflow = async (api: AxiosInstance, id: string, workspace: string): Promise<Workflow> => {
231
- if (!workspace) {
232
- throw new Error("Workspace is required to fetch a workflow");
233
- }
234
-
235
- try {
236
- const params: AnyRecord = { workspace };
237
- const response: AxiosResponse<WorkflowSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });
238
-
239
- return response.data.workflow;
240
- } catch (error: unknown) {
241
- if (isAxiosError<AnyRecord>(error)) {
242
- throw new Error(error.message || "Error while fetching workflow");
243
- }
244
- if (error instanceof Error) {
245
- throw error;
246
- }
104
+ export const getWorkflow = async (
105
+ api: AxiosInstance,
106
+ id: string,
107
+ workspace: string,
108
+ signal?: AbortSignal,
109
+ ): Promise<Workflow> => {
110
+ requireWorkspace(workspace, "fetch a workflow");
111
+
112
+ const body = await request(
113
+ () =>
114
+ api.get<WorkflowSingleResponse>(`${baseUrl}/${id}`, { params: { workspace }, signal }),
115
+ "Error fetching workflow",
116
+ );
117
+ return body.workflow;
118
+ };
247
119
 
248
- throw new Error("Error while fetching workflow");
249
- }
120
+ /** What `listWorkflows` sends. */
121
+ export type WorkflowListParams = {
122
+ /** Required: without one the API lists `main` rather than failing, and refuses a sub-user. */
123
+ workspace: string;
124
+ /** A name prefix, an id, `#tag #tag` (every tag), or `&link_uid`. Sent as `query`. */
125
+ search?: string;
126
+ pageSize?: number;
127
+ pageToken?: string;
250
128
  };
251
129
 
252
130
  /**
253
- * Fetches a paginated list of workflows using the legacy method (workspace as query param).
131
+ * Lists the workflows of a workspace, a page at a time.
132
+ *
133
+ * The endpoint takes a text search rather than the JSON query the other lists take, so this
134
+ * takes `search` rather than a `QueryObject`.
254
135
  *
255
136
  * @param api - Axios instance used to make the HTTP request.
256
- * @param workspace - Current workspace name. Sent as a query param via the legacy method, required by some API configurations.
257
- * @param pageSize - Number of items per page.
258
- * @param pageToken - Cursor token for the next page.
259
- * @returns A promise that resolves with a {@link WorkflowListResponse} containing the matched workflows.
137
+ * @param params - Workspace, search and paging.
138
+ * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
139
+ * @returns A page of workflows, with the cursor to the next one.
140
+ * @throws {Error} If `workspace` is empty.
260
141
  * @throws {Error} If the request fails.
261
142
  */
262
- export const listWorkflows = async (api: AxiosInstance, workspace?: string, pageSize?: number, pageToken?: string): Promise<WorkflowListResponse> => {
263
- const params: AnyRecord = {};
264
-
265
- if (workspace) params.workspace = workspace;
266
- if (pageSize) params.page_size = pageSize;
267
- if (pageToken) params.page_token = pageToken;
268
-
269
- try {
270
- const response: AxiosResponse<WorkflowListResponse> = await api.get(baseUrl, { params });
271
- return response.data;
272
- } catch (error: unknown) {
273
- if (isAxiosError<AnyRecord>(error)) {
274
- throw new Error(error.message || "Error listing workflows");
275
- }
276
-
277
- if (error instanceof Error) {
278
- throw error;
279
- }
280
-
281
- throw new Error("Error listing workflows");
282
- }
143
+ export const listWorkflows = async (
144
+ api: AxiosInstance,
145
+ { workspace, search, pageSize, pageToken }: WorkflowListParams,
146
+ signal?: AbortSignal,
147
+ ): Promise<WorkflowListResponse> => {
148
+ requireWorkspace(workspace, "list workflows");
149
+
150
+ const params = pageParams({ workspace, search, pageSize, pageToken });
151
+
152
+ return request(
153
+ () => api.get<WorkflowListResponse>(baseUrl, { params, signal }),
154
+ "Error listing workflows",
155
+ );
283
156
  };
284
157
 
285
158
  /**
@@ -287,70 +160,83 @@ export const listWorkflows = async (api: AxiosInstance, workspace?: string, page
287
160
  *
288
161
  * @param api - Axios instance used to make the HTTP request.
289
162
  * @param workflowId - The unique identifier of the workflow.
290
- * @param executionId - The unique identifier of the workflow execution to fetch.
163
+ * @param workflowExecutionId - The unique identifier of the workflow execution to fetch.
291
164
  * @param workspace - The workspace in which the workflow execution resides.
165
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
292
166
  * @returns A promise that resolves with the {@link WorkflowExecution} object.
293
167
  * @throws {Error} If `workspace` is not provided.
294
168
  * @throws {Error} If the request fails.
295
169
  */
296
- export const getWorkflowExecution = async (api: AxiosInstance, workflowId: string, executionId: string, workspace: string): Promise<WorkflowExecution> => {
297
- if (!workspace) {
298
- throw new Error("Workspace is required to fetch a workflow execution");
299
- }
300
-
301
- try {
302
- const params: AnyRecord = { workspace, workflow_execution_id: executionId };
303
- const response: AxiosResponse<WorkflowExecutionSingleResponse> = await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params });
304
- return response.data.workflow_execution;
305
- } catch (error: unknown) {
306
- if (isAxiosError<AnyRecord>(error)) {
307
- throw new Error(error.message || "Error fetching workflow execution");
308
- }
309
-
310
- if (error instanceof Error) {
311
- throw error;
312
- }
170
+ export const getWorkflowExecution = async (
171
+ api: AxiosInstance,
172
+ workflowId: string,
173
+ workflowExecutionId: string,
174
+ workspace: string,
175
+ signal?: AbortSignal,
176
+ ): Promise<WorkflowExecution> => {
177
+ requireWorkspace(workspace, "fetch a workflow execution");
178
+
179
+ const params: AnyRecord = { workspace, workflow_execution_id: workflowExecutionId };
180
+ const body = await request(
181
+ () =>
182
+ api.get<WorkflowExecutionSingleResponse>(
183
+ `${baseUrl}/${workflowId}/workflow_executions`,
184
+ { params, signal },
185
+ ),
186
+ "Error fetching workflow execution",
187
+ );
188
+ return body.workflow_execution;
189
+ };
313
190
 
314
- throw new Error("Error fetching workflow execution");
315
- }
191
+ /** What `listWorkflowExecutions` sends: the parameters the endpoint reads, each from the URL. */
192
+ export type WorkflowExecutionListParams = {
193
+ /** Not used to filter: the endpoint lists the workflow's executions. A sub-user's role check needs it. */
194
+ workspace: string;
195
+ pageSize?: number;
196
+ pageToken?: string;
197
+ /** Only the executions this worker took part in. */
198
+ workerId?: string;
199
+ /** Include each execution's `resume`, the per-worker summary. The API leaves it out by default. */
200
+ withResume?: boolean;
316
201
  };
317
202
 
318
203
  /**
319
- * Fetches a paginated list of workflow executions matching the given query.
204
+ * Lists the executions of one workflow, newest first, a page at a time.
205
+ *
206
+ * Everything goes in the URL. The endpoint reads `page_size`, `page_token`, `worker_id` and
207
+ * `with_resume` from there and ignores a JSON `query`, which is what this function used to send:
208
+ * the page size had no effect and every "next page" came back as the first one.
320
209
  *
321
210
  * @param api - Axios instance used to make the HTTP request.
322
- * @param workflowId - The unique identifier of the workflow whose executions to list.
323
- * @param query - Query object containing filters, pagination, and sorting options.
324
- * Must include a `workspace` filter expression.
325
- * @returns A promise that resolves with a {@link WorkflowExecutionListResponse} containing the matched executions.
326
- * @throws {Error} If the `workspace` filter is not present in `query.filters`.
211
+ * @param workflowId - The workflow whose executions to list.
212
+ * @param params - Workspace, paging, and the endpoint's two filters.
213
+ * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
214
+ * @returns A page of executions, with the cursor to the next one.
215
+ * @throws {Error} If `workspace` is empty.
327
216
  * @throws {Error} If the request fails.
328
217
  */
329
- export const listWorkflowExecutions = async (api: AxiosInstance, workflowId: string, query: QueryObject): Promise<WorkflowExecutionListResponse> => {
330
- const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === "workspace");
331
- const workspace = workspaceFilter?.[workspaceFilter.length - 1];
332
-
333
- if (!workspace) throw new Error("Workspace filter is required to list workflows");
334
-
335
- try {
336
- const params: AnyRecord = {
337
- workspace,
338
- ...(query ? { query: JSON.stringify(query) } : {}),
218
+ export const listWorkflowExecutions = async (
219
+ api: AxiosInstance,
220
+ workflowId: string,
221
+ { workspace, pageSize, pageToken, workerId, withResume }: WorkflowExecutionListParams,
222
+ signal?: AbortSignal,
223
+ ): Promise<WorkflowExecutionListResponse> => {
224
+ requireWorkspace(workspace, "list workflow executions");
225
+
226
+ const params = {
227
+ ...pageParams({ workspace, pageSize, pageToken }),
228
+ ...(workerId ? { worker_id: workerId } : {}),
229
+ ...(withResume !== undefined ? { with_resume: withResume } : {}),
339
230
  };
340
231
 
341
- const response: AxiosResponse<WorkflowExecutionListResponse> = await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params });
342
- return response.data;
343
- } catch (error: unknown) {
344
- if (isAxiosError<AnyRecord>(error)) {
345
- throw new Error(error.message || "Error listing workflow executions");
346
- }
347
-
348
- if (error instanceof Error) {
349
- throw error;
350
- }
351
-
352
- throw new Error("Error listing workflow executions");
353
- }
232
+ return request(
233
+ () =>
234
+ api.get<WorkflowExecutionListResponse>(`${baseUrl}/${workflowId}/workflow_executions`, {
235
+ params,
236
+ signal,
237
+ }),
238
+ "Error listing workflow executions",
239
+ );
354
240
  };
355
241
 
356
242
  /**
@@ -360,68 +246,80 @@ export const listWorkflowExecutions = async (api: AxiosInstance, workflowId: str
360
246
  * @param workflowId - The unique identifier of the parent workflow.
361
247
  * @param workerExecutionId - The unique identifier of the worker execution to fetch.
362
248
  * @param workspace - The workspace in which the worker execution resides.
249
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
363
250
  * @returns A promise that resolves with the {@link WorkerExecution} object.
364
251
  * @throws {Error} If `workspace` is not provided.
365
252
  * @throws {Error} If the request fails.
366
253
  */
367
- export const getWorkerExecution = async (api: AxiosInstance, workflowId: string, workerExecutionId: string, workspace: string): Promise<WorkerExecution> => {
368
- if (!workspace) {
369
- throw new Error("Workspace is required to fetch a worker execution");
370
- }
254
+ export const getWorkerExecution = async (
255
+ api: AxiosInstance,
256
+ workflowId: string,
257
+ workerExecutionId: string,
258
+ workspace: string,
259
+ signal?: AbortSignal,
260
+ ): Promise<WorkerExecution> => {
261
+ requireWorkspace(workspace, "fetch a worker execution");
371
262
 
372
- try {
373
- const params: AnyRecord = { workspace, worker_execution_id: workerExecutionId, with_result: true };
374
- const response: AxiosResponse<WorkerExecutionSingleResponse> = await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params });
375
- return response.data.worker_execution;
376
- } catch (error: unknown) {
377
- if (isAxiosError<AnyRecord>(error)) {
378
- throw new Error(error.message || "Error fetching worker execution");
379
- }
380
-
381
- if (error instanceof Error) {
382
- throw error;
383
- }
263
+ const params: AnyRecord = {
264
+ workspace,
265
+ worker_execution_id: workerExecutionId,
266
+ with_result: true,
267
+ };
268
+ const body = await request(
269
+ () =>
270
+ api.get<WorkerExecutionSingleResponse>(`${baseUrl}/${workflowId}/worker_executions`, {
271
+ params,
272
+ signal,
273
+ }),
274
+ "Error fetching worker execution",
275
+ );
276
+ return body.worker_execution;
277
+ };
384
278
 
385
- throw new Error("Error fetching worker execution");
386
- }
387
- }
279
+ /** What `listWorkerExecutions` sends besides the execution id. */
280
+ export type WorkerExecutionListParams = {
281
+ /** Not used to filter. A sub-user's role check needs it. */
282
+ workspace: string;
283
+ /** Include each run's `result` and `input_params`. The API leaves them out by default. */
284
+ withResult?: boolean;
285
+ };
388
286
 
389
287
  /**
390
- * Fetches a paginated list of worker executions for a given workflow.
288
+ * Lists every worker execution of one workflow execution, grouped by worker.
289
+ *
290
+ * The endpoint returns them all at once: it is not paginated and takes no query. Each group is
291
+ * one worker, with its run as `execution`, or every parallel run as `executions`.
391
292
  *
392
293
  * @param api - Axios instance used to make the HTTP request.
393
- * @param workflowId - The unique identifier of the parent workflow.
394
- * @param workflowExecutionId - The unique identifier of the workflow execution to filter by.
395
- * @param query - Query object containing filters, pagination, and sorting options.
396
- * Must include a `workspace` filter expression.
397
- * @returns A promise that resolves with a {@link WorkerExecutionListResponse} containing the matched worker executions.
398
- * @throws {Error} If the `workspace` filter is not present in `query.filters`.
294
+ * @param workflowId - The parent workflow.
295
+ * @param workflowExecutionId - The workflow execution whose workers to list.
296
+ * @param params - Workspace, and whether to include results.
297
+ * @param {AbortSignal} [signal] - Aborts the request itself; the hooks pass the query's own.
298
+ * @returns The groups, and the highest parallel index among them.
299
+ * @throws {Error} If `workspace` is empty.
399
300
  * @throws {Error} If the request fails.
400
301
  */
401
- export const listWorkerExecutions = async (api: AxiosInstance, workflowId: string, workflowExecutionId: string, query: QueryObject): Promise<WorkerExecutionListResponse> => {
402
- const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === "workspace");
403
- const workspace = workspaceFilter?.[workspaceFilter.length - 1];
404
-
405
- if (!workspace) throw new Error("Workspace filter is required to list worker executions");
406
-
407
- try {
408
- const params: AnyRecord = {
409
- workspace,
410
- workflow_execution_id: workflowExecutionId,
411
- ...(query ? { query: JSON.stringify(query) } : {}),
302
+ export const listWorkerExecutions = async (
303
+ api: AxiosInstance,
304
+ workflowId: string,
305
+ workflowExecutionId: string,
306
+ { workspace, withResult }: WorkerExecutionListParams,
307
+ signal?: AbortSignal,
308
+ ): Promise<WorkerExecutionListResponse> => {
309
+ requireWorkspace(workspace, "list worker executions");
310
+
311
+ const params = {
312
+ workspace,
313
+ workflow_execution_id: workflowExecutionId,
314
+ ...(withResult !== undefined ? { with_result: withResult } : {}),
412
315
  };
413
316
 
414
- const response: AxiosResponse<WorkerExecutionListResponse> = await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params });
415
- return response.data;
416
- } catch (error: unknown) {
417
- if (isAxiosError<AnyRecord>(error)) {
418
- throw new Error(error.message || "Error listing worker executions");
419
- }
420
-
421
- if (error instanceof Error) {
422
- throw error;
423
- }
424
-
425
- throw new Error("Error listing worker executions");
426
- }
427
- };
317
+ return request(
318
+ () =>
319
+ api.get<WorkerExecutionListResponse>(`${baseUrl}/${workflowId}/worker_executions`, {
320
+ params,
321
+ signal,
322
+ }),
323
+ "Error listing worker executions",
324
+ );
325
+ };