/** * Budget enforcement utilities for ACP checkout flows * Uses bigint for all currency calculations to avoid floating-point errors */ export interface BudgetConfig { /** Maximum cost per single checkout in minor currency units (e.g., paise for INR) */ maxPerCallMinor?: bigint; /** Maximum total cost per day in minor currency units */ maxDailyMinor?: bigint; /** Maximum total cost per month in minor currency units */ maxMonthlyMinor?: bigint; /** Currency code (must match at runtime, e.g., 'USD', 'INR') */ currency: string; } export interface BudgetResult { /** Whether the cost is allowed within budget limits */ allowed: boolean; /** * Remaining budget in minor units (after this operation). * - When allowed: the minimum remaining across all applicable limits * - When denied: 0n (never negative) * - When unbounded: undefined (check `unbounded` flag instead) */ remainingMinor?: bigint; /** * True when no budget limits are configured. * In this case, remainingMinor is undefined. */ unbounded?: boolean; /** Error code if not allowed */ code?: 'budget_exceeded' | 'currency_mismatch'; /** Human-readable reason if not allowed */ reason?: string; } /** * Check if a cost is within budget. * Pure, deterministic function - caller tracks time windows externally. * * @param spentMinor - Amount already spent in minor units (e.g., paise for INR) * @param costMinor - Cost of current operation in minor units * @param currency - Currency code (must match config.currency) * @param config - Budget configuration * @returns Result indicating whether cost is allowed and remaining budget * * @example * ```typescript * const config: BudgetConfig = { * maxPerCallMinor: 50000n, // 500.00 INR max per checkout * maxDailyMinor: 1000000n, // 10000.00 INR max per day * currency: 'INR' * }; * * const result = checkBudget( * 850000n, // Already spent 8500.00 INR today * 100000n, // Current checkout costs 1000.00 INR * 'INR', * config * ); * * if (result.allowed) { * console.log(`Allowed. Remaining: ${result.remainingMinor} paise`); * } else { * console.log(`Denied: ${result.reason}`); * } * ``` */ export declare function checkBudget(spentMinor: bigint, costMinor: bigint, currency: string, config: BudgetConfig): BudgetResult; //# sourceMappingURL=budget.d.ts.map