import type { Prisma, PrismaClient } from "@b2bcall/database"; export interface AuditEvent { action: string; tenantId?: string | null; userId?: string | null; entityType?: string; entityId?: string; before?: Prisma.InputJsonValue; after?: Prisma.InputJsonValue; ipAddress?: string; userAgent?: string; } export async function recordAuditEvent(prisma: PrismaClient, event: AuditEvent): Promise { await prisma.auditLog.create({ data: { action: event.action, tenantId: event.tenantId ?? null, userId: event.userId ?? null, entityType: event.entityType, entityId: event.entityId, before: event.before, after: event.after, ipAddress: event.ipAddress, userAgent: event.userAgent, }, }); }