import type { StorageAdapterInternal, Page, PageOptions } from "../interfaces.js"; import type { ID, OperationStatus, EntryStatus } from "../types.js"; import type { Wallet, WalletBalance, LedgerEntry, Operation, FxSnapshot, PaymentPage, CheckoutSession, CheckoutQuote, CheckoutPayment, PayoutRecipient, ScheduledPayout, ScheduledPayoutExecution, ScheduledPayoutStatus, ScheduledTransfer, ScheduledTransferExecution, ScheduledTransferStatus } from "../schemas.js"; /** * Fully in-memory StorageAdapter — intended for testing and local development only. * * Balance derivation: replays LedgerEntries ordered by (effectiveAt ASC, sequence ASC), * exactly as a production adapter must. * * Concurrency: uses a per-wallet mutex (promise chain) to make debit balance-check + * entry-write atomic within the same JS event loop. */ export declare class InMemoryStorageAdapter implements StorageAdapterInternal { private wallets; private entries; private operations; private fxSnapshots; private paymentPages; private checkoutSessions; private checkoutQuotes; private checkoutPayments; private payoutRecipients; private scheduledPayouts; private scheduledPayoutExecutions; private scheduledTransfers; private scheduledTransferExecutions; /** Per-wallet serialisation locks — ensures atomic debit operations */ private walletLocks; /** Per-wallet monotonic sequence counters — keyed by "tenantId:walletId" */ private walletSeqCounters; private walletKey; private deriveBalance; private withWalletLock; private paginate; createWallet(wallet: Wallet): Promise; getWallet(tenantId: ID, walletId: ID): Promise; listWalletsByOwner(tenantId: ID, ownerId: ID, ownerType: string, page?: PageOptions): Promise>; updateWallet(tenantId: ID, walletId: ID, patch: Partial): Promise; archiveWallet(tenantId: ID, walletId: ID): Promise; createEntries(tenantId: ID, entries: LedgerEntry[]): Promise; getEntry(tenantId: ID, entryId: ID): Promise; listEntriesByWallet(tenantId: ID, walletId: ID, page?: PageOptions, filter?: { beforeEffectiveAt?: Date; afterSequence?: number; }): Promise>; updateEntryStatus(tenantId: ID, entryId: ID, status: EntryStatus): Promise; createOperation(operation: Operation): Promise; getOperation(tenantId: ID, operationId: ID): Promise; getOperationByIdempotencyKey(tenantId: ID, idempotencyKey: string): Promise; getOperationByExternalId(tenantId: ID, externalId: string, provider: string): Promise; updateOperationStatus(tenantId: ID, operationId: ID, status: OperationStatus, patch?: Partial>): Promise; mergeOperationMetadata(tenantId: ID, operationId: ID, patch: Record): Promise; listOperationsByWallet(tenantId: ID, walletId: ID, page?: PageOptions): Promise>; listOperations(tenantId: ID, page?: PageOptions, filter?: { walletId?: string; types?: string[]; statuses?: string[]; provider?: string; fromEffectiveAt?: Date; toEffectiveAt?: Date; idempotencyKey?: string; recipientId?: string; }): Promise>; getBalance(tenantId: ID, walletId: ID): Promise; getBalanceAt(tenantId: ID, walletId: ID, at: Date): Promise; /** * Returns the current reserved amount (sum of pending debits) for a wallet. * Called exclusively from createEntries under the wallet-level lock (§13 rule 6a). * NOT part of the public StorageAdapter surface. */ getReserved(tenantId: ID, walletId: ID): Promise; /** * Create a transit wallet with upsert semantics (IC-4). * If a wallet with (tenantId, ownerId, ownerType='checkout_session', currency) already * exists, return it without error (prevents duplicate transit wallets under concurrent races). */ createTransitWallet(wallet: Wallet): Promise; createFxSnapshot(snapshot: FxSnapshot): Promise; getFxSnapshot(tenantId: ID, snapshotId: ID): Promise; createPaymentPage(page: PaymentPage): Promise; getPaymentPage(tenantId: ID, pageId: ID): Promise; updatePaymentPage(tenantId: ID, pageId: ID, patch: Partial): Promise; listPaymentPages(tenantId: ID, page?: PageOptions): Promise>; createCheckoutSession(session: CheckoutSession): Promise; getCheckoutSession(tenantId: ID, sessionId: ID): Promise; findCheckoutSessionByPayerRef(tenantId: ID, pageId: ID, payerRefHash: string): Promise; updateCheckoutSession(tenantId: ID, sessionId: ID, patch: Partial): Promise; listCheckoutSessionsByPage(tenantId: ID, pageId: ID, page?: PageOptions): Promise>; createCheckoutQuote(quote: CheckoutQuote): Promise; getCheckoutQuote(tenantId: ID, quoteId: ID): Promise; updateCheckoutQuote(tenantId: ID, quoteId: ID, patch: Partial): Promise; createCheckoutPayment(payment: CheckoutPayment): Promise; getCheckoutPayment(tenantId: ID, paymentId: ID): Promise; findCheckoutPaymentByProviderRef(tenantId: ID, providerRef: string): Promise; updateCheckoutPayment(tenantId: ID, paymentId: ID, patch: Partial): Promise; listCheckoutPaymentsBySession(tenantId: ID, sessionId: ID, page?: PageOptions): Promise>; createPayoutRecipient(recipient: PayoutRecipient): Promise; getPayoutRecipient(tenantId: ID, recipientId: ID): Promise; updatePayoutRecipient(tenantId: ID, recipientId: ID, patch: Partial): Promise; listPayoutRecipients(tenantId: ID, page?: PageOptions, filter?: { provider?: string; currency?: string; ownerId?: string; ownerType?: string; includeArchived?: boolean; }): Promise>; archivePayoutRecipient(tenantId: ID, recipientId: ID): Promise; /** Clear all state — useful between tests */ clear(): void; createScheduledPayout(schedule: ScheduledPayout): Promise; getScheduledPayout(tenantId: ID, scheduleId: ID): Promise; updateScheduledPayout(tenantId: ID, scheduleId: ID, patch: Partial): Promise; listScheduledPayouts(tenantId: ID, page?: PageOptions, filter?: { walletId?: string; recipientId?: string; status?: ScheduledPayoutStatus; }): Promise>; listDueScheduledPayouts(tenantId: ID, now: Date): Promise; claimScheduledPayout(tenantId: ID, scheduleId: ID, now: Date): Promise; createScheduledPayoutExecution(exec: ScheduledPayoutExecution): Promise; listScheduledPayoutExecutions(tenantId: ID, scheduleId: ID, page?: PageOptions): Promise>; createScheduledTransfer(schedule: ScheduledTransfer): Promise; getScheduledTransfer(tenantId: ID, scheduleId: ID): Promise; updateScheduledTransfer(tenantId: ID, scheduleId: ID, patch: Partial): Promise; listScheduledTransfers(tenantId: ID, page?: PageOptions, filter?: { fromWalletId?: string; status?: ScheduledTransferStatus; }): Promise>; listDueScheduledTransfers(tenantId: ID, now: Date): Promise; claimScheduledTransfer(tenantId: ID, scheduleId: ID, now: Date): Promise; createScheduledTransferExecution(exec: ScheduledTransferExecution): Promise; listScheduledTransferExecutions(tenantId: ID, scheduleId: ID, page?: PageOptions): Promise>; } //# sourceMappingURL=memory.d.ts.map