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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/README.md +342 -12
  2. package/dist/EveryskApp.d.ts +34 -2
  3. package/dist/EveryskApp.d.ts.map +1 -1
  4. package/dist/EveryskApp.js +35 -2
  5. package/dist/EveryskApp.js.map +1 -1
  6. package/dist/agGrid/handleRowsScrollEnd.d.ts +53 -0
  7. package/dist/agGrid/handleRowsScrollEnd.d.ts.map +1 -0
  8. package/dist/agGrid/handleRowsScrollEnd.js +47 -0
  9. package/dist/agGrid/handleRowsScrollEnd.js.map +1 -0
  10. package/dist/agGrid/index.d.ts +2 -0
  11. package/dist/agGrid/index.d.ts.map +1 -1
  12. package/dist/agGrid/index.js +2 -1
  13. package/dist/api/datastore.d.ts +10 -8
  14. package/dist/api/datastore.d.ts.map +1 -1
  15. package/dist/api/datastore.js +24 -55
  16. package/dist/api/datastore.js.map +1 -1
  17. package/dist/api/entityQuery.d.ts +46 -41
  18. package/dist/api/entityQuery.d.ts.map +1 -1
  19. package/dist/api/entityQuery.js +55 -14
  20. package/dist/api/entityQuery.js.map +1 -1
  21. package/dist/api/file.d.ts +26 -9
  22. package/dist/api/file.d.ts.map +1 -1
  23. package/dist/api/file.js +45 -55
  24. package/dist/api/file.js.map +1 -1
  25. package/dist/api/portfolio.d.ts +11 -8
  26. package/dist/api/portfolio.d.ts.map +1 -1
  27. package/dist/api/portfolio.js +24 -55
  28. package/dist/api/portfolio.js.map +1 -1
  29. package/dist/api/profile.d.ts +3 -2
  30. package/dist/api/profile.d.ts.map +1 -1
  31. package/dist/api/profile.js +4 -9
  32. package/dist/api/profile.js.map +1 -1
  33. package/dist/api/request.d.ts +106 -0
  34. package/dist/api/request.d.ts.map +1 -0
  35. package/dist/api/request.js +132 -0
  36. package/dist/api/request.js.map +1 -0
  37. package/dist/api/websocketsConfig.d.ts +7 -2
  38. package/dist/api/websocketsConfig.d.ts.map +1 -1
  39. package/dist/api/websocketsConfig.js +2 -10
  40. package/dist/api/websocketsConfig.js.map +1 -1
  41. package/dist/api/workflow.d.ts +84 -89
  42. package/dist/api/workflow.d.ts.map +1 -1
  43. package/dist/api/workflow.js +121 -208
  44. package/dist/api/workflow.js.map +1 -1
  45. package/dist/api/workspace.d.ts +18 -8
  46. package/dist/api/workspace.d.ts.map +1 -1
  47. package/dist/api/workspace.js +21 -26
  48. package/dist/api/workspace.js.map +1 -1
  49. package/dist/components/ui/Footer/index.d.ts.map +1 -1
  50. package/dist/components/ui/Footer/index.js.map +1 -1
  51. package/dist/components/ui/GlobalLoading/index.d.ts.map +1 -1
  52. package/dist/components/ui/GlobalLoading/index.js.map +1 -1
  53. package/dist/components/ui/PageContainer/index.d.ts +1 -1
  54. package/dist/components/ui/PageContainer/index.d.ts.map +1 -1
  55. package/dist/components/ui/PageContainer/index.js.map +1 -1
  56. package/dist/components/ui/Toolbar/index.d.ts +40 -3
  57. package/dist/components/ui/Toolbar/index.d.ts.map +1 -1
  58. package/dist/components/ui/Toolbar/index.js +42 -15
  59. package/dist/components/ui/Toolbar/index.js.map +1 -1
  60. package/dist/contexts/appAlertContext/provider.js.map +1 -1
  61. package/dist/contexts/appAlertContext/types.d.ts.map +1 -1
  62. package/dist/contexts/appConfigContext/index.d.ts.map +1 -1
  63. package/dist/contexts/appConfigContext/index.js.map +1 -1
  64. package/dist/contexts/appConfigContext/provider.d.ts.map +1 -1
  65. package/dist/contexts/appConfigContext/provider.js.map +1 -1
  66. package/dist/contexts/webSocketContext/handler.d.ts +3 -2
  67. package/dist/contexts/webSocketContext/handler.d.ts.map +1 -1
  68. package/dist/contexts/webSocketContext/handler.js.map +1 -1
  69. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts +1 -1
  70. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js +1 -1
  71. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js.map +1 -1
  72. package/dist/contexts/webSocketContext/provider.d.ts +6 -3
  73. package/dist/contexts/webSocketContext/provider.d.ts.map +1 -1
  74. package/dist/contexts/webSocketContext/provider.js +42 -7
  75. package/dist/contexts/webSocketContext/provider.js.map +1 -1
  76. package/dist/contexts/webSocketContext/types.d.ts +7 -5
  77. package/dist/contexts/webSocketContext/types.d.ts.map +1 -1
  78. package/dist/file/index.d.ts +2 -0
  79. package/dist/file/index.d.ts.map +1 -1
  80. package/dist/hooks/datastore/useDatastoreMutations.d.ts +4 -4
  81. package/dist/hooks/datastore/useDatastoreMutations.d.ts.map +1 -1
  82. package/dist/hooks/datastore/useDatastoreMutations.js +17 -55
  83. package/dist/hooks/datastore/useDatastoreMutations.js.map +1 -1
  84. package/dist/hooks/datastore/useFetchDatastore.d.ts +30 -41
  85. package/dist/hooks/datastore/useFetchDatastore.d.ts.map +1 -1
  86. package/dist/hooks/datastore/useFetchDatastore.js +25 -59
  87. package/dist/hooks/datastore/useFetchDatastore.js.map +1 -1
  88. package/dist/hooks/datastore/useFetchDatastores.d.ts +47 -52
  89. package/dist/hooks/datastore/useFetchDatastores.d.ts.map +1 -1
  90. package/dist/hooks/datastore/useFetchDatastores.js +55 -70
  91. package/dist/hooks/datastore/useFetchDatastores.js.map +1 -1
  92. package/dist/hooks/file/fileData.d.ts +17 -0
  93. package/dist/hooks/file/fileData.d.ts.map +1 -0
  94. package/dist/hooks/file/fileData.js +10 -0
  95. package/dist/hooks/file/fileData.js.map +1 -0
  96. package/dist/hooks/file/useFetchFile.d.ts +38 -58
  97. package/dist/hooks/file/useFetchFile.d.ts.map +1 -1
  98. package/dist/hooks/file/useFetchFile.js +26 -66
  99. package/dist/hooks/file/useFetchFile.js.map +1 -1
  100. package/dist/hooks/file/useFetchFiles.d.ts +18 -52
  101. package/dist/hooks/file/useFetchFiles.d.ts.map +1 -1
  102. package/dist/hooks/file/useFetchFiles.js +53 -69
  103. package/dist/hooks/file/useFetchFiles.js.map +1 -1
  104. package/dist/hooks/file/useFileMutations.d.ts +9 -8
  105. package/dist/hooks/file/useFileMutations.d.ts.map +1 -1
  106. package/dist/hooks/file/useFileMutations.js +23 -60
  107. package/dist/hooks/file/useFileMutations.js.map +1 -1
  108. package/dist/hooks/portfolio/useFetchPortfolio.d.ts +16 -50
  109. package/dist/hooks/portfolio/useFetchPortfolio.d.ts.map +1 -1
  110. package/dist/hooks/portfolio/useFetchPortfolio.js +15 -63
  111. package/dist/hooks/portfolio/useFetchPortfolio.js.map +1 -1
  112. package/dist/hooks/portfolio/useFetchPortfolios.d.ts +13 -52
  113. package/dist/hooks/portfolio/useFetchPortfolios.d.ts.map +1 -1
  114. package/dist/hooks/portfolio/useFetchPortfolios.js +29 -71
  115. package/dist/hooks/portfolio/useFetchPortfolios.js.map +1 -1
  116. package/dist/hooks/portfolio/usePortfolioMutations.d.ts +8 -8
  117. package/dist/hooks/portfolio/usePortfolioMutations.d.ts.map +1 -1
  118. package/dist/hooks/portfolio/usePortfolioMutations.js +20 -58
  119. package/dist/hooks/portfolio/usePortfolioMutations.js.map +1 -1
  120. package/dist/hooks/profile/useFetchProfile.d.ts +18 -44
  121. package/dist/hooks/profile/useFetchProfile.d.ts.map +1 -1
  122. package/dist/hooks/profile/useFetchProfile.js +16 -48
  123. package/dist/hooks/profile/useFetchProfile.js.map +1 -1
  124. package/dist/hooks/useAxios.js.map +1 -1
  125. package/dist/hooks/useEntityInfiniteQuery.d.ts +88 -0
  126. package/dist/hooks/useEntityInfiniteQuery.d.ts.map +1 -0
  127. package/dist/hooks/useEntityInfiniteQuery.js +111 -0
  128. package/dist/hooks/useEntityInfiniteQuery.js.map +1 -0
  129. package/dist/hooks/useEntityMutation.d.ts +47 -0
  130. package/dist/hooks/useEntityMutation.d.ts.map +1 -0
  131. package/dist/hooks/useEntityMutation.js +58 -0
  132. package/dist/hooks/useEntityMutation.js.map +1 -0
  133. package/dist/hooks/useEntityQuery.d.ts +68 -0
  134. package/dist/hooks/useEntityQuery.d.ts.map +1 -0
  135. package/dist/hooks/useEntityQuery.js +75 -0
  136. package/dist/hooks/useEntityQuery.js.map +1 -0
  137. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts +17 -34
  138. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts.map +1 -1
  139. package/dist/hooks/workflow/useFetchWorkerExecution.js +16 -46
  140. package/dist/hooks/workflow/useFetchWorkerExecution.js.map +1 -1
  141. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts +179 -41
  142. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts.map +1 -1
  143. package/dist/hooks/workflow/useFetchWorkerExecutions.js +29 -62
  144. package/dist/hooks/workflow/useFetchWorkerExecutions.js.map +1 -1
  145. package/dist/hooks/workflow/useFetchWorkflow.d.ts +16 -35
  146. package/dist/hooks/workflow/useFetchWorkflow.d.ts.map +1 -1
  147. package/dist/hooks/workflow/useFetchWorkflow.js +15 -48
  148. package/dist/hooks/workflow/useFetchWorkflow.js.map +1 -1
  149. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts +17 -34
  150. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts.map +1 -1
  151. package/dist/hooks/workflow/useFetchWorkflowExecution.js +16 -46
  152. package/dist/hooks/workflow/useFetchWorkflowExecution.js.map +1 -1
  153. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts +22 -36
  154. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts.map +1 -1
  155. package/dist/hooks/workflow/useFetchWorkflowExecutions.js +43 -56
  156. package/dist/hooks/workflow/useFetchWorkflowExecutions.js.map +1 -1
  157. package/dist/hooks/workflow/useFetchWorkflows.d.ts +20 -37
  158. package/dist/hooks/workflow/useFetchWorkflows.d.ts.map +1 -1
  159. package/dist/hooks/workflow/useFetchWorkflows.js +32 -47
  160. package/dist/hooks/workflow/useFetchWorkflows.js.map +1 -1
  161. package/dist/hooks/workflow/useRunWorkflow.d.ts +21 -16
  162. package/dist/hooks/workflow/useRunWorkflow.d.ts.map +1 -1
  163. package/dist/hooks/workflow/useRunWorkflow.js +66 -29
  164. package/dist/hooks/workflow/useRunWorkflow.js.map +1 -1
  165. package/dist/hooks/workflow/useTriggerWorkflow.d.ts +20 -0
  166. package/dist/hooks/workflow/useTriggerWorkflow.d.ts.map +1 -0
  167. package/dist/hooks/workflow/useTriggerWorkflow.js +32 -0
  168. package/dist/hooks/workflow/useTriggerWorkflow.js.map +1 -0
  169. package/dist/hooks/workspace/useFetchWorkspace.d.ts +19 -34
  170. package/dist/hooks/workspace/useFetchWorkspace.d.ts.map +1 -1
  171. package/dist/hooks/workspace/useFetchWorkspace.js +16 -46
  172. package/dist/hooks/workspace/useFetchWorkspace.js.map +1 -1
  173. package/dist/hooks/workspace/useFetchWorkspaces.d.ts +17 -37
  174. package/dist/hooks/workspace/useFetchWorkspaces.d.ts.map +1 -1
  175. package/dist/hooks/workspace/useFetchWorkspaces.js +25 -47
  176. package/dist/hooks/workspace/useFetchWorkspaces.js.map +1 -1
  177. package/dist/index.d.ts +13 -10
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +13 -11
  180. package/dist/lib/abort.d.ts +58 -0
  181. package/dist/lib/abort.d.ts.map +1 -0
  182. package/dist/lib/abort.js +112 -0
  183. package/dist/lib/abort.js.map +1 -0
  184. package/dist/lib/datastoreTable.d.ts +59 -54
  185. package/dist/lib/datastoreTable.d.ts.map +1 -1
  186. package/dist/lib/datastoreTable.js +58 -62
  187. package/dist/lib/datastoreTable.js.map +1 -1
  188. package/dist/lib/file.d.ts +34 -0
  189. package/dist/lib/file.d.ts.map +1 -0
  190. package/dist/lib/file.js +63 -0
  191. package/dist/lib/file.js.map +1 -0
  192. package/dist/lib/queryClient.d.ts.map +1 -1
  193. package/dist/lib/queryClient.js.map +1 -1
  194. package/dist/lib/workflowRun.d.ts +91 -0
  195. package/dist/lib/workflowRun.d.ts.map +1 -0
  196. package/dist/lib/workflowRun.js +224 -0
  197. package/dist/lib/workflowRun.js.map +1 -0
  198. package/dist/socket/index.d.ts +1 -3
  199. package/dist/socket/index.d.ts.map +1 -1
  200. package/dist/socket/index.js +3 -5
  201. package/dist/test/mocks/index.d.ts +1 -1
  202. package/dist/test/mocks/index.d.ts.map +1 -1
  203. package/dist/test/msw/fakeApi.d.ts +43 -0
  204. package/dist/test/msw/fakeApi.d.ts.map +1 -0
  205. package/dist/test/msw/fakeApi.js +74 -0
  206. package/dist/test/msw/fakeApi.js.map +1 -0
  207. package/dist/test/msw/handlers.d.ts +20 -0
  208. package/dist/test/msw/handlers.d.ts.map +1 -0
  209. package/dist/test/msw/handlers.js +279 -0
  210. package/dist/test/msw/handlers.js.map +1 -0
  211. package/dist/test/msw/index.d.ts +5 -0
  212. package/dist/test/msw/index.d.ts.map +1 -0
  213. package/dist/test/msw/index.js +2 -0
  214. package/dist/test/msw/query.d.ts +34 -0
  215. package/dist/test/msw/query.d.ts.map +1 -0
  216. package/dist/test/msw/query.js +96 -0
  217. package/dist/test/msw/query.js.map +1 -0
  218. package/dist/test/msw/recorder.d.ts +30 -0
  219. package/dist/test/msw/recorder.d.ts.map +1 -0
  220. package/dist/test/msw/recorder.js +65 -0
  221. package/dist/test/msw/recorder.js.map +1 -0
  222. package/dist/test/msw/store.d.ts +57 -0
  223. package/dist/test/msw/store.d.ts.map +1 -0
  224. package/dist/test/msw/store.js +145 -0
  225. package/dist/test/msw/store.js.map +1 -0
  226. package/dist/test/renderWithProviders.d.ts +2 -2
  227. package/dist/test/renderWithProviders.d.ts.map +1 -1
  228. package/dist/test/renderWithProviders.js.map +1 -1
  229. package/dist/test/setup.js.map +1 -1
  230. package/dist/theme/index.d.ts +1 -1
  231. package/dist/theme/index.d.ts.map +1 -1
  232. package/dist/theme/overrides/index.d.ts +4 -2
  233. package/dist/theme/overrides/index.d.ts.map +1 -1
  234. package/dist/theme/overrides/index.js +5 -3
  235. package/dist/theme/overrides/index.js.map +1 -1
  236. package/dist/theme/overrides/muiButton.d.ts +2 -2
  237. package/dist/theme/overrides/muiButton.js.map +1 -1
  238. package/dist/theme/overrides/muiCssBaseline.d.ts.map +1 -1
  239. package/dist/theme/overrides/muiCssBaseline.js.map +1 -1
  240. package/dist/theme/overrides/muiDatePicker.js.map +1 -1
  241. package/dist/theme/overrides/muiFormControl.js.map +1 -1
  242. package/dist/theme/overrides/muiIconButton.d.ts +2 -2
  243. package/dist/theme/overrides/muiIconButton.js.map +1 -1
  244. package/dist/theme/overrides/muiSelect.d.ts.map +1 -1
  245. package/dist/theme/overrides/muiSelect.js.map +1 -1
  246. package/dist/theme/overrides/muiSvgIcon.d.ts.map +1 -1
  247. package/dist/theme/overrides/muiSvgIcon.js.map +1 -1
  248. package/dist/theme/overrides/muiTextField.js.map +1 -1
  249. package/dist/theme/overrides/muiToggleButton.d.ts +2 -2
  250. package/dist/theme/overrides/muiToggleButton.js.map +1 -1
  251. package/dist/theme/overrides/muiToggleButtonGroup.d.ts +2 -2
  252. package/dist/theme/overrides/muiToggleButtonGroup.js.map +1 -1
  253. package/dist/theme/themes/DefaultDark.js +2 -2
  254. package/dist/theme/themes/DefaultDark.js.map +1 -1
  255. package/dist/theme/themes/DefaultLight.js +2 -2
  256. package/dist/theme/themes/DefaultLight.js.map +1 -1
  257. package/dist/theme/themes/EveryskDark.js +2 -2
  258. package/dist/theme/themes/EveryskDark.js.map +1 -1
  259. package/dist/theme/themes/EveryskLight.js +2 -2
  260. package/dist/theme/themes/EveryskLight.js.map +1 -1
  261. package/dist/theme/themes/MidnightEmber.js +2 -2
  262. package/dist/theme/themes/MidnightEmber.js.map +1 -1
  263. package/dist/types/anyRecord.d.ts.map +1 -1
  264. package/dist/types/datastore.d.ts +35 -5
  265. package/dist/types/datastore.d.ts.map +1 -1
  266. package/dist/types/datastoreDataFormat.d.ts +13 -0
  267. package/dist/types/datastoreDataFormat.d.ts.map +1 -0
  268. package/dist/types/entityQuery.d.ts +86 -16
  269. package/dist/types/entityQuery.d.ts.map +1 -1
  270. package/dist/types/file.d.ts +7 -3
  271. package/dist/types/file.d.ts.map +1 -1
  272. package/dist/types/portfolio.d.ts +1 -3
  273. package/dist/types/portfolio.d.ts.map +1 -1
  274. package/dist/types/profile.d.ts +0 -10
  275. package/dist/types/profile.d.ts.map +1 -1
  276. package/dist/types/workflow.d.ts +35 -6
  277. package/dist/types/workflow.d.ts.map +1 -1
  278. package/dist/types/workspace.d.ts +1 -2
  279. package/dist/types/workspace.d.ts.map +1 -1
  280. package/dist/ui/index.d.ts +1 -1
  281. package/dist/ui/index.d.ts.map +1 -1
  282. package/dist/workflow/index.d.ts +2 -0
  283. package/dist/workflow/index.d.ts.map +1 -1
  284. package/package.json +10 -1
  285. package/src/EveryskApp.tsx +53 -2
  286. package/src/agGrid/handleRowsScrollEnd.ts +71 -0
  287. package/src/agGrid/index.ts +5 -1
  288. package/src/api/datastore.ts +79 -107
  289. package/src/api/entityQuery.ts +86 -17
  290. package/src/api/file.ts +110 -103
  291. package/src/api/portfolio.ts +82 -125
  292. package/src/api/profile.ts +25 -18
  293. package/src/api/request.ts +168 -0
  294. package/src/api/websocketsConfig.ts +11 -19
  295. package/src/api/workflow.ts +232 -334
  296. package/src/api/workspace.ts +43 -43
  297. package/src/components/ui/Footer/index.tsx +8 -7
  298. package/src/components/ui/GlobalLoading/index.tsx +13 -3
  299. package/src/components/ui/PageContainer/index.tsx +9 -2
  300. package/src/components/ui/Toolbar/index.tsx +105 -30
  301. package/src/contexts/appAlertContext/provider.tsx +1 -1
  302. package/src/contexts/appAlertContext/types.ts +3 -3
  303. package/src/contexts/appConfigContext/index.tsx +1 -1
  304. package/src/contexts/appConfigContext/provider.tsx +1 -5
  305. package/src/contexts/webSocketContext/handler.ts +8 -2
  306. package/src/contexts/webSocketContext/hooks/useWebSocket/index.ts +1 -1
  307. package/src/contexts/webSocketContext/provider.tsx +64 -14
  308. package/src/contexts/webSocketContext/types.ts +7 -6
  309. package/src/file/index.ts +2 -0
  310. package/src/hooks/datastore/useDatastoreMutations.ts +19 -60
  311. package/src/hooks/datastore/useFetchDatastore.ts +45 -73
  312. package/src/hooks/datastore/useFetchDatastores.ts +106 -131
  313. package/src/hooks/file/fileData.ts +19 -0
  314. package/src/hooks/file/useFetchFile.ts +41 -76
  315. package/src/hooks/file/useFetchFiles.ts +92 -87
  316. package/src/hooks/file/useFileMutations.ts +23 -73
  317. package/src/hooks/portfolio/useFetchPortfolio.ts +26 -78
  318. package/src/hooks/portfolio/useFetchPortfolios.ts +50 -93
  319. package/src/hooks/portfolio/usePortfolioMutations.ts +22 -72
  320. package/src/hooks/profile/useFetchProfile.ts +24 -65
  321. package/src/hooks/useAxios.ts +5 -5
  322. package/src/hooks/useEntityInfiniteQuery.ts +193 -0
  323. package/src/hooks/useEntityMutation.ts +70 -0
  324. package/src/hooks/useEntityQuery.ts +117 -0
  325. package/src/hooks/workflow/useFetchWorkerExecution.ts +27 -56
  326. package/src/hooks/workflow/useFetchWorkerExecutions.ts +54 -79
  327. package/src/hooks/workflow/useFetchWorkflow.ts +24 -58
  328. package/src/hooks/workflow/useFetchWorkflowExecution.ts +27 -57
  329. package/src/hooks/workflow/useFetchWorkflowExecutions.ts +64 -73
  330. package/src/hooks/workflow/useFetchWorkflows.ts +48 -64
  331. package/src/hooks/workflow/useRunWorkflow.ts +82 -36
  332. package/src/hooks/workflow/useTriggerWorkflow.ts +36 -0
  333. package/src/hooks/workspace/useFetchWorkspace.ts +25 -58
  334. package/src/hooks/workspace/useFetchWorkspaces.ts +38 -69
  335. package/src/index.ts +34 -19
  336. package/src/lib/abort.ts +131 -0
  337. package/src/lib/datastoreTable.ts +127 -74
  338. package/src/lib/file.ts +67 -0
  339. package/src/lib/queryClient.ts +11 -13
  340. package/src/lib/workflowRun.ts +329 -0
  341. package/src/socket/index.ts +1 -3
  342. package/src/test/mocks/index.ts +1 -5
  343. package/src/test/msw/fakeApi.ts +83 -0
  344. package/src/test/msw/handlers.ts +350 -0
  345. package/src/test/msw/index.ts +9 -0
  346. package/src/test/msw/query.ts +134 -0
  347. package/src/test/msw/recorder.ts +88 -0
  348. package/src/test/msw/store.ts +182 -0
  349. package/src/test/renderWithProviders.tsx +8 -3
  350. package/src/test/setup.ts +16 -16
  351. package/src/theme/index.ts +1 -1
  352. package/src/theme/overrides/index.ts +5 -3
  353. package/src/theme/overrides/muiButton.ts +3 -3
  354. package/src/theme/overrides/muiCssBaseline.ts +11 -12
  355. package/src/theme/overrides/muiDatePicker.ts +2 -2
  356. package/src/theme/overrides/muiFormControl.ts +2 -2
  357. package/src/theme/overrides/muiIconButton.ts +3 -3
  358. package/src/theme/overrides/muiSelect.ts +2 -2
  359. package/src/theme/overrides/muiSvgIcon.ts +2 -2
  360. package/src/theme/overrides/muiTextField.ts +1 -1
  361. package/src/theme/overrides/muiToggleButton.ts +4 -4
  362. package/src/theme/overrides/muiToggleButtonGroup.ts +4 -4
  363. package/src/theme/themes/DefaultDark.ts +2 -2
  364. package/src/theme/themes/DefaultLight.ts +2 -2
  365. package/src/theme/themes/EveryskDark.ts +2 -2
  366. package/src/theme/themes/EveryskLight.ts +2 -2
  367. package/src/theme/themes/MidnightEmber.ts +15 -15
  368. package/src/types/anyRecord.ts +2 -2
  369. package/src/types/datastore.ts +56 -22
  370. package/src/types/datastoreDataFormat.ts +12 -0
  371. package/src/types/entityQuery.ts +122 -38
  372. package/src/types/file.ts +8 -6
  373. package/src/types/portfolio.ts +70 -74
  374. package/src/types/profile.ts +0 -11
  375. package/src/types/workflow.ts +38 -9
  376. package/src/types/workspace.ts +2 -4
  377. package/src/ui/index.ts +1 -1
  378. package/src/workflow/index.ts +5 -0
@@ -0,0 +1,224 @@
1
+ import { isRetryableFailure } from "../api/request.js";
2
+ import { isTerminalRunStatus } from "../api/workflow.js";
3
+ import { abortable, createDeadline, unlessAborted } from "./abort.js";
4
+ //#region src/lib/workflowRun.ts
5
+ /** The alert a run hook shows when its failure carries no message of its own. */
6
+ var RUN_FAILED_MESSAGE = "Unable to run the workflow. Please try again.";
7
+ /** The events the backend sends when a run's Ender finishes. */
8
+ var RUN_END_EVENTS = ["WORKFLOW_EXECUTION_COMPLETED", "WORKFLOW_EXECUTION_FAILED"];
9
+ var isRunEndEvent = (event) => RUN_END_EVENTS.includes(event.event_type);
10
+ /**
11
+ * The error a run ends with when its caller stopped it — the screen went away, or the app's own
12
+ * signal — with that signal's reason as the cause. One class for both phases, the wait and the
13
+ * result read, so a caller can tell a stop from a failure with `instanceof` rather than by its
14
+ * message.
15
+ */
16
+ var WorkflowRunAbortedError = class extends Error {
17
+ constructor(reason) {
18
+ super("Waiting for the workflow run was aborted", { cause: reason });
19
+ this.name = "WorkflowRunAbortedError";
20
+ }
21
+ };
22
+ /** The longest delay `setTimeout` honours; it fires a longer one after 1 ms. */
23
+ var MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
24
+ /**
25
+ * Throws when a wait option is not a positive number a timer can wait: zero or NaN would read
26
+ * back to back, and above `MAX_TIMER_DELAY_MS` the timer fires at once.
27
+ */
28
+ var requireTimerDelays = (options) => {
29
+ for (const [name, value] of Object.entries(options)) if (!(value > 0 && value <= MAX_TIMER_DELAY_MS)) throw new Error(`[apps-sdk] runWorkflowToEnd: ${name} must be a positive number of milliseconds up to ${MAX_TIMER_DELAY_MS}, got ${value}`);
30
+ };
31
+ /** The triggers kept for later while the loop is busy reading, highest first. */
32
+ var PENDING_PRIORITY = [
33
+ "unavailable",
34
+ "end",
35
+ "reconnect"
36
+ ];
37
+ var socketUnavailableError = () => /* @__PURE__ */ new Error("Real-time notifications are unavailable, so the end of the workflow run cannot be followed. The run itself may still be going on on the server.");
38
+ /**
39
+ * The triggers, handed by the socket listeners to the wait loop one at a time, so the loop reads
40
+ * as a sequence while the listeners stay callbacks.
41
+ *
42
+ * Only one trigger is kept for later while the loop is busy reading, the highest in
43
+ * `PENDING_PRIORITY`; `progress` only restarts the silence, which matters only while the loop
44
+ * waits. `unavailable` outranks everything, since it ends the wait; `end` outranks `reconnect`,
45
+ * since both lead to a read and the end's read is the one that keeps going.
46
+ */
47
+ var createTriggerQueue = (signal) => {
48
+ let pending = null;
49
+ let wake = null;
50
+ const outranks = (trigger) => PENDING_PRIORITY.includes(trigger) && (!pending || PENDING_PRIORITY.indexOf(trigger) < PENDING_PRIORITY.indexOf(pending));
51
+ return {
52
+ push(trigger) {
53
+ if (wake) return wake(trigger);
54
+ if (outranks(trigger)) pending = trigger;
55
+ },
56
+ /** The next trigger, or `silence` when none comes within `silenceMs`. */
57
+ next(silenceMs) {
58
+ if (pending) {
59
+ const trigger = pending;
60
+ pending = null;
61
+ return Promise.resolve(trigger);
62
+ }
63
+ return abortable(signal, (resolve) => {
64
+ const silenceTimer = setTimeout(() => resolve("silence"), silenceMs);
65
+ wake = resolve;
66
+ return () => {
67
+ clearTimeout(silenceTimer);
68
+ wake = null;
69
+ };
70
+ });
71
+ }
72
+ };
73
+ };
74
+ /**
75
+ * Hands `onEvent` the events of one execution. Listening starts at once, and events are kept
76
+ * until `follow` names the execution: a quick run can end before `POST /run` answers. After that,
77
+ * only that execution's events pass — the channel carries every run of the account.
78
+ */
79
+ var listenToRun = (subscribeToEvents, onEvent) => {
80
+ let workflowExecutionId = null;
81
+ const buffered = [];
82
+ const isFollowed = (event) => event.workflow_execution_id === workflowExecutionId;
83
+ return {
84
+ follow(id) {
85
+ workflowExecutionId = id;
86
+ buffered.splice(0).filter(isFollowed).forEach(onEvent);
87
+ },
88
+ stop: subscribeToEvents((event) => {
89
+ if (!workflowExecutionId) buffered.push(event);
90
+ else if (isFollowed(event)) onEvent(event);
91
+ })
92
+ };
93
+ };
94
+ /**
95
+ * Follows the socket's status for the wait, starting from the one the subscription reports at
96
+ * once. It reports the socket coming back (`connected` after any other status) and going: an
97
+ * `error` that lasts `unavailableAfterMs` without a reconnect, counted from the first one, since
98
+ * `connecting` in between only means socket.io is retrying. `isConnected` is false from any other
99
+ * status until the next `connected`; the run is not started before then.
100
+ */
101
+ var watchSocket = (subscribeToStatus, { unavailableAfterMs, onReconnect, onUnavailable }) => {
102
+ let connected = true;
103
+ let graceTimer;
104
+ const endGrace = () => {
105
+ clearTimeout(graceTimer);
106
+ graceTimer = void 0;
107
+ };
108
+ const stopListening = subscribeToStatus((status) => {
109
+ if (status === "error" && graceTimer === void 0) graceTimer = setTimeout(onUnavailable, unavailableAfterMs);
110
+ if (status !== "connected") {
111
+ connected = false;
112
+ return;
113
+ }
114
+ endGrace();
115
+ if (!connected) {
116
+ connected = true;
117
+ onReconnect();
118
+ }
119
+ });
120
+ return {
121
+ isConnected: () => connected,
122
+ stop() {
123
+ endGrace();
124
+ stopListening();
125
+ }
126
+ };
127
+ };
128
+ /**
129
+ * runWorkflowToEnd
130
+ *
131
+ * Starts a workflow run and waits for it to end, listening to the websocket rather than polling;
132
+ * the end itself is read from the API. Resolves with the ended execution, whatever its
133
+ * `run_status` — deciding what counts as success is the caller's.
134
+ *
135
+ * The websocket says *when* to read, never *what* happened. The backend publishes a
136
+ * `WORKER_EXECUTION_*` event per worker and a `WORKFLOW_EXECUTION_COMPLETED|FAILED` one when the
137
+ * Ender finishes, all on the account's channel. That end event goes out before `run_status` is
138
+ * written, and its `COMPLETED` is the Ender's status, not the run's: so it triggers a read, and
139
+ * then more on a short, doubling delay (`confirmIntervalMs`, capped at `silenceMs`) until the run
140
+ * reads ended — no later event would trigger one.
141
+ *
142
+ * Delivery is at most once, with no replay, and the server cuts every socket about once an hour.
143
+ * So the execution is also read after `silenceMs` without any event of the run, and as soon as
144
+ * the socket reconnects. A read that fails in a way that may pass (no response, a 5XX, a 429) does
145
+ * not end the wait — the next trigger reads again — and the last such failure is the cause if the
146
+ * wait times out, until a read succeeds. Any other failure ends it at once: a 4XX, or anything
147
+ * that is not a request failure, such as a body that is not the expected JSON.
148
+ *
149
+ * The run's end cannot be followed without the socket, so a socket in `error` for
150
+ * `unavailableAfterMs` — its config failed, or the server dropped it — fails the wait. The run is
151
+ * held back until the socket is connected, so it is never started unfollowable, and nothing it
152
+ * publishes goes out before the wait is listening.
153
+ *
154
+ * A timeout or an abort stops everything at once through one signal: the wait, the pause between
155
+ * reads, and the read in flight, whose request is cancelled. The start request is abandoned
156
+ * rather than cancelled — `startRun` takes no signal — so the run may still begin on the server.
157
+ *
158
+ * @param params - The start and read calls, the websocket subscriptions and the wait options.
159
+ * @returns The execution, once its `run_status` is terminal.
160
+ * @throws {Error} If a wait option is not a positive number, the run cannot be started or has no
161
+ * execution id, a read fails for good, the socket stays unavailable for `unavailableAfterMs`, or
162
+ * the wait times out or is aborted (`WorkflowRunAbortedError`, with the signal's reason as the cause).
163
+ */
164
+ var runWorkflowToEnd = async ({ startRun, getExecution, subscribeToEvents, subscribeToStatus, silenceMs = 6e4, timeoutMs = 3e5, confirmIntervalMs = 1e3, unavailableAfterMs = 3e4, signal }) => {
165
+ requireTimerDelays({
166
+ silenceMs,
167
+ timeoutMs,
168
+ confirmIntervalMs,
169
+ unavailableAfterMs
170
+ });
171
+ let lastError;
172
+ const deadline = createDeadline({
173
+ timeoutMs,
174
+ signal,
175
+ timeoutError: () => new Error("Timed out while waiting for the workflow run to end", { cause: lastError }),
176
+ abortError: () => new WorkflowRunAbortedError(signal?.reason)
177
+ });
178
+ const waitSignal = deadline.signal;
179
+ const triggers = createTriggerQueue(waitSignal);
180
+ const runEvents = listenToRun(subscribeToEvents, (event) => triggers.push(isRunEndEvent(event) ? "end" : "progress"));
181
+ const connection = watchSocket(subscribeToStatus, {
182
+ unavailableAfterMs,
183
+ onReconnect: () => triggers.push("reconnect"),
184
+ onUnavailable: () => triggers.push("unavailable")
185
+ });
186
+ /** Reads the execution once; `null` while the run has not ended. */
187
+ const readIfEnded = async (id) => {
188
+ try {
189
+ const execution = await unlessAborted(getExecution(id, waitSignal), waitSignal);
190
+ lastError = void 0;
191
+ return isTerminalRunStatus(execution.run_status) ? execution : null;
192
+ } catch (error) {
193
+ if (waitSignal.aborted) throw waitSignal.reason;
194
+ if (!isRetryableFailure(error)) throw error;
195
+ lastError = error;
196
+ return null;
197
+ }
198
+ };
199
+ try {
200
+ if (waitSignal.aborted) throw waitSignal.reason;
201
+ while (!connection.isConnected()) if (await triggers.next(silenceMs) === "unavailable") throw socketUnavailableError();
202
+ const id = (await unlessAborted(startRun(), waitSignal))?.id;
203
+ if (!id) throw new Error("Workflow run did not return an execution id");
204
+ runEvents.follow(id);
205
+ let confirmDelay;
206
+ for (;;) {
207
+ const trigger = await triggers.next(confirmDelay ?? silenceMs);
208
+ if (trigger === "unavailable") throw socketUnavailableError();
209
+ if (trigger === "progress") continue;
210
+ if (trigger === "end") confirmDelay = confirmIntervalMs;
211
+ else if (trigger === "silence" && confirmDelay !== void 0) confirmDelay = Math.min(confirmDelay * 2, silenceMs);
212
+ const ended = await readIfEnded(id);
213
+ if (ended) return ended;
214
+ }
215
+ } finally {
216
+ deadline.dispose();
217
+ runEvents.stop();
218
+ connection.stop();
219
+ }
220
+ };
221
+ //#endregion
222
+ export { RUN_FAILED_MESSAGE, WorkflowRunAbortedError, runWorkflowToEnd };
223
+
224
+ //# sourceMappingURL=workflowRun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflowRun.js","names":[],"sources":["../../src/lib/workflowRun.ts"],"sourcesContent":["import { isRetryableFailure } from \"@/api/request\";\nimport { isTerminalRunStatus } from \"@/api/workflow\";\nimport { abortable, createDeadline, unlessAborted } from \"@/lib/abort\";\nimport type { WebSocketNotification, WebSocketStatus } from \"@/contexts/webSocketContext/types\";\nimport type { WorkflowExecution } from \"@/types/workflow\";\n\n/** The alert a run hook shows when its failure carries no message of its own. */\nexport const RUN_FAILED_MESSAGE = \"Unable to run the workflow. Please try again.\";\n\n/** The events the backend sends when a run's Ender finishes. */\nconst RUN_END_EVENTS: readonly string[] = [\n \"WORKFLOW_EXECUTION_COMPLETED\",\n \"WORKFLOW_EXECUTION_FAILED\",\n];\n\nconst isRunEndEvent = (event: WebSocketNotification) => RUN_END_EVENTS.includes(event.event_type);\n\n/**\n * The error a run ends with when its caller stopped it — the screen went away, or the app's own\n * signal — with that signal's reason as the cause. One class for both phases, the wait and the\n * result read, so a caller can tell a stop from a failure with `instanceof` rather than by its\n * message.\n */\nexport class WorkflowRunAbortedError extends Error {\n constructor(reason: unknown) {\n super(\"Waiting for the workflow run was aborted\", { cause: reason });\n this.name = \"WorkflowRunAbortedError\";\n }\n}\n\n/** The longest delay `setTimeout` honours; it fires a longer one after 1 ms. */\nconst MAX_TIMER_DELAY_MS = 2 ** 31 - 1;\n\n/**\n * Throws when a wait option is not a positive number a timer can wait: zero or NaN would read\n * back to back, and above `MAX_TIMER_DELAY_MS` the timer fires at once.\n */\nconst requireTimerDelays = (options: Record<string, number>) => {\n for (const [name, value] of Object.entries(options)) {\n if (!(value > 0 && value <= MAX_TIMER_DELAY_MS)) {\n throw new Error(\n `[apps-sdk] runWorkflowToEnd: ${name} must be a positive number of milliseconds up to ${MAX_TIMER_DELAY_MS}, got ${value}`,\n );\n }\n }\n};\n\nexport type WorkflowWaitOptions = {\n /**\n * How long the run may go without any event before the execution is read anyway, in\n * milliseconds. Defaults to a minute. It covers a lost event, and a long worker, which sends\n * nothing while it runs.\n */\n silenceMs?: number;\n /** How long to wait for the run to end before giving up, in milliseconds. Defaults to 5 minutes. */\n timeoutMs?: number;\n /**\n * The first gap between reads after the end event, while the run still reads RUNNING, in\n * milliseconds. It doubles each time it passes without a new event, up to `silenceMs`.\n * Defaults to 1 second.\n */\n confirmIntervalMs?: number;\n /**\n * How long the socket may stay in `error` before the run is given up on as unfollowable, in\n * milliseconds. Defaults to 30 seconds: socket.io keeps retrying after a failed reconnect, on\n * a backoff that alone can reach about 7.5 seconds between attempts.\n */\n unavailableAfterMs?: number;\n /** Stops waiting. `useRunWorkflow` also stops when its screen unmounts. */\n signal?: AbortSignal;\n};\n\nexport type RunWorkflowToEndParams = WorkflowWaitOptions & {\n /** Starts the run (`POST /workflows/:id/run`) and returns the execution it created. */\n startRun: () => Promise<WorkflowExecution>;\n /**\n * Reads the execution; its `run_status` is what says the run ended, and how. Pass `signal` to\n * the request, so a timeout or an abort cancels a read in flight.\n */\n getExecution: (workflowExecutionId: string, signal: AbortSignal) => Promise<WorkflowExecution>;\n /** The websocket context's `subscribe`. */\n subscribeToEvents: (listener: (event: WebSocketNotification) => void) => () => void;\n /**\n * The websocket context's `subscribeStatus`, which tells a new listener the current status at\n * once: that is how the wait learns the status it begins in.\n */\n subscribeToStatus: (listener: (status: WebSocketStatus) => void) => () => void;\n};\n\n/**\n * What wakes the wait up: an event of the run (`progress`, or `end` for the Ender's), the socket\n * coming back (`reconnect`) or going (`unavailable`), or nothing at all for `silenceMs` (`silence`).\n */\ntype Trigger = \"progress\" | \"end\" | \"reconnect\" | \"unavailable\" | \"silence\";\n\n/** The triggers kept for later while the loop is busy reading, highest first. */\nconst PENDING_PRIORITY: Trigger[] = [\"unavailable\", \"end\", \"reconnect\"];\n\nconst socketUnavailableError = () =>\n new Error(\n \"Real-time notifications are unavailable, so the end of the workflow run cannot be followed. \" +\n \"The run itself may still be going on on the server.\",\n );\n\n/**\n * The triggers, handed by the socket listeners to the wait loop one at a time, so the loop reads\n * as a sequence while the listeners stay callbacks.\n *\n * Only one trigger is kept for later while the loop is busy reading, the highest in\n * `PENDING_PRIORITY`; `progress` only restarts the silence, which matters only while the loop\n * waits. `unavailable` outranks everything, since it ends the wait; `end` outranks `reconnect`,\n * since both lead to a read and the end's read is the one that keeps going.\n */\nconst createTriggerQueue = (signal: AbortSignal) => {\n let pending: Trigger | null = null;\n let wake: ((trigger: Trigger) => void) | null = null;\n const outranks = (trigger: Trigger) =>\n PENDING_PRIORITY.includes(trigger) &&\n (!pending || PENDING_PRIORITY.indexOf(trigger) < PENDING_PRIORITY.indexOf(pending));\n\n return {\n push(trigger: Trigger) {\n if (wake) return wake(trigger);\n if (outranks(trigger)) pending = trigger;\n },\n /** The next trigger, or `silence` when none comes within `silenceMs`. */\n next(silenceMs: number): Promise<Trigger> {\n if (pending) {\n const trigger = pending;\n pending = null;\n return Promise.resolve(trigger);\n }\n return abortable<Trigger>(signal, (resolve) => {\n const silenceTimer = setTimeout(() => resolve(\"silence\"), silenceMs);\n wake = resolve;\n return () => {\n clearTimeout(silenceTimer);\n wake = null;\n };\n });\n },\n };\n};\n\n/**\n * Hands `onEvent` the events of one execution. Listening starts at once, and events are kept\n * until `follow` names the execution: a quick run can end before `POST /run` answers. After that,\n * only that execution's events pass — the channel carries every run of the account.\n */\nconst listenToRun = (\n subscribeToEvents: RunWorkflowToEndParams[\"subscribeToEvents\"],\n onEvent: (event: WebSocketNotification) => void,\n) => {\n let workflowExecutionId: string | null = null;\n const buffered: WebSocketNotification[] = [];\n const isFollowed = (event: WebSocketNotification) =>\n event.workflow_execution_id === workflowExecutionId;\n\n const stop = subscribeToEvents((event) => {\n if (!workflowExecutionId) buffered.push(event);\n else if (isFollowed(event)) onEvent(event);\n });\n\n return {\n follow(id: string) {\n workflowExecutionId = id;\n buffered.splice(0).filter(isFollowed).forEach(onEvent);\n },\n stop,\n };\n};\n\n/**\n * Follows the socket's status for the wait, starting from the one the subscription reports at\n * once. It reports the socket coming back (`connected` after any other status) and going: an\n * `error` that lasts `unavailableAfterMs` without a reconnect, counted from the first one, since\n * `connecting` in between only means socket.io is retrying. `isConnected` is false from any other\n * status until the next `connected`; the run is not started before then.\n */\nconst watchSocket = (\n subscribeToStatus: RunWorkflowToEndParams[\"subscribeToStatus\"],\n {\n unavailableAfterMs,\n onReconnect,\n onUnavailable,\n }: { unavailableAfterMs: number; onReconnect: () => void; onUnavailable: () => void },\n) => {\n let connected = true;\n let graceTimer: ReturnType<typeof setTimeout> | undefined;\n const endGrace = () => {\n clearTimeout(graceTimer);\n graceTimer = undefined;\n };\n\n const stopListening = subscribeToStatus((status) => {\n if (status === \"error\" && graceTimer === undefined)\n graceTimer = setTimeout(onUnavailable, unavailableAfterMs);\n if (status !== \"connected\") {\n connected = false;\n return;\n }\n endGrace();\n if (!connected) {\n connected = true;\n onReconnect();\n }\n });\n\n return {\n isConnected: () => connected,\n stop() {\n endGrace();\n stopListening();\n },\n };\n};\n\n/**\n * runWorkflowToEnd\n *\n * Starts a workflow run and waits for it to end, listening to the websocket rather than polling;\n * the end itself is read from the API. Resolves with the ended execution, whatever its\n * `run_status` — deciding what counts as success is the caller's.\n *\n * The websocket says *when* to read, never *what* happened. The backend publishes a\n * `WORKER_EXECUTION_*` event per worker and a `WORKFLOW_EXECUTION_COMPLETED|FAILED` one when the\n * Ender finishes, all on the account's channel. That end event goes out before `run_status` is\n * written, and its `COMPLETED` is the Ender's status, not the run's: so it triggers a read, and\n * then more on a short, doubling delay (`confirmIntervalMs`, capped at `silenceMs`) until the run\n * reads ended — no later event would trigger one.\n *\n * Delivery is at most once, with no replay, and the server cuts every socket about once an hour.\n * So the execution is also read after `silenceMs` without any event of the run, and as soon as\n * the socket reconnects. A read that fails in a way that may pass (no response, a 5XX, a 429) does\n * not end the wait — the next trigger reads again — and the last such failure is the cause if the\n * wait times out, until a read succeeds. Any other failure ends it at once: a 4XX, or anything\n * that is not a request failure, such as a body that is not the expected JSON.\n *\n * The run's end cannot be followed without the socket, so a socket in `error` for\n * `unavailableAfterMs` — its config failed, or the server dropped it — fails the wait. The run is\n * held back until the socket is connected, so it is never started unfollowable, and nothing it\n * publishes goes out before the wait is listening.\n *\n * A timeout or an abort stops everything at once through one signal: the wait, the pause between\n * reads, and the read in flight, whose request is cancelled. The start request is abandoned\n * rather than cancelled — `startRun` takes no signal — so the run may still begin on the server.\n *\n * @param params - The start and read calls, the websocket subscriptions and the wait options.\n * @returns The execution, once its `run_status` is terminal.\n * @throws {Error} If a wait option is not a positive number, the run cannot be started or has no\n * execution id, a read fails for good, the socket stays unavailable for `unavailableAfterMs`, or\n * the wait times out or is aborted (`WorkflowRunAbortedError`, with the signal's reason as the cause).\n */\nexport const runWorkflowToEnd = async ({\n startRun,\n getExecution,\n subscribeToEvents,\n subscribeToStatus,\n silenceMs = 60_000,\n timeoutMs = 5 * 60_000,\n confirmIntervalMs = 1_000,\n unavailableAfterMs = 30_000,\n signal,\n}: RunWorkflowToEndParams): Promise<WorkflowExecution> => {\n requireTimerDelays({ silenceMs, timeoutMs, confirmIntervalMs, unavailableAfterMs });\n\n let lastError: unknown;\n const deadline = createDeadline({\n timeoutMs,\n signal,\n timeoutError: () =>\n new Error(\"Timed out while waiting for the workflow run to end\", { cause: lastError }),\n abortError: () => new WorkflowRunAbortedError(signal?.reason),\n });\n const waitSignal = deadline.signal;\n\n const triggers = createTriggerQueue(waitSignal);\n const runEvents = listenToRun(subscribeToEvents, (event) =>\n triggers.push(isRunEndEvent(event) ? \"end\" : \"progress\"),\n );\n const connection = watchSocket(subscribeToStatus, {\n unavailableAfterMs,\n onReconnect: () => triggers.push(\"reconnect\"),\n onUnavailable: () => triggers.push(\"unavailable\"),\n });\n\n /** Reads the execution once; `null` while the run has not ended. */\n const readIfEnded = async (id: string) => {\n try {\n const execution = await unlessAborted(getExecution(id, waitSignal), waitSignal);\n lastError = undefined;\n return isTerminalRunStatus(execution.run_status) ? execution : null;\n } catch (error) {\n if (waitSignal.aborted) throw waitSignal.reason;\n if (!isRetryableFailure(error)) throw error;\n lastError = error;\n return null;\n }\n };\n\n try {\n if (waitSignal.aborted) throw waitSignal.reason;\n while (!connection.isConnected()) {\n if ((await triggers.next(silenceMs)) === \"unavailable\") throw socketUnavailableError();\n }\n\n const id = (await unlessAborted(startRun(), waitSignal))?.id;\n if (!id) throw new Error(\"Workflow run did not return an execution id\");\n runEvents.follow(id);\n\n let confirmDelay: number | undefined;\n for (;;) {\n const trigger = await triggers.next(confirmDelay ?? silenceMs);\n if (trigger === \"unavailable\") throw socketUnavailableError();\n if (trigger === \"progress\") continue;\n\n if (trigger === \"end\") confirmDelay = confirmIntervalMs;\n else if (trigger === \"silence\" && confirmDelay !== undefined)\n confirmDelay = Math.min(confirmDelay * 2, silenceMs);\n\n const ended = await readIfEnded(id);\n if (ended) return ended;\n }\n } finally {\n deadline.dispose();\n runEvents.stop();\n connection.stop();\n }\n};\n"],"mappings":"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"}
@@ -1,10 +1,8 @@
1
1
  export * from "../contexts/webSocketContext/index.js";
2
2
  export * from "../contexts/webSocketContext/provider.js";
3
3
  export * from "../contexts/webSocketContext/types.d.ts";
4
- export * from "../contexts/webSocketContext/constants.js";
5
- export * from "../contexts/webSocketContext/handler.js";
4
+ export { APP_NOTIFICATION_EVENT_TYPE } from "../contexts/webSocketContext/constants.js";
6
5
  export * from "../contexts/webSocketContext/hooks/useWebSocket/index.js";
7
6
  export * from "../contexts/webSocketContext/hooks/useWebSocketSubscription/index.js";
8
7
  export * from "../contexts/webSocketContext/hooks/useAppNotificationSubscription/index.js";
9
- export * from "../api/websocketsConfig.js";
10
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/socket/index.ts"],"names":[],"mappings":"AAUA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4DAA4D,CAAC;AAC3E,cAAc,kEAAkE,CAAC;AACjF,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/socket/index.ts"],"names":[],"mappings":"AAUA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4DAA4D,CAAC;AAC3E,cAAc,kEAAkE,CAAC"}
@@ -1,9 +1,7 @@
1
1
  import { WebSocketContext } from "../contexts/webSocketContext/index.js";
2
- import { getWebsocketsConfig } from "../api/websocketsConfig.js";
3
- import { APP_NOTIFICATION_EVENT_TYPE, JOIN_EVENT, NOTIFICATION_EVENT } from "../contexts/webSocketContext/constants.js";
4
- import { WebSocketHandler } from "../contexts/webSocketContext/handler.js";
5
- import { WebSocketProvider } from "../contexts/webSocketContext/provider.js";
6
2
  import { useWebSocket } from "../contexts/webSocketContext/hooks/useWebSocket/index.js";
3
+ import { APP_NOTIFICATION_EVENT_TYPE } from "../contexts/webSocketContext/constants.js";
4
+ import { WebSocketProvider } from "../contexts/webSocketContext/provider.js";
7
5
  import { useWebSocketSubscription } from "../contexts/webSocketContext/hooks/useWebSocketSubscription/index.js";
8
6
  import { useAppNotificationSubscription } from "../contexts/webSocketContext/hooks/useAppNotificationSubscription/index.js";
9
- export { APP_NOTIFICATION_EVENT_TYPE, JOIN_EVENT, NOTIFICATION_EVENT, WebSocketContext, WebSocketHandler, WebSocketProvider, getWebsocketsConfig, useAppNotificationSubscription, useWebSocket, useWebSocketSubscription };
7
+ export { APP_NOTIFICATION_EVENT_TYPE, WebSocketContext, WebSocketProvider, useAppNotificationSubscription, useWebSocket, useWebSocketSubscription };
@@ -1,5 +1,5 @@
1
1
  export { agGridReactMock } from "./agGridReact";
2
- export { agGridEnterpriseMock, getAgGridLicenseKey, resetAgGridLicense, } from "./agGridEnterprise";
2
+ export { agGridEnterpriseMock, getAgGridLicenseKey, resetAgGridLicense } from "./agGridEnterprise";
3
3
  export { socketIoClientMock, createMockSocket, getMockSocket, resetMockSocket, } from "./socketIoClient";
4
4
  export type { MockSocket, SocketEventHandler } from "./socketIoClient";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test/mocks/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,eAAe,GAClB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test/mocks/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnG,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,eAAe,GAClB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { type SetupServer } from "msw/node";
2
+ import { type RecordedRequest } from "./recorder";
3
+ import { type FakeApiSeed, type FakeApiStore } from "./store";
4
+ export type FakeApi = {
5
+ store: FakeApiStore;
6
+ requests: RecordedRequest[];
7
+ /** Replaces what the store holds. */
8
+ seed: (data: FakeApiSeed) => void;
9
+ /** Answers the next matching request with the API's error body, once. */
10
+ fail: (method: string, path: string, status: number, message?: string) => void;
11
+ /** The MSW server, for a handler of an app's own (`api.server.use(...)`). */
12
+ server: SetupServer;
13
+ };
14
+ /**
15
+ * setupFakeApi — a fake of the API behind the app's `/api`, for tests that render pages with
16
+ * the SDK's real hooks.
17
+ *
18
+ * The hooks, their axios instance and the query cache run for real; MSW answers the requests
19
+ * they send from an in-memory store, the way the API would. A test seeds data, renders, and
20
+ * asserts on what the page shows and on `requests`, what it sent. Nothing ties a test to the
21
+ * SDK's files: mocking its modules by path did, and could not reach its hooks at all once the
22
+ * SDK was a package.
23
+ *
24
+ * Every request an SDK hook sends is answered: datastores, files and portfolios (listed by
25
+ * JSON query), workflows and workspaces (by text search), workflow and worker executions, a
26
+ * workflow run, the profile and the websocket config. `useRunWorkflow` waits for a run's end
27
+ * over the websocket, which this does not fake; pair it with the socket double in
28
+ * `@everysk/apps-sdk/test/mocks`.
29
+ *
30
+ * Call it once at the top of a test file. It registers its own `beforeAll`, `afterEach` and
31
+ * `afterAll`: the server listens for the file, and the store, the recorded requests and any
32
+ * pending failure are cleared after every test. A request no handler answers fails the test,
33
+ * so a page that calls an endpoint the fake does not have says so instead of hanging.
34
+ *
35
+ * The behaviour follows the API as `CLAUDE.md` records it (Platform facts): a JSON query's
36
+ * filters, order, projection and page (20 by default, the URL's `page_size` and `page_token`
37
+ * winning), a text search's id, `#tag`, `&link_uid` or name prefix (10 a page), a create
38
+ * defaulting the workspace to `main`, a delete answering with one object, a run answering 202
39
+ * with a RUNNING execution, worker executions grouped and unpaginated, and errors as
40
+ * `{ code, message }`.
41
+ */
42
+ export declare const setupFakeApi: () => FakeApi;
43
+ //# sourceMappingURL=fakeApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fakeApi.d.ts","sourceRoot":"","sources":["../../../src/test/msw/fakeApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAyB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAErF,MAAM,MAAM,OAAO,GAAG;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,qCAAqC;IACrC,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAClC,yEAAyE;IACzE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/E,6EAA6E;IAC7E,MAAM,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,YAAY,QAAO,OAoC/B,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { recordRequests } from "./recorder.js";
2
+ import { emptyStore, storeFrom } from "./store.js";
3
+ import { fakeApiHandlers } from "./handlers.js";
4
+ import { afterAll, afterEach, beforeAll } from "vitest";
5
+ import { setupServer } from "msw/node";
6
+ //#region src/test/msw/fakeApi.ts
7
+ /**
8
+ * setupFakeApi — a fake of the API behind the app's `/api`, for tests that render pages with
9
+ * the SDK's real hooks.
10
+ *
11
+ * The hooks, their axios instance and the query cache run for real; MSW answers the requests
12
+ * they send from an in-memory store, the way the API would. A test seeds data, renders, and
13
+ * asserts on what the page shows and on `requests`, what it sent. Nothing ties a test to the
14
+ * SDK's files: mocking its modules by path did, and could not reach its hooks at all once the
15
+ * SDK was a package.
16
+ *
17
+ * Every request an SDK hook sends is answered: datastores, files and portfolios (listed by
18
+ * JSON query), workflows and workspaces (by text search), workflow and worker executions, a
19
+ * workflow run, the profile and the websocket config. `useRunWorkflow` waits for a run's end
20
+ * over the websocket, which this does not fake; pair it with the socket double in
21
+ * `@everysk/apps-sdk/test/mocks`.
22
+ *
23
+ * Call it once at the top of a test file. It registers its own `beforeAll`, `afterEach` and
24
+ * `afterAll`: the server listens for the file, and the store, the recorded requests and any
25
+ * pending failure are cleared after every test. A request no handler answers fails the test,
26
+ * so a page that calls an endpoint the fake does not have says so instead of hanging.
27
+ *
28
+ * The behaviour follows the API as `CLAUDE.md` records it (Platform facts): a JSON query's
29
+ * filters, order, projection and page (20 by default, the URL's `page_size` and `page_token`
30
+ * winning), a text search's id, `#tag`, `&link_uid` or name prefix (10 a page), a create
31
+ * defaulting the workspace to `main`, a delete answering with one object, a run answering 202
32
+ * with a RUNNING execution, worker executions grouped and unpaginated, and errors as
33
+ * `{ code, message }`.
34
+ */
35
+ var setupFakeApi = () => {
36
+ let failures = [];
37
+ const api = {
38
+ store: emptyStore(),
39
+ requests: [],
40
+ seed: (data) => {
41
+ api.store = storeFrom(data);
42
+ },
43
+ fail: (method, path, status, message = `Request failed with status ${status}`) => {
44
+ failures.push({
45
+ method: method.toUpperCase(),
46
+ path,
47
+ status,
48
+ message
49
+ });
50
+ },
51
+ server: setupServer(...fakeApiHandlers({
52
+ store: () => api.store,
53
+ takeFailure: (method, path) => {
54
+ const failure = failures.find((f) => f.method === method && f.path === path);
55
+ failures = failures.filter((f) => f !== failure);
56
+ return failure;
57
+ }
58
+ }))
59
+ };
60
+ recordRequests(api.server, () => api.requests);
61
+ beforeAll(() => api.server.listen({ onUnhandledRequest: "error" }));
62
+ afterEach(() => {
63
+ api.server.resetHandlers();
64
+ api.store = emptyStore();
65
+ api.requests = [];
66
+ failures = [];
67
+ });
68
+ afterAll(() => api.server.close());
69
+ return api;
70
+ };
71
+ //#endregion
72
+ export { setupFakeApi };
73
+
74
+ //# sourceMappingURL=fakeApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fakeApi.js","names":[],"sources":["../../../src/test/msw/fakeApi.ts"],"sourcesContent":["import { afterAll, afterEach, beforeAll } from \"vitest\";\nimport { setupServer, type SetupServer } from \"msw/node\";\n\nimport { fakeApiHandlers, type Failure } from \"./handlers\";\nimport { recordRequests, type RecordedRequest } from \"./recorder\";\nimport { emptyStore, storeFrom, type FakeApiSeed, type FakeApiStore } from \"./store\";\n\nexport type FakeApi = {\n store: FakeApiStore;\n requests: RecordedRequest[];\n /** Replaces what the store holds. */\n seed: (data: FakeApiSeed) => void;\n /** Answers the next matching request with the API's error body, once. */\n fail: (method: string, path: string, status: number, message?: string) => void;\n /** The MSW server, for a handler of an app's own (`api.server.use(...)`). */\n server: SetupServer;\n};\n\n/**\n * setupFakeApi — a fake of the API behind the app's `/api`, for tests that render pages with\n * the SDK's real hooks.\n *\n * The hooks, their axios instance and the query cache run for real; MSW answers the requests\n * they send from an in-memory store, the way the API would. A test seeds data, renders, and\n * asserts on what the page shows and on `requests`, what it sent. Nothing ties a test to the\n * SDK's files: mocking its modules by path did, and could not reach its hooks at all once the\n * SDK was a package.\n *\n * Every request an SDK hook sends is answered: datastores, files and portfolios (listed by\n * JSON query), workflows and workspaces (by text search), workflow and worker executions, a\n * workflow run, the profile and the websocket config. `useRunWorkflow` waits for a run's end\n * over the websocket, which this does not fake; pair it with the socket double in\n * `@everysk/apps-sdk/test/mocks`.\n *\n * Call it once at the top of a test file. It registers its own `beforeAll`, `afterEach` and\n * `afterAll`: the server listens for the file, and the store, the recorded requests and any\n * pending failure are cleared after every test. A request no handler answers fails the test,\n * so a page that calls an endpoint the fake does not have says so instead of hanging.\n *\n * The behaviour follows the API as `CLAUDE.md` records it (Platform facts): a JSON query's\n * filters, order, projection and page (20 by default, the URL's `page_size` and `page_token`\n * winning), a text search's id, `#tag`, `&link_uid` or name prefix (10 a page), a create\n * defaulting the workspace to `main`, a delete answering with one object, a run answering 202\n * with a RUNNING execution, worker executions grouped and unpaginated, and errors as\n * `{ code, message }`.\n */\nexport const setupFakeApi = (): FakeApi => {\n let failures: Failure[] = [];\n\n const api: FakeApi = {\n store: emptyStore(),\n requests: [],\n seed: (data) => {\n api.store = storeFrom(data);\n },\n fail: (method, path, status, message = `Request failed with status ${status}`) => {\n failures.push({ method: method.toUpperCase(), path, status, message });\n },\n server: setupServer(\n ...fakeApiHandlers({\n store: () => api.store,\n takeFailure: (method, path) => {\n const failure = failures.find((f) => f.method === method && f.path === path);\n failures = failures.filter((f) => f !== failure);\n return failure;\n },\n }),\n ),\n };\n\n recordRequests(api.server, () => api.requests);\n\n beforeAll(() => api.server.listen({ onUnhandledRequest: \"error\" }));\n afterEach(() => {\n api.server.resetHandlers();\n api.store = emptyStore();\n api.requests = [];\n failures = [];\n });\n afterAll(() => api.server.close());\n\n return api;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAa,qBAA8B;CACvC,IAAI,WAAsB,CAAC;CAE3B,MAAM,MAAe;EACjB,OAAO,WAAW;EAClB,UAAU,CAAC;EACX,OAAO,SAAS;GACZ,IAAI,QAAQ,UAAU,IAAI;EAC9B;EACA,OAAO,QAAQ,MAAM,QAAQ,UAAU,8BAA8B,aAAa;GAC9E,SAAS,KAAK;IAAE,QAAQ,OAAO,YAAY;IAAG;IAAM;IAAQ;GAAQ,CAAC;EACzE;EACA,QAAQ,YACJ,GAAG,gBAAgB;GACf,aAAa,IAAI;GACjB,cAAc,QAAQ,SAAS;IAC3B,MAAM,UAAU,SAAS,MAAM,MAAM,EAAE,WAAW,UAAU,EAAE,SAAS,IAAI;IAC3E,WAAW,SAAS,QAAQ,MAAM,MAAM,OAAO;IAC/C,OAAO;GACX;EACJ,CAAC,CACL;CACJ;CAEA,eAAe,IAAI,cAAc,IAAI,QAAQ;CAE7C,gBAAgB,IAAI,OAAO,OAAO,EAAE,oBAAoB,QAAQ,CAAC,CAAC;CAClE,gBAAgB;EACZ,IAAI,OAAO,cAAc;EACzB,IAAI,QAAQ,WAAW;EACvB,IAAI,WAAW,CAAC;EAChB,WAAW,CAAC;CAChB,CAAC;CACD,eAAe,IAAI,OAAO,MAAM,CAAC;CAEjC,OAAO;AACX"}
@@ -0,0 +1,20 @@
1
+ import { type HttpHandler } from "msw";
2
+ import { type FakeApiStore } from "./store";
3
+ export type Failure = {
4
+ method: string;
5
+ path: string;
6
+ status: number;
7
+ message: string;
8
+ };
9
+ /** What the handlers read and write: the store, and the failures queued. */
10
+ export type FakeState = {
11
+ store: () => FakeApiStore;
12
+ takeFailure: (method: string, path: string) => Failure | undefined;
13
+ };
14
+ export declare const errorBody: (status: number, message: string) => {
15
+ code: number;
16
+ message: string;
17
+ };
18
+ /** Every route the SDK's request functions call. */
19
+ export declare const fakeApiHandlers: (state: FakeState) => HttpHandler[];
20
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/test/msw/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,WAAW,EAAqB,MAAM,KAAK,CAAC;AAO9E,OAAO,EAA+B,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzE,MAAM,MAAM,OAAO,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExF,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GAAG;IACpB,KAAK,EAAE,MAAM,YAAY,CAAC;IAC1B,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,SAAS,CAAC;CACtE,CAAC;AASF,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM;;;CAAgC,CAAC;AAoS1F,oDAAoD;AACpD,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,KAAG,WAAW,EAgC7D,CAAC"}