import { c as PortableReservation } from '../types-DgQtamEe.js'; export { A as AIProviderType, B as BuiltinTier, g as CreditCheckResult, a as CreditOperationType, C as CreditSource, J as JournalReferenceType, M as MonthlyResetResult, f as PortableJournalEntry, P as PortableTransaction, d as PortableUsageLog, b as PortableUserCredits, R as ReservationStatus, h as ResourceType, e as SubscriptionExpiryResult, S as SubscriptionTier, T as TierConfig, i as TransactionType, U as UsageHistoryEntry, j as UsageHistoryResponse, W as WithCreditsOptions, k as calculateAvailableCredits, t as toDate, l as toPortableTimestamp } from '../types-DgQtamEe.js'; export { D as DeferredExecutor, c as createDeferredExecutor, g as genericDeferred, n as noopDeferred, s as synchronousDeferred } from '../deferred-C7rrRfkm.js'; import { I as ICreditRepository } from '../types-fW2JNmmr.js'; /** * Credit system error classes - framework agnostic * * Provides typed error handling for credit operations. * These errors can be used across different environments. */ /** * Error codes for credit operations */ declare const CreditErrorCode: { readonly INSUFFICIENT_CREDITS: "INSUFFICIENT_CREDITS"; readonly RESERVATION_NOT_FOUND: "RESERVATION_NOT_FOUND"; readonly RESERVATION_EXPIRED: "RESERVATION_EXPIRED"; readonly RESERVATION_ALREADY_PROCESSED: "RESERVATION_ALREADY_PROCESSED"; readonly USER_NOT_FOUND: "USER_NOT_FOUND"; readonly INVALID_OPERATION_TYPE: "INVALID_OPERATION_TYPE"; readonly CONFIGURATION_ERROR: "CONFIGURATION_ERROR"; readonly DATABASE_ERROR: "DATABASE_ERROR"; }; type CreditErrorCodeType = (typeof CreditErrorCode)[keyof typeof CreditErrorCode]; /** * Custom error class for credit operations * * Provides structured error information including: * - Error code for programmatic handling * - Human-readable message * - Optional details for debugging */ declare class CreditError extends Error { readonly code: CreditErrorCodeType; readonly details?: Record; constructor(message: string, code: CreditErrorCodeType, details?: Record); /** * Convert to JSON-serializable object */ toJSON(): { name: string; code: string; message: string; details?: Record; }; } /** * Type guard to check if an error is a CreditError */ declare function isCreditError(error: unknown): error is CreditError; /** * Check if an error represents insufficient credits * * Works with both CreditError and regular Error instances. * Useful for handling errors from different sources. */ declare function isInsufficientCreditsError(error: unknown): boolean; /** * Create an insufficient credits error */ declare function createInsufficientCreditsError(required: number, available: number): CreditError; /** * Create a reservation not found error */ declare function createReservationNotFoundError(reservationId: string): CreditError; /** * Create a reservation expired error */ declare function createReservationExpiredError(reservationId: string): CreditError; /** * Create a reservation already processed error */ declare function createReservationAlreadyProcessedError(reservationId: string, status: string): CreditError; /** * Create a user not found error */ declare function createUserNotFoundError(userId: string): CreditError; /** * Create an invalid operation type error */ declare function createInvalidOperationTypeError(operationType: string, validTypes: string[]): CreditError; /** * Core credit operations - framework agnostic * * Contains the business logic for credit operations that can be * used by any adapter or service implementation. */ /** * Commit a reservation with journal entry * * @param repository - The credit repository * @param userId - User ID * @param reservationId - Reservation to commit */ declare function commitReservationWithJournal(repository: ICreditRepository, userId: string, reservationId: string): Promise; /** * Release a reservation with journal entry * * @param repository - The credit repository * @param userId - User ID * @param reservationId - Reservation to release */ declare function releaseReservationWithJournal(repository: ICreditRepository, userId: string, reservationId: string): Promise; /** * Reserve credits for an operation * * @param repository - The credit repository * @param userId - User ID * @param amount - Credits to reserve * @param operationType - Type of operation * @param expiryMs - Reservation expiry time in milliseconds * @returns The reservation */ declare function reserveCreditsForOperation(repository: ICreditRepository, userId: string, amount: number, operationType: string, expiryMs?: number): Promise; export { CreditError, CreditErrorCode, type CreditErrorCodeType, PortableReservation, commitReservationWithJournal, createInsufficientCreditsError, createInvalidOperationTypeError, createReservationAlreadyProcessedError, createReservationExpiredError, createReservationNotFoundError, createUserNotFoundError, isCreditError, isInsufficientCreditsError, releaseReservationWithJournal, reserveCreditsForOperation };