From 3307cd74cc2dbfca1feb6f4f50e8beceefb2d8b0 Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Thu, 6 Feb 2025 16:36:54 +0700 Subject: [PATCH 1/2] fix: wrong workspace id passed to collaborator client (#7950) Signed-off-by: Alexander Onnikov --- packages/api-client/src/client.ts | 17 +++++++++++------ packages/api-client/src/types.ts | 3 +++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/api-client/src/client.ts b/packages/api-client/src/client.ts index 5ad7fe45b9..61d8483b1d 100644 --- a/packages/api-client/src/client.ts +++ b/packages/api-client/src/client.ts @@ -57,20 +57,21 @@ import { type PlatformClient, type ConnectOptions, WithMarkup } from './types' export async function connect (url: string, options: ConnectOptions): Promise { const config = await loadServerConfig(url) - const { endpoint, token } = await getWorkspaceToken(url, options, config) - return await createClient(url, endpoint, token, config, options) + const { endpoint, token, workspaceId } = await getWorkspaceToken(url, options, config) + return await createClient(url, endpoint, workspaceId, token, config, options) } async function createClient ( url: string, endpoint: string, + workspaceId: string, token: string, config: ServerConfig, options: ConnectOptions ): Promise { addLocation(clientId, () => import(/* webpackChunkName: "client" */ '@hcengineering/client-resources')) - const { workspace, socketFactory, connectionTimeout } = options + const { socketFactory, connectionTimeout } = options const clientFactory = await getResource(client.function.GetClient) const connection = await clientFactory(token, endpoint, { @@ -79,7 +80,7 @@ async function createClient ( }) const account = await connection.getAccount() - return new PlatformClientImpl(url, workspace, token, config, connection, account) + return new PlatformClientImpl(url, workspaceId, token, config, connection, account) } class PlatformClientImpl implements PlatformClient { @@ -100,6 +101,10 @@ class PlatformClientImpl implements PlatformClient { // Client + getAccount (): Account { + return { ...this.account } + } + getHierarchy (): Hierarchy { return this.client.getHierarchy() } @@ -277,7 +282,7 @@ async function getWorkspaceToken ( url: string, options: ConnectOptions, config?: ServerConfig -): Promise<{ endpoint: string, token: string }> { +): Promise<{ endpoint: string, token: string, workspaceId: string }> { config ??= await loadServerConfig(url) let token: string @@ -298,5 +303,5 @@ async function getWorkspaceToken ( throw new Error('Workspace not found') } - return { endpoint: ws.endpoint, token: ws.token } + return { endpoint: ws.endpoint, token: ws.token, workspaceId: ws.workspaceId } } diff --git a/packages/api-client/src/types.ts b/packages/api-client/src/types.ts index 4a7cd0a66a..27241eada1 100644 --- a/packages/api-client/src/types.ts +++ b/packages/api-client/src/types.ts @@ -16,6 +16,7 @@ import { type ClientSocketFactory } from '@hcengineering/client' import { CollaborativeDoc, + type Account, type AttachedData, type AttachedDoc, type Class, @@ -53,6 +54,8 @@ MarkupContent * @public * */ export type PlatformClient = { + getAccount: () => Account + getHierarchy: () => Hierarchy getModel: () => ModelDb From 5d2b04eb5119ab9d09fed22912348a700ed343ad Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 6 Feb 2025 16:42:14 +0700 Subject: [PATCH 2/2] Remove 0.7 tagTime versioning Signed-off-by: Andrey Sobolev --- .github/workflows/main.yml | 1 - common/scripts/show_version.js | 39 +++++++++++----------------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 48798e1de1..aeb567b8af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,7 +41,6 @@ env: .prettierrc tools PublishTempFolder: publish_artifacts - MODEL_VERSION_MODE: ${{ startsWith(github.ref, 'refs/tags/s') && 'tagTime' || 'file' }} INIT_SCRIPTS_BRANCH: 'unified-init-scripts' # A workflow run is made up of one or more jobs that can run sequentially or in parallel diff --git a/common/scripts/show_version.js b/common/scripts/show_version.js index 0ac52f770d..7a49a74d5f 100644 --- a/common/scripts/show_version.js +++ b/common/scripts/show_version.js @@ -17,38 +17,23 @@ const fs = require('fs') const path = require('path') const exec = require('child_process').exec -function main (mode) { +function main() { exec('git describe --tags --abbrev=0', (err, stdout) => { if (err !== null) { - console.log('"0.7.0"') + console.log('"0.6.0"') return } - - const tag = stdout.trim() - - if (mode === 'tagTime') { - // Take tagged git commit date as model version - exec(`git for-each-ref --shell --format="%(creatordate:format:%s)" "refs/tags/${tag}"`, (err, stdout) => { - console.log(`"0.7.${err === null ? stdout.trim().slice(1, -1) : 0}"`) - }) - } else { - // Take version from file - let version - try { - const versionFilePath = path.resolve(__dirname, 'version.txt') - version = fs.readFileSync(versionFilePath, 'utf8').trim() - } catch (error) { - version = '"0.6.0"' - } - - console.log(version) + // Take version from file + let version + try { + const versionFilePath = path.resolve(__dirname, 'version.txt') + version = fs.readFileSync(versionFilePath, 'utf8').trim() + } catch (error) { + version = '"0.6.0"' } + + console.log(version) }) } -let mode = process.env.MODEL_VERSION_MODE -if (mode !== 'tagTime') { - mode = 'file' -} - -main(mode) +main()