(
workspaceId: string,
options?: { includeArchived?: boolean }
)
| 80 | * @returns The workspace with owner info if found, null otherwise |
| 81 | */ |
| 82 | export async function getWorkspaceWithOwner( |
| 83 | workspaceId: string, |
| 84 | options?: { includeArchived?: boolean } |
| 85 | ): Promise<WorkspaceWithOwner | null> { |
| 86 | const { includeArchived = false } = options ?? {} |
| 87 | const [ws] = await db |
| 88 | .select({ |
| 89 | id: workspace.id, |
| 90 | name: workspace.name, |
| 91 | ownerId: workspace.ownerId, |
| 92 | organizationId: workspace.organizationId, |
| 93 | workspaceMode: workspace.workspaceMode, |
| 94 | billedAccountUserId: workspace.billedAccountUserId, |
| 95 | archivedAt: workspace.archivedAt, |
| 96 | }) |
| 97 | .from(workspace) |
| 98 | .where( |
| 99 | includeArchived |
| 100 | ? eq(workspace.id, workspaceId) |
| 101 | : and(eq(workspace.id, workspaceId), isNull(workspace.archivedAt)) |
| 102 | ) |
| 103 | .limit(1) |
| 104 | |
| 105 | return ws || null |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Resolve the effective workspace permission for a user under the governance |
no test coverage detected