mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-19 17:01:57 +03:00
UBERF-8887: Allow override region settings (#7450)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
f467388b64
commit
de77b1a559
@ -17,7 +17,7 @@ const Dotenv = require('dotenv-webpack')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const CompressionPlugin = require('compression-webpack-plugin')
|
const CompressionPlugin = require('compression-webpack-plugin')
|
||||||
const DefinePlugin = require('webpack').DefinePlugin
|
const DefinePlugin = require('webpack').DefinePlugin
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
const { Configuration } = require('webpack')
|
const { Configuration } = require('webpack')
|
||||||
|
|
||||||
const mode = process.env.NODE_ENV || 'development'
|
const mode = process.env.NODE_ENV || 'development'
|
||||||
@ -26,17 +26,17 @@ const devServer = (process.env.CLIENT_TYPE ?? '') === 'dev-server'
|
|||||||
const devProduction = (process.env.CLIENT_TYPE ?? '') === 'dev-production'
|
const devProduction = (process.env.CLIENT_TYPE ?? '') === 'dev-production'
|
||||||
const devProductionHuly = (process.env.CLIENT_TYPE ?? '') === 'dev-huly'
|
const devProductionHuly = (process.env.CLIENT_TYPE ?? '') === 'dev-huly'
|
||||||
const devProductionBold = (process.env.CLIENT_TYPE ?? '') === 'dev-bold'
|
const devProductionBold = (process.env.CLIENT_TYPE ?? '') === 'dev-bold'
|
||||||
const dev = (process.env.CLIENT_TYPE ?? '') === 'dev' || devServer || devProduction || devProductionHuly || devProductionBold
|
const dev =
|
||||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
(process.env.CLIENT_TYPE ?? '') === 'dev' || devServer || devProduction || devProductionHuly || devProductionBold
|
||||||
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
|
||||||
|
|
||||||
const { EsbuildPlugin } = require('esbuild-loader')
|
const { EsbuildPlugin } = require('esbuild-loader')
|
||||||
|
|
||||||
const doValidate = !prod || (process.env.DO_VALIDATE === 'true')
|
const doValidate = !prod || process.env.DO_VALIDATE === 'true'
|
||||||
|
|
||||||
const useCache = process.env.USE_CACHE === 'true'
|
const useCache = process.env.USE_CACHE === 'true'
|
||||||
|
|
||||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Configuration}
|
* @type {Configuration}
|
||||||
@ -77,356 +77,366 @@ module.exports = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cache: useCache ? {
|
cache: useCache
|
||||||
type: 'filesystem',
|
? {
|
||||||
allowCollectingMemory: true,
|
type: 'filesystem',
|
||||||
cacheLocation: path.resolve(__dirname, '.build_dev'),
|
allowCollectingMemory: true,
|
||||||
}: undefined,
|
cacheLocation: path.resolve(__dirname, '.build_dev')
|
||||||
entry: {
|
}
|
||||||
bundle: [
|
: undefined,
|
||||||
'@hcengineering/theme/styles/global.scss',
|
entry: {
|
||||||
...(dev ? ['./src/main-dev.ts'] : ['./src/main.ts']),
|
bundle: ['@hcengineering/theme/styles/global.scss', ...(dev ? ['./src/main-dev.ts'] : ['./src/main.ts'])]
|
||||||
]
|
|
||||||
},
|
|
||||||
ignoreWarnings: [
|
|
||||||
{
|
|
||||||
message: /a11y-/,
|
|
||||||
},
|
},
|
||||||
/warning from compiler/,
|
ignoreWarnings: [
|
||||||
(warning) => true,
|
|
||||||
],
|
|
||||||
resolve: {
|
|
||||||
symlinks: true,
|
|
||||||
alias: {
|
|
||||||
svelte: path.resolve('node_modules', 'svelte/src/runtime'),
|
|
||||||
'@hcengineering/platform-rig/profiles/ui/svelte': path.resolve('node_modules', 'svelte/src/runtime')
|
|
||||||
},
|
|
||||||
fallback: {
|
|
||||||
crypto: false
|
|
||||||
},
|
|
||||||
extensions: ['.mjs', '.js', '.svelte', '.ts'],
|
|
||||||
mainFields: ['svelte', 'browser', 'module', 'main'],
|
|
||||||
conditionNames: ['svelte', 'browser', 'import']
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
path: __dirname + '/dist',
|
|
||||||
filename: '[name].[contenthash].js',
|
|
||||||
chunkFilename: '[name].[contenthash].js',
|
|
||||||
publicPath: '/',
|
|
||||||
pathinfo: false
|
|
||||||
},
|
|
||||||
optimization: prod ? {
|
|
||||||
minimize: true,
|
|
||||||
minimizer: [
|
|
||||||
new EsbuildPlugin({ target: 'es2021' })
|
|
||||||
],
|
|
||||||
splitChunks: {
|
|
||||||
chunks: 'all'
|
|
||||||
}
|
|
||||||
} : {
|
|
||||||
minimize: false,
|
|
||||||
mangleExports: false,
|
|
||||||
usedExports: false,
|
|
||||||
splitChunks: {
|
|
||||||
chunks: 'all'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
{
|
||||||
test: /\.ts?$/,
|
message: /a11y-/
|
||||||
loader: 'esbuild-loader',
|
|
||||||
options: {
|
|
||||||
target: 'es2021',
|
|
||||||
keepNames: true,
|
|
||||||
minify: prod,
|
|
||||||
sourcemap: true
|
|
||||||
},
|
|
||||||
exclude: /node_modules/,
|
|
||||||
},
|
},
|
||||||
{
|
/warning from compiler/,
|
||||||
test: /\.svelte$/,
|
(warning) => true
|
||||||
use: [
|
],
|
||||||
{
|
resolve: {
|
||||||
loader: 'svelte-loader',
|
symlinks: true,
|
||||||
|
alias: {
|
||||||
|
svelte: path.resolve('node_modules', 'svelte/src/runtime'),
|
||||||
|
'@hcengineering/platform-rig/profiles/ui/svelte': path.resolve('node_modules', 'svelte/src/runtime')
|
||||||
|
},
|
||||||
|
fallback: {
|
||||||
|
crypto: false
|
||||||
|
},
|
||||||
|
extensions: ['.mjs', '.js', '.svelte', '.ts'],
|
||||||
|
mainFields: ['svelte', 'browser', 'module', 'main'],
|
||||||
|
conditionNames: ['svelte', 'browser', 'import']
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
path: __dirname + '/dist',
|
||||||
|
filename: '[name].[contenthash].js',
|
||||||
|
chunkFilename: '[name].[contenthash].js',
|
||||||
|
publicPath: '/',
|
||||||
|
pathinfo: false
|
||||||
|
},
|
||||||
|
optimization: prod
|
||||||
|
? {
|
||||||
|
minimize: true,
|
||||||
|
minimizer: [new EsbuildPlugin({ target: 'es2021' })],
|
||||||
|
splitChunks: {
|
||||||
|
chunks: 'all'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
minimize: false,
|
||||||
|
mangleExports: false,
|
||||||
|
usedExports: false,
|
||||||
|
splitChunks: {
|
||||||
|
chunks: 'all'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.ts?$/,
|
||||||
|
loader: 'esbuild-loader',
|
||||||
options: {
|
options: {
|
||||||
compilerOptions: {
|
target: 'es2021',
|
||||||
dev: !prod
|
keepNames: true,
|
||||||
},
|
minify: prod,
|
||||||
emitCss: true,
|
sourcemap: true
|
||||||
hotReload: !prod,
|
},
|
||||||
preprocess: require('svelte-preprocess')({
|
exclude: /node_modules/
|
||||||
postcss: true,
|
},
|
||||||
sourceMap: true,
|
{
|
||||||
}),
|
test: /\.svelte$/,
|
||||||
hotOptions: {
|
use: [
|
||||||
// Prevent preserving local component state
|
{
|
||||||
preserveLocalState: true,
|
loader: 'svelte-loader',
|
||||||
|
options: {
|
||||||
|
compilerOptions: {
|
||||||
|
dev: !prod
|
||||||
|
},
|
||||||
|
emitCss: true,
|
||||||
|
hotReload: !prod,
|
||||||
|
preprocess: require('svelte-preprocess')({
|
||||||
|
postcss: true,
|
||||||
|
sourceMap: true
|
||||||
|
}),
|
||||||
|
hotOptions: {
|
||||||
|
// Prevent preserving local component state
|
||||||
|
preserveLocalState: true,
|
||||||
|
|
||||||
// If this string appears anywhere in your component's code, then local
|
// If this string appears anywhere in your component's code, then local
|
||||||
// state won't be preserved, even when noPreserveState is false
|
// state won't be preserved, even when noPreserveState is false
|
||||||
noPreserveStateKey: '@!hmr',
|
noPreserveStateKey: '@!hmr',
|
||||||
|
|
||||||
// Prevent doing a full reload on next HMR update after fatal error
|
// Prevent doing a full reload on next HMR update after fatal error
|
||||||
noReload: true,
|
noReload: true,
|
||||||
|
|
||||||
// Try to recover after runtime errors in component init
|
// Try to recover after runtime errors in component init
|
||||||
optimistic: false,
|
optimistic: false,
|
||||||
|
|
||||||
// --- Advanced ---
|
// --- Advanced ---
|
||||||
|
|
||||||
// Prevent adding an HMR accept handler to components with
|
// Prevent adding an HMR accept handler to components with
|
||||||
// accessors option to true, or to components with named exports
|
// accessors option to true, or to components with named exports
|
||||||
// (from <script context="module">). This have the effect of
|
// (from <script context="module">). This have the effect of
|
||||||
// recreating the consumer of those components, instead of the
|
// recreating the consumer of those components, instead of the
|
||||||
// component themselves, on HMR updates. This might be needed to
|
// component themselves, on HMR updates. This might be needed to
|
||||||
// reflect changes to accessors / named exports in the parents,
|
// reflect changes to accessors / named exports in the parents,
|
||||||
// depending on how you use them.
|
// depending on how you use them.
|
||||||
acceptAccessors: true,
|
acceptAccessors: true,
|
||||||
acceptNamedExports: true,
|
acceptNamedExports: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: [
|
||||||
|
// prod ? MiniCssExtractPlugin.loader :
|
||||||
|
'style-loader',
|
||||||
|
'css-loader',
|
||||||
|
'postcss-loader'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
test: /\.scss$/,
|
||||||
|
use: [
|
||||||
|
// prod ? MiniCssExtractPlugin.loader :
|
||||||
|
'style-loader',
|
||||||
|
'css-loader',
|
||||||
|
'postcss-loader',
|
||||||
|
'sass-loader'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
test: /\.(ttf|otf|eot|woff|woff2)$/,
|
||||||
|
use: {
|
||||||
|
loader: 'file-loader',
|
||||||
|
options: {
|
||||||
|
name: 'fonts/[hash:base64:8].[ext]',
|
||||||
|
esModule: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]
|
},
|
||||||
},
|
{
|
||||||
{
|
test: /\.(jpg|png|webp|heic|avif)$/,
|
||||||
test: /\.css$/,
|
use: {
|
||||||
use: [
|
|
||||||
// prod ? MiniCssExtractPlugin.loader :
|
|
||||||
'style-loader',
|
|
||||||
'css-loader',
|
|
||||||
'postcss-loader'
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
test: /\.scss$/,
|
|
||||||
use: [
|
|
||||||
// prod ? MiniCssExtractPlugin.loader :
|
|
||||||
'style-loader',
|
|
||||||
'css-loader',
|
|
||||||
'postcss-loader',
|
|
||||||
'sass-loader',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
test: /\.(ttf|otf|eot|woff|woff2)$/,
|
|
||||||
use: {
|
|
||||||
loader: 'file-loader',
|
|
||||||
options: {
|
|
||||||
name: 'fonts/[hash:base64:8].[ext]',
|
|
||||||
esModule: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(jpg|png|webp|heic|avif)$/,
|
|
||||||
use: {
|
|
||||||
loader: 'file-loader',
|
|
||||||
options: {
|
|
||||||
name: 'img/[contenthash].[ext]',
|
|
||||||
esModule: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(wav|ogg)$/,
|
|
||||||
use: {
|
|
||||||
loader: 'file-loader',
|
|
||||||
options: {
|
|
||||||
'name': 'snd/[contenthash].[ext]',
|
|
||||||
esModule: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.svg$/,
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: 'file-loader',
|
loader: 'file-loader',
|
||||||
options: {
|
options: {
|
||||||
name: 'img/[contenthash].[ext]',
|
name: 'img/[contenthash].[ext]',
|
||||||
esModule: false
|
esModule: false
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
},
|
||||||
loader: 'svgo-loader',
|
{
|
||||||
|
test: /\.(wav|ogg)$/,
|
||||||
|
use: {
|
||||||
|
loader: 'file-loader',
|
||||||
options: {
|
options: {
|
||||||
plugins: [
|
name: 'snd/[contenthash].[ext]',
|
||||||
{ name: 'removeHiddenElems', active: false }
|
esModule: false
|
||||||
// { removeHiddenElems: { displayNone: false } },
|
|
||||||
// { cleanupIDs: false },
|
|
||||||
// { removeTitle: true }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
}
|
{
|
||||||
]
|
test: /\.svg$/,
|
||||||
},
|
use: [
|
||||||
mode,
|
{
|
||||||
plugins: [
|
loader: 'file-loader',
|
||||||
new BundleAnalyzerPlugin({
|
options: {
|
||||||
analyzerMode: 'static',
|
name: 'img/[contenthash].[ext]',
|
||||||
openAnalyzer: false,
|
esModule: false
|
||||||
}),
|
}
|
||||||
new HtmlWebpackPlugin({
|
},
|
||||||
meta: {
|
{
|
||||||
viewport: 'width=device-width, initial-scale=1.0'
|
loader: 'svgo-loader',
|
||||||
}
|
options: {
|
||||||
}),
|
plugins: [
|
||||||
...(prod ? [new CompressionPlugin()] : []),
|
{ name: 'removeHiddenElems', active: false }
|
||||||
// new MiniCssExtractPlugin({
|
// { removeHiddenElems: { displayNone: false } },
|
||||||
// filename: '[name].[id][contenthash].css'
|
// { cleanupIDs: false },
|
||||||
// }),
|
// { removeTitle: true }
|
||||||
new Dotenv({ path: prod ? '.env-prod' : '.env' }),
|
]
|
||||||
new DefinePlugin({
|
}
|
||||||
'process.env.CLIENT_TYPE': JSON.stringify(process.env.CLIENT_TYPE)
|
}
|
||||||
}),
|
]
|
||||||
...(doValidate ? [
|
}
|
||||||
new ForkTsCheckerWebpackPlugin()
|
]
|
||||||
] : [])
|
},
|
||||||
],
|
mode,
|
||||||
watchOptions: {
|
plugins: [
|
||||||
// for some systems, watching many files can result in a lot of CPU or memory usage
|
...(prod
|
||||||
// https://webpack.js.org/configuration/watch/#watchoptionsignored
|
? [
|
||||||
// don't use this pattern, if you have a monorepo with linked packages
|
new BundleAnalyzerPlugin({
|
||||||
ignored: [
|
analyzerMode: 'static',
|
||||||
"**/node_modules",
|
openAnalyzer: false
|
||||||
"**/.git",
|
})
|
||||||
"**/common/temp",
|
]
|
||||||
"**/.rush",
|
: []),
|
||||||
"**/.rush/**",
|
new HtmlWebpackPlugin({
|
||||||
"**/rush-logs",
|
meta: {
|
||||||
"**/lib/*.js",
|
viewport: 'width=device-width, initial-scale=1.0'
|
||||||
"**/lib/*.js.map",
|
}
|
||||||
"**/types/*.d.ts",
|
}),
|
||||||
"**/.git/objects/**",
|
...(prod ? [new CompressionPlugin()] : []),
|
||||||
"**/node_modules/**",
|
// new MiniCssExtractPlugin({
|
||||||
"**/desktop/deploy/**",
|
// filename: '[name].[id][contenthash].css'
|
||||||
"**/dist/**",
|
// }),
|
||||||
"**/.validate/**",
|
new Dotenv({ path: prod ? '.env-prod' : '.env' }),
|
||||||
"**/.format/**",
|
new DefinePlugin({
|
||||||
"**/.build_dev/**"
|
'process.env.CLIENT_TYPE': JSON.stringify(process.env.CLIENT_TYPE)
|
||||||
|
}),
|
||||||
|
...(doValidate ? [new ForkTsCheckerWebpackPlugin()] : [])
|
||||||
],
|
],
|
||||||
aggregateTimeout: 100,
|
watchOptions: {
|
||||||
followSymlinks: false,
|
// for some systems, watching many files can result in a lot of CPU or memory usage
|
||||||
poll: 250
|
// https://webpack.js.org/configuration/watch/#watchoptionsignored
|
||||||
},
|
// don't use this pattern, if you have a monorepo with linked packages
|
||||||
devtool: prod ? 'source-map' : 'eval-source-map', // 'inline-source-map',
|
ignored: [
|
||||||
devServer: {
|
'**/node_modules',
|
||||||
static: {
|
'**/.git',
|
||||||
directory: path.resolve(__dirname, "public"),
|
'**/common/temp',
|
||||||
publicPath: "/",
|
'**/.rush',
|
||||||
serveIndex: true,
|
'**/.rush/**',
|
||||||
watch: true,
|
'**/rush-logs',
|
||||||
|
'**/lib/*.js',
|
||||||
|
'**/lib/*.js.map',
|
||||||
|
'**/types/*.d.ts',
|
||||||
|
'**/.git/objects/**',
|
||||||
|
'**/node_modules/**',
|
||||||
|
'**/desktop/deploy/**',
|
||||||
|
'**/dist/**',
|
||||||
|
'**/.validate/**',
|
||||||
|
'**/.format/**',
|
||||||
|
'**/.build_dev/**'
|
||||||
|
],
|
||||||
|
aggregateTimeout: 100,
|
||||||
|
followSymlinks: false,
|
||||||
|
poll: 250
|
||||||
},
|
},
|
||||||
historyApiFallback: {
|
devtool: prod ? 'source-map' : 'eval-source-map', // 'inline-source-map',
|
||||||
disableDotRule: true
|
devServer: {
|
||||||
},
|
static: {
|
||||||
host: '0.0.0.0',
|
directory: path.resolve(__dirname, 'public'),
|
||||||
allowedHosts: 'all',
|
publicPath: '/',
|
||||||
hot: true,
|
serveIndex: true,
|
||||||
client: {
|
watch: true
|
||||||
logging: "info",
|
|
||||||
overlay: true,
|
|
||||||
progress: false,
|
|
||||||
},
|
|
||||||
proxy: (devServer && !devProduction && !devProductionHuly && !devProductionBold) ? {
|
|
||||||
'/account': {
|
|
||||||
target: 'http://localhost:3000',
|
|
||||||
changeOrigin: true,
|
|
||||||
pathRewrite: { '^/account': '' },
|
|
||||||
logLevel: 'debug'
|
|
||||||
},
|
},
|
||||||
'/files': {
|
historyApiFallback: {
|
||||||
target: 'http://localhost:8087',
|
disableDotRule: true
|
||||||
changeOrigin: true,
|
|
||||||
logLevel: 'debug'
|
|
||||||
},
|
},
|
||||||
'/api/v1': {
|
host: '0.0.0.0',
|
||||||
target: 'http://localhost:8087',
|
allowedHosts: 'all',
|
||||||
changeOrigin: true,
|
hot: true,
|
||||||
logLevel: 'debug'
|
client: {
|
||||||
|
logging: 'info',
|
||||||
|
overlay: true,
|
||||||
|
progress: false
|
||||||
},
|
},
|
||||||
'/import': {
|
proxy:
|
||||||
target: 'http://localhost:8087',
|
devServer && !devProduction && !devProductionHuly && !devProductionBold
|
||||||
changeOrigin: true,
|
? {
|
||||||
logLevel: 'debug'
|
'/account': {
|
||||||
},
|
target: 'http://localhost:3000',
|
||||||
'/rekoni/recognize': {
|
changeOrigin: true,
|
||||||
target: 'http://localhost:4004',
|
pathRewrite: { '^/account': '' },
|
||||||
changeOrigin: true,
|
logLevel: 'debug'
|
||||||
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
},
|
||||||
logLevel: 'debug'
|
'/files': {
|
||||||
}
|
target: 'http://localhost:8087',
|
||||||
} : !devProductionHuly && !devProductionBold ? {
|
changeOrigin: true,
|
||||||
'/account': {
|
logLevel: 'debug'
|
||||||
target: 'https://account.hc.engineering/',
|
},
|
||||||
changeOrigin: true,
|
'/api/v1': {
|
||||||
pathRewrite: { '^/account': '' },
|
target: 'http://localhost:8087',
|
||||||
logLevel: 'debug'
|
changeOrigin: true,
|
||||||
},
|
logLevel: 'debug'
|
||||||
'/files': {
|
},
|
||||||
target: 'https://front.hc.engineering/files',
|
'/import': {
|
||||||
changeOrigin: true,
|
target: 'http://localhost:8087',
|
||||||
pathRewrite: { '^/files': '' },
|
changeOrigin: true,
|
||||||
logLevel: 'debug'
|
logLevel: 'debug'
|
||||||
},
|
},
|
||||||
'/rekoni/recognize': {
|
'/rekoni/recognize': {
|
||||||
target: 'https://rekoni.hc.enigneering',
|
target: 'http://localhost:4004',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
||||||
logLevel: 'debug'
|
logLevel: 'debug'
|
||||||
}
|
}
|
||||||
}: !devProductionBold ? {
|
}
|
||||||
'/account': {
|
: !devProductionHuly && !devProductionBold
|
||||||
target: 'https://account.huly.app/',
|
? {
|
||||||
changeOrigin: true,
|
'/account': {
|
||||||
pathRewrite: { '^/account': '' },
|
target: 'https://account.hc.engineering/',
|
||||||
logLevel: 'debug'
|
changeOrigin: true,
|
||||||
},
|
pathRewrite: { '^/account': '' },
|
||||||
'/api/v1': {
|
logLevel: 'debug'
|
||||||
target: 'http://huly.app',
|
},
|
||||||
changeOrigin: true,
|
'/files': {
|
||||||
logLevel: 'debug'
|
target: 'https://front.hc.engineering/files',
|
||||||
},
|
changeOrigin: true,
|
||||||
'/files': {
|
pathRewrite: { '^/files': '' },
|
||||||
target: 'https://huly.app/files',
|
logLevel: 'debug'
|
||||||
changeOrigin: true,
|
},
|
||||||
pathRewrite: { '^/files': '' },
|
'/rekoni/recognize': {
|
||||||
logLevel: 'debug'
|
target: 'https://rekoni.hc.enigneering',
|
||||||
},
|
changeOrigin: true,
|
||||||
'/rekoni/recognize': {
|
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
||||||
target: 'https://rekoni.huly.app',
|
logLevel: 'debug'
|
||||||
changeOrigin: true,
|
}
|
||||||
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
}
|
||||||
logLevel: 'debug'
|
: !devProductionBold
|
||||||
}
|
? {
|
||||||
} : {
|
'/account': {
|
||||||
'/account': {
|
target: 'https://account.huly.app/',
|
||||||
target: 'https://account.bold.ru/',
|
changeOrigin: true,
|
||||||
changeOrigin: true,
|
pathRewrite: { '^/account': '' },
|
||||||
pathRewrite: { '^/account': '' },
|
logLevel: 'debug'
|
||||||
logLevel: 'debug'
|
},
|
||||||
},
|
'/api/v1': {
|
||||||
'/files': {
|
target: 'http://huly.app',
|
||||||
target: 'https://app.bold.ru/files',
|
changeOrigin: true,
|
||||||
changeOrigin: true,
|
logLevel: 'debug'
|
||||||
pathRewrite: { '^/files': '' },
|
},
|
||||||
logLevel: 'debug'
|
'/files': {
|
||||||
},
|
target: 'https://huly.app/files',
|
||||||
'/api/v1': {
|
changeOrigin: true,
|
||||||
target: 'http://app.bold.ru',
|
pathRewrite: { '^/files': '' },
|
||||||
changeOrigin: true,
|
logLevel: 'debug'
|
||||||
logLevel: 'debug'
|
},
|
||||||
},
|
'/rekoni/recognize': {
|
||||||
'/rekoni/recognize': {
|
target: 'https://rekoni.huly.app',
|
||||||
target: 'https://rekoni.bold.ru',
|
changeOrigin: true,
|
||||||
changeOrigin: true,
|
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
||||||
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
logLevel: 'debug'
|
||||||
logLevel: 'debug'
|
}
|
||||||
}
|
}
|
||||||
|
: {
|
||||||
|
'/account': {
|
||||||
|
target: 'https://account.bold.ru/',
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: { '^/account': '' },
|
||||||
|
logLevel: 'debug'
|
||||||
|
},
|
||||||
|
'/files': {
|
||||||
|
target: 'https://app.bold.ru/files',
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: { '^/files': '' },
|
||||||
|
logLevel: 'debug'
|
||||||
|
},
|
||||||
|
'/api/v1': {
|
||||||
|
target: 'http://app.bold.ru',
|
||||||
|
changeOrigin: true,
|
||||||
|
logLevel: 'debug'
|
||||||
|
},
|
||||||
|
'/rekoni/recognize': {
|
||||||
|
target: 'https://rekoni.bold.ru',
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
||||||
|
logLevel: 'debug'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]
|
]
|
||||||
|
@ -426,13 +426,25 @@ export async function selectWorkspace (
|
|||||||
branding: Branding | null,
|
branding: Branding | null,
|
||||||
token: string,
|
token: string,
|
||||||
workspaceUrl: string,
|
workspaceUrl: string,
|
||||||
kind: 'external' | 'internal',
|
kind: 'external' | 'internal' | 'byregion',
|
||||||
allowAdmin: boolean = true
|
allowAdmin: boolean = true,
|
||||||
|
externalRegions: string[] = []
|
||||||
): Promise<WorkspaceLoginInfo> {
|
): Promise<WorkspaceLoginInfo> {
|
||||||
const decodedToken = decodeToken(ctx, token)
|
const decodedToken = decodeToken(ctx, token)
|
||||||
const email = cleanEmail(decodedToken.email)
|
const email = cleanEmail(decodedToken.email)
|
||||||
|
|
||||||
const endpointKind = kind === 'external' ? EndpointKind.External : EndpointKind.Internal
|
const getKind = (region: string | undefined): EndpointKind => {
|
||||||
|
switch (kind) {
|
||||||
|
case 'external':
|
||||||
|
return EndpointKind.External
|
||||||
|
case 'internal':
|
||||||
|
return EndpointKind.Internal
|
||||||
|
case 'byregion':
|
||||||
|
return externalRegions.includes(region ?? '') ? EndpointKind.External : EndpointKind.Internal
|
||||||
|
default:
|
||||||
|
return EndpointKind.External
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (email === guestAccountEmail && decodedToken.extra?.guest === 'true') {
|
if (email === guestAccountEmail && decodedToken.extra?.guest === 'true') {
|
||||||
const workspaceInfo = await getWorkspaceByUrl(db, workspaceUrl)
|
const workspaceInfo = await getWorkspaceByUrl(db, workspaceUrl)
|
||||||
@ -441,9 +453,10 @@ export async function selectWorkspace (
|
|||||||
new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspace: workspaceUrl })
|
new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspace: workspaceUrl })
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Guest mode select workspace
|
// Guest mode select workspace
|
||||||
return {
|
return {
|
||||||
endpoint: getEndpoint(ctx, workspaceInfo, kind === 'external' ? EndpointKind.External : EndpointKind.Internal),
|
endpoint: getEndpoint(ctx, workspaceInfo, getKind(workspaceInfo.region)),
|
||||||
email,
|
email,
|
||||||
token,
|
token,
|
||||||
workspace: workspaceUrl,
|
workspace: workspaceUrl,
|
||||||
@ -475,7 +488,7 @@ export async function selectWorkspace (
|
|||||||
|
|
||||||
if ((accountInfo?.admin === true || email === systemAccountEmail) && allowAdmin) {
|
if ((accountInfo?.admin === true || email === systemAccountEmail) && allowAdmin) {
|
||||||
return {
|
return {
|
||||||
endpoint: getEndpoint(ctx, workspaceInfo, endpointKind),
|
endpoint: getEndpoint(ctx, workspaceInfo, getKind(workspaceInfo.region)),
|
||||||
email,
|
email,
|
||||||
token: generateToken(email, getWorkspaceId(workspaceInfo.workspace), getExtra(accountInfo)),
|
token: generateToken(email, getWorkspaceId(workspaceInfo.workspace), getExtra(accountInfo)),
|
||||||
workspace: workspaceUrl,
|
workspace: workspaceUrl,
|
||||||
@ -509,7 +522,7 @@ export async function selectWorkspace (
|
|||||||
for (const w of workspaces) {
|
for (const w of workspaces) {
|
||||||
if (areDbIdsEqual(w, workspaceInfo._id)) {
|
if (areDbIdsEqual(w, workspaceInfo._id)) {
|
||||||
const result = {
|
const result = {
|
||||||
endpoint: getEndpoint(ctx, workspaceInfo, endpointKind),
|
endpoint: getEndpoint(ctx, workspaceInfo, getKind(workspaceInfo.region)),
|
||||||
email,
|
email,
|
||||||
token: generateToken(email, getWorkspaceId(workspaceInfo.workspace), getExtra(accountInfo)),
|
token: generateToken(email, getWorkspaceId(workspaceInfo.workspace), getExtra(accountInfo)),
|
||||||
workspace: workspaceUrl,
|
workspace: workspaceUrl,
|
||||||
|
@ -76,9 +76,20 @@ export async function updateBackupInfo (token: string, info: BackupStatus): Prom
|
|||||||
return (workspaces.result as BaseWorkspaceInfo[]) ?? []
|
return (workspaces.result as BaseWorkspaceInfo[]) ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const externalRegions = process.env.EXTERNAL_REGIONS?.split(';') ?? []
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the transactor endpoint for a given token and kind.
|
||||||
|
*
|
||||||
|
* @param token - The authorization token.
|
||||||
|
* @param kind - The type of endpoint to retrieve. Can be 'internal', 'external', or 'byregion'. Defaults to 'byregion'.
|
||||||
|
* @param timeout - The timeout duration in milliseconds. Defaults to -1 (no timeout).
|
||||||
|
* @returns A promise that resolves to the transactor endpoint URL as a string.
|
||||||
|
* @throws Will throw an error if the request fails or if the timeout is reached.
|
||||||
|
*/
|
||||||
export async function getTransactorEndpoint (
|
export async function getTransactorEndpoint (
|
||||||
token: string,
|
token: string,
|
||||||
kind: 'internal' | 'external' = 'internal',
|
kind: 'internal' | 'external' | 'byregion' = 'byregion',
|
||||||
timeout: number = -1
|
timeout: number = -1
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const accountsUrl = getAccoutsUrlOrFail()
|
const accountsUrl = getAccoutsUrlOrFail()
|
||||||
@ -94,7 +105,7 @@ export async function getTransactorEndpoint (
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
method: 'selectWorkspace',
|
method: 'selectWorkspace',
|
||||||
params: ['', kind]
|
params: ['', kind, true, externalRegions]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
).json()
|
).json()
|
||||||
|
Loading…
Reference in New Issue
Block a user