class DatabaseAuditStorage
implements IAuditStorage

Database-backed audit storage. Requires an injected IAuditDbClient at construction time.

append serializes records via toAuditRow and calls client.insert. query calls client.select and maps rows back via fromAuditRow.

Constructors

DatabaseAuditStorage(options: { client: IAuditDbClient; table?: string; })
Parameters
options: { client: IAuditDbClient; table?: string; }

Methods

append(entry: StoredAuditEntry): Promise<void>

Appends one row via client.insert.

close(): Promise<void>

The injected client owns the connection lifecycle; nothing to drain here.

Since 0.6.0
isHealthy(): Promise<boolean>

Probes the injected client with a select that matches nothing.

IAuditDbClient exposes only insert and select, and an audit probe may not insert — it would write a fabricated record into the trail this plugin exists to keep trustworthy. So the probe reads instead, on the primary key against a sentinel that no generated id can equal (toAuditRow writes runtime.uuid() there): the round trip exercises the connection and the table's existence while returning no rows, which is what keeps it cheap enough to run on a health interval.

A rejection means the client was reached for and did not answer — a dropped connection, a missing table, a revoked grant — all of which mean the next append will be lost.

isReady(): boolean

Database storage is always ready once constructed.

query(criteria?: AuditQuery): Promise<StoredAuditEntry[]>

Selects rows via client.select, filters, maps to frozen entries.

Usage

import { DatabaseAuditStorage } from "audit-plugin/src/index.ts";