Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

723 B
Raw Blame
import type { CanvasSpace } from './canvasTasksApi'

export type CanvasVisibility = 'private' | 'public' | 'shared'

type SpaceShape = Pick<CanvasSpace, 'system_role' | 'channel_type'>

export function canvasVisibility(space: SpaceShape): CanvasVisibility {
    if (space.system_role === 'personal' || space.channel_type === 'personal') {
        return 'private'
    }
    return space.channel_type === 'private' ? 'shared' : 'public'
}

export function visibilitySpace<T extends Pick<CanvasSpace, 'system_role'>>(
    spaces: T[],
    visibility: 'private' | 'public'
): T | null {
    const role = visibility === 'private' ? 'personal' : 'general'
    return spaces.find((space) => space.system_role === role) ?? null
}