import { type CardClaimInput, type CardHoldKey, type CardHoldStore, type CardVelocity, type ClaimedCardAuthorization, type HeldCardGrant, type HeldCardGrantRecord } from "./CardHoldStore.js"; import type { CardAuthorizationRequest } from "./CardPurchase.js"; export type { CardApproval, CardVelocity, ClaimedCardAuthorization, HeldCardGrant, } from "./CardHoldStore.js"; export { CARD_VELOCITY_WINDOW_MS } from "./CardHoldStore.js"; export interface HeldCardGrantsOptions { /** Entries of each kind this process keeps at most; a hold beyond it is refused. */ readonly maxEntries?: number; /** How long a claimed authorization waits for its result before it is forgotten. */ readonly claimRetentionMs?: number; readonly clock?: () => number; } /** * Grants held for a card authorization that has not happened yet, keyed by * the card and the merchant, and the authorizations that claimed one, keyed * by the issuer's authorization id. In memory and bounded on purpose: a hold * lives no longer than its grant, which the authority caps in minutes, and a * restart that loses one loses only a grant nobody claimed, which expires * with no effect. A claimed authorization is already in the journal. A * deployment with more than one replica, or one that must keep its holds * across a restart, uses the shared store instead. * * One card has at most one spendable hold per merchant. An agent that wants * a second purchase at the same merchant on the same card waits for the * first to be authorised or to expire, so an authorization can never be * matched to the wrong one of two; purchases at different merchants hold in * parallel, because the authorization names its merchant. */ export declare class HeldCardGrants implements CardHoldStore { readonly kind: "memory"; private static readonly MAX_ACTIVITY_PER_CARD; private readonly holds; private readonly claims; /** When each card was last held for and claimed, most recently touched card last. */ private readonly activity; private readonly maxEntries; private readonly claimRetentionMs; private readonly clock; constructor(options?: HeldCardGrantsOptions); spendable(key: CardHoldKey): Promise; hold(grant: HeldCardGrant): Promise; grant(key: CardHoldKey): Promise; /** Spent before anything is awaited by the caller: the first to ask gets it, later askers find it used. */ spend(grant: HeldCardGrant): Promise; claimed(authorizationId: string): Promise; /** Remembers a claim for its result; a full store forgets the oldest, which the journal still holds. */ recordClaim(authorizationId: string, claim: CardClaimInput): Promise; amend(authorizationId: string, request: CardAuthorizationRequest): Promise; settle(authorizationId: string): Promise; /** * The burst a policy wants to see: how many purchases were held for this * card and how many authorizations claimed one, over the window. The * policy language counts nothing over time, so the executor counts here * and puts the numbers in the intent's context; a card reference never * leaves with them. */ velocity(cardTokenRef: string, windowMs?: number): Promise; ready(): Promise; cleanup(): Promise; close(): Promise; get size(): { readonly holds: number; readonly claims: number; }; private spendableNow; /** Remembers one hold or claim on a card, bounded per card and across cards. */ private note; private sweep; } //# sourceMappingURL=HeldCardGrants.d.ts.map