/** * Audit-log helpers for successful admin writes. * * The package has no session store and no first-party AuditLog table — same * bring-your-own philosophy as `authCheck` / `logout`. This module builds a * redacted `AuditEvent` and emits it to the consumer's callback. Sensitive * names (`isSensitiveFieldName`) and config `hidden` fields are stripped from * every snapshot so the audit sink cannot become a second oracle for secrets. */ import type { Model } from './types/schema.js'; export type AuditAction = 'create' | 'update' | 'delete'; export type AuditEvent = { event: any; at: Date; action: 'create'; model: string; id: string | number; values: Record; after: Record; m2m?: Record>; } | { event: any; at: Date; action: 'update'; model: string; id: string | number; values: Record; before: Record | null; after: Record; changes: Record; m2m?: Record>; } | { event: any; at: Date; action: 'delete'; model: string; id: string | number; before: Record | null; }; export declare function redactForAudit(record: Record, model: Model, hidden: ReadonlySet): Record; export declare function diffRecords(before: Record, after: Record): Record; export interface BuildAuditEventInput { event: any; at?: Date; action: AuditAction; model: Model; id: string | number; hidden: ReadonlySet; values?: Record; m2m?: Record; }>; before?: Record | null; after?: Record; } export declare function buildAuditEvent(input: BuildAuditEventInput): AuditEvent; export declare function readAuditSnapshot(getRecord: (model: Model, id: string | number) => Promise | null>, model: Model, id: string | number): Promise | null>; export declare function emitAudit(audit: ((entry: AuditEvent) => void | Promise) | undefined, entry: AuditEvent): Promise;