/** * Billing and Usage Tracker * Tracks usage, calculates costs, and generates invoices */ import { EventEmitter } from 'events'; import { BillingPeriod, InvoiceStatus, UsageRecord, UsageSummary, Invoice, BillingAccount, UsageQuota, BillingAlert, PaymentTransaction, PaymentMethod, CostEstimate, BillingReport, StripeConfig } from './types'; export interface BillingTrackerConfig { defaultCurrency?: string; defaultBillingPeriod?: BillingPeriod; taxRate?: number; stripeConfig?: StripeConfig; autoGenerateInvoices?: boolean; invoicePrefix?: string; alertThresholds?: { usage?: number[]; cost?: number[]; }; } export declare class BillingTracker extends EventEmitter { private config; private usageRecords; private accounts; private invoices; private quotas; private alerts; private transactions; private invoiceCounter; constructor(config?: BillingTrackerConfig); /** * Create a billing account */ createAccount(account: Omit): BillingAccount; /** * Update billing account */ updateAccount(userId: string, updates: Partial): BillingAccount | null; /** * Record usage */ recordUsage(record: Omit): UsageRecord; /** * Calculate cost based on pricing config */ private calculateCost; /** * Calculate tiered pricing cost */ private calculateTieredCost; /** * Find volume tier for quantity */ private findVolumeTier; /** * Get usage summary */ getUsageSummary(userId: string, start: Date, end: Date): UsageSummary; /** * Generate invoice */ generateInvoice(userId: string, periodStart: Date, periodEnd: Date, options?: { dueDate?: Date; notes?: string; metadata?: Record; }): Invoice; /** * Pay invoice */ payInvoice(invoiceId: string, paymentMethod: PaymentMethod, transactionId?: string): PaymentTransaction; /** * Set usage quota */ setQuota(quota: Omit): UsageQuota; /** * Check quotas */ private checkQuotas; /** * Check cost alerts */ private checkCostAlerts; /** * Create alert */ private createAlert; /** * Get period start date */ private getPeriodStart; /** * Estimate cost */ estimateCost(userId: string, tokens: number, requests?: number): CostEstimate; /** * Generate report */ generateReport(userId: string, reportType: 'usage' | 'cost' | 'invoice' | 'forecast', start: Date, end: Date): BillingReport; /** * List invoices */ listInvoices(userId: string, status?: InvoiceStatus): Invoice[]; /** * Get alerts */ getAlerts(userId: string, acknowledged?: boolean): BillingAlert[]; /** * Acknowledge alert */ acknowledgeAlert(alertId: string): boolean; /** * Clean up old records */ cleanup(userId: string, olderThan: Date): void; /** * Get health status */ getHealth(): { healthy: boolean; accounts: number; totalUsageRecords: number; totalInvoices: number; }; } //# sourceMappingURL=tracker.d.ts.map