import type { Dialect } from '@enbox/dwn-sql-store'; /** * Input for recording a new audit event. */ export type AuditEventInput = { /** The actor that performed the action (`system` or an admin identifier). */ actor: string; /** Dot-delimited action identifier (e.g. `tenant.suspend`, `quota.update`). */ action: string; /** Target of the action (typically a tenant DID or resource identifier). */ target?: string; /** Additional detail — stored as a JSON string. */ detail?: string; }; /** * A persisted audit event row. */ export type AuditEvent = AuditEventInput & { /** Auto-incremented row ID. */ id: number; /** ISO-8601 timestamp when the event was recorded. */ timestamp: string; }; /** * Query options for retrieving audit events. */ export type AuditQueryOptions = { /** Return events with timestamp >= this ISO-8601 value. */ since?: string; /** Filter by action (exact match or prefix with `*`). */ action?: string; /** Filter by target DID or resource. */ target?: string; /** Maximum number of results. Default: 50. */ limit?: number; /** Cursor (row ID) for keyset pagination. */ cursor?: number; }; /** * Persistent, append-only audit log backed by a SQL table. * * Records significant admin and system events. Queryable via * `GET /admin/api/audit`. * * @see https://github.com/enboxorg/enbox/issues/327 */ /** * Configuration for audit log retention. * * @see https://github.com/enboxorg/enbox/issues/394 */ export type AuditRetentionConfig = { /** Maximum age in days. 0 = no limit. */ maxAgeDays: number; /** Maximum row count. 0 = no limit. */ maxRows: number; }; export declare class AuditLog { #private; private constructor(); /** * Creates and initializes an `AuditLog` instance. * Creates the `adminAuditLog` table if it does not already exist. * If `retentionConfig` is provided, starts periodic cleanup. */ static create(dialect: Dialect, retentionConfig?: AuditRetentionConfig): Promise; /** * Records a new audit event. */ record(event: AuditEventInput): Promise; /** * Queries audit events with optional filtering and pagination. */ query(options?: AuditQueryOptions): Promise<{ events: AuditEvent[]; cursor?: number; }>; /** * Returns the total number of audit events. */ count(): Promise; /** * Runs retention cleanup: purges entries older than maxAgeDays and trims * the table to maxRows. Returns the total number of rows deleted. * * @see https://github.com/enboxorg/enbox/issues/394 */ enforceRetention(config?: AuditRetentionConfig): Promise; /** * Closes the underlying database connection and stops the retention timer. */ close(): Promise; } //# sourceMappingURL=audit-log.d.ts.map