From ca73f4e8f1c54753229fba154b5daf7f10f44445 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Wed, 12 Feb 2025 09:15:34 +0700 Subject: [PATCH 1/5] UBERF-9457: Region move fixes + tests (#7986) Signed-off-by: Andrey Sobolev --- .github/workflows/main.yml | 141 ++++++---- .gitignore | 2 +- .vscode/launch.json | 65 +++++ common/config/rush/command-line.json | 12 +- common/config/rush/pnpm-lock.yaml | 29 ++ common/scripts/each-diff.sh | 4 +- common/scripts/fast-format.sh | 12 + desktop/package.json | 2 +- desktop/src/main/backup.ts | 2 - dev/prod/package.json | 1 + dev/prod/public/config-test.json | 22 ++ dev/prod/src/platform.ts | 1 + dev/prod/webpack.config.js | 34 ++- dev/tool/src/index.ts | 10 - packages/platform/src/platform.ts | 1 + plugins/client-resources/src/connection.ts | 3 + plugins/client/src/index.ts | 1 + .../src/components/AdminWorkspaces.svelte | 54 ++-- plugins/workbench-assets/lang/cs.json | 3 +- plugins/workbench-assets/lang/de.json | 3 +- plugins/workbench-assets/lang/en.json | 3 +- plugins/workbench-assets/lang/es.json | 3 +- plugins/workbench-assets/lang/fr.json | 3 +- plugins/workbench-assets/lang/it.json | 3 +- plugins/workbench-assets/lang/pt.json | 3 +- plugins/workbench-assets/lang/ru.json | 3 +- plugins/workbench-assets/lang/zh.json | 3 +- .../components/ServerManagerGeneral.svelte | 4 +- plugins/workbench-resources/src/connect.ts | 11 + plugins/workbench/src/index.ts | 3 +- rush.json | 5 + server/account/src/operations.ts | 25 +- server/backup-service/src/index.ts | 4 - server/backup/src/backup.ts | 51 +--- server/backup/src/service.ts | 8 - server/core/src/types.ts | 16 +- server/server/src/sessionManager.ts | 30 +- server/tool/src/index.ts | 10 +- server/workspace-service/src/service.ts | 27 +- server/ws/src/server_http.ts | 17 +- tests/sanity/tests/API/Api.ts | 12 +- tests/sanity/tests/index.ts | 2 + tests/sanity/tests/model/login-page.ts | 5 + ws-tests/.env | 5 + ws-tests/branding-test.json | 33 +++ ws-tests/build-reload.sh | 9 + ws-tests/create-local.sh | 4 + ws-tests/docker-compose.yaml | 264 ++++++++++++++++++ ws-tests/prepare.sh | 29 ++ ws-tests/profile-download.sh | 5 + ws-tests/profile-generate.sh | 8 + ws-tests/profile-start.sh | 3 + ws-tests/sanity/.env | 11 + ws-tests/sanity/.eslintrc.js | 7 + ws-tests/sanity/.gitignore | 5 + ws-tests/sanity/config/rig.json | 5 + ws-tests/sanity/package.json | 57 ++++ ws-tests/sanity/tests/auth/auth.setup.ts | 42 +++ ws-tests/sanity/tests/index.ts | 0 ws-tests/sanity/tests/model/admin.page.ts | 15 + ws-tests/sanity/tests/playwright.config.ts | 56 ++++ .../sanity/tests/workspace/archive.spec.ts | 101 +++++++ .../sanity/tests/workspace/create.spec.ts | 227 +++++++++++++++ .../sanity/tests/workspace/migrate.spec.ts | 91 ++++++ ws-tests/sanity/tsconfig.json | 10 + ws-tests/tool.sh | 16 ++ ws-tests/wait-elastic.sh | 17 ++ 67 files changed, 1459 insertions(+), 214 deletions(-) create mode 100755 common/scripts/fast-format.sh create mode 100644 dev/prod/public/config-test.json create mode 100644 ws-tests/.env create mode 100644 ws-tests/branding-test.json create mode 100755 ws-tests/build-reload.sh create mode 100755 ws-tests/create-local.sh create mode 100644 ws-tests/docker-compose.yaml create mode 100755 ws-tests/prepare.sh create mode 100755 ws-tests/profile-download.sh create mode 100755 ws-tests/profile-generate.sh create mode 100755 ws-tests/profile-start.sh create mode 100644 ws-tests/sanity/.env create mode 100644 ws-tests/sanity/.eslintrc.js create mode 100644 ws-tests/sanity/.gitignore create mode 100644 ws-tests/sanity/config/rig.json create mode 100644 ws-tests/sanity/package.json create mode 100644 ws-tests/sanity/tests/auth/auth.setup.ts create mode 100644 ws-tests/sanity/tests/index.ts create mode 100644 ws-tests/sanity/tests/model/admin.page.ts create mode 100644 ws-tests/sanity/tests/playwright.config.ts create mode 100644 ws-tests/sanity/tests/workspace/archive.spec.ts create mode 100644 ws-tests/sanity/tests/workspace/create.spec.ts create mode 100644 ws-tests/sanity/tests/workspace/migrate.spec.ts create mode 100644 ws-tests/sanity/tsconfig.json create mode 100755 ws-tests/tool.sh create mode 100755 ws-tests/wait-elastic.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aeb567b8af..3cdf9e6f26 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,6 +40,8 @@ env: rush.json .prettierrc tools + workers + ws-tests PublishTempFolder: publish_artifacts INIT_SCRIPTS_BRANCH: 'unified-init-scripts' @@ -81,13 +83,13 @@ jobs: run: node common/scripts/install-run-rush.js model-version - name: Building... - run: node common/scripts/install-run-rush.js build -p 20 + run: node common/scripts/install-run-rush.js build - name: Bundle... - run: node common/scripts/install-run-rush.js bundle -p 20 + run: node common/scripts/install-run-rush.js bundle - name: Validate... - run: node common/scripts/install-run-rush.js validate -p 20 + run: node common/scripts/install-run-rush.js validate - name: Cache build results uses: actions/cache@v4 @@ -154,7 +156,7 @@ jobs: [ -z "$(git diff --name-only '*.js' '*.ts' '*.svelte' '*.json' '*.yaml' | cat)" ] echo '================================================================' - name: Formatting... - run: node common/scripts/install-run-rush.js fast-format + run: node common/scripts/install-run-rush.js fast-format --branch ${{ github.base_ref }} - name: Check files formatting run: | echo '================================================================' @@ -223,7 +225,7 @@ jobs: run: node common/scripts/install-run-rush.js install - name: Docker Build - run: node common/scripts/install-run-rush.js docker:build -p 20 + run: node common/scripts/install-run-rush.js docker env: DOCKER_CLI_HINTS: false - name: Prepare server @@ -260,10 +262,8 @@ jobs: run: | cd ./tests/sanity mkdir logs - docker logs $(docker ps | grep transactor | cut -f 1 -d ' ') > logs/transactor.log - docker logs $(docker ps | grep account | cut -f 1 -d ' ') > logs/account.log - docker logs $(docker ps | grep front | cut -f 1 -d ' ') > logs/front.log - docker logs $(docker ps | grep collaborator | cut -f 1 -d ' ') > logs/collaborator.log + cd logs + docker ps -a --format '{{.Names}}' | xargs -I {} sh -c 'docker logs {} > {}_logs.log 2>&1' - name: Upload test results if: always() uses: actions/upload-artifact@v4 @@ -340,7 +340,7 @@ jobs: run: node common/scripts/install-run-rush.js install - name: Docker Build - run: node common/scripts/install-run-rush.js docker:build -p 20 + run: node common/scripts/install-run-rush.js docker env: DOCKER_CLI_HINTS: false - name: Prepare server @@ -361,9 +361,8 @@ jobs: run: | cd ./tests/sanity mkdir logs - docker logs $(docker ps | grep transactor | cut -f 1 -d ' ') > logs/transactor.log - docker logs $(docker ps | grep account | cut -f 1 -d ' ') > logs/account.log - docker logs $(docker ps | grep front | cut -f 1 -d ' ') > logs/front.log + cd logs + docker ps -a --format '{{.Names}}' | xargs -I {} sh -c 'docker logs {} > {}_logs.log 2>&1' - name: Upload test results if: always() uses: actions/upload-artifact@v4 @@ -405,12 +404,12 @@ jobs: run: node common/scripts/install-run-rush.js install - name: Docker Build - run: node common/scripts/install-run-rush.js docker:build -p 20 + run: node common/scripts/install-run-rush.js docker env: DOCKER_CLI_HINTS: false - name: Configure /etc/hosts run: | - sudo echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts + sudo echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts - name: Prepare server run: | cd ./qms-tests @@ -429,50 +428,90 @@ jobs: run: | cd ./qms-tests/sanity mkdir logs - docker logs $(docker ps | grep transactor | cut -f 1 -d ' ') > logs/transactor.log - docker logs $(docker ps | grep account | cut -f 1 -d ' ') > logs/account.log - docker logs $(docker ps | grep front | cut -f 1 -d ' ') > logs/front.log + cd logs + docker ps -a --format '{{.Names}}' | xargs -I {} sh -c 'docker logs {} > {}_logs.log 2>&1' - name: Upload test results if: always() uses: actions/upload-artifact@v4 with: name: playwright-results-qms path: ./qms-tests/sanity/playwright-report/ - # - name: Get Allure history - # uses: actions/checkout@v4 - # if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} - # continue-on-error: true - # with: - # ref: gh-pages - # path: gh-pages - # - name: Generates Allure Report - # uses: simple-elf/allure-report-action@master - # if: always() - # id: allure-report - # with: - # allure_results: ./qms-tests/sanity/allure-results/ - # gh_pages: gh-pages - # allure_report: allure-report - # allure_history: allure-history - # - name: Upload allure test results - # if: always() - # uses: actions/upload-artifact@v4 - # with: - # name: allure-report-qms - # path: ./allure-report/ - # - name: Deploy report to Github Pages - # if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} - # uses: peaceiris/actions-gh-pages@v4 - # with: - # PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # PUBLISH_BRANCH: gh-pages - # PUBLISH_DIR: allure-history - name: Upload Logs if: always() uses: actions/upload-artifact@v4 with: name: docker-logs-qms path: ./qms-tests/sanity/logs + uitest-workspaces: + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + filter: tree:0 + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-platform + with: + path: | + common/temp + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} + + - name: Checking for mis-matching dependencies... + run: node common/scripts/install-run-rush.js check + + - name: Installing... + run: node common/scripts/install-run-rush.js install + + - name: Build sanity-tests suite + run: node common/scripts/install-run-rush.js build -t @hcengineering/tests-sanity + + - name: Docker Build + run: node common/scripts/install-run-rush.js docker + env: + DOCKER_CLI_HINTS: false + - name: Configure /etc/hosts + run: | + sudo echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts + - name: Prepare server + run: | + cd ./ws-tests + export DO_CLEAN=true + ./prepare.sh + - name: Install Playwright + run: | + cd ./ws-tests/sanity + node ../../common/scripts/install-run-rushx.js ci + - name: Run UI tests + run: | + cd ./ws-tests/sanity + node ../../common/scripts/install-run-rushx.js uitest + - name: 'Store docker logs' + if: always() + run: | + cd ./ws-tests/sanity + mkdir logs + cd logs + docker ps -a --format '{{.Names}}' | xargs -I {} sh -c 'docker logs {} > {}_logs.log 2>&1' + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: playwright-results-ws + path: ./ws-tests/sanity/playwright-report/ + - name: Upload Logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: docker-logs-ws + path: ./ws-tests/sanity/logs docker-build: needs: [build, test, svelte-check, uitest] runs-on: ubuntu-latest @@ -531,9 +570,9 @@ jobs: DOCKER_EXTRA: --platform=linux/amd64,linux/arm64 - name: Docker build love-agent run: | - cd ./services/ai-bot/love-agent - pnpm install && pnpm build - pnpm docker:build -v + cd ./services/ai-bot/love-agent + pnpm install && pnpm build + pnpm docker:build -v env: DOCKER_CLI_HINTS: false DOCKER_EXTRA: --platform=linux/amd64,linux/arm64 @@ -590,7 +629,7 @@ jobs: - name: Model version from git tags run: node common/scripts/install-run-rush.js model-version - name: Package - run: node common/scripts/install-run-rush.js package --to desktop -p 20 -v + run: node common/scripts/install-run-rush.js package --to desktop -v - name: Package JSON run: | cd desktop-package diff --git a/.gitignore b/.gitignore index 7709393636..739d78c64a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ temp/ npm-debug.log* yarn-debug.log* yarn-error.log* -tests/sanity/screenshots +*tests/sanity/screenshots # Runtime data *.pid diff --git a/.vscode/launch.json b/.vscode/launch.json index 5a64285111..77330c4067 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -70,6 +70,38 @@ "cwd": "${workspaceRoot}/pods/server", "protocol": "inspector" }, + { + "name": "Debug server(Test)", + "type": "node", + "request": "launch", + "args": ["src/__start.ts"], + "env": { + "FULLTEXT_URL": "http://localhost:4710", + // "DB_URL": "mongodb://localhost:27018", + // "DB_URL": "postgresql://postgres:example@localhost:5432", + "DB_URL": "postgresql://root@host.docker.internal:26258/defaultdb?sslmode=disable", + // "GREEN_URL": "http://host.docker.internal:6767?token=secret", + "SERVER_PORT": "3335", + "METRICS_CONSOLE": "false", + "METRICS_FILE": "${workspaceRoot}/metrics.txt", // Show metrics in console evert 30 seconds., + "STORAGE_CONFIG": "minio|localhost?accessKey=minioadmin&secretKey=minioadmin", + "SERVER_SECRET": "secret", + "ENABLE_CONSOLE": "true", + "COLLABORATOR_URL": "ws://localhost:3079", + "FRONT_URL": "http://localhost:8083", + "ACCOUNTS_URL": "http://localhost:3003", + "MODEL_JSON": "${workspaceRoot}/models/all/bundle/model.json", + "MODEL_VERSION": "0.6.435", + "STATS_URL": "http://host.docker.internal:4901" + }, + "runtimeArgs": ["--nolazy", "-r", "ts-node/register"], + "runtimeVersion": "20", + "showAsyncStacks": true, + "outputCapture": "std", + "sourceMaps": true, + "cwd": "${workspaceRoot}/pods/server", + "protocol": "inspector" + }, { "name": "Debug Fulltext", "type": "node", @@ -131,6 +163,39 @@ "cwd": "${workspaceRoot}/pods/account", "protocol": "inspector" }, + { + "name": "Debug Account(Staging)", + "type": "node", + "request": "launch", + "args": ["src/__start.ts"], + "env": { + "MONGO_URL": "mongodb://localhost:27018", + "DB_URL": "mongodb://localhost:27018", + // "DB_URL": "postgresql://postgres:example@localhost:5432", + "SERVER_SECRET": "secret", + "REGION_INFO":"|Mongo;pg|Postgres;cockroach|CockroachDB", + "TRANSACTOR_URL": "ws://host.docker.internal:3334;;,ws://host.docker.internal:3335;;europe", + "ACCOUNTS_URL": "http://localhost:3003", + "ACCOUNT_PORT": "3003", + "FRONT_URL": "http://localhost:8083", + "STATS_URL": "http://host.docker.internal:4901", + "SES_URL": "", + // "DB_NS": "account-2", + // "WS_LIVENESS_DAYS": "1", + "MINIO_ACCESS_KEY": "minioadmin", + "MINIO_SECRET_KEY": "minioadmin", + "MINIO_ENDPOINT": "localhost" + // "DISABLE_SIGNUP": "true", + // "INIT_SCRIPT_URL": "https://raw.githubusercontent.com/hcengineering/init/main/script.yaml", + // "INIT_WORKSPACE": "onboarding", + }, + "runtimeVersion": "20", + "runtimeArgs": ["--nolazy", "-r", "ts-node/register"], + "sourceMaps": true, + "outputCapture": "std", + "cwd": "${workspaceRoot}/pods/account", + "protocol": "inspector" + }, { "name": "Debug Stats", "type": "node", diff --git a/common/config/rush/command-line.json b/common/config/rush/command-line.json index 5175b19edd..adc962fdf2 100644 --- a/common/config/rush/command-line.json +++ b/common/config/rush/command-line.json @@ -318,7 +318,7 @@ "summary": "Format changed projects", "description": "Format and autofix linting issues in changed projects", "safeForSimultaneousRushProcesses": true, - "shellCommand": "./common/scripts/each-diff.sh rushx format --force" + "shellCommand": "./common/scripts/fast-format.sh" }, { "commandKind": "global", @@ -354,6 +354,16 @@ "shortName": "-f", "description": "Force formatting", "associatedCommands": ["format"] + }, + { + "parameterKind": "string", + "argumentName": "BRANCH", + "required": false, + "associatedPhases": [], + "shortName": "-b", + "longName": "--branch", + "description": "Force formatting of branch", + "associatedCommands": ["fast-format"] } // { // /** diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 6228a6687f..3392b6edb9 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1084,6 +1084,9 @@ importers: '@rush-temp/tests-sanity': specifier: file:./projects/tests-sanity.tgz version: file:projects/tests-sanity.tgz + '@rush-temp/tests-ws-sanity': + specifier: file:./projects/tests-ws-sanity.tgz + version: file:projects/tests-ws-sanity.tgz '@rush-temp/text': specifier: file:./projects/text.tgz version: file:projects/text.tgz(@babel/core@7.23.9)(@jest/types@29.6.3)(@types/node@20.11.19)(babel-jest@29.7.0(@babel/core@7.23.9))(bufferutil@4.0.8)(esbuild@0.24.2)(prosemirror-inputrules@1.4.0)(prosemirror-model@1.24.1)(prosemirror-state@1.4.3)(prosemirror-view@1.37.2)(ts-node@10.9.2(@types/node@20.11.19)(typescript@5.3.3))(utf-8-validate@6.0.4) @@ -5156,6 +5159,10 @@ packages: resolution: {integrity: sha512-noV3nlBP0OvM6i4C5YUevkhltHxG/2bct4pusP3O3AEQ7Za+A4qwzpsE08pHfA9f9pedEG677GE4EmG9x61rVQ==, tarball: file:projects/tests-sanity.tgz} version: 0.0.0 + '@rush-temp/tests-ws-sanity@file:projects/tests-ws-sanity.tgz': + resolution: {integrity: sha512-2y+gKxse3ozzKeoi1TF7Qfv7Y1fWy9Z6HiqSsEeQgGPpv396cH7ZfpSJ/qwsxO66c6iq8LUuBtzZ4AlquHfG3w==, tarball: file:projects/tests-ws-sanity.tgz} + version: 0.0.0 + '@rush-temp/text-core@file:projects/text-core.tgz': resolution: {integrity: sha512-sQ1C/LTDJ6RoC7YHYOCrRGsOHerkeumxp9lRjRaTmjc65mAFtiizz4eYFlkbSVSQvahSdD5KMT1G+wvtmLq7Gg==, tarball: file:projects/text-core.tgz} version: 0.0.0 @@ -24844,6 +24851,28 @@ snapshots: transitivePeerDependencies: - supports-color + '@rush-temp/tests-ws-sanity@file:projects/tests-ws-sanity.tgz': + dependencies: + '@faker-js/faker': 8.4.1 + '@playwright/test': 1.49.1 + '@types/jest': 29.5.12 + '@types/node': 20.11.19 + '@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.56.0)(typescript@5.3.3))(eslint@8.56.0)(typescript@5.7.3) + '@typescript-eslint/parser': 6.21.0(eslint@8.56.0)(typescript@5.7.3) + allure-js-commons: 3.0.7(allure-playwright@3.0.7(@playwright/test@1.49.1)) + allure-playwright: 3.0.7(@playwright/test@1.49.1) + cross-env: 7.0.3 + dotenv: 16.0.3 + eslint: 8.56.0 + eslint-config-standard-with-typescript: 40.0.0(@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.56.0)(typescript@5.3.3))(eslint@8.56.0)(typescript@5.3.3))(eslint-plugin-import@2.29.1(eslint@8.56.0))(eslint-plugin-n@15.7.0(eslint@8.56.0))(eslint-plugin-promise@6.1.1(eslint@8.56.0))(eslint@8.56.0)(typescript@5.7.3) + eslint-plugin-import: 2.29.1(eslint@8.56.0) + eslint-plugin-n: 15.7.0(eslint@8.56.0) + eslint-plugin-promise: 6.1.1(eslint@8.56.0) + prettier: 3.2.5 + typescript: 5.7.3 + transitivePeerDependencies: + - supports-color + '@rush-temp/text-core@file:projects/text-core.tgz(@babel/core@7.23.9)(@jest/types@29.6.3)(@types/node@20.11.19)(babel-jest@29.7.0(@babel/core@7.23.9))(bufferutil@4.0.8)(esbuild@0.24.2)(ts-node@10.9.2(@types/node@20.11.19)(typescript@5.3.3))(utf-8-validate@6.0.4)': dependencies: '@types/jest': 29.5.12 diff --git a/common/scripts/each-diff.sh b/common/scripts/each-diff.sh index 8fc1d9dada..1025117be5 100755 --- a/common/scripts/each-diff.sh +++ b/common/scripts/each-diff.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -FILES=$(git diff origin/develop --name-only --diff-filter=ACMR | sed 's| |\\ |g') +branch=${BASE_BRANCH:-develop} + +FILES=$(git diff origin/$branch --name-only --diff-filter=ACMR | sed 's| |\\ |g') [ -z "$FILES" ] && exit 0 roots=$(rush list -p --json | grep "path" | cut -f 2 -d ':' | cut -f 2 -d '"') diff --git a/common/scripts/fast-format.sh b/common/scripts/fast-format.sh new file mode 100755 index 0000000000..1de57197e0 --- /dev/null +++ b/common/scripts/fast-format.sh @@ -0,0 +1,12 @@ +#!/bin/bash +echo $@ +BASE_BRANCH=${1:-develop} +while [[ "$#" -gt 0 ]]; do + case $1 in + --branch) BASE_BRANCH="$2"; shift ;; + *) ;; + esac + shift +done +export BASE_BRANCH +./common/scripts/each-diff.sh rushx format --force \ No newline at end of file diff --git a/desktop/package.json b/desktop/package.json index 9e1bb126ba..37c083bd9f 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -1,6 +1,6 @@ { "name": "@hcengineering/desktop", - "version": "0.6.271", + "version": "0.6.435", "main": "dist/main/electron.js", "template": "@hcengineering/webpack-package", "scripts": { diff --git a/desktop/src/main/backup.ts b/desktop/src/main/backup.ts index 73bad40eaf..19d3c6343e 100644 --- a/desktop/src/main/backup.ts +++ b/desktop/src/main/backup.ts @@ -42,8 +42,6 @@ async function doBackup (dirName: string, token: string, endpoint: string, works ctx.info('do backup', { workspace, endpoint }) await backup(ctx, endpoint, wsid, storage, { force: true, - freshBackup: false, - clean: false, skipDomains: [], timeout: 0, connectTimeout: 60 * 1000, diff --git a/dev/prod/package.json b/dev/prod/package.json index dc96c0d4d5..36f1d360c1 100644 --- a/dev/prod/package.json +++ b/dev/prod/package.json @@ -10,6 +10,7 @@ "analyze": "rm -rf ./dist && cross-env NODE_ENV=production webpack --profile --json > stats.json", "show": "webpack-bundle-analyzer stats.json dist", "dev-server": "cross-env USE_CACHE=false CLIENT_TYPE=dev-server webpack serve", + "dev-server-test": "cross-env USE_CACHE=false CLIENT_TYPE=dev-server-test webpack serve", "dev-worker": "cross-env USE_CACHE=false CLIENT_TYPE=dev-worker webpack serve", "dev-worker-local": "cross-env USE_CACHE=false CLIENT_TYPE=dev-worker-local webpack serve", "dev-server-cache": "cross-env USE_CACHE=true CLIENT_TYPE=dev-server webpack serve", diff --git a/dev/prod/public/config-test.json b/dev/prod/public/config-test.json new file mode 100644 index 0000000000..d556839c93 --- /dev/null +++ b/dev/prod/public/config-test.json @@ -0,0 +1,22 @@ +{ + "ACCOUNTS_URL": "/account", + "COLLABORATOR_URL": "ws://localhost:3079", + "UPLOAD_URL": "/files", + "TELEGRAM_URL": "http://localhost:8088", + "GMAIL_URL": "http://localhost:8089", + "CALENDAR_URL": "http://localhost:8096", + "REKONI_URL": "/rekoni", + "GITHUB_APP": "uberflow-dev", + "GITHUB_CLIENTID": "Iv1.43f9cac43bd68617", + "GITHUB_URL": "http://localhost:3501", + "LAST_NAME_FIRST": "true", + "PRINT_URL": "http://localhost:4006", + "SIGN_URL": "http://localhost:4006", + "ANALYTICS_COLLECTOR_URL": "http://localhost:4018", + "AI_URL": "http://localhost:4011", + "BRANDING_URL": "/branding.json", + "VERSION": null, + "MODEL_VERSION": null, + "STATS_URL": "http://localhost:4901", + "PASSWORD_STRICTNESS": "none" +} diff --git a/dev/prod/src/platform.ts b/dev/prod/src/platform.ts index 87c5e8906c..c1739b7c04 100644 --- a/dev/prod/src/platform.ts +++ b/dev/prod/src/platform.ts @@ -196,6 +196,7 @@ const configs: Record = { 'dev-huly': '/config-huly.json', 'dev-bold': '/config.json', 'dev-server': '/config.json', + 'dev-server-test': '/config-test.json', 'dev-worker': '/config-worker.json', 'dev-worker-local': '/config-worker-local.json' } diff --git a/dev/prod/webpack.config.js b/dev/prod/webpack.config.js index 46d01ef793..78036c9ee6 100644 --- a/dev/prod/webpack.config.js +++ b/dev/prod/webpack.config.js @@ -24,13 +24,14 @@ const mode = process.env.NODE_ENV || 'development' const prod = mode === 'production' const clientType = process.env.CLIENT_TYPE ?? '' const devServer = clientType === 'dev-server' +const devServerTest = clientType === 'dev-server-test' const devServerWorker = clientType === 'dev-worker' const devServerWorkerLocal = clientType === 'dev-worker-local' const devProduction = clientType === 'dev-production' const devProductionHuly = clientType === 'dev-huly' const devProductionBold = clientType === 'dev-bold' const dev = - (process.env.CLIENT_TYPE ?? '') === 'dev' || devServer || devProduction || devProductionHuly || devProductionBold || devServerWorker || devServerWorkerLocal + (process.env.CLIENT_TYPE ?? '') === 'dev' || devServer || devProduction || devProductionHuly || devProductionBold || devServerWorker || devServerWorkerLocal || devServerTest const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin') const { EsbuildPlugin } = require('esbuild-loader') @@ -71,6 +72,36 @@ const devProxy = { } } +const devProxyTest = { + '/account': { + target: 'http://localhost:3003', + changeOrigin: true, + pathRewrite: { '^/account': '' }, + logLevel: 'debug' + }, + '/files': { + target: 'http://localhost:8083', + changeOrigin: true, + logLevel: 'debug' + }, + '/api/v1': { + target: 'http://localhost:8083', + changeOrigin: true, + logLevel: 'debug' + }, + '/import': { + target: 'http://localhost:8083', + changeOrigin: true, + logLevel: 'debug' + }, + '/rekoni/recognize': { + target: 'http://localhost:4004', + changeOrigin: true, + pathRewrite: { '^/rekoni/recognize': '/recognize' }, + logLevel: 'debug' + } +} + const devHulyProxy = { '/account': { target: 'https://account.huly.app/', @@ -148,6 +179,7 @@ const proxy = { 'dev-worker': devProxy, 'dev-worker-local': devProxy, 'dev-server': devProxy, + 'dev-server-test': devProxyTest, 'dev-production': devFrontProxy, 'dev-bold': devBoldProxy, 'dev-huly': devHulyProxy diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index 64f853a095..95ee1fc85e 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -662,8 +662,6 @@ export function devTool ( }) }, cmd.region, - true, - true, 5000, // 5 gigabytes per blob sharedPipelineContextVars, async (storage, workspaceStorage) => { @@ -734,8 +732,6 @@ export function devTool ( }) }, cmd.region, - false, - false, 100, sharedPipelineContextVars ) @@ -932,8 +928,6 @@ export function devTool ( ) .option('-bl, --blobLimit ', 'A blob size limit in megabytes (default 15mb)', '15') .option('-f, --force', 'Force backup', false) - .option('-f, --fresh', 'Force fresh backup', false) - .option('-c, --clean', 'Force clean of old backup files, only with fresh backup option', false) .option('-t, --timeout ', 'Connect timeout in seconds', '30') .action( async ( @@ -942,8 +936,6 @@ export function devTool ( cmd: { skip: string force: boolean - fresh: boolean - clean: boolean timeout: string include: string blobLimit: string @@ -955,8 +947,6 @@ export function devTool ( const endpoint = await getTransactorEndpoint(generateToken(systemAccountEmail, wsid), 'external') await backup(toolCtx, endpoint, wsid, storage, { force: cmd.force, - freshBackup: cmd.fresh, - clean: cmd.clean, include: cmd.include === '*' ? undefined : new Set(cmd.include.split(';').map((it) => it.trim())), skipDomains: (cmd.skip ?? '').split(';').map((it) => it.trim()), timeout: 0, diff --git a/packages/platform/src/platform.ts b/packages/platform/src/platform.ts index ec85cb5687..5a3af6c907 100644 --- a/packages/platform/src/platform.ts +++ b/packages/platform/src/platform.ts @@ -150,6 +150,7 @@ export default plugin(platformId, { AccountNotConfirmed: '' as StatusCode<{ account: string }>, WorkspaceNotFound: '' as StatusCode<{ workspace: string }>, WorkspaceArchived: '' as StatusCode<{ workspace: string }>, + WorkspaceMigration: '' as StatusCode<{ workspace: string }>, InvalidPassword: '' as StatusCode<{ account: string }>, AccountAlreadyExists: '' as StatusCode<{ account: string }>, AccountAlreadyConfirmed: '' as StatusCode<{ account: string }>, diff --git a/plugins/client-resources/src/connection.ts b/plugins/client-resources/src/connection.ts index 3cf22d75fb..a31db1d2ce 100644 --- a/plugins/client-resources/src/connection.ts +++ b/plugins/client-resources/src/connection.ts @@ -281,6 +281,9 @@ class Connection implements ClientConnection { if (resp.error?.code === platform.status.WorkspaceArchived) { this.opt?.onArchived?.() } + if (resp.error?.code === platform.status.WorkspaceMigration) { + this.opt?.onMigration?.() + } } if (resp.id !== undefined) { diff --git a/plugins/client/src/index.ts b/plugins/client/src/index.ts index 0e6c09e47e..40e5b5cbee 100644 --- a/plugins/client/src/index.ts +++ b/plugins/client/src/index.ts @@ -62,6 +62,7 @@ export interface ClientFactoryOptions { onUpgrade?: () => void onUnauthorized?: () => void onArchived?: () => void + onMigration?: () => void onConnect?: (event: ClientConnectEvent, lastTx: string | undefined, data: any) => Promise ctx?: MeasureContext onDialTimeout?: () => void | Promise diff --git a/plugins/login-resources/src/components/AdminWorkspaces.svelte b/plugins/login-resources/src/components/AdminWorkspaces.svelte index 2452fa282b..2d91fc4764 100644 --- a/plugins/login-resources/src/components/AdminWorkspaces.svelte +++ b/plugins/login-resources/src/components/AdminWorkspaces.svelte @@ -192,13 +192,19 @@ let selectedRegionId: string = '' void getRegionInfo().then((_regionInfo) => { - regionInfo = _regionInfo?.filter((it) => it.name !== '') ?? [] + regionInfo = _regionInfo ?? [] if (selectedRegionId === '' && regionInfo.length > 0) { selectedRegionId = regionInfo[0].region } }) - $: selectedRegionName = regionInfo.find((it) => it.region === selectedRegionId)?.name + $: selectedRegionRef = regionInfo.find((it) => it.region === selectedRegionId) + $: selectedRegionName = + selectedRegionRef !== undefined + ? selectedRegionRef.name.length > 0 + ? selectedRegionRef.name + : selectedRegionRef.region + : '' $: byVersion = groupByArray( workspaces.filter((it) => { @@ -277,8 +283,11 @@ it.region === selectedRegionId)?.name} - items={regionInfo.map((it) => ({ id: it.region === '' ? '#' : it.region, label: getEmbeddedLabel(it.name) }))} + title={selectedRegionName} + items={regionInfo.map((it) => ({ + id: it.region === '' ? '#' : it.region, + label: getEmbeddedLabel(it.name.length > 0 ? it.name : it.region + ' (hidden)') + }))} on:selected={(it) => { selectedRegionId = it.detail === '#' ? '' : it.detail }} @@ -290,12 +299,13 @@ {#each Object.keys(dayRanges) as k} {@const v = groupped.get(k) ?? []} {@const hasMore = (groupped.get(k) ?? []).length > limit} - {@const activeV = v.filter((it) => it.mode === 'active' && (it.region ?? '') !== selectedRegionId)} - {@const archivedV = v.filter((it) => it.mode === 'archived')} - {@const deletedV = v.filter((it) => it.mode === 'deleted')} - {@const av = v.length - archivedV.length - deletedV.length} + {@const activeV = v.filter((it) => isActiveMode(it.mode) && it.region !== selectedRegionId)} + {@const activeAll = v.filter((it) => isActiveMode(it.mode))} + {@const archivedV = v.filter((it) => isArchivingMode(it.mode))} + {@const deletedV = v.filter((it) => isDeletingMode(it.mode))} + {@const maintenance = v.length - activeAll.length - archivedV.length - deletedV.length} {#if v.length > 0} - + 0}> {k} - @@ -304,8 +314,8 @@ {:else} {v.length} {/if} - {#if av > 0} - - maitenance: {av} + {#if maintenance > 0} + - maitenance: {maintenance} {/if} @@ -323,18 +333,18 @@ {/if} - {#if archivedV.length > 0} + {#if activeAll.length > 0}