(orgId: number)
| 162 | * the offline license key, if available. |
| 163 | */ |
| 164 | export const orgHasAvailability = async (orgId: number): Promise<boolean> => { |
| 165 | const org = await __unsafePrisma.org.findUniqueOrThrow({ |
| 166 | where: { |
| 167 | id: orgId, |
| 168 | }, |
| 169 | include: { |
| 170 | members: true, |
| 171 | } |
| 172 | }); |
| 173 | |
| 174 | const seatCap = getSeatCap(); |
| 175 | const memberCount = org.members.length; |
| 176 | |
| 177 | if ( |
| 178 | seatCap && |
| 179 | memberCount >= seatCap |
| 180 | ) { |
| 181 | logger.error(`orgHasAvailability: org ${org.id} has reached max capacity`); |
| 182 | return false; |
| 183 | } |
| 184 | |
| 185 | return true; |
| 186 | } |
| 187 | |
| 188 | export const addUserToOrganization = async (userId: string, orgId: number): Promise<{ success: boolean } | ServiceError> => { |
| 189 | const user = await __unsafePrisma.user.findUnique({ |
no test coverage detected