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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (349) hide show
  1. package/README.md +298 -12
  2. package/dist/EveryskApp.d.ts +34 -2
  3. package/dist/EveryskApp.d.ts.map +1 -1
  4. package/dist/EveryskApp.js +35 -2
  5. package/dist/EveryskApp.js.map +1 -1
  6. package/dist/agGrid/handleRowsScrollEnd.d.ts +53 -0
  7. package/dist/agGrid/handleRowsScrollEnd.d.ts.map +1 -0
  8. package/dist/agGrid/handleRowsScrollEnd.js +47 -0
  9. package/dist/agGrid/handleRowsScrollEnd.js.map +1 -0
  10. package/dist/agGrid/index.d.ts +2 -0
  11. package/dist/agGrid/index.d.ts.map +1 -1
  12. package/dist/agGrid/index.js +2 -1
  13. package/dist/api/datastore.d.ts +10 -8
  14. package/dist/api/datastore.d.ts.map +1 -1
  15. package/dist/api/datastore.js +24 -55
  16. package/dist/api/datastore.js.map +1 -1
  17. package/dist/api/entityQuery.d.ts +46 -41
  18. package/dist/api/entityQuery.d.ts.map +1 -1
  19. package/dist/api/entityQuery.js +55 -14
  20. package/dist/api/entityQuery.js.map +1 -1
  21. package/dist/api/file.d.ts +26 -9
  22. package/dist/api/file.d.ts.map +1 -1
  23. package/dist/api/file.js +45 -55
  24. package/dist/api/file.js.map +1 -1
  25. package/dist/api/portfolio.d.ts +11 -8
  26. package/dist/api/portfolio.d.ts.map +1 -1
  27. package/dist/api/portfolio.js +24 -55
  28. package/dist/api/portfolio.js.map +1 -1
  29. package/dist/api/profile.d.ts +3 -2
  30. package/dist/api/profile.d.ts.map +1 -1
  31. package/dist/api/profile.js +4 -9
  32. package/dist/api/profile.js.map +1 -1
  33. package/dist/api/request.d.ts +106 -0
  34. package/dist/api/request.d.ts.map +1 -0
  35. package/dist/api/request.js +132 -0
  36. package/dist/api/request.js.map +1 -0
  37. package/dist/api/websocketsConfig.d.ts +7 -2
  38. package/dist/api/websocketsConfig.d.ts.map +1 -1
  39. package/dist/api/websocketsConfig.js +2 -10
  40. package/dist/api/websocketsConfig.js.map +1 -1
  41. package/dist/api/workflow.d.ts +84 -89
  42. package/dist/api/workflow.d.ts.map +1 -1
  43. package/dist/api/workflow.js +121 -208
  44. package/dist/api/workflow.js.map +1 -1
  45. package/dist/api/workspace.d.ts +18 -8
  46. package/dist/api/workspace.d.ts.map +1 -1
  47. package/dist/api/workspace.js +21 -26
  48. package/dist/api/workspace.js.map +1 -1
  49. package/dist/components/ui/Footer/index.d.ts.map +1 -1
  50. package/dist/components/ui/Footer/index.js.map +1 -1
  51. package/dist/components/ui/GlobalLoading/index.d.ts.map +1 -1
  52. package/dist/components/ui/GlobalLoading/index.js.map +1 -1
  53. package/dist/components/ui/PageContainer/index.d.ts +1 -1
  54. package/dist/components/ui/PageContainer/index.d.ts.map +1 -1
  55. package/dist/components/ui/PageContainer/index.js.map +1 -1
  56. package/dist/components/ui/Toolbar/index.d.ts +40 -3
  57. package/dist/components/ui/Toolbar/index.d.ts.map +1 -1
  58. package/dist/components/ui/Toolbar/index.js +42 -15
  59. package/dist/components/ui/Toolbar/index.js.map +1 -1
  60. package/dist/contexts/appAlertContext/provider.js.map +1 -1
  61. package/dist/contexts/appAlertContext/types.d.ts.map +1 -1
  62. package/dist/contexts/appConfigContext/index.d.ts.map +1 -1
  63. package/dist/contexts/appConfigContext/index.js.map +1 -1
  64. package/dist/contexts/appConfigContext/provider.d.ts.map +1 -1
  65. package/dist/contexts/appConfigContext/provider.js.map +1 -1
  66. package/dist/contexts/webSocketContext/handler.d.ts +3 -2
  67. package/dist/contexts/webSocketContext/handler.d.ts.map +1 -1
  68. package/dist/contexts/webSocketContext/handler.js.map +1 -1
  69. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts +1 -1
  70. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js +1 -1
  71. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js.map +1 -1
  72. package/dist/contexts/webSocketContext/provider.d.ts +6 -3
  73. package/dist/contexts/webSocketContext/provider.d.ts.map +1 -1
  74. package/dist/contexts/webSocketContext/provider.js +42 -7
  75. package/dist/contexts/webSocketContext/provider.js.map +1 -1
  76. package/dist/contexts/webSocketContext/types.d.ts +7 -5
  77. package/dist/contexts/webSocketContext/types.d.ts.map +1 -1
  78. package/dist/file/index.d.ts +2 -0
  79. package/dist/file/index.d.ts.map +1 -1
  80. package/dist/hooks/datastore/useDatastoreMutations.d.ts +4 -4
  81. package/dist/hooks/datastore/useDatastoreMutations.d.ts.map +1 -1
  82. package/dist/hooks/datastore/useDatastoreMutations.js +17 -55
  83. package/dist/hooks/datastore/useDatastoreMutations.js.map +1 -1
  84. package/dist/hooks/datastore/useFetchDatastore.d.ts +30 -41
  85. package/dist/hooks/datastore/useFetchDatastore.d.ts.map +1 -1
  86. package/dist/hooks/datastore/useFetchDatastore.js +25 -59
  87. package/dist/hooks/datastore/useFetchDatastore.js.map +1 -1
  88. package/dist/hooks/datastore/useFetchDatastores.d.ts +47 -52
  89. package/dist/hooks/datastore/useFetchDatastores.d.ts.map +1 -1
  90. package/dist/hooks/datastore/useFetchDatastores.js +55 -70
  91. package/dist/hooks/datastore/useFetchDatastores.js.map +1 -1
  92. package/dist/hooks/file/fileData.d.ts +17 -0
  93. package/dist/hooks/file/fileData.d.ts.map +1 -0
  94. package/dist/hooks/file/fileData.js +10 -0
  95. package/dist/hooks/file/fileData.js.map +1 -0
  96. package/dist/hooks/file/useFetchFile.d.ts +38 -58
  97. package/dist/hooks/file/useFetchFile.d.ts.map +1 -1
  98. package/dist/hooks/file/useFetchFile.js +26 -66
  99. package/dist/hooks/file/useFetchFile.js.map +1 -1
  100. package/dist/hooks/file/useFetchFiles.d.ts +18 -52
  101. package/dist/hooks/file/useFetchFiles.d.ts.map +1 -1
  102. package/dist/hooks/file/useFetchFiles.js +53 -69
  103. package/dist/hooks/file/useFetchFiles.js.map +1 -1
  104. package/dist/hooks/file/useFileMutations.d.ts +9 -8
  105. package/dist/hooks/file/useFileMutations.d.ts.map +1 -1
  106. package/dist/hooks/file/useFileMutations.js +23 -60
  107. package/dist/hooks/file/useFileMutations.js.map +1 -1
  108. package/dist/hooks/portfolio/useFetchPortfolio.d.ts +16 -50
  109. package/dist/hooks/portfolio/useFetchPortfolio.d.ts.map +1 -1
  110. package/dist/hooks/portfolio/useFetchPortfolio.js +15 -63
  111. package/dist/hooks/portfolio/useFetchPortfolio.js.map +1 -1
  112. package/dist/hooks/portfolio/useFetchPortfolios.d.ts +13 -52
  113. package/dist/hooks/portfolio/useFetchPortfolios.d.ts.map +1 -1
  114. package/dist/hooks/portfolio/useFetchPortfolios.js +29 -71
  115. package/dist/hooks/portfolio/useFetchPortfolios.js.map +1 -1
  116. package/dist/hooks/portfolio/usePortfolioMutations.d.ts +8 -8
  117. package/dist/hooks/portfolio/usePortfolioMutations.d.ts.map +1 -1
  118. package/dist/hooks/portfolio/usePortfolioMutations.js +20 -58
  119. package/dist/hooks/portfolio/usePortfolioMutations.js.map +1 -1
  120. package/dist/hooks/profile/useFetchProfile.d.ts +18 -44
  121. package/dist/hooks/profile/useFetchProfile.d.ts.map +1 -1
  122. package/dist/hooks/profile/useFetchProfile.js +16 -48
  123. package/dist/hooks/profile/useFetchProfile.js.map +1 -1
  124. package/dist/hooks/useAxios.js.map +1 -1
  125. package/dist/hooks/useEntityInfiniteQuery.d.ts +88 -0
  126. package/dist/hooks/useEntityInfiniteQuery.d.ts.map +1 -0
  127. package/dist/hooks/useEntityInfiniteQuery.js +111 -0
  128. package/dist/hooks/useEntityInfiniteQuery.js.map +1 -0
  129. package/dist/hooks/useEntityMutation.d.ts +47 -0
  130. package/dist/hooks/useEntityMutation.d.ts.map +1 -0
  131. package/dist/hooks/useEntityMutation.js +58 -0
  132. package/dist/hooks/useEntityMutation.js.map +1 -0
  133. package/dist/hooks/useEntityQuery.d.ts +68 -0
  134. package/dist/hooks/useEntityQuery.d.ts.map +1 -0
  135. package/dist/hooks/useEntityQuery.js +75 -0
  136. package/dist/hooks/useEntityQuery.js.map +1 -0
  137. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts +17 -34
  138. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts.map +1 -1
  139. package/dist/hooks/workflow/useFetchWorkerExecution.js +16 -46
  140. package/dist/hooks/workflow/useFetchWorkerExecution.js.map +1 -1
  141. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts +179 -41
  142. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts.map +1 -1
  143. package/dist/hooks/workflow/useFetchWorkerExecutions.js +29 -62
  144. package/dist/hooks/workflow/useFetchWorkerExecutions.js.map +1 -1
  145. package/dist/hooks/workflow/useFetchWorkflow.d.ts +16 -35
  146. package/dist/hooks/workflow/useFetchWorkflow.d.ts.map +1 -1
  147. package/dist/hooks/workflow/useFetchWorkflow.js +15 -48
  148. package/dist/hooks/workflow/useFetchWorkflow.js.map +1 -1
  149. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts +17 -34
  150. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts.map +1 -1
  151. package/dist/hooks/workflow/useFetchWorkflowExecution.js +16 -46
  152. package/dist/hooks/workflow/useFetchWorkflowExecution.js.map +1 -1
  153. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts +22 -36
  154. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts.map +1 -1
  155. package/dist/hooks/workflow/useFetchWorkflowExecutions.js +43 -56
  156. package/dist/hooks/workflow/useFetchWorkflowExecutions.js.map +1 -1
  157. package/dist/hooks/workflow/useFetchWorkflows.d.ts +20 -37
  158. package/dist/hooks/workflow/useFetchWorkflows.d.ts.map +1 -1
  159. package/dist/hooks/workflow/useFetchWorkflows.js +32 -47
  160. package/dist/hooks/workflow/useFetchWorkflows.js.map +1 -1
  161. package/dist/hooks/workflow/useRunWorkflow.d.ts +21 -16
  162. package/dist/hooks/workflow/useRunWorkflow.d.ts.map +1 -1
  163. package/dist/hooks/workflow/useRunWorkflow.js +66 -29
  164. package/dist/hooks/workflow/useRunWorkflow.js.map +1 -1
  165. package/dist/hooks/workflow/useTriggerWorkflow.d.ts +20 -0
  166. package/dist/hooks/workflow/useTriggerWorkflow.d.ts.map +1 -0
  167. package/dist/hooks/workflow/useTriggerWorkflow.js +32 -0
  168. package/dist/hooks/workflow/useTriggerWorkflow.js.map +1 -0
  169. package/dist/hooks/workspace/useFetchWorkspace.d.ts +19 -34
  170. package/dist/hooks/workspace/useFetchWorkspace.d.ts.map +1 -1
  171. package/dist/hooks/workspace/useFetchWorkspace.js +16 -46
  172. package/dist/hooks/workspace/useFetchWorkspace.js.map +1 -1
  173. package/dist/hooks/workspace/useFetchWorkspaces.d.ts +17 -37
  174. package/dist/hooks/workspace/useFetchWorkspaces.d.ts.map +1 -1
  175. package/dist/hooks/workspace/useFetchWorkspaces.js +25 -47
  176. package/dist/hooks/workspace/useFetchWorkspaces.js.map +1 -1
  177. package/dist/index.d.ts +13 -10
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +13 -11
  180. package/dist/lib/abort.d.ts +58 -0
  181. package/dist/lib/abort.d.ts.map +1 -0
  182. package/dist/lib/abort.js +112 -0
  183. package/dist/lib/abort.js.map +1 -0
  184. package/dist/lib/datastoreTable.d.ts +59 -54
  185. package/dist/lib/datastoreTable.d.ts.map +1 -1
  186. package/dist/lib/datastoreTable.js +58 -62
  187. package/dist/lib/datastoreTable.js.map +1 -1
  188. package/dist/lib/file.d.ts +34 -0
  189. package/dist/lib/file.d.ts.map +1 -0
  190. package/dist/lib/file.js +63 -0
  191. package/dist/lib/file.js.map +1 -0
  192. package/dist/lib/queryClient.d.ts.map +1 -1
  193. package/dist/lib/queryClient.js.map +1 -1
  194. package/dist/lib/workflowRun.d.ts +91 -0
  195. package/dist/lib/workflowRun.d.ts.map +1 -0
  196. package/dist/lib/workflowRun.js +224 -0
  197. package/dist/lib/workflowRun.js.map +1 -0
  198. package/dist/socket/index.d.ts +1 -3
  199. package/dist/socket/index.d.ts.map +1 -1
  200. package/dist/socket/index.js +3 -5
  201. package/dist/test/mocks/index.d.ts +1 -1
  202. package/dist/test/mocks/index.d.ts.map +1 -1
  203. package/dist/test/renderWithProviders.d.ts +2 -2
  204. package/dist/test/renderWithProviders.d.ts.map +1 -1
  205. package/dist/test/renderWithProviders.js.map +1 -1
  206. package/dist/test/setup.js.map +1 -1
  207. package/dist/theme/index.d.ts +1 -1
  208. package/dist/theme/index.d.ts.map +1 -1
  209. package/dist/theme/overrides/index.d.ts +4 -2
  210. package/dist/theme/overrides/index.d.ts.map +1 -1
  211. package/dist/theme/overrides/index.js +5 -3
  212. package/dist/theme/overrides/index.js.map +1 -1
  213. package/dist/theme/overrides/muiButton.d.ts +2 -2
  214. package/dist/theme/overrides/muiButton.js.map +1 -1
  215. package/dist/theme/overrides/muiCssBaseline.d.ts.map +1 -1
  216. package/dist/theme/overrides/muiCssBaseline.js.map +1 -1
  217. package/dist/theme/overrides/muiDatePicker.js.map +1 -1
  218. package/dist/theme/overrides/muiFormControl.js.map +1 -1
  219. package/dist/theme/overrides/muiIconButton.d.ts +2 -2
  220. package/dist/theme/overrides/muiIconButton.js.map +1 -1
  221. package/dist/theme/overrides/muiSelect.d.ts.map +1 -1
  222. package/dist/theme/overrides/muiSelect.js.map +1 -1
  223. package/dist/theme/overrides/muiSvgIcon.d.ts.map +1 -1
  224. package/dist/theme/overrides/muiSvgIcon.js.map +1 -1
  225. package/dist/theme/overrides/muiTextField.js.map +1 -1
  226. package/dist/theme/overrides/muiToggleButton.d.ts +2 -2
  227. package/dist/theme/overrides/muiToggleButton.js.map +1 -1
  228. package/dist/theme/overrides/muiToggleButtonGroup.d.ts +2 -2
  229. package/dist/theme/overrides/muiToggleButtonGroup.js.map +1 -1
  230. package/dist/theme/themes/DefaultDark.js +2 -2
  231. package/dist/theme/themes/DefaultDark.js.map +1 -1
  232. package/dist/theme/themes/DefaultLight.js +2 -2
  233. package/dist/theme/themes/DefaultLight.js.map +1 -1
  234. package/dist/theme/themes/EveryskDark.js +2 -2
  235. package/dist/theme/themes/EveryskDark.js.map +1 -1
  236. package/dist/theme/themes/EveryskLight.js +2 -2
  237. package/dist/theme/themes/EveryskLight.js.map +1 -1
  238. package/dist/theme/themes/MidnightEmber.js +2 -2
  239. package/dist/theme/themes/MidnightEmber.js.map +1 -1
  240. package/dist/types/anyRecord.d.ts.map +1 -1
  241. package/dist/types/datastore.d.ts +35 -5
  242. package/dist/types/datastore.d.ts.map +1 -1
  243. package/dist/types/datastoreDataFormat.d.ts +13 -0
  244. package/dist/types/datastoreDataFormat.d.ts.map +1 -0
  245. package/dist/types/entityQuery.d.ts +86 -16
  246. package/dist/types/entityQuery.d.ts.map +1 -1
  247. package/dist/types/file.d.ts +7 -3
  248. package/dist/types/file.d.ts.map +1 -1
  249. package/dist/types/portfolio.d.ts +1 -3
  250. package/dist/types/portfolio.d.ts.map +1 -1
  251. package/dist/types/profile.d.ts +0 -10
  252. package/dist/types/profile.d.ts.map +1 -1
  253. package/dist/types/workflow.d.ts +35 -6
  254. package/dist/types/workflow.d.ts.map +1 -1
  255. package/dist/types/workspace.d.ts +1 -2
  256. package/dist/types/workspace.d.ts.map +1 -1
  257. package/dist/ui/index.d.ts +1 -1
  258. package/dist/ui/index.d.ts.map +1 -1
  259. package/dist/workflow/index.d.ts +2 -0
  260. package/dist/workflow/index.d.ts.map +1 -1
  261. package/package.json +1 -1
  262. package/src/EveryskApp.tsx +53 -2
  263. package/src/agGrid/handleRowsScrollEnd.ts +71 -0
  264. package/src/agGrid/index.ts +5 -1
  265. package/src/api/datastore.ts +79 -107
  266. package/src/api/entityQuery.ts +86 -17
  267. package/src/api/file.ts +110 -103
  268. package/src/api/portfolio.ts +82 -125
  269. package/src/api/profile.ts +25 -18
  270. package/src/api/request.ts +168 -0
  271. package/src/api/websocketsConfig.ts +11 -19
  272. package/src/api/workflow.ts +232 -334
  273. package/src/api/workspace.ts +43 -43
  274. package/src/components/ui/Footer/index.tsx +8 -7
  275. package/src/components/ui/GlobalLoading/index.tsx +13 -3
  276. package/src/components/ui/PageContainer/index.tsx +9 -2
  277. package/src/components/ui/Toolbar/index.tsx +105 -30
  278. package/src/contexts/appAlertContext/provider.tsx +1 -1
  279. package/src/contexts/appAlertContext/types.ts +3 -3
  280. package/src/contexts/appConfigContext/index.tsx +1 -1
  281. package/src/contexts/appConfigContext/provider.tsx +1 -5
  282. package/src/contexts/webSocketContext/handler.ts +8 -2
  283. package/src/contexts/webSocketContext/hooks/useWebSocket/index.ts +1 -1
  284. package/src/contexts/webSocketContext/provider.tsx +64 -14
  285. package/src/contexts/webSocketContext/types.ts +7 -6
  286. package/src/file/index.ts +2 -0
  287. package/src/hooks/datastore/useDatastoreMutations.ts +19 -60
  288. package/src/hooks/datastore/useFetchDatastore.ts +45 -73
  289. package/src/hooks/datastore/useFetchDatastores.ts +106 -131
  290. package/src/hooks/file/fileData.ts +19 -0
  291. package/src/hooks/file/useFetchFile.ts +41 -76
  292. package/src/hooks/file/useFetchFiles.ts +92 -87
  293. package/src/hooks/file/useFileMutations.ts +23 -73
  294. package/src/hooks/portfolio/useFetchPortfolio.ts +26 -78
  295. package/src/hooks/portfolio/useFetchPortfolios.ts +50 -93
  296. package/src/hooks/portfolio/usePortfolioMutations.ts +22 -72
  297. package/src/hooks/profile/useFetchProfile.ts +24 -65
  298. package/src/hooks/useAxios.ts +5 -5
  299. package/src/hooks/useEntityInfiniteQuery.ts +193 -0
  300. package/src/hooks/useEntityMutation.ts +70 -0
  301. package/src/hooks/useEntityQuery.ts +117 -0
  302. package/src/hooks/workflow/useFetchWorkerExecution.ts +27 -56
  303. package/src/hooks/workflow/useFetchWorkerExecutions.ts +54 -79
  304. package/src/hooks/workflow/useFetchWorkflow.ts +24 -58
  305. package/src/hooks/workflow/useFetchWorkflowExecution.ts +27 -57
  306. package/src/hooks/workflow/useFetchWorkflowExecutions.ts +64 -73
  307. package/src/hooks/workflow/useFetchWorkflows.ts +48 -64
  308. package/src/hooks/workflow/useRunWorkflow.ts +82 -36
  309. package/src/hooks/workflow/useTriggerWorkflow.ts +36 -0
  310. package/src/hooks/workspace/useFetchWorkspace.ts +25 -58
  311. package/src/hooks/workspace/useFetchWorkspaces.ts +38 -69
  312. package/src/index.ts +34 -19
  313. package/src/lib/abort.ts +131 -0
  314. package/src/lib/datastoreTable.ts +127 -74
  315. package/src/lib/file.ts +67 -0
  316. package/src/lib/queryClient.ts +11 -13
  317. package/src/lib/workflowRun.ts +329 -0
  318. package/src/socket/index.ts +1 -3
  319. package/src/test/mocks/index.ts +1 -5
  320. package/src/test/renderWithProviders.tsx +8 -3
  321. package/src/test/setup.ts +16 -16
  322. package/src/theme/index.ts +1 -1
  323. package/src/theme/overrides/index.ts +5 -3
  324. package/src/theme/overrides/muiButton.ts +3 -3
  325. package/src/theme/overrides/muiCssBaseline.ts +11 -12
  326. package/src/theme/overrides/muiDatePicker.ts +2 -2
  327. package/src/theme/overrides/muiFormControl.ts +2 -2
  328. package/src/theme/overrides/muiIconButton.ts +3 -3
  329. package/src/theme/overrides/muiSelect.ts +2 -2
  330. package/src/theme/overrides/muiSvgIcon.ts +2 -2
  331. package/src/theme/overrides/muiTextField.ts +1 -1
  332. package/src/theme/overrides/muiToggleButton.ts +4 -4
  333. package/src/theme/overrides/muiToggleButtonGroup.ts +4 -4
  334. package/src/theme/themes/DefaultDark.ts +2 -2
  335. package/src/theme/themes/DefaultLight.ts +2 -2
  336. package/src/theme/themes/EveryskDark.ts +2 -2
  337. package/src/theme/themes/EveryskLight.ts +2 -2
  338. package/src/theme/themes/MidnightEmber.ts +15 -15
  339. package/src/types/anyRecord.ts +2 -2
  340. package/src/types/datastore.ts +56 -22
  341. package/src/types/datastoreDataFormat.ts +12 -0
  342. package/src/types/entityQuery.ts +122 -38
  343. package/src/types/file.ts +8 -6
  344. package/src/types/portfolio.ts +70 -74
  345. package/src/types/profile.ts +0 -11
  346. package/src/types/workflow.ts +38 -9
  347. package/src/types/workspace.ts +2 -4
  348. package/src/ui/index.ts +1 -1
  349. package/src/workflow/index.ts +5 -0
@@ -1,7 +1,5 @@
1
- import { useMutation, useQueryClient } from "@tanstack/react-query";
2
-
3
- import { useAxios } from "./../useAxios";
4
- import { useAppAlert } from "@/contexts/appAlertContext/useAppAlert";
1
+ import { useAxios } from "@/hooks/useAxios";
2
+ import { useEntityMutation } from "@/hooks/useEntityMutation";
5
3
  import type { Datastore } from "@/types/datastore";
6
4
  import { deleteDatastore, createDatastore, updateDatastore } from "@/api/datastore";
7
5
 
@@ -23,9 +21,6 @@ type UseDatastoreMutationsProps = {
23
21
  queryKey?: unknown[];
24
22
  };
25
23
 
26
- const getErrorMessage = (err: unknown, fallback: string) =>
27
- err instanceof Error && err.message ? err.message : fallback;
28
-
29
24
  /**
30
25
  * useDatastoreMutations
31
26
  *
@@ -79,7 +74,7 @@ const getErrorMessage = (err: unknown, fallback: string) =>
79
74
  * Returns an object with the three TanStack Query mutation results:
80
75
  * - `create`: UseMutationResult<Datastore, Error, CreateDatastoreProps, unknown>
81
76
  * - `update`: UseMutationResult<Datastore, Error, UpdateDatastoreProps, unknown>
82
- * - `remove`: UseMutationResult<Datastore, Error, DeleteDatastoreProps, unknown>
77
+ * - `remove`: UseMutationResult<DeletedEntity, Error, DeleteDatastoreProps, unknown>
83
78
  *
84
79
  * Each mutation includes standard TanStack Query helpers:
85
80
  * - `mutate(variables, options?)`
@@ -158,63 +153,27 @@ const getErrorMessage = (err: unknown, fallback: string) =>
158
153
 
159
154
  export const useDatastoreMutations = ({ queryKey }: UseDatastoreMutationsProps) => {
160
155
  const { api } = useAxios();
161
- const { showAlert } = useAppAlert();
162
- const queryClient = useQueryClient();
163
-
164
- const invalidate = async () => {
165
- if (!queryKey?.length) return;
166
- await queryClient.invalidateQueries({ queryKey });
167
- };
168
156
 
169
- const create = useMutation({
170
- mutationFn: async ({ data }: CreateDatastoreProps) => createDatastore(api, data),
171
- onSuccess: async () => {
172
- await invalidate();
173
- showAlert({
174
- severity: "success",
175
- message: "Datastore created successfully.",
176
- });
177
- },
178
- onError: (err: unknown) => {
179
- showAlert({
180
- severity: "error",
181
- message: getErrorMessage(err, "Unable to create the datastore. Please try again."),
182
- });
183
- },
157
+ const create = useEntityMutation({
158
+ mutationFn: ({ data }: CreateDatastoreProps) => createDatastore(api, data),
159
+ queryKey,
160
+ successMessage: "Datastore created successfully.",
161
+ errorMessage: "Unable to create the datastore. Please try again.",
184
162
  });
185
163
 
186
- const update = useMutation({
187
- mutationFn: async ({ id, data }: UpdateDatastoreProps) => updateDatastore(api, id, data),
188
- onSuccess: async () => {
189
- await invalidate();
190
- showAlert({
191
- severity: "success",
192
- message: "Datastore updated successfully.",
193
- });
194
- },
195
- onError: (err: unknown) => {
196
- showAlert({
197
- severity: "error",
198
- message: getErrorMessage(err, "Unable to update the datastore. Please try again."),
199
- });
200
- },
164
+ const update = useEntityMutation({
165
+ mutationFn: ({ id, data }: UpdateDatastoreProps) => updateDatastore(api, id, data),
166
+ queryKey,
167
+ successMessage: "Datastore updated successfully.",
168
+ errorMessage: "Unable to update the datastore. Please try again.",
201
169
  });
202
170
 
203
- const remove = useMutation({
204
- mutationFn: async ({ id, workspace }: DeleteDatastoreProps) => deleteDatastore(api, id, workspace),
205
- onSuccess: async () => {
206
- await invalidate();
207
- showAlert({
208
- severity: "success",
209
- message: "Datastore deleted successfully.",
210
- });
211
- },
212
- onError: (err: unknown) => {
213
- showAlert({
214
- severity: "error",
215
- message: getErrorMessage(err, "Unable to delete the datastore. Please try again."),
216
- });
217
- },
171
+ const remove = useEntityMutation({
172
+ mutationFn: ({ id, workspace }: DeleteDatastoreProps) =>
173
+ deleteDatastore(api, id, workspace),
174
+ queryKey,
175
+ successMessage: "Datastore deleted successfully.",
176
+ errorMessage: "Unable to delete the datastore. Please try again.",
218
177
  });
219
178
 
220
179
  return { create, update, remove };
@@ -1,95 +1,67 @@
1
- import { useEffect } from "react";
2
-
3
- import { useQuery } from "@tanstack/react-query";
4
-
5
1
  import { useAxios } from "@/hooks/useAxios";
6
- import { useAppAlert } from "@/contexts/appAlertContext/useAppAlert";
2
+ import { useEntityQuery } from "@/hooks/useEntityQuery";
3
+ import { missingWorkspaceError } from "@/api/entityQuery";
7
4
  import { getDatastore } from "@/api/datastore";
8
- import { tableToObjects } from "@/lib/datastoreTable";
9
- import type { DatastoreWithRows } from "@/types/datastore";
10
- import type { EntityQueryOptions, FetchEntityParams } from "@/types/entityQuery";
11
-
12
- export type FetchDatastoreProps = FetchEntityParams<DatastoreWithRows>;
5
+ import { parseDatastore } from "@/lib/datastoreTable";
6
+ import type { ParsedDatastore } from "@/types/datastore";
7
+ import type { DatastoreDataFormat } from "@/types/datastoreDataFormat";
8
+ import type { FetchEntityByIdProps } from "@/types/entityQuery";
13
9
 
14
- const defaultQueryOptions: EntityQueryOptions<DatastoreWithRows> = {
15
- refetchOnMount: "always",
16
- staleTime: 0,
17
- gcTime: 0,
10
+ export type FetchDatastoreProps<
11
+ F extends DatastoreDataFormat = "object",
12
+ TSelected = ParsedDatastore<F>,
13
+ > = FetchEntityByIdProps<ParsedDatastore<F>, TSelected> & {
14
+ /**
15
+ * Tabular datastores only: `"object"` (default) turns the matrix into one object per row;
16
+ * `"matrix"` leaves the matrix, header row included. A JSON datastore's `data` is unchanged either way.
17
+ */
18
+ dataFormat?: F;
18
19
  };
19
20
 
20
21
  /**
21
22
  * useFetchDatastore
22
23
  *
23
- * Data-fetching hook built on TanStack Query to retrieve a single datastore by ID.
24
- *
25
- * It also:
26
- * - triggers an error alert via `useAppAlert` whenever `query.error` is present
27
- *
28
- * Important notes:
29
- * - Returns a `DatastoreWithRows` object: the full `Datastore` shape with `data`
30
- * replaced by `AnyRecord[]` (rows transformed via `tableToObjects`).
31
- *
32
- * Parameters (FetchDatastoreProps):
33
- * @param {string} id
34
- * Datastore identifier (required).
24
+ * Fetches one datastore. `data` is a `ParsedDatastore` — a table's matrix converted to row
25
+ * objects with `fields`, or a JSON datastore's content untouched, told apart by `format`, the
26
+ * same shape `useFetchDatastores` returns — or whatever `select` makes of it. With
27
+ * `dataFormat: "matrix"` a tabular datastore keeps its matrix unconverted, as in `useFetchDatastores`.
35
28
  *
36
- * @param {string} workspace
37
- * Workspace the datastore belongs to (required by `getDatastore`).
29
+ * Idle while `id` is empty; fails loudly, without a request, while `workspace` is. A failure is
30
+ * shown as an error alert.
38
31
  *
39
- * @param {EntityQueryOptions<DatastoreWithRows>} [queryOptions=defaultQueryOptions]
40
- * TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
41
- *
42
- * Returns:
43
- * @returns {object}
44
- * TanStack Query's `query` object extended with:
45
- * - `queryKey`: the cache key used by React Query
32
+ * @param {FetchDatastoreProps} props - `id`, `workspace`, `dataFormat`, `select` and TanStack
33
+ * `queryOptions`.
34
+ * @returns {object} The `useQuery` result, plus `queryKey`.
46
35
  *
47
36
  * Example:
48
37
  * ```ts
49
- * const { data, isLoading } = useFetchDatastore({
50
- * id: "abc123",
51
- * workspace: "my-workspace",
52
- * });
53
- * // data -> DatastoreWithRows (datastore metadata + rows as AnyRecord[])
54
- * // data.name -> "my-datastore"
55
- * // data.data -> [{ datastoreId: "abc123", col1: "value", ... }]
38
+ * const { data, isLoading, queryKey } = useFetchDatastore({ id: "abc123", workspace: "ws-1" });
56
39
  * ```
57
40
  */
58
- export const useFetchDatastore = ({ id, workspace, queryOptions = defaultQueryOptions }: FetchDatastoreProps) => {
59
-
41
+ export const useFetchDatastore = <
42
+ F extends DatastoreDataFormat = "object",
43
+ TSelected = ParsedDatastore<F>,
44
+ >({
45
+ id,
46
+ workspace,
47
+ dataFormat,
48
+ select,
49
+ queryOptions,
50
+ }: FetchDatastoreProps<F, TSelected>) => {
60
51
  const { api } = useAxios();
61
- const { showAlert } = useAppAlert();
62
52
 
63
- const queryKey = ["datastore", id, workspace];
53
+ const format = (dataFormat ?? "object") as F;
54
+ const queryKey = ["datastore", id, workspace, format];
64
55
 
65
- const query = useQuery<DatastoreWithRows>({
56
+ const query = useEntityQuery<ParsedDatastore<F>, TSelected>({
66
57
  queryKey,
67
- queryFn: async () => {
68
- const datastore = await getDatastore(api, id, workspace);
69
-
70
- return {
71
- ...datastore,
72
- data: tableToObjects(
73
- datastore.id,
74
- datastore.data?.[0] as string[],
75
- datastore.data
76
- ),
77
- };
78
- },
79
- ...queryOptions ?? {}
58
+ fetchEntity: async (signal) =>
59
+ parseDatastore(await getDatastore(api, id, workspace, signal), format),
60
+ select,
61
+ enabled: Boolean(id),
62
+ configError: workspace ? undefined : missingWorkspaceError("useFetchDatastore"),
63
+ queryOptions,
80
64
  });
81
65
 
82
- useEffect(() => {
83
- if (!query.error) return;
84
-
85
- showAlert({
86
- severity: "error",
87
- message: query.error.message,
88
- });
89
- }, [query.error, showAlert]);
90
-
91
- return {
92
- ...query,
93
- queryKey,
94
- };
66
+ return { ...query, queryKey };
95
67
  };
@@ -1,162 +1,137 @@
1
- //import { useCallback, useMemo, useRef } from "react";
2
- import { useMemo } from "react";
3
- import { useInfiniteQuery, type UseInfiniteQueryOptions, type QueryKey } from "@tanstack/react-query";
4
-
5
- //import type { GridApi } from "ag-grid-community";
6
-
7
1
  import { useAxios } from "@/hooks/useAxios";
8
- import { tableToObjects } from "@/lib/datastoreTable";
2
+ import { useEntityInfiniteQuery } from "@/hooks/useEntityInfiniteQuery";
3
+ import { parseDatastore } from "@/lib/datastoreTable";
9
4
  import { listDatastores } from "@/api/datastore";
10
5
 
11
- import type { Datastore, DatastoreListResponse, DatastoreWithRows } from "@/types/datastore";
12
- import type { FetchEntitiesParams, EntityDefaultResponse } from "@/types/entityQuery";
13
- import { buildQueryKey, buildQueryObject } from "@/api/entityQuery";
14
-
15
- type PageToken = string | null;
16
-
17
- type InfiniteOptions<TData> = Omit<
18
- UseInfiniteQueryOptions<DatastoreQueryPage, Error, TData, QueryKey, PageToken>,
19
- "queryKey" | "queryFn" | "initialPageParam" | "getNextPageParam"
20
- >;
21
-
22
-
23
- export type DatastoreQueryPage = EntityDefaultResponse & {
24
- datastores: DatastoreWithRows[];
6
+ import type { DatastoreListResponse, ParsedDatastore } from "@/types/datastore";
7
+ import type { DatastoreDataFormat } from "@/types/datastoreDataFormat";
8
+ import type {
9
+ PagedResponse,
10
+ FetchEntitiesProps,
11
+ ListQueryProps,
12
+ ListCache,
13
+ } from "@/types/entityQuery";
14
+ import {
15
+ buildQueryKey,
16
+ buildQueryObject,
17
+ hasWorkspaceFilter,
18
+ missingWorkspaceError,
19
+ } from "@/api/entityQuery";
20
+
21
+ export type DatastoreQueryPage<F extends DatastoreDataFormat = "object"> = PagedResponse & {
22
+ datastores: ParsedDatastore<F>[];
25
23
  };
26
24
 
27
- export type FetchInfiniteDatastoreProps = FetchEntitiesParams<DatastoreWithRows[], InfiniteOptions<DatastoreWithRows[]>> & {
28
- pageSize?: number;
29
- };
25
+ /** The query cache of `useFetchDatastores`, for typing `setQueryData`. */
26
+ export type DatastoresCache<F extends DatastoreDataFormat = "object"> = ListCache<
27
+ DatastoreQueryPage<F>
28
+ >;
30
29
 
31
- const defaultQueryOptions: InfiniteOptions<DatastoreWithRows[]> = {
32
- refetchOnMount: "always",
33
- staleTime: 0,
34
- gcTime: 0,
35
- };
30
+ export type FetchDatastoresProps<
31
+ F extends DatastoreDataFormat = "object",
32
+ TData = ParsedDatastore<F>[],
33
+ > = ListQueryProps &
34
+ FetchEntitiesProps<ParsedDatastore<F>, TData, DatastoreQueryPage<F>> & {
35
+ /**
36
+ * Tabular datastores only: `"object"` (default) turns the matrix into one object per row;
37
+ * `"matrix"` leaves the matrix, header row included. A JSON datastore's `data` is unchanged either way.
38
+ */
39
+ dataFormat?: F;
40
+ };
36
41
 
37
42
  /**
38
43
  * useFetchDatastores
39
44
  *
40
- * Data-fetching hook built on TanStack Query's `useInfiniteQuery` to retrieve
41
- * datastores with cursor-based pagination.
42
- *
43
- * It also:
44
- * - flattens all pages into a single `DatastoreWithRows[]` via `select`
45
- * - exposes `actions` for cache management
46
- * - exposes `events` for ag-Grid integration
47
- *
48
- * Important notes:
49
- * - `query.data` returns a flat `DatastoreWithRows[]` (all pages merged).
50
- * - Each item retains the full `Datastore` shape, with `data` replaced by `AnyRecord[]` (rows transformed via `tableToObjects`).
45
+ * Lists datastores with cursor pagination. `query.data` is every loaded page merged into one
46
+ * `ParsedDatastore[]`, each datastore's matrix converted to row objects — or whatever
47
+ * `select` makes of that list.
51
48
  *
52
- * Parameters (FetchInfiniteDatastoreProps):
53
- * @param {FilterClause[]} [filters=[]]
54
- * Filters applied to every page request. Must include a `workspace` filter.
49
+ * Built to be used directly rather than wrapped: `select` shapes the result, `queryKey` and
50
+ * `DatastoresCache` let an app write to the cache, and `fetchAllPages` reads a whole set.
51
+ * Paging on grid scroll is `handleRowsScrollEnd` from `@everysk/apps-sdk/ag-grid`, kept out of
52
+ * this hook so it works for any list.
55
53
  *
56
- * @param {string[]} [order=[]]
57
- * Sorting applied to every page request.
54
+ * Without a `workspace` filter, or with an empty one, the read fails at once with an error
55
+ * naming this hook, logged to the console, and no request is sent. The app config is in place
56
+ * before the app renders, so a missing workspace is a misconfigured app, never a wait.
58
57
  *
59
- * @param {string} [projection=""]
60
- * Single field to project: `"field"` returns only that field (others come back null),
61
- * `"-field"` returns every field except that one. One field only — lists 500. Omitted when empty.
58
+ * Rows are converted in the request (`parseDatastore`), so the cache holds objects and an
59
+ * app patches a row as `{ ...row, ...patch }`. `dataFormat: "matrix"` skips the conversion and
60
+ * leaves a tabular datastore's matrix unconverted, for a grid that takes arrays, an export, or a
61
+ * datastore too large to convert. It is a value, not a conversion function, so that it can be
62
+ * part of the cache key: two callers converting differently would otherwise share one entry.
62
63
  *
63
- * @param {number} [pageSize=10]
64
- * Number of datastores to fetch per page.
65
- *
66
- * @param {InfiniteOptions<DatastoreWithRows[]>} [queryOptions]
67
- * TanStack Query options passed through to `useInfiniteQuery`
68
- * (e.g., enabled, staleTime, gcTime, etc.).
69
- *
70
- * Returns:
71
- * @returns {object}
72
- * - `query`: the full `useInfiniteQuery` result (data, isLoading, hasNextPage, fetchNextPage, etc.)
73
- * - `queryKey`: the cache key used by React Query
74
- * - `events.handleFetchIfGridEmptyOrNearEnd(gridApi)`: triggers next page fetch when the ag-Grid is empty or near the end of the list
64
+ * @param {FilterClause[]} [filters=[]] - Filters of every page request; one must be `workspace`.
65
+ * @param {string[]} [order=[]] - Sorting of every page request.
66
+ * @param {Projection} [projection=""] - The fields to return, one or a list: `"field"` returns
67
+ * only that field (others come back null), `"-field"` every field but that one. Several go as a
68
+ * list, never comma-joined — `"a,b"` is a 500.
69
+ * @param {number} [pageSize=10] - Datastores per request.
70
+ * @param {"object" | "matrix"} [dataFormat="object"] - How a table's rows are handed over.
71
+ * @param {(datastores: ParsedDatastore[]) => TData} [select] - Shapes the merged list.
72
+ * @param {boolean} [fetchAllPages=false] - Reads to the last page before reporting success.
73
+ * @param {EntityInfiniteQueryOptions} [queryOptions] - Passed through to `useInfiniteQuery`.
74
+ * @returns {object} `query` (the `useInfiniteQuery` result) and `queryKey`.
75
75
  *
76
76
  * Example:
77
77
  * ```ts
78
- * const { query, events } = useFetchDatastores({
79
- * filters: [{ field: "workspace", value: "ws-1" }],
80
- * pageSize: 20,
81
- * });
82
- *
83
- * // Flat list of all fetched datastores with transformed rows
84
- * const datastores = query.data ?? [];
78
+ * // A list can mix tabular and JSON datastores; only a table's `data` is rows.
79
+ * const toRows = (datastores: ParsedDatastore[]) => datastores.filter(isTableDatastore).flatMap((d) => d.data);
85
80
  *
86
- * // Load next page when grid is near end
87
- * <AgGridReact onBodyScroll={() => events.handleFetchIfGridEmptyOrNearEnd(gridApi)} />
81
+ * const { query } = useFetchDatastores({
82
+ * filters: [{ field: "workspace", value: workspace }],
83
+ * select: toRows, // query.data: AnyRecord[]
84
+ * });
88
85
  * ```
89
86
  */
90
- export function useFetchDatastores({ filters = [], order = [], projection = "", pageSize = 10, queryOptions }: FetchInfiniteDatastoreProps) {
87
+ export function useFetchDatastores<
88
+ F extends DatastoreDataFormat = "object",
89
+ TData = ParsedDatastore<F>[],
90
+ >({
91
+ filters = [],
92
+ order = [],
93
+ projection = "",
94
+ pageSize = 10,
95
+ dataFormat,
96
+ select,
97
+ fetchAllPages = false,
98
+ queryOptions,
99
+ }: FetchDatastoresProps<F, TData>) {
91
100
  const { api } = useAxios();
92
101
 
93
- //const fetchingGuardRef = useRef(false);
94
- const queryKey = buildQueryKey(["datastores"], filters);
95
-
96
- const mergedQueryOptions = useMemo<InfiniteOptions<DatastoreWithRows[]>>(() => ({
97
- ...defaultQueryOptions,
98
- ...(queryOptions ?? {}),
99
- }), [queryOptions]);
102
+ const format = (dataFormat ?? "object") as F;
103
+ const queryKey = buildQueryKey(["datastores"], filters, {
104
+ order,
105
+ projection,
106
+ pageSize,
107
+ fetchAllPages,
108
+ dataFormat: format,
109
+ });
100
110
 
101
- const query = useInfiniteQuery<DatastoreQueryPage, Error, DatastoreWithRows[], QueryKey, PageToken>({
111
+ const query = useEntityInfiniteQuery<DatastoreQueryPage<F>, "datastores", TData>({
102
112
  queryKey,
103
- initialPageParam: null,
104
- getNextPageParam: (lastPage) => lastPage.next_page_token ?? undefined,
105
-
106
- queryFn: async ({ pageParam }) => {
107
- const queryFilter = buildQueryObject({
108
- filters,
109
- order,
110
- projection,
111
- pageSize,
112
- pageToken: pageParam ?? undefined,
113
- });
114
-
115
- const response: DatastoreListResponse = await listDatastores(api, queryFilter);
116
-
117
- const nested: DatastoreWithRows[] = response.datastores.map((datastore: Datastore) => ({
118
- ...datastore,
119
- data: tableToObjects(
120
- datastore.id,
121
- datastore.data?.[0] as string[],
122
- datastore.data
123
- ),
124
- }));
113
+ itemsKey: "datastores",
114
+ fetchPage: async (pageToken, signal) => {
115
+ const response: DatastoreListResponse = await listDatastores(
116
+ api,
117
+ buildQueryObject({ filters, order, projection, pageSize, pageToken }),
118
+ signal,
119
+ );
125
120
 
126
121
  return {
127
122
  next_page_token: response.next_page_token,
128
- datastores: nested,
123
+ datastores: response.datastores.map((datastore) =>
124
+ parseDatastore(datastore, format),
125
+ ),
129
126
  };
130
127
  },
131
-
132
- select: (data) => data.pages.flatMap((p) => p.datastores),
133
-
134
- ...mergedQueryOptions,
128
+ select,
129
+ fetchAllPages,
130
+ configError: hasWorkspaceFilter(filters)
131
+ ? undefined
132
+ : missingWorkspaceError("useFetchDatastores"),
133
+ queryOptions,
135
134
  });
136
135
 
137
- /*
138
- const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;
139
- const handleFetchIfGridEmptyOrNearEnd = useCallback((gridApi: GridApi) => {
140
- if (!hasNextPage || isFetchingNextPage || fetchingGuardRef.current) return;
141
-
142
- const total = gridApi.getDisplayedRowCount();
143
- const last = gridApi.getLastDisplayedRowIndex();
144
-
145
- const isEmpty = total === 0 || last < 0;
146
- const isNearEnd = !isEmpty && (total - 1 - last) <= 30;
147
-
148
- if (!isEmpty && !isNearEnd) return;
149
-
150
- fetchingGuardRef.current = true;
151
- fetchNextPage().finally(() => {
152
- fetchingGuardRef.current = false;
153
- });
154
- }, [hasNextPage, isFetchingNextPage, fetchNextPage]);
155
- */
156
-
157
- return {
158
- query,
159
- queryKey,
160
- //events: { handleFetchIfGridEmptyOrNearEnd },
161
- };
162
- }
136
+ return { query, queryKey };
137
+ }
@@ -0,0 +1,19 @@
1
+ import type { EveryskFile } from "@/types/file";
2
+
3
+ /** What the file hooks take about a file's content. */
4
+ export type FileDataProps = {
5
+ /**
6
+ * `true` returns the content (`data`, base64). Left out by default: it is a third larger than
7
+ * the file, and showing or downloading a file needs only its `url` (`/file/<hash>`), which
8
+ * the platform serves inline with the user's session and the devkit's dev server serves too.
9
+ * With a list `projection` of the app's own that includes fields, `data` comes only if the
10
+ * projection names it.
11
+ */
12
+ withData?: boolean;
13
+ };
14
+
15
+ /** The file without its content, as the hooks return it unless `withData` asks for it. */
16
+ export const withoutData = <F extends { data: EveryskFile["data"] }>(file: F): F => ({
17
+ ...file,
18
+ data: null,
19
+ });