31 lines
911 B
TypeScript
31 lines
911 B
TypeScript
import { Prisma } from "../../prisma/generated/client";
|
|
|
|
export async function logAuditEvent(
|
|
tx: Prisma.TransactionClient,
|
|
params: {
|
|
actorType: "SYSTEM" | "AGENT" | "USER";
|
|
actorId?: string;
|
|
action: string;
|
|
entityType: "TASK" | "CLAIM" | "SUBMISSION" | "JUDGE_RESULT" | "SYSTEM";
|
|
entityId: string;
|
|
beforeState?: Prisma.InputJsonValue | null;
|
|
afterState?: Prisma.InputJsonValue | null;
|
|
reason?: string;
|
|
metadata?: Prisma.InputJsonValue | null;
|
|
}
|
|
) {
|
|
return tx.auditEvent.create({
|
|
data: {
|
|
actorType: params.actorType,
|
|
actorId: params.actorId,
|
|
action: params.action,
|
|
entityType: params.entityType,
|
|
entityId: params.entityId,
|
|
beforeState: params.beforeState ?? Prisma.JsonNull,
|
|
afterState: params.afterState ?? Prisma.JsonNull,
|
|
reason: params.reason,
|
|
metadata: params.metadata ?? Prisma.JsonNull,
|
|
},
|
|
});
|
|
}
|