(params: {
organizationId: string
userId: string
logger: Logger
})
| 249 | * This maintains the existing response format for the backend API. |
| 250 | */ |
| 251 | export async function getOrganizationUsageResponse(params: { |
| 252 | organizationId: string |
| 253 | userId: string |
| 254 | logger: Logger |
| 255 | }): Promise<{ |
| 256 | type: 'usage-response' |
| 257 | usage: number |
| 258 | remainingBalance: number |
| 259 | balanceBreakdown: Record<string, never> |
| 260 | next_quota_reset: null |
| 261 | }> { |
| 262 | const { organizationId, userId, logger } = params |
| 263 | |
| 264 | try { |
| 265 | const data = await getOrganizationUsageData(params) |
| 266 | |
| 267 | return { |
| 268 | type: 'usage-response' as const, |
| 269 | usage: data.usageThisCycle, |
| 270 | remainingBalance: data.currentBalance, |
| 271 | balanceBreakdown: {}, |
| 272 | next_quota_reset: null, |
| 273 | } |
| 274 | } catch (error) { |
| 275 | logger.error( |
| 276 | { organizationId, userId, error }, |
| 277 | 'Error generating organization usage response', |
| 278 | ) |
| 279 | throw error |
| 280 | } |
| 281 | } |
no test coverage detected