/** * MongoDBOutboxStore — MongoDB implementation of the OutboxStore contract. * * Uses MongoDB's `findOneAndUpdate` with atomic filter conditions to simulate * the `SELECT … FOR UPDATE SKIP LOCKED` semantics used by the PostgreSQL * adapter. Change streams on the outbox collection enable reactive dispatch. * * 'mongodb' is an optional peer dependency. It is loaded via dynamic import * at construction time. If the package is not installed, a clear error is * thrown. * * Transaction support: the `tx` parameter in `enqueue` accepts a MongoDB * `ClientSession` for transactional outbox pattern — state mutation and * event persistence share the same session/transaction boundary. */ import type { OutboxEntry, OutboxStore } from '../outbox-store'; export interface MongoDBOutboxStoreConfig { /** Required unless `collection` is injected. */ connectionString?: string; databaseName?: string; collectionName?: string; /** * Pre-initialized collection handle. When set, skips `mongodb` import and * connect — used by unit tests and hosts that own the client lifecycle. */ collection?: any; } export interface MongoDBOutboxStoreOptions { /** Provide a stable id generator for entries that arrive without one. */ generateId?: () => string; /** Wall-clock function for timestamps. Defaults to Date.now. */ now?: () => number; } export declare class MongoDBOutboxStore implements OutboxStore { private client; private collection; private collectionName; private databaseName; private generateId; private now; private ready; private readonly initConfig; constructor(config: MongoDBOutboxStoreConfig, opts?: MongoDBOutboxStoreOptions); private init; private ensureReady; enqueue(entries: OutboxEntry[], tx?: unknown): Promise; claim(batchSize: number): Promise; markDelivered(entryIds: string[]): Promise; markFailed(entryIds: string[], error: string): Promise; /** * Start watching the outbox collection for new entries via MongoDB change * streams. Returns a change stream that emits 'insert' events for reactive * dispatch. * * This is NOT part of the OutboxStore contract — it's a MongoDB-specific * utility for consumers that want push-based event dispatch instead of * polling with `claim()`. * * Requires a MongoDB replica set or sharded cluster. */ watch(): Promise; close(): Promise; private docToEntry; } //# sourceMappingURL=mongodb.d.ts.map