@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.
- package/LICENSE +21 -0
- package/README.md +128 -0
- package/dist/EveryskApp.d.ts +73 -0
- package/dist/EveryskApp.d.ts.map +1 -0
- package/dist/EveryskApp.js +66 -0
- package/dist/EveryskApp.js.map +1 -0
- package/dist/agGrid/agGridTheme.d.ts +77 -0
- package/dist/agGrid/agGridTheme.d.ts.map +1 -0
- package/dist/agGrid/agGridTheme.js +88 -0
- package/dist/agGrid/agGridTheme.js.map +1 -0
- package/dist/agGrid/index.d.ts +4 -0
- package/dist/agGrid/index.d.ts.map +1 -0
- package/dist/agGrid/index.js +3 -0
- package/dist/api/datastore.d.ts +68 -0
- package/dist/api/datastore.d.ts.map +1 -0
- package/dist/api/datastore.js +125 -0
- package/dist/api/datastore.js.map +1 -0
- package/dist/api/entityQuery.d.ts +78 -0
- package/dist/api/entityQuery.d.ts.map +1 -0
- package/dist/api/entityQuery.js +100 -0
- package/dist/api/entityQuery.js.map +1 -0
- package/dist/api/file.d.ts +70 -0
- package/dist/api/file.d.ts.map +1 -0
- package/dist/api/file.js +126 -0
- package/dist/api/file.js.map +1 -0
- package/dist/api/portfolio.d.ts +67 -0
- package/dist/api/portfolio.d.ts.map +1 -0
- package/dist/api/portfolio.js +125 -0
- package/dist/api/portfolio.js.map +1 -0
- package/dist/api/profile.d.ts +40 -0
- package/dist/api/profile.d.ts.map +1 -0
- package/dist/api/profile.js +71 -0
- package/dist/api/profile.js.map +1 -0
- package/dist/api/websocketsConfig.d.ts +13 -0
- package/dist/api/websocketsConfig.d.ts.map +1 -0
- package/dist/api/websocketsConfig.js +25 -0
- package/dist/api/websocketsConfig.js.map +1 -0
- package/dist/api/workflow.d.ts +154 -0
- package/dist/api/workflow.d.ts.map +1 -0
- package/dist/api/workflow.js +289 -0
- package/dist/api/workflow.js.map +1 -0
- package/dist/api/workspace.d.ts +29 -0
- package/dist/api/workspace.d.ts.map +1 -0
- package/dist/api/workspace.js +54 -0
- package/dist/api/workspace.js.map +1 -0
- package/dist/components/ui/EveryskIcon/index.d.ts +5 -0
- package/dist/components/ui/EveryskIcon/index.d.ts.map +1 -0
- package/dist/components/ui/EveryskIcon/index.js +25 -0
- package/dist/components/ui/EveryskIcon/index.js.map +1 -0
- package/dist/components/ui/Footer/index.d.ts +5 -0
- package/dist/components/ui/Footer/index.d.ts.map +1 -0
- package/dist/components/ui/Footer/index.js +23 -0
- package/dist/components/ui/Footer/index.js.map +1 -0
- package/dist/components/ui/GlobalLoading/index.d.ts +8 -0
- package/dist/components/ui/GlobalLoading/index.d.ts.map +1 -0
- package/dist/components/ui/GlobalLoading/index.js +42 -0
- package/dist/components/ui/GlobalLoading/index.js.map +1 -0
- package/dist/components/ui/PageContainer/index.d.ts +7 -0
- package/dist/components/ui/PageContainer/index.d.ts.map +1 -0
- package/dist/components/ui/PageContainer/index.js +20 -0
- package/dist/components/ui/PageContainer/index.js.map +1 -0
- package/dist/components/ui/Toolbar/index.d.ts +5 -0
- package/dist/components/ui/Toolbar/index.d.ts.map +1 -0
- package/dist/components/ui/Toolbar/index.js +32 -0
- package/dist/components/ui/Toolbar/index.js.map +1 -0
- package/dist/contexts/agGridLicenseContext/provider.d.ts +51 -0
- package/dist/contexts/agGridLicenseContext/provider.d.ts.map +1 -0
- package/dist/contexts/agGridLicenseContext/provider.js +58 -0
- package/dist/contexts/agGridLicenseContext/provider.js.map +1 -0
- package/dist/contexts/appAlertContext/index.d.ts +3 -0
- package/dist/contexts/appAlertContext/index.d.ts.map +1 -0
- package/dist/contexts/appAlertContext/index.js +7 -0
- package/dist/contexts/appAlertContext/index.js.map +1 -0
- package/dist/contexts/appAlertContext/provider.d.ts +40 -0
- package/dist/contexts/appAlertContext/provider.d.ts.map +1 -0
- package/dist/contexts/appAlertContext/provider.js +96 -0
- package/dist/contexts/appAlertContext/provider.js.map +1 -0
- package/dist/contexts/appAlertContext/types.d.ts +15 -0
- package/dist/contexts/appAlertContext/types.d.ts.map +1 -0
- package/dist/contexts/appAlertContext/useAppAlert.d.ts +30 -0
- package/dist/contexts/appAlertContext/useAppAlert.d.ts.map +1 -0
- package/dist/contexts/appAlertContext/useAppAlert.js +40 -0
- package/dist/contexts/appAlertContext/useAppAlert.js.map +1 -0
- package/dist/contexts/appConfigContext/index.d.ts +3 -0
- package/dist/contexts/appConfigContext/index.d.ts.map +1 -0
- package/dist/contexts/appConfigContext/index.js +7 -0
- package/dist/contexts/appConfigContext/index.js.map +1 -0
- package/dist/contexts/appConfigContext/provider.d.ts +45 -0
- package/dist/contexts/appConfigContext/provider.d.ts.map +1 -0
- package/dist/contexts/appConfigContext/provider.js +63 -0
- package/dist/contexts/appConfigContext/provider.js.map +1 -0
- package/dist/contexts/appConfigContext/types.d.ts +28 -0
- package/dist/contexts/appConfigContext/types.d.ts.map +1 -0
- package/dist/contexts/appConfigContext/useAppConfig.d.ts +20 -0
- package/dist/contexts/appConfigContext/useAppConfig.d.ts.map +1 -0
- package/dist/contexts/appConfigContext/useAppConfig.js +30 -0
- package/dist/contexts/appConfigContext/useAppConfig.js.map +1 -0
- package/dist/contexts/webSocketContext/constants.d.ts +4 -0
- package/dist/contexts/webSocketContext/constants.d.ts.map +1 -0
- package/dist/contexts/webSocketContext/constants.js +8 -0
- package/dist/contexts/webSocketContext/constants.js.map +1 -0
- package/dist/contexts/webSocketContext/handler.d.ts +43 -0
- package/dist/contexts/webSocketContext/handler.d.ts.map +1 -0
- package/dist/contexts/webSocketContext/handler.js +87 -0
- package/dist/contexts/webSocketContext/handler.js.map +1 -0
- package/dist/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.d.ts +19 -0
- package/dist/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.d.ts.map +1 -0
- package/dist/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.js +31 -0
- package/dist/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.js.map +1 -0
- package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts +11 -0
- package/dist/contexts/webSocketContext/hooks/useWebSocket/index.d.ts.map +1 -0
- package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js +21 -0
- package/dist/contexts/webSocketContext/hooks/useWebSocket/index.js.map +1 -0
- package/dist/contexts/webSocketContext/hooks/useWebSocketSubscription/index.d.ts +30 -0
- package/dist/contexts/webSocketContext/hooks/useWebSocketSubscription/index.d.ts.map +1 -0
- package/dist/contexts/webSocketContext/hooks/useWebSocketSubscription/index.js +44 -0
- package/dist/contexts/webSocketContext/hooks/useWebSocketSubscription/index.js.map +1 -0
- package/dist/contexts/webSocketContext/index.d.ts +3 -0
- package/dist/contexts/webSocketContext/index.d.ts.map +1 -0
- package/dist/contexts/webSocketContext/index.js +7 -0
- package/dist/contexts/webSocketContext/index.js.map +1 -0
- package/dist/contexts/webSocketContext/provider.d.ts +39 -0
- package/dist/contexts/webSocketContext/provider.d.ts.map +1 -0
- package/dist/contexts/webSocketContext/provider.js +121 -0
- package/dist/contexts/webSocketContext/provider.js.map +1 -0
- package/dist/contexts/webSocketContext/types.d.ts +41 -0
- package/dist/contexts/webSocketContext/types.d.ts.map +1 -0
- package/dist/datastore/index.d.ts +7 -0
- package/dist/datastore/index.d.ts.map +1 -0
- package/dist/file/index.d.ts +6 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/hooks/datastore/useDatastoreMutations.d.ts +151 -0
- package/dist/hooks/datastore/useDatastoreMutations.d.ts.map +1 -0
- package/dist/hooks/datastore/useDatastoreMutations.js +198 -0
- package/dist/hooks/datastore/useDatastoreMutations.js.map +1 -0
- package/dist/hooks/datastore/useFetchDatastore.d.ts +205 -0
- package/dist/hooks/datastore/useFetchDatastore.d.ts.map +1 -0
- package/dist/hooks/datastore/useFetchDatastore.js +85 -0
- package/dist/hooks/datastore/useFetchDatastore.js.map +1 -0
- package/dist/hooks/datastore/useFetchDatastores.d.ts +70 -0
- package/dist/hooks/datastore/useFetchDatastores.d.ts.map +1 -0
- package/dist/hooks/datastore/useFetchDatastores.js +105 -0
- package/dist/hooks/datastore/useFetchDatastores.js.map +1 -0
- package/dist/hooks/file/useFetchFile.d.ts +212 -0
- package/dist/hooks/file/useFetchFile.d.ts.map +1 -0
- package/dist/hooks/file/useFetchFile.js +87 -0
- package/dist/hooks/file/useFetchFile.js.map +1 -0
- package/dist/hooks/file/useFetchFiles.d.ts +60 -0
- package/dist/hooks/file/useFetchFiles.d.ts.map +1 -0
- package/dist/hooks/file/useFetchFiles.js +89 -0
- package/dist/hooks/file/useFetchFiles.js.map +1 -0
- package/dist/hooks/file/useFileMutations.d.ts +161 -0
- package/dist/hooks/file/useFileMutations.d.ts.map +1 -0
- package/dist/hooks/file/useFileMutations.js +208 -0
- package/dist/hooks/file/useFileMutations.js.map +1 -0
- package/dist/hooks/portfolio/useFetchPortfolio.d.ts +210 -0
- package/dist/hooks/portfolio/useFetchPortfolio.d.ts.map +1 -0
- package/dist/hooks/portfolio/useFetchPortfolio.js +85 -0
- package/dist/hooks/portfolio/useFetchPortfolio.js.map +1 -0
- package/dist/hooks/portfolio/useFetchPortfolios.d.ts +60 -0
- package/dist/hooks/portfolio/useFetchPortfolios.d.ts.map +1 -0
- package/dist/hooks/portfolio/useFetchPortfolios.js +89 -0
- package/dist/hooks/portfolio/useFetchPortfolios.js.map +1 -0
- package/dist/hooks/portfolio/usePortfolioMutations.d.ts +171 -0
- package/dist/hooks/portfolio/usePortfolioMutations.d.ts.map +1 -0
- package/dist/hooks/portfolio/usePortfolioMutations.js +218 -0
- package/dist/hooks/portfolio/usePortfolioMutations.js.map +1 -0
- package/dist/hooks/profile/useFetchProfile.d.ts +206 -0
- package/dist/hooks/profile/useFetchProfile.d.ts.map +1 -0
- package/dist/hooks/profile/useFetchProfile.js +70 -0
- package/dist/hooks/profile/useFetchProfile.js.map +1 -0
- package/dist/hooks/useAxios.d.ts +40 -0
- package/dist/hooks/useAxios.d.ts.map +1 -0
- package/dist/hooks/useAxios.js +76 -0
- package/dist/hooks/useAxios.js.map +1 -0
- package/dist/hooks/workflow/useFetchWorkerExecution.d.ts +198 -0
- package/dist/hooks/workflow/useFetchWorkerExecution.d.ts.map +1 -0
- package/dist/hooks/workflow/useFetchWorkerExecution.js +69 -0
- package/dist/hooks/workflow/useFetchWorkerExecution.js.map +1 -0
- package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts +52 -0
- package/dist/hooks/workflow/useFetchWorkerExecutions.d.ts.map +1 -0
- package/dist/hooks/workflow/useFetchWorkerExecutions.js +83 -0
- package/dist/hooks/workflow/useFetchWorkerExecutions.js.map +1 -0
- package/dist/hooks/workflow/useFetchWorkflow.d.ts +195 -0
- package/dist/hooks/workflow/useFetchWorkflow.d.ts.map +1 -0
- package/dist/hooks/workflow/useFetchWorkflow.js +70 -0
- package/dist/hooks/workflow/useFetchWorkflow.js.map +1 -0
- package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts +198 -0
- package/dist/hooks/workflow/useFetchWorkflowExecution.d.ts.map +1 -0
- package/dist/hooks/workflow/useFetchWorkflowExecution.js +69 -0
- package/dist/hooks/workflow/useFetchWorkflowExecution.js.map +1 -0
- package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts +49 -0
- package/dist/hooks/workflow/useFetchWorkflowExecutions.d.ts.map +1 -0
- package/dist/hooks/workflow/useFetchWorkflowExecutions.js +77 -0
- package/dist/hooks/workflow/useFetchWorkflowExecutions.js.map +1 -0
- package/dist/hooks/workflow/useFetchWorkflows.d.ts +47 -0
- package/dist/hooks/workflow/useFetchWorkflows.d.ts.map +1 -0
- package/dist/hooks/workflow/useFetchWorkflows.js +67 -0
- package/dist/hooks/workflow/useFetchWorkflows.js.map +1 -0
- package/dist/hooks/workflow/useRunWorkflow.d.ts +30 -0
- package/dist/hooks/workflow/useRunWorkflow.d.ts.map +1 -0
- package/dist/hooks/workflow/useRunWorkflow.js +50 -0
- package/dist/hooks/workflow/useRunWorkflow.js.map +1 -0
- package/dist/hooks/workspace/useFetchWorkspace.d.ts +197 -0
- package/dist/hooks/workspace/useFetchWorkspace.d.ts.map +1 -0
- package/dist/hooks/workspace/useFetchWorkspace.js +65 -0
- package/dist/hooks/workspace/useFetchWorkspace.js.map +1 -0
- package/dist/hooks/workspace/useFetchWorkspaces.d.ts +46 -0
- package/dist/hooks/workspace/useFetchWorkspaces.d.ts.map +1 -0
- package/dist/hooks/workspace/useFetchWorkspaces.js +66 -0
- package/dist/hooks/workspace/useFetchWorkspaces.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/lib/datastoreTable.d.ts +126 -0
- package/dist/lib/datastoreTable.d.ts.map +1 -0
- package/dist/lib/datastoreTable.js +146 -0
- package/dist/lib/datastoreTable.js.map +1 -0
- package/dist/lib/queryClient.d.ts +24 -0
- package/dist/lib/queryClient.d.ts.map +1 -0
- package/dist/lib/queryClient.js +48 -0
- package/dist/lib/queryClient.js.map +1 -0
- package/dist/portfolio/index.d.ts +6 -0
- package/dist/portfolio/index.d.ts.map +1 -0
- package/dist/profile/index.d.ts +4 -0
- package/dist/profile/index.d.ts.map +1 -0
- package/dist/socket/index.d.ts +10 -0
- package/dist/socket/index.d.ts.map +1 -0
- package/dist/socket/index.js +9 -0
- package/dist/test/index.d.ts +2 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +2 -0
- package/dist/test/mocks/agGridEnterprise.d.ts +38 -0
- package/dist/test/mocks/agGridEnterprise.d.ts.map +1 -0
- package/dist/test/mocks/agGridEnterprise.js +43 -0
- package/dist/test/mocks/agGridEnterprise.js.map +1 -0
- package/dist/test/mocks/agGridReact.d.ts +42 -0
- package/dist/test/mocks/agGridReact.d.ts.map +1 -0
- package/dist/test/mocks/agGridReact.js +47 -0
- package/dist/test/mocks/agGridReact.js.map +1 -0
- package/dist/test/mocks/index.d.ts +5 -0
- package/dist/test/mocks/index.d.ts.map +1 -0
- package/dist/test/mocks/index.js +4 -0
- package/dist/test/mocks/socketIoClient.d.ts +45 -0
- package/dist/test/mocks/socketIoClient.d.ts.map +1 -0
- package/dist/test/mocks/socketIoClient.js +54 -0
- package/dist/test/mocks/socketIoClient.js.map +1 -0
- package/dist/test/renderWithProviders.d.ts +107 -0
- package/dist/test/renderWithProviders.d.ts.map +1 -0
- package/dist/test/renderWithProviders.js +85 -0
- package/dist/test/renderWithProviders.js.map +1 -0
- package/dist/test/setup.d.ts +2 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/test/setup.js +25 -0
- package/dist/test/setup.js.map +1 -0
- package/dist/theme/ThemeProvider.d.ts +12 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +22 -0
- package/dist/theme/ThemeProvider.js.map +1 -0
- package/dist/theme/index.d.ts +9 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/overrides/index.d.ts +7 -0
- package/dist/theme/overrides/index.d.ts.map +1 -0
- package/dist/theme/overrides/index.js +31 -0
- package/dist/theme/overrides/index.js.map +1 -0
- package/dist/theme/overrides/muiButton.d.ts +3 -0
- package/dist/theme/overrides/muiButton.d.ts.map +1 -0
- package/dist/theme/overrides/muiButton.js +6 -0
- package/dist/theme/overrides/muiButton.js.map +1 -0
- package/dist/theme/overrides/muiCssBaseline.d.ts +31 -0
- package/dist/theme/overrides/muiCssBaseline.d.ts.map +1 -0
- package/dist/theme/overrides/muiCssBaseline.js +27 -0
- package/dist/theme/overrides/muiCssBaseline.js.map +1 -0
- package/dist/theme/overrides/muiDatePicker.d.ts +10 -0
- package/dist/theme/overrides/muiDatePicker.d.ts.map +1 -0
- package/dist/theme/overrides/muiDatePicker.js +6 -0
- package/dist/theme/overrides/muiDatePicker.js.map +1 -0
- package/dist/theme/overrides/muiFormControl.d.ts +3 -0
- package/dist/theme/overrides/muiFormControl.d.ts.map +1 -0
- package/dist/theme/overrides/muiFormControl.js +6 -0
- package/dist/theme/overrides/muiFormControl.js.map +1 -0
- package/dist/theme/overrides/muiIconButton.d.ts +3 -0
- package/dist/theme/overrides/muiIconButton.d.ts.map +1 -0
- package/dist/theme/overrides/muiIconButton.js +6 -0
- package/dist/theme/overrides/muiIconButton.js.map +1 -0
- package/dist/theme/overrides/muiSelect.d.ts +3 -0
- package/dist/theme/overrides/muiSelect.d.ts.map +1 -0
- package/dist/theme/overrides/muiSelect.js +6 -0
- package/dist/theme/overrides/muiSelect.js.map +1 -0
- package/dist/theme/overrides/muiSvgIcon.d.ts +3 -0
- package/dist/theme/overrides/muiSvgIcon.d.ts.map +1 -0
- package/dist/theme/overrides/muiSvgIcon.js +6 -0
- package/dist/theme/overrides/muiSvgIcon.js.map +1 -0
- package/dist/theme/overrides/muiTextField.d.ts +3 -0
- package/dist/theme/overrides/muiTextField.d.ts.map +1 -0
- package/dist/theme/overrides/muiTextField.js +6 -0
- package/dist/theme/overrides/muiTextField.js.map +1 -0
- package/dist/theme/overrides/muiToggleButton.d.ts +3 -0
- package/dist/theme/overrides/muiToggleButton.d.ts.map +1 -0
- package/dist/theme/overrides/muiToggleButton.js +6 -0
- package/dist/theme/overrides/muiToggleButton.js.map +1 -0
- package/dist/theme/overrides/muiToggleButtonGroup.d.ts +3 -0
- package/dist/theme/overrides/muiToggleButtonGroup.d.ts.map +1 -0
- package/dist/theme/overrides/muiToggleButtonGroup.js +6 -0
- package/dist/theme/overrides/muiToggleButtonGroup.js.map +1 -0
- package/dist/theme/themes/DefaultDark.d.ts +7 -0
- package/dist/theme/themes/DefaultDark.d.ts.map +1 -0
- package/dist/theme/themes/DefaultDark.js +15 -0
- package/dist/theme/themes/DefaultDark.js.map +1 -0
- package/dist/theme/themes/DefaultLight.d.ts +7 -0
- package/dist/theme/themes/DefaultLight.d.ts.map +1 -0
- package/dist/theme/themes/DefaultLight.js +15 -0
- package/dist/theme/themes/DefaultLight.js.map +1 -0
- package/dist/theme/themes/EveryskDark.d.ts +15 -0
- package/dist/theme/themes/EveryskDark.d.ts.map +1 -0
- package/dist/theme/themes/EveryskDark.js +63 -0
- package/dist/theme/themes/EveryskDark.js.map +1 -0
- package/dist/theme/themes/EveryskLight.d.ts +21 -0
- package/dist/theme/themes/EveryskLight.d.ts.map +1 -0
- package/dist/theme/themes/EveryskLight.js +69 -0
- package/dist/theme/themes/EveryskLight.js.map +1 -0
- package/dist/theme/themes/MidnightEmber.d.ts +3 -0
- package/dist/theme/themes/MidnightEmber.d.ts.map +1 -0
- package/dist/theme/themes/MidnightEmber.js +31 -0
- package/dist/theme/themes/MidnightEmber.js.map +1 -0
- package/dist/theme/themes/index.d.ts +17 -0
- package/dist/theme/themes/index.d.ts.map +1 -0
- package/dist/theme/themes/index.js +32 -0
- package/dist/theme/themes/index.js.map +1 -0
- package/dist/types/anyRecord.d.ts +4 -0
- package/dist/types/anyRecord.d.ts.map +1 -0
- package/dist/types/datastore.d.ts +26 -0
- package/dist/types/datastore.d.ts.map +1 -0
- package/dist/types/entityQuery.d.ts +47 -0
- package/dist/types/entityQuery.d.ts.map +1 -0
- package/dist/types/file.d.ts +29 -0
- package/dist/types/file.d.ts.map +1 -0
- package/dist/types/portfolio.d.ts +77 -0
- package/dist/types/portfolio.d.ts.map +1 -0
- package/dist/types/profile.d.ts +37 -0
- package/dist/types/profile.d.ts.map +1 -0
- package/dist/types/workflow.d.ts +68 -0
- package/dist/types/workflow.d.ts.map +1 -0
- package/dist/types/workspace.d.ts +13 -0
- package/dist/types/workspace.d.ts.map +1 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/workflow/index.d.ts +10 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workspace/index.d.ts +5 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/package.json +148 -0
- package/src/EveryskApp.tsx +108 -0
- package/src/agGrid/agGridTheme.ts +113 -0
- package/src/agGrid/index.ts +15 -0
- package/src/api/datastore.ts +175 -0
- package/src/api/entityQuery.ts +101 -0
- package/src/api/file.ts +174 -0
- package/src/api/portfolio.ts +190 -0
- package/src/api/profile.ts +80 -0
- package/src/api/websocketsConfig.ts +32 -0
- package/src/api/workflow.ts +427 -0
- package/src/api/workspace.ts +72 -0
- package/src/components/ui/EveryskIcon/index.tsx +24 -0
- package/src/components/ui/Footer/index.tsx +30 -0
- package/src/components/ui/GlobalLoading/index.tsx +38 -0
- package/src/components/ui/PageContainer/index.tsx +14 -0
- package/src/components/ui/Toolbar/index.tsx +44 -0
- package/src/contexts/agGridLicenseContext/provider.tsx +63 -0
- package/src/contexts/appAlertContext/index.tsx +4 -0
- package/src/contexts/appAlertContext/provider.tsx +92 -0
- package/src/contexts/appAlertContext/types.ts +17 -0
- package/src/contexts/appAlertContext/useAppAlert.ts +39 -0
- package/src/contexts/appConfigContext/index.tsx +4 -0
- package/src/contexts/appConfigContext/provider.tsx +67 -0
- package/src/contexts/appConfigContext/types.ts +28 -0
- package/src/contexts/appConfigContext/useAppConfig.ts +30 -0
- package/src/contexts/webSocketContext/constants.ts +3 -0
- package/src/contexts/webSocketContext/handler.ts +108 -0
- package/src/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.ts +36 -0
- package/src/contexts/webSocketContext/hooks/useWebSocket/index.ts +18 -0
- package/src/contexts/webSocketContext/hooks/useWebSocketSubscription/index.ts +45 -0
- package/src/contexts/webSocketContext/index.tsx +5 -0
- package/src/contexts/webSocketContext/provider.tsx +125 -0
- package/src/contexts/webSocketContext/types.ts +50 -0
- package/src/datastore/index.ts +14 -0
- package/src/file/index.ts +13 -0
- package/src/hooks/datastore/useDatastoreMutations.ts +221 -0
- package/src/hooks/datastore/useFetchDatastore.ts +95 -0
- package/src/hooks/datastore/useFetchDatastores.ts +162 -0
- package/src/hooks/file/useFetchFile.ts +93 -0
- package/src/hooks/file/useFetchFiles.ts +109 -0
- package/src/hooks/file/useFileMutations.ts +240 -0
- package/src/hooks/portfolio/useFetchPortfolio.ts +94 -0
- package/src/hooks/portfolio/useFetchPortfolios.ts +109 -0
- package/src/hooks/portfolio/usePortfolioMutations.ts +250 -0
- package/src/hooks/profile/useFetchProfile.ts +93 -0
- package/src/hooks/useAxios.ts +98 -0
- package/src/hooks/workflow/useFetchWorkerExecution.ts +78 -0
- package/src/hooks/workflow/useFetchWorkerExecutions.ts +98 -0
- package/src/hooks/workflow/useFetchWorkflow.ts +76 -0
- package/src/hooks/workflow/useFetchWorkflowExecution.ts +79 -0
- package/src/hooks/workflow/useFetchWorkflowExecutions.ts +95 -0
- package/src/hooks/workflow/useFetchWorkflows.ts +84 -0
- package/src/hooks/workflow/useRunWorkflow.ts +62 -0
- package/src/hooks/workspace/useFetchWorkspace.ts +78 -0
- package/src/hooks/workspace/useFetchWorkspaces.ts +86 -0
- package/src/index.ts +72 -0
- package/src/lib/datastoreTable.ts +159 -0
- package/src/lib/queryClient.ts +60 -0
- package/src/portfolio/index.ts +13 -0
- package/src/profile/index.ts +11 -0
- package/src/socket/index.ts +19 -0
- package/src/test/index.ts +10 -0
- package/src/test/mocks/agGridEnterprise.ts +45 -0
- package/src/test/mocks/agGridReact.tsx +61 -0
- package/src/test/mocks/index.ts +22 -0
- package/src/test/mocks/socketIoClient.ts +78 -0
- package/src/test/renderWithProviders.tsx +114 -0
- package/src/test/setup.ts +46 -0
- package/src/theme/ThemeProvider.tsx +33 -0
- package/src/theme/index.ts +15 -0
- package/src/theme/overrides/index.ts +31 -0
- package/src/theme/overrides/muiButton.ts +7 -0
- package/src/theme/overrides/muiCssBaseline.ts +35 -0
- package/src/theme/overrides/muiDatePicker.ts +5 -0
- package/src/theme/overrides/muiFormControl.ts +7 -0
- package/src/theme/overrides/muiIconButton.ts +7 -0
- package/src/theme/overrides/muiSelect.ts +7 -0
- package/src/theme/overrides/muiSvgIcon.ts +7 -0
- package/src/theme/overrides/muiTextField.ts +7 -0
- package/src/theme/overrides/muiToggleButton.ts +7 -0
- package/src/theme/overrides/muiToggleButtonGroup.ts +7 -0
- package/src/theme/themes/DefaultDark.ts +14 -0
- package/src/theme/themes/DefaultLight.ts +14 -0
- package/src/theme/themes/EveryskDark.ts +62 -0
- package/src/theme/themes/EveryskLight.ts +68 -0
- package/src/theme/themes/MidnightEmber.ts +30 -0
- package/src/theme/themes/index.ts +35 -0
- package/src/types/anyRecord.ts +4 -0
- package/src/types/datastore.ts +33 -0
- package/src/types/entityQuery.ts +64 -0
- package/src/types/file.ts +32 -0
- package/src/types/portfolio.ts +81 -0
- package/src/types/profile.ts +39 -0
- package/src/types/workflow.ts +76 -0
- package/src/types/workspace.ts +15 -0
- package/src/ui/index.ts +14 -0
- package/src/workflow/index.ts +17 -0
- 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"}
|