Line data Source code
1 : import {
2 : isWorkspaceId,
3 : withWorkspaceLink
4 : } from '@comfyorg/account-core/workspaceLink'
5 :
6 : import { getComfyPlatformBaseUrl } from '@/config/comfyApi'
7 : import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
8 :
9 : /** A platform URL for `path` that opens in the cloud app's active workspace, when there is one, and carries `correlationId` when given. */
10 4 : export function platformLink(
11 : path: `/${string}`,
12 : correlationId?: string
13 : ): string {
14 4 : const url = new URL(`${getComfyPlatformBaseUrl()}${path}`)
15 4 : if (correlationId) url.searchParams.set('correlation_id', correlationId)
16 4 : const workspaceId = useTeamWorkspaceStore().activeWorkspaceId
17 4 : if (!workspaceId || !isWorkspaceId(workspaceId)) return url.href
18 4 : return withWorkspaceLink(url, workspaceId).href
19 : }
|