@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,47 @@
1
+ //#region src/agGrid/handleRowsScrollEnd.ts
2
+ /**
3
+ * handleRowsScrollEnd
4
+ *
5
+ * Requests the next page when an AG Grid is scrolled near its last row, or shows none — the
6
+ * grid paging on demand. The handler for what MUI X DataGrid calls `onRowsScrollEnd`; wire it
7
+ * to AG Grid's `onBodyScrollEnd` and `onModelUpdated`, the second so that a grid whose rows a
8
+ * client-side filter hid entirely keeps loading.
9
+ *
10
+ * A function, not part of any hook: the data hook does not know a grid exists, and the grid
11
+ * does not know where its rows come from. It lives in this subpath because it needs `GridApi`,
12
+ * and AG Grid is an optional peer.
13
+ *
14
+ * Events fire in bursts, before `isFetchingNextPage` has flipped, so the request is made with
15
+ * `cancelRefetch: false`: TanStack then ignores a repeat while the first one is in flight,
16
+ * instead of cancelling it and asking for the same page again.
17
+ *
18
+ * @param {GridApi} gridApi - The grid, from the event (`event.api`).
19
+ * @param {InfiniteQueryPaging} query - The infinite query feeding the grid.
20
+ * @param {HandleRowsScrollEndOptions} [options] - `scrollEndThreshold`, in pixels (default 80).
21
+ *
22
+ * Example:
23
+ * ```tsx
24
+ * const { query } = useFetchDatastores({ filters, select: toRows });
25
+ *
26
+ * <AgGridReact
27
+ * rowData={query.data}
28
+ * onBodyScrollEnd={(event) => handleRowsScrollEnd(event.api, query)}
29
+ * onModelUpdated={(event) => handleRowsScrollEnd(event.api, query)}
30
+ * />
31
+ * ```
32
+ */
33
+ var handleRowsScrollEnd = (gridApi, query, { scrollEndThreshold = 80 } = {}) => {
34
+ if (!query.hasNextPage || query.isFetchingNextPage) return;
35
+ const rowCount = gridApi.getDisplayedRowCount();
36
+ const lastRow = rowCount > 0 ? gridApi.getDisplayedRowAtIndex(rowCount - 1) : void 0;
37
+ if (lastRow) {
38
+ const rowsEnd = (lastRow.rowTop ?? 0) + (lastRow.rowHeight ?? 0);
39
+ const { bottom } = gridApi.getVerticalPixelRange();
40
+ if (rowsEnd - bottom > scrollEndThreshold) return;
41
+ }
42
+ query.fetchNextPage({ cancelRefetch: false });
43
+ };
44
+ //#endregion
45
+ export { handleRowsScrollEnd };
46
+
47
+ //# sourceMappingURL=handleRowsScrollEnd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleRowsScrollEnd.js","names":[],"sources":["../../src/agGrid/handleRowsScrollEnd.ts"],"sourcesContent":["import type { GridApi } from \"ag-grid-community\";\n\n/**\n * The part of an infinite query this needs. Structural, so it takes any list hook's `query`,\n * or a `useInfiniteQuery` an app writes itself.\n */\nexport type InfiniteQueryPaging = {\n hasNextPage: boolean;\n isFetchingNextPage: boolean;\n fetchNextPage: (options?: { cancelRefetch?: boolean }) => Promise<unknown>;\n};\n\nexport type HandleRowsScrollEndOptions = {\n /**\n * Distance in pixels from the end of the rows at which the next page is requested. Named and\n * measured as MUI X DataGrid's `scrollEndThreshold`, whose default it shares. Pixels rather\n * than rows, so it holds with rows of different heights.\n */\n scrollEndThreshold?: number;\n};\n\n/**\n * handleRowsScrollEnd\n *\n * Requests the next page when an AG Grid is scrolled near its last row, or shows none — the\n * grid paging on demand. The handler for what MUI X DataGrid calls `onRowsScrollEnd`; wire it\n * to AG Grid's `onBodyScrollEnd` and `onModelUpdated`, the second so that a grid whose rows a\n * client-side filter hid entirely keeps loading.\n *\n * A function, not part of any hook: the data hook does not know a grid exists, and the grid\n * does not know where its rows come from. It lives in this subpath because it needs `GridApi`,\n * and AG Grid is an optional peer.\n *\n * Events fire in bursts, before `isFetchingNextPage` has flipped, so the request is made with\n * `cancelRefetch: false`: TanStack then ignores a repeat while the first one is in flight,\n * instead of cancelling it and asking for the same page again.\n *\n * @param {GridApi} gridApi - The grid, from the event (`event.api`).\n * @param {InfiniteQueryPaging} query - The infinite query feeding the grid.\n * @param {HandleRowsScrollEndOptions} [options] - `scrollEndThreshold`, in pixels (default 80).\n *\n * Example:\n * ```tsx\n * const { query } = useFetchDatastores({ filters, select: toRows });\n *\n * <AgGridReact\n * rowData={query.data}\n * onBodyScrollEnd={(event) => handleRowsScrollEnd(event.api, query)}\n * onModelUpdated={(event) => handleRowsScrollEnd(event.api, query)}\n * />\n * ```\n */\nexport const handleRowsScrollEnd = (\n gridApi: GridApi,\n query: InfiniteQueryPaging,\n { scrollEndThreshold = 80 }: HandleRowsScrollEndOptions = {},\n): void => {\n if (!query.hasNextPage || query.isFetchingNextPage) return;\n\n const rowCount = gridApi.getDisplayedRowCount();\n const lastRow = rowCount > 0 ? gridApi.getDisplayedRowAtIndex(rowCount - 1) : undefined;\n\n if (lastRow) {\n const rowsEnd = (lastRow.rowTop ?? 0) + (lastRow.rowHeight ?? 0);\n const { bottom } = gridApi.getVerticalPixelRange();\n\n if (rowsEnd - bottom > scrollEndThreshold) return;\n }\n\n void query.fetchNextPage({ cancelRefetch: false });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,uBACT,SACA,OACA,EAAE,qBAAqB,OAAmC,CAAC,MACpD;CACP,IAAI,CAAC,MAAM,eAAe,MAAM,oBAAoB;CAEpD,MAAM,WAAW,QAAQ,qBAAqB;CAC9C,MAAM,UAAU,WAAW,IAAI,QAAQ,uBAAuB,WAAW,CAAC,IAAI,KAAA;CAE9E,IAAI,SAAS;EACT,MAAM,WAAW,QAAQ,UAAU,MAAM,QAAQ,aAAa;EAC9D,MAAM,EAAE,WAAW,QAAQ,sBAAsB;EAEjD,IAAI,UAAU,SAAS,oBAAoB;CAC/C;CAEA,MAAW,cAAc,EAAE,eAAe,MAAM,CAAC;AACrD"}
@@ -1,4 +1,6 @@
1
1
  export { setAgGridLicense, AgGridLicenseProvider } from "../contexts/agGridLicenseContext/provider.js";
2
2
  export type { AgGridLicenseProviderProps } from "../contexts/agGridLicenseContext/provider.js";
3
3
  export { getAgGridTheme, useAgGridTheme, agGridThemeParams } from "./agGridTheme";
4
+ export { handleRowsScrollEnd } from "./handleRowsScrollEnd";
5
+ export type { HandleRowsScrollEndOptions, InfiniteQueryPaging } from "./handleRowsScrollEnd";
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agGrid/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACnG,YAAY,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAE3F,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agGrid/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACnG,YAAY,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAE3F,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  import { AgGridLicenseProvider, setAgGridLicense } from "../contexts/agGridLicenseContext/provider.js";
2
2
  import { agGridThemeParams, getAgGridTheme, useAgGridTheme } from "./agGridTheme.js";
3
- export { AgGridLicenseProvider, agGridThemeParams, getAgGridTheme, setAgGridLicense, useAgGridTheme };
3
+ import { handleRowsScrollEnd } from "./handleRowsScrollEnd.js";
4
+ export { AgGridLicenseProvider, agGridThemeParams, getAgGridTheme, handleRowsScrollEnd, setAgGridLicense, useAgGridTheme };
@@ -1,5 +1,5 @@
1
- import { type AxiosInstance } from "axios";
2
- import type { DeleteEntityDefaultResponse, QueryObject } from "../types/entityQuery.d.ts";
1
+ import type { AxiosInstance } from "axios";
2
+ import type { DeletedEntity, QueryObject } from "../types/entityQuery.d.ts";
3
3
  import type { Datastore, DatastoreListResponse } from "../types/datastore.d.ts";
4
4
  /**
5
5
  * getDatastore
@@ -9,24 +9,26 @@ import type { Datastore, DatastoreListResponse } from "../types/datastore.d.ts";
9
9
  * @param {AxiosInstance} api - Axios instance.
10
10
  * @param {string} id - Datastore identifier.
11
11
  * @param {string} workspace - Workspace the datastore belongs to.
12
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
12
13
  * @returns {Promise<Datastore>} The fetched datastore.
13
14
  *
14
15
  * @throws {Error} If the request fails.
15
16
  */
16
- export declare const getDatastore: (api: AxiosInstance, id: string, workspace: string) => Promise<Datastore>;
17
+ export declare const getDatastore: (api: AxiosInstance, id: string, workspace: string, signal?: AbortSignal) => Promise<Datastore>;
17
18
  /**
18
19
  * listDatastores
19
20
  *
20
21
  * Fetches a list of datastores using a query object (filters, order, pagination, etc.).
21
22
  *
22
23
  * @param {AxiosInstance} api - Axios instance.
23
- * @param {AnyRecord} query - Query object built via `buildQueryObject`.
24
+ * @param {QueryObject} query - Query object built via `buildQueryObject`.
25
+ * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
24
26
  * @returns {Promise<DatastoreListResponse>} Paginated list of datastores.
25
27
  *
26
- * @throws {Error} If workspace filter is missing.
28
+ * @throws {Error} If the query has no workspace filter.
27
29
  * @throws {Error} If the request fails.
28
30
  */
29
- export declare const listDatastores: (api: AxiosInstance, query: QueryObject) => Promise<DatastoreListResponse>;
31
+ export declare const listDatastores: (api: AxiosInstance, query: QueryObject, signal?: AbortSignal) => Promise<DatastoreListResponse>;
30
32
  /**
31
33
  * createDatastore
32
34
  *
@@ -60,9 +62,9 @@ export declare const updateDatastore: (api: AxiosInstance, id: string, data: Par
60
62
  * @param {AxiosInstance} api - Axios instance.
61
63
  * @param {string} id - Datastore identifier.
62
64
  * @param {string} workspace - Workspace the datastore belongs to.
63
- * @returns {Promise<DeleteEntityDefaultResponse[]>} List of deleted entity records.
65
+ * @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.
64
66
  *
65
67
  * @throws {Error} If the request fails.
66
68
  */
67
- export declare const deleteDatastore: (api: AxiosInstance, id: string, workspace: string) => Promise<DeleteEntityDefaultResponse[]>;
69
+ export declare const deleteDatastore: (api: AxiosInstance, id: string, workspace: string) => Promise<DeletedEntity>;
68
70
  //# sourceMappingURL=datastore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"datastore.d.ts","sourceRoot":"","sources":["../../src/api/datastore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAsB,MAAM,OAAO,CAAC;AAG7E,OAAO,KAAK,EAAE,2BAA2B,EAAoB,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACtG,OAAO,KAAK,EAAE,SAAS,EAA2B,qBAAqB,EAA2B,MAAM,mBAAmB,CAAC;AAI5H;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAU,KAAK,aAAa,EAAE,IAAI,MAAM,EAAE,WAAW,MAAM,KAAG,OAAO,CAAC,SAAS,CAmBvG,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAAU,KAAK,aAAa,EAAE,OAAO,WAAW,KAAG,OAAO,CAAC,qBAAqB,CAyB1G,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAAU,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,KAAG,OAAO,CAAC,SAAS,CAmBrG,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAU,KAAK,aAAa,EAAE,IAAI,MAAM,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,KAAG,OAAO,CAAC,SAAS,CAmBjH,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAU,KAAK,aAAa,EAAE,IAAI,MAAM,EAAE,WAAW,MAAM,KAAG,OAAO,CAAC,2BAA2B,EAAE,CAiB9H,CAAC"}
1
+ {"version":3,"file":"datastore.d.ts","sourceRoot":"","sources":["../../src/api/datastore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EACR,aAAa,EAGb,WAAW,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAS1E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GACrB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,WAAW,MAAM,EACjB,SAAS,WAAW,KACrB,OAAO,CAAC,SAAS,CASnB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GACvB,KAAK,aAAa,EAClB,OAAO,WAAW,EAClB,SAAS,WAAW,KACrB,OAAO,CAAC,qBAAqB,CAO/B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GACxB,KAAK,aAAa,EAClB,MAAM,OAAO,CAAC,SAAS,CAAC,KACzB,OAAO,CAAC,SAAS,CAQnB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GACxB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,MAAM,OAAO,CAAC,SAAS,CAAC,KACzB,OAAO,CAAC,SAAS,CAQnB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GACxB,KAAK,aAAa,EAClB,IAAI,MAAM,EACV,WAAW,MAAM,KAClB,OAAO,CAAC,aAAa,CAQvB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { isAxiosError } from "axios";
1
+ import { listParams, request, requireWorkspace } from "./request.js";
2
2
  //#region src/api/datastore.ts
3
3
  var baseUrl = "datastores";
4
4
  /**
@@ -9,20 +9,17 @@ var baseUrl = "datastores";
9
9
  * @param {AxiosInstance} api - Axios instance.
10
10
  * @param {string} id - Datastore identifier.
11
11
  * @param {string} workspace - Workspace the datastore belongs to.
12
+ * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.
12
13
  * @returns {Promise<Datastore>} The fetched datastore.
13
14
  *
14
15
  * @throws {Error} If the request fails.
15
16
  */
16
- var getDatastore = async (api, id, workspace) => {
17
- const params = { workspace };
18
- if (!workspace) throw new Error("Workspace filter is required to fetch a datastore");
19
- try {
20
- return (await api.get(`${baseUrl}/${id}`, { params })).data.datastore;
21
- } catch (error) {
22
- if (isAxiosError(error)) throw new Error(error.message || "Error fetching datastore", { cause: error });
23
- if (error instanceof Error) throw error;
24
- throw new Error("Error fetching datastore", { cause: error });
25
- }
17
+ var getDatastore = async (api, id, workspace, signal) => {
18
+ requireWorkspace(workspace, "fetch a datastore");
19
+ return (await request(() => api.get(`${baseUrl}/${id}`, {
20
+ params: { workspace },
21
+ signal
22
+ }), "Error fetching datastore")).datastore;
26
23
  };
27
24
  /**
28
25
  * listDatastores
@@ -30,27 +27,19 @@ var getDatastore = async (api, id, workspace) => {
30
27
  * Fetches a list of datastores using a query object (filters, order, pagination, etc.).
31
28
  *
32
29
  * @param {AxiosInstance} api - Axios instance.
33
- * @param {AnyRecord} query - Query object built via `buildQueryObject`.
30
+ * @param {QueryObject} query - Query object built via `buildQueryObject`.
31
+ * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.
34
32
  * @returns {Promise<DatastoreListResponse>} Paginated list of datastores.
35
33
  *
36
- * @throws {Error} If workspace filter is missing.
34
+ * @throws {Error} If the query has no workspace filter.
37
35
  * @throws {Error} If the request fails.
38
36
  */
39
- var listDatastores = async (api, query) => {
40
- const workspaceFilter = query.filters.find((filter) => filter[0] === "workspace");
41
- const workspace = workspaceFilter?.[workspaceFilter.length - 1];
42
- if (!workspace) throw new Error("Workspace filter is required to list datastores");
43
- const params = {
44
- workspace,
45
- ...query ? { query: JSON.stringify(query) } : {}
46
- };
47
- try {
48
- return (await api.get(baseUrl, { params })).data;
49
- } catch (error) {
50
- if (isAxiosError(error)) throw new Error(error.message || "Error listing datastores", { cause: error });
51
- if (error instanceof Error) throw error;
52
- throw new Error("Error listing datastores", { cause: error });
53
- }
37
+ var listDatastores = async (api, query, signal) => {
38
+ const params = listParams(query, "list datastores");
39
+ return request(() => api.get(baseUrl, {
40
+ params,
41
+ signal
42
+ }), "Error listing datastores");
54
43
  };
55
44
  /**
56
45
  * createDatastore
@@ -64,15 +53,8 @@ var listDatastores = async (api, query) => {
64
53
  * @throws {Error} If the request fails.
65
54
  */
66
55
  var createDatastore = async (api, data) => {
67
- const { workspace } = data;
68
- if (!workspace) throw new Error("Workspace filter is required to create a datastore");
69
- try {
70
- return (await api.post(baseUrl, data)).data.datastore;
71
- } catch (error) {
72
- if (isAxiosError(error)) throw new Error(error.message || "Error creating datastore", { cause: error });
73
- if (error instanceof Error) throw error;
74
- throw new Error("Error creating datastore", { cause: error });
75
- }
56
+ requireWorkspace(data.workspace, "create a datastore");
57
+ return (await request(() => api.post(baseUrl, data), "Error creating datastore")).datastore;
76
58
  };
77
59
  /**
78
60
  * updateDatastore
@@ -87,15 +69,8 @@ var createDatastore = async (api, data) => {
87
69
  * @throws {Error} If the request fails.
88
70
  */
89
71
  var updateDatastore = async (api, id, data) => {
90
- const { workspace } = data;
91
- if (!workspace) throw new Error("Workspace filter is required to update a datastore");
92
- try {
93
- return (await api.put(`${baseUrl}/${id}`, data)).data.datastore;
94
- } catch (error) {
95
- if (isAxiosError(error)) throw new Error(error.message || "Error updating datastore", { cause: error });
96
- if (error instanceof Error) throw error;
97
- throw new Error("Error updating datastore", { cause: error });
98
- }
72
+ requireWorkspace(data.workspace, "update a datastore");
73
+ return (await request(() => api.put(`${baseUrl}/${id}`, data), "Error updating datastore")).datastore;
99
74
  };
100
75
  /**
101
76
  * deleteDatastore
@@ -105,19 +80,13 @@ var updateDatastore = async (api, id, data) => {
105
80
  * @param {AxiosInstance} api - Axios instance.
106
81
  * @param {string} id - Datastore identifier.
107
82
  * @param {string} workspace - Workspace the datastore belongs to.
108
- * @returns {Promise<DeleteEntityDefaultResponse[]>} List of deleted entity records.
83
+ * @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.
109
84
  *
110
85
  * @throws {Error} If the request fails.
111
86
  */
112
87
  var deleteDatastore = async (api, id, workspace) => {
113
- const params = { workspace };
114
- try {
115
- return (await api.delete(`${baseUrl}/${id}`, { params })).data.datastores;
116
- } catch (error) {
117
- if (isAxiosError(error)) throw new Error(error.message || "Error removing datastore", { cause: error });
118
- if (error instanceof Error) throw error;
119
- throw new Error("Error removing datastore", { cause: error });
120
- }
88
+ requireWorkspace(workspace, "delete a datastore");
89
+ return (await request(() => api.delete(`${baseUrl}/${id}`, { params: { workspace } }), "Error deleting datastore")).datastore;
121
90
  };
122
91
  //#endregion
123
92
  export { createDatastore, deleteDatastore, getDatastore, listDatastores, updateDatastore };
@@ -1 +1 @@
1
- {"version":3,"file":"datastore.js","names":[],"sources":["../../src/api/datastore.ts"],"sourcesContent":["import { isAxiosError, type AxiosInstance, type AxiosResponse } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { DeleteEntityDefaultResponse, FilterExpression, QueryObject } from \"@/types/entityQuery\";\nimport type { Datastore, DatastoreSingleResponse, DatastoreListResponse, DeleteDatastoreResponse } from \"@/types/datastore\";\n\nconst baseUrl = \"datastores\";\n\n/**\n * getDatastore\n *\n * Fetches a single datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {string} workspace - Workspace the datastore belongs to.\n * @returns {Promise<Datastore>} The fetched datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const getDatastore = async (api: AxiosInstance, id: string, workspace: string): Promise<Datastore> => {\n const params: AnyRecord = { workspace };\n\n if (!workspace) throw new Error(\"Workspace filter is required to fetch a datastore\");\n\n try {\n const response: AxiosResponse<DatastoreSingleResponse> = await api.get(`${baseUrl}/${id}`, { params });\n return response.data.datastore;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error fetching datastore\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error fetching datastore\", { cause: error });\n }\n};\n\n/**\n * listDatastores\n *\n * Fetches a list of datastores using a query object (filters, order, pagination, etc.).\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {AnyRecord} query - Query object built via `buildQueryObject`.\n * @returns {Promise<DatastoreListResponse>} Paginated list of datastores.\n *\n * @throws {Error} If workspace filter is missing.\n * @throws {Error} If the request fails.\n */\nexport const listDatastores = async (api: AxiosInstance, query: QueryObject): Promise<DatastoreListResponse> => {\n const workspaceFilter = query.filters.find((filter: FilterExpression) => filter[0] === \"workspace\");\n const workspace = workspaceFilter?.[workspaceFilter.length - 1];\n\n if (!workspace) throw new Error(\"Workspace filter is required to list datastores\");\n\n const params: AnyRecord = {\n workspace,\n ...(query ? { query: JSON.stringify(query) } : {}),\n };\n\n try {\n const response: AxiosResponse<DatastoreListResponse> = await api.get(baseUrl, { params });\n return response.data;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error listing datastores\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error listing datastores\", { cause: error });\n }\n};\n\n/**\n * createDatastore\n *\n * Creates a new datastore.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {Partial<Datastore>} data - Datastore payload.\n * @returns {Promise<Datastore>} The created datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const createDatastore = async (api: AxiosInstance, data: Partial<Datastore>): Promise<Datastore> => {\n\n const { workspace } = data;\n if (!workspace) throw new Error(\"Workspace filter is required to create a datastore\");\n\n try {\n const response: AxiosResponse<DatastoreSingleResponse> = await api.post(baseUrl, data);\n return response.data.datastore;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error creating datastore\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error creating datastore\", { cause: error });\n }\n};\n\n/**\n * updateDatastore\n *\n * Updates an existing datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {Partial<Datastore>} data - Fields to update.\n * @returns {Promise<Datastore>} The updated datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const updateDatastore = async (api: AxiosInstance, id: string, data: Partial<Datastore>): Promise<Datastore> => {\n\n const { workspace } = data;\n if (!workspace) throw new Error(\"Workspace filter is required to update a datastore\");\n\n try {\n const response: AxiosResponse<DatastoreSingleResponse> = await api.put(`${baseUrl}/${id}`, data);\n return response.data.datastore;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error updating datastore\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error updating datastore\", { cause: error });\n }\n};\n\n/**\n * deleteDatastore\n *\n * Deletes a datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {string} workspace - Workspace the datastore belongs to.\n * @returns {Promise<DeleteEntityDefaultResponse[]>} List of deleted entity records.\n *\n * @throws {Error} If the request fails.\n */\nexport const deleteDatastore = async (api: AxiosInstance, id: string, workspace: string): Promise<DeleteEntityDefaultResponse[]> => {\n const params: AnyRecord = { workspace };\n\n try {\n const response: AxiosResponse<DeleteDatastoreResponse> = await api.delete(`${baseUrl}/${id}`, { params });\n return response.data.datastores;\n } catch (error: unknown) {\n if (isAxiosError<AnyRecord>(error)) {\n throw new Error(error.message || \"Error removing datastore\", { cause: error });\n }\n\n if (error instanceof Error) {\n throw error;\n }\n\n throw new Error(\"Error removing datastore\", { cause: error });\n }\n};"],"mappings":";;AAMA,IAAM,UAAU;;;;;;;;;;;;;AAchB,IAAa,eAAe,OAAO,KAAoB,IAAY,cAA0C;CAC3G,MAAM,SAAoB,EAAE,UAAU;CAEtC,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,mDAAmD;CAEnF,IAAI;EAEF,QAAO,MADwD,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,EAAA,CACrF,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,4BAA4B,EAAE,OAAO,MAAM,CAAC;EAG/E,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,4BAA4B,EAAE,OAAO,MAAM,CAAC;CAC9D;AACF;;;;;;;;;;;;;AAcA,IAAa,iBAAiB,OAAO,KAAoB,UAAuD;CAC9G,MAAM,kBAAkB,MAAM,QAAQ,MAAM,WAA6B,OAAO,OAAO,WAAW;CAClG,MAAM,YAAY,kBAAkB,gBAAgB,SAAS;CAE7D,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,iDAAiD;CAEjF,MAAM,SAAoB;EACxB;EACA,GAAI,QAAQ,EAAE,OAAO,KAAK,UAAU,KAAK,EAAE,IAAI,CAAC;CAClD;CAEA,IAAI;EAEF,QAAO,MADsD,IAAI,IAAI,SAAS,EAAE,OAAO,CAAC,EAAA,CACxE;CAClB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,4BAA4B,EAAE,OAAO,MAAM,CAAC;EAG/E,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,4BAA4B,EAAE,OAAO,MAAM,CAAC;CAC9D;AACF;;;;;;;;;;;;AAaA,IAAa,kBAAkB,OAAO,KAAoB,SAAiD;CAEzG,MAAM,EAAE,cAAc;CACtB,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,oDAAoD;CAEpF,IAAI;EAEF,QAAO,MADwD,IAAI,KAAK,SAAS,IAAI,EAAA,CACrE,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,4BAA4B,EAAE,OAAO,MAAM,CAAC;EAG/E,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,4BAA4B,EAAE,OAAO,MAAM,CAAC;CAC9D;AACF;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAAO,KAAoB,IAAY,SAAiD;CAErH,MAAM,EAAE,cAAc;CACtB,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,oDAAoD;CAEpF,IAAI;EAEF,QAAO,MADwD,IAAI,IAAI,GAAG,QAAQ,GAAG,MAAM,IAAI,EAAA,CAC/E,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,4BAA4B,EAAE,OAAO,MAAM,CAAC;EAG/E,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,4BAA4B,EAAE,OAAO,MAAM,CAAC;CAC9D;AACF;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAAO,KAAoB,IAAY,cAA8D;CAClI,MAAM,SAAoB,EAAE,UAAU;CAEtC,IAAI;EAEF,QAAO,MADwD,IAAI,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,EAAA,CACxF,KAAK;CACvB,SAAS,OAAgB;EACvB,IAAI,aAAwB,KAAK,GAC/B,MAAM,IAAI,MAAM,MAAM,WAAW,4BAA4B,EAAE,OAAO,MAAM,CAAC;EAG/E,IAAI,iBAAiB,OACnB,MAAM;EAGR,MAAM,IAAI,MAAM,4BAA4B,EAAE,OAAO,MAAM,CAAC;CAC9D;AACF"}
1
+ {"version":3,"file":"datastore.js","names":[],"sources":["../../src/api/datastore.ts"],"sourcesContent":["import type { AxiosInstance } from \"axios\";\n\nimport type {\n DeletedEntity,\n DeleteEntityResponse,\n EntitySingleResponse,\n QueryObject,\n} from \"@/types/entityQuery\";\nimport type { Datastore, DatastoreListResponse } from \"@/types/datastore\";\nimport { listParams, request, requireWorkspace } from \"./request\";\n\nconst baseUrl = \"datastores\";\n\n/** The endpoint's envelopes, private: every function here returns the entity itself. */\ntype DatastoreSingleResponse = EntitySingleResponse<\"datastore\", Datastore>;\ntype DeleteDatastoreResponse = DeleteEntityResponse<\"datastore\">;\n\n/**\n * getDatastore\n *\n * Fetches a single datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {string} workspace - Workspace the datastore belongs to.\n * @param {AbortSignal} [signal] - Aborts the request itself; the entity hooks pass the query's own.\n * @returns {Promise<Datastore>} The fetched datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const getDatastore = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n signal?: AbortSignal,\n): Promise<Datastore> => {\n requireWorkspace(workspace, \"fetch a datastore\");\n\n const body = await request(\n () =>\n api.get<DatastoreSingleResponse>(`${baseUrl}/${id}`, { params: { workspace }, signal }),\n \"Error fetching datastore\",\n );\n return body.datastore;\n};\n\n/**\n * listDatastores\n *\n * Fetches a list of datastores using a query object (filters, order, pagination, etc.).\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {QueryObject} query - Query object built via `buildQueryObject`.\n * @param {AbortSignal} [signal] - Aborts the request itself; the list hooks pass the query's own.\n * @returns {Promise<DatastoreListResponse>} Paginated list of datastores.\n *\n * @throws {Error} If the query has no workspace filter.\n * @throws {Error} If the request fails.\n */\nexport const listDatastores = async (\n api: AxiosInstance,\n query: QueryObject,\n signal?: AbortSignal,\n): Promise<DatastoreListResponse> => {\n const params = listParams(query, \"list datastores\");\n\n return request(\n () => api.get<DatastoreListResponse>(baseUrl, { params, signal }),\n \"Error listing datastores\",\n );\n};\n\n/**\n * createDatastore\n *\n * Creates a new datastore.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {Partial<Datastore>} data - Datastore payload.\n * @returns {Promise<Datastore>} The created datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const createDatastore = async (\n api: AxiosInstance,\n data: Partial<Datastore>,\n): Promise<Datastore> => {\n requireWorkspace(data.workspace, \"create a datastore\");\n\n const body = await request(\n () => api.post<DatastoreSingleResponse>(baseUrl, data),\n \"Error creating datastore\",\n );\n return body.datastore;\n};\n\n/**\n * updateDatastore\n *\n * Updates an existing datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {Partial<Datastore>} data - Fields to update.\n * @returns {Promise<Datastore>} The updated datastore.\n *\n * @throws {Error} If the request fails.\n */\nexport const updateDatastore = async (\n api: AxiosInstance,\n id: string,\n data: Partial<Datastore>,\n): Promise<Datastore> => {\n requireWorkspace(data.workspace, \"update a datastore\");\n\n const body = await request(\n () => api.put<DatastoreSingleResponse>(`${baseUrl}/${id}`, data),\n \"Error updating datastore\",\n );\n return body.datastore;\n};\n\n/**\n * deleteDatastore\n *\n * Deletes a datastore by ID.\n *\n * @param {AxiosInstance} api - Axios instance.\n * @param {string} id - Datastore identifier.\n * @param {string} workspace - Workspace the datastore belongs to.\n * @returns {Promise<DeletedEntity>} The deletion record: id, name and `deleted`.\n *\n * @throws {Error} If the request fails.\n */\nexport const deleteDatastore = async (\n api: AxiosInstance,\n id: string,\n workspace: string,\n): Promise<DeletedEntity> => {\n requireWorkspace(workspace, \"delete a datastore\");\n\n const body = await request(\n () => api.delete<DeleteDatastoreResponse>(`${baseUrl}/${id}`, { params: { workspace } }),\n \"Error deleting datastore\",\n );\n return body.datastore;\n};\n"],"mappings":";;AAWA,IAAM,UAAU;;;;;;;;;;;;;;AAmBhB,IAAa,eAAe,OACxB,KACA,IACA,WACA,WACqB;CACrB,iBAAiB,WAAW,mBAAmB;CAO/C,QAAO,MALY,cAEX,IAAI,IAA6B,GAAG,QAAQ,GAAG,MAAM;EAAE,QAAQ,EAAE,UAAU;EAAG;CAAO,CAAC,GAC1F,0BACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;;AAeA,IAAa,iBAAiB,OAC1B,KACA,OACA,WACiC;CACjC,MAAM,SAAS,WAAW,OAAO,iBAAiB;CAElD,OAAO,cACG,IAAI,IAA2B,SAAS;EAAE;EAAQ;CAAO,CAAC,GAChE,0BACJ;AACJ;;;;;;;;;;;;AAaA,IAAa,kBAAkB,OAC3B,KACA,SACqB;CACrB,iBAAiB,KAAK,WAAW,oBAAoB;CAMrD,QAAO,MAJY,cACT,IAAI,KAA8B,SAAS,IAAI,GACrD,0BACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAC3B,KACA,IACA,SACqB;CACrB,iBAAiB,KAAK,WAAW,oBAAoB;CAMrD,QAAO,MAJY,cACT,IAAI,IAA6B,GAAG,QAAQ,GAAG,MAAM,IAAI,GAC/D,0BACJ,EAAA,CACY;AAChB;;;;;;;;;;;;;AAcA,IAAa,kBAAkB,OAC3B,KACA,IACA,cACyB;CACzB,iBAAiB,WAAW,oBAAoB;CAMhD,QAAO,MAJY,cACT,IAAI,OAAgC,GAAG,QAAQ,GAAG,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,GACvF,0BACJ,EAAA,CACY;AAChB"}
@@ -1,4 +1,4 @@
1
- import type { FilterClause, FilterExpression, EntityQueryParams, QueryObject } from "../types/entityQuery.d.ts";
1
+ import type { FilterClause, FilterExpression, EntityQueryParams, Projection, QueryObject } from "../types/entityQuery.d.ts";
2
2
  /**
3
3
  * toFilterTuple
4
4
  *
@@ -21,58 +21,63 @@ import type { FilterClause, FilterExpression, EntityQueryParams, QueryObject } f
21
21
  * ```
22
22
  */
23
23
  export declare const toFilterTuple: (filter: FilterClause) => FilterExpression;
24
+ export declare const buildQueryObject: (params: EntityQueryParams) => QueryObject;
25
+ /** What, besides the filters, changes the response a list read gets back. */
26
+ export type QueryKeyParams = {
27
+ order?: string[];
28
+ projection?: Projection;
29
+ pageSize?: number;
30
+ fetchAllPages?: boolean;
31
+ /** The datastore hooks' `dataFormat`. In the key whenever a hook passes it; only those hooks do. */
32
+ dataFormat?: "object" | "matrix";
33
+ };
24
34
  /**
25
- * buildQueryObject
35
+ * buildQueryKey
26
36
  *
27
- * Builds the query payload object to be sent to the API,
28
- * converting filters, ordering, pagination, and projection into the expected format.
37
+ * Builds the React Query cache key of a list read: the base keys, then one object holding
38
+ * everything that changes the response.
29
39
  *
30
- * @param {EntityQueryParams} params - Query parameters.
31
- * @param {FilterClause[]} params.filters - Filters to apply (converted via `toFilterTuple`).
32
- * @param {string[]} params.order - Sorting fields.
33
- * @param {number} [params.pageSize] - Number of items per page.
34
- * @param {string} [params.pageToken] - Cursor token for the next page.
35
- * @param {string} [params.projection] - Single field to project. `"field"` returns only that
36
- * field (every other field comes back null); `"-field"` returns all fields except that one.
37
- * One field only — comma/space lists return a 500. Omitted from payload if empty.
38
- * @returns {QueryObject} Query payload ready to be passed to the API.
40
+ * Every part of the request is in the key, not only the filter values. The key used to be
41
+ * `[...keys, ...values]`, so a `-data` metadata read and a full read of the same workspace,
42
+ * or `date = X` and `date >= X`, shared one cache entry and one of them rendered the other's
43
+ * data. Filters go in as the tuples the API receives, so field and operator are included.
44
+ *
45
+ * The base keys stay in front, so prefix invalidation keeps working:
46
+ * `invalidateQueries({ queryKey: ["workflow_executions", workflowId] })`.
47
+ *
48
+ * @param {(string | number | null)[]} keys - Base keys (entity name, then any ids).
49
+ * @param {FilterClause[]} filters - The filters of the read.
50
+ * @param {QueryKeyParams} [params] - Order, projection, page size and paging mode.
51
+ * @returns {unknown[]} Cache key array for use in `queryKey`.
39
52
  *
40
53
  * Example:
41
54
  * ```ts
42
- * buildQueryObject({
43
- * filters: [{ field: "workspace", value: "ws-1" }],
44
- * order: ["name"], // plain field name(s) only — no "asc"/"desc" suffix
45
- * pageSize: 10,
46
- * pageToken: "token-abc",
47
- * projection: "name",
48
- * });
49
- * // -> {
50
- * // filters: [["workspace", "ws-1"]],
51
- * // order: ["name"],
52
- * // projection: "name",
53
- * // page_size: 10,
54
- * // page_token: "token-abc",
55
- * // }
55
+ * buildQueryKey(["datastores"], [{ field: "workspace", value: "ws-1" }], { pageSize: 10 });
56
+ * // -> ["datastores", { filters: [["workspace", "ws-1"]], pageSize: 10 }]
56
57
  * ```
57
58
  */
58
- export declare const buildQueryObject: (params: EntityQueryParams) => QueryObject;
59
+ export declare const buildQueryKey: (keys: (string | number | null)[], filters: FilterClause[], { order, projection, pageSize, fetchAllPages, dataFormat }?: QueryKeyParams) => unknown[];
59
60
  /**
60
- * buildQueryKey
61
+ * hasWorkspaceFilter
61
62
  *
62
- * Builds a stable React Query cache key by combining a base key array
63
- * with the values of the provided filters.
63
+ * Whether a read can be sent: every endpoint that takes filters rejects a request with no
64
+ * workspace. It reads the workspace through `workspaceOf`, as the list functions in `api/` do:
65
+ * while each read it its own way, it passed on a filter the request then ignored.
64
66
  *
65
- * This ensures the query is re-executed whenever filter values change.
67
+ * @param {FilterClause[]} filters - The filters of the read.
68
+ * @returns {boolean} True when the first `workspace` filter carries a value.
69
+ */
70
+ export declare const hasWorkspaceFilter: (filters: FilterClause[]) => boolean;
71
+ /**
72
+ * missingWorkspaceError
66
73
  *
67
- * @param {(string | number)[]} keys - Base keys (e.g. entity name, id).
68
- * @param {FilterClause[]} filters - Filters whose values are appended to the key.
69
- * @returns {unknown[]} Cache key array for use in `queryKey`.
74
+ * The reason a hook gives, as `configError`, when it has no workspace to read. A missing
75
+ * workspace is a misconfigured app, never a state to wait out: the app config is merged into
76
+ * `window.APP_CONFIG` before the app renders, so an empty value there is a wrong or misspelled
77
+ * key. The message names the hook, so it points at the call to fix.
70
78
  *
71
- * Example:
72
- * ```ts
73
- * buildQueryKey(["datastores"], [{ field: "workspace", value: "ws-1" }]);
74
- * // -> ["datastores", "ws-1"]
75
- * ```
79
+ * @param {string} hookName - The hook that could not send its request.
80
+ * @returns {string} The error message.
76
81
  */
77
- export declare const buildQueryKey: (keys: (string | number)[], filters: FilterClause[]) => unknown[];
82
+ export declare const missingWorkspaceError: (hookName: string) => string;
78
83
  //# sourceMappingURL=entityQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entityQuery.d.ts","sourceRoot":"","sources":["../../src/api/entityQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE1G;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,YAAY,KAAG,gBAMpD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,iBAAiB,KAAG,WAU5D,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,YAAY,EAAE,KAAG,OAAO,EAKzF,CAAA"}
1
+ {"version":3,"file":"entityQuery.d.ts","sourceRoot":"","sources":["../../src/api/entityQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,WAAW,EACd,MAAM,qBAAqB,CAAC;AAG7B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,YAAY,KAAG,gBAMpD,CAAC;AAyCF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,iBAAiB,KAAG,WAU5D,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,cAAc,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oGAAoG;IACpG,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,aAAa,GACtB,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,EAChC,SAAS,YAAY,EAAE,EACvB,6DAA4D,cAAmB,KAChF,OAAO,EAaT,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,YAAY,EAAE,KAAG,OACT,CAAC;AAErD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,MAED,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { workspaceOf } from "./request.js";
1
2
  //#region src/api/entityQuery.ts
2
3
  /**
3
4
  * toFilterTuple
@@ -40,9 +41,10 @@ var toFilterTuple = (filter) => {
40
41
  * @param {string[]} params.order - Sorting fields.
41
42
  * @param {number} [params.pageSize] - Number of items per page.
42
43
  * @param {string} [params.pageToken] - Cursor token for the next page.
43
- * @param {string} [params.projection] - Single field to project. `"field"` returns only that
44
- * field (every other field comes back null); `"-field"` returns all fields except that one.
45
- * One field only — comma/space lists return a 500. Omitted from payload if empty.
44
+ * @param {Projection} [params.projection] - The fields to return: one, or a list. `"field"`
45
+ * returns only that field (every other field comes back null); `"-field"` returns all fields
46
+ * except that one. Pass several as a list, never comma-joined: `"a,b"` is a 500. Omitted from
47
+ * the payload when empty.
46
48
  * @returns {QueryObject} Query payload ready to be passed to the API.
47
49
  *
48
50
  * Example:
@@ -63,12 +65,14 @@ var toFilterTuple = (filter) => {
63
65
  * // }
64
66
  * ```
65
67
  */
68
+ /** An empty string or list asks for every field, as no projection does. */
69
+ var hasProjection = (projection) => projection !== void 0 && projection.length > 0;
66
70
  var buildQueryObject = (params) => {
67
71
  const { filters, pageSize, pageToken, order, projection } = params;
68
72
  return {
69
73
  filters: filters.map(toFilterTuple),
70
74
  order,
71
- ...!!projection && { projection },
75
+ ...hasProjection(projection) && { projection },
72
76
  page_size: pageSize,
73
77
  page_token: pageToken
74
78
  };
@@ -76,25 +80,62 @@ var buildQueryObject = (params) => {
76
80
  /**
77
81
  * buildQueryKey
78
82
  *
79
- * Builds a stable React Query cache key by combining a base key array
80
- * with the values of the provided filters.
83
+ * Builds the React Query cache key of a list read: the base keys, then one object holding
84
+ * everything that changes the response.
81
85
  *
82
- * This ensures the query is re-executed whenever filter values change.
86
+ * Every part of the request is in the key, not only the filter values. The key used to be
87
+ * `[...keys, ...values]`, so a `-data` metadata read and a full read of the same workspace,
88
+ * or `date = X` and `date >= X`, shared one cache entry and one of them rendered the other's
89
+ * data. Filters go in as the tuples the API receives, so field and operator are included.
83
90
  *
84
- * @param {(string | number)[]} keys - Base keys (e.g. entity name, id).
85
- * @param {FilterClause[]} filters - Filters whose values are appended to the key.
91
+ * The base keys stay in front, so prefix invalidation keeps working:
92
+ * `invalidateQueries({ queryKey: ["workflow_executions", workflowId] })`.
93
+ *
94
+ * @param {(string | number | null)[]} keys - Base keys (entity name, then any ids).
95
+ * @param {FilterClause[]} filters - The filters of the read.
96
+ * @param {QueryKeyParams} [params] - Order, projection, page size and paging mode.
86
97
  * @returns {unknown[]} Cache key array for use in `queryKey`.
87
98
  *
88
99
  * Example:
89
100
  * ```ts
90
- * buildQueryKey(["datastores"], [{ field: "workspace", value: "ws-1" }]);
91
- * // -> ["datastores", "ws-1"]
101
+ * buildQueryKey(["datastores"], [{ field: "workspace", value: "ws-1" }], { pageSize: 10 });
102
+ * // -> ["datastores", { filters: [["workspace", "ws-1"]], pageSize: 10 }]
92
103
  * ```
93
104
  */
94
- var buildQueryKey = (keys, filters) => {
95
- return [...keys, ...filters.flatMap((filter) => filter.value)];
105
+ var buildQueryKey = (keys, filters, { order, projection, pageSize, fetchAllPages, dataFormat } = {}) => {
106
+ return [...keys, {
107
+ filters: filters.map(toFilterTuple),
108
+ ...order?.length ? { order } : {},
109
+ ...hasProjection(projection) ? { projection } : {},
110
+ ...pageSize !== void 0 ? { pageSize } : {},
111
+ ...fetchAllPages ? { fetchAllPages } : {},
112
+ ...dataFormat ? { dataFormat } : {}
113
+ }];
96
114
  };
115
+ /**
116
+ * hasWorkspaceFilter
117
+ *
118
+ * Whether a read can be sent: every endpoint that takes filters rejects a request with no
119
+ * workspace. It reads the workspace through `workspaceOf`, as the list functions in `api/` do:
120
+ * while each read it its own way, it passed on a filter the request then ignored.
121
+ *
122
+ * @param {FilterClause[]} filters - The filters of the read.
123
+ * @returns {boolean} True when the first `workspace` filter carries a value.
124
+ */
125
+ var hasWorkspaceFilter = (filters) => Boolean(workspaceOf(filters.map(toFilterTuple)));
126
+ /**
127
+ * missingWorkspaceError
128
+ *
129
+ * The reason a hook gives, as `configError`, when it has no workspace to read. A missing
130
+ * workspace is a misconfigured app, never a state to wait out: the app config is merged into
131
+ * `window.APP_CONFIG` before the app renders, so an empty value there is a wrong or misspelled
132
+ * key. The message names the hook, so it points at the call to fix.
133
+ *
134
+ * @param {string} hookName - The hook that could not send its request.
135
+ * @returns {string} The error message.
136
+ */
137
+ var missingWorkspaceError = (hookName) => `[apps-sdk] ${hookName}: the "workspace" filter is missing or empty, so the request was not sent. Check the workspace the app config provides.`;
97
138
  //#endregion
98
- export { buildQueryKey, buildQueryObject, toFilterTuple };
139
+ export { buildQueryKey, buildQueryObject, hasWorkspaceFilter, missingWorkspaceError, toFilterTuple };
99
140
 
100
141
  //# sourceMappingURL=entityQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entityQuery.js","names":[],"sources":["../../src/api/entityQuery.ts"],"sourcesContent":["import type { FilterClause, FilterExpression, EntityQueryParams, QueryObject } from \"@/types/entityQuery\";\n\n/**\n * toFilterTuple\n *\n * Converts a `FilterClause` object into a `FilterExpression` tuple\n * compatible with the API query format.\n *\n * - If no operator is provided or operator is `\"=\"`, returns a 2-tuple `[field, value]`.\n * - Otherwise, returns a 3-tuple `[field, op, value]`.\n *\n * @param {FilterClause} filter - Filter clause to convert.\n * @returns {FilterExpression} Tuple representation of the filter.\n *\n * Examples:\n * ```ts\n * toFilterTuple({ field: \"workspace\", value: \"ws-1\" })\n * // -> [\"workspace\", \"ws-1\"]\n *\n * toFilterTuple({ field: \"age\", op: \">=\", value: 18 })\n * // -> [\"age\", \">=\", 18]\n * ```\n */\nexport const toFilterTuple = (filter: FilterClause): FilterExpression => {\n const { field, op, value } = filter;\n if (!op || op === '=') {\n return [field, value];\n }\n return [field, op, value];\n};\n\n/**\n * buildQueryObject\n *\n * Builds the query payload object to be sent to the API,\n * converting filters, ordering, pagination, and projection into the expected format.\n *\n * @param {EntityQueryParams} params - Query parameters.\n * @param {FilterClause[]} params.filters - Filters to apply (converted via `toFilterTuple`).\n * @param {string[]} params.order - Sorting fields.\n * @param {number} [params.pageSize] - Number of items per page.\n * @param {string} [params.pageToken] - Cursor token for the next page.\n * @param {string} [params.projection] - Single field to project. `\"field\"` returns only that\n * field (every other field comes back null); `\"-field\"` returns all fields except that one.\n * One field only — comma/space lists return a 500. Omitted from payload if empty.\n * @returns {QueryObject} Query payload ready to be passed to the API.\n *\n * Example:\n * ```ts\n * buildQueryObject({\n * filters: [{ field: \"workspace\", value: \"ws-1\" }],\n * order: [\"name\"], // plain field name(s) only — no \"asc\"/\"desc\" suffix\n * pageSize: 10,\n * pageToken: \"token-abc\",\n * projection: \"name\",\n * });\n * // -> {\n * // filters: [[\"workspace\", \"ws-1\"]],\n * // order: [\"name\"],\n * // projection: \"name\",\n * // page_size: 10,\n * // page_token: \"token-abc\",\n * // }\n * ```\n */\nexport const buildQueryObject = (params: EntityQueryParams): QueryObject => {\n const { filters, pageSize, pageToken, order, projection } = params;\n\n return {\n filters: filters.map(toFilterTuple),\n order,\n ...(!!projection && { projection }),\n page_size: pageSize,\n page_token: pageToken,\n };\n}\n\n/**\n * buildQueryKey\n *\n * Builds a stable React Query cache key by combining a base key array\n * with the values of the provided filters.\n *\n * This ensures the query is re-executed whenever filter values change.\n *\n * @param {(string | number)[]} keys - Base keys (e.g. entity name, id).\n * @param {FilterClause[]} filters - Filters whose values are appended to the key.\n * @returns {unknown[]} Cache key array for use in `queryKey`.\n *\n * Example:\n * ```ts\n * buildQueryKey([\"datastores\"], [{ field: \"workspace\", value: \"ws-1\" }]);\n * // -> [\"datastores\", \"ws-1\"]\n * ```\n */\nexport const buildQueryKey = (keys: (string | number)[], filters: FilterClause[]): unknown[] => {\n return [\n ...keys,\n ...filters.flatMap((filter) => filter.value)\n ];\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,iBAAiB,WAA2C;CACrE,MAAM,EAAE,OAAO,IAAI,UAAU;CAC7B,IAAI,CAAC,MAAM,OAAO,KACd,OAAO,CAAC,OAAO,KAAK;CAExB,OAAO;EAAC;EAAO;EAAI;CAAK;AAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAa,oBAAoB,WAA2C;CACxE,MAAM,EAAE,SAAS,UAAU,WAAW,OAAO,eAAe;CAE5D,OAAO;EACH,SAAS,QAAQ,IAAI,aAAa;EAClC;EACA,GAAI,CAAC,CAAC,cAAc,EAAE,WAAW;EACjC,WAAW;EACX,YAAY;CAChB;AACJ;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,iBAAiB,MAA2B,YAAuC;CAC5F,OAAO,CACH,GAAG,MACH,GAAG,QAAQ,SAAS,WAAW,OAAO,KAAK,CAC/C;AACJ"}
1
+ {"version":3,"file":"entityQuery.js","names":[],"sources":["../../src/api/entityQuery.ts"],"sourcesContent":["import type {\n FilterClause,\n FilterExpression,\n EntityQueryParams,\n Projection,\n QueryObject,\n} from \"@/types/entityQuery\";\nimport { workspaceOf } from \"./request\";\n\n/**\n * toFilterTuple\n *\n * Converts a `FilterClause` object into a `FilterExpression` tuple\n * compatible with the API query format.\n *\n * - If no operator is provided or operator is `\"=\"`, returns a 2-tuple `[field, value]`.\n * - Otherwise, returns a 3-tuple `[field, op, value]`.\n *\n * @param {FilterClause} filter - Filter clause to convert.\n * @returns {FilterExpression} Tuple representation of the filter.\n *\n * Examples:\n * ```ts\n * toFilterTuple({ field: \"workspace\", value: \"ws-1\" })\n * // -> [\"workspace\", \"ws-1\"]\n *\n * toFilterTuple({ field: \"age\", op: \">=\", value: 18 })\n * // -> [\"age\", \">=\", 18]\n * ```\n */\nexport const toFilterTuple = (filter: FilterClause): FilterExpression => {\n const { field, op, value } = filter;\n if (!op || op === \"=\") {\n return [field, value];\n }\n return [field, op, value];\n};\n\n/**\n * buildQueryObject\n *\n * Builds the query payload object to be sent to the API,\n * converting filters, ordering, pagination, and projection into the expected format.\n *\n * @param {EntityQueryParams} params - Query parameters.\n * @param {FilterClause[]} params.filters - Filters to apply (converted via `toFilterTuple`).\n * @param {string[]} params.order - Sorting fields.\n * @param {number} [params.pageSize] - Number of items per page.\n * @param {string} [params.pageToken] - Cursor token for the next page.\n * @param {Projection} [params.projection] - The fields to return: one, or a list. `\"field\"`\n * returns only that field (every other field comes back null); `\"-field\"` returns all fields\n * except that one. Pass several as a list, never comma-joined: `\"a,b\"` is a 500. Omitted from\n * the payload when empty.\n * @returns {QueryObject} Query payload ready to be passed to the API.\n *\n * Example:\n * ```ts\n * buildQueryObject({\n * filters: [{ field: \"workspace\", value: \"ws-1\" }],\n * order: [\"name\"], // plain field name(s) only — no \"asc\"/\"desc\" suffix\n * pageSize: 10,\n * pageToken: \"token-abc\",\n * projection: \"name\",\n * });\n * // -> {\n * // filters: [[\"workspace\", \"ws-1\"]],\n * // order: [\"name\"],\n * // projection: \"name\",\n * // page_size: 10,\n * // page_token: \"token-abc\",\n * // }\n * ```\n */\n/** An empty string or list asks for every field, as no projection does. */\nconst hasProjection = (projection: Projection | undefined): projection is Projection =>\n projection !== undefined && projection.length > 0;\n\nexport const buildQueryObject = (params: EntityQueryParams): QueryObject => {\n const { filters, pageSize, pageToken, order, projection } = params;\n\n return {\n filters: filters.map(toFilterTuple),\n order,\n ...(hasProjection(projection) && { projection }),\n page_size: pageSize,\n page_token: pageToken,\n };\n};\n\n/** What, besides the filters, changes the response a list read gets back. */\nexport type QueryKeyParams = {\n order?: string[];\n projection?: Projection;\n pageSize?: number;\n fetchAllPages?: boolean;\n /** The datastore hooks' `dataFormat`. In the key whenever a hook passes it; only those hooks do. */\n dataFormat?: \"object\" | \"matrix\";\n};\n\n/**\n * buildQueryKey\n *\n * Builds the React Query cache key of a list read: the base keys, then one object holding\n * everything that changes the response.\n *\n * Every part of the request is in the key, not only the filter values. The key used to be\n * `[...keys, ...values]`, so a `-data` metadata read and a full read of the same workspace,\n * or `date = X` and `date >= X`, shared one cache entry and one of them rendered the other's\n * data. Filters go in as the tuples the API receives, so field and operator are included.\n *\n * The base keys stay in front, so prefix invalidation keeps working:\n * `invalidateQueries({ queryKey: [\"workflow_executions\", workflowId] })`.\n *\n * @param {(string | number | null)[]} keys - Base keys (entity name, then any ids).\n * @param {FilterClause[]} filters - The filters of the read.\n * @param {QueryKeyParams} [params] - Order, projection, page size and paging mode.\n * @returns {unknown[]} Cache key array for use in `queryKey`.\n *\n * Example:\n * ```ts\n * buildQueryKey([\"datastores\"], [{ field: \"workspace\", value: \"ws-1\" }], { pageSize: 10 });\n * // -> [\"datastores\", { filters: [[\"workspace\", \"ws-1\"]], pageSize: 10 }]\n * ```\n */\nexport const buildQueryKey = (\n keys: (string | number | null)[],\n filters: FilterClause[],\n { order, projection, pageSize, fetchAllPages, dataFormat }: QueryKeyParams = {},\n): unknown[] => {\n return [\n ...keys,\n {\n filters: filters.map(toFilterTuple),\n ...(order?.length ? { order } : {}),\n // The request omits an empty projection, so the key must not tell it apart.\n ...(hasProjection(projection) ? { projection } : {}),\n ...(pageSize !== undefined ? { pageSize } : {}),\n ...(fetchAllPages ? { fetchAllPages } : {}),\n ...(dataFormat ? { dataFormat } : {}),\n },\n ];\n};\n\n/**\n * hasWorkspaceFilter\n *\n * Whether a read can be sent: every endpoint that takes filters rejects a request with no\n * workspace. It reads the workspace through `workspaceOf`, as the list functions in `api/` do:\n * while each read it its own way, it passed on a filter the request then ignored.\n *\n * @param {FilterClause[]} filters - The filters of the read.\n * @returns {boolean} True when the first `workspace` filter carries a value.\n */\nexport const hasWorkspaceFilter = (filters: FilterClause[]): boolean =>\n Boolean(workspaceOf(filters.map(toFilterTuple)));\n\n/**\n * missingWorkspaceError\n *\n * The reason a hook gives, as `configError`, when it has no workspace to read. A missing\n * workspace is a misconfigured app, never a state to wait out: the app config is merged into\n * `window.APP_CONFIG` before the app renders, so an empty value there is a wrong or misspelled\n * key. The message names the hook, so it points at the call to fix.\n *\n * @param {string} hookName - The hook that could not send its request.\n * @returns {string} The error message.\n */\nexport const missingWorkspaceError = (hookName: string): string =>\n `[apps-sdk] ${hookName}: the \"workspace\" filter is missing or empty, so the request was not ` +\n \"sent. Check the workspace the app config provides.\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,iBAAiB,WAA2C;CACrE,MAAM,EAAE,OAAO,IAAI,UAAU;CAC7B,IAAI,CAAC,MAAM,OAAO,KACd,OAAO,CAAC,OAAO,KAAK;CAExB,OAAO;EAAC;EAAO;EAAI;CAAK;AAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAM,iBAAiB,eACnB,eAAe,KAAA,KAAa,WAAW,SAAS;AAEpD,IAAa,oBAAoB,WAA2C;CACxE,MAAM,EAAE,SAAS,UAAU,WAAW,OAAO,eAAe;CAE5D,OAAO;EACH,SAAS,QAAQ,IAAI,aAAa;EAClC;EACA,GAAI,cAAc,UAAU,KAAK,EAAE,WAAW;EAC9C,WAAW;EACX,YAAY;CAChB;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAa,iBACT,MACA,SACA,EAAE,OAAO,YAAY,UAAU,eAAe,eAA+B,CAAC,MAClE;CACZ,OAAO,CACH,GAAG,MACH;EACI,SAAS,QAAQ,IAAI,aAAa;EAClC,GAAI,OAAO,SAAS,EAAE,MAAM,IAAI,CAAC;EAEjC,GAAI,cAAc,UAAU,IAAI,EAAE,WAAW,IAAI,CAAC;EAClD,GAAI,aAAa,KAAA,IAAY,EAAE,SAAS,IAAI,CAAC;EAC7C,GAAI,gBAAgB,EAAE,cAAc,IAAI,CAAC;EACzC,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;CACvC,CACJ;AACJ;;;;;;;;;;;AAYA,IAAa,sBAAsB,YAC/B,QAAQ,YAAY,QAAQ,IAAI,aAAa,CAAC,CAAC;;;;;;;;;;;;AAanD,IAAa,yBAAyB,aAClC,cAAc,SAAS"}