@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,30 @@
|
|
|
1
|
+
import { AppConfigContext } from "./index.js";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
//#region src/contexts/appConfigContext/useAppConfig.ts
|
|
4
|
+
/**
|
|
5
|
+
* useAppConfig
|
|
6
|
+
*
|
|
7
|
+
* Convenience hook that reads the current application configuration from `AppConfigContext`.
|
|
8
|
+
*
|
|
9
|
+
* Behavior:
|
|
10
|
+
* - Returns the `AppConfigContextType` value provided by `<AppConfigProvider>`.
|
|
11
|
+
* - Throws a descriptive error if called outside of an `<AppConfigProvider>` scope, to fail fast and
|
|
12
|
+
* avoid undefined configuration usage throughout the app.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```ts
|
|
16
|
+
* const { appId, appEnvironmentVar } = useAppConfig();
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @throws {Error}
|
|
20
|
+
* Throws if the hook is used outside of `<AppConfigProvider>`.
|
|
21
|
+
*/
|
|
22
|
+
var useAppConfig = () => {
|
|
23
|
+
const context = useContext(AppConfigContext);
|
|
24
|
+
if (!context) throw new Error("useAppConfig must be used within <AppConfigProvider>.");
|
|
25
|
+
return context;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { useAppConfig };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=useAppConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAppConfig.js","names":[],"sources":["../../../src/contexts/appConfigContext/useAppConfig.ts"],"sourcesContent":["import { useContext } from \"react\";\n\nimport { AppConfigContext } from \".\";\n\n/**\n * useAppConfig\n *\n * Convenience hook that reads the current application configuration from `AppConfigContext`.\n *\n * Behavior:\n * - Returns the `AppConfigContextType` value provided by `<AppConfigProvider>`.\n * - Throws a descriptive error if called outside of an `<AppConfigProvider>` scope, to fail fast and\n * avoid undefined configuration usage throughout the app.\n *\n * Usage:\n * ```ts\n * const { appId, appEnvironmentVar } = useAppConfig();\n * ```\n *\n * @throws {Error}\n * Throws if the hook is used outside of `<AppConfigProvider>`.\n */\n\nexport const useAppConfig = () => {\n const context = useContext(AppConfigContext);\n if (!context) {\n throw new Error(\"useAppConfig must be used within <AppConfigProvider>.\");\n }\n return context;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,qBAAqB;CAC9B,MAAM,UAAU,WAAW,gBAAgB;CAC3C,IAAI,CAAC,SACD,MAAM,IAAI,MAAM,uDAAuD;CAE3E,OAAO;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/contexts/webSocketContext/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AACjD,eAAO,MAAM,UAAU,SAAS,CAAC;AACjC,eAAO,MAAM,2BAA2B,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/contexts/webSocketContext/constants.ts
|
|
2
|
+
var NOTIFICATION_EVENT = "notification";
|
|
3
|
+
var JOIN_EVENT = "join";
|
|
4
|
+
var APP_NOTIFICATION_EVENT_TYPE = "USER_APP_NOTIFICATION";
|
|
5
|
+
//#endregion
|
|
6
|
+
export { APP_NOTIFICATION_EVENT_TYPE, JOIN_EVENT, NOTIFICATION_EVENT };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../src/contexts/webSocketContext/constants.ts"],"sourcesContent":["export const NOTIFICATION_EVENT = \"notification\";\nexport const JOIN_EVENT = \"join\";\nexport const APP_NOTIFICATION_EVENT_TYPE = \"USER_APP_NOTIFICATION\";\n"],"mappings":";AAAA,IAAa,qBAAqB;AAClC,IAAa,aAAa;AAC1B,IAAa,8BAA8B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { WebSocketNotification, WebSocketStatus, WebsocketsConfig } from "./types";
|
|
2
|
+
type StatusListener = (status: Exclude<WebSocketStatus, "idle">) => void;
|
|
3
|
+
type WebSocketHandlerConfig = WebsocketsConfig & {
|
|
4
|
+
onStatusChange?: StatusListener;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* WebSocketHandler
|
|
8
|
+
*
|
|
9
|
+
* Low-level Socket.IO wrapper with a pub/sub layer.
|
|
10
|
+
*
|
|
11
|
+
* - Connects to the notification server.
|
|
12
|
+
* - Joins the per-user channel.
|
|
13
|
+
* - Forwards notifications to registered listeners.
|
|
14
|
+
*
|
|
15
|
+
* API:
|
|
16
|
+
* - `listen(callback)`: register a notification listener; returns an unsubscribe function.
|
|
17
|
+
* - `close()`: disconnect the socket and clear all listeners.
|
|
18
|
+
*/
|
|
19
|
+
export declare class WebSocketHandler {
|
|
20
|
+
private _socket;
|
|
21
|
+
private _everyskUID;
|
|
22
|
+
private _listeners;
|
|
23
|
+
constructor({ appConnectionURL, appChannelID, everyskUID, onStatusChange }: WebSocketHandlerConfig);
|
|
24
|
+
private _isEcho;
|
|
25
|
+
/**
|
|
26
|
+
* listen
|
|
27
|
+
*
|
|
28
|
+
* Registers a listener that receives every incoming notification.
|
|
29
|
+
*
|
|
30
|
+
* @param {(msg: WebSocketNotification) => void} callback - Invoked for each notification.
|
|
31
|
+
* @returns {() => void} Unsubscribe function.
|
|
32
|
+
*/
|
|
33
|
+
listen(callback: (msg: WebSocketNotification) => void): () => void;
|
|
34
|
+
/**
|
|
35
|
+
* close
|
|
36
|
+
*
|
|
37
|
+
* Clears all listeners and disconnects the socket.
|
|
38
|
+
* After calling this, the handler should be considered unusable.
|
|
39
|
+
*/
|
|
40
|
+
close(): void;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/contexts/webSocketContext/handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAWxF,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AAEzE,KAAK,sBAAsB,GAAG,gBAAgB,GAAG;IAC7C,cAAc,CAAC,EAAE,cAAc,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAwD;gBAE9D,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,sBAAsB;IAoClG,OAAO,CAAC,OAAO;IAUf;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,qBAAqB,KAAK,IAAI,GAAG,MAAM,IAAI;IAKlE;;;;;OAKG;IACH,KAAK,IAAI,IAAI;CAKhB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { JOIN_EVENT, NOTIFICATION_EVENT } from "./constants.js";
|
|
2
|
+
import { io } from "socket.io-client";
|
|
3
|
+
//#region src/contexts/webSocketContext/handler.ts
|
|
4
|
+
function isWebSocketNotification(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && typeof value["event_type"] === "string";
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* WebSocketHandler
|
|
9
|
+
*
|
|
10
|
+
* Low-level Socket.IO wrapper with a pub/sub layer.
|
|
11
|
+
*
|
|
12
|
+
* - Connects to the notification server.
|
|
13
|
+
* - Joins the per-user channel.
|
|
14
|
+
* - Forwards notifications to registered listeners.
|
|
15
|
+
*
|
|
16
|
+
* API:
|
|
17
|
+
* - `listen(callback)`: register a notification listener; returns an unsubscribe function.
|
|
18
|
+
* - `close()`: disconnect the socket and clear all listeners.
|
|
19
|
+
*/
|
|
20
|
+
var WebSocketHandler = class {
|
|
21
|
+
_socket;
|
|
22
|
+
_everyskUID;
|
|
23
|
+
_listeners = /* @__PURE__ */ new Set();
|
|
24
|
+
constructor({ appConnectionURL, appChannelID, everyskUID, onStatusChange }) {
|
|
25
|
+
this._everyskUID = everyskUID;
|
|
26
|
+
this._socket = io(appConnectionURL, {
|
|
27
|
+
auth: {
|
|
28
|
+
appChannelID,
|
|
29
|
+
everyskUID
|
|
30
|
+
},
|
|
31
|
+
transports: ["websocket"]
|
|
32
|
+
});
|
|
33
|
+
this._socket.on("connect", () => {
|
|
34
|
+
this._socket.emit(JOIN_EVENT, appChannelID);
|
|
35
|
+
onStatusChange?.("connected");
|
|
36
|
+
});
|
|
37
|
+
this._socket.on("connect_error", (error) => {
|
|
38
|
+
console.error("Socket.IO connection error:", error);
|
|
39
|
+
onStatusChange?.("error");
|
|
40
|
+
});
|
|
41
|
+
this._socket.on("disconnect", (reason) => {
|
|
42
|
+
console.error("Socket.IO disconnected:", reason);
|
|
43
|
+
onStatusChange?.(reason === "io server disconnect" ? "error" : "connecting");
|
|
44
|
+
});
|
|
45
|
+
this._socket.on(NOTIFICATION_EVENT, (msg) => {
|
|
46
|
+
if (!isWebSocketNotification(msg)) return;
|
|
47
|
+
if (this._isEcho(msg)) return;
|
|
48
|
+
this._listeners.forEach((callback) => {
|
|
49
|
+
try {
|
|
50
|
+
callback(msg);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error("Socket.IO notification listener threw:", error);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
_isEcho(msg) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* listen
|
|
62
|
+
*
|
|
63
|
+
* Registers a listener that receives every incoming notification.
|
|
64
|
+
*
|
|
65
|
+
* @param {(msg: WebSocketNotification) => void} callback - Invoked for each notification.
|
|
66
|
+
* @returns {() => void} Unsubscribe function.
|
|
67
|
+
*/
|
|
68
|
+
listen(callback) {
|
|
69
|
+
this._listeners.add(callback);
|
|
70
|
+
return () => this._listeners.delete(callback);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* close
|
|
74
|
+
*
|
|
75
|
+
* Clears all listeners and disconnects the socket.
|
|
76
|
+
* After calling this, the handler should be considered unusable.
|
|
77
|
+
*/
|
|
78
|
+
close() {
|
|
79
|
+
this._listeners.clear();
|
|
80
|
+
this._socket.removeAllListeners();
|
|
81
|
+
this._socket.disconnect();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
export { WebSocketHandler };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","names":[],"sources":["../../../src/contexts/webSocketContext/handler.ts"],"sourcesContent":["import { io, type Socket } from \"socket.io-client\";\n\nimport type { WebSocketNotification, WebSocketStatus, WebsocketsConfig } from \"./types\";\n\nfunction isWebSocketNotification(value: unknown): value is WebSocketNotification {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as Record<string, unknown>)[\"event_type\"] === \"string\"\n );\n}\nimport { JOIN_EVENT, NOTIFICATION_EVENT } from \"./constants\";\n\ntype StatusListener = (status: Exclude<WebSocketStatus, \"idle\">) => void;\n\ntype WebSocketHandlerConfig = WebsocketsConfig & {\n onStatusChange?: StatusListener;\n};\n\n/**\n * WebSocketHandler\n *\n * Low-level Socket.IO wrapper with a pub/sub layer.\n *\n * - Connects to the notification server.\n * - Joins the per-user channel.\n * - Forwards notifications to registered listeners.\n *\n * API:\n * - `listen(callback)`: register a notification listener; returns an unsubscribe function.\n * - `close()`: disconnect the socket and clear all listeners.\n */\nexport class WebSocketHandler {\n private _socket: Socket;\n private _everyskUID: string;\n private _listeners: Set<(msg: WebSocketNotification) => void> = new Set();\n\n constructor({ appConnectionURL, appChannelID, everyskUID, onStatusChange }: WebSocketHandlerConfig) {\n this._everyskUID = everyskUID;\n\n this._socket = io(appConnectionURL, {\n auth: { appChannelID, everyskUID },\n transports: [\"websocket\"],\n });\n\n this._socket.on(\"connect\", () => {\n this._socket.emit(JOIN_EVENT, appChannelID);\n onStatusChange?.(\"connected\");\n });\n\n this._socket.on(\"connect_error\", (error) => {\n console.error(\"Socket.IO connection error:\", error);\n onStatusChange?.(\"error\");\n });\n\n this._socket.on(\"disconnect\", (reason: string) => {\n console.error(\"Socket.IO disconnected:\", reason);\n onStatusChange?.(reason === \"io server disconnect\" ? \"error\" : \"connecting\");\n });\n\n this._socket.on(NOTIFICATION_EVENT, (msg: unknown) => {\n if (!isWebSocketNotification(msg)) return;\n if (this._isEcho(msg)) return;\n this._listeners.forEach((callback) => {\n try {\n callback(msg);\n } catch (error) {\n console.error(\"Socket.IO notification listener threw:\", error);\n }\n });\n });\n }\n\n private _isEcho(msg: WebSocketNotification): boolean {\n // Echo-cancellation is disabled by default.\n // Set ECHO_UID_FIELD to the message field that carries the originating uid\n // once the server team confirms the field name.\n const ECHO_UID_FIELD: string | null = null;\n if (!ECHO_UID_FIELD) return false;\n const originating = (msg as Record<string, unknown>)[ECHO_UID_FIELD];\n return originating === this._everyskUID;\n }\n\n /**\n * listen\n *\n * Registers a listener that receives every incoming notification.\n *\n * @param {(msg: WebSocketNotification) => void} callback - Invoked for each notification.\n * @returns {() => void} Unsubscribe function.\n */\n listen(callback: (msg: WebSocketNotification) => void): () => void {\n this._listeners.add(callback);\n return () => this._listeners.delete(callback);\n }\n\n /**\n * close\n *\n * Clears all listeners and disconnects the socket.\n * After calling this, the handler should be considered unusable.\n */\n close(): void {\n this._listeners.clear();\n this._socket.removeAllListeners();\n this._socket.disconnect();\n }\n}\n"],"mappings":";;;AAIA,SAAS,wBAAwB,OAAgD;CAC7E,OACI,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAkC,kBAAkB;AAEpE;;;;;;;;;;;;;;AAsBA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA,6BAAgE,IAAI,IAAI;CAExE,YAAY,EAAE,kBAAkB,cAAc,YAAY,kBAA0C;EAChG,KAAK,cAAc;EAEnB,KAAK,UAAU,GAAG,kBAAkB;GAChC,MAAM;IAAE;IAAc;GAAW;GACjC,YAAY,CAAC,WAAW;EAC5B,CAAC;EAED,KAAK,QAAQ,GAAG,iBAAiB;GAC7B,KAAK,QAAQ,KAAK,YAAY,YAAY;GAC1C,iBAAiB,WAAW;EAChC,CAAC;EAED,KAAK,QAAQ,GAAG,kBAAkB,UAAU;GACxC,QAAQ,MAAM,+BAA+B,KAAK;GAClD,iBAAiB,OAAO;EAC5B,CAAC;EAED,KAAK,QAAQ,GAAG,eAAe,WAAmB;GAC9C,QAAQ,MAAM,2BAA2B,MAAM;GAC/C,iBAAiB,WAAW,yBAAyB,UAAU,YAAY;EAC/E,CAAC;EAED,KAAK,QAAQ,GAAG,qBAAqB,QAAiB;GAClD,IAAI,CAAC,wBAAwB,GAAG,GAAG;GACnC,IAAI,KAAK,QAAQ,GAAG,GAAG;GACvB,KAAK,WAAW,SAAS,aAAa;IAClC,IAAI;KACA,SAAS,GAAG;IAChB,SAAS,OAAO;KACZ,QAAQ,MAAM,0CAA0C,KAAK;IACjE;GACJ,CAAC;EACL,CAAC;CACL;CAEA,QAAgB,KAAqC;EAK5B,OAAO;CAGhC;;;;;;;;;CAUA,OAAO,UAA4D;EAC/D,KAAK,WAAW,IAAI,QAAQ;EAC5B,aAAa,KAAK,WAAW,OAAO,QAAQ;CAChD;;;;;;;CAQA,QAAc;EACV,KAAK,WAAW,MAAM;EACtB,KAAK,QAAQ,mBAAmB;EAChC,KAAK,QAAQ,WAAW;CAC5B;AACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AppNotification } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* useAppNotificationSubscription
|
|
4
|
+
*
|
|
5
|
+
* Convenience wrapper around `useWebSocketSubscription` that only invokes the handler
|
|
6
|
+
* for `event_type === "USER_APP_NOTIFICATION"` messages. All other WebSocket events are ignored.
|
|
7
|
+
*
|
|
8
|
+
* @param {(msg: AppNotification) => void} handler
|
|
9
|
+
* Callback invoked for each app-targeted notification.
|
|
10
|
+
*
|
|
11
|
+
* Example:
|
|
12
|
+
* ```ts
|
|
13
|
+
* useAppNotificationSubscription((msg) => {
|
|
14
|
+
* queryClient.invalidateQueries({ queryKey: ["portfolios"] });
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const useAppNotificationSubscription: (handler: (msg: AppNotification) => void) => void;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,aAAa,CAAC;AAW1E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,SAMrF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "../../constants.js";
|
|
2
|
+
import { useWebSocketSubscription } from "../useWebSocketSubscription/index.js";
|
|
3
|
+
//#region src/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.ts
|
|
4
|
+
function isAppNotification(msg) {
|
|
5
|
+
return msg.event_type === "USER_APP_NOTIFICATION" && typeof msg["user_app_id"] === "string" && typeof msg["payload"] === "object" && msg["payload"] !== null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* useAppNotificationSubscription
|
|
9
|
+
*
|
|
10
|
+
* Convenience wrapper around `useWebSocketSubscription` that only invokes the handler
|
|
11
|
+
* for `event_type === "USER_APP_NOTIFICATION"` messages. All other WebSocket events are ignored.
|
|
12
|
+
*
|
|
13
|
+
* @param {(msg: AppNotification) => void} handler
|
|
14
|
+
* Callback invoked for each app-targeted notification.
|
|
15
|
+
*
|
|
16
|
+
* Example:
|
|
17
|
+
* ```ts
|
|
18
|
+
* useAppNotificationSubscription((msg) => {
|
|
19
|
+
* queryClient.invalidateQueries({ queryKey: ["portfolios"] });
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
var useAppNotificationSubscription = (handler) => {
|
|
24
|
+
useWebSocketSubscription((msg) => {
|
|
25
|
+
if (isAppNotification(msg)) handler(msg);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { useAppNotificationSubscription };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/contexts/webSocketContext/hooks/useAppNotificationSubscription/index.ts"],"sourcesContent":["import { useWebSocketSubscription } from \"../useWebSocketSubscription\";\nimport { APP_NOTIFICATION_EVENT_TYPE } from \"../../constants\";\nimport type { AppNotification, WebSocketNotification } from \"../../types\";\n\nfunction isAppNotification(msg: WebSocketNotification): msg is AppNotification {\n return (\n msg.event_type === APP_NOTIFICATION_EVENT_TYPE &&\n typeof msg[\"user_app_id\"] === \"string\" &&\n typeof msg[\"payload\"] === \"object\" &&\n msg[\"payload\"] !== null\n );\n}\n\n/**\n * useAppNotificationSubscription\n *\n * Convenience wrapper around `useWebSocketSubscription` that only invokes the handler\n * for `event_type === \"USER_APP_NOTIFICATION\"` messages. All other WebSocket events are ignored.\n *\n * @param {(msg: AppNotification) => void} handler\n * Callback invoked for each app-targeted notification.\n *\n * Example:\n * ```ts\n * useAppNotificationSubscription((msg) => {\n * queryClient.invalidateQueries({ queryKey: [\"portfolios\"] });\n * });\n * ```\n */\nexport const useAppNotificationSubscription = (handler: (msg: AppNotification) => void) => {\n useWebSocketSubscription((msg: WebSocketNotification) => {\n if (isAppNotification(msg)) {\n handler(msg);\n }\n });\n};\n"],"mappings":";;;AAIA,SAAS,kBAAkB,KAAoD;CAC3E,OACI,IAAI,eAAA,2BACJ,OAAO,IAAI,mBAAmB,YAC9B,OAAO,IAAI,eAAe,YAC1B,IAAI,eAAe;AAE3B;;;;;;;;;;;;;;;;;AAkBA,IAAa,kCAAkC,YAA4C;CACvF,0BAA0B,QAA+B;EACrD,IAAI,kBAAkB,GAAG,GACrB,QAAQ,GAAG;CAEnB,CAAC;AACL"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useWebSocket
|
|
3
|
+
*
|
|
4
|
+
* Convenience hook that reads the WebSocket API from `WebSocketContext`.
|
|
5
|
+
*
|
|
6
|
+
* Returns: `{ subscribe, lastMessage, status }` (see `WebSocketContextType`).
|
|
7
|
+
*
|
|
8
|
+
* @throws {Error} If used outside of `<WebSocketProvider>`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useWebSocket: () => import("../../types").WebSocketContextType;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/webSocketContext/hooks/useWebSocket/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,kDAIxB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WebSocketContext } from "../../index.js";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
//#region src/contexts/webSocketContext/hooks/useWebSocket/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* useWebSocket
|
|
6
|
+
*
|
|
7
|
+
* Convenience hook that reads the WebSocket API from `WebSocketContext`.
|
|
8
|
+
*
|
|
9
|
+
* Returns: `{ subscribe, lastMessage, status }` (see `WebSocketContextType`).
|
|
10
|
+
*
|
|
11
|
+
* @throws {Error} If used outside of `<WebSocketProvider>`.
|
|
12
|
+
*/
|
|
13
|
+
var useWebSocket = () => {
|
|
14
|
+
const context = useContext(WebSocketContext);
|
|
15
|
+
if (!context) throw new Error("useWebSocket must be used within <WebSocketProvider>.");
|
|
16
|
+
return context;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { useWebSocket };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/contexts/webSocketContext/hooks/useWebSocket/index.ts"],"sourcesContent":["import { useContext } from \"react\";\n\nimport { WebSocketContext } from \"../..\";\n\n/**\n * useWebSocket\n *\n * Convenience hook that reads the WebSocket API from `WebSocketContext`.\n *\n * Returns: `{ subscribe, lastMessage, status }` (see `WebSocketContextType`).\n *\n * @throws {Error} If used outside of `<WebSocketProvider>`.\n */\nexport const useWebSocket = () => {\n const context = useContext(WebSocketContext);\n if (!context) throw new Error(\"useWebSocket must be used within <WebSocketProvider>.\");\n return context;\n};\n"],"mappings":";;;;;;;;;;;;AAaA,IAAa,qBAAqB;CAC9B,MAAM,UAAU,WAAW,gBAAgB;CAC3C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACX"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { WebSocketNotification } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* useWebSocketSubscription
|
|
4
|
+
*
|
|
5
|
+
* High-level helper hook that subscribes to all WebSocket notifications on mount
|
|
6
|
+
* and unsubscribes on unmount.
|
|
7
|
+
*
|
|
8
|
+
* Why this exists:
|
|
9
|
+
* - Enforces the correct subscription pattern (`useEffect` + cleanup).
|
|
10
|
+
* - Prevents accidental duplicate subscriptions from re-renders.
|
|
11
|
+
* - Uses a ref-backed handler so the subscription is not recreated when the callback
|
|
12
|
+
* identity changes — the latest handler is always called without re-subscribing.
|
|
13
|
+
*
|
|
14
|
+
* Filtering (e.g. by `msg.event_type`) is intentionally left to the consumer.
|
|
15
|
+
* See `useAppNotificationSubscription` for a typed convenience wrapper.
|
|
16
|
+
*
|
|
17
|
+
* @param {(msg: WebSocketNotification) => void} handler
|
|
18
|
+
* Callback invoked for every received notification.
|
|
19
|
+
*
|
|
20
|
+
* Example:
|
|
21
|
+
* ```ts
|
|
22
|
+
* useWebSocketSubscription((msg) => {
|
|
23
|
+
* if (msg.event_type === "WORKFLOW_EXECUTION_COMPLETED") {
|
|
24
|
+
* queryClient.invalidateQueries({ queryKey: ["workflows"] });
|
|
25
|
+
* }
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const useWebSocketSubscription: (handler: (msg: WebSocketNotification) => void) => void;
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/webSocketContext/hooks/useWebSocketSubscription/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,CAAC,GAAG,EAAE,qBAAqB,KAAK,IAAI,SAYrF,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useWebSocket } from "../useWebSocket/index.js";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
//#region src/contexts/webSocketContext/hooks/useWebSocketSubscription/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* useWebSocketSubscription
|
|
6
|
+
*
|
|
7
|
+
* High-level helper hook that subscribes to all WebSocket notifications on mount
|
|
8
|
+
* and unsubscribes on unmount.
|
|
9
|
+
*
|
|
10
|
+
* Why this exists:
|
|
11
|
+
* - Enforces the correct subscription pattern (`useEffect` + cleanup).
|
|
12
|
+
* - Prevents accidental duplicate subscriptions from re-renders.
|
|
13
|
+
* - Uses a ref-backed handler so the subscription is not recreated when the callback
|
|
14
|
+
* identity changes — the latest handler is always called without re-subscribing.
|
|
15
|
+
*
|
|
16
|
+
* Filtering (e.g. by `msg.event_type`) is intentionally left to the consumer.
|
|
17
|
+
* See `useAppNotificationSubscription` for a typed convenience wrapper.
|
|
18
|
+
*
|
|
19
|
+
* @param {(msg: WebSocketNotification) => void} handler
|
|
20
|
+
* Callback invoked for every received notification.
|
|
21
|
+
*
|
|
22
|
+
* Example:
|
|
23
|
+
* ```ts
|
|
24
|
+
* useWebSocketSubscription((msg) => {
|
|
25
|
+
* if (msg.event_type === "WORKFLOW_EXECUTION_COMPLETED") {
|
|
26
|
+
* queryClient.invalidateQueries({ queryKey: ["workflows"] });
|
|
27
|
+
* }
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
var useWebSocketSubscription = (handler) => {
|
|
32
|
+
const { subscribe } = useWebSocket();
|
|
33
|
+
const handlerRef = useRef(handler);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
handlerRef.current = handler;
|
|
36
|
+
});
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
return subscribe((msg) => handlerRef.current(msg));
|
|
39
|
+
}, [subscribe]);
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { useWebSocketSubscription };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/contexts/webSocketContext/hooks/useWebSocketSubscription/index.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nimport { useWebSocket } from \"../useWebSocket\";\nimport type { WebSocketNotification } from \"../../types\";\n\n/**\n * useWebSocketSubscription\n *\n * High-level helper hook that subscribes to all WebSocket notifications on mount\n * and unsubscribes on unmount.\n *\n * Why this exists:\n * - Enforces the correct subscription pattern (`useEffect` + cleanup).\n * - Prevents accidental duplicate subscriptions from re-renders.\n * - Uses a ref-backed handler so the subscription is not recreated when the callback\n * identity changes — the latest handler is always called without re-subscribing.\n *\n * Filtering (e.g. by `msg.event_type`) is intentionally left to the consumer.\n * See `useAppNotificationSubscription` for a typed convenience wrapper.\n *\n * @param {(msg: WebSocketNotification) => void} handler\n * Callback invoked for every received notification.\n *\n * Example:\n * ```ts\n * useWebSocketSubscription((msg) => {\n * if (msg.event_type === \"WORKFLOW_EXECUTION_COMPLETED\") {\n * queryClient.invalidateQueries({ queryKey: [\"workflows\"] });\n * }\n * });\n * ```\n */\nexport const useWebSocketSubscription = (handler: (msg: WebSocketNotification) => void) => {\n const { subscribe } = useWebSocket();\n const handlerRef = useRef(handler);\n\n useEffect(() => {\n handlerRef.current = handler;\n });\n\n useEffect(() => {\n const unsubscribe = subscribe((msg: WebSocketNotification) => handlerRef.current(msg));\n return unsubscribe;\n }, [subscribe]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAa,4BAA4B,YAAkD;CACvF,MAAM,EAAE,cAAc,aAAa;CACnC,MAAM,aAAa,OAAO,OAAO;CAEjC,gBAAgB;EACZ,WAAW,UAAU;CACzB,CAAC;CAED,gBAAgB;EAEZ,OADoB,WAAW,QAA+B,WAAW,QAAQ,GAAG,CAC7E;CACX,GAAG,CAAC,SAAS,CAAC;AAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/contexts/webSocketContext/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,eAAO,MAAM,gBAAgB,sDAAmD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/contexts/webSocketContext/index.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nimport type { WebSocketContextType } from \"./types\";\n\nexport const WebSocketContext = createContext<WebSocketContextType | null>(null);\n"],"mappings":";;AAIA,IAAa,mBAAmB,cAA2C,IAAI"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { WebSocketProviderProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* WebSocketProvider
|
|
4
|
+
*
|
|
5
|
+
* React context provider that exposes a receive-only pub/sub API backed by Socket.IO.
|
|
6
|
+
*
|
|
7
|
+
* What this provider does:
|
|
8
|
+
* - Fetches `/api/websockets_config` once on mount to get the connection URL, channel id,
|
|
9
|
+
* and session uid. Socket.IO handles reconnection internally — the config is not re-fetched.
|
|
10
|
+
* - Opens a `WebSocketHandler` instance that connects and joins the per-user channel.
|
|
11
|
+
* - Exposes `subscribe`, `lastMessage`, and `status` via `WebSocketContext`.
|
|
12
|
+
*
|
|
13
|
+
* Why the pending buffer exists (`pendingRef`):
|
|
14
|
+
* - The handler is created asynchronously (after the config fetch resolves).
|
|
15
|
+
* - Consumers that call `subscribe` before the handler is ready have their callbacks buffered
|
|
16
|
+
* and registered once the handler initializes, ensuring no early subscriptions are lost.
|
|
17
|
+
*
|
|
18
|
+
* Subscribe buffering behavior:
|
|
19
|
+
* - If `subscribe(fn)` is called before the handler exists, `fn` is stored with a `null` placeholder.
|
|
20
|
+
* - Once the handler is ready, all pending callbacks are registered and their unsubscribe functions
|
|
21
|
+
* stored back into the map.
|
|
22
|
+
* - The returned cleanup always works: it calls the real unsubscribe if available, or removes
|
|
23
|
+
* the entry from the pending map.
|
|
24
|
+
*
|
|
25
|
+
* Usage:
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <WebSocketProvider>
|
|
28
|
+
* <YourPage />
|
|
29
|
+
* </WebSocketProvider>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* Context value (WebSocketContextType):
|
|
33
|
+
* @returns {object}
|
|
34
|
+
* - `subscribe(fn)`: register a listener; returns an unsubscribe function.
|
|
35
|
+
* - `lastMessage`: the most recently received notification (or null).
|
|
36
|
+
* - `status`: current connection status ("connecting" | "connected" | "error").
|
|
37
|
+
*/
|
|
38
|
+
export declare const WebSocketProvider: ({ children }: WebSocketProviderProps) => import("react").JSX.Element;
|
|
39
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/webSocketContext/provider.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAA+C,sBAAsB,EAAmB,MAAM,SAAS,CAAC;AAEpH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,iBAAiB,GAAI,cAAc,sBAAsB,gCA+ErE,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { useAppAlert } from "../appAlertContext/useAppAlert.js";
|
|
2
|
+
import { useAxios } from "../../hooks/useAxios.js";
|
|
3
|
+
import { WebSocketContext } from "./index.js";
|
|
4
|
+
import { getWebsocketsConfig } from "../../api/websocketsConfig.js";
|
|
5
|
+
import { WebSocketHandler } from "./handler.js";
|
|
6
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
//#region src/contexts/webSocketContext/provider.tsx
|
|
9
|
+
/**
|
|
10
|
+
* WebSocketProvider
|
|
11
|
+
*
|
|
12
|
+
* React context provider that exposes a receive-only pub/sub API backed by Socket.IO.
|
|
13
|
+
*
|
|
14
|
+
* What this provider does:
|
|
15
|
+
* - Fetches `/api/websockets_config` once on mount to get the connection URL, channel id,
|
|
16
|
+
* and session uid. Socket.IO handles reconnection internally — the config is not re-fetched.
|
|
17
|
+
* - Opens a `WebSocketHandler` instance that connects and joins the per-user channel.
|
|
18
|
+
* - Exposes `subscribe`, `lastMessage`, and `status` via `WebSocketContext`.
|
|
19
|
+
*
|
|
20
|
+
* Why the pending buffer exists (`pendingRef`):
|
|
21
|
+
* - The handler is created asynchronously (after the config fetch resolves).
|
|
22
|
+
* - Consumers that call `subscribe` before the handler is ready have their callbacks buffered
|
|
23
|
+
* and registered once the handler initializes, ensuring no early subscriptions are lost.
|
|
24
|
+
*
|
|
25
|
+
* Subscribe buffering behavior:
|
|
26
|
+
* - If `subscribe(fn)` is called before the handler exists, `fn` is stored with a `null` placeholder.
|
|
27
|
+
* - Once the handler is ready, all pending callbacks are registered and their unsubscribe functions
|
|
28
|
+
* stored back into the map.
|
|
29
|
+
* - The returned cleanup always works: it calls the real unsubscribe if available, or removes
|
|
30
|
+
* the entry from the pending map.
|
|
31
|
+
*
|
|
32
|
+
* Usage:
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <WebSocketProvider>
|
|
35
|
+
* <YourPage />
|
|
36
|
+
* </WebSocketProvider>
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* Context value (WebSocketContextType):
|
|
40
|
+
* @returns {object}
|
|
41
|
+
* - `subscribe(fn)`: register a listener; returns an unsubscribe function.
|
|
42
|
+
* - `lastMessage`: the most recently received notification (or null).
|
|
43
|
+
* - `status`: current connection status ("connecting" | "connected" | "error").
|
|
44
|
+
*/
|
|
45
|
+
var WebSocketProvider = ({ children }) => {
|
|
46
|
+
const { api } = useAxios();
|
|
47
|
+
const { showAlert } = useAppAlert();
|
|
48
|
+
const apiRef = useRef(api);
|
|
49
|
+
const showAlertRef = useRef(showAlert);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
apiRef.current = api;
|
|
52
|
+
});
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
showAlertRef.current = showAlert;
|
|
55
|
+
});
|
|
56
|
+
const handlerRef = useRef(null);
|
|
57
|
+
const unsubscribeProviderRef = useRef(null);
|
|
58
|
+
const [lastMessage, setLastMessage] = useState(null);
|
|
59
|
+
const [status, setStatus] = useState("idle");
|
|
60
|
+
const pendingRef = useRef(/* @__PURE__ */ new Map());
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
let cancelled = false;
|
|
63
|
+
const pending = pendingRef.current;
|
|
64
|
+
getWebsocketsConfig(apiRef.current).then((config) => {
|
|
65
|
+
if (cancelled) return;
|
|
66
|
+
setStatus("connecting");
|
|
67
|
+
const handler = new WebSocketHandler({
|
|
68
|
+
...config,
|
|
69
|
+
onStatusChange: (s) => setStatus(s)
|
|
70
|
+
});
|
|
71
|
+
handlerRef.current = handler;
|
|
72
|
+
unsubscribeProviderRef.current = handler.listen((message) => setLastMessage(message));
|
|
73
|
+
for (const [fn, unsub] of pending.entries()) if (!unsub) {
|
|
74
|
+
const realUnsub = handler.listen(fn);
|
|
75
|
+
pending.set(fn, realUnsub);
|
|
76
|
+
}
|
|
77
|
+
}).catch((error) => {
|
|
78
|
+
if (cancelled) return;
|
|
79
|
+
console.error("Failed to initialize WebSocket connection:", error);
|
|
80
|
+
setStatus("error");
|
|
81
|
+
showAlertRef.current({
|
|
82
|
+
message: "Real-time notifications are unavailable. Please refresh the page.",
|
|
83
|
+
severity: "error"
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
return () => {
|
|
87
|
+
cancelled = true;
|
|
88
|
+
unsubscribeProviderRef.current?.();
|
|
89
|
+
unsubscribeProviderRef.current = null;
|
|
90
|
+
handlerRef.current?.close();
|
|
91
|
+
handlerRef.current = null;
|
|
92
|
+
pending.clear();
|
|
93
|
+
};
|
|
94
|
+
}, []);
|
|
95
|
+
const subscribe = useCallback((fn) => {
|
|
96
|
+
if (handlerRef.current) return handlerRef.current.listen(fn);
|
|
97
|
+
pendingRef.current.set(fn, null);
|
|
98
|
+
return () => {
|
|
99
|
+
const maybeUnsub = pendingRef.current.get(fn);
|
|
100
|
+
if (maybeUnsub) maybeUnsub();
|
|
101
|
+
pendingRef.current.delete(fn);
|
|
102
|
+
};
|
|
103
|
+
}, []);
|
|
104
|
+
const value = useMemo(() => ({
|
|
105
|
+
subscribe,
|
|
106
|
+
lastMessage,
|
|
107
|
+
status
|
|
108
|
+
}), [
|
|
109
|
+
subscribe,
|
|
110
|
+
lastMessage,
|
|
111
|
+
status
|
|
112
|
+
]);
|
|
113
|
+
return /* @__PURE__ */ jsx(WebSocketContext.Provider, {
|
|
114
|
+
value,
|
|
115
|
+
children
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
//#endregion
|
|
119
|
+
export { WebSocketProvider };
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","names":[],"sources":["../../../src/contexts/webSocketContext/provider.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { getWebsocketsConfig } from \"@/api/websocketsConfig\";\nimport { useAxios } from \"@/hooks/useAxios\";\nimport { useAppAlert } from \"@/contexts/appAlertContext/useAppAlert\";\nimport { WebSocketContext } from \".\";\nimport { WebSocketHandler } from \"./handler\";\nimport type { WebSocketContextType, WebSocketNotification, WebSocketProviderProps, WebSocketStatus } from \"./types\";\n\n/**\n * WebSocketProvider\n *\n * React context provider that exposes a receive-only pub/sub API backed by Socket.IO.\n *\n * What this provider does:\n * - Fetches `/api/websockets_config` once on mount to get the connection URL, channel id,\n * and session uid. Socket.IO handles reconnection internally — the config is not re-fetched.\n * - Opens a `WebSocketHandler` instance that connects and joins the per-user channel.\n * - Exposes `subscribe`, `lastMessage`, and `status` via `WebSocketContext`.\n *\n * Why the pending buffer exists (`pendingRef`):\n * - The handler is created asynchronously (after the config fetch resolves).\n * - Consumers that call `subscribe` before the handler is ready have their callbacks buffered\n * and registered once the handler initializes, ensuring no early subscriptions are lost.\n *\n * Subscribe buffering behavior:\n * - If `subscribe(fn)` is called before the handler exists, `fn` is stored with a `null` placeholder.\n * - Once the handler is ready, all pending callbacks are registered and their unsubscribe functions\n * stored back into the map.\n * - The returned cleanup always works: it calls the real unsubscribe if available, or removes\n * the entry from the pending map.\n *\n * Usage:\n * ```tsx\n * <WebSocketProvider>\n * <YourPage />\n * </WebSocketProvider>\n * ```\n *\n * Context value (WebSocketContextType):\n * @returns {object}\n * - `subscribe(fn)`: register a listener; returns an unsubscribe function.\n * - `lastMessage`: the most recently received notification (or null).\n * - `status`: current connection status (\"connecting\" | \"connected\" | \"error\").\n */\nexport const WebSocketProvider = ({ children }: WebSocketProviderProps) => {\n const { api } = useAxios();\n const { showAlert } = useAppAlert();\n\n // Refs keep the latest values accessible inside the mount-only effect without\n // making it re-run when api or showAlert change.\n const apiRef = useRef(api);\n const showAlertRef = useRef(showAlert);\n useEffect(() => { apiRef.current = api; });\n useEffect(() => { showAlertRef.current = showAlert; });\n\n const handlerRef = useRef<WebSocketHandler | null>(null);\n const unsubscribeProviderRef = useRef<(() => void) | null>(null);\n const [lastMessage, setLastMessage] = useState<WebSocketNotification | null>(null);\n const [status, setStatus] = useState<WebSocketStatus>(\"idle\");\n\n const pendingRef = useRef(new Map<(m: WebSocketNotification) => void, (() => void) | null>());\n\n useEffect(() => {\n let cancelled = false;\n const pending = pendingRef.current;\n\n getWebsocketsConfig(apiRef.current)\n .then((config) => {\n if (cancelled) return;\n\n setStatus(\"connecting\");\n const handler = new WebSocketHandler({\n ...config,\n onStatusChange: (s) => setStatus(s),\n });\n handlerRef.current = handler;\n\n unsubscribeProviderRef.current = handler.listen((message) => setLastMessage(message));\n\n for (const [fn, unsub] of pending.entries()) {\n if (!unsub) {\n const realUnsub = handler.listen(fn);\n pending.set(fn, realUnsub);\n }\n }\n })\n .catch((error) => {\n if (cancelled) return;\n console.error(\"Failed to initialize WebSocket connection:\", error);\n setStatus(\"error\");\n showAlertRef.current({ message: \"Real-time notifications are unavailable. Please refresh the page.\", severity: \"error\" });\n });\n\n return () => {\n cancelled = true;\n unsubscribeProviderRef.current?.();\n unsubscribeProviderRef.current = null;\n handlerRef.current?.close();\n handlerRef.current = null;\n pending.clear();\n };\n }, []); // mount-only — Socket.IO handles reconnection; no re-init needed when api changes\n\n const subscribe = useCallback((fn: (m: WebSocketNotification) => void) => {\n if (handlerRef.current) {\n return handlerRef.current.listen(fn);\n }\n\n pendingRef.current.set(fn, null);\n\n return () => {\n const maybeUnsub = pendingRef.current.get(fn);\n if (maybeUnsub) maybeUnsub();\n pendingRef.current.delete(fn);\n };\n }, []);\n\n const value: WebSocketContextType = useMemo(\n () => ({ subscribe, lastMessage, status }),\n [subscribe, lastMessage, status]\n );\n\n return <WebSocketContext.Provider value={value}>{children}</WebSocketContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,qBAAqB,EAAE,eAAuC;CACvE,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,cAAc,YAAY;CAIlC,MAAM,SAAS,OAAO,GAAG;CACzB,MAAM,eAAe,OAAO,SAAS;CACrC,gBAAgB;EAAE,OAAO,UAAU;CAAK,CAAC;CACzC,gBAAgB;EAAE,aAAa,UAAU;CAAW,CAAC;CAErD,MAAM,aAAa,OAAgC,IAAI;CACvD,MAAM,yBAAyB,OAA4B,IAAI;CAC/D,MAAM,CAAC,aAAa,kBAAkB,SAAuC,IAAI;CACjF,MAAM,CAAC,QAAQ,aAAa,SAA0B,MAAM;CAE5D,MAAM,aAAa,uBAAO,IAAI,IAA6D,CAAC;CAE5F,gBAAgB;EACZ,IAAI,YAAY;EAChB,MAAM,UAAU,WAAW;EAE3B,oBAAoB,OAAO,OAAO,CAAC,CAC9B,MAAM,WAAW;GACd,IAAI,WAAW;GAEf,UAAU,YAAY;GACtB,MAAM,UAAU,IAAI,iBAAiB;IACjC,GAAG;IACH,iBAAiB,MAAM,UAAU,CAAC;GACtC,CAAC;GACD,WAAW,UAAU;GAErB,uBAAuB,UAAU,QAAQ,QAAQ,YAAY,eAAe,OAAO,CAAC;GAEpF,KAAK,MAAM,CAAC,IAAI,UAAU,QAAQ,QAAQ,GACtC,IAAI,CAAC,OAAO;IACR,MAAM,YAAY,QAAQ,OAAO,EAAE;IACnC,QAAQ,IAAI,IAAI,SAAS;GAC7B;EAER,CAAC,CAAC,CACD,OAAO,UAAU;GACd,IAAI,WAAW;GACf,QAAQ,MAAM,8CAA8C,KAAK;GACjE,UAAU,OAAO;GACjB,aAAa,QAAQ;IAAE,SAAS;IAAqE,UAAU;GAAQ,CAAC;EAC5H,CAAC;EAEL,aAAa;GACT,YAAY;GACZ,uBAAuB,UAAU;GACjC,uBAAuB,UAAU;GACjC,WAAW,SAAS,MAAM;GAC1B,WAAW,UAAU;GACrB,QAAQ,MAAM;EAClB;CACJ,GAAG,CAAC,CAAC;CAEL,MAAM,YAAY,aAAa,OAA2C;EACtE,IAAI,WAAW,SACX,OAAO,WAAW,QAAQ,OAAO,EAAE;EAGvC,WAAW,QAAQ,IAAI,IAAI,IAAI;EAE/B,aAAa;GACT,MAAM,aAAa,WAAW,QAAQ,IAAI,EAAE;GAC5C,IAAI,YAAY,WAAW;GAC3B,WAAW,QAAQ,OAAO,EAAE;EAChC;CACJ,GAAG,CAAC,CAAC;CAEL,MAAM,QAA8B,eACzB;EAAE;EAAW;EAAa;CAAO,IACxC;EAAC;EAAW;EAAa;CAAM,CACnC;CAEA,OAAO,oBAAC,iBAAiB,UAAlB;EAAkC;EAAQ;CAAoC,CAAA;AACzF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type WebsocketsConfig = {
|
|
3
|
+
appConnectionURL: string;
|
|
4
|
+
appChannelID: string;
|
|
5
|
+
everyskUID: string;
|
|
6
|
+
};
|
|
7
|
+
export type WebSocketStatus = "idle" | "connecting" | "connected" | "error";
|
|
8
|
+
export type AppNotificationPayload = {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* WebSocketNotification
|
|
13
|
+
*
|
|
14
|
+
* Base type for all Socket.IO notifications.
|
|
15
|
+
* `event_type` discriminates between notification kinds (e.g. "USER_APP_NOTIFICATION",
|
|
16
|
+
* "WORKFLOW_EXECUTION_COMPLETED"). Other fields vary per event_type.
|
|
17
|
+
*/
|
|
18
|
+
export type WebSocketNotification = {
|
|
19
|
+
event_type: string;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* AppNotification
|
|
24
|
+
*
|
|
25
|
+
* Narrowed type for event_type === "USER_APP_NOTIFICATION".
|
|
26
|
+
* Has a nested `payload` with app-level metadata.
|
|
27
|
+
*/
|
|
28
|
+
export type AppNotification = WebSocketNotification & {
|
|
29
|
+
event_type: "USER_APP_NOTIFICATION";
|
|
30
|
+
user_app_id: string;
|
|
31
|
+
payload: AppNotificationPayload;
|
|
32
|
+
};
|
|
33
|
+
export type WebSocketContextType = {
|
|
34
|
+
subscribe: (listener: (msg: WebSocketNotification) => void) => () => void;
|
|
35
|
+
lastMessage: WebSocketNotification | null;
|
|
36
|
+
status: WebSocketStatus;
|
|
37
|
+
};
|
|
38
|
+
export type WebSocketProviderProps = {
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|