Files
agent-bounty-protocol/apps/web/src/lib/audit.ts
OG T 745ff300b5
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 7s
feat: harden A2A funnel and paid proposal intake
2026-06-11 11:28:08 +08:00

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,
},
});
}