feat: move to V2
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-10-29 11:21:52 +01:00
parent 6342b8451e
commit 314717ba3a
244 changed files with 11615 additions and 15292 deletions
+25 -14
View File
@@ -1,6 +1,14 @@
import { Injectable, Logger } from '@nestjs/common';
import { v4 as uuidv4 } from 'uuid';
import { PrismaService } from '../prisma/prisma.service';
import { Prisma, PrismaService, Tx } from '../prisma/prisma.service';
import { ActorType } from '../generated/prisma/client';
export type AuditEntry = {
/** Null for actions that are not about one venue. */
venueId: string | null;
actor: { type: ActorType; id: string | null };
action: string;
details?: Prisma.InputJsonObject;
};
@Injectable()
export class AuditService {
@@ -8,20 +16,23 @@ export class AuditService {
constructor(private prisma: PrismaService) {}
async log(venueId: string, actorType: string, actorId: string, action: string, details?: Record<string, any>) {
/** Records [entry]; inside [tx] it is part of that change, otherwise a failure is only logged. */
async log(entry: AuditEntry, tx?: Tx) {
const data = {
venueId: entry.venueId,
actorType: entry.actor.type,
actorId: entry.actor.id,
action: entry.action,
details: entry.details,
};
if (tx) {
await tx.auditLog.create({ data });
return;
}
try {
await this.prisma.auditLog.create({
data: {
id: uuidv4(),
venueId,
actorType,
actorId,
action,
details: details ? JSON.stringify(details) : null,
},
});
await this.prisma.auditLog.create({ data });
} catch (error) {
this.logger.error(`Failed to write audit log: ${error}`);
}
}
}
}