import type { IdentityDatabase } from '../../identity/drizzle/db'; export interface AccountUsageRecord { accountId: string; storageBytes: number; ingressBytes: number; egressBytes: number; storageLimitBytes?: number | null; bandwidthLimitBps?: number | null; computeSeconds: number; tokensUsed: number; computeLimitSeconds?: number | null; tokenLimitMonthly?: number | null; periodStart?: number | null; } export interface PodUsageRecord extends AccountUsageRecord { podId: string; } export interface ApiKeyUsageRecord { keyId: string; accountId: string; totalTokens: number; lastUsedAt: Date | null; } /** * Tracks account and pod usage in one table. Account/pod are scopes of the same * metric record, not separate data models. */ export declare class UsageRepository { private readonly db; private readonly schema; constructor(db: IdentityDatabase); incrementUsage(accountId: string, podId: string, storageDelta: number, ingressDelta: number, egressDelta: number): Promise; incrementBandwidth(accountId: string, podId: string, ingressDelta: number, egressDelta: number): Promise; setPodStorage(accountId: string, podId: string, storageBytes: number): Promise; setAccountStorage(accountId: string, storageBytes: number): Promise; getAccountUsage(accountId: string): Promise; getPodUsage(podId: string): Promise; setAccountStorageLimit(accountId: string, limit: number | null): Promise; setPodStorageLimit(podId: string, accountId: string, limit: number | null): Promise; setAccountBandwidthLimit(accountId: string, limit: number | null): Promise; setPodBandwidthLimit(podId: string, accountId: string, limit: number | null): Promise; setAccountComputeLimit(accountId: string, limit: number | null): Promise; setAccountTokenLimit(accountId: string, limit: number | null): Promise; setPodComputeLimit(podId: string, accountId: string, limit: number | null): Promise; setPodTokenLimit(podId: string, accountId: string, limit: number | null): Promise; incrementTokenUsage(accountId: string, podId: string, tokensDelta: number): Promise; incrementApiKeyTokenUsage(accountId: string, podId: string, keyId: string, tokensDelta: number): Promise; listApiKeyUsagesByAccount(accountId: string): Promise; incrementComputeUsage(accountId: string, podId: string, secondsDelta: number): Promise; private getPodUsageWith; private getUsageRow; private incrementTokensWith; private incrementComputeWith; private incrementUsageWith; private upsertUsage; private toAccountUsage; private toPodUsage; private toUsageMetrics; private normalizeDelta; private normalizeValue; private coerceNumber; private coerceNullable; private coerceTimestamp; private coerceDate; private now; }