@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 @@
1
+ {"version":3,"file":"useEntityInfiniteQuery.js","names":[],"sources":["../../src/hooks/useEntityInfiniteQuery.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useInfiniteQuery, type QueryKey } from \"@tanstack/react-query\";\n\nimport type {\n PagedResponse,\n EntityInfiniteQueryOptions,\n ListCache,\n PageToken,\n} from \"@/types/entityQuery\";\n\n/**\n * Ceiling on `fetchAllPages`. Reaching it fails the read instead of returning what was read so\n * far: a cursor that never ends is a bug, and a consolidated view shown from a partial read is\n * a wrong answer that looks right. A set legitimately this long wants a larger `pageSize`.\n */\nexport const FETCH_ALL_PAGES_LIMIT = 100;\n\n/** The element type of a page's item array. */\nexport type ItemOf<TPage, K extends keyof TPage> = TPage[K] extends (infer TItem)[] ? TItem : never;\n\nexport type EntityInfiniteQueryProps<TPage extends PagedResponse, K extends keyof TPage, TData> = {\n /**\n * Must describe everything that changes the response, `fetchAllPages` included, or two reads\n * share one cache entry. Build it with `buildQueryKey(keys, filters, { order, projection,\n * pageSize, fetchAllPages })`, and return it from your hook so callers can write to the cache.\n */\n queryKey: QueryKey;\n /** Where a page keeps its items (`\"datastores\"`, `\"files\"`, …). */\n itemsKey: K;\n /**\n * Requests one page; `undefined` asks for the first. `signal` aborts when no screen wants the\n * read any more — pass it to the request (`api.get(url, { signal })`) to cancel it in flight.\n */\n fetchPage: (pageToken: string | undefined, signal?: AbortSignal) => Promise<TPage>;\n select?: (items: ItemOf<TPage, K>[]) => TData;\n fetchAllPages?: boolean;\n /**\n * Your hook's own precondition for something legitimately not there yet (a selection the\n * user has not made), ANDed with the caller's `queryOptions.enabled`. Unmet, the query stays\n * idle. For something that should always be there, use `configError`: idle hides it.\n */\n enabled?: boolean;\n /**\n * Why the request cannot be right, when it cannot — `missingWorkspaceError(hookName)` in the\n * SDK's hooks. Set, the query fails at once with it as the error, without a request or a\n * retry, and logs it with `console.error` once per message, in every environment: a\n * misconfigured app shows up in the browser console and in test output, not as an empty\n * screen.\n * It is reported even while `enabled` is unmet, so an empty id cannot hide a misconfigured\n * workspace; only the caller's `queryOptions.enabled: false` holds it back.\n */\n configError?: string;\n queryOptions?: EntityInfiniteQueryOptions<TPage, TData>;\n};\n\n/** The `configError` messages already logged, so a render loop does not flood the console. */\nconst loggedConfigErrors = new Set<string>();\n\n/**\n * Fails a query with its `configError`, logging it the first time. Shared by the SDK's query\n * hooks.\n */\nexport const failWithConfigError = (configError: string): never => {\n if (!loggedConfigErrors.has(configError)) {\n loggedConfigErrors.add(configError);\n console.error(configError);\n }\n\n throw new Error(configError);\n};\n\nconst defaultQueryOptions = {\n refetchOnMount: \"always\",\n staleTime: 0,\n gcTime: 0,\n} as const;\n\n/**\n * Reads every page into one page, so the cache holds a single entry for the whole set and a\n * refetch rereads all of it.\n *\n * Stops as soon as `signal` aborts. TanStack aborts it when the last screen reading the query\n * unmounts — only because the query function takes it — and without this check the loop would\n * go on requesting every remaining page for nobody.\n */\nconst fetchEveryPage = async <TPage extends PagedResponse, K extends keyof TPage>(\n fetchPage: (pageToken: string | undefined, signal?: AbortSignal) => Promise<TPage>,\n itemsKey: K,\n signal: AbortSignal,\n): Promise<TPage> => {\n let page = await fetchPage(undefined, signal);\n const items = [...(page[itemsKey] as unknown[])];\n\n for (let count = 1; page.next_page_token; count++) {\n signal.throwIfAborted();\n\n if (count >= FETCH_ALL_PAGES_LIMIT) {\n throw new Error(\n `fetchAllPages stopped after ${FETCH_ALL_PAGES_LIMIT} pages without reaching the end. ` +\n \"Raise pageSize, or page on demand instead.\",\n );\n }\n\n page = await fetchPage(page.next_page_token, signal);\n items.push(...(page[itemsKey] as unknown[]));\n }\n\n return { ...page, [itemsKey]: items, next_page_token: null };\n};\n\n/**\n * useEntityInfiniteQuery\n *\n * The list hook every SDK list hook is built on, and the one to build on for an endpoint the\n * SDK does not cover. A hook says how to request a page and where its items are; this merges\n * the pages, applies the caller's `select`, and owns the paging modes (`fetchAllPages`, and\n * `fetchNextPage` for `handleRowsScrollEnd`). It replaced seven copies of the same\n * `useInfiniteQuery` call, which is how one `select` defect had reached all seven — an app\n * copying a list hook instead of composing this would copy the next one too.\n *\n * `select` is composed with the merging after the caller's options are spread, so nothing in\n * `queryOptions` can replace it. The composed function is memoised on the caller's `select`:\n * TanStack skips a select whose data and reference are both unchanged.\n *\n * @returns {UseInfiniteQueryResult} The `useInfiniteQuery` result; `data` is the merged items,\n * or what `select` makes of them.\n *\n * Example:\n * ```ts\n * export const useFetchReports = <TData = Report[]>({ workspace, select, fetchAllPages = false }: Props<TData>) => {\n * const { api } = useAxios();\n * const filters = [{ field: \"workspace\", value: workspace }];\n * const queryKey = buildQueryKey([\"reports\"], filters, { fetchAllPages });\n *\n * const query = useEntityInfiniteQuery<ReportListResponse, \"reports\", TData>({\n * queryKey,\n * itemsKey: \"reports\",\n * fetchPage: (pageToken) => listReports(api, workspace, pageToken),\n * select,\n * fetchAllPages,\n * configError: hasWorkspaceFilter(filters) ? undefined : missingWorkspaceError(\"useFetchReports\"),\n * });\n *\n * return { query, queryKey };\n * };\n * ```\n */\nexport function useEntityInfiniteQuery<\n TPage extends PagedResponse,\n K extends keyof TPage,\n TData = ItemOf<TPage, K>[],\n>({\n queryKey,\n itemsKey,\n fetchPage,\n select,\n fetchAllPages = false,\n enabled = true,\n configError,\n queryOptions,\n}: EntityInfiniteQueryProps<TPage, K, TData>) {\n const selectMerged = useCallback(\n (data: ListCache<TPage>): TData => {\n const items = data.pages.flatMap((page) => page[itemsKey] as ItemOf<TPage, K>[]);\n return select ? select(items) : (items as unknown as TData);\n },\n [itemsKey, select],\n );\n\n return useInfiniteQuery<TPage, Error, TData, QueryKey, PageToken>({\n ...defaultQueryOptions,\n ...queryOptions,\n\n queryKey,\n initialPageParam: null,\n getNextPageParam: (lastPage) => lastPage.next_page_token ?? undefined,\n queryFn: async ({ pageParam, signal }) => {\n if (configError) return failWithConfigError(configError);\n\n return fetchAllPages\n ? fetchEveryPage(fetchPage, itemsKey, signal)\n : fetchPage(pageParam ?? undefined, signal);\n },\n // A retry would rerun the same check and delay an error that cannot resolve itself.\n ...(configError ? { retry: false } : {}),\n\n select: selectMerged,\n // A config error runs past the hook's own precondition, so that an empty id cannot hide a\n // misconfigured workspace; the caller's `enabled` still wins. Kept as the caller wrote it,\n // so a function still works.\n enabled: configError || enabled ? (queryOptions?.enabled ?? true) : false,\n });\n}\n"],"mappings":";;;;;;;;AAeA,IAAa,wBAAwB;;AAyCrC,IAAM,qCAAqB,IAAI,IAAY;;;;;AAM3C,IAAa,uBAAuB,gBAA+B;CAC/D,IAAI,CAAC,mBAAmB,IAAI,WAAW,GAAG;EACtC,mBAAmB,IAAI,WAAW;EAClC,QAAQ,MAAM,WAAW;CAC7B;CAEA,MAAM,IAAI,MAAM,WAAW;AAC/B;AAEA,IAAM,sBAAsB;CACxB,gBAAgB;CAChB,WAAW;CACX,QAAQ;AACZ;;;;;;;;;AAUA,IAAM,iBAAiB,OACnB,WACA,UACA,WACiB;CACjB,IAAI,OAAO,MAAM,UAAU,KAAA,GAAW,MAAM;CAC5C,MAAM,QAAQ,CAAC,GAAI,KAAK,SAAuB;CAE/C,KAAK,IAAI,QAAQ,GAAG,KAAK,iBAAiB,SAAS;EAC/C,OAAO,eAAe;EAEtB,IAAI,SAAA,KACA,MAAM,IAAI,MACN,4GAEJ;EAGJ,OAAO,MAAM,UAAU,KAAK,iBAAiB,MAAM;EACnD,MAAM,KAAK,GAAI,KAAK,SAAuB;CAC/C;CAEA,OAAO;EAAE,GAAG;GAAO,WAAW;EAAO,iBAAiB;CAAK;AAC/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,uBAId,EACE,UACA,UACA,WACA,QACA,gBAAgB,OAChB,UAAU,MACV,aACA,gBAC0C;CAC1C,MAAM,eAAe,aAChB,SAAkC;EAC/B,MAAM,QAAQ,KAAK,MAAM,SAAS,SAAS,KAAK,SAA+B;EAC/E,OAAO,SAAS,OAAO,KAAK,IAAK;CACrC,GACA,CAAC,UAAU,MAAM,CACrB;CAEA,OAAO,iBAA2D;EAC9D,GAAG;EACH,GAAG;EAEH;EACA,kBAAkB;EAClB,mBAAmB,aAAa,SAAS,mBAAmB,KAAA;EAC5D,SAAS,OAAO,EAAE,WAAW,aAAa;GACtC,IAAI,aAAa,OAAO,oBAAoB,WAAW;GAEvD,OAAO,gBACD,eAAe,WAAW,UAAU,MAAM,IAC1C,UAAU,aAAa,KAAA,GAAW,MAAM;EAClD;EAEA,GAAI,cAAc,EAAE,OAAO,MAAM,IAAI,CAAC;EAEtC,QAAQ;EAIR,SAAS,eAAe,UAAW,cAAc,WAAW,OAAQ;CACxE,CAAC;AACL"}
@@ -0,0 +1,47 @@
1
+ import { type QueryKey } from "@tanstack/react-query";
2
+ export type EntityMutationProps<TVariables, TResult> = {
3
+ /** Sends the write. Receives the variables passed to `mutate`, and only those. */
4
+ mutationFn: (variables: TVariables) => Promise<TResult>;
5
+ /**
6
+ * Invalidated after a success, so the screens reading it refetch. Pass the `queryKey` a fetch
7
+ * hook returned, or a prefix of it (`["datastores"]`) to refresh every list of that entity.
8
+ */
9
+ queryKey?: QueryKey;
10
+ /** Shown as a success alert. */
11
+ successMessage: string;
12
+ /** Shown as an error alert when the failure carries no message of its own. */
13
+ errorMessage: string;
14
+ };
15
+ /**
16
+ * useEntityMutation
17
+ *
18
+ * The write hook every SDK mutation is built on, and the one to build on for an endpoint the SDK
19
+ * does not cover — the counterpart of `useEntityQuery`. A hook says how to send the write and
20
+ * what to tell the user; this owns the cache invalidation and the alerts.
21
+ *
22
+ * It replaced nine copies of the same `useMutation` call across `useDatastoreMutations`,
23
+ * `useFileMutations` and `usePortfolioMutations`, which had already drifted apart in wording.
24
+ *
25
+ * The invalidation is awaited before the mutation resolves, so code after `mutateAsync` sees the
26
+ * refetched data rather than racing it.
27
+ *
28
+ * @returns {UseMutationResult} The `useMutation` result.
29
+ *
30
+ * Example:
31
+ * ```ts
32
+ * export const useReportMutations = ({ queryKey }: { queryKey?: QueryKey }) => {
33
+ * const { api } = useAxios();
34
+ *
35
+ * const share = useEntityMutation({
36
+ * mutationFn: ({ id, workspace }: ShareReportProps) => shareReport(api, id, workspace),
37
+ * queryKey,
38
+ * successMessage: "Report shared successfully.",
39
+ * errorMessage: "Unable to share the report. Please try again.",
40
+ * });
41
+ *
42
+ * return { share };
43
+ * };
44
+ * ```
45
+ */
46
+ export declare function useEntityMutation<TVariables, TResult>({ mutationFn, queryKey, successMessage, errorMessage, }: EntityMutationProps<TVariables, TResult>): import("@tanstack/react-query").UseMutationResult<TResult, Error, TVariables, unknown>;
47
+ //# sourceMappingURL=useEntityMutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityMutation.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntityMutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAInF,MAAM,MAAM,mBAAmB,CAAC,UAAU,EAAE,OAAO,IAAI;IACnD,kFAAkF;IAClF,UAAU,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACxD;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,gCAAgC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,YAAY,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,OAAO,EAAE,EACnD,UAAU,EACV,QAAQ,EACR,cAAc,EACd,YAAY,GACf,EAAE,mBAAmB,CAAC,UAAU,EAAE,OAAO,CAAC,0FAe1C"}
@@ -0,0 +1,58 @@
1
+ import { useAppAlert } from "../contexts/appAlertContext/useAppAlert.js";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ //#region src/hooks/useEntityMutation.ts
4
+ /**
5
+ * useEntityMutation
6
+ *
7
+ * The write hook every SDK mutation is built on, and the one to build on for an endpoint the SDK
8
+ * does not cover — the counterpart of `useEntityQuery`. A hook says how to send the write and
9
+ * what to tell the user; this owns the cache invalidation and the alerts.
10
+ *
11
+ * It replaced nine copies of the same `useMutation` call across `useDatastoreMutations`,
12
+ * `useFileMutations` and `usePortfolioMutations`, which had already drifted apart in wording.
13
+ *
14
+ * The invalidation is awaited before the mutation resolves, so code after `mutateAsync` sees the
15
+ * refetched data rather than racing it.
16
+ *
17
+ * @returns {UseMutationResult} The `useMutation` result.
18
+ *
19
+ * Example:
20
+ * ```ts
21
+ * export const useReportMutations = ({ queryKey }: { queryKey?: QueryKey }) => {
22
+ * const { api } = useAxios();
23
+ *
24
+ * const share = useEntityMutation({
25
+ * mutationFn: ({ id, workspace }: ShareReportProps) => shareReport(api, id, workspace),
26
+ * queryKey,
27
+ * successMessage: "Report shared successfully.",
28
+ * errorMessage: "Unable to share the report. Please try again.",
29
+ * });
30
+ *
31
+ * return { share };
32
+ * };
33
+ * ```
34
+ */
35
+ function useEntityMutation({ mutationFn, queryKey, successMessage, errorMessage }) {
36
+ const { showAlert } = useAppAlert();
37
+ const queryClient = useQueryClient();
38
+ return useMutation({
39
+ mutationFn: (variables) => mutationFn(variables),
40
+ onSuccess: async () => {
41
+ if (queryKey?.length) await queryClient.invalidateQueries({ queryKey });
42
+ showAlert({
43
+ severity: "success",
44
+ message: successMessage
45
+ });
46
+ },
47
+ onError: (error) => {
48
+ showAlert({
49
+ severity: "error",
50
+ message: error.message || errorMessage
51
+ });
52
+ }
53
+ });
54
+ }
55
+ //#endregion
56
+ export { useEntityMutation };
57
+
58
+ //# sourceMappingURL=useEntityMutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityMutation.js","names":[],"sources":["../../src/hooks/useEntityMutation.ts"],"sourcesContent":["import { useMutation, useQueryClient, type QueryKey } from \"@tanstack/react-query\";\n\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\n\nexport type EntityMutationProps<TVariables, TResult> = {\n /** Sends the write. Receives the variables passed to `mutate`, and only those. */\n mutationFn: (variables: TVariables) => Promise<TResult>;\n /**\n * Invalidated after a success, so the screens reading it refetch. Pass the `queryKey` a fetch\n * hook returned, or a prefix of it (`[\"datastores\"]`) to refresh every list of that entity.\n */\n queryKey?: QueryKey;\n /** Shown as a success alert. */\n successMessage: string;\n /** Shown as an error alert when the failure carries no message of its own. */\n errorMessage: string;\n};\n\n/**\n * useEntityMutation\n *\n * The write hook every SDK mutation is built on, and the one to build on for an endpoint the SDK\n * does not cover — the counterpart of `useEntityQuery`. A hook says how to send the write and\n * what to tell the user; this owns the cache invalidation and the alerts.\n *\n * It replaced nine copies of the same `useMutation` call across `useDatastoreMutations`,\n * `useFileMutations` and `usePortfolioMutations`, which had already drifted apart in wording.\n *\n * The invalidation is awaited before the mutation resolves, so code after `mutateAsync` sees the\n * refetched data rather than racing it.\n *\n * @returns {UseMutationResult} The `useMutation` result.\n *\n * Example:\n * ```ts\n * export const useReportMutations = ({ queryKey }: { queryKey?: QueryKey }) => {\n * const { api } = useAxios();\n *\n * const share = useEntityMutation({\n * mutationFn: ({ id, workspace }: ShareReportProps) => shareReport(api, id, workspace),\n * queryKey,\n * successMessage: \"Report shared successfully.\",\n * errorMessage: \"Unable to share the report. Please try again.\",\n * });\n *\n * return { share };\n * };\n * ```\n */\nexport function useEntityMutation<TVariables, TResult>({\n mutationFn,\n queryKey,\n successMessage,\n errorMessage,\n}: EntityMutationProps<TVariables, TResult>) {\n const { showAlert } = useAppAlert();\n const queryClient = useQueryClient();\n\n return useMutation<TResult, Error, TVariables>({\n // TanStack passes a context as a second argument; the request gets the variables alone.\n mutationFn: (variables) => mutationFn(variables),\n onSuccess: async () => {\n if (queryKey?.length) await queryClient.invalidateQueries({ queryKey });\n showAlert({ severity: \"success\", message: successMessage });\n },\n onError: (error) => {\n showAlert({ severity: \"error\", message: error.message || errorMessage });\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,kBAAuC,EACnD,YACA,UACA,gBACA,gBACyC;CACzC,MAAM,EAAE,cAAc,YAAY;CAClC,MAAM,cAAc,eAAe;CAEnC,OAAO,YAAwC;EAE3C,aAAa,cAAc,WAAW,SAAS;EAC/C,WAAW,YAAY;GACnB,IAAI,UAAU,QAAQ,MAAM,YAAY,kBAAkB,EAAE,SAAS,CAAC;GACtE,UAAU;IAAE,UAAU;IAAW,SAAS;GAAe,CAAC;EAC9D;EACA,UAAU,UAAU;GAChB,UAAU;IAAE,UAAU;IAAS,SAAS,MAAM,WAAW;GAAa,CAAC;EAC3E;CACJ,CAAC;AACL"}
@@ -0,0 +1,68 @@
1
+ import { type QueryKey } from "@tanstack/react-query";
2
+ import type { EntityQueryOptions } from "../types/entityQuery.d.ts";
3
+ export type EntityQueryProps<TEntity, TData> = {
4
+ /** Must describe everything that changes the response: the entity's ids and workspace. */
5
+ queryKey: QueryKey;
6
+ /**
7
+ * Requests the entity. `signal` aborts when no screen wants it any more — pass it to the
8
+ * request (`api.get(url, { signal })`) to cancel it in flight.
9
+ */
10
+ fetchEntity: (signal: AbortSignal) => Promise<TEntity>;
11
+ select?: (entity: TEntity) => TData;
12
+ /**
13
+ * Your hook's own precondition for something legitimately not there yet — an id from a
14
+ * selection the user has not made — ANDed with the caller's `queryOptions.enabled`. Unmet,
15
+ * the query stays idle rather than send an empty id, which reaches another endpoint entirely.
16
+ */
17
+ enabled?: boolean;
18
+ /**
19
+ * Why the request cannot be right, when it cannot — `missingWorkspaceError(hookName)` in the
20
+ * SDK's hooks. Set, the query fails at once with it, without a request or a retry, logs it once
21
+ * with `console.error` and shows it as the error alert. See `useEntityInfiniteQuery`.
22
+ * It is reported even while `enabled` is unmet, so an empty id cannot hide a misconfigured
23
+ * workspace; only the caller's `queryOptions.enabled: false` holds it back.
24
+ */
25
+ configError?: string;
26
+ /** Replaces the SDK's defaults for this hook, as the profile does. */
27
+ defaultQueryOptions?: EntityQueryOptions<TEntity, TData>;
28
+ queryOptions?: EntityQueryOptions<TEntity, TData>;
29
+ };
30
+ /**
31
+ * useEntityQuery
32
+ *
33
+ * The single-entity hook every SDK single-entity hook is built on, and the one to build on for
34
+ * an endpoint the SDK does not cover — the counterpart of `useEntityInfiniteQuery`. A hook says
35
+ * how to request the entity; this owns the defaults, the idle precondition, `select` and the
36
+ * error alert.
37
+ *
38
+ * It replaced eight copies of the same `useQuery` call, which is how one defect had reached all
39
+ * eight: each declared `queryOptions = defaultQueryOptions`, so passing any option replaced the
40
+ * defaults and the query fell back to TanStack's own (a 5-minute cache instead of none). Here
41
+ * the caller's options are merged over the defaults.
42
+ *
43
+ * A failure is shown through `useAppAlert`, as the entity hooks always have.
44
+ *
45
+ * @returns {UseQueryResult} The `useQuery` result; `data` is the entity, or what `select` makes
46
+ * of it. The SDK's hooks spread it and add `queryKey`.
47
+ *
48
+ * Example:
49
+ * ```ts
50
+ * export const useFetchReport = <TData = Report>({ id, workspace, select, queryOptions }: Props<TData>) => {
51
+ * const { api } = useAxios();
52
+ * const queryKey = ["report", id, workspace];
53
+ *
54
+ * const query = useEntityQuery<Report, TData>({
55
+ * queryKey,
56
+ * fetchEntity: (signal) => getReport(api, id, workspace, signal),
57
+ * select,
58
+ * enabled: Boolean(id),
59
+ * configError: workspace ? undefined : missingWorkspaceError("useFetchReport"),
60
+ * queryOptions,
61
+ * });
62
+ *
63
+ * return { ...query, queryKey };
64
+ * };
65
+ * ```
66
+ */
67
+ export declare function useEntityQuery<TEntity, TData = TEntity>({ queryKey, fetchEntity, select, enabled, configError, defaultQueryOptions, queryOptions, }: EntityQueryProps<TEntity, TData>): import("@tanstack/react-query").UseQueryResult<TData, Error>;
68
+ //# sourceMappingURL=useEntityQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntityQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAIhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,MAAM,gBAAgB,CAAC,OAAO,EAAE,KAAK,IAAI;IAC3C,0FAA0F;IAC1F,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;OAGG;IACH,WAAW,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,KAAK,CAAC;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzD,YAAY,CAAC,EAAE,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;CACrD,CAAC;AAYF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,EAAE,EACrD,QAAQ,EACR,WAAW,EACX,MAAM,EACN,OAAc,EACd,WAAW,EACX,mBAA4C,EAC5C,YAAY,GACf,EAAE,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,gEA0BlC"}
@@ -0,0 +1,75 @@
1
+ import { useAppAlert } from "../contexts/appAlertContext/useAppAlert.js";
2
+ import { failWithConfigError } from "./useEntityInfiniteQuery.js";
3
+ import { useEffect } from "react";
4
+ import { useQuery } from "@tanstack/react-query";
5
+ //#region src/hooks/useEntityQuery.ts
6
+ /**
7
+ * The entity hooks read data the platform keeps changing, so by default nothing is cached:
8
+ * refetched on every mount, dropped as soon as no screen reads it.
9
+ */
10
+ var sdkDefaultQueryOptions = {
11
+ refetchOnMount: "always",
12
+ staleTime: 0,
13
+ gcTime: 0
14
+ };
15
+ /**
16
+ * useEntityQuery
17
+ *
18
+ * The single-entity hook every SDK single-entity hook is built on, and the one to build on for
19
+ * an endpoint the SDK does not cover — the counterpart of `useEntityInfiniteQuery`. A hook says
20
+ * how to request the entity; this owns the defaults, the idle precondition, `select` and the
21
+ * error alert.
22
+ *
23
+ * It replaced eight copies of the same `useQuery` call, which is how one defect had reached all
24
+ * eight: each declared `queryOptions = defaultQueryOptions`, so passing any option replaced the
25
+ * defaults and the query fell back to TanStack's own (a 5-minute cache instead of none). Here
26
+ * the caller's options are merged over the defaults.
27
+ *
28
+ * A failure is shown through `useAppAlert`, as the entity hooks always have.
29
+ *
30
+ * @returns {UseQueryResult} The `useQuery` result; `data` is the entity, or what `select` makes
31
+ * of it. The SDK's hooks spread it and add `queryKey`.
32
+ *
33
+ * Example:
34
+ * ```ts
35
+ * export const useFetchReport = <TData = Report>({ id, workspace, select, queryOptions }: Props<TData>) => {
36
+ * const { api } = useAxios();
37
+ * const queryKey = ["report", id, workspace];
38
+ *
39
+ * const query = useEntityQuery<Report, TData>({
40
+ * queryKey,
41
+ * fetchEntity: (signal) => getReport(api, id, workspace, signal),
42
+ * select,
43
+ * enabled: Boolean(id),
44
+ * configError: workspace ? undefined : missingWorkspaceError("useFetchReport"),
45
+ * queryOptions,
46
+ * });
47
+ *
48
+ * return { ...query, queryKey };
49
+ * };
50
+ * ```
51
+ */
52
+ function useEntityQuery({ queryKey, fetchEntity, select, enabled = true, configError, defaultQueryOptions = sdkDefaultQueryOptions, queryOptions }) {
53
+ const { showAlert } = useAppAlert();
54
+ const query = useQuery({
55
+ ...defaultQueryOptions,
56
+ ...queryOptions,
57
+ queryKey,
58
+ queryFn: async ({ signal }) => configError ? failWithConfigError(configError) : fetchEntity(signal),
59
+ ...configError ? { retry: false } : {},
60
+ select,
61
+ enabled: configError || enabled ? queryOptions?.enabled ?? true : false
62
+ });
63
+ useEffect(() => {
64
+ if (!query.error) return;
65
+ showAlert({
66
+ severity: "error",
67
+ message: query.error.message
68
+ });
69
+ }, [query.error, showAlert]);
70
+ return query;
71
+ }
72
+ //#endregion
73
+ export { useEntityQuery };
74
+
75
+ //# sourceMappingURL=useEntityQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityQuery.js","names":[],"sources":["../../src/hooks/useEntityQuery.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useQuery, type QueryKey } from \"@tanstack/react-query\";\n\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport { failWithConfigError } from \"@/hooks/useEntityInfiniteQuery\";\nimport type { EntityQueryOptions } from \"@/types/entityQuery\";\n\nexport type EntityQueryProps<TEntity, TData> = {\n /** Must describe everything that changes the response: the entity's ids and workspace. */\n queryKey: QueryKey;\n /**\n * Requests the entity. `signal` aborts when no screen wants it any more — pass it to the\n * request (`api.get(url, { signal })`) to cancel it in flight.\n */\n fetchEntity: (signal: AbortSignal) => Promise<TEntity>;\n select?: (entity: TEntity) => TData;\n /**\n * Your hook's own precondition for something legitimately not there yet — an id from a\n * selection the user has not made — ANDed with the caller's `queryOptions.enabled`. Unmet,\n * the query stays idle rather than send an empty id, which reaches another endpoint entirely.\n */\n enabled?: boolean;\n /**\n * Why the request cannot be right, when it cannot — `missingWorkspaceError(hookName)` in the\n * SDK's hooks. Set, the query fails at once with it, without a request or a retry, logs it once\n * with `console.error` and shows it as the error alert. See `useEntityInfiniteQuery`.\n * It is reported even while `enabled` is unmet, so an empty id cannot hide a misconfigured\n * workspace; only the caller's `queryOptions.enabled: false` holds it back.\n */\n configError?: string;\n /** Replaces the SDK's defaults for this hook, as the profile does. */\n defaultQueryOptions?: EntityQueryOptions<TEntity, TData>;\n queryOptions?: EntityQueryOptions<TEntity, TData>;\n};\n\n/**\n * The entity hooks read data the platform keeps changing, so by default nothing is cached:\n * refetched on every mount, dropped as soon as no screen reads it.\n */\nconst sdkDefaultQueryOptions = {\n refetchOnMount: \"always\",\n staleTime: 0,\n gcTime: 0,\n} as const;\n\n/**\n * useEntityQuery\n *\n * The single-entity hook every SDK single-entity hook is built on, and the one to build on for\n * an endpoint the SDK does not cover — the counterpart of `useEntityInfiniteQuery`. A hook says\n * how to request the entity; this owns the defaults, the idle precondition, `select` and the\n * error alert.\n *\n * It replaced eight copies of the same `useQuery` call, which is how one defect had reached all\n * eight: each declared `queryOptions = defaultQueryOptions`, so passing any option replaced the\n * defaults and the query fell back to TanStack's own (a 5-minute cache instead of none). Here\n * the caller's options are merged over the defaults.\n *\n * A failure is shown through `useAppAlert`, as the entity hooks always have.\n *\n * @returns {UseQueryResult} The `useQuery` result; `data` is the entity, or what `select` makes\n * of it. The SDK's hooks spread it and add `queryKey`.\n *\n * Example:\n * ```ts\n * export const useFetchReport = <TData = Report>({ id, workspace, select, queryOptions }: Props<TData>) => {\n * const { api } = useAxios();\n * const queryKey = [\"report\", id, workspace];\n *\n * const query = useEntityQuery<Report, TData>({\n * queryKey,\n * fetchEntity: (signal) => getReport(api, id, workspace, signal),\n * select,\n * enabled: Boolean(id),\n * configError: workspace ? undefined : missingWorkspaceError(\"useFetchReport\"),\n * queryOptions,\n * });\n *\n * return { ...query, queryKey };\n * };\n * ```\n */\nexport function useEntityQuery<TEntity, TData = TEntity>({\n queryKey,\n fetchEntity,\n select,\n enabled = true,\n configError,\n defaultQueryOptions = sdkDefaultQueryOptions,\n queryOptions,\n}: EntityQueryProps<TEntity, TData>) {\n const { showAlert } = useAppAlert();\n\n const query = useQuery<TEntity, Error, TData>({\n ...defaultQueryOptions,\n ...queryOptions,\n\n queryKey,\n queryFn: async ({ signal }) =>\n configError ? failWithConfigError(configError) : fetchEntity(signal),\n // A retry would rerun the same check and delay an error that cannot resolve itself.\n ...(configError ? { retry: false } : {}),\n select,\n // A config error runs past the hook's own precondition, so that an empty id cannot hide a\n // misconfigured workspace; the caller's `enabled` still wins. Kept as the caller wrote it,\n // so a function still works.\n enabled: configError || enabled ? (queryOptions?.enabled ?? true) : false,\n });\n\n useEffect(() => {\n if (!query.error) return;\n\n showAlert({ severity: \"error\", message: query.error.message });\n }, [query.error, showAlert]);\n\n return query;\n}\n"],"mappings":";;;;;;;;;AAuCA,IAAM,yBAAyB;CAC3B,gBAAgB;CAChB,WAAW;CACX,QAAQ;AACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,eAAyC,EACrD,UACA,aACA,QACA,UAAU,MACV,aACA,sBAAsB,wBACtB,gBACiC;CACjC,MAAM,EAAE,cAAc,YAAY;CAElC,MAAM,QAAQ,SAAgC;EAC1C,GAAG;EACH,GAAG;EAEH;EACA,SAAS,OAAO,EAAE,aACd,cAAc,oBAAoB,WAAW,IAAI,YAAY,MAAM;EAEvE,GAAI,cAAc,EAAE,OAAO,MAAM,IAAI,CAAC;EACtC;EAIA,SAAS,eAAe,UAAW,cAAc,WAAW,OAAQ;CACxE,CAAC;CAED,gBAAgB;EACZ,IAAI,CAAC,MAAM,OAAO;EAElB,UAAU;GAAE,UAAU;GAAS,SAAS,MAAM,MAAM;EAAQ,CAAC;CACjE,GAAG,CAAC,MAAM,OAAO,SAAS,CAAC;CAE3B,OAAO;AACX"}
@@ -1,40 +1,23 @@
1
1
  import type { WorkerExecution } from "../../types/workflow.d.ts";
2
- import type { EntityQueryOptions } from "../../types/entityQuery.d.ts";
3
- export type FetchWorkerExecutionProps<TData = WorkerExecution, TSelected = TData> = {
2
+ import type { FetchEntityProps } from "../../types/entityQuery.d.ts";
3
+ export type FetchWorkerExecutionProps<TData = WorkerExecution, TSelected = TData> = FetchEntityProps<TData, TSelected> & {
4
4
  workflowId: string;
5
5
  workerExecutionId: string;
6
6
  workspace: string;
7
- queryOptions?: EntityQueryOptions<TData, TSelected>;
8
7
  };
9
8
  /**
10
9
  * useFetchWorkerExecution
11
10
  *
12
- * Data-fetching hook built on TanStack Query to retrieve a single worker execution.
11
+ * Fetches one worker execution; `data` is the execution, or whatever `select` makes of it. Idle
12
+ * while an id is empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error alert.
13
13
  *
14
- * It also:
15
- * - builds a stable React Query `queryKey` that can be reused by mutation hooks for cache invalidation
16
- * - triggers an error alert via `useAppAlert` whenever `query.error` is present
17
- *
18
- * @param workflowId - Workflow identifier the worker execution belongs to (required).
19
- * @param workerExecutionId - Worker execution identifier (required).
20
- * @param workspace - Workspace the workflow belongs to (required).
21
- * @param queryOptions - TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
22
- *
23
- * @returns TanStack Query result extended with `queryKey`.
24
- *
25
- * Example:
26
- * ```ts
27
- * const { data, isLoading } = useFetchWorkerExecution({
28
- * workflowId: "wf-123",
29
- * workerExecutionId: "wkex-456",
30
- * workspace: "main",
31
- * });
32
- * // data -> WorkerExecution
33
- * ```
14
+ * @param {FetchWorkerExecutionProps} props - `workflowId`, `workerExecutionId`, `workspace`,
15
+ * `select` and TanStack `queryOptions`.
16
+ * @returns {object} The `useQuery` result, plus `queryKey`.
34
17
  */
35
- export declare const useFetchWorkerExecution: ({ workflowId, workerExecutionId, workspace, queryOptions }: FetchWorkerExecutionProps) => {
18
+ export declare const useFetchWorkerExecution: <TSelected = WorkerExecution>({ workflowId, workerExecutionId, workspace, select, queryOptions, }: FetchWorkerExecutionProps<WorkerExecution, TSelected>) => {
36
19
  queryKey: string[];
37
- data: WorkerExecution;
20
+ data: TSelected;
38
21
  error: Error;
39
22
  isError: true;
40
23
  isPending: false;
@@ -57,11 +40,11 @@ export declare const useFetchWorkerExecution: ({ workflowId, workerExecutionId,
57
40
  isRefetching: boolean;
58
41
  isStale: boolean;
59
42
  isEnabled: boolean;
60
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WorkerExecution, Error>>;
43
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
61
44
  fetchStatus: import("@tanstack/query-core").FetchStatus;
62
45
  } | {
63
46
  queryKey: string[];
64
- data: WorkerExecution;
47
+ data: TSelected;
65
48
  error: null;
66
49
  isError: false;
67
50
  isPending: false;
@@ -84,7 +67,7 @@ export declare const useFetchWorkerExecution: ({ workflowId, workerExecutionId,
84
67
  isRefetching: boolean;
85
68
  isStale: boolean;
86
69
  isEnabled: boolean;
87
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WorkerExecution, Error>>;
70
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
88
71
  fetchStatus: import("@tanstack/query-core").FetchStatus;
89
72
  } | {
90
73
  queryKey: string[];
@@ -111,7 +94,7 @@ export declare const useFetchWorkerExecution: ({ workflowId, workerExecutionId,
111
94
  isRefetching: boolean;
112
95
  isStale: boolean;
113
96
  isEnabled: boolean;
114
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WorkerExecution, Error>>;
97
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
115
98
  fetchStatus: import("@tanstack/query-core").FetchStatus;
116
99
  } | {
117
100
  queryKey: string[];
@@ -138,7 +121,7 @@ export declare const useFetchWorkerExecution: ({ workflowId, workerExecutionId,
138
121
  isRefetching: boolean;
139
122
  isStale: boolean;
140
123
  isEnabled: boolean;
141
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WorkerExecution, Error>>;
124
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
142
125
  fetchStatus: import("@tanstack/query-core").FetchStatus;
143
126
  } | {
144
127
  queryKey: string[];
@@ -165,11 +148,11 @@ export declare const useFetchWorkerExecution: ({ workflowId, workerExecutionId,
165
148
  isRefetching: boolean;
166
149
  isStale: boolean;
167
150
  isEnabled: boolean;
168
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WorkerExecution, Error>>;
151
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
169
152
  fetchStatus: import("@tanstack/query-core").FetchStatus;
170
153
  } | {
171
154
  queryKey: string[];
172
- data: WorkerExecution;
155
+ data: TSelected;
173
156
  isError: false;
174
157
  error: null;
175
158
  isPending: false;
@@ -192,7 +175,7 @@ export declare const useFetchWorkerExecution: ({ workflowId, workerExecutionId,
192
175
  isRefetching: boolean;
193
176
  isStale: boolean;
194
177
  isEnabled: boolean;
195
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WorkerExecution, Error>>;
178
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<TSelected, Error>>;
196
179
  fetchStatus: import("@tanstack/query-core").FetchStatus;
197
180
  };
198
181
  //# sourceMappingURL=useFetchWorkerExecution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchWorkerExecution.d.ts","sourceRoot":"","sources":["../../../src/hooks/workflow/useFetchWorkerExecution.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,MAAM,yBAAyB,CAAC,KAAK,GAAG,eAAe,EAAE,SAAS,GAAG,KAAK,IAAI;IAChF,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,kBAAkB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACvD,CAAC;AAQF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,uBAAuB,GAAI,4DAAkF,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BlJ,CAAC"}
1
+ {"version":3,"file":"useFetchWorkerExecution.d.ts","sourceRoot":"","sources":["../../../src/hooks/workflow/useFetchWorkerExecution.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,MAAM,yBAAyB,CACjC,KAAK,GAAG,eAAe,EACvB,SAAS,GAAG,KAAK,IACjB,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,GAAG,eAAe,EAAE,qEAMlE,yBAAyB,CAAC,eAAe,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBvD,CAAC"}
@@ -1,65 +1,35 @@
1
- import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
2
1
  import { useAxios } from "../useAxios.js";
2
+ import { useEntityQuery } from "../useEntityQuery.js";
3
+ import { missingWorkspaceError } from "../../api/entityQuery.js";
3
4
  import { getWorkerExecution } from "../../api/workflow.js";
4
- import { useEffect } from "react";
5
- import { useQuery } from "@tanstack/react-query";
6
5
  //#region src/hooks/workflow/useFetchWorkerExecution.ts
7
- var defaultQueryOptions = {
8
- refetchOnMount: "always",
9
- staleTime: 0,
10
- gcTime: 0
11
- };
12
6
  /**
13
7
  * useFetchWorkerExecution
14
8
  *
15
- * Data-fetching hook built on TanStack Query to retrieve a single worker execution.
16
- *
17
- * It also:
18
- * - builds a stable React Query `queryKey` that can be reused by mutation hooks for cache invalidation
19
- * - triggers an error alert via `useAppAlert` whenever `query.error` is present
20
- *
21
- * @param workflowId - Workflow identifier the worker execution belongs to (required).
22
- * @param workerExecutionId - Worker execution identifier (required).
23
- * @param workspace - Workspace the workflow belongs to (required).
24
- * @param queryOptions - TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
25
- *
26
- * @returns TanStack Query result extended with `queryKey`.
9
+ * Fetches one worker execution; `data` is the execution, or whatever `select` makes of it. Idle
10
+ * while an id is empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error alert.
27
11
  *
28
- * Example:
29
- * ```ts
30
- * const { data, isLoading } = useFetchWorkerExecution({
31
- * workflowId: "wf-123",
32
- * workerExecutionId: "wkex-456",
33
- * workspace: "main",
34
- * });
35
- * // data -> WorkerExecution
36
- * ```
12
+ * @param {FetchWorkerExecutionProps} props - `workflowId`, `workerExecutionId`, `workspace`,
13
+ * `select` and TanStack `queryOptions`.
14
+ * @returns {object} The `useQuery` result, plus `queryKey`.
37
15
  */
38
- var useFetchWorkerExecution = ({ workflowId, workerExecutionId, workspace, queryOptions = defaultQueryOptions }) => {
16
+ var useFetchWorkerExecution = ({ workflowId, workerExecutionId, workspace, select, queryOptions }) => {
39
17
  const { api } = useAxios();
40
- const { showAlert } = useAppAlert();
41
18
  const queryKey = [
42
19
  "worker_execution",
43
20
  workflowId,
44
21
  workerExecutionId,
45
22
  workspace
46
23
  ];
47
- const query = useQuery({
48
- queryKey,
49
- queryFn: async () => {
50
- return await getWorkerExecution(api, workflowId, workerExecutionId, workspace);
51
- },
52
- ...queryOptions ?? {}
53
- });
54
- useEffect(() => {
55
- if (!query.error) return;
56
- showAlert({
57
- severity: "error",
58
- message: query.error.message
59
- });
60
- }, [query.error, showAlert]);
61
24
  return {
62
- ...query,
25
+ ...useEntityQuery({
26
+ queryKey,
27
+ fetchEntity: (signal) => getWorkerExecution(api, workflowId, workerExecutionId, workspace, signal),
28
+ select,
29
+ enabled: Boolean(workflowId) && Boolean(workerExecutionId),
30
+ configError: workspace ? void 0 : missingWorkspaceError("useFetchWorkerExecution"),
31
+ queryOptions
32
+ }),
63
33
  queryKey
64
34
  };
65
35
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchWorkerExecution.js","names":[],"sources":["../../../src/hooks/workflow/useFetchWorkerExecution.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { useQuery } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport { getWorkerExecution } from \"@/api/workflow\";\nimport type { WorkerExecution } from \"@/types/workflow\";\nimport type { EntityQueryOptions } from \"@/types/entityQuery\";\n\nexport type FetchWorkerExecutionProps<TData = WorkerExecution, TSelected = TData> = {\n workflowId: string;\n workerExecutionId: string;\n workspace: string;\n queryOptions?: EntityQueryOptions<TData, TSelected>;\n};\n\nconst defaultQueryOptions: EntityQueryOptions<WorkerExecution> = {\n refetchOnMount: \"always\",\n staleTime: 0,\n gcTime: 0,\n};\n\n/**\n * useFetchWorkerExecution\n *\n * Data-fetching hook built on TanStack Query to retrieve a single worker execution.\n *\n * It also:\n * - builds a stable React Query `queryKey` that can be reused by mutation hooks for cache invalidation\n * - triggers an error alert via `useAppAlert` whenever `query.error` is present\n *\n * @param workflowId - Workflow identifier the worker execution belongs to (required).\n * @param workerExecutionId - Worker execution identifier (required).\n * @param workspace - Workspace the workflow belongs to (required).\n * @param queryOptions - TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).\n *\n * @returns TanStack Query result extended with `queryKey`.\n *\n * Example:\n * ```ts\n * const { data, isLoading } = useFetchWorkerExecution({\n * workflowId: \"wf-123\",\n * workerExecutionId: \"wkex-456\",\n * workspace: \"main\",\n * });\n * // data -> WorkerExecution\n * ```\n */\nexport const useFetchWorkerExecution = ({ workflowId, workerExecutionId, workspace, queryOptions = defaultQueryOptions }: FetchWorkerExecutionProps) => {\n\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n\n const queryKey = [\"worker_execution\", workflowId, workerExecutionId, workspace];\n\n const query = useQuery<WorkerExecution>({\n queryKey,\n queryFn: async () => {\n return await getWorkerExecution(api, workflowId, workerExecutionId, workspace);\n },\n ...queryOptions ?? {}\n });\n\n useEffect(() => {\n if (!query.error) return;\n\n showAlert({\n severity: \"error\",\n message: query.error.message,\n });\n }, [query.error, showAlert]);\n\n return {\n ...query,\n queryKey,\n };\n};\n"],"mappings":";;;;;;AAiBA,IAAM,sBAA2D;CAC7D,gBAAgB;CAChB,WAAW;CACX,QAAQ;AACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,2BAA2B,EAAE,YAAY,mBAAmB,WAAW,eAAe,0BAAqD;CAEpJ,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAElC,MAAM,WAAW;EAAC;EAAoB;EAAY;EAAmB;CAAS;CAE9E,MAAM,QAAQ,SAA0B;EACpC;EACA,SAAS,YAAY;GACjB,OAAO,MAAM,mBAAmB,KAAK,YAAY,mBAAmB,SAAS;EACjF;EACA,GAAG,gBAAgB,CAAC;CACxB,CAAC;CAED,gBAAgB;EACZ,IAAI,CAAC,MAAM,OAAO;EAElB,UAAU;GACN,UAAU;GACV,SAAS,MAAM,MAAM;EACzB,CAAC;CACL,GAAG,CAAC,MAAM,OAAO,SAAS,CAAC;CAE3B,OAAO;EACH,GAAG;EACH;CACJ;AACJ"}
1
+ {"version":3,"file":"useFetchWorkerExecution.js","names":[],"sources":["../../../src/hooks/workflow/useFetchWorkerExecution.ts"],"sourcesContent":["import { useAxios } from \"@/hooks/useAxios\";\nimport { useEntityQuery } from \"@/hooks/useEntityQuery\";\nimport { missingWorkspaceError } from \"@/api/entityQuery\";\nimport { getWorkerExecution } from \"@/api/workflow\";\nimport type { WorkerExecution } from \"@/types/workflow\";\nimport type { FetchEntityProps } from \"@/types/entityQuery\";\n\nexport type FetchWorkerExecutionProps<\n TData = WorkerExecution,\n TSelected = TData,\n> = FetchEntityProps<TData, TSelected> & {\n workflowId: string;\n workerExecutionId: string;\n workspace: string;\n};\n\n/**\n * useFetchWorkerExecution\n *\n * Fetches one worker execution; `data` is the execution, or whatever `select` makes of it. Idle\n * while an id is empty; fails loudly, without a request, while `workspace` is. A failure is shown as an error alert.\n *\n * @param {FetchWorkerExecutionProps} props - `workflowId`, `workerExecutionId`, `workspace`,\n * `select` and TanStack `queryOptions`.\n * @returns {object} The `useQuery` result, plus `queryKey`.\n */\nexport const useFetchWorkerExecution = <TSelected = WorkerExecution>({\n workflowId,\n workerExecutionId,\n workspace,\n select,\n queryOptions,\n}: FetchWorkerExecutionProps<WorkerExecution, TSelected>) => {\n const { api } = useAxios();\n\n const queryKey = [\"worker_execution\", workflowId, workerExecutionId, workspace];\n\n const query = useEntityQuery<WorkerExecution, TSelected>({\n queryKey,\n fetchEntity: (signal) =>\n getWorkerExecution(api, workflowId, workerExecutionId, workspace, signal),\n select,\n enabled: Boolean(workflowId) && Boolean(workerExecutionId),\n configError: workspace ? undefined : missingWorkspaceError(\"useFetchWorkerExecution\"),\n queryOptions,\n });\n\n return { ...query, queryKey };\n};\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAa,2BAAwD,EACjE,YACA,mBACA,WACA,QACA,mBACyD;CACzD,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,WAAW;EAAC;EAAoB;EAAY;EAAmB;CAAS;CAY9E,OAAO;EAAE,GAVK,eAA2C;GACrD;GACA,cAAc,WACV,mBAAmB,KAAK,YAAY,mBAAmB,WAAW,MAAM;GAC5E;GACA,SAAS,QAAQ,UAAU,KAAK,QAAQ,iBAAiB;GACzD,aAAa,YAAY,KAAA,IAAY,sBAAsB,yBAAyB;GACpF;EACJ,CAEY;EAAO;CAAS;AAChC"}