import type { ActorType, Prisma } from "@/generated/prisma/client"; import type { Db, Tx } from "./db"; export type Actor = { type: ActorType; id?: string | null }; export const SYSTEM: Actor = { type: "SYSTEM" }; export const STRIPE_ACTOR: Actor = { type: "STRIPE" }; export const WORKER: Actor = { type: "WORKER" }; export const CUSTOMER: Actor = { type: "CUSTOMER" }; /** * Protokolliert Buchungs-, Bestands- und Zahlungsaktionen. "details" enthaelt * Betraege, Status und Stripe-IDs — keine Kontaktdaten der Teilnehmerin. */ export async function audit( db: Db | Tx, actor: Actor, action: string, entityType: string, entityId: string, details?: Prisma.InputJsonValue, ): Promise { await db.auditLog.create({ data: { actorType: actor.type, actorId: actor.id ?? null, action, entityType, entityId, details }, }); }