Skip to content

AuditSink

Defined in: pipeline-audit/src/interfaces/audit-sink.interface.ts:18

Backend-agnostic sink for audit records — the single seam every storage backend implements.

Implement this once per backend; the bundled implementations are LogAuditSink (default, zero-dependency) and PostgresAuditSink. Because AuditBehavior depends only on this interface, swapping the backend (Postgres, an event store, Kafka, an HTTP collector, …) is a one-line change: the sink passed to its constructor.

optional begin(record): void | Promise<void>

Defined in: pipeline-audit/src/interfaces/audit-sink.interface.ts:42

Persist the start of an operation, before its handler runs. Optional: when implemented, AuditBehavior calls it first (unless recordStart: false), then calls write with the final record under the same id, which must replace this one. An attempt interrupted by a process stop then stays visible as 'pending' instead of being lost.

A throw here is logged by the behavior; with failOpen: false it also stops the request before its handler runs.

AuditStartRecord

The pending entry for the operation about to run.

void | Promise<void>


write(record): void | Promise<void>

Defined in: pipeline-audit/src/interfaces/audit-sink.interface.ts:28

Persist / publish a single audit record.

Implementations should be resilient. A throw here is logged by the behavior; with failOpen: false it also fails a successful request. A handler error is always rethrown unchanged.

AuditRecord

The completed audit entry to forward.

void | Promise<void>