diff --git a/packages/presentation/src/file.ts b/packages/presentation/src/file.ts index 4eb95050de..2e3b615c53 100644 --- a/packages/presentation/src/file.ts +++ b/packages/presentation/src/file.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import { concatLink, type WorkspaceDataId, type Blob as PlatformBlob, type Ref } from '@hcengineering/core' +import { concatLink, type Blob as PlatformBlob, type Ref, type WorkspaceUuid } from '@hcengineering/core' import { PlatformError, Severity, Status, getMetadata } from '@hcengineering/platform' import { v4 as uuid } from 'uuid' @@ -99,9 +99,9 @@ function getFilesUrl (): string { return filesUrl.includes('://') ? filesUrl : concatLink(frontUrl, filesUrl) } -export function getCurrentWorkspaceUuid (): WorkspaceDataId { +export function getCurrentWorkspaceUuid (): WorkspaceUuid { const workspaceUuid = getMetadata(plugin.metadata.WorkspaceUuid) ?? '' - return workspaceUuid as WorkspaceDataId + return workspaceUuid as WorkspaceUuid } /** diff --git a/packages/presentation/src/utils.ts b/packages/presentation/src/utils.ts index 64308238b6..19b531f670 100644 --- a/packages/presentation/src/utils.ts +++ b/packages/presentation/src/utils.ts @@ -47,7 +47,7 @@ import core, { type TxResult, type TypeAny, type WithLookup, - type WorkspaceDataId + type WorkspaceUuid } from '@hcengineering/core' import { getMetadata, getResource } from '@hcengineering/platform' import { LiveQuery as LQ } from '@hcengineering/query' @@ -763,7 +763,7 @@ export function isSpaceClass (_class: Ref>): boolean { return client.getHierarchy().isDerived(_class, core.class.Space) } -export function setPresentationCookie (token: string, workspaceUuid: WorkspaceDataId): void { +export function setPresentationCookie (token: string, workspaceUuid: WorkspaceUuid): void { function setToken (path: string): void { const res = encodeURIComponent(plugin.metadata.Token.replaceAll(':', '-')) + diff --git a/plugins/guest-resources/src/connect.ts b/plugins/guest-resources/src/connect.ts index a93555b990..2d6178c3a6 100644 --- a/plugins/guest-resources/src/connect.ts +++ b/plugins/guest-resources/src/connect.ts @@ -9,7 +9,6 @@ import core, { type Client, type Version, type Ref, - type WorkspaceDataId, type PersonId } from '@hcengineering/core' import { setCurrentEmployee, type Employee } from '@hcengineering/contact' @@ -65,10 +64,7 @@ export async function connect (title: string): Promise { return } - setPresentationCookie( - token, - workspaceLoginInfo.workspaceDataId ?? (workspaceLoginInfo.workspace as unknown as WorkspaceDataId) - ) + setPresentationCookie(token, workspaceLoginInfo.workspace) setMetadata(presentation.metadata.Token, token) setMetadata(presentation.metadata.WorkspaceUuid, workspaceLoginInfo.workspace) @@ -253,7 +249,7 @@ function clearMetadata (ws: string): void { delete tokens[loc.path[1]] setMetadataLocalStorage(login.metadata.LoginTokens, tokens) } - const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) as unknown as WorkspaceDataId + const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) if (currentWorkspace !== undefined) { setPresentationCookie('', currentWorkspace) } diff --git a/plugins/workbench-resources/src/connect.ts b/plugins/workbench-resources/src/connect.ts index 4093ae8dde..2d019951d2 100644 --- a/plugins/workbench-resources/src/connect.ts +++ b/plugins/workbench-resources/src/connect.ts @@ -13,7 +13,6 @@ import core, { type MeasureMetricsContext, type Version, pickPrimarySocialId, - type WorkspaceDataId, type Person as GlobalPerson } from '@hcengineering/core' import { setCurrentEmployee, ensureEmployee } from '@hcengineering/contact' @@ -148,10 +147,7 @@ export async function connect (title: string): Promise { } } - setPresentationCookie( - token, - workspaceLoginInfo.workspaceDataId ?? (workspaceLoginInfo.workspace as unknown as WorkspaceDataId) - ) + setPresentationCookie(token, workspaceLoginInfo.workspace) setMetadataLocalStorage(login.metadata.LoginEndpoint, workspaceLoginInfo?.endpoint) const endpoint = getMetadata(login.metadata.TransactorOverride) ?? workspaceLoginInfo?.endpoint @@ -445,7 +441,7 @@ export function clearMetadata (ws: string): void { delete tokens[loc.path[1]] setMetadataLocalStorage(login.metadata.LoginTokens, tokens) } - const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) as unknown as WorkspaceDataId + const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) if (currentWorkspace !== undefined) { setPresentationCookie('', currentWorkspace) } diff --git a/server/front/src/index.ts b/server/front/src/index.ts index f6838b16a1..426a290f56 100644 --- a/server/front/src/index.ts +++ b/server/front/src/index.ts @@ -15,14 +15,7 @@ // import { Analytics } from '@hcengineering/analytics' -import { - MeasureContext, - Blob as PlatformBlob, - WorkspaceDataId, - WorkspaceIds, - metricsAggregate, - type Ref -} from '@hcengineering/core' +import { MeasureContext, Blob as PlatformBlob, WorkspaceIds, metricsAggregate, type Ref } from '@hcengineering/core' import { TokenError, decodeToken } from '@hcengineering/server-token' import { StorageAdapter } from '@hcengineering/storage' import bp from 'body-parser' @@ -429,16 +422,16 @@ export function start ( dataId: workspaceInfo.dataId, url: workspaceInfo.url } - const actualDataId = workspaceInfo.dataId ?? (workspaceInfo.uuid as unknown as WorkspaceDataId) if (path === undefined) { return wsIds } - const expectedDataId = path.split('/')[2] - if (expectedDataId !== undefined && actualDataId !== expectedDataId) { - ctx.error('Cannot validate dataId', { - expectedDataId, - actualDataId, + const actualUuid = workspaceInfo.uuid + const expectedUuid = path.split('/')[2] + if (expectedUuid !== undefined && actualUuid !== expectedUuid) { + ctx.error('Cannot validate uuid', { + expectedUuid, + actualUuid, path, workspaceUuid: workspaceInfo.uuid, workspaceDataId: workspaceInfo.dataId