/** * Generates the HasOmnifyAuditLog trait for models with audit-log opt-in. * * The trait is the single hook point that connects every audited Eloquent * model to the central `audits` history table. Adding `use HasOmnifyAuditLog;` * to a model makes it record `created` / `updated` / `deleted` / `restored` * events, with dirty-only diffing on update and sensitive-column scrubbing * before serialization. * * Performance design (audit-log is a hot path on every write): * - WriteAuditLog is dispatched as a queued job when `omnify.audit.queue` * is non-empty. The web request returns immediately; the audit row is * inserted by a worker. Sync fallback is only used in dev / low-traffic * mode (queue == ""). * - Auth, URL, IP, and User-Agent are captured at DISPATCH time, not at * job HANDLE time — workers have no Auth context and no Request facade. * - Updated events skip dispatch entirely when `getDirty()` is empty * (re-saves with no real changes don't emit phantom audit rows). * - Sensitive columns listed in `$auditExclude` are stripped from * `old_values` / `new_values` BEFORE the JSON payload is built, so a * stolen audits dump can't leak passwords or two-factor secrets. * - String columns are truncated to fit the table schema (`url` 2048, * `user_agent` 1023, `tags` 255) so a hostile UA header can't blow up * the insert with a row-too-large error. * - `Model::withoutAudit(fn() => ...)` lets seeders / migrations / batch * imports temporarily disable auditing for bulk writes that would * otherwise dispatch hundreds of thousands of jobs. */ import type { GeneratedFile, PhpConfig } from './types.js'; /** Generate the HasOmnifyAuditLog trait. */ export declare function generateAuditTrait(config: PhpConfig): GeneratedFile[];