(workspaceId: string)
| 71 | } |
| 72 | |
| 73 | export async function checkCredit(workspaceId: string) { |
| 74 | const res = await prisma.workspace.findFirst({ |
| 75 | where: { |
| 76 | id: workspaceId, |
| 77 | }, |
| 78 | select: { |
| 79 | credit: true, |
| 80 | }, |
| 81 | }); |
| 82 | |
| 83 | const credit = res?.credit ?? 0; |
| 84 | if (credit <= 0) { |
| 85 | const workspaceTier = await getWorkspaceTier(workspaceId); |
| 86 | if (workspaceTier === 'UNLIMITED') { |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | throw new Error('Workspace not have enough credit'); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | export async function costCredit( |
| 95 | workspaceId: string, |
no test coverage detected