diff --git a/webapp/packages/core-app/package.json b/webapp/packages/core-app/package.json index 4db89b8584..1f510c8e48 100644 --- a/webapp/packages/core-app/package.json +++ b/webapp/packages/core-app/package.json @@ -15,6 +15,7 @@ "lint-fix": "eslint ./src/ --ext .ts,.tsx --fix" }, "peerDependencies": { + "@cloudbeaver/core-browser": "~0.1.0", "@cloudbeaver/core-blocks": "~0.1.0", "@cloudbeaver/core-connections": "~0.1.0", "@cloudbeaver/core-di": "~0.1.0", diff --git a/webapp/packages/core-app/src/index.ts b/webapp/packages/core-app/src/index.ts index a37baa691d..d28037669f 100644 --- a/webapp/packages/core-app/src/index.ts +++ b/webapp/packages/core-app/src/index.ts @@ -86,3 +86,4 @@ export * from './TopNavBar/Logo'; // Interfaces export * from './shared/NodesManager/NodeManagerUtils'; export * from './shared/NodesManager/EntityTypes'; +export * from './manifest'; \ No newline at end of file diff --git a/webapp/packages/core-app/src/manifest.ts b/webapp/packages/core-app/src/manifest.ts new file mode 100644 index 0000000000..c01b89a3c4 --- /dev/null +++ b/webapp/packages/core-app/src/manifest.ts @@ -0,0 +1,76 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ + +import type { PluginManifest } from '@cloudbeaver/core-di'; + +import { AppLocaleService } from './AppLocaleService'; +import { AppScreenService } from './AppScreen/AppScreenService'; +import { CoreSettingsService } from './CoreSettingsService'; +import { ElementsTreeToolsMenuService } from './NavigationTree/ElementsTree/ElementsTreeTools/ElementsTreeToolsMenuService'; +import { NavigationTreeBootstrap } from './NavigationTree/NavigationTreeBootstrap'; +import { NavigationTreeService } from './NavigationTree/NavigationTreeService'; +import { QuotasService } from './QuotasService'; +import { NavigationTabsService } from './shared/NavigationTabs/NavigationTabsService'; +import { ConnectionDialogsService } from './shared/NodesManager/ConnectionDialogsService'; +import { DBObjectResource } from './shared/NodesManager/DBObjectResource'; +import { NavNodeContextMenuService } from './shared/NodesManager/NavNodeContextMenuService'; +import { NavNodeExtensionsService } from './shared/NodesManager/NavNodeExtensionsService'; +import { NavNodeInfoResource } from './shared/NodesManager/NavNodeInfoResource'; +import { NavNodeManagerService } from './shared/NodesManager/NavNodeManagerService'; +import { NavNodeViewService } from './shared/NodesManager/NavNodeView/NavNodeViewService'; +import { NavTreeResource } from './shared/NodesManager/NavTreeResource'; +import { SessionExpiredDialogService } from './shared/SessionExpireDialog/SessionExpiredDialogService'; +import { SessionExpireWarningDialogService } from './shared/SessionExpireWarningDialog/SessionExpireWarningDialogService'; +import { SqlGeneratorsBootstrap } from './shared/SqlGenerators/SqlGeneratorsBootstrap'; +import { SqlGeneratorsResource } from './shared/SqlGenerators/SqlGeneratorsResource'; +import { LogViewerBootstrap } from './shared/ToolsPanel/LogViewer/LogViewerBootstrap'; +import { LogViewerService } from './shared/ToolsPanel/LogViewer/LogViewerService'; +import { ToolsPanelService } from './shared/ToolsPanel/ToolsPanelService'; +import { AdministrationTopAppBarBootstrapService } from './TopNavBar/AdministrationTopAppBarBootstrapService'; +import { ConnectionSchemaManagerBootstrap } from './TopNavBar/ConnectionSchemaManager/ConnectionSchemaManagerBootstrap'; +import { ConnectionSchemaManagerService } from './TopNavBar/ConnectionSchemaManager/ConnectionSchemaManagerService'; +import { MainMenuService } from './TopNavBar/MainMenu/MainMenuService'; +import { TopNavService } from './TopNavBar/TopNavBarService'; + + +export const coreAppManifest: PluginManifest = { + info: { + name: 'Core App', + }, + + providers: [ + ConnectionDialogsService, + MainMenuService, + NavigationTreeService, + NavNodeManagerService, + DBObjectResource, + NavNodeViewService, + NavNodeExtensionsService, + NavNodeInfoResource, + SqlGeneratorsBootstrap, + SqlGeneratorsResource, + NavTreeResource, + ConnectionSchemaManagerService, + NavigationTabsService, + NavNodeContextMenuService, + LogViewerService, + LogViewerBootstrap, + TopNavService, + AppScreenService, + CoreSettingsService, + AdministrationTopAppBarBootstrapService, + AppLocaleService, + SessionExpiredDialogService, + SessionExpireWarningDialogService, + ConnectionSchemaManagerBootstrap, + NavigationTreeBootstrap, + ToolsPanelService, + QuotasService, + ElementsTreeToolsMenuService, + ], +}; diff --git a/webapp/packages/core-app/src/shared/SessionExpireWarningDialog/SessionExpireWarningDialogService.ts b/webapp/packages/core-app/src/shared/SessionExpireWarningDialog/SessionExpireWarningDialogService.ts index f6216a26ef..0b6e62ec44 100644 --- a/webapp/packages/core-app/src/shared/SessionExpireWarningDialog/SessionExpireWarningDialogService.ts +++ b/webapp/packages/core-app/src/shared/SessionExpireWarningDialog/SessionExpireWarningDialogService.ts @@ -7,9 +7,10 @@ */ import { UserInfoResource } from '@cloudbeaver/core-authentication'; +import { CookiesService } from '@cloudbeaver/core-browser'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; import { CommonDialogService, DialogueStateResult } from '@cloudbeaver/core-dialogs'; -import { ServerConfigResource, SessionExpireService, SessionResource, CookiesService } from '@cloudbeaver/core-root'; +import { ServerConfigResource, SessionExpireService, SessionResource } from '@cloudbeaver/core-root'; import { getCookies } from '@cloudbeaver/core-utils'; import { SessionExpireWarningDialog } from '../SessionExpireWarningDialog/SessionExpireWarningDialog'; diff --git a/webapp/packages/core-blocks/src/ErrorMessage.tsx b/webapp/packages/core-blocks/src/ErrorMessage.tsx index 6d6e7d8fbf..ee885291d2 100644 --- a/webapp/packages/core-blocks/src/ErrorMessage.tsx +++ b/webapp/packages/core-blocks/src/ErrorMessage.tsx @@ -10,7 +10,6 @@ import { observer } from 'mobx-react-lite'; import styled, { css } from 'reshadow'; import { useTranslate } from '@cloudbeaver/core-localization'; -import { useStyles } from '@cloudbeaver/core-theming'; import { Button } from './Button'; import { IconOrImage } from './IconOrImage'; @@ -62,7 +61,7 @@ export const ErrorMessage = observer(function ErrorMessage({ }) { const translate = useTranslate(); - return styled(useStyles(styles))( + return styled(styles)( diff --git a/webapp/packages/core-blocks/src/index.ts b/webapp/packages/core-blocks/src/index.ts index 14016c473a..de58c6aefd 100644 --- a/webapp/packages/core-blocks/src/index.ts +++ b/webapp/packages/core-blocks/src/index.ts @@ -182,3 +182,4 @@ export * from './Snackbars/Snackbar'; export * from './Snackbars/ActionSnackbar'; export * from './Snackbars/ProcessSnackbar'; export * from './useUserData'; +export * from './manifest'; \ No newline at end of file diff --git a/webapp/packages/core-blocks/src/manifest.ts b/webapp/packages/core-blocks/src/manifest.ts new file mode 100644 index 0000000000..d0ded1b47f --- /dev/null +++ b/webapp/packages/core-blocks/src/manifest.ts @@ -0,0 +1,21 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ + +import type { PluginManifest } from '@cloudbeaver/core-di'; + +import { BlocksLocaleService } from './BlocksLocaleService'; + +export const coreBlocksManifest: PluginManifest = { + info: { + name: 'Core Blocks', + }, + + providers: [ + BlocksLocaleService, + ], +}; diff --git a/webapp/packages/core-bootstrap/package.json b/webapp/packages/core-bootstrap/package.json index aeda4f15c9..6858fcac2a 100644 --- a/webapp/packages/core-bootstrap/package.json +++ b/webapp/packages/core-bootstrap/package.json @@ -19,6 +19,7 @@ "@cloudbeaver/core-app": "~0.1.0", "@cloudbeaver/core-authentication": "~0.1.0", "@cloudbeaver/core-blocks": "~0.1.0", + "@cloudbeaver/core-browser": "~0.1.0", "@cloudbeaver/core-connections": "~0.1.0", "@cloudbeaver/core-di": "~0.1.0", "@cloudbeaver/core-dialogs": "~0.1.0", diff --git a/webapp/packages/core-bootstrap/src/manifest.ts b/webapp/packages/core-bootstrap/src/manifest.ts index 9cb1292bf7..abae2421ef 100644 --- a/webapp/packages/core-bootstrap/src/manifest.ts +++ b/webapp/packages/core-bootstrap/src/manifest.ts @@ -7,42 +7,14 @@ */ import { coreAdministrationManifest } from '@cloudbeaver/core-administration'; -import { - ConnectionDialogsService, - MainMenuService, - NavigationTreeService, - NavNodeManagerService, - DBObjectResource, - NavNodeViewService, - NavNodeExtensionsService, - NavNodeInfoResource, - SqlGeneratorsBootstrap, - SqlGeneratorsResource, - NavTreeResource, - ConnectionSchemaManagerService, - NavigationTabsService, - NavNodeContextMenuService, - LogViewerService, - LogViewerBootstrap, - TopNavService, - AppScreenService, - CoreSettingsService, - AdministrationTopAppBarBootstrapService, - AppLocaleService, - SessionExpiredDialogService, - SessionExpireWarningDialogService, - ConnectionSchemaManagerBootstrap, - NavigationTreeBootstrap, - ToolsPanelService, - QuotasService, - ElementsTreeToolsMenuService, -} from '@cloudbeaver/core-app'; +import { coreAppManifest } from '@cloudbeaver/core-app'; import { coreAuthenticationManifest } from '@cloudbeaver/core-authentication'; -import { BlocksLocaleService } from '@cloudbeaver/core-blocks'; +import { coreBlocksManifest } from '@cloudbeaver/core-blocks'; +import { coreBrowserManifest } from '@cloudbeaver/core-browser'; import { coreConnectionsManifest } from '@cloudbeaver/core-connections'; import type { PluginManifest } from '@cloudbeaver/core-di'; -import { CommonDialogService, ContextMenuService } from '@cloudbeaver/core-dialogs'; -import { NotificationService, ExceptionsCatcherService, EventsSettingsService } from '@cloudbeaver/core-events'; +import { codeDialogsManifest } from '@cloudbeaver/core-dialogs'; +import { coreEventsManifest } from '@cloudbeaver/core-events'; import { coreLocalizationManifest } from '@cloudbeaver/core-localization'; import { corePluginManifest } from '@cloudbeaver/core-plugin'; import { coreProductManifest } from '@cloudbeaver/core-product'; @@ -57,6 +29,7 @@ import { coreVersionManifest } from '@cloudbeaver/core-version'; import { coreVersionUpdateManifest } from '@cloudbeaver/core-version-update'; import { coreViewManifest } from '@cloudbeaver/core-view'; + export const coreManifests: PluginManifest[] = [ { info: { @@ -64,57 +37,27 @@ export const coreManifests: PluginManifest[] = [ }, depends: [], - providers: [ - AdministrationTopAppBarBootstrapService, - CoreSettingsService, - QuotasService, - CommonDialogService, - SessionExpireWarningDialogService, - SessionExpiredDialogService, - ConnectionDialogsService, - ConnectionSchemaManagerBootstrap, - ConnectionSchemaManagerService, - BlocksLocaleService, - AppLocaleService, - AppScreenService, - ContextMenuService, - ExceptionsCatcherService, - EventsSettingsService, - LogViewerBootstrap, - LogViewerService, - MainMenuService, - TopNavService, - NavigationTabsService, - NavNodeContextMenuService, - NavigationTreeService, - NavNodeManagerService, - NavNodeViewService, - NavNodeExtensionsService, - NavNodeInfoResource, - SqlGeneratorsBootstrap, - SqlGeneratorsResource, - ElementsTreeToolsMenuService, - NavigationTreeBootstrap, - NavTreeResource, - DBObjectResource, - NotificationService, - ToolsPanelService, - ], + providers: [ ], }, coreRoutingManifest, // important, should be first because the router starts in load phase first after all plugins register phase coreThemingManifest, coreLocalizationManifest, + coreBlocksManifest, coreSettingsManifest, - coreProjectsManifest, - coreAdministrationManifest, + coreEventsManifest, coreSDKManifest, + coreRootManifest, + corePluginManifest, + coreBrowserManifest, + coreProductManifest, + coreProjectsManifest, coreAuthenticationManifest, coreUIManifest, coreViewManifest, coreVersionManifest, coreVersionUpdateManifest, - coreRootManifest, coreConnectionsManifest, - corePluginManifest, - coreProductManifest, + coreAdministrationManifest, + codeDialogsManifest, + coreAppManifest, ]; diff --git a/webapp/packages/core-browser/.gitignore b/webapp/packages/core-browser/.gitignore new file mode 100644 index 0000000000..99902db863 --- /dev/null +++ b/webapp/packages/core-browser/.gitignore @@ -0,0 +1,21 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/lib + +# misc +.DS_Store +.env* + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/webapp/packages/core-browser/package.json b/webapp/packages/core-browser/package.json new file mode 100644 index 0000000000..e1fff814b8 --- /dev/null +++ b/webapp/packages/core-browser/package.json @@ -0,0 +1,27 @@ +{ + "name": "@cloudbeaver/core-browser", + "sideEffects": false, + "version": "0.1.0", + "description": "", + "license": "Apache-2.0", + "main": "lib/index.js", + "module": "lib/index.js", + "types": "src/index.ts", + "scripts": { + "prebuild": "rimraf lib/*", + "build": "webpack --config ../../configs/webpack.plugin.config.js", + "postbuild": "tsc", + "lint": "eslint ./src/ --ext .ts,.tsx", + "lint-fix": "eslint ./src/ --ext .ts,.tsx --fix" + }, + "dependencies": { + "@cloudbeaver/core-di": "~0.1.0", + "@cloudbeaver/core-plugin": "~0.1.0", + "react": "~18.x.x", + "react-dom": "~18.x.x", + "reakit": "~1.x.x", + "mobx": "~6.x.x", + "mobx-react-lite": "~3.x.x", + "reshadow": "~0.x.x" + } +} \ No newline at end of file diff --git a/webapp/packages/core-root/src/CookiesService.ts b/webapp/packages/core-browser/src/CookiesService.ts similarity index 100% rename from webapp/packages/core-root/src/CookiesService.ts rename to webapp/packages/core-browser/src/CookiesService.ts diff --git a/webapp/packages/core-root/src/CookiesSettingsService.ts b/webapp/packages/core-browser/src/CookiesSettingsService.ts similarity index 100% rename from webapp/packages/core-root/src/CookiesSettingsService.ts rename to webapp/packages/core-browser/src/CookiesSettingsService.ts diff --git a/webapp/packages/core-browser/src/index.ts b/webapp/packages/core-browser/src/index.ts new file mode 100644 index 0000000000..d662748372 --- /dev/null +++ b/webapp/packages/core-browser/src/index.ts @@ -0,0 +1,2 @@ +export * from './CookiesService'; +export * from './manifest'; diff --git a/webapp/packages/core-browser/src/manifest.ts b/webapp/packages/core-browser/src/manifest.ts new file mode 100644 index 0000000000..66530bcff5 --- /dev/null +++ b/webapp/packages/core-browser/src/manifest.ts @@ -0,0 +1,24 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ + +import type { PluginManifest } from '@cloudbeaver/core-di'; + +import { CookiesService } from './CookiesService'; +import { CookiesSettingsService } from './CookiesSettingsService'; + + +export const coreBrowserManifest: PluginManifest = { + info: { + name: 'Core Browser', + }, + + providers: [ + CookiesSettingsService, + CookiesService, + ], +}; diff --git a/webapp/packages/core-browser/tsconfig.json b/webapp/packages/core-browser/tsconfig.json new file mode 100644 index 0000000000..2a4cc370f7 --- /dev/null +++ b/webapp/packages/core-browser/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "lib", + "composite": true + }, + "include": ["src"], + "exclude": ["**/node_modules", "**/.*/"], + "references": [{ "path": "../*" }] +} diff --git a/webapp/packages/core-cli/configs/webpack.config.js b/webapp/packages/core-cli/configs/webpack.config.js index 480662004d..06262a08c8 100644 --- a/webapp/packages/core-cli/configs/webpack.config.js +++ b/webapp/packages/core-cli/configs/webpack.config.js @@ -1,20 +1,20 @@ -const { resolve, join } = require('path') -const ModuleDependencyWarning = require('webpack/lib/ModuleDependencyWarning') -const MiniCssExtractPlugin = require('mini-css-extract-plugin') -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin') -const PnpWebpackPlugin = require(`pnp-webpack-plugin`); +const { resolve, join } = require('path'); +const PnpWebpackPlugin = require('pnp-webpack-plugin'); +const ModuleDependencyWarning = require('webpack/lib/ModuleDependencyWarning'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin'); // const ESLintPlugin = require('eslint-webpack-plugin'); class IgnoreNotFoundExportPlugin { - apply (compiler) { + apply(compiler) { const messageRegExp = /export '.*'( \(imported as '.*'\))? was not found in/; - function doneHook (stats) { + function doneHook(stats) { stats.compilation.warnings = stats.compilation.warnings.filter(warn => { if (warn instanceof ModuleDependencyWarning && messageRegExp.test(warn.message)) { return false; } - return true + return true; }); } if (compiler.hooks) { @@ -32,37 +32,37 @@ const nodeModules = [ ]; module.exports = (env, argv) => { - process.env.NODE_ENV = argv.mode - const devTool = 'source-map' in env && 'source-map' - const devMode = argv.mode !== 'production' - function getBaseStyleLoaders () { - const loaders = [] + process.env.NODE_ENV = argv.mode; + const devTool = 'source-map' in env && 'source-map'; + const devMode = argv.mode !== 'production'; + function getBaseStyleLoaders() { + const loaders = []; // Broke styles order in dev mode // if (devMode) { // loaders.push('style-loader'); // } else { - loaders.push(MiniCssExtractPlugin.loader) + loaders.push(MiniCssExtractPlugin.loader); // } - return loaders + return loaders; } - function generateStyleLoaders (options = { hasModule: false, disable: false }) { - const moduleScope = options.hasModule ? 'local' : 'global' + function generateStyleLoaders(options = { hasModule: false, disable: false }) { + const moduleScope = options.hasModule ? 'local' : 'global'; let modules = { mode: moduleScope, localIdentName: '[local]___[hash:base64:5]', - } + }; - if(options.disable) { + if (options.disable) { modules = false; } const postCssPlugins = [ require('postcss-preset-env')({ stage: 0 }), require('@reshadow/postcss')({ scopeBehaviour: moduleScope }), - ] + ]; return [ ...getBaseStyleLoaders(), @@ -93,7 +93,7 @@ module.exports = (env, argv) => { }, }, }, - ] + ]; } var babelLoader = { @@ -108,22 +108,22 @@ module.exports = (env, argv) => { optimization: { removeAvailableModules: false, removeEmptyChunks: false, - splitChunks: false + splitChunks: false, }, output: { - pathinfo: false + pathinfo: false, }, resolve: { extensions: ['.ts', '.tsx', '.js'], modules: nodeModules, // alias: { - // "react/jsx-dev-runtime": "react/jsx-dev-runtime.js", // 17->18 - // "react/jsx-runtime": "react/jsx-runtime.js", - // "react/jsx-runtime.js": "react/jsx-runtime", // 18->17 - // "react/jsx-dev-runtime.js": "react/jsx-dev-runtime" + // "react/jsx-dev-runtime": "react/jsx-dev-runtime.js", // 17->18 + // "react/jsx-runtime": "react/jsx-runtime.js", + // "react/jsx-runtime.js": "react/jsx-runtime", // 18->17 + // "react/jsx-dev-runtime.js": "react/jsx-dev-runtime" // }, fallback: { - path: require.resolve("path-browserify"), + path: require.resolve('path-browserify'), }, plugins: [ PnpWebpackPlugin, @@ -203,13 +203,13 @@ module.exports = (env, argv) => { insert: linkTag => { let reshadowObj = document.getElementById('__reshadow__'); - if(reshadowObj) { + if (reshadowObj) { document.head.insertBefore(linkTag, reshadowObj); - } else { - document.head.appendChild(linkTag) + } else { + document.head.appendChild(linkTag); } - } + }, }), ], - } -} + }; +}; diff --git a/webapp/packages/core-cli/configs/webpack.plugin.config.js b/webapp/packages/core-cli/configs/webpack.plugin.config.js index 164467c7fd..8d8e330d00 100644 --- a/webapp/packages/core-cli/configs/webpack.plugin.config.js +++ b/webapp/packages/core-cli/configs/webpack.plugin.config.js @@ -1,11 +1,12 @@ -const { merge } = require('webpack-merge'); const { resolve } = require('path'); var PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin'); +const { merge } = require('webpack-merge'); + const commonConfig = require('./webpack.config.js'); var main = resolve('src/index.ts'); var outputDir = resolve('lib'); -var package = require(resolve("package.json")); +var package = require(resolve('package.json')); module.exports = (env, argv) => merge(commonConfig(env, argv), { entry: main, diff --git a/webapp/packages/core-cli/configs/webpack.product.config.js b/webapp/packages/core-cli/configs/webpack.product.config.js index 347eb42974..2908e0e90b 100644 --- a/webapp/packages/core-cli/configs/webpack.product.config.js +++ b/webapp/packages/core-cli/configs/webpack.product.config.js @@ -3,7 +3,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); const webpack = require('webpack'); -const { merge } = require('webpack-merge') +const { merge } = require('webpack-merge'); const commonConfig = require('./webpack.config.js'); const { getAssets, withTimestamp } = require('./webpack.product.utils'); @@ -12,8 +12,8 @@ const HtmlInjectWebpackPlugin = require('./HtmlInjectWebpackPlugin.js'); const main = resolve('src/index.ts'); const sso = require.resolve('@cloudbeaver/plugin-sso/src/index.ts'); const ssoHtmlTemplate = require.resolve('@cloudbeaver/plugin-sso/src/index.html.ejs'); -const outputDir = resolve('lib') -const package = require(resolve('package.json')) +const outputDir = resolve('lib'); +const package = require(resolve('package.json')); const excludedFromVendor = [ 'react-data-grid', @@ -36,15 +36,15 @@ const excludedFromVendor = [ 'codemirror', 'react-codemirror2', 'd3', - 'dagre' -] + 'dagre', +]; -const timestampVersion = withTimestamp(package.version) +const timestampVersion = withTimestamp(package.version); module.exports = (env, argv) => merge(commonConfig(env, argv), { entry: { main, - sso + sso, }, output: { filename: 'index.[contenthash].js', @@ -82,14 +82,14 @@ module.exports = (env, argv) => merge(commonConfig(env, argv), { }), new webpack.DefinePlugin({ _VERSION_: JSON.stringify(timestampVersion), - _DEV_: false + _DEV_: false, }), new HtmlWebpackPlugin({ template: resolve('src/index.html.ejs'), inject: 'body', chunks: ['main'], version: timestampVersion, - title: package.product?.name + title: package.product?.name, }), new HtmlWebpackPlugin({ filename: 'sso.html', @@ -97,10 +97,10 @@ module.exports = (env, argv) => merge(commonConfig(env, argv), { inject: 'body', chunks: ['sso'], version: timestampVersion, - title: package.product?.name + title: package.product?.name, }), new HtmlInjectWebpackPlugin({ - body: [{ attributes: { hidden: true }, tagName: 'object', innerHTML: "{STATIC_CONTENT}", voidTag: false }] + body: [{ attributes: { hidden: true }, tagName: 'object', innerHTML: '{STATIC_CONTENT}', voidTag: false }], }), ], -}) +}); diff --git a/webapp/packages/core-cli/configs/webpack.product.dev.config.js b/webapp/packages/core-cli/configs/webpack.product.dev.config.js index 097e6cc08e..98e0a09d1e 100644 --- a/webapp/packages/core-cli/configs/webpack.product.dev.config.js +++ b/webapp/packages/core-cli/configs/webpack.product.dev.config.js @@ -1,38 +1,39 @@ -const { getAssets } = require('./webpack.product.utils'); const { merge } = require('webpack-merge'); const { resolve } = require('path'); const webpack = require('webpack'); const fs = require('fs'); -const commonConfig = require('./webpack.config.js') +const commonConfig = require('./webpack.config.js'); const main = resolve('src/index.ts'); const sso = require.resolve('@cloudbeaver/plugin-sso/src/index.ts'); const ssoHtmlTemplate = require.resolve('@cloudbeaver/plugin-sso/src/index.html.ejs'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); + const HtmlInjectWebpackPlugin = require('./HtmlInjectWebpackPlugin'); +const { getAssets } = require('./webpack.product.utils'); const package = require(resolve('package.json')); -const certPath = resolve(__dirname, '../../../../../certs/private.pem') -const keyPath = resolve(__dirname, '../../../../../certs/private.key') +const certPath = resolve(__dirname, '../../../../../certs/private.pem'); +const keyPath = resolve(__dirname, '../../../../../certs/private.key'); let server = undefined; -if(fs.existsSync(certPath) && fs.existsSync(keyPath)) { +if (fs.existsSync(certPath) && fs.existsSync(keyPath)) { server = { type: 'https', options: { key: fs.readFileSync(keyPath), cert: fs.readFileSync(certPath), - } - } + }, + }; } module.exports = (env, argv) => merge(commonConfig(env, argv), { entry: { main, - sso + sso, }, mode: 'development', devServer: { @@ -46,11 +47,11 @@ module.exports = (env, argv) => merge(commonConfig(env, argv), { '/api': { target: env.server, }, - } + }, }, devtool: 'eval-source-map', optimization: { - moduleIds: "named" + moduleIds: 'named', }, plugins: [ new CopyWebpackPlugin({ @@ -60,12 +61,12 @@ module.exports = (env, argv) => merge(commonConfig(env, argv), { _VERSION_: JSON.stringify(package.version), _DEV_: true, }), - new HtmlWebpackPlugin({ - template: resolve('src/index.html.ejs'), + new HtmlWebpackPlugin({ + template: resolve('src/index.html.ejs'), inject: 'body', chunks: ['main'], version: package.version, - title: package.product?.name + title: package.product?.name, }), new HtmlWebpackPlugin({ filename: 'sso.html', @@ -73,10 +74,10 @@ module.exports = (env, argv) => merge(commonConfig(env, argv), { inject: 'body', chunks: ['sso'], version: package.version, - title: package.product?.name + title: package.product?.name, }), new HtmlInjectWebpackPlugin({ - body: [{ attributes: { hidden: true }, tagName: 'object', innerHTML: "{STATIC_CONTENT}", voidTag: false }] + body: [{ attributes: { hidden: true }, tagName: 'object', innerHTML: '{STATIC_CONTENT}', voidTag: false }], }), new webpack.HotModuleReplacementPlugin(), ], diff --git a/webapp/packages/core-cli/configs/webpack.product.utils.js b/webapp/packages/core-cli/configs/webpack.product.utils.js index 9db308332a..722a5a3f3e 100644 --- a/webapp/packages/core-cli/configs/webpack.product.utils.js +++ b/webapp/packages/core-cli/configs/webpack.product.utils.js @@ -3,7 +3,7 @@ const { resolve } = require('path'); const paths = [resolve('.')]; function withTimestamp(version) { - return `${version}.${new Date().toISOString().substr(0, 19).replace('T', '').split(/[-:]+/).join('').slice(0, -2)}` + return `${version}.${new Date().toISOString().substr(0, 19).replace('T', '').split(/[-:]+/).join('').slice(0, -2)}`; } function getCloudbeaverDeps(package) { @@ -12,7 +12,7 @@ function getCloudbeaverDeps(package) { } return Object.keys(package.dependencies) - .filter(dependency => /@cloudbeaver\/(.*?)/.test(dependency)) + .filter(dependency => /@cloudbeaver\/(.*?)/.test(dependency)); } function scanCloudbeaverDeps(package) { @@ -23,13 +23,13 @@ function scanCloudbeaverDeps(package) { const dependency = list.shift(); if (!deps.has(dependency)) { - list.push(...getCloudbeaverDeps(require(resolve('../../node_modules', dependency, 'package.json')))) + list.push(...getCloudbeaverDeps(require(resolve('../../node_modules', dependency, 'package.json')))); } deps.add(dependency); } - return Array.from(deps.keys()) + return Array.from(deps.keys()); } function getAssets(package, to) { @@ -39,10 +39,10 @@ function getAssets(package, to) { patterns.push({ from: './public', to, force: true }); - return patterns.filter(pattern => fs.existsSync(pattern.from)) + return patterns.filter(pattern => fs.existsSync(pattern.from)); } -module.exports = { - withTimestamp, - getAssets -} +module.exports = { + withTimestamp, + getAssets, +}; diff --git a/webapp/packages/core-connections/src/ConnectionsManagerService.ts b/webapp/packages/core-connections/src/ConnectionsManagerService.ts index 583e2a7a66..cbaa19f920 100644 --- a/webapp/packages/core-connections/src/ConnectionsManagerService.ts +++ b/webapp/packages/core-connections/src/ConnectionsManagerService.ts @@ -12,7 +12,6 @@ import { CommonDialogService, ConfirmationDialogDelete, DialogueStateResult } fr import { NotificationService } from '@cloudbeaver/core-events'; import { Executor, ExecutorInterrupter, IExecutor } from '@cloudbeaver/core-executor'; import { CachedMapAllKey } from '@cloudbeaver/core-sdk'; -import { AuthenticationService } from '@cloudbeaver/plugin-authentication'; import { ConnectionInfoResource, Connection } from './ConnectionInfoResource'; import { ContainerResource, IStructContainers, ObjectContainer } from './ContainerResource'; @@ -36,7 +35,6 @@ export class ConnectionsManagerService { readonly containerContainers: ContainerResource, private readonly notificationService: NotificationService, private readonly commonDialogService: CommonDialogService, - private readonly authenticationService: AuthenticationService, ) { this.disconnecting = false; @@ -46,12 +44,6 @@ export class ConnectionsManagerService { this.connectionExecutor.addHandler(() => connectionInfo.load(CachedMapAllKey)); this.onDelete.before(this.onDisconnect); - this.authenticationService.onLogout.before(this.onDisconnect, state => ({ - connections: this.connectionInfo.values - .filter(connection => connection.connected) - .map(connection => connection.id), - state, - })); } async requireConnection(connectionId: string | null = null): Promise { diff --git a/webapp/packages/core-di/src/IApp.ts b/webapp/packages/core-di/src/IApp.ts index 04c1c000f4..6207bf9dcd 100644 --- a/webapp/packages/core-di/src/IApp.ts +++ b/webapp/packages/core-di/src/IApp.ts @@ -14,7 +14,7 @@ export interface IServiceCollection { addServiceByClass: (ctor: IServiceConstructor, value?: any) => void; } -export type ExtractInitArgs = T extends IInitializableController? TArgs : never; +export type ExtractInitArgs = T extends IInitializableController ? TArgs : never; export interface IDestructibleController { destruct: () => void; diff --git a/webapp/packages/core-dialogs/src/index.ts b/webapp/packages/core-dialogs/src/index.ts index 3f18b9d6e3..65db8c5311 100644 --- a/webapp/packages/core-dialogs/src/index.ts +++ b/webapp/packages/core-dialogs/src/index.ts @@ -17,3 +17,4 @@ export * from './Menu/models/ComputedMenuPanelModel'; export * from './Menu/ContextMenu/ContextMenuService'; export * from './Menu/ContextMenu/IContextMenuItem'; export * from './Menu/ContextMenu/IMenuContext'; +export * from './manifest'; diff --git a/webapp/packages/core-dialogs/src/manifest.ts b/webapp/packages/core-dialogs/src/manifest.ts new file mode 100644 index 0000000000..1964e093d9 --- /dev/null +++ b/webapp/packages/core-dialogs/src/manifest.ts @@ -0,0 +1,24 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ + +import type { PluginManifest } from '@cloudbeaver/core-di'; + +import { CommonDialogService } from './CommonDialog/CommonDialogService'; +import { ContextMenuService } from './Menu/ContextMenu/ContextMenuService'; + + +export const codeDialogsManifest: PluginManifest = { + info: { + name: 'Core Dialogs', + }, + + providers: [ + CommonDialogService, + ContextMenuService, + ], +}; diff --git a/webapp/packages/core-events/src/index.ts b/webapp/packages/core-events/src/index.ts index 48129ea517..0fd034080c 100644 --- a/webapp/packages/core-events/src/index.ts +++ b/webapp/packages/core-events/src/index.ts @@ -5,3 +5,4 @@ export * from './INotification'; export * from './DbeaverError'; export * from './ExceptionsCatcherService'; export * from './EventsSettingsService'; +export { manifest as coreEventsManifest } from './manifest'; diff --git a/webapp/packages/core-events/src/manifest.ts b/webapp/packages/core-events/src/manifest.ts new file mode 100644 index 0000000000..6e3a2774b5 --- /dev/null +++ b/webapp/packages/core-events/src/manifest.ts @@ -0,0 +1,27 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2022 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ + +import type { PluginManifest } from '@cloudbeaver/core-di'; + +import { EventsSettingsService } from './EventsSettingsService'; +import { ExceptionsCatcherService } from './ExceptionsCatcherService'; +import { NotificationService } from './NotificationService'; + + + +export const manifest: PluginManifest = { + info: { + name: 'Core Events', + }, + + providers: [ + NotificationService, + ExceptionsCatcherService, + EventsSettingsService, + ], +}; diff --git a/webapp/packages/core-plugin/src/PluginManagerService.ts b/webapp/packages/core-plugin/src/PluginManagerService.ts index 4e35206e5a..4568ca2de9 100644 --- a/webapp/packages/core-plugin/src/PluginManagerService.ts +++ b/webapp/packages/core-plugin/src/PluginManagerService.ts @@ -13,7 +13,7 @@ import { PluginSettings } from './PluginSettings'; @injectable() export class PluginManagerService { - constructor(private productManagerService: ProductManagerService) { } + constructor(private readonly productManagerService: ProductManagerService) { } getPluginSettings(scope: string, defaults: T) { return new PluginSettings(this.productManagerService.settings, scope, defaults); diff --git a/webapp/packages/core-plugin/src/PluginSettings.ts b/webapp/packages/core-plugin/src/PluginSettings.ts index 828f483cbe..9afb7e8853 100644 --- a/webapp/packages/core-plugin/src/PluginSettings.ts +++ b/webapp/packages/core-plugin/src/PluginSettings.ts @@ -10,9 +10,9 @@ import type { ISettingsSource } from '@cloudbeaver/core-settings'; export class PluginSettings implements ISettingsSource { constructor( - private source: ISettingsSource, - private scope: string, - private defaults: T + private readonly source: ISettingsSource, + private readonly scope: string, + private readonly defaults: T ) { } diff --git a/webapp/packages/core-product/src/ProductManagerService.ts b/webapp/packages/core-product/src/ProductManagerService.ts index fa86f50736..5eae43d31c 100644 --- a/webapp/packages/core-product/src/ProductManagerService.ts +++ b/webapp/packages/core-product/src/ProductManagerService.ts @@ -16,7 +16,7 @@ import { ProductSettingsService } from './ProductSettingsService'; export class ProductManagerService { readonly settings: ProductSettingsService; - constructor(private readonly serverService: ServerService) { + constructor(private readonly serverService: ServerService) { this.settings = new ProductSettingsService(this.serverService.settings); } diff --git a/webapp/packages/core-root/src/index.ts b/webapp/packages/core-root/src/index.ts index 81c0de1467..bfdd15bfb8 100644 --- a/webapp/packages/core-root/src/index.ts +++ b/webapp/packages/core-root/src/index.ts @@ -15,5 +15,4 @@ export * from './SessionSettingsService'; export * from './SessionExpireService'; export * from './usePermission'; export * from './WindowEventsService'; -export * from './CookiesService'; export { manifest as coreRootManifest } from './manifest'; diff --git a/webapp/packages/core-root/src/manifest.ts b/webapp/packages/core-root/src/manifest.ts index 44e44f4efa..1f9483efb1 100644 --- a/webapp/packages/core-root/src/manifest.ts +++ b/webapp/packages/core-root/src/manifest.ts @@ -8,8 +8,6 @@ import type { PluginManifest } from '@cloudbeaver/core-di'; -import { CookiesService } from './CookiesService'; -import { CookiesSettingsService } from './CookiesSettingsService'; import { FeaturesResource } from './FeaturesResource'; import { NetworkStateService } from './NetworkStateService'; import { PermissionsService } from './PermissionsService'; @@ -46,7 +44,5 @@ export const manifest: PluginManifest = { SessionService, SessionSettingsService, WindowEventsService, - CookiesSettingsService, - CookiesService, ], }; diff --git a/webapp/packages/core-view/src/Action/Actions/ACTION_EXPORT.ts b/webapp/packages/core-view/src/Action/Actions/ACTION_EXPORT.ts index d8c7aea991..f1dc483be8 100644 --- a/webapp/packages/core-view/src/Action/Actions/ACTION_EXPORT.ts +++ b/webapp/packages/core-view/src/Action/Actions/ACTION_EXPORT.ts @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. */ -import { createAction } from '@cloudbeaver/core-view'; +import { createAction } from '../createAction'; export const ACTION_EXPORT = createAction( 'export', diff --git a/webapp/packages/plugin-authentication/src/index.ts b/webapp/packages/plugin-authentication/src/index.ts index 7af0d5bcc7..cd9fe02cc8 100644 --- a/webapp/packages/plugin-authentication/src/index.ts +++ b/webapp/packages/plugin-authentication/src/index.ts @@ -1,6 +1,4 @@ import { manifest } from './manifest'; - -export default manifest; - export * from './AuthenticationService'; export * from './Dialog/AuthDialogService'; +export default manifest; diff --git a/webapp/packages/plugin-authentication/src/manifest.ts b/webapp/packages/plugin-authentication/src/manifest.ts index 6edf573a42..1f1bd14759 100644 --- a/webapp/packages/plugin-authentication/src/manifest.ts +++ b/webapp/packages/plugin-authentication/src/manifest.ts @@ -15,7 +15,7 @@ import { PluginBootstrap } from './PluginBootstrap'; export const manifest: PluginManifest = { info: { - name: 'Authentication', + name: 'Plugin Authentication', }, providers: [ diff --git a/webapp/packages/plugin-connections/src/ConnectionAuthService.ts b/webapp/packages/plugin-connections/src/ConnectionAuthService.ts index 8339b3717a..0ea05454dc 100644 --- a/webapp/packages/plugin-connections/src/ConnectionAuthService.ts +++ b/webapp/packages/plugin-connections/src/ConnectionAuthService.ts @@ -8,23 +8,33 @@ import { AuthProviderService } from '@cloudbeaver/core-authentication'; import { Connection, ConnectionInfoResource, ConnectionsManagerService } from '@cloudbeaver/core-connections'; -import { injectable } from '@cloudbeaver/core-di'; +import { Dependency, injectable } from '@cloudbeaver/core-di'; import { CommonDialogService } from '@cloudbeaver/core-dialogs'; import { NotificationService } from '@cloudbeaver/core-events'; import type { IExecutionContextProvider } from '@cloudbeaver/core-executor'; +import type { AuthenticationService } from '@cloudbeaver/plugin-authentication'; import { DatabaseAuthDialog } from './DatabaseAuthDialog/DatabaseAuthDialog'; @injectable() -export class ConnectionAuthService { +export class ConnectionAuthService extends Dependency { constructor( private readonly connectionInfoResource: ConnectionInfoResource, private readonly commonDialogService: CommonDialogService, private readonly authProviderService: AuthProviderService, private readonly connectionsManagerService: ConnectionsManagerService, private readonly notificationService: NotificationService, + private readonly authenticationService: AuthenticationService, ) { + super(); + connectionsManagerService.connectionExecutor.addHandler(this.connectionDialog.bind(this)); + this.authenticationService.onLogout.before(connectionsManagerService.onDisconnect, state => ({ + connections: connectionInfoResource.values + .filter(connection => connection.connected) + .map(connection => connection.id), + state, + })); } private async connectionDialog(connectionId: string | null, context: IExecutionContextProvider) {