import { db } from '../db/client'; import { auditLogs } from '../db/schema'; export const writeAuditLog = async (entry: { ownerUserId: string; action: string; targetType: string; targetId: string; actorDeviceId?: string; metadata?: Record; ipAddress?: string; }): Promise => { await db.insert(auditLogs).values({ ownerUserId: entry.ownerUserId, actorDeviceId: entry.actorDeviceId, action: entry.action, targetType: entry.targetType, targetId: entry.targetId, metadata: entry.metadata ?? null, ipAddress: entry.ipAddress, }); };