import { getDb } from "@/db"; import { auditLogs } from "@/db/schema"; export async function writeAuditLog(input: { tenantId?: string | null; actorId?: string | null; action: string; entityType: string; entityId: string; metadata?: Record; }) { await getDb().insert(auditLogs).values({ tenantId: input.tenantId ?? null, actorId: input.actorId ?? null, action: input.action, entityType: input.entityType, entityId: input.entityId, metadata: input.metadata ?? {}, }); }