Files
cal.diy/packages/features/booking-audit/lib/repository/PrismaAuditActorRepository.ts
T
Hariom Balhara c04402e7ee feat: [Booking Audit Stack - 1] Add Booking Audit System foundation (database schema and repositories) (#24838)
* feat: Implement Booking Audit System with database architecture and repository interfaces

- Added `ARCHITECTURE.md` detailing the design and structure of the Booking Audit System, including core tables `AuditActor` and `BookingAudit`.
- Created repository interfaces `IAuditActorRepository` and `IBookingAuditRepository` for managing audit actor and booking audit records.
- Implemented `PrismaAuditActorRepository` and `PrismaBookingAuditRepository` for database interactions.
- Defined enums for `BookingAuditType`, `BookingAuditAction`, and `AuditActorType` in the Prisma schema.
- Added migration scripts to create necessary database tables and enums for the audit system.

This commit establishes a robust framework for tracking booking-related actions, ensuring compliance and data integrity.

* feat(audit): add system actor migration
2025-11-19 08:21:34 -03:00

30 lines
830 B
TypeScript

import type { PrismaClient } from "@calcom/prisma/client";
import type { IAuditActorRepository } from "./IAuditActorRepository";
const SYSTEM_ACTOR_ID = "00000000-0000-0000-0000-000000000000";
type Dependencies = {
prismaClient: PrismaClient;
}
export class PrismaAuditActorRepository implements IAuditActorRepository {
constructor(private readonly deps: Dependencies) { }
async findByUserUuid(userUuid: string) {
return this.deps.prismaClient.auditActor.findUnique({
where: { userUuid },
});
}
async findSystemActorOrThrow() {
const actor = await this.deps.prismaClient.auditActor.findUnique({
where: { id: SYSTEM_ACTOR_ID },
});
if (!actor) {
throw new Error("System actor not found");
}
return actor;
}
}