(userId: string)
| 31 | } |
| 32 | |
| 33 | export async function getDefaultWorkspaceId(userId: string): Promise<string> { |
| 34 | const accessibleRows = await listAccessibleWorkspaceRowsForUser(userId) |
| 35 | const mostRecent = accessibleRows |
| 36 | .map((row) => row.workspace) |
| 37 | .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())[0] |
| 38 | |
| 39 | if (!mostRecent) { |
| 40 | throw new Error('No workspace found for user') |
| 41 | } |
| 42 | |
| 43 | return mostRecent.id |
| 44 | } |
| 45 | |
| 46 | export async function ensureWorkspaceAccess( |
| 47 | workspaceId: string, |
no test coverage detected