@everysk/apps-sdk 0.1.0-beta.0

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 (450) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +128 -0
  3. package/dist/EveryskApp.d.ts +73 -0
  4. package/dist/EveryskApp.d.ts.map +1 -0
  5. package/dist/EveryskApp.js +66 -0
  6. package/dist/EveryskApp.js.map +1 -0
  7. package/dist/agGrid/agGridTheme.d.ts +77 -0
  8. package/dist/agGrid/agGridTheme.d.ts.map +1 -0
  9. package/dist/agGrid/agGridTheme.js +88 -0
  10. package/dist/agGrid/agGridTheme.js.map +1 -0
  11. package/dist/agGrid/index.d.ts +4 -0
  12. package/dist/agGrid/index.d.ts.map +1 -0
  13. package/dist/agGrid/index.js +3 -0
  14. package/dist/api/datastore.d.ts +68 -0
  15. package/dist/api/datastore.d.ts.map +1 -0
  16. package/dist/api/datastore.js +125 -0
  17. package/dist/api/datastore.js.map +1 -0
  18. package/dist/api/entityQuery.d.ts +78 -0
  19. package/dist/api/entityQuery.d.ts.map +1 -0
  20. package/dist/api/entityQuery.js +100 -0
  21. package/dist/api/entityQuery.js.map +1 -0
  22. package/dist/api/file.d.ts +70 -0
  23. package/dist/api/file.d.ts.map +1 -0
  24. package/dist/api/file.js +126 -0
  25. package/dist/api/file.js.map +1 -0
  26. package/dist/api/portfolio.d.ts +67 -0
  27. package/dist/api/portfolio.d.ts.map +1 -0
  28. package/dist/api/portfolio.js +125 -0
  29. package/dist/api/portfolio.js.map +1 -0
  30. package/dist/api/profile.d.ts +40 -0
  31. package/dist/api/profile.d.ts.map +1 -0
  32. package/dist/api/profile.js +71 -0
  33. package/dist/api/profile.js.map +1 -0
  34. package/dist/api/websocketsConfig.d.ts +13 -0
  35. package/dist/api/websocketsConfig.d.ts.map +1 -0
  36. package/dist/api/websocketsConfig.js +25 -0
  37. package/dist/api/websocketsConfig.js.map +1 -0
  38. package/dist/api/workflow.d.ts +154 -0
  39. package/dist/api/workflow.d.ts.map +1 -0
  40. package/dist/api/workflow.js +289 -0
  41. package/dist/api/workflow.js.map +1 -0
  42. package/dist/api/workspace.d.ts +29 -0
  43. package/dist/api/workspace.d.ts.map +1 -0
  44. package/dist/api/workspace.js +54 -0
  45. package/dist/api/workspace.js.map +1 -0
  46. package/dist/components/ui/EveryskIcon/index.d.ts +5 -0
  47. package/dist/components/ui/EveryskIcon/index.d.ts.map +1 -0
  48. package/dist/components/ui/EveryskIcon/index.js +25 -0
  49. package/dist/components/ui/EveryskIcon/index.js.map +1 -0
  50. package/dist/components/ui/Footer/index.d.ts +5 -0
  51. package/dist/components/ui/Footer/index.d.ts.map +1 -0
  52. package/dist/components/ui/Footer/index.js +23 -0
  53. package/dist/components/ui/Footer/index.js.map +1 -0
  54. package/dist/components/ui/GlobalLoading/index.d.ts +8 -0
  55. package/dist/components/ui/GlobalLoading/index.d.ts.map +1 -0
  56. package/dist/components/ui/GlobalLoading/index.js +42 -0
  57. package/dist/components/ui/GlobalLoading/index.js.map +1 -0
  58. package/dist/components/ui/PageContainer/index.d.ts +7 -0
  59. package/dist/components/ui/PageContainer/index.d.ts.map +1 -0
  60. package/dist/components/ui/PageContainer/index.js +20 -0
  61. package/dist/components/ui/PageContainer/index.js.map +1 -0
  62. package/dist/components/ui/Toolbar/index.d.ts +5 -0
  63. package/dist/components/ui/Toolbar/index.d.ts.map +1 -0
  64. package/dist/components/ui/Toolbar/index.js +32 -0
  65. package/dist/components/ui/Toolbar/index.js.map +1 -0
  66. package/dist/contexts/agGridLicenseContext/provider.d.ts +51 -0
  67. package/dist/contexts/agGridLicenseContext/provider.d.ts.map +1 -0
  68. package/dist/contexts/agGridLicenseContext/provider.js +58 -0
  69. package/dist/contexts/agGridLicenseContext/provider.js.map +1 -0
  70. package/dist/contexts/appAlertContext/index.d.ts +3 -0
  71. package/dist/contexts/appAlertContext/index.d.ts.map +1 -0
  72. package/dist/contexts/appAlertContext/index.js +7 -0
  73. package/dist/contexts/appAlertContext/index.js.map +1 -0
  74. package/dist/contexts/appAlertContext/provider.d.ts +40 -0
  75. package/dist/contexts/appAlertContext/provider.d.ts.map +1 -0
  76. package/dist/contexts/appAlertContext/provider.js +96 -0
  77. package/dist/contexts/appAlertContext/provider.js.map +1 -0
  78. package/dist/contexts/appAlertContext/types.d.ts +15 -0
  79. package/dist/contexts/appAlertContext/types.d.ts.map +1 -0
  80. package/dist/contexts/appAlertContext/useAppAlert.d.ts +30 -0
  81. package/dist/contexts/appAlertContext/useAppAlert.d.ts.map +1 -0
  82. package/dist/contexts/appAlertContext/useAppAlert.js +40 -0
  83. package/dist/contexts/appAlertContext/useAppAlert.js.map +1 -0
  84. package/dist/contexts/appConfigContext/index.d.ts +3 -0
  85. package/dist/contexts/appConfigContext/index.d.ts.map +1 -0
  86. package/dist/contexts/appConfigContext/index.js +7 -0
  87. package/dist/contexts/appConfigContext/index.js.map +1 -0
  88. package/dist/contexts/appConfigContext/provider.d.ts +45 -0
  89. package/dist/contexts/appConfigContext/provider.d.ts.map +1 -0
  90. package/dist/contexts/appConfigContext/provider.js +63 -0
  91. package/dist/contexts/appConfigContext/provider.js.map +1 -0
  92. package/dist/contexts/appConfigContext/types.d.ts +28 -0
  93. package/dist/contexts/appConfigContext/types.d.ts.map +1 -0
  94. package/dist/contexts/appConfigContext/useAppConfig.d.ts +20 -0
  95. package/dist/contexts/appConfigContext/useAppConfig.d.ts.map +1 -0
  96. package/dist/contexts/appConfigContext/useAppConfig.js +30 -0
  97. package/dist/contexts/appConfigContext/useAppConfig.js.map +1 -0
  98. package/dist/contexts/webSocketContext/constants.d.ts +4 -0
  99. package/dist/contexts/webSocketContext/constants.d.ts.map +1 -0
  100. package/dist/contexts/webSocketContext/constants.js +8 -0
  101. package/dist/contexts/webSocketContext/constants.js.map +1 -0
  102. package/dist/contexts/webSocketContext/handler.d.ts +43 -0
  103. package/dist/contexts/webSocketContext/handler.d.ts.map +1 -0
  104. package/dist/contexts/webSocketContext/handler.js +87 -0
  105. package/dist/contexts/webSocketContext/handler.js.map +1 -0
  106. package/dist/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.d.ts +19 -0
  107. package/dist/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.d.ts.map +1 -0
  108. package/dist/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.js +31 -0
  109. package/dist/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.js.map +1 -0
  110. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts +11 -0
  111. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts.map +1 -0
  112. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js +21 -0
  113. package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js.map +1 -0
  114. package/dist/contexts/webSocketContext/hooks/useWebSocketSubscription/index.d.ts +30 -0
  115. package/dist/contexts/webSocketContext/hooks/useWebSocketSubscription/index.d.ts.map +1 -0
  116. package/dist/contexts/webSocketContext/hooks/useWebSocketSubscription/index.js +44 -0
  117. package/dist/contexts/webSocketContext/hooks/useWebSocketSubscription/index.js.map +1 -0
  118. package/dist/contexts/webSocketContext/index.d.ts +3 -0
  119. package/dist/contexts/webSocketContext/index.d.ts.map +1 -0
  120. package/dist/contexts/webSocketContext/index.js +7 -0
  121. package/dist/contexts/webSocketContext/index.js.map +1 -0
  122. package/dist/contexts/webSocketContext/provider.d.ts +39 -0
  123. package/dist/contexts/webSocketContext/provider.d.ts.map +1 -0
  124. package/dist/contexts/webSocketContext/provider.js +121 -0
  125. package/dist/contexts/webSocketContext/provider.js.map +1 -0
  126. package/dist/contexts/webSocketContext/types.d.ts +41 -0
  127. package/dist/contexts/webSocketContext/types.d.ts.map +1 -0
  128. package/dist/datastore/index.d.ts +7 -0
  129. package/dist/datastore/index.d.ts.map +1 -0
  130. package/dist/file/index.d.ts +6 -0
  131. package/dist/file/index.d.ts.map +1 -0
  132. package/dist/hooks/datastore/useDatastoreMutations.d.ts +151 -0
  133. package/dist/hooks/datastore/useDatastoreMutations.d.ts.map +1 -0
  134. package/dist/hooks/datastore/useDatastoreMutations.js +198 -0
  135. package/dist/hooks/datastore/useDatastoreMutations.js.map +1 -0
  136. package/dist/hooks/datastore/useFetchDatastore.d.ts +205 -0
  137. package/dist/hooks/datastore/useFetchDatastore.d.ts.map +1 -0
  138. package/dist/hooks/datastore/useFetchDatastore.js +85 -0
  139. package/dist/hooks/datastore/useFetchDatastore.js.map +1 -0
  140. package/dist/hooks/datastore/useFetchDatastores.d.ts +70 -0
  141. package/dist/hooks/datastore/useFetchDatastores.d.ts.map +1 -0
  142. package/dist/hooks/datastore/useFetchDatastores.js +105 -0
  143. package/dist/hooks/datastore/useFetchDatastores.js.map +1 -0
  144. package/dist/hooks/file/useFetchFile.d.ts +212 -0
  145. package/dist/hooks/file/useFetchFile.d.ts.map +1 -0
  146. package/dist/hooks/file/useFetchFile.js +87 -0
  147. package/dist/hooks/file/useFetchFile.js.map +1 -0
  148. package/dist/hooks/file/useFetchFiles.d.ts +60 -0
  149. package/dist/hooks/file/useFetchFiles.d.ts.map +1 -0
  150. package/dist/hooks/file/useFetchFiles.js +89 -0
  151. package/dist/hooks/file/useFetchFiles.js.map +1 -0
  152. package/dist/hooks/file/useFileMutations.d.ts +161 -0
  153. package/dist/hooks/file/useFileMutations.d.ts.map +1 -0
  154. package/dist/hooks/file/useFileMutations.js +208 -0
  155. package/dist/hooks/file/useFileMutations.js.map +1 -0
  156. package/dist/hooks/portfolio/useFetchPortfolio.d.ts +210 -0
  157. package/dist/hooks/portfolio/useFetchPortfolio.d.ts.map +1 -0
  158. package/dist/hooks/portfolio/useFetchPortfolio.js +85 -0
  159. package/dist/hooks/portfolio/useFetchPortfolio.js.map +1 -0
  160. package/dist/hooks/portfolio/useFetchPortfolios.d.ts +60 -0
  161. package/dist/hooks/portfolio/useFetchPortfolios.d.ts.map +1 -0
  162. package/dist/hooks/portfolio/useFetchPortfolios.js +89 -0
  163. package/dist/hooks/portfolio/useFetchPortfolios.js.map +1 -0
  164. package/dist/hooks/portfolio/usePortfolioMutations.d.ts +171 -0
  165. package/dist/hooks/portfolio/usePortfolioMutations.d.ts.map +1 -0
  166. package/dist/hooks/portfolio/usePortfolioMutations.js +218 -0
  167. package/dist/hooks/portfolio/usePortfolioMutations.js.map +1 -0
  168. package/dist/hooks/profile/useFetchProfile.d.ts +206 -0
  169. package/dist/hooks/profile/useFetchProfile.d.ts.map +1 -0
  170. package/dist/hooks/profile/useFetchProfile.js +70 -0
  171. package/dist/hooks/profile/useFetchProfile.js.map +1 -0
  172. package/dist/hooks/useAxios.d.ts +40 -0
  173. package/dist/hooks/useAxios.d.ts.map +1 -0
  174. package/dist/hooks/useAxios.js +76 -0
  175. package/dist/hooks/useAxios.js.map +1 -0
  176. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts +198 -0
  177. package/dist/hooks/workflow/useFetchWorkerExecution.d.ts.map +1 -0
  178. package/dist/hooks/workflow/useFetchWorkerExecution.js +69 -0
  179. package/dist/hooks/workflow/useFetchWorkerExecution.js.map +1 -0
  180. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts +52 -0
  181. package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts.map +1 -0
  182. package/dist/hooks/workflow/useFetchWorkerExecutions.js +83 -0
  183. package/dist/hooks/workflow/useFetchWorkerExecutions.js.map +1 -0
  184. package/dist/hooks/workflow/useFetchWorkflow.d.ts +195 -0
  185. package/dist/hooks/workflow/useFetchWorkflow.d.ts.map +1 -0
  186. package/dist/hooks/workflow/useFetchWorkflow.js +70 -0
  187. package/dist/hooks/workflow/useFetchWorkflow.js.map +1 -0
  188. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts +198 -0
  189. package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts.map +1 -0
  190. package/dist/hooks/workflow/useFetchWorkflowExecution.js +69 -0
  191. package/dist/hooks/workflow/useFetchWorkflowExecution.js.map +1 -0
  192. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts +49 -0
  193. package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts.map +1 -0
  194. package/dist/hooks/workflow/useFetchWorkflowExecutions.js +77 -0
  195. package/dist/hooks/workflow/useFetchWorkflowExecutions.js.map +1 -0
  196. package/dist/hooks/workflow/useFetchWorkflows.d.ts +47 -0
  197. package/dist/hooks/workflow/useFetchWorkflows.d.ts.map +1 -0
  198. package/dist/hooks/workflow/useFetchWorkflows.js +67 -0
  199. package/dist/hooks/workflow/useFetchWorkflows.js.map +1 -0
  200. package/dist/hooks/workflow/useRunWorkflow.d.ts +30 -0
  201. package/dist/hooks/workflow/useRunWorkflow.d.ts.map +1 -0
  202. package/dist/hooks/workflow/useRunWorkflow.js +50 -0
  203. package/dist/hooks/workflow/useRunWorkflow.js.map +1 -0
  204. package/dist/hooks/workspace/useFetchWorkspace.d.ts +197 -0
  205. package/dist/hooks/workspace/useFetchWorkspace.d.ts.map +1 -0
  206. package/dist/hooks/workspace/useFetchWorkspace.js +65 -0
  207. package/dist/hooks/workspace/useFetchWorkspace.js.map +1 -0
  208. package/dist/hooks/workspace/useFetchWorkspaces.d.ts +46 -0
  209. package/dist/hooks/workspace/useFetchWorkspaces.d.ts.map +1 -0
  210. package/dist/hooks/workspace/useFetchWorkspaces.js +66 -0
  211. package/dist/hooks/workspace/useFetchWorkspaces.js.map +1 -0
  212. package/dist/index.d.ts +24 -0
  213. package/dist/index.d.ts.map +1 -0
  214. package/dist/index.js +50 -0
  215. package/dist/lib/datastoreTable.d.ts +126 -0
  216. package/dist/lib/datastoreTable.d.ts.map +1 -0
  217. package/dist/lib/datastoreTable.js +146 -0
  218. package/dist/lib/datastoreTable.js.map +1 -0
  219. package/dist/lib/queryClient.d.ts +24 -0
  220. package/dist/lib/queryClient.d.ts.map +1 -0
  221. package/dist/lib/queryClient.js +48 -0
  222. package/dist/lib/queryClient.js.map +1 -0
  223. package/dist/portfolio/index.d.ts +6 -0
  224. package/dist/portfolio/index.d.ts.map +1 -0
  225. package/dist/profile/index.d.ts +4 -0
  226. package/dist/profile/index.d.ts.map +1 -0
  227. package/dist/socket/index.d.ts +10 -0
  228. package/dist/socket/index.d.ts.map +1 -0
  229. package/dist/socket/index.js +9 -0
  230. package/dist/test/index.d.ts +2 -0
  231. package/dist/test/index.d.ts.map +1 -0
  232. package/dist/test/index.js +2 -0
  233. package/dist/test/mocks/agGridEnterprise.d.ts +38 -0
  234. package/dist/test/mocks/agGridEnterprise.d.ts.map +1 -0
  235. package/dist/test/mocks/agGridEnterprise.js +43 -0
  236. package/dist/test/mocks/agGridEnterprise.js.map +1 -0
  237. package/dist/test/mocks/agGridReact.d.ts +42 -0
  238. package/dist/test/mocks/agGridReact.d.ts.map +1 -0
  239. package/dist/test/mocks/agGridReact.js +47 -0
  240. package/dist/test/mocks/agGridReact.js.map +1 -0
  241. package/dist/test/mocks/index.d.ts +5 -0
  242. package/dist/test/mocks/index.d.ts.map +1 -0
  243. package/dist/test/mocks/index.js +4 -0
  244. package/dist/test/mocks/socketIoClient.d.ts +45 -0
  245. package/dist/test/mocks/socketIoClient.d.ts.map +1 -0
  246. package/dist/test/mocks/socketIoClient.js +54 -0
  247. package/dist/test/mocks/socketIoClient.js.map +1 -0
  248. package/dist/test/renderWithProviders.d.ts +107 -0
  249. package/dist/test/renderWithProviders.d.ts.map +1 -0
  250. package/dist/test/renderWithProviders.js +85 -0
  251. package/dist/test/renderWithProviders.js.map +1 -0
  252. package/dist/test/setup.d.ts +2 -0
  253. package/dist/test/setup.d.ts.map +1 -0
  254. package/dist/test/setup.js +25 -0
  255. package/dist/test/setup.js.map +1 -0
  256. package/dist/theme/ThemeProvider.d.ts +12 -0
  257. package/dist/theme/ThemeProvider.d.ts.map +1 -0
  258. package/dist/theme/ThemeProvider.js +22 -0
  259. package/dist/theme/ThemeProvider.js.map +1 -0
  260. package/dist/theme/index.d.ts +9 -0
  261. package/dist/theme/index.d.ts.map +1 -0
  262. package/dist/theme/overrides/index.d.ts +7 -0
  263. package/dist/theme/overrides/index.d.ts.map +1 -0
  264. package/dist/theme/overrides/index.js +31 -0
  265. package/dist/theme/overrides/index.js.map +1 -0
  266. package/dist/theme/overrides/muiButton.d.ts +3 -0
  267. package/dist/theme/overrides/muiButton.d.ts.map +1 -0
  268. package/dist/theme/overrides/muiButton.js +6 -0
  269. package/dist/theme/overrides/muiButton.js.map +1 -0
  270. package/dist/theme/overrides/muiCssBaseline.d.ts +31 -0
  271. package/dist/theme/overrides/muiCssBaseline.d.ts.map +1 -0
  272. package/dist/theme/overrides/muiCssBaseline.js +27 -0
  273. package/dist/theme/overrides/muiCssBaseline.js.map +1 -0
  274. package/dist/theme/overrides/muiDatePicker.d.ts +10 -0
  275. package/dist/theme/overrides/muiDatePicker.d.ts.map +1 -0
  276. package/dist/theme/overrides/muiDatePicker.js +6 -0
  277. package/dist/theme/overrides/muiDatePicker.js.map +1 -0
  278. package/dist/theme/overrides/muiFormControl.d.ts +3 -0
  279. package/dist/theme/overrides/muiFormControl.d.ts.map +1 -0
  280. package/dist/theme/overrides/muiFormControl.js +6 -0
  281. package/dist/theme/overrides/muiFormControl.js.map +1 -0
  282. package/dist/theme/overrides/muiIconButton.d.ts +3 -0
  283. package/dist/theme/overrides/muiIconButton.d.ts.map +1 -0
  284. package/dist/theme/overrides/muiIconButton.js +6 -0
  285. package/dist/theme/overrides/muiIconButton.js.map +1 -0
  286. package/dist/theme/overrides/muiSelect.d.ts +3 -0
  287. package/dist/theme/overrides/muiSelect.d.ts.map +1 -0
  288. package/dist/theme/overrides/muiSelect.js +6 -0
  289. package/dist/theme/overrides/muiSelect.js.map +1 -0
  290. package/dist/theme/overrides/muiSvgIcon.d.ts +3 -0
  291. package/dist/theme/overrides/muiSvgIcon.d.ts.map +1 -0
  292. package/dist/theme/overrides/muiSvgIcon.js +6 -0
  293. package/dist/theme/overrides/muiSvgIcon.js.map +1 -0
  294. package/dist/theme/overrides/muiTextField.d.ts +3 -0
  295. package/dist/theme/overrides/muiTextField.d.ts.map +1 -0
  296. package/dist/theme/overrides/muiTextField.js +6 -0
  297. package/dist/theme/overrides/muiTextField.js.map +1 -0
  298. package/dist/theme/overrides/muiToggleButton.d.ts +3 -0
  299. package/dist/theme/overrides/muiToggleButton.d.ts.map +1 -0
  300. package/dist/theme/overrides/muiToggleButton.js +6 -0
  301. package/dist/theme/overrides/muiToggleButton.js.map +1 -0
  302. package/dist/theme/overrides/muiToggleButtonGroup.d.ts +3 -0
  303. package/dist/theme/overrides/muiToggleButtonGroup.d.ts.map +1 -0
  304. package/dist/theme/overrides/muiToggleButtonGroup.js +6 -0
  305. package/dist/theme/overrides/muiToggleButtonGroup.js.map +1 -0
  306. package/dist/theme/themes/DefaultDark.d.ts +7 -0
  307. package/dist/theme/themes/DefaultDark.d.ts.map +1 -0
  308. package/dist/theme/themes/DefaultDark.js +15 -0
  309. package/dist/theme/themes/DefaultDark.js.map +1 -0
  310. package/dist/theme/themes/DefaultLight.d.ts +7 -0
  311. package/dist/theme/themes/DefaultLight.d.ts.map +1 -0
  312. package/dist/theme/themes/DefaultLight.js +15 -0
  313. package/dist/theme/themes/DefaultLight.js.map +1 -0
  314. package/dist/theme/themes/EveryskDark.d.ts +15 -0
  315. package/dist/theme/themes/EveryskDark.d.ts.map +1 -0
  316. package/dist/theme/themes/EveryskDark.js +63 -0
  317. package/dist/theme/themes/EveryskDark.js.map +1 -0
  318. package/dist/theme/themes/EveryskLight.d.ts +21 -0
  319. package/dist/theme/themes/EveryskLight.d.ts.map +1 -0
  320. package/dist/theme/themes/EveryskLight.js +69 -0
  321. package/dist/theme/themes/EveryskLight.js.map +1 -0
  322. package/dist/theme/themes/MidnightEmber.d.ts +3 -0
  323. package/dist/theme/themes/MidnightEmber.d.ts.map +1 -0
  324. package/dist/theme/themes/MidnightEmber.js +31 -0
  325. package/dist/theme/themes/MidnightEmber.js.map +1 -0
  326. package/dist/theme/themes/index.d.ts +17 -0
  327. package/dist/theme/themes/index.d.ts.map +1 -0
  328. package/dist/theme/themes/index.js +32 -0
  329. package/dist/theme/themes/index.js.map +1 -0
  330. package/dist/types/anyRecord.d.ts +4 -0
  331. package/dist/types/anyRecord.d.ts.map +1 -0
  332. package/dist/types/datastore.d.ts +26 -0
  333. package/dist/types/datastore.d.ts.map +1 -0
  334. package/dist/types/entityQuery.d.ts +47 -0
  335. package/dist/types/entityQuery.d.ts.map +1 -0
  336. package/dist/types/file.d.ts +29 -0
  337. package/dist/types/file.d.ts.map +1 -0
  338. package/dist/types/portfolio.d.ts +77 -0
  339. package/dist/types/portfolio.d.ts.map +1 -0
  340. package/dist/types/profile.d.ts +37 -0
  341. package/dist/types/profile.d.ts.map +1 -0
  342. package/dist/types/workflow.d.ts +68 -0
  343. package/dist/types/workflow.d.ts.map +1 -0
  344. package/dist/types/workspace.d.ts +13 -0
  345. package/dist/types/workspace.d.ts.map +1 -0
  346. package/dist/ui/index.d.ts +6 -0
  347. package/dist/ui/index.d.ts.map +1 -0
  348. package/dist/workflow/index.d.ts +10 -0
  349. package/dist/workflow/index.d.ts.map +1 -0
  350. package/dist/workspace/index.d.ts +5 -0
  351. package/dist/workspace/index.d.ts.map +1 -0
  352. package/package.json +148 -0
  353. package/src/EveryskApp.tsx +108 -0
  354. package/src/agGrid/agGridTheme.ts +113 -0
  355. package/src/agGrid/index.ts +15 -0
  356. package/src/api/datastore.ts +175 -0
  357. package/src/api/entityQuery.ts +101 -0
  358. package/src/api/file.ts +174 -0
  359. package/src/api/portfolio.ts +190 -0
  360. package/src/api/profile.ts +80 -0
  361. package/src/api/websocketsConfig.ts +32 -0
  362. package/src/api/workflow.ts +427 -0
  363. package/src/api/workspace.ts +72 -0
  364. package/src/components/ui/EveryskIcon/index.tsx +24 -0
  365. package/src/components/ui/Footer/index.tsx +30 -0
  366. package/src/components/ui/GlobalLoading/index.tsx +38 -0
  367. package/src/components/ui/PageContainer/index.tsx +14 -0
  368. package/src/components/ui/Toolbar/index.tsx +44 -0
  369. package/src/contexts/agGridLicenseContext/provider.tsx +63 -0
  370. package/src/contexts/appAlertContext/index.tsx +4 -0
  371. package/src/contexts/appAlertContext/provider.tsx +92 -0
  372. package/src/contexts/appAlertContext/types.ts +17 -0
  373. package/src/contexts/appAlertContext/useAppAlert.ts +39 -0
  374. package/src/contexts/appConfigContext/index.tsx +4 -0
  375. package/src/contexts/appConfigContext/provider.tsx +67 -0
  376. package/src/contexts/appConfigContext/types.ts +28 -0
  377. package/src/contexts/appConfigContext/useAppConfig.ts +30 -0
  378. package/src/contexts/webSocketContext/constants.ts +3 -0
  379. package/src/contexts/webSocketContext/handler.ts +108 -0
  380. package/src/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.ts +36 -0
  381. package/src/contexts/webSocketContext/hooks/useWebSocket/index.ts +18 -0
  382. package/src/contexts/webSocketContext/hooks/useWebSocketSubscription/index.ts +45 -0
  383. package/src/contexts/webSocketContext/index.tsx +5 -0
  384. package/src/contexts/webSocketContext/provider.tsx +125 -0
  385. package/src/contexts/webSocketContext/types.ts +50 -0
  386. package/src/datastore/index.ts +14 -0
  387. package/src/file/index.ts +13 -0
  388. package/src/hooks/datastore/useDatastoreMutations.ts +221 -0
  389. package/src/hooks/datastore/useFetchDatastore.ts +95 -0
  390. package/src/hooks/datastore/useFetchDatastores.ts +162 -0
  391. package/src/hooks/file/useFetchFile.ts +93 -0
  392. package/src/hooks/file/useFetchFiles.ts +109 -0
  393. package/src/hooks/file/useFileMutations.ts +240 -0
  394. package/src/hooks/portfolio/useFetchPortfolio.ts +94 -0
  395. package/src/hooks/portfolio/useFetchPortfolios.ts +109 -0
  396. package/src/hooks/portfolio/usePortfolioMutations.ts +250 -0
  397. package/src/hooks/profile/useFetchProfile.ts +93 -0
  398. package/src/hooks/useAxios.ts +98 -0
  399. package/src/hooks/workflow/useFetchWorkerExecution.ts +78 -0
  400. package/src/hooks/workflow/useFetchWorkerExecutions.ts +98 -0
  401. package/src/hooks/workflow/useFetchWorkflow.ts +76 -0
  402. package/src/hooks/workflow/useFetchWorkflowExecution.ts +79 -0
  403. package/src/hooks/workflow/useFetchWorkflowExecutions.ts +95 -0
  404. package/src/hooks/workflow/useFetchWorkflows.ts +84 -0
  405. package/src/hooks/workflow/useRunWorkflow.ts +62 -0
  406. package/src/hooks/workspace/useFetchWorkspace.ts +78 -0
  407. package/src/hooks/workspace/useFetchWorkspaces.ts +86 -0
  408. package/src/index.ts +72 -0
  409. package/src/lib/datastoreTable.ts +159 -0
  410. package/src/lib/queryClient.ts +60 -0
  411. package/src/portfolio/index.ts +13 -0
  412. package/src/profile/index.ts +11 -0
  413. package/src/socket/index.ts +19 -0
  414. package/src/test/index.ts +10 -0
  415. package/src/test/mocks/agGridEnterprise.ts +45 -0
  416. package/src/test/mocks/agGridReact.tsx +61 -0
  417. package/src/test/mocks/index.ts +22 -0
  418. package/src/test/mocks/socketIoClient.ts +78 -0
  419. package/src/test/renderWithProviders.tsx +114 -0
  420. package/src/test/setup.ts +46 -0
  421. package/src/theme/ThemeProvider.tsx +33 -0
  422. package/src/theme/index.ts +15 -0
  423. package/src/theme/overrides/index.ts +31 -0
  424. package/src/theme/overrides/muiButton.ts +7 -0
  425. package/src/theme/overrides/muiCssBaseline.ts +35 -0
  426. package/src/theme/overrides/muiDatePicker.ts +5 -0
  427. package/src/theme/overrides/muiFormControl.ts +7 -0
  428. package/src/theme/overrides/muiIconButton.ts +7 -0
  429. package/src/theme/overrides/muiSelect.ts +7 -0
  430. package/src/theme/overrides/muiSvgIcon.ts +7 -0
  431. package/src/theme/overrides/muiTextField.ts +7 -0
  432. package/src/theme/overrides/muiToggleButton.ts +7 -0
  433. package/src/theme/overrides/muiToggleButtonGroup.ts +7 -0
  434. package/src/theme/themes/DefaultDark.ts +14 -0
  435. package/src/theme/themes/DefaultLight.ts +14 -0
  436. package/src/theme/themes/EveryskDark.ts +62 -0
  437. package/src/theme/themes/EveryskLight.ts +68 -0
  438. package/src/theme/themes/MidnightEmber.ts +30 -0
  439. package/src/theme/themes/index.ts +35 -0
  440. package/src/types/anyRecord.ts +4 -0
  441. package/src/types/datastore.ts +33 -0
  442. package/src/types/entityQuery.ts +64 -0
  443. package/src/types/file.ts +32 -0
  444. package/src/types/portfolio.ts +81 -0
  445. package/src/types/profile.ts +39 -0
  446. package/src/types/workflow.ts +76 -0
  447. package/src/types/workspace.ts +15 -0
  448. package/src/ui/index.ts +14 -0
  449. package/src/workflow/index.ts +17 -0
  450. package/src/workspace/index.ts +12 -0
@@ -0,0 +1,218 @@
1
+ import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
2
+ import { useAxios } from "../useAxios.js";
3
+ import { createPortfolio, deletePortfolio, updatePortfolio } from "../../api/portfolio.js";
4
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
5
+ //#region src/hooks/portfolio/usePortfolioMutations.ts
6
+ var getErrorMessage = (err, fallback) => err instanceof Error && err.message ? err.message : fallback;
7
+ /**
8
+ * usePortfolioMutations
9
+ *
10
+ * Mutation hook built on TanStack Query to perform Portfolio write operations:
11
+ * - create a portfolio (POST)
12
+ * - update a portfolio (PUT)
13
+ * - delete a portfolio (DELETE)
14
+ *
15
+ * It also:
16
+ * - optionally invalidates a target query cache key after successful mutations
17
+ * - displays success/error alerts via `useAppAlert`
18
+ *
19
+ * Important notes:
20
+ * - This hook is intended for side-effect operations only. Reading/retrieving data should be done via `useQuery` or `useFetchPortfolio`.
21
+ * - Cache invalidation is controlled by `queryKey`. If `queryKey` is not provided, the hook will still run
22
+ * mutations and show alerts, but it will NOT invalidate any cached queries.
23
+ * - `remove` requires a `workspace` parameter because the underlying API helper `deletePortfolio(api, id, workspace)`
24
+ * expects it as a query param.
25
+ *
26
+ * Parameters (UsePortfolioMutationsProps):
27
+ * @param {unknown[]} [queryKey]
28
+ * Query key to invalidate after successful mutations. Use the same `queryKey` you pass to the relevant `useQuery`
29
+ * (e.g., portfolio list/detail) so UI data is refreshed automatically after a write.
30
+ *
31
+ * Tip:
32
+ * - If you're using `useFetchPortfolio`, you can pass its returned `queryKey` directly:
33
+ * `const fetch = useFetchPortfolio(...);`
34
+ * `usePortfolioMutations({ queryKey: fetch.queryKey });`
35
+ *
36
+ * Mutations:
37
+ * - `create`:
38
+ * - mutationFn: `createPortfolio(api, data)`
39
+ * - variables: `{ data: Partial<Portfolio> }`
40
+ * - success message: "Portfolio created successfully."
41
+ * - error message: "We couldn't create the portfolio. Please review your inputs and try again." (fallback)
42
+ *
43
+ * - `update`:
44
+ * - mutationFn: `updatePortfolio(api, id, data)`
45
+ * - variables: `{ id: string; data: Partial<Portfolio> }`
46
+ * - success message: "Portfolio updated successfully."
47
+ * - error message: "We couldn't update the portfolio. Please try again." (fallback)
48
+ *
49
+ * - `remove`:
50
+ * - mutationFn: `deletePortfolio(api, id, workspace)`
51
+ * - variables: `{ id: string; workspace: string }`
52
+ * - success message: "Portfolio deleted successfully."
53
+ * - error message: "We couldn't delete the portfolio. Please try again." (fallback)
54
+ *
55
+ * Return value:
56
+ * @returns {object}
57
+ * Returns an object with the three TanStack Query mutation results:
58
+ * - `create`: UseMutationResult<Portfolio, Error, CreatePortfolioProps, unknown>
59
+ * - `update`: UseMutationResult<Portfolio, Error, UpdatePortfolioProps, unknown>
60
+ * - `remove`: UseMutationResult<Portfolio, Error, DeletePortfolioProps, unknown>
61
+ *
62
+ * Each mutation includes standard TanStack Query helpers:
63
+ * - `mutate(variables, options?)`
64
+ * - `mutateAsync(variables, options?)`
65
+ * - `isPending`, `isSuccess`, `isError`, `error`, `data`, etc.
66
+ *
67
+ * Examples:
68
+ *
69
+ * 1) Invalidate a portfolio list query after mutations:
70
+ * ```ts
71
+ * const { create, update, remove } = usePortfolioMutations({ queryKey: ["portfolio"] });
72
+ *
73
+ * // Create (minimal example - other Security fields omitted for brevity)
74
+ * create.mutate({
75
+ * data: {
76
+ * name: "My Portfolio",
77
+ * description: "Test portfolio",
78
+ * base_currency: "USD",
79
+ * date: "2026-01-08",
80
+ * workspace: "ws-1",
81
+ * securities: [
82
+ * {
83
+ * id: "sec-1",
84
+ * ticker: "AAPL",
85
+ * symbol: "AAPL",
86
+ * name: "Apple Inc.",
87
+ * currency: "USD",
88
+ * quantity: 10,
89
+ * market_price: 200,
90
+ * market_value: 2000,
91
+ * market_value_in_base: 2000,
92
+ * fx_rate: 1,
93
+ * instrument_type: "Equity",
94
+ * instrument_class: "Equity",
95
+ * asset_class: "Equity",
96
+ * exchange: "NASDAQ",
97
+ * status: "active",
98
+ * // Other fields are nullable in the Security type and can be omitted here for documentation purposes.
99
+ * } as Security,
100
+ * ],
101
+ * }
102
+ * });
103
+ *
104
+ * // Update (partial)
105
+ * update.mutate({
106
+ * id: "pf-123",
107
+ * data: {
108
+ * name: "Renamed Portfolio",
109
+ * tags: ["tag-1", "tag-2"],
110
+ * check_securities: true,
111
+ * }
112
+ * });
113
+ *
114
+ * // Delete
115
+ * remove.mutate({ id: "pf-123", workspace: "ws-1" });
116
+ * ```
117
+ *
118
+ * 2) Using async/await with `mutateAsync`:
119
+ * ```ts
120
+ * const { create } = usePortfolioMutations({ queryKey: ["portfolio"] });
121
+ *
122
+ * await create.mutateAsync({
123
+ * data: {
124
+ * name: "My Portfolio",
125
+ * base_currency: "USD",
126
+ * date: "2026-01-08",
127
+ * workspace: "ws-1",
128
+ * securities: [],
129
+ * }
130
+ * });
131
+ * ```
132
+ *
133
+ * 3) Without cache invalidation (no queryKey):
134
+ * ```ts
135
+ * const { update } = usePortfolioMutations({});
136
+ *
137
+ * update.mutate({
138
+ * id: "pf-123",
139
+ * data: { description: "Updated description" }
140
+ * });
141
+ * // Mutation still runs and alerts are shown, but cached queries are not invalidated.
142
+ * ```
143
+ *
144
+ * 4) Using `useFetchPortfolio` queryKey for automatic invalidation:
145
+ * ```ts
146
+ * const fetch = useFetchPortfolio({
147
+ * id: null,
148
+ * filters: [{ field: "workspace", value: "ws-1" }],
149
+ * });
150
+ *
151
+ * const { remove } = usePortfolioMutations({ queryKey: fetch.queryKey });
152
+ *
153
+ * await remove.mutateAsync({ id: "pf-123", workspace: "ws-1" });
154
+ * ```
155
+ */
156
+ var usePortfolioMutations = ({ queryKey }) => {
157
+ const { api } = useAxios();
158
+ const { showAlert } = useAppAlert();
159
+ const queryClient = useQueryClient();
160
+ const invalidate = async () => {
161
+ if (!queryKey?.length) return;
162
+ await queryClient.invalidateQueries({ queryKey });
163
+ };
164
+ return {
165
+ create: useMutation({
166
+ mutationFn: async ({ data }) => createPortfolio(api, data),
167
+ onSuccess: async () => {
168
+ await invalidate();
169
+ showAlert({
170
+ severity: "success",
171
+ message: "Portfolio created successfully."
172
+ });
173
+ },
174
+ onError: (err) => {
175
+ showAlert({
176
+ severity: "error",
177
+ message: getErrorMessage(err, "We couldn't create the portfolio. Please review your inputs and try again.")
178
+ });
179
+ }
180
+ }),
181
+ update: useMutation({
182
+ mutationFn: async ({ id, data }) => updatePortfolio(api, id, data),
183
+ onSuccess: async () => {
184
+ await invalidate();
185
+ showAlert({
186
+ severity: "success",
187
+ message: "Portfolio updated successfully."
188
+ });
189
+ },
190
+ onError: (err) => {
191
+ showAlert({
192
+ severity: "error",
193
+ message: getErrorMessage(err, "We couldn't update the portfolio. Please try again.")
194
+ });
195
+ }
196
+ }),
197
+ remove: useMutation({
198
+ mutationFn: async ({ id, workspace }) => deletePortfolio(api, id, workspace),
199
+ onSuccess: async () => {
200
+ await invalidate();
201
+ showAlert({
202
+ severity: "success",
203
+ message: "Portfolio deleted successfully."
204
+ });
205
+ },
206
+ onError: (err) => {
207
+ showAlert({
208
+ severity: "error",
209
+ message: getErrorMessage(err, "We couldn't delete the portfolio. Please try again.")
210
+ });
211
+ }
212
+ })
213
+ };
214
+ };
215
+ //#endregion
216
+ export { usePortfolioMutations };
217
+
218
+ //# sourceMappingURL=usePortfolioMutations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePortfolioMutations.js","names":[],"sources":["../../../src/hooks/portfolio/usePortfolioMutations.ts"],"sourcesContent":["import { useMutation, useQueryClient } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport type { Portfolio } from \"@/types/portfolio\";\nimport { deletePortfolio, createPortfolio, updatePortfolio } from \"@/api/portfolio\";\n\ntype CreatePortfolioProps = {\n data: Partial<Portfolio>;\n};\n\ntype UpdatePortfolioProps = {\n id: string;\n data: Partial<Portfolio>;\n};\n\ntype DeletePortfolioProps = {\n id: string;\n workspace: string;\n};\n\ntype UsePortfolioMutationsProps = {\n queryKey?: unknown[];\n};\n\nconst getErrorMessage = (err: unknown, fallback: string) =>\n err instanceof Error && err.message ? err.message : fallback;\n\n/**\n * usePortfolioMutations\n *\n * Mutation hook built on TanStack Query to perform Portfolio write operations:\n * - create a portfolio (POST)\n * - update a portfolio (PUT)\n * - delete a portfolio (DELETE)\n *\n * It also:\n * - optionally invalidates a target query cache key after successful mutations\n * - displays success/error alerts via `useAppAlert`\n *\n * Important notes:\n * - This hook is intended for side-effect operations only. Reading/retrieving data should be done via `useQuery` or `useFetchPortfolio`.\n * - Cache invalidation is controlled by `queryKey`. If `queryKey` is not provided, the hook will still run\n * mutations and show alerts, but it will NOT invalidate any cached queries.\n * - `remove` requires a `workspace` parameter because the underlying API helper `deletePortfolio(api, id, workspace)`\n * expects it as a query param.\n *\n * Parameters (UsePortfolioMutationsProps):\n * @param {unknown[]} [queryKey]\n * Query key to invalidate after successful mutations. Use the same `queryKey` you pass to the relevant `useQuery`\n * (e.g., portfolio list/detail) so UI data is refreshed automatically after a write.\n *\n * Tip:\n * - If you're using `useFetchPortfolio`, you can pass its returned `queryKey` directly:\n * `const fetch = useFetchPortfolio(...);`\n * `usePortfolioMutations({ queryKey: fetch.queryKey });`\n *\n * Mutations:\n * - `create`:\n * - mutationFn: `createPortfolio(api, data)`\n * - variables: `{ data: Partial<Portfolio> }`\n * - success message: \"Portfolio created successfully.\"\n * - error message: \"We couldn't create the portfolio. Please review your inputs and try again.\" (fallback)\n *\n * - `update`:\n * - mutationFn: `updatePortfolio(api, id, data)`\n * - variables: `{ id: string; data: Partial<Portfolio> }`\n * - success message: \"Portfolio updated successfully.\"\n * - error message: \"We couldn't update the portfolio. Please try again.\" (fallback)\n *\n * - `remove`:\n * - mutationFn: `deletePortfolio(api, id, workspace)`\n * - variables: `{ id: string; workspace: string }`\n * - success message: \"Portfolio deleted successfully.\"\n * - error message: \"We couldn't delete the portfolio. Please try again.\" (fallback)\n *\n * Return value:\n * @returns {object}\n * Returns an object with the three TanStack Query mutation results:\n * - `create`: UseMutationResult<Portfolio, Error, CreatePortfolioProps, unknown>\n * - `update`: UseMutationResult<Portfolio, Error, UpdatePortfolioProps, unknown>\n * - `remove`: UseMutationResult<Portfolio, Error, DeletePortfolioProps, unknown>\n *\n * Each mutation includes standard TanStack Query helpers:\n * - `mutate(variables, options?)`\n * - `mutateAsync(variables, options?)`\n * - `isPending`, `isSuccess`, `isError`, `error`, `data`, etc.\n *\n * Examples:\n *\n * 1) Invalidate a portfolio list query after mutations:\n * ```ts\n * const { create, update, remove } = usePortfolioMutations({ queryKey: [\"portfolio\"] });\n *\n * // Create (minimal example - other Security fields omitted for brevity)\n * create.mutate({\n * data: {\n * name: \"My Portfolio\",\n * description: \"Test portfolio\",\n * base_currency: \"USD\",\n * date: \"2026-01-08\",\n * workspace: \"ws-1\",\n * securities: [\n * {\n * id: \"sec-1\",\n * ticker: \"AAPL\",\n * symbol: \"AAPL\",\n * name: \"Apple Inc.\",\n * currency: \"USD\",\n * quantity: 10,\n * market_price: 200,\n * market_value: 2000,\n * market_value_in_base: 2000,\n * fx_rate: 1,\n * instrument_type: \"Equity\",\n * instrument_class: \"Equity\",\n * asset_class: \"Equity\",\n * exchange: \"NASDAQ\",\n * status: \"active\",\n * // Other fields are nullable in the Security type and can be omitted here for documentation purposes.\n * } as Security,\n * ],\n * }\n * });\n *\n * // Update (partial)\n * update.mutate({\n * id: \"pf-123\",\n * data: {\n * name: \"Renamed Portfolio\",\n * tags: [\"tag-1\", \"tag-2\"],\n * check_securities: true,\n * }\n * });\n *\n * // Delete\n * remove.mutate({ id: \"pf-123\", workspace: \"ws-1\" });\n * ```\n *\n * 2) Using async/await with `mutateAsync`:\n * ```ts\n * const { create } = usePortfolioMutations({ queryKey: [\"portfolio\"] });\n *\n * await create.mutateAsync({\n * data: {\n * name: \"My Portfolio\",\n * base_currency: \"USD\",\n * date: \"2026-01-08\",\n * workspace: \"ws-1\",\n * securities: [],\n * }\n * });\n * ```\n *\n * 3) Without cache invalidation (no queryKey):\n * ```ts\n * const { update } = usePortfolioMutations({});\n *\n * update.mutate({\n * id: \"pf-123\",\n * data: { description: \"Updated description\" }\n * });\n * // Mutation still runs and alerts are shown, but cached queries are not invalidated.\n * ```\n *\n * 4) Using `useFetchPortfolio` queryKey for automatic invalidation:\n * ```ts\n * const fetch = useFetchPortfolio({\n * id: null,\n * filters: [{ field: \"workspace\", value: \"ws-1\" }],\n * });\n *\n * const { remove } = usePortfolioMutations({ queryKey: fetch.queryKey });\n *\n * await remove.mutateAsync({ id: \"pf-123\", workspace: \"ws-1\" });\n * ```\n */\n\nexport const usePortfolioMutations = ({ queryKey }: UsePortfolioMutationsProps) => {\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n const queryClient = useQueryClient();\n\n const invalidate = async () => {\n if (!queryKey?.length) return;\n await queryClient.invalidateQueries({ queryKey });\n };\n\n const create = useMutation({\n mutationFn: async ({ data }: CreatePortfolioProps) => createPortfolio(api, data),\n onSuccess: async () => {\n await invalidate();\n showAlert({\n severity: \"success\",\n message: \"Portfolio created successfully.\",\n });\n },\n onError: (err: unknown) => {\n showAlert({\n severity: \"error\",\n message: getErrorMessage(\n err,\n \"We couldn't create the portfolio. Please review your inputs and try again.\"\n ),\n });\n },\n });\n\n const update = useMutation({\n mutationFn: async ({ id, data }: UpdatePortfolioProps) => updatePortfolio(api, id, data),\n onSuccess: async () => {\n await invalidate();\n showAlert({\n severity: \"success\",\n message: \"Portfolio updated successfully.\",\n });\n },\n onError: (err: unknown) => {\n showAlert({\n severity: \"error\",\n message: getErrorMessage(\n err,\n \"We couldn't update the portfolio. Please try again.\"\n ),\n });\n },\n });\n\n const remove = useMutation({\n mutationFn: async ({ id, workspace }: DeletePortfolioProps) => deletePortfolio(api, id, workspace),\n onSuccess: async () => {\n await invalidate();\n showAlert({\n severity: \"success\",\n message: \"Portfolio deleted successfully.\",\n });\n },\n onError: (err: unknown) => {\n showAlert({\n severity: \"error\",\n message: getErrorMessage(\n err,\n \"We couldn't delete the portfolio. Please try again.\"\n ),\n });\n },\n });\n\n return { create, update, remove };\n};\n"],"mappings":";;;;;AAyBA,IAAM,mBAAmB,KAAc,aACnC,eAAe,SAAS,IAAI,UAAU,IAAI,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwJxD,IAAa,yBAAyB,EAAE,eAA2C;CAC/E,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAClC,MAAM,cAAc,eAAe;CAEnC,MAAM,aAAa,YAAY;EAC3B,IAAI,CAAC,UAAU,QAAQ;EACvB,MAAM,YAAY,kBAAkB,EAAE,SAAS,CAAC;CACpD;CA8DA,OAAO;EAAE,QA5DM,YAAY;GACvB,YAAY,OAAO,EAAE,WAAiC,gBAAgB,KAAK,IAAI;GAC/E,WAAW,YAAY;IACnB,MAAM,WAAW;IACjB,UAAU;KACN,UAAU;KACV,SAAS;IACb,CAAC;GACL;GACA,UAAU,QAAiB;IACvB,UAAU;KACN,UAAU;KACV,SAAS,gBACL,KACA,4EACJ;IACJ,CAAC;GACL;EACJ,CA0CS;EAAQ,QAxCF,YAAY;GACvB,YAAY,OAAO,EAAE,IAAI,WAAiC,gBAAgB,KAAK,IAAI,IAAI;GACvF,WAAW,YAAY;IACnB,MAAM,WAAW;IACjB,UAAU;KACN,UAAU;KACV,SAAS;IACb,CAAC;GACL;GACA,UAAU,QAAiB;IACvB,UAAU;KACN,UAAU;KACV,SAAS,gBACL,KACA,qDACJ;IACJ,CAAC;GACL;EACJ,CAsBiB;EAAQ,QApBV,YAAY;GACvB,YAAY,OAAO,EAAE,IAAI,gBAAsC,gBAAgB,KAAK,IAAI,SAAS;GACjG,WAAW,YAAY;IACnB,MAAM,WAAW;IACjB,UAAU;KACN,UAAU;KACV,SAAS;IACb,CAAC;GACL;GACA,UAAU,QAAiB;IACvB,UAAU;KACN,UAAU;KACV,SAAS,gBACL,KACA,qDACJ;IACJ,CAAC;GACL;EACJ,CAEyB;CAAO;AACpC"}
@@ -0,0 +1,206 @@
1
+ import type { Profile } from "../../types/profile.d.ts";
2
+ import type { EntityQueryOptions } from "../../types/entityQuery.d.ts";
3
+ export type FetchProfileProps<TData = Profile, TSelected = TData> = {
4
+ queryOptions?: EntityQueryOptions<TData, TSelected>;
5
+ /**
6
+ * Served instead of calling the API. Pass `DEV_PROFILE` while running the dev server,
7
+ * where `/api/profile` has no session to resolve.
8
+ */
9
+ fallback?: Profile;
10
+ };
11
+ /**
12
+ * useFetchProfile
13
+ *
14
+ * Data-fetching hook built on TanStack Query to retrieve the profile of the logged user. It takes
15
+ * no identifier: the API resolves the user from the session.
16
+ *
17
+ * It also:
18
+ * - builds a stable React Query `queryKey`, shared by every consumer, so the profile is fetched
19
+ * once per session and read from cache afterwards
20
+ * - triggers an error alert via `useAppAlert` whenever `query.error` is present
21
+ *
22
+ * Parameters (FetchProfileProps):
23
+ * @param queryOptions
24
+ * TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
25
+ * Defaults keep the profile cached for the whole session.
26
+ * @param fallback
27
+ * Served instead of calling the API. `/api/profile` only resolves in production, so an app
28
+ * running the dev server passes `DEV_PROFILE` here:
29
+ * `useFetchProfile({ fallback: import.meta.env.DEV ? DEV_PROFILE : undefined })`.
30
+ * The SDK cannot make that choice itself — see `getProfile`.
31
+ *
32
+ * Returns:
33
+ * @returns {object}
34
+ * TanStack Query's `query` object extended with:
35
+ * - `queryKey`: the cache key used by React Query
36
+ *
37
+ * Example:
38
+ * ```ts
39
+ * const { data, isPending } = useFetchProfile();
40
+ * // data -> Profile
41
+ * ```
42
+ */
43
+ export declare const useFetchProfile: ({ queryOptions, fallback, }?: FetchProfileProps) => {
44
+ queryKey: string[];
45
+ data: Profile;
46
+ error: Error;
47
+ isError: true;
48
+ isPending: false;
49
+ isLoading: false;
50
+ isLoadingError: false;
51
+ isRefetchError: true;
52
+ isSuccess: false;
53
+ isPlaceholderData: false;
54
+ status: "error";
55
+ dataUpdatedAt: number;
56
+ errorUpdatedAt: number;
57
+ failureCount: number;
58
+ failureReason: Error | null;
59
+ errorUpdateCount: number;
60
+ isFetched: boolean;
61
+ isFetchedAfterMount: boolean;
62
+ isFetching: boolean;
63
+ isInitialLoading: boolean;
64
+ isPaused: boolean;
65
+ isRefetching: boolean;
66
+ isStale: boolean;
67
+ isEnabled: boolean;
68
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Profile, Error>>;
69
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
70
+ } | {
71
+ queryKey: string[];
72
+ data: Profile;
73
+ error: null;
74
+ isError: false;
75
+ isPending: false;
76
+ isLoading: false;
77
+ isLoadingError: false;
78
+ isRefetchError: false;
79
+ isSuccess: true;
80
+ isPlaceholderData: false;
81
+ status: "success";
82
+ dataUpdatedAt: number;
83
+ errorUpdatedAt: number;
84
+ failureCount: number;
85
+ failureReason: Error | null;
86
+ errorUpdateCount: number;
87
+ isFetched: boolean;
88
+ isFetchedAfterMount: boolean;
89
+ isFetching: boolean;
90
+ isInitialLoading: boolean;
91
+ isPaused: boolean;
92
+ isRefetching: boolean;
93
+ isStale: boolean;
94
+ isEnabled: boolean;
95
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Profile, Error>>;
96
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
97
+ } | {
98
+ queryKey: string[];
99
+ data: undefined;
100
+ error: Error;
101
+ isError: true;
102
+ isPending: false;
103
+ isLoading: false;
104
+ isLoadingError: true;
105
+ isRefetchError: false;
106
+ isSuccess: false;
107
+ isPlaceholderData: false;
108
+ status: "error";
109
+ dataUpdatedAt: number;
110
+ errorUpdatedAt: number;
111
+ failureCount: number;
112
+ failureReason: Error | null;
113
+ errorUpdateCount: number;
114
+ isFetched: boolean;
115
+ isFetchedAfterMount: boolean;
116
+ isFetching: boolean;
117
+ isInitialLoading: boolean;
118
+ isPaused: boolean;
119
+ isRefetching: boolean;
120
+ isStale: boolean;
121
+ isEnabled: boolean;
122
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Profile, Error>>;
123
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
124
+ } | {
125
+ queryKey: string[];
126
+ data: undefined;
127
+ error: null;
128
+ isError: false;
129
+ isPending: true;
130
+ isLoading: true;
131
+ isLoadingError: false;
132
+ isRefetchError: false;
133
+ isSuccess: false;
134
+ isPlaceholderData: false;
135
+ status: "pending";
136
+ dataUpdatedAt: number;
137
+ errorUpdatedAt: number;
138
+ failureCount: number;
139
+ failureReason: Error | null;
140
+ errorUpdateCount: number;
141
+ isFetched: boolean;
142
+ isFetchedAfterMount: boolean;
143
+ isFetching: boolean;
144
+ isInitialLoading: boolean;
145
+ isPaused: boolean;
146
+ isRefetching: boolean;
147
+ isStale: boolean;
148
+ isEnabled: boolean;
149
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Profile, Error>>;
150
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
151
+ } | {
152
+ queryKey: string[];
153
+ data: undefined;
154
+ error: null;
155
+ isError: false;
156
+ isPending: true;
157
+ isLoadingError: false;
158
+ isRefetchError: false;
159
+ isSuccess: false;
160
+ isPlaceholderData: false;
161
+ status: "pending";
162
+ dataUpdatedAt: number;
163
+ errorUpdatedAt: number;
164
+ failureCount: number;
165
+ failureReason: Error | null;
166
+ errorUpdateCount: number;
167
+ isFetched: boolean;
168
+ isFetchedAfterMount: boolean;
169
+ isFetching: boolean;
170
+ isLoading: boolean;
171
+ isInitialLoading: boolean;
172
+ isPaused: boolean;
173
+ isRefetching: boolean;
174
+ isStale: boolean;
175
+ isEnabled: boolean;
176
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Profile, Error>>;
177
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
178
+ } | {
179
+ queryKey: string[];
180
+ data: Profile;
181
+ isError: false;
182
+ error: null;
183
+ isPending: false;
184
+ isLoading: false;
185
+ isLoadingError: false;
186
+ isRefetchError: false;
187
+ isSuccess: true;
188
+ isPlaceholderData: true;
189
+ status: "success";
190
+ dataUpdatedAt: number;
191
+ errorUpdatedAt: number;
192
+ failureCount: number;
193
+ failureReason: Error | null;
194
+ errorUpdateCount: number;
195
+ isFetched: boolean;
196
+ isFetchedAfterMount: boolean;
197
+ isFetching: boolean;
198
+ isInitialLoading: boolean;
199
+ isPaused: boolean;
200
+ isRefetching: boolean;
201
+ isStale: boolean;
202
+ isEnabled: boolean;
203
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<Profile, Error>>;
204
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
205
+ };
206
+ //# sourceMappingURL=useFetchProfile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFetchProfile.d.ts","sourceRoot":"","sources":["../../../src/hooks/profile/useFetchProfile.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,OAAO,EAAE,SAAS,GAAG,KAAK,IAAI;IAChE,YAAY,CAAC,EAAE,kBAAkB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACpD;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAWF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,eAAe,GAAI,8BAG7B,iBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BxB,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { useAppAlert } from "../../contexts/appAlertContext/useAppAlert.js";
2
+ import { useAxios } from "../useAxios.js";
3
+ import { getProfile } from "../../api/profile.js";
4
+ import { useEffect } from "react";
5
+ import { useQuery } from "@tanstack/react-query";
6
+ //#region src/hooks/profile/useFetchProfile.ts
7
+ var defaultQueryOptions = {
8
+ staleTime: Infinity,
9
+ refetchOnMount: false,
10
+ refetchOnWindowFocus: false
11
+ };
12
+ /**
13
+ * useFetchProfile
14
+ *
15
+ * Data-fetching hook built on TanStack Query to retrieve the profile of the logged user. It takes
16
+ * no identifier: the API resolves the user from the session.
17
+ *
18
+ * It also:
19
+ * - builds a stable React Query `queryKey`, shared by every consumer, so the profile is fetched
20
+ * once per session and read from cache afterwards
21
+ * - triggers an error alert via `useAppAlert` whenever `query.error` is present
22
+ *
23
+ * Parameters (FetchProfileProps):
24
+ * @param queryOptions
25
+ * TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).
26
+ * Defaults keep the profile cached for the whole session.
27
+ * @param fallback
28
+ * Served instead of calling the API. `/api/profile` only resolves in production, so an app
29
+ * running the dev server passes `DEV_PROFILE` here:
30
+ * `useFetchProfile({ fallback: import.meta.env.DEV ? DEV_PROFILE : undefined })`.
31
+ * The SDK cannot make that choice itself — see `getProfile`.
32
+ *
33
+ * Returns:
34
+ * @returns {object}
35
+ * TanStack Query's `query` object extended with:
36
+ * - `queryKey`: the cache key used by React Query
37
+ *
38
+ * Example:
39
+ * ```ts
40
+ * const { data, isPending } = useFetchProfile();
41
+ * // data -> Profile
42
+ * ```
43
+ */
44
+ var useFetchProfile = ({ queryOptions = defaultQueryOptions, fallback } = {}) => {
45
+ const { api } = useAxios();
46
+ const { showAlert } = useAppAlert();
47
+ const queryKey = ["profile"];
48
+ const query = useQuery({
49
+ queryKey,
50
+ queryFn: async () => {
51
+ return await getProfile(api, fallback);
52
+ },
53
+ ...queryOptions ?? {}
54
+ });
55
+ useEffect(() => {
56
+ if (!query.error) return;
57
+ showAlert({
58
+ severity: "error",
59
+ message: query.error.message
60
+ });
61
+ }, [query.error, showAlert]);
62
+ return {
63
+ ...query,
64
+ queryKey
65
+ };
66
+ };
67
+ //#endregion
68
+ export { useFetchProfile };
69
+
70
+ //# sourceMappingURL=useFetchProfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFetchProfile.js","names":[],"sources":["../../../src/hooks/profile/useFetchProfile.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { useQuery } from \"@tanstack/react-query\";\n\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport type { Profile } from \"@/types/profile\";\nimport { getProfile } from \"@/api/profile\";\nimport type { EntityQueryOptions } from \"@/types/entityQuery\";\n\nexport type FetchProfileProps<TData = Profile, TSelected = TData> = {\n queryOptions?: EntityQueryOptions<TData, TSelected>;\n /**\n * Served instead of calling the API. Pass `DEV_PROFILE` while running the dev server,\n * where `/api/profile` has no session to resolve.\n */\n fallback?: Profile;\n};\n\n// The logged user's profile does not change during a session, so it is fetched once and kept —\n// unlike the entity hooks (staleTime/gcTime 0, refetch on every mount), which read data the\n// platform keeps changing.\nconst defaultQueryOptions: EntityQueryOptions<Profile> = {\n staleTime: Infinity,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n};\n\n/**\n * useFetchProfile\n *\n * Data-fetching hook built on TanStack Query to retrieve the profile of the logged user. It takes\n * no identifier: the API resolves the user from the session.\n *\n * It also:\n * - builds a stable React Query `queryKey`, shared by every consumer, so the profile is fetched\n * once per session and read from cache afterwards\n * - triggers an error alert via `useAppAlert` whenever `query.error` is present\n *\n * Parameters (FetchProfileProps):\n * @param queryOptions\n * TanStack Query options passed through to `useQuery` (e.g., enabled, staleTime, gcTime, etc.).\n * Defaults keep the profile cached for the whole session.\n * @param fallback\n * Served instead of calling the API. `/api/profile` only resolves in production, so an app\n * running the dev server passes `DEV_PROFILE` here:\n * `useFetchProfile({ fallback: import.meta.env.DEV ? DEV_PROFILE : undefined })`.\n * The SDK cannot make that choice itself — see `getProfile`.\n *\n * Returns:\n * @returns {object}\n * TanStack Query's `query` object extended with:\n * - `queryKey`: the cache key used by React Query\n *\n * Example:\n * ```ts\n * const { data, isPending } = useFetchProfile();\n * // data -> Profile\n * ```\n */\nexport const useFetchProfile = ({\n queryOptions = defaultQueryOptions,\n fallback,\n}: FetchProfileProps = {}) => {\n\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n\n const queryKey = [\"profile\"];\n\n const query = useQuery<Profile>({\n queryKey,\n queryFn: async () => {\n const profile = await getProfile(api, fallback);\n return profile;\n },\n ...queryOptions ?? {}\n });\n\n useEffect(() => {\n if (!query.error) return;\n\n showAlert({\n severity: \"error\",\n message: query.error.message,\n });\n }, [query.error, showAlert]);\n\n return {\n ...query,\n queryKey,\n };\n};\n"],"mappings":";;;;;;AAsBA,IAAM,sBAAmD;CACrD,WAAW;CACX,gBAAgB;CAChB,sBAAsB;AAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,mBAAmB,EAC5B,eAAe,qBACf,aACmB,CAAC,MAAM;CAE1B,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAElC,MAAM,WAAW,CAAC,SAAS;CAE3B,MAAM,QAAQ,SAAkB;EAC5B;EACA,SAAS,YAAY;GAEjB,OAAO,MADe,WAAW,KAAK,QAAQ;EAElD;EACA,GAAG,gBAAgB,CAAC;CACxB,CAAC;CAED,gBAAgB;EACZ,IAAI,CAAC,MAAM,OAAO;EAElB,UAAU;GACN,UAAU;GACV,SAAS,MAAM,MAAM;EACzB,CAAC;CACL,GAAG,CAAC,MAAM,OAAO,SAAS,CAAC;CAE3B,OAAO;EACH,GAAG;EACH;CACJ;AACJ"}
@@ -0,0 +1,40 @@
1
+ import { type AxiosInstance } from "axios";
2
+ /**
3
+ * useAxios
4
+ *
5
+ * Axios client hook that returns a memoized `AxiosInstance` configured with:
6
+ * - `baseURL` derived from:
7
+ * - the optional `url` parameter, or
8
+ * - the relative `/api` by default. In dev, `/api` is proxied to `EVERYSK_API_URL`
9
+ * (see `vite/serverProxy.ts`); in production it is served behind the same host.
10
+ *
11
+ * Request behavior:
12
+ * - Sets the `X-Everysk-Source` header on every request, identifying the app to the API as
13
+ * `everysk-user-app-<appId>` (the `appId` from `useAppConfig()`). When there is no app id (dev,
14
+ * where the host page hasn't injected `window.APP_ID`), it falls back to
15
+ * `everysk-user-app-development`.
16
+ * - Registers a request interceptor that, for `GET` and `DELETE` requests, attempts to parse
17
+ * `config.params.query` (expected to be a JSON string) and extract a `workspace` filter from it.
18
+ * - If a `workspace` value is found, it is injected into `config.params.workspace`.
19
+ *
20
+ * Lifecycle / cleanup:
21
+ * - The interceptor is attached in `useEffect` and ejected on cleanup to avoid stacking interceptors
22
+ * across re-renders or unmount/mount cycles.
23
+ *
24
+ * Notes:
25
+ * - `params.query` parsing is best-effort. Invalid JSON is ignored.
26
+ * - This hook assumes a query structure containing `filters`, where the workspace filter is identified by
27
+ * `filter[0] === "workspace"`.
28
+ *
29
+ * Parameters:
30
+ * @param {string | null} [url=null]
31
+ * Optional base URL override. If omitted/null, defaults to the relative `/api`.
32
+ *
33
+ * Return value:
34
+ * @returns {{ api: AxiosInstance }}
35
+ * Returns an object containing the configured Axios instance.
36
+ */
37
+ export declare const useAxios: (url?: string | null) => {
38
+ api: AxiosInstance;
39
+ };
40
+ //# sourceMappingURL=useAxios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAxios.d.ts","sourceRoot":"","sources":["../../src/hooks/useAxios.ts"],"names":[],"mappings":"AAEA,OAAc,EAAE,KAAK,aAAa,EAAmC,MAAM,OAAO,CAAC;AAMnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,eAAO,MAAM,QAAQ,GAAI,MAAK,MAAM,GAAG,IAAW;;CAqDjD,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { useAppConfig } from "../contexts/appConfigContext/useAppConfig.js";
2
+ import { useEffect, useMemo, useRef } from "react";
3
+ import axios from "axios";
4
+ //#region src/hooks/useAxios.ts
5
+ /**
6
+ * useAxios
7
+ *
8
+ * Axios client hook that returns a memoized `AxiosInstance` configured with:
9
+ * - `baseURL` derived from:
10
+ * - the optional `url` parameter, or
11
+ * - the relative `/api` by default. In dev, `/api` is proxied to `EVERYSK_API_URL`
12
+ * (see `vite/serverProxy.ts`); in production it is served behind the same host.
13
+ *
14
+ * Request behavior:
15
+ * - Sets the `X-Everysk-Source` header on every request, identifying the app to the API as
16
+ * `everysk-user-app-<appId>` (the `appId` from `useAppConfig()`). When there is no app id (dev,
17
+ * where the host page hasn't injected `window.APP_ID`), it falls back to
18
+ * `everysk-user-app-development`.
19
+ * - Registers a request interceptor that, for `GET` and `DELETE` requests, attempts to parse
20
+ * `config.params.query` (expected to be a JSON string) and extract a `workspace` filter from it.
21
+ * - If a `workspace` value is found, it is injected into `config.params.workspace`.
22
+ *
23
+ * Lifecycle / cleanup:
24
+ * - The interceptor is attached in `useEffect` and ejected on cleanup to avoid stacking interceptors
25
+ * across re-renders or unmount/mount cycles.
26
+ *
27
+ * Notes:
28
+ * - `params.query` parsing is best-effort. Invalid JSON is ignored.
29
+ * - This hook assumes a query structure containing `filters`, where the workspace filter is identified by
30
+ * `filter[0] === "workspace"`.
31
+ *
32
+ * Parameters:
33
+ * @param {string | null} [url=null]
34
+ * Optional base URL override. If omitted/null, defaults to the relative `/api`.
35
+ *
36
+ * Return value:
37
+ * @returns {{ api: AxiosInstance }}
38
+ * Returns an object containing the configured Axios instance.
39
+ */
40
+ var useAxios = (url = null) => {
41
+ const reqInterceptorId = useRef(null);
42
+ const { appId } = useAppConfig();
43
+ const source = appId ? `everysk-user-app-${appId}` : "everysk-user-app-development";
44
+ const api = useMemo(() => {
45
+ const instance = axios.create({ baseURL: url ?? "/api" });
46
+ instance.defaults.headers.common["X-Everysk-Source"] = source;
47
+ return instance;
48
+ }, [url, source]);
49
+ useEffect(() => {
50
+ reqInterceptorId.current = api.interceptors.request.use((config) => {
51
+ const method = (config.method ?? "").toLowerCase();
52
+ if (method === "get" || method === "delete") {
53
+ const params = config.params ?? {};
54
+ try {
55
+ const rawQuery = params.query;
56
+ const workspaceFilter = (typeof rawQuery === "string" ? JSON.parse(rawQuery) : null)?.filters?.find((filter) => filter?.[0] === "workspace");
57
+ const workspace = Array.isArray(workspaceFilter) ? workspaceFilter[workspaceFilter.length - 1] : null;
58
+ if (workspace) config.params = {
59
+ ...params,
60
+ workspace
61
+ };
62
+ } catch {}
63
+ }
64
+ return config;
65
+ });
66
+ return () => {
67
+ if (reqInterceptorId.current != null) api.interceptors.request.eject(reqInterceptorId.current);
68
+ reqInterceptorId.current = null;
69
+ };
70
+ }, [api]);
71
+ return { api };
72
+ };
73
+ //#endregion
74
+ export { useAxios };
75
+
76
+ //# sourceMappingURL=useAxios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAxios.js","names":[],"sources":["../../src/hooks/useAxios.ts"],"sourcesContent":["import { useEffect, useMemo, useRef } from \"react\";\n\nimport axios, { type AxiosInstance, type InternalAxiosRequestConfig } from \"axios\";\n\nimport type { AnyRecord } from \"@/types/anyRecord\";\nimport type { FilterExpression } from \"@/types/entityQuery\";\nimport { useAppConfig } from \"@/contexts/appConfigContext/useAppConfig\";\n\n/**\n * useAxios\n *\n * Axios client hook that returns a memoized `AxiosInstance` configured with:\n * - `baseURL` derived from:\n * - the optional `url` parameter, or\n * - the relative `/api` by default. In dev, `/api` is proxied to `EVERYSK_API_URL`\n * (see `vite/serverProxy.ts`); in production it is served behind the same host.\n *\n * Request behavior:\n * - Sets the `X-Everysk-Source` header on every request, identifying the app to the API as\n * `everysk-user-app-<appId>` (the `appId` from `useAppConfig()`). When there is no app id (dev,\n * where the host page hasn't injected `window.APP_ID`), it falls back to\n * `everysk-user-app-development`.\n * - Registers a request interceptor that, for `GET` and `DELETE` requests, attempts to parse\n * `config.params.query` (expected to be a JSON string) and extract a `workspace` filter from it.\n * - If a `workspace` value is found, it is injected into `config.params.workspace`.\n *\n * Lifecycle / cleanup:\n * - The interceptor is attached in `useEffect` and ejected on cleanup to avoid stacking interceptors\n * across re-renders or unmount/mount cycles.\n *\n * Notes:\n * - `params.query` parsing is best-effort. Invalid JSON is ignored.\n * - This hook assumes a query structure containing `filters`, where the workspace filter is identified by\n * `filter[0] === \"workspace\"`.\n *\n * Parameters:\n * @param {string | null} [url=null]\n * Optional base URL override. If omitted/null, defaults to the relative `/api`.\n *\n * Return value:\n * @returns {{ api: AxiosInstance }}\n * Returns an object containing the configured Axios instance.\n */\n\nexport const useAxios = (url: string | null = null) => {\n\n const reqInterceptorId = useRef<number | null>(null);\n const { appId } = useAppConfig();\n\n const source = appId ? `everysk-user-app-${appId}` : \"everysk-user-app-development\";\n\n const api: AxiosInstance = useMemo(() => {\n const instance = axios.create({ baseURL: url ?? \"/api\" });\n instance.defaults.headers.common[\"X-Everysk-Source\"] = source;\n return instance;\n }, [url, source]);\n\n useEffect(() => {\n reqInterceptorId.current = api.interceptors.request.use(\n (config: InternalAxiosRequestConfig<AnyRecord>) => {\n const method = (config.method ?? \"\").toLowerCase();\n\n if (method === \"get\" || method === \"delete\") {\n const params = (config.params ?? {}) as Record<string, unknown>;\n\n try {\n const rawQuery = params.query;\n const queryObj = typeof rawQuery === \"string\" ? JSON.parse(rawQuery) : null;\n\n const workspaceFilter = queryObj?.filters?.find(\n (filter: FilterExpression) => filter?.[0] === \"workspace\"\n );\n\n const workspace =\n Array.isArray(workspaceFilter) ? workspaceFilter[workspaceFilter.length - 1] : null;\n\n if (workspace) {\n config.params = { ...params, workspace };\n }\n } catch {\n // ignore invalid query JSON\n }\n }\n\n return config;\n }\n );\n\n return () => {\n if (reqInterceptorId.current != null) {\n api.interceptors.request.eject(reqInterceptorId.current);\n }\n reqInterceptorId.current = null;\n };\n }, [api]);\n\n return { api };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,YAAY,MAAqB,SAAS;CAEnD,MAAM,mBAAmB,OAAsB,IAAI;CACnD,MAAM,EAAE,UAAU,aAAa;CAE/B,MAAM,SAAS,QAAQ,oBAAoB,UAAU;CAErD,MAAM,MAAqB,cAAc;EACrC,MAAM,WAAW,MAAM,OAAO,EAAE,SAAS,OAAO,OAAO,CAAC;EACxD,SAAS,SAAS,QAAQ,OAAO,sBAAsB;EACvD,OAAO;CACX,GAAG,CAAC,KAAK,MAAM,CAAC;CAEhB,gBAAgB;EACZ,iBAAiB,UAAU,IAAI,aAAa,QAAQ,KAC/C,WAAkD;GAC/C,MAAM,UAAU,OAAO,UAAU,GAAA,CAAI,YAAY;GAEjD,IAAI,WAAW,SAAS,WAAW,UAAU;IACzC,MAAM,SAAU,OAAO,UAAU,CAAC;IAElC,IAAI;KACA,MAAM,WAAW,OAAO;KAGxB,MAAM,mBAFW,OAAO,aAAa,WAAW,KAAK,MAAM,QAAQ,IAAI,KAAA,EAErC,SAAS,MACtC,WAA6B,SAAS,OAAO,WAClD;KAEA,MAAM,YACF,MAAM,QAAQ,eAAe,IAAI,gBAAgB,gBAAgB,SAAS,KAAK;KAEnF,IAAI,WACA,OAAO,SAAS;MAAE,GAAG;MAAQ;KAAU;IAE/C,QAAQ,CAER;GACJ;GAEA,OAAO;EACX,CACJ;EAEA,aAAa;GACT,IAAI,iBAAiB,WAAW,MAC5B,IAAI,aAAa,QAAQ,MAAM,iBAAiB,OAAO;GAE3D,iBAAiB,UAAU;EAC/B;CACJ,GAAG,CAAC,GAAG,CAAC;CAER,OAAO,EAAE,IAAI;AACjB"}