import type { ClientSession } from 'mongodb'; import type { Logger } from '@nl-framework/logger'; import type { DocumentClass } from '../interfaces/document'; export type EntityWriteOperation = 'insert' | 'update' | 'updateMany' | 'softDelete' | 'restore' | 'delete' | 'bulkWrite' | 'bulkUpsert'; /** * Emitted after a repository write succeeds. For single-document operations * `documents`/`ids` identify what was written; for many-ops (`updateMany`, * `delete`, ...) only `filter` and `count` are known — consumers that need the * affected documents should refetch or lean on an `updatedAt` reconcile sweep. */ export interface EntityWriteEvent { connectionName: string; collection: string; target: DocumentClass; operation: EntityWriteOperation; documents?: T[]; ids?: string[]; filter?: unknown; count?: number; /** Present when the write ran inside a session — listeners can join the same transaction. */ session?: ClientSession; timestamp: Date; } export type EntityWriteListener = (event: EntityWriteEvent) => void | Promise; export type EntityWriteEventInput = Omit; /** * Per-connection write-event bus. Repositories emit after each successful * write; listeners are awaited (so an outbox insert can share the write's * session/transaction) but a listener failure never fails the write — it is * logged and the remaining listeners still run. */ export declare class WriteNotifier { private readonly connectionName; private readonly logger?; private readonly listeners; constructor(connectionName: string, logger?: Logger | undefined); get hasListeners(): boolean; onWrite(listener: EntityWriteListener): () => void; emit(event: EntityWriteEventInput): Promise; } //# sourceMappingURL=write-notifier.d.ts.map