( workspaceId: string )
| 17 | export type WorkspaceScope = 'active' | 'archived' | 'all' |
| 18 | |
| 19 | export async function getWorkspaceBillingSettings( |
| 20 | workspaceId: string |
| 21 | ): Promise<WorkspaceBillingSettings | null> { |
| 22 | if (!workspaceId) { |
| 23 | return null |
| 24 | } |
| 25 | |
| 26 | const rows = await db |
| 27 | .select({ |
| 28 | billedAccountUserId: workspaceTable.billedAccountUserId, |
| 29 | allowPersonalApiKeys: workspaceTable.allowPersonalApiKeys, |
| 30 | }) |
| 31 | .from(workspaceTable) |
| 32 | .where(and(eq(workspaceTable.id, workspaceId), isNull(workspaceTable.archivedAt))) |
| 33 | .limit(1) |
| 34 | |
| 35 | if (!rows.length) { |
| 36 | return null |
| 37 | } |
| 38 | |
| 39 | return { |
| 40 | billedAccountUserId: rows[0].billedAccountUserId ?? null, |
| 41 | allowPersonalApiKeys: rows[0].allowPersonalApiKeys ?? false, |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | export async function getWorkspaceBilledAccountUserId(workspaceId: string): Promise<string | null> { |
| 46 | const settings = await getWorkspaceBillingSettings(workspaceId) |
no test coverage detected