import { randomUUID } from 'node:crypto';
export async function appendAudit(tx, context, input) {
    const id = randomUUID();
    await tx.query(`INSERT INTO audit_events
      (id, actor_id, actor_role, action, entity_type, entity_id, old_values, new_values, reason,
       ip_address, user_agent, import_id, delivery_event_id)
     VALUES ($1,$2,$3,$4,$5,$6,$7::jsonb,$8::jsonb,$9,$10::inet,$11,$12,$13)`, [
        id,
        context.actorId ?? null,
        context.actorRole ?? null,
        input.action,
        input.entityType,
        input.entityId,
        input.oldValues === undefined ? null : JSON.stringify(input.oldValues),
        input.newValues === undefined ? null : JSON.stringify(input.newValues),
        input.reason ?? null,
        context.ip ?? null,
        context.userAgent ?? null,
        input.importId ?? null,
        input.deliveryEventId ?? null
    ]);
    return id;
}
//# sourceMappingURL=audit.js.map