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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (349) hide show
  1. package/README.md +298 -12
  2. package/dist/EveryskApp.d.ts +34 -2
  3. package/dist/EveryskApp.d.ts.map +1 -1
  4. package/dist/EveryskApp.js +35 -2
  5. package/dist/EveryskApp.js.map +1 -1
  6. package/dist/agGrid/handleRowsScrollEnd.d.ts +53 -0
  7. package/dist/agGrid/handleRowsScrollEnd.d.ts.map +1 -0
  8. package/dist/agGrid/handleRowsScrollEnd.js +47 -0
  9. package/dist/agGrid/handleRowsScrollEnd.js.map +1 -0
  10. package/dist/agGrid/index.d.ts +2 -0
  11. package/dist/agGrid/index.d.ts.map +1 -1
  12. package/dist/agGrid/index.js +2 -1
  13. package/dist/api/datastore.d.ts +10 -8
  14. package/dist/api/datastore.d.ts.map +1 -1
  15. package/dist/api/datastore.js +24 -55
  16. package/dist/api/datastore.js.map +1 -1
  17. package/dist/api/entityQuery.d.ts +46 -41
  18. package/dist/api/entityQuery.d.ts.map +1 -1
  19. package/dist/api/entityQuery.js +55 -14
  20. package/dist/api/entityQuery.js.map +1 -1
  21. package/dist/api/file.d.ts +26 -9
  22. package/dist/api/file.d.ts.map +1 -1
  23. package/dist/api/file.js +45 -55
  24. package/dist/api/file.js.map +1 -1
  25. package/dist/api/portfolio.d.ts +11 -8
  26. package/dist/api/portfolio.d.ts.map +1 -1
  27. package/dist/api/portfolio.js +24 -55
  28. package/dist/api/portfolio.js.map +1 -1
  29. package/dist/api/profile.d.ts +3 -2
  30. package/dist/api/profile.d.ts.map +1 -1
  31. package/dist/api/profile.js +4 -9
  32. package/dist/api/profile.js.map +1 -1
  33. package/dist/api/request.d.ts +106 -0
  34. package/dist/api/request.d.ts.map +1 -0
  35. package/dist/api/request.js +132 -0
  36. package/dist/api/request.js.map +1 -0
  37. package/dist/api/websocketsConfig.d.ts +7 -2
  38. package/dist/api/websocketsConfig.d.ts.map +1 -1
  39. package/dist/api/websocketsConfig.js +2 -10
  40. package/dist/api/websocketsConfig.js.map +1 -1
  41. package/dist/api/workflow.d.ts +84 -89
  42. package/dist/api/workflow.d.ts.map +1 -1
  43. package/dist/api/workflow.js +121 -208
  44. package/dist/api/workflow.js.map +1 -1
  45. package/dist/api/workspace.d.ts +18 -8
  46. package/dist/api/workspace.d.ts.map +1 -1
  47. package/dist/api/workspace.js +21 -26
  48. package/dist/api/workspace.js.map +1 -1
  49. package/dist/components/ui/Footer/index.d.ts.map +1 -1
  50. package/dist/components/ui/Footer/index.js.map +1 -1
  51. package/dist/components/ui/GlobalLoading/index.d.ts.map +1 -1
  52. package/dist/components/ui/GlobalLoading/index.js.map +1 -1
  53. package/dist/components/ui/PageContainer/index.d.ts +1 -1
  54. package/dist/components/ui/PageContainer/index.d.ts.map +1 -1
  55. package/dist/components/ui/PageContainer/index.js.map +1 -1
  56. package/dist/components/ui/Toolbar/index.d.ts +40 -3
  57. package/dist/components/ui/Toolbar/index.d.ts.map +1 -1
  58. package/dist/components/ui/Toolbar/index.js +42 -15
  59. package/dist/components/ui/Toolbar/index.js.map +1 -1
  60. package/dist/contexts/appAlertContext/provider.js.map +1 -1
  61. package/dist/contexts/appAlertContext/types.d.ts.map +1 -1
  62. package/dist/contexts/appConfigContext/index.d.ts.map +1 -1
  63. package/dist/contexts/appConfigContext/index.js.map +1 -1
  64. package/dist/contexts/appConfigContext/provider.d.ts.map +1 -1
  65. package/dist/contexts/appConfigContext/provider.js.map +1 -1
  66. package/dist/contexts/webSocketContext/handler.d.ts +3 -2
  67. package/dist/contexts/webSocketContext/handler.d.ts.map +1 -1
  68. package/dist/contexts/webSocketContext/handler.js.map +1 -1
  69. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts +1 -1
  70. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js +1 -1
  71. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js.map +1 -1
  72. package/dist/contexts/webSocketContext/provider.d.ts +6 -3
  73. package/dist/contexts/webSocketContext/provider.d.ts.map +1 -1
  74. package/dist/contexts/webSocketContext/provider.js +42 -7
  75. package/dist/contexts/webSocketContext/provider.js.map +1 -1
  76. package/dist/contexts/webSocketContext/types.d.ts +7 -5
  77. package/dist/contexts/webSocketContext/types.d.ts.map +1 -1
  78. package/dist/file/index.d.ts +2 -0
  79. package/dist/file/index.d.ts.map +1 -1
  80. package/dist/hooks/datastore/useDatastoreMutations.d.ts +4 -4
  81. package/dist/hooks/datastore/useDatastoreMutations.d.ts.map +1 -1
  82. package/dist/hooks/datastore/useDatastoreMutations.js +17 -55
  83. package/dist/hooks/datastore/useDatastoreMutations.js.map +1 -1
  84. package/dist/hooks/datastore/useFetchDatastore.d.ts +30 -41
  85. package/dist/hooks/datastore/useFetchDatastore.d.ts.map +1 -1
  86. package/dist/hooks/datastore/useFetchDatastore.js +25 -59
  87. package/dist/hooks/datastore/useFetchDatastore.js.map +1 -1
  88. package/dist/hooks/datastore/useFetchDatastores.d.ts +47 -52
  89. package/dist/hooks/datastore/useFetchDatastores.d.ts.map +1 -1
  90. package/dist/hooks/datastore/useFetchDatastores.js +55 -70
  91. package/dist/hooks/datastore/useFetchDatastores.js.map +1 -1
  92. package/dist/hooks/file/fileData.d.ts +17 -0
  93. package/dist/hooks/file/fileData.d.ts.map +1 -0
  94. package/dist/hooks/file/fileData.js +10 -0
  95. package/dist/hooks/file/fileData.js.map +1 -0
  96. package/dist/hooks/file/useFetchFile.d.ts +38 -58
  97. package/dist/hooks/file/useFetchFile.d.ts.map +1 -1
  98. package/dist/hooks/file/useFetchFile.js +26 -66
  99. package/dist/hooks/file/useFetchFile.js.map +1 -1
  100. package/dist/hooks/file/useFetchFiles.d.ts +18 -52
  101. package/dist/hooks/file/useFetchFiles.d.ts.map +1 -1
  102. package/dist/hooks/file/useFetchFiles.js +53 -69
  103. package/dist/hooks/file/useFetchFiles.js.map +1 -1
  104. package/dist/hooks/file/useFileMutations.d.ts +9 -8
  105. package/dist/hooks/file/useFileMutations.d.ts.map +1 -1
  106. package/dist/hooks/file/useFileMutations.js +23 -60
  107. package/dist/hooks/file/useFileMutations.js.map +1 -1
  108. package/dist/hooks/portfolio/useFetchPortfolio.d.ts +16 -50
  109. package/dist/hooks/portfolio/useFetchPortfolio.d.ts.map +1 -1
  110. package/dist/hooks/portfolio/useFetchPortfolio.js +15 -63
  111. package/dist/hooks/portfolio/useFetchPortfolio.js.map +1 -1
  112. package/dist/hooks/portfolio/useFetchPortfolios.d.ts +13 -52
  113. package/dist/hooks/portfolio/useFetchPortfolios.d.ts.map +1 -1
  114. package/dist/hooks/portfolio/useFetchPortfolios.js +29 -71
  115. package/dist/hooks/portfolio/useFetchPortfolios.js.map +1 -1
  116. package/dist/hooks/portfolio/usePortfolioMutations.d.ts +8 -8
  117. package/dist/hooks/portfolio/usePortfolioMutations.d.ts.map +1 -1
  118. package/dist/hooks/portfolio/usePortfolioMutations.js +20 -58
  119. package/dist/hooks/portfolio/usePortfolioMutations.js.map +1 -1
  120. package/dist/hooks/profile/useFetchProfile.d.ts +18 -44
  121. package/dist/hooks/profile/useFetchProfile.d.ts.map +1 -1
  122. package/dist/hooks/profile/useFetchProfile.js +16 -48
  123. package/dist/hooks/profile/useFetchProfile.js.map +1 -1
  124. package/dist/hooks/useAxios.js.map +1 -1
  125. package/dist/hooks/useEntityInfiniteQuery.d.ts +88 -0
  126. package/dist/hooks/useEntityInfiniteQuery.d.ts.map +1 -0
  127. package/dist/hooks/useEntityInfiniteQuery.js +111 -0
  128. package/dist/hooks/useEntityInfiniteQuery.js.map +1 -0
  129. package/dist/hooks/useEntityMutation.d.ts +47 -0
  130. package/dist/hooks/useEntityMutation.d.ts.map +1 -0
  131. package/dist/hooks/useEntityMutation.js +58 -0
  132. package/dist/hooks/useEntityMutation.js.map +1 -0
  133. package/dist/hooks/useEntityQuery.d.ts +68 -0
  134. package/dist/hooks/useEntityQuery.d.ts.map +1 -0
  135. package/dist/hooks/useEntityQuery.js +75 -0
  136. package/dist/hooks/useEntityQuery.js.map +1 -0
  137. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts +17 -34
  138. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts.map +1 -1
  139. package/dist/hooks/workflow/useFetchWorkerExecution.js +16 -46
  140. package/dist/hooks/workflow/useFetchWorkerExecution.js.map +1 -1
  141. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts +179 -41
  142. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts.map +1 -1
  143. package/dist/hooks/workflow/useFetchWorkerExecutions.js +29 -62
  144. package/dist/hooks/workflow/useFetchWorkerExecutions.js.map +1 -1
  145. package/dist/hooks/workflow/useFetchWorkflow.d.ts +16 -35
  146. package/dist/hooks/workflow/useFetchWorkflow.d.ts.map +1 -1
  147. package/dist/hooks/workflow/useFetchWorkflow.js +15 -48
  148. package/dist/hooks/workflow/useFetchWorkflow.js.map +1 -1
  149. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts +17 -34
  150. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts.map +1 -1
  151. package/dist/hooks/workflow/useFetchWorkflowExecution.js +16 -46
  152. package/dist/hooks/workflow/useFetchWorkflowExecution.js.map +1 -1
  153. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts +22 -36
  154. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts.map +1 -1
  155. package/dist/hooks/workflow/useFetchWorkflowExecutions.js +43 -56
  156. package/dist/hooks/workflow/useFetchWorkflowExecutions.js.map +1 -1
  157. package/dist/hooks/workflow/useFetchWorkflows.d.ts +20 -37
  158. package/dist/hooks/workflow/useFetchWorkflows.d.ts.map +1 -1
  159. package/dist/hooks/workflow/useFetchWorkflows.js +32 -47
  160. package/dist/hooks/workflow/useFetchWorkflows.js.map +1 -1
  161. package/dist/hooks/workflow/useRunWorkflow.d.ts +21 -16
  162. package/dist/hooks/workflow/useRunWorkflow.d.ts.map +1 -1
  163. package/dist/hooks/workflow/useRunWorkflow.js +66 -29
  164. package/dist/hooks/workflow/useRunWorkflow.js.map +1 -1
  165. package/dist/hooks/workflow/useTriggerWorkflow.d.ts +20 -0
  166. package/dist/hooks/workflow/useTriggerWorkflow.d.ts.map +1 -0
  167. package/dist/hooks/workflow/useTriggerWorkflow.js +32 -0
  168. package/dist/hooks/workflow/useTriggerWorkflow.js.map +1 -0
  169. package/dist/hooks/workspace/useFetchWorkspace.d.ts +19 -34
  170. package/dist/hooks/workspace/useFetchWorkspace.d.ts.map +1 -1
  171. package/dist/hooks/workspace/useFetchWorkspace.js +16 -46
  172. package/dist/hooks/workspace/useFetchWorkspace.js.map +1 -1
  173. package/dist/hooks/workspace/useFetchWorkspaces.d.ts +17 -37
  174. package/dist/hooks/workspace/useFetchWorkspaces.d.ts.map +1 -1
  175. package/dist/hooks/workspace/useFetchWorkspaces.js +25 -47
  176. package/dist/hooks/workspace/useFetchWorkspaces.js.map +1 -1
  177. package/dist/index.d.ts +13 -10
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +13 -11
  180. package/dist/lib/abort.d.ts +58 -0
  181. package/dist/lib/abort.d.ts.map +1 -0
  182. package/dist/lib/abort.js +112 -0
  183. package/dist/lib/abort.js.map +1 -0
  184. package/dist/lib/datastoreTable.d.ts +59 -54
  185. package/dist/lib/datastoreTable.d.ts.map +1 -1
  186. package/dist/lib/datastoreTable.js +58 -62
  187. package/dist/lib/datastoreTable.js.map +1 -1
  188. package/dist/lib/file.d.ts +34 -0
  189. package/dist/lib/file.d.ts.map +1 -0
  190. package/dist/lib/file.js +63 -0
  191. package/dist/lib/file.js.map +1 -0
  192. package/dist/lib/queryClient.d.ts.map +1 -1
  193. package/dist/lib/queryClient.js.map +1 -1
  194. package/dist/lib/workflowRun.d.ts +91 -0
  195. package/dist/lib/workflowRun.d.ts.map +1 -0
  196. package/dist/lib/workflowRun.js +224 -0
  197. package/dist/lib/workflowRun.js.map +1 -0
  198. package/dist/socket/index.d.ts +1 -3
  199. package/dist/socket/index.d.ts.map +1 -1
  200. package/dist/socket/index.js +3 -5
  201. package/dist/test/mocks/index.d.ts +1 -1
  202. package/dist/test/mocks/index.d.ts.map +1 -1
  203. package/dist/test/renderWithProviders.d.ts +2 -2
  204. package/dist/test/renderWithProviders.d.ts.map +1 -1
  205. package/dist/test/renderWithProviders.js.map +1 -1
  206. package/dist/test/setup.js.map +1 -1
  207. package/dist/theme/index.d.ts +1 -1
  208. package/dist/theme/index.d.ts.map +1 -1
  209. package/dist/theme/overrides/index.d.ts +4 -2
  210. package/dist/theme/overrides/index.d.ts.map +1 -1
  211. package/dist/theme/overrides/index.js +5 -3
  212. package/dist/theme/overrides/index.js.map +1 -1
  213. package/dist/theme/overrides/muiButton.d.ts +2 -2
  214. package/dist/theme/overrides/muiButton.js.map +1 -1
  215. package/dist/theme/overrides/muiCssBaseline.d.ts.map +1 -1
  216. package/dist/theme/overrides/muiCssBaseline.js.map +1 -1
  217. package/dist/theme/overrides/muiDatePicker.js.map +1 -1
  218. package/dist/theme/overrides/muiFormControl.js.map +1 -1
  219. package/dist/theme/overrides/muiIconButton.d.ts +2 -2
  220. package/dist/theme/overrides/muiIconButton.js.map +1 -1
  221. package/dist/theme/overrides/muiSelect.d.ts.map +1 -1
  222. package/dist/theme/overrides/muiSelect.js.map +1 -1
  223. package/dist/theme/overrides/muiSvgIcon.d.ts.map +1 -1
  224. package/dist/theme/overrides/muiSvgIcon.js.map +1 -1
  225. package/dist/theme/overrides/muiTextField.js.map +1 -1
  226. package/dist/theme/overrides/muiToggleButton.d.ts +2 -2
  227. package/dist/theme/overrides/muiToggleButton.js.map +1 -1
  228. package/dist/theme/overrides/muiToggleButtonGroup.d.ts +2 -2
  229. package/dist/theme/overrides/muiToggleButtonGroup.js.map +1 -1
  230. package/dist/theme/themes/DefaultDark.js +2 -2
  231. package/dist/theme/themes/DefaultDark.js.map +1 -1
  232. package/dist/theme/themes/DefaultLight.js +2 -2
  233. package/dist/theme/themes/DefaultLight.js.map +1 -1
  234. package/dist/theme/themes/EveryskDark.js +2 -2
  235. package/dist/theme/themes/EveryskDark.js.map +1 -1
  236. package/dist/theme/themes/EveryskLight.js +2 -2
  237. package/dist/theme/themes/EveryskLight.js.map +1 -1
  238. package/dist/theme/themes/MidnightEmber.js +2 -2
  239. package/dist/theme/themes/MidnightEmber.js.map +1 -1
  240. package/dist/types/anyRecord.d.ts.map +1 -1
  241. package/dist/types/datastore.d.ts +35 -5
  242. package/dist/types/datastore.d.ts.map +1 -1
  243. package/dist/types/datastoreDataFormat.d.ts +13 -0
  244. package/dist/types/datastoreDataFormat.d.ts.map +1 -0
  245. package/dist/types/entityQuery.d.ts +86 -16
  246. package/dist/types/entityQuery.d.ts.map +1 -1
  247. package/dist/types/file.d.ts +7 -3
  248. package/dist/types/file.d.ts.map +1 -1
  249. package/dist/types/portfolio.d.ts +1 -3
  250. package/dist/types/portfolio.d.ts.map +1 -1
  251. package/dist/types/profile.d.ts +0 -10
  252. package/dist/types/profile.d.ts.map +1 -1
  253. package/dist/types/workflow.d.ts +35 -6
  254. package/dist/types/workflow.d.ts.map +1 -1
  255. package/dist/types/workspace.d.ts +1 -2
  256. package/dist/types/workspace.d.ts.map +1 -1
  257. package/dist/ui/index.d.ts +1 -1
  258. package/dist/ui/index.d.ts.map +1 -1
  259. package/dist/workflow/index.d.ts +2 -0
  260. package/dist/workflow/index.d.ts.map +1 -1
  261. package/package.json +1 -1
  262. package/src/EveryskApp.tsx +53 -2
  263. package/src/agGrid/handleRowsScrollEnd.ts +71 -0
  264. package/src/agGrid/index.ts +5 -1
  265. package/src/api/datastore.ts +79 -107
  266. package/src/api/entityQuery.ts +86 -17
  267. package/src/api/file.ts +110 -103
  268. package/src/api/portfolio.ts +82 -125
  269. package/src/api/profile.ts +25 -18
  270. package/src/api/request.ts +168 -0
  271. package/src/api/websocketsConfig.ts +11 -19
  272. package/src/api/workflow.ts +232 -334
  273. package/src/api/workspace.ts +43 -43
  274. package/src/components/ui/Footer/index.tsx +8 -7
  275. package/src/components/ui/GlobalLoading/index.tsx +13 -3
  276. package/src/components/ui/PageContainer/index.tsx +9 -2
  277. package/src/components/ui/Toolbar/index.tsx +105 -30
  278. package/src/contexts/appAlertContext/provider.tsx +1 -1
  279. package/src/contexts/appAlertContext/types.ts +3 -3
  280. package/src/contexts/appConfigContext/index.tsx +1 -1
  281. package/src/contexts/appConfigContext/provider.tsx +1 -5
  282. package/src/contexts/webSocketContext/handler.ts +8 -2
  283. package/src/contexts/webSocketContext/hooks/useWebSocket/index.ts +1 -1
  284. package/src/contexts/webSocketContext/provider.tsx +64 -14
  285. package/src/contexts/webSocketContext/types.ts +7 -6
  286. package/src/file/index.ts +2 -0
  287. package/src/hooks/datastore/useDatastoreMutations.ts +19 -60
  288. package/src/hooks/datastore/useFetchDatastore.ts +45 -73
  289. package/src/hooks/datastore/useFetchDatastores.ts +106 -131
  290. package/src/hooks/file/fileData.ts +19 -0
  291. package/src/hooks/file/useFetchFile.ts +41 -76
  292. package/src/hooks/file/useFetchFiles.ts +92 -87
  293. package/src/hooks/file/useFileMutations.ts +23 -73
  294. package/src/hooks/portfolio/useFetchPortfolio.ts +26 -78
  295. package/src/hooks/portfolio/useFetchPortfolios.ts +50 -93
  296. package/src/hooks/portfolio/usePortfolioMutations.ts +22 -72
  297. package/src/hooks/profile/useFetchProfile.ts +24 -65
  298. package/src/hooks/useAxios.ts +5 -5
  299. package/src/hooks/useEntityInfiniteQuery.ts +193 -0
  300. package/src/hooks/useEntityMutation.ts +70 -0
  301. package/src/hooks/useEntityQuery.ts +117 -0
  302. package/src/hooks/workflow/useFetchWorkerExecution.ts +27 -56
  303. package/src/hooks/workflow/useFetchWorkerExecutions.ts +54 -79
  304. package/src/hooks/workflow/useFetchWorkflow.ts +24 -58
  305. package/src/hooks/workflow/useFetchWorkflowExecution.ts +27 -57
  306. package/src/hooks/workflow/useFetchWorkflowExecutions.ts +64 -73
  307. package/src/hooks/workflow/useFetchWorkflows.ts +48 -64
  308. package/src/hooks/workflow/useRunWorkflow.ts +82 -36
  309. package/src/hooks/workflow/useTriggerWorkflow.ts +36 -0
  310. package/src/hooks/workspace/useFetchWorkspace.ts +25 -58
  311. package/src/hooks/workspace/useFetchWorkspaces.ts +38 -69
  312. package/src/index.ts +34 -19
  313. package/src/lib/abort.ts +131 -0
  314. package/src/lib/datastoreTable.ts +127 -74
  315. package/src/lib/file.ts +67 -0
  316. package/src/lib/queryClient.ts +11 -13
  317. package/src/lib/workflowRun.ts +329 -0
  318. package/src/socket/index.ts +1 -3
  319. package/src/test/mocks/index.ts +1 -5
  320. package/src/test/renderWithProviders.tsx +8 -3
  321. package/src/test/setup.ts +16 -16
  322. package/src/theme/index.ts +1 -1
  323. package/src/theme/overrides/index.ts +5 -3
  324. package/src/theme/overrides/muiButton.ts +3 -3
  325. package/src/theme/overrides/muiCssBaseline.ts +11 -12
  326. package/src/theme/overrides/muiDatePicker.ts +2 -2
  327. package/src/theme/overrides/muiFormControl.ts +2 -2
  328. package/src/theme/overrides/muiIconButton.ts +3 -3
  329. package/src/theme/overrides/muiSelect.ts +2 -2
  330. package/src/theme/overrides/muiSvgIcon.ts +2 -2
  331. package/src/theme/overrides/muiTextField.ts +1 -1
  332. package/src/theme/overrides/muiToggleButton.ts +4 -4
  333. package/src/theme/overrides/muiToggleButtonGroup.ts +4 -4
  334. package/src/theme/themes/DefaultDark.ts +2 -2
  335. package/src/theme/themes/DefaultLight.ts +2 -2
  336. package/src/theme/themes/EveryskDark.ts +2 -2
  337. package/src/theme/themes/EveryskLight.ts +2 -2
  338. package/src/theme/themes/MidnightEmber.ts +15 -15
  339. package/src/types/anyRecord.ts +2 -2
  340. package/src/types/datastore.ts +56 -22
  341. package/src/types/datastoreDataFormat.ts +12 -0
  342. package/src/types/entityQuery.ts +122 -38
  343. package/src/types/file.ts +8 -6
  344. package/src/types/portfolio.ts +70 -74
  345. package/src/types/profile.ts +0 -11
  346. package/src/types/workflow.ts +38 -9
  347. package/src/types/workspace.ts +2 -4
  348. package/src/ui/index.ts +1 -1
  349. package/src/workflow/index.ts +5 -0
@@ -1,232 +1,149 @@
1
- import { isAxiosError } from "axios";
1
+ import { pageParams, request, requireWorkspace } from "./request.js";
2
2
  //#region src/api/workflow.ts
3
3
  var baseUrl = "workflows";
4
4
  /**
5
5
  * Runs a workflow asynchronously.
6
6
  *
7
7
  * Starts the workflow in a non-blocking way: the response carries a workflow execution
8
- * with a non-terminal status (e.g. "RUNNING"). Use polling to wait for the terminal state.
8
+ * with a non-terminal status (e.g. "RUNNING"). `useRunWorkflow` waits for the end over
9
+ * the websocket.
9
10
  *
10
11
  * @param api - Axios instance used to make the HTTP request.
11
12
  * @param id - The unique identifier of the workflow to run.
12
13
  * @param workspace - The workspace in which the workflow will be executed.
13
14
  * @param parameters - Key-value parameters to pass to the workflow.
14
- * @returns A promise that resolves with the workflow execution response data.
15
+ * @returns The execution the run started, still `RUNNING`. It used to be the raw body,
16
+ * `{ workflow_execution, result: null }`, where every other function returns the entity.
15
17
  * @throws {Error} If `workspace` is not provided.
16
18
  * @throws {Error} If the request fails.
17
19
  */
18
20
  var runWorkflow = async (api, id, workspace, parameters) => {
19
- if (!workspace) throw new Error("Workspace is required to run workflow");
20
- try {
21
- const body = {
22
- workspace,
23
- parameters
24
- };
25
- return (await api.post(`${baseUrl}/${id}/run`, body)).data;
26
- } catch (error) {
27
- if (isAxiosError(error)) throw new Error(error.message || "", { cause: error });
28
- if (error instanceof Error) throw error;
29
- throw new Error("Error while running workflow", { cause: error });
30
- }
21
+ requireWorkspace(workspace, "run a workflow");
22
+ return (await request(() => api.post(`${baseUrl}/${id}/run`, {
23
+ workspace,
24
+ parameters
25
+ }), "Error running workflow")).workflow_execution;
31
26
  };
32
27
  /**
33
- * Run statuses that indicate a workflow execution has reached a terminal state
34
- * (i.e. it is no longer running and will not change again).
35
- *
36
- * Union of the backend's `WORKFLOW_EXECUTION_STATUS_FINISHED` set and the API's documented
37
- * terminal `run_status` values (`SUCCEEDED`/`FAILED`/`KILLED`). `KILLED` is included so a
38
- * killed execution is detected as terminal instead of polling until timeout.
28
+ * The run statuses a workflow execution can end with. The backend writes `RUNNING` when the run
29
+ * starts, and `SUCCEEDED` or `FAILED` once its Ender finishes; `CANCELED` is reserved for a
30
+ * cancellation it does not write yet. This list used to carry `KILLED`, which the backend never
31
+ * writes, and `COMPLETED`, the value of the deprecated `status` field, seen in `run_status` only
32
+ * on executions from before 2024-10-03.
39
33
  */
40
34
  var TERMINAL_RUN_STATUSES = [
41
- "CANCELED",
42
- "COMPLETED",
43
35
  "SUCCEEDED",
44
36
  "FAILED",
45
- "KILLED"
37
+ "CANCELED"
46
38
  ];
47
- var isTerminalRunStatus = (runStatus) => TERMINAL_RUN_STATUSES.includes(String(runStatus ?? "").toUpperCase());
48
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
49
39
  /**
50
- * Polls a workflow execution until it reaches a terminal run status (see {@link TERMINAL_RUN_STATUSES}).
51
- *
52
- * This is the interim, non-blocking replacement for synchronous (`synchronous: true`) execution:
53
- * the workflow is started asynchronously and its status is checked periodically until it completes.
54
- *
55
- * @param api - Axios instance used to make the HTTP request.
56
- * @param workflowId - The unique identifier of the workflow.
57
- * @param executionId - The unique identifier of the workflow execution to poll.
58
- * @param workspace - The workspace in which the workflow execution resides.
59
- * @param options - Polling configuration (interval, timeout, abort signal).
60
- * @returns A promise that resolves with the terminal {@link WorkflowExecution}.
61
- * @throws {Error} If `workspace` is not provided.
62
- * @throws {Error} If polling is aborted via `options.signal`.
63
- * @throws {Error} If a terminal status is not reached before `options.timeoutMs` elapses.
40
+ * The status a run ended with, read whatever its case; `null` while it has not ended. A missing
41
+ * status — a projection can drop the field, and JSON can carry it as `null` — is a run not known
42
+ * to have ended. The one place a run's status is read, so a comparison against it is typed.
64
43
  */
65
- var pollWorkflowExecution = async (api, workflowId, executionId, workspace, options = {}) => {
66
- if (!workspace) throw new Error("Workspace is required to poll a workflow execution");
67
- const { intervalMs = 2e3, timeoutMs = 3e5, signal } = options;
68
- const startedAt = Date.now();
69
- while (true) {
70
- if (signal?.aborted) throw new Error("Workflow execution polling was aborted");
71
- const execution = await getWorkflowExecution(api, workflowId, executionId, workspace);
72
- if (isTerminalRunStatus(execution.run_status)) return execution;
73
- if (Date.now() - startedAt >= timeoutMs) throw new Error("Timed out while waiting for the workflow execution to complete");
74
- await sleep(intervalMs);
75
- }
76
- };
77
- /**
78
- * Starts a workflow asynchronously and polls its execution until completion.
79
- *
80
- * Interim replacement for synchronous execution: instead of holding the request open with
81
- * `synchronous: true`, the workflow is started in a non-blocking way and its status is polled
82
- * until it reaches a terminal state, at which point the final execution (with its result) is returned.
83
- *
84
- * @param api - Axios instance used to make the HTTP request.
85
- * @param id - The unique identifier of the workflow to run.
86
- * @param workspace - The workspace in which the workflow will be executed.
87
- * @param parameters - Key-value parameters to pass to the workflow.
88
- * @param options - Polling configuration (interval, timeout, abort signal).
89
- * @returns A promise that resolves with the terminal {@link WorkflowExecution}.
90
- * @throws {Error} If `workspace` is not provided.
91
- * @throws {Error} If the run response does not contain a workflow execution id.
92
- * @throws {Error} If the workflow execution ends in a "FAILED" run status.
93
- * @throws {Error} If polling times out or is aborted.
94
- */
95
- var runWorkflowAndPoll = async (api, id, workspace, parameters, options = {}) => {
96
- if (!workspace) throw new Error("Workspace is required to run workflow");
97
- const executionId = (await runWorkflow(api, id, workspace, parameters)).workflow_execution?.id;
98
- if (!executionId) throw new Error("Workflow run did not return an execution id to poll");
99
- const execution = await pollWorkflowExecution(api, id, executionId, workspace, options);
100
- if (String(execution.run_status ?? "").toUpperCase() === "FAILED") throw new Error("Workflow execution failed");
101
- return execution;
102
- };
103
- /**
104
- * Starts a workflow, polls it to completion, then fetches the output produced by its final worker.
105
- *
106
- * A workflow execution does not carry the output payload itself — it references the final worker via
107
- * `ender_worker_execution_id`, and that worker execution's `result` field holds the actual data.
108
- * This helper performs the full flow: start (async) → poll → fetch ender worker → return its `result`.
109
- *
110
- * @param api - Axios instance used to make the HTTP request.
111
- * @param id - The unique identifier of the workflow to run.
112
- * @param workspace - The workspace in which the workflow will be executed.
113
- * @param parameters - Key-value parameters to pass to the workflow.
114
- * @param options - Polling configuration (interval, timeout, abort signal).
115
- * @returns A promise that resolves with the {@link WorkflowResult} (execution, ender worker execution, and its result).
116
- * @throws {Error} If `workspace` is not provided.
117
- * @throws {Error} If the workflow execution ends in a "FAILED" run status.
118
- * @throws {Error} If polling times out or is aborted.
119
- */
120
- var runWorkflowAndGetResult = async (api, id, workspace, parameters, options = {}) => {
121
- const execution = await runWorkflowAndPoll(api, id, workspace, parameters, options);
122
- const enderWorkerExecutionId = execution.ender_worker_execution_id;
123
- if (!enderWorkerExecutionId) return {
124
- execution,
125
- workerExecution: null,
126
- result: null
127
- };
128
- const workerExecution = await getWorkerExecution(api, id, enderWorkerExecutionId, workspace);
129
- return {
130
- execution,
131
- workerExecution,
132
- result: workerExecution.result ?? null
133
- };
44
+ var terminalRunStatusOf = (runStatus) => {
45
+ const upper = runStatus?.toUpperCase();
46
+ return TERMINAL_RUN_STATUSES.find((status) => status === upper) ?? null;
134
47
  };
48
+ /** Whether a run with this `run_status` has ended; see `terminalRunStatusOf`. */
49
+ var isTerminalRunStatus = (runStatus) => terminalRunStatusOf(runStatus) !== null;
135
50
  /**
136
51
  * Fetches a single workflow by ID.
137
52
  *
138
53
  * @param api - Axios instance used to make the HTTP request.
139
54
  * @param id - The unique identifier of the workflow to fetch.
140
55
  * @param workspace - The workspace in which the workflow resides.
56
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
141
57
  * @returns A promise that resolves with the {@link Workflow} object.
142
58
  * @throws {Error} If `workspace` is not provided.
143
59
  * @throws {Error} If the request fails.
144
60
  */
145
- var getWorkflow = async (api, id, workspace) => {
146
- if (!workspace) throw new Error("Workspace is required to fetch a workflow");
147
- try {
148
- const params = { workspace };
149
- return (await api.get(`${baseUrl}/${id}`, { params })).data.workflow;
150
- } catch (error) {
151
- if (isAxiosError(error)) throw new Error(error.message || "Error while fetching workflow", { cause: error });
152
- if (error instanceof Error) throw error;
153
- throw new Error("Error while fetching workflow", { cause: error });
154
- }
61
+ var getWorkflow = async (api, id, workspace, signal) => {
62
+ requireWorkspace(workspace, "fetch a workflow");
63
+ return (await request(() => api.get(`${baseUrl}/${id}`, {
64
+ params: { workspace },
65
+ signal
66
+ }), "Error fetching workflow")).workflow;
155
67
  };
156
68
  /**
157
- * Fetches a paginated list of workflows using the legacy method (workspace as query param).
69
+ * Lists the workflows of a workspace, a page at a time.
70
+ *
71
+ * The endpoint takes a text search rather than the JSON query the other lists take, so this
72
+ * takes `search` rather than a `QueryObject`.
158
73
  *
159
74
  * @param api - Axios instance used to make the HTTP request.
160
- * @param workspace - Current workspace name. Sent as a query param via the legacy method, required by some API configurations.
161
- * @param pageSize - Number of items per page.
162
- * @param pageToken - Cursor token for the next page.
163
- * @returns A promise that resolves with a {@link WorkflowListResponse} containing the matched workflows.
75
+ * @param params - Workspace, search and paging.
76
+ * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
77
+ * @returns A page of workflows, with the cursor to the next one.
78
+ * @throws {Error} If `workspace` is empty.
164
79
  * @throws {Error} If the request fails.
165
80
  */
166
- var listWorkflows = async (api, workspace, pageSize, pageToken) => {
167
- const params = {};
168
- if (workspace) params.workspace = workspace;
169
- if (pageSize) params.page_size = pageSize;
170
- if (pageToken) params.page_token = pageToken;
171
- try {
172
- return (await api.get(baseUrl, { params })).data;
173
- } catch (error) {
174
- if (isAxiosError(error)) throw new Error(error.message || "Error listing workflows", { cause: error });
175
- if (error instanceof Error) throw error;
176
- throw new Error("Error listing workflows", { cause: error });
177
- }
81
+ var listWorkflows = async (api, { workspace, search, pageSize, pageToken }, signal) => {
82
+ requireWorkspace(workspace, "list workflows");
83
+ const params = pageParams({
84
+ workspace,
85
+ search,
86
+ pageSize,
87
+ pageToken
88
+ });
89
+ return request(() => api.get(baseUrl, {
90
+ params,
91
+ signal
92
+ }), "Error listing workflows");
178
93
  };
179
94
  /**
180
95
  * Fetches a single workflow execution by ID.
181
96
  *
182
97
  * @param api - Axios instance used to make the HTTP request.
183
98
  * @param workflowId - The unique identifier of the workflow.
184
- * @param executionId - The unique identifier of the workflow execution to fetch.
99
+ * @param workflowExecutionId - The unique identifier of the workflow execution to fetch.
185
100
  * @param workspace - The workspace in which the workflow execution resides.
101
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
186
102
  * @returns A promise that resolves with the {@link WorkflowExecution} object.
187
103
  * @throws {Error} If `workspace` is not provided.
188
104
  * @throws {Error} If the request fails.
189
105
  */
190
- var getWorkflowExecution = async (api, workflowId, executionId, workspace) => {
191
- if (!workspace) throw new Error("Workspace is required to fetch a workflow execution");
192
- try {
193
- const params = {
194
- workspace,
195
- workflow_execution_id: executionId
196
- };
197
- return (await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params })).data.workflow_execution;
198
- } catch (error) {
199
- if (isAxiosError(error)) throw new Error(error.message || "Error fetching workflow execution", { cause: error });
200
- if (error instanceof Error) throw error;
201
- throw new Error("Error fetching workflow execution", { cause: error });
202
- }
106
+ var getWorkflowExecution = async (api, workflowId, workflowExecutionId, workspace, signal) => {
107
+ requireWorkspace(workspace, "fetch a workflow execution");
108
+ const params = {
109
+ workspace,
110
+ workflow_execution_id: workflowExecutionId
111
+ };
112
+ return (await request(() => api.get(`${baseUrl}/${workflowId}/workflow_executions`, {
113
+ params,
114
+ signal
115
+ }), "Error fetching workflow execution")).workflow_execution;
203
116
  };
204
117
  /**
205
- * Fetches a paginated list of workflow executions matching the given query.
118
+ * Lists the executions of one workflow, newest first, a page at a time.
119
+ *
120
+ * Everything goes in the URL. The endpoint reads `page_size`, `page_token`, `worker_id` and
121
+ * `with_resume` from there and ignores a JSON `query`, which is what this function used to send:
122
+ * the page size had no effect and every "next page" came back as the first one.
206
123
  *
207
124
  * @param api - Axios instance used to make the HTTP request.
208
- * @param workflowId - The unique identifier of the workflow whose executions to list.
209
- * @param query - Query object containing filters, pagination, and sorting options.
210
- * Must include a `workspace` filter expression.
211
- * @returns A promise that resolves with a {@link WorkflowExecutionListResponse} containing the matched executions.
212
- * @throws {Error} If the `workspace` filter is not present in `query.filters`.
125
+ * @param workflowId - The workflow whose executions to list.
126
+ * @param params - Workspace, paging, and the endpoint's two filters.
127
+ * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
128
+ * @returns A page of executions, with the cursor to the next one.
129
+ * @throws {Error} If `workspace` is empty.
213
130
  * @throws {Error} If the request fails.
214
131
  */
215
- var listWorkflowExecutions = async (api, workflowId, query) => {
216
- const workspaceFilter = query.filters.find((filter) => filter[0] === "workspace");
217
- const workspace = workspaceFilter?.[workspaceFilter.length - 1];
218
- if (!workspace) throw new Error("Workspace filter is required to list workflows");
219
- try {
220
- const params = {
132
+ var listWorkflowExecutions = async (api, workflowId, { workspace, pageSize, pageToken, workerId, withResume }, signal) => {
133
+ requireWorkspace(workspace, "list workflow executions");
134
+ const params = {
135
+ ...pageParams({
221
136
  workspace,
222
- ...query ? { query: JSON.stringify(query) } : {}
223
- };
224
- return (await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params })).data;
225
- } catch (error) {
226
- if (isAxiosError(error)) throw new Error(error.message || "Error listing workflow executions", { cause: error });
227
- if (error instanceof Error) throw error;
228
- throw new Error("Error listing workflow executions", { cause: error });
229
- }
137
+ pageSize,
138
+ pageToken
139
+ }),
140
+ ...workerId ? { worker_id: workerId } : {},
141
+ ...withResume !== void 0 ? { with_resume: withResume } : {}
142
+ };
143
+ return request(() => api.get(`${baseUrl}/${workflowId}/workflow_executions`, {
144
+ params,
145
+ signal
146
+ }), "Error listing workflow executions");
230
147
  };
231
148
  /**
232
149
  * Fetches a single worker execution by ID.
@@ -235,55 +152,51 @@ var listWorkflowExecutions = async (api, workflowId, query) => {
235
152
  * @param workflowId - The unique identifier of the parent workflow.
236
153
  * @param workerExecutionId - The unique identifier of the worker execution to fetch.
237
154
  * @param workspace - The workspace in which the worker execution resides.
155
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
238
156
  * @returns A promise that resolves with the {@link WorkerExecution} object.
239
157
  * @throws {Error} If `workspace` is not provided.
240
158
  * @throws {Error} If the request fails.
241
159
  */
242
- var getWorkerExecution = async (api, workflowId, workerExecutionId, workspace) => {
243
- if (!workspace) throw new Error("Workspace is required to fetch a worker execution");
244
- try {
245
- const params = {
246
- workspace,
247
- worker_execution_id: workerExecutionId,
248
- with_result: true
249
- };
250
- return (await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params })).data.worker_execution;
251
- } catch (error) {
252
- if (isAxiosError(error)) throw new Error(error.message || "Error fetching worker execution", { cause: error });
253
- if (error instanceof Error) throw error;
254
- throw new Error("Error fetching worker execution", { cause: error });
255
- }
160
+ var getWorkerExecution = async (api, workflowId, workerExecutionId, workspace, signal) => {
161
+ requireWorkspace(workspace, "fetch a worker execution");
162
+ const params = {
163
+ workspace,
164
+ worker_execution_id: workerExecutionId,
165
+ with_result: true
166
+ };
167
+ return (await request(() => api.get(`${baseUrl}/${workflowId}/worker_executions`, {
168
+ params,
169
+ signal
170
+ }), "Error fetching worker execution")).worker_execution;
256
171
  };
257
172
  /**
258
- * Fetches a paginated list of worker executions for a given workflow.
173
+ * Lists every worker execution of one workflow execution, grouped by worker.
174
+ *
175
+ * The endpoint returns them all at once: it is not paginated and takes no query. Each group is
176
+ * one worker, with its run as `execution`, or every parallel run as `executions`.
259
177
  *
260
178
  * @param api - Axios instance used to make the HTTP request.
261
- * @param workflowId - The unique identifier of the parent workflow.
262
- * @param workflowExecutionId - The unique identifier of the workflow execution to filter by.
263
- * @param query - Query object containing filters, pagination, and sorting options.
264
- * Must include a `workspace` filter expression.
265
- * @returns A promise that resolves with a {@link WorkerExecutionListResponse} containing the matched worker executions.
266
- * @throws {Error} If the `workspace` filter is not present in `query.filters`.
179
+ * @param workflowId - The parent workflow.
180
+ * @param workflowExecutionId - The workflow execution whose workers to list.
181
+ * @param params - Workspace, and whether to include results.
182
+ * @param {AbortSignal} [signal] - Aborts the request itself; the hooks pass the query's own.
183
+ * @returns The groups, and the highest parallel index among them.
184
+ * @throws {Error} If `workspace` is empty.
267
185
  * @throws {Error} If the request fails.
268
186
  */
269
- var listWorkerExecutions = async (api, workflowId, workflowExecutionId, query) => {
270
- const workspaceFilter = query.filters.find((filter) => filter[0] === "workspace");
271
- const workspace = workspaceFilter?.[workspaceFilter.length - 1];
272
- if (!workspace) throw new Error("Workspace filter is required to list worker executions");
273
- try {
274
- const params = {
275
- workspace,
276
- workflow_execution_id: workflowExecutionId,
277
- ...query ? { query: JSON.stringify(query) } : {}
278
- };
279
- return (await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params })).data;
280
- } catch (error) {
281
- if (isAxiosError(error)) throw new Error(error.message || "Error listing worker executions", { cause: error });
282
- if (error instanceof Error) throw error;
283
- throw new Error("Error listing worker executions", { cause: error });
284
- }
187
+ var listWorkerExecutions = async (api, workflowId, workflowExecutionId, { workspace, withResult }, signal) => {
188
+ requireWorkspace(workspace, "list worker executions");
189
+ const params = {
190
+ workspace,
191
+ workflow_execution_id: workflowExecutionId,
192
+ ...withResult !== void 0 ? { with_result: withResult } : {}
193
+ };
194
+ return request(() => api.get(`${baseUrl}/${workflowId}/worker_executions`, {
195
+ params,
196
+ signal
197
+ }), "Error listing worker executions");
285
198
  };
286
199
  //#endregion
287
- export { TERMINAL_RUN_STATUSES, getWorkerExecution, getWorkflow, getWorkflowExecution, listWorkerExecutions, listWorkflowExecutions, listWorkflows, pollWorkflowExecution, runWorkflow, runWorkflowAndGetResult };
200
+ export { TERMINAL_RUN_STATUSES, getWorkerExecution, getWorkflow, getWorkflowExecution, isTerminalRunStatus, listWorkerExecutions, listWorkflowExecutions, listWorkflows, runWorkflow, terminalRunStatusOf };
288
201
 
289
202
  //# sourceMappingURL=workflow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.js","names":[],"sources":["../../src/api/workflow.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { FilterExpression, QueryObject } from \"@/types/entityQuery\";\nimport type { WorkerExecution, WorkerExecutionListResponse, WorkerExecutionSingleResponse, Workflow, WorkflowExecution, WorkflowExecutionListResponse, WorkflowExecutionSingleResponse, WorkflowListResponse, WorkflowSingleResponse } from \"@/types/workflow\";\n\nconst baseUrl = \"workflows\";\n\n/**\n * Runs a workflow asynchronously.\n *\n * Starts the workflow in a non-blocking way: the response carries a workflow execution\n * with a non-terminal status (e.g. \"RUNNING\"). Use polling to wait for the terminal state.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to run.\n * @param workspace - The workspace in which the workflow will be executed.\n * @param parameters - Key-value parameters to pass to the workflow.\n * @returns A promise that resolves with the workflow execution response data.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const runWorkflow = async (api: AxiosInstance, id: string, workspace: string, parameters: AnyRecord): Promise<AnyRecord> => {\n \n if (!workspace) {\n throw new Error(\"Workspace is required to run workflow\");\n } \n\n try {\n const body: AnyRecord = {\n workspace,\n parameters,\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const response: AxiosResponse<any> = await api.post(`${baseUrl}/${id}/run`, body);\n\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while running workflow\", { cause: error });\n }\n};\n\n/**\n * Run statuses that indicate a workflow execution has reached a terminal state\n * (i.e. it is no longer running and will not change again).\n *\n * Union of the backend's `WORKFLOW_EXECUTION_STATUS_FINISHED` set and the API's documented\n * terminal `run_status` values (`SUCCEEDED`/`FAILED`/`KILLED`). `KILLED` is included so a\n * killed execution is detected as terminal instead of polling until timeout.\n */\nexport const TERMINAL_RUN_STATUSES = [\"CANCELED\", \"COMPLETED\", \"SUCCEEDED\", \"FAILED\", \"KILLED\"] as const;\n\nconst isTerminalRunStatus = (runStatus: unknown): boolean =>\n TERMINAL_RUN_STATUSES.includes(String(runStatus ?? \"\").toUpperCase() as (typeof TERMINAL_RUN_STATUSES)[number]);\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\nexport type PollWorkflowExecutionOptions = {\n /** Delay between status checks, in milliseconds. Defaults to 2000ms. */\n intervalMs?: number;\n /** Maximum time to wait for a terminal status before giving up, in milliseconds. Defaults to 5 minutes. */\n timeoutMs?: number;\n /** Optional abort signal to cancel polling (e.g. on unmount). */\n signal?: AbortSignal;\n};\n\n/**\n * Polls a workflow execution until it reaches a terminal run status (see {@link TERMINAL_RUN_STATUSES}).\n *\n * This is the interim, non-blocking replacement for synchronous (`synchronous: true`) execution:\n * the workflow is started asynchronously and its status is checked periodically until it completes.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the workflow.\n * @param executionId - The unique identifier of the workflow execution to poll.\n * @param workspace - The workspace in which the workflow execution resides.\n * @param options - Polling configuration (interval, timeout, abort signal).\n * @returns A promise that resolves with the terminal {@link WorkflowExecution}.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If polling is aborted via `options.signal`.\n * @throws {Error} If a terminal status is not reached before `options.timeoutMs` elapses.\n */\nexport const pollWorkflowExecution = async (\n api: AxiosInstance,\n workflowId: string,\n executionId: string,\n workspace: string,\n options: PollWorkflowExecutionOptions = {}\n): Promise<WorkflowExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to poll a workflow execution\");\n }\n\n const { intervalMs = 2000, timeoutMs = 5 * 60 * 1000, signal } = options;\n const startedAt = Date.now();\n\n while (true) {\n if (signal?.aborted) {\n throw new Error(\"Workflow execution polling was aborted\");\n }\n\n const execution = await getWorkflowExecution(api, workflowId, executionId, workspace);\n\n if (isTerminalRunStatus(execution.run_status)) {\n return execution;\n }\n\n if (Date.now() - startedAt >= timeoutMs) {\n throw new Error(\"Timed out while waiting for the workflow execution to complete\");\n }\n\n await sleep(intervalMs);\n }\n};\n\n/**\n * Starts a workflow asynchronously and polls its execution until completion.\n *\n * Interim replacement for synchronous execution: instead of holding the request open with\n * `synchronous: true`, the workflow is started in a non-blocking way and its status is polled\n * until it reaches a terminal state, at which point the final execution (with its result) is returned.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to run.\n * @param workspace - The workspace in which the workflow will be executed.\n * @param parameters - Key-value parameters to pass to the workflow.\n * @param options - Polling configuration (interval, timeout, abort signal).\n * @returns A promise that resolves with the terminal {@link WorkflowExecution}.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the run response does not contain a workflow execution id.\n * @throws {Error} If the workflow execution ends in a \"FAILED\" run status.\n * @throws {Error} If polling times out or is aborted.\n */\nconst runWorkflowAndPoll = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n parameters: AnyRecord,\n options: PollWorkflowExecutionOptions = {}\n): Promise<WorkflowExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to run workflow\");\n }\n\n // Start the workflow asynchronously (non-blocking).\n const startResponse = await runWorkflow(api, id, workspace, parameters);\n const executionId = (startResponse.workflow_execution as WorkflowExecution | undefined)?.id;\n\n if (!executionId) {\n throw new Error(\"Workflow run did not return an execution id to poll\");\n }\n\n // Poll the execution status until it completes, then consume the result.\n const execution = await pollWorkflowExecution(api, id, executionId, workspace, options);\n\n if (String(execution.run_status ?? \"\").toUpperCase() === \"FAILED\") {\n throw new Error(\"Workflow execution failed\");\n }\n\n return execution;\n};\n\n/**\n * The terminal workflow execution together with the output produced by its final (ender) worker.\n */\nexport type WorkflowResult = {\n /** The terminal workflow execution. */\n execution: WorkflowExecution;\n /** The ender worker execution, or `null` if the execution did not reference one. */\n workerExecution: WorkerExecution | null;\n /** The output data produced by the ender worker (`workerExecution.result`), or `null`. */\n result: Record<string, unknown> | null;\n};\n\n/**\n * Starts a workflow, polls it to completion, then fetches the output produced by its final worker.\n *\n * A workflow execution does not carry the output payload itself — it references the final worker via\n * `ender_worker_execution_id`, and that worker execution's `result` field holds the actual data.\n * This helper performs the full flow: start (async) → poll → fetch ender worker → return its `result`.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to run.\n * @param workspace - The workspace in which the workflow will be executed.\n * @param parameters - Key-value parameters to pass to the workflow.\n * @param options - Polling configuration (interval, timeout, abort signal).\n * @returns A promise that resolves with the {@link WorkflowResult} (execution, ender worker execution, and its result).\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the workflow execution ends in a \"FAILED\" run status.\n * @throws {Error} If polling times out or is aborted.\n */\nexport const runWorkflowAndGetResult = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n parameters: AnyRecord,\n options: PollWorkflowExecutionOptions = {}\n): Promise<WorkflowResult> => {\n const execution = await runWorkflowAndPoll(api, id, workspace, parameters, options);\n\n const enderWorkerExecutionId = execution.ender_worker_execution_id;\n if (!enderWorkerExecutionId) {\n return { execution, workerExecution: null, result: null };\n }\n\n const workerExecution = await getWorkerExecution(api, id, enderWorkerExecutionId, workspace);\n\n return { execution, workerExecution, result: workerExecution.result ?? null };\n};\n\n/**\n * Fetches a single workflow by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to fetch.\n * @param workspace - The workspace in which the workflow resides.\n * @returns A promise that resolves with the {@link Workflow} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkflow = async (api: AxiosInstance, id: string, workspace: string): Promise<Workflow> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch a workflow\");\n }\n \n try {\n const params: AnyRecord = { workspace };\n const response: AxiosResponse<WorkflowSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });\n\n return response.data.workflow;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error while fetching workflow\", { cause: error });\n } \n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error while fetching workflow\", { cause: error });\n }\n};\n\n/**\n * Fetches a paginated list of workflows using the legacy method (workspace as query param).\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workspace - Current workspace name. Sent as a query param via the legacy method, required by some API configurations.\n * @param pageSize - Number of items per page.\n * @param pageToken - Cursor token for the next page.\n * @returns A promise that resolves with a {@link WorkflowListResponse} containing the matched workflows.\n * @throws {Error} If the request fails.\n */\nexport const listWorkflows = async (api: AxiosInstance, workspace?: string, pageSize?: number, pageToken?: string): Promise<WorkflowListResponse> => {\n const params: AnyRecord = {};\n\n if (workspace) params.workspace = workspace;\n if (pageSize) params.page_size = pageSize;\n if (pageToken) params.page_token = pageToken;\n\n try {\n const response: AxiosResponse<WorkflowListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing workflows\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing workflows\", { cause: error });\n }\n};\n\n/**\n * Fetches a single workflow execution by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the workflow.\n * @param executionId - The unique identifier of the workflow execution to fetch.\n * @param workspace - The workspace in which the workflow execution resides.\n * @returns A promise that resolves with the {@link WorkflowExecution} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkflowExecution = async (api: AxiosInstance, workflowId: string, executionId: string, workspace: string): Promise<WorkflowExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch a workflow execution\");\n }\n\n try {\n const params: AnyRecord = { workspace, workflow_execution_id: executionId };\n const response: AxiosResponse<WorkflowExecutionSingleResponse> = await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params });\n return response.data.workflow_execution;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching workflow execution\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching workflow execution\", { cause: error });\n }\n};\n\n/**\n * Fetches a paginated list of workflow executions matching the given query.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the workflow whose executions to list.\n * @param query - Query object containing filters, pagination, and sorting options.\n * Must include a `workspace` filter expression.\n * @returns A promise that resolves with a {@link WorkflowExecutionListResponse} containing the matched executions.\n * @throws {Error} If the `workspace` filter is not present in `query.filters`.\n * @throws {Error} If the request fails.\n */\nexport const listWorkflowExecutions = async (api: AxiosInstance, workflowId: string, query: QueryObject): Promise<WorkflowExecutionListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) throw new Error(\"Workspace filter is required to list workflows\");\n\n try {\n const params: AnyRecord = {\n workspace,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n const response: AxiosResponse<WorkflowExecutionListResponse> = await api.get(`${baseUrl}/${workflowId}/workflow_executions`, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing workflow executions\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing workflow executions\", { cause: error });\n }\n};\n\n/**\n * Fetches a single worker execution by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the parent workflow.\n * @param workerExecutionId - The unique identifier of the worker execution to fetch.\n * @param workspace - The workspace in which the worker execution resides.\n * @returns A promise that resolves with the {@link WorkerExecution} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkerExecution = async (api: AxiosInstance, workflowId: string, workerExecutionId: string, workspace: string): Promise<WorkerExecution> => {\n if (!workspace) {\n throw new Error(\"Workspace is required to fetch a worker execution\");\n }\n\n try {\n const params: AnyRecord = { workspace, worker_execution_id: workerExecutionId, with_result: true };\n const response: AxiosResponse<WorkerExecutionSingleResponse> = await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params });\n return response.data.worker_execution;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching worker execution\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching worker execution\", { cause: error });\n }\n}\n\n/**\n * Fetches a paginated list of worker executions for a given workflow.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the parent workflow.\n * @param workflowExecutionId - The unique identifier of the workflow execution to filter by.\n * @param query - Query object containing filters, pagination, and sorting options.\n * Must include a `workspace` filter expression.\n * @returns A promise that resolves with a {@link WorkerExecutionListResponse} containing the matched worker executions.\n * @throws {Error} If the `workspace` filter is not present in `query.filters`.\n * @throws {Error} If the request fails.\n */\nexport const listWorkerExecutions = async (api: AxiosInstance, workflowId: string, workflowExecutionId: string, query: QueryObject): Promise<WorkerExecutionListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) throw new Error(\"Workspace filter is required to list worker executions\");\n\n try {\n const params: AnyRecord = {\n workspace,\n workflow_execution_id: workflowExecutionId,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n const response: AxiosResponse<WorkerExecutionListResponse> = await api.get(`${baseUrl}/${workflowId}/worker_executions`, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing worker executions\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing worker executions\", { cause: error });\n }\n};"],"mappings":";;AAMA,IAAM,UAAU;;;;;;;;;;;;;;;AAgBhB,IAAa,cAAc,OAAO,KAAoB,IAAY,WAAmB,eAA8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AE,OAAO,CAAC,EAAA,CACnH;CAClB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,mCAAmC,EAAE,OAAO,MAAM,CAAC;EAGtF,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,MAAM,CAAC;CACrE;AACF"}
1
+ {"version":3,"file":"workflow.js","names":[],"sources":["../../src/api/workflow.ts"],"sourcesContent":["import type { AxiosInstance } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport { pageParams, request, requireWorkspace } from \"./request\";\nimport type { EntitySingleResponse } from \"@/types/entityQuery\";\nimport type {\n WorkerExecution,\n WorkerExecutionListResponse,\n Workflow,\n WorkflowExecution,\n WorkflowExecutionListResponse,\n WorkflowListResponse,\n} from \"@/types/workflow\";\n\nconst baseUrl = \"workflows\";\n\n/** The endpoints' envelopes, private: every function here returns the entity itself. */\ntype WorkflowSingleResponse = EntitySingleResponse<\"workflow\", Workflow>;\ntype WorkflowExecutionSingleResponse = EntitySingleResponse<\n \"workflow_execution\",\n WorkflowExecution\n>;\ntype WorkerExecutionSingleResponse = EntitySingleResponse<\"worker_execution\", WorkerExecution>;\n\n/**\n * What `POST /workflows/:id/run` answers: the execution it started, still `RUNNING`, and a\n * `result` that is always `null` — the run is asynchronous, and the output is read from the\n * Ender's worker execution once it finishes. Private: `runWorkflow` returns the execution.\n */\ntype RunWorkflowResponse = {\n workflow_execution: WorkflowExecution;\n result: null;\n};\n\n/**\n * Runs a workflow asynchronously.\n *\n * Starts the workflow in a non-blocking way: the response carries a workflow execution\n * with a non-terminal status (e.g. \"RUNNING\"). `useRunWorkflow` waits for the end over\n * the websocket.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to run.\n * @param workspace - The workspace in which the workflow will be executed.\n * @param parameters - Key-value parameters to pass to the workflow.\n * @returns The execution the run started, still `RUNNING`. It used to be the raw body,\n * `{ workflow_execution, result: null }`, where every other function returns the entity.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const runWorkflow = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n parameters: AnyRecord,\n): Promise<WorkflowExecution> => {\n requireWorkspace(workspace, \"run a workflow\");\n\n const body = await request(\n () => api.post<RunWorkflowResponse>(`${baseUrl}/${id}/run`, { workspace, parameters }),\n \"Error running workflow\",\n );\n return body.workflow_execution;\n};\n\n/**\n * The run statuses a workflow execution can end with. The backend writes `RUNNING` when the run\n * starts, and `SUCCEEDED` or `FAILED` once its Ender finishes; `CANCELED` is reserved for a\n * cancellation it does not write yet. This list used to carry `KILLED`, which the backend never\n * writes, and `COMPLETED`, the value of the deprecated `status` field, seen in `run_status` only\n * on executions from before 2024-10-03.\n */\nexport const TERMINAL_RUN_STATUSES = [\"SUCCEEDED\", \"FAILED\", \"CANCELED\"] as const;\n\nexport type TerminalRunStatus = (typeof TERMINAL_RUN_STATUSES)[number];\n\n/**\n * The status a run ended with, read whatever its case; `null` while it has not ended. A missing\n * status — a projection can drop the field, and JSON can carry it as `null` — is a run not known\n * to have ended. The one place a run's status is read, so a comparison against it is typed.\n */\nexport const terminalRunStatusOf = (\n runStatus: string | null | undefined,\n): TerminalRunStatus | null => {\n const upper = runStatus?.toUpperCase();\n return TERMINAL_RUN_STATUSES.find((status) => status === upper) ?? null;\n};\n\n/** Whether a run with this `run_status` has ended; see `terminalRunStatusOf`. */\nexport const isTerminalRunStatus = (runStatus: string | null | undefined): boolean =>\n terminalRunStatusOf(runStatus) !== null;\n\n/**\n * Fetches a single workflow by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param id - The unique identifier of the workflow to fetch.\n * @param workspace - The workspace in which the workflow resides.\n * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.\n * @returns A promise that resolves with the {@link Workflow} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkflow = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n signal?: AbortSignal,\n): Promise<Workflow> => {\n requireWorkspace(workspace, \"fetch a workflow\");\n\n const body = await request(\n () =>\n api.get<WorkflowSingleResponse>(`${baseUrl}/${id}`, { params: { workspace }, signal }),\n \"Error fetching workflow\",\n );\n return body.workflow;\n};\n\n/** What `listWorkflows` sends. */\nexport type WorkflowListParams = {\n /** Required: without one the API lists `main` rather than failing, and refuses a sub-user. */\n workspace: string;\n /** A name prefix, an id, `#tag #tag` (every tag), or `&link_uid`. Sent as `query`. */\n search?: string;\n pageSize?: number;\n pageToken?: string;\n};\n\n/**\n * Lists the workflows of a workspace, a page at a time.\n *\n * The endpoint takes a text search rather than the JSON query the other lists take, so this\n * takes `search` rather than a `QueryObject`.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param params - Workspace, search and paging.\n * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.\n * @returns A page of workflows, with the cursor to the next one.\n * @throws {Error} If `workspace` is empty.\n * @throws {Error} If the request fails.\n */\nexport const listWorkflows = async (\n api: AxiosInstance,\n { workspace, search, pageSize, pageToken }: WorkflowListParams,\n signal?: AbortSignal,\n): Promise<WorkflowListResponse> => {\n requireWorkspace(workspace, \"list workflows\");\n\n const params = pageParams({ workspace, search, pageSize, pageToken });\n\n return request(\n () => api.get<WorkflowListResponse>(baseUrl, { params, signal }),\n \"Error listing workflows\",\n );\n};\n\n/**\n * Fetches a single workflow execution by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the workflow.\n * @param workflowExecutionId - The unique identifier of the workflow execution to fetch.\n * @param workspace - The workspace in which the workflow execution resides.\n * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.\n * @returns A promise that resolves with the {@link WorkflowExecution} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkflowExecution = async (\n api: AxiosInstance,\n workflowId: string,\n workflowExecutionId: string,\n workspace: string,\n signal?: AbortSignal,\n): Promise<WorkflowExecution> => {\n requireWorkspace(workspace, \"fetch a workflow execution\");\n\n const params: AnyRecord = { workspace, workflow_execution_id: workflowExecutionId };\n const body = await request(\n () =>\n api.get<WorkflowExecutionSingleResponse>(\n `${baseUrl}/${workflowId}/workflow_executions`,\n { params, signal },\n ),\n \"Error fetching workflow execution\",\n );\n return body.workflow_execution;\n};\n\n/** What `listWorkflowExecutions` sends: the parameters the endpoint reads, each from the URL. */\nexport type WorkflowExecutionListParams = {\n /** Not used to filter: the endpoint lists the workflow's executions. A sub-user's role check needs it. */\n workspace: string;\n pageSize?: number;\n pageToken?: string;\n /** Only the executions this worker took part in. */\n workerId?: string;\n /** Include each execution's `resume`, the per-worker summary. The API leaves it out by default. */\n withResume?: boolean;\n};\n\n/**\n * Lists the executions of one workflow, newest first, a page at a time.\n *\n * Everything goes in the URL. The endpoint reads `page_size`, `page_token`, `worker_id` and\n * `with_resume` from there and ignores a JSON `query`, which is what this function used to send:\n * the page size had no effect and every \"next page\" came back as the first one.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The workflow whose executions to list.\n * @param params - Workspace, paging, and the endpoint's two filters.\n * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.\n * @returns A page of executions, with the cursor to the next one.\n * @throws {Error} If `workspace` is empty.\n * @throws {Error} If the request fails.\n */\nexport const listWorkflowExecutions = async (\n api: AxiosInstance,\n workflowId: string,\n { workspace, pageSize, pageToken, workerId, withResume }: WorkflowExecutionListParams,\n signal?: AbortSignal,\n): Promise<WorkflowExecutionListResponse> => {\n requireWorkspace(workspace, \"list workflow executions\");\n\n const params = {\n ...pageParams({ workspace, pageSize, pageToken }),\n ...(workerId ? { worker_id: workerId } : {}),\n ...(withResume !== undefined ? { with_resume: withResume } : {}),\n };\n\n return request(\n () =>\n api.get<WorkflowExecutionListResponse>(`${baseUrl}/${workflowId}/workflow_executions`, {\n params,\n signal,\n }),\n \"Error listing workflow executions\",\n );\n};\n\n/**\n * Fetches a single worker execution by ID.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The unique identifier of the parent workflow.\n * @param workerExecutionId - The unique identifier of the worker execution to fetch.\n * @param workspace - The workspace in which the worker execution resides.\n * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.\n * @returns A promise that resolves with the {@link WorkerExecution} object.\n * @throws {Error} If `workspace` is not provided.\n * @throws {Error} If the request fails.\n */\nexport const getWorkerExecution = async (\n api: AxiosInstance,\n workflowId: string,\n workerExecutionId: string,\n workspace: string,\n signal?: AbortSignal,\n): Promise<WorkerExecution> => {\n requireWorkspace(workspace, \"fetch a worker execution\");\n\n const params: AnyRecord = {\n workspace,\n worker_execution_id: workerExecutionId,\n with_result: true,\n };\n const body = await request(\n () =>\n api.get<WorkerExecutionSingleResponse>(`${baseUrl}/${workflowId}/worker_executions`, {\n params,\n signal,\n }),\n \"Error fetching worker execution\",\n );\n return body.worker_execution;\n};\n\n/** What `listWorkerExecutions` sends besides the execution id. */\nexport type WorkerExecutionListParams = {\n /** Not used to filter. A sub-user's role check needs it. */\n workspace: string;\n /** Include each run's `result` and `input_params`. The API leaves them out by default. */\n withResult?: boolean;\n};\n\n/**\n * Lists every worker execution of one workflow execution, grouped by worker.\n *\n * The endpoint returns them all at once: it is not paginated and takes no query. Each group is\n * one worker, with its run as `execution`, or every parallel run as `executions`.\n *\n * @param api - Axios instance used to make the HTTP request.\n * @param workflowId - The parent workflow.\n * @param workflowExecutionId - The workflow execution whose workers to list.\n * @param params - Workspace, and whether to include results.\n * @param {AbortSignal} [signal] - Aborts the request itself; the hooks pass the query's own.\n * @returns The groups, and the highest parallel index among them.\n * @throws {Error} If `workspace` is empty.\n * @throws {Error} If the request fails.\n */\nexport const listWorkerExecutions = async (\n api: AxiosInstance,\n workflowId: string,\n workflowExecutionId: string,\n { workspace, withResult }: WorkerExecutionListParams,\n signal?: AbortSignal,\n): Promise<WorkerExecutionListResponse> => {\n requireWorkspace(workspace, \"list worker executions\");\n\n const params = {\n workspace,\n workflow_execution_id: workflowExecutionId,\n ...(withResult !== undefined ? { with_result: withResult } : {}),\n };\n\n return request(\n () =>\n api.get<WorkerExecutionListResponse>(`${baseUrl}/${workflowId}/worker_executions`, {\n params,\n signal,\n }),\n \"Error listing worker executions\",\n );\n};\n"],"mappings":";;AAcA,IAAM,UAAU;;;;;;;;;;;;;;;;;AAoChB,IAAa,cAAc,OACvB,KACA,IACA,WACA,eAC6B;CAC7B,iBAAiB,WAAW,gBAAgB;CAM5C,QAAO,MAJY,cACT,IAAI,KAA0B,GAAG,QAAQ,GAAG,GAAG,OAAO;EAAE;EAAW;CAAW,CAAC,GACrF,wBACJ,EAAA,CACY;AAChB;;;;;;;;AASA,IAAa,wBAAwB;CAAC;CAAa;CAAU;AAAU;;;;;;AASvE,IAAa,uBACT,cAC2B;CAC3B,MAAM,QAAQ,WAAW,YAAY;CACrC,OAAO,sBAAsB,MAAM,WAAW,WAAW,KAAK,KAAK;AACvE;;AAGA,IAAa,uBAAuB,cAChC,oBAAoB,SAAS,MAAM;;;;;;;;;;;;AAavC,IAAa,cAAc,OACvB,KACA,IACA,WACA,WACoB;CACpB,iBAAiB,WAAW,kBAAkB;CAO9C,QAAO,MALY,cAEX,IAAI,IAA4B,GAAG,QAAQ,GAAG,MAAM;EAAE,QAAQ,EAAE,UAAU;EAAG;CAAO,CAAC,GACzF,yBACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;;AAyBA,IAAa,gBAAgB,OACzB,KACA,EAAE,WAAW,QAAQ,UAAU,aAC/B,WACgC;CAChC,iBAAiB,WAAW,gBAAgB;CAE5C,MAAM,SAAS,WAAW;EAAE;EAAW;EAAQ;EAAU;CAAU,CAAC;CAEpE,OAAO,cACG,IAAI,IAA0B,SAAS;EAAE;EAAQ;CAAO,CAAC,GAC/D,yBACJ;AACJ;;;;;;;;;;;;;AAcA,IAAa,uBAAuB,OAChC,KACA,YACA,qBACA,WAC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1,4 +1,4 @@
1
- import { type AxiosInstance } from "axios";
1
+ import type { AxiosInstance } from "axios";
2
2
  import type { Workspace, WorkspaceListResponse } from "../types/workspace.d.ts";
3
3
  /**
4
4
  * getWorkspace
@@ -7,23 +7,33 @@ import type { Workspace, WorkspaceListResponse } from "../types/workspace.d.ts";
7
7
  *
8
8
  * @param {AxiosInstance} api - Axios instance.
9
9
  * @param {string} name - Workspace name.
10
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
10
11
  * @returns {Promise<Workspace>} The fetched workspace.
11
12
  *
12
13
  * @throws {Error} If the request fails.
13
14
  */
14
- export declare const getWorkspace: (api: AxiosInstance, name: string) => Promise<Workspace>;
15
+ export declare const getWorkspace: (api: AxiosInstance, name: string, signal?: AbortSignal) => Promise<Workspace>;
16
+ /** What `listWorkspaces` sends. */
17
+ export type WorkspaceListParams = {
18
+ /** A name prefix. Sent as `query`. */
19
+ search?: string;
20
+ pageSize?: number;
21
+ pageToken?: string;
22
+ };
15
23
  /**
16
24
  * listWorkspaces
17
25
  *
18
- * Fetches a list of workspaces with optional cursor-based pagination.
26
+ * Lists the account's workspaces, a page at a time.
27
+ *
28
+ * The one list that takes no workspace: the docs exempt it, and the endpoint ignores one. This
29
+ * function used to send it anyway, documented as "required by some API configurations".
19
30
  *
20
31
  * @param {AxiosInstance} api - Axios instance.
21
- * @param {string} [workspace] - Current workspace name. Sent as a query param via the legacy method, required by some API configurations.
22
- * @param {number} [pageSize] - Number of items per page.
23
- * @param {string} [pageToken] - Cursor token for the next page.
24
- * @returns {Promise<WorkspaceListResponse>} List of workspaces.
32
+ * @param {WorkspaceListParams} [params] - Search and paging.
33
+ * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
34
+ * @returns {Promise<WorkspaceListResponse>} A page of workspaces, with the cursor to the next one.
25
35
  *
26
36
  * @throws {Error} If the request fails.
27
37
  */
28
- export declare const listWorkspaces: (api: AxiosInstance, workspace?: string, pageSize?: number, pageToken?: string) => Promise<WorkspaceListResponse>;
38
+ export declare const listWorkspaces: (api: AxiosInstance, { search, pageSize, pageToken }?: WorkspaceListParams, signal?: AbortSignal) => Promise<WorkspaceListResponse>;
29
39
  //# sourceMappingURL=workspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/api/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAsB,MAAM,OAAO,CAAC;AAG7E,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAA2B,MAAM,mBAAmB,CAAC;AAInG;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAU,KAAK,aAAa,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,SAAS,CAiBtF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAU,KAAK,aAAa,EAAE,YAAY,MAAM,EAAE,WAAW,MAAM,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,qBAAqB,CAqBjJ,CAAC"}
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/api/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAQ1E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GACrB,KAAK,aAAa,EAClB,MAAM,MAAM,EACZ,SAAS,WAAW,KACrB,OAAO,CAAC,SAAS,CAQnB,CAAC;AAEF,mCAAmC;AACnC,MAAM,MAAM,mBAAmB,GAAG;IAC9B,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,GACvB,KAAK,aAAa,EAClB,kCAAiC,mBAAwB,EACzD,SAAS,WAAW,KACrB,OAAO,CAAC,qBAAqB,CAO/B,CAAC"}