MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getOrganizationUsageResponse

Function getOrganizationUsageResponse

packages/billing/src/usage-service.ts:251–281  ·  view source on GitHub ↗
(params: {
  organizationId: string
  userId: string
  logger: Logger
})

Source from the content-addressed store, hash-verified

249 * This maintains the existing response format for the backend API.
250 */
251export 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}

Callers 1

postUsageFunction · 0.85

Calls 1

getOrganizationUsageDataFunction · 0.85

Tested by

no test coverage detected