import { type Firestore } from 'firebase-admin/firestore'; import { type Account, type AccountInput, type CheckAndConsumeInput, type CheckAndConsumeResult, type Consumption, type Entitlement, type EntitlementGrant, type EntitlementStore, type Iso8601, type ListEntitlementsFilter, type Payment, type PaymentInput, type PaymentStatus, type Receipt } from 'stipend-mcp'; export interface FirestoreStoreOptions { /** Initialised Firestore client (Admin SDK). */ readonly firestore: Firestore; /** * Prefix prepended to every collection name. Useful in tests so that * concurrent runs against the same emulator don't see each other's data. * Defaults to no prefix. */ readonly collectionPrefix?: string; /** Override clock for deterministic tests. Defaults to `nowIso()`. */ readonly now?: () => Iso8601; /** * Optional async hook invoked once at the start of every * `checkAndConsume` transaction attempt, before any read happens. Tests * inject this to exercise interleavings; production callers should not * supply it. Because Firestore retries the transaction body on write * contention, the hook can fire more than once for the same logical call. */ readonly beforeAtomicSection?: () => Promise | void; } /** * Firestore-backed `EntitlementStore`. * * Atomicity of `checkAndConsume` is provided by a single `runTransaction` * callback. The consumption document's ID is the tool-call idempotency * key, which mirrors the SQL `UNIQUE (tool_call_idempotency_key)` from * TDD §2.5 — collision on the second writer is what defends against * double-spend on replays. * * Monetary amounts are stored as JSON numbers; see the package README for * the rationale and the implied ceiling. */ export declare class FirestoreStore implements EntitlementStore { private readonly db; private readonly prefix; private readonly now; private readonly beforeAtomicSection; constructor(options: FirestoreStoreOptions); private col; private accountRef; private entitlementRef; private paymentRef; private paymentByKeyRef; private receiptRef; private consumptionRef; upsertAccount(input: AccountInput): Promise; getAccount(accountId: string): Promise; getAccountByAgentId(agentId: string): Promise; listEntitlements(accountId: string, filter?: ListEntitlementsFilter): Promise; getEntitlement(id: string): Promise; grant(grant: EntitlementGrant): Promise; revoke(entitlementId: string): Promise; expire(entitlementId: string): Promise; checkAndConsume(input: CheckAndConsumeInput): Promise; private doCheckAndConsume; findConsumption(idempotencyKey: string): Promise; listConsumptions(accountId: string, since?: string): Promise; createPayment(input: PaymentInput): Promise; updatePaymentStatus(paymentId: string, status: PaymentStatus, fields?: { providerIntentId?: string; providerRef?: string; }): Promise; getPayment(paymentId: string): Promise; findPaymentByIdempotencyKey(key: string): Promise; findPaymentByProviderIntentId(providerIntentId: string): Promise; saveReceipt(receipt: Receipt): Promise; getReceipt(id: string): Promise; } //# sourceMappingURL=firestore-store.d.ts.map