mirror of
https://github.com/immich-app/static-pages.git
synced 2026-09-30 21:27:54 +08:00
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Zack Pollard <zackpollard@Zacks-MBP.local>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { AuditRepository, type AuditLogRow } from '../repositories/audit.repository';
|
|
|
|
export interface AuditLogInput {
|
|
userSub: string;
|
|
userEmail: string;
|
|
action: string;
|
|
resourceType: string;
|
|
resourceId?: string;
|
|
details?: string;
|
|
ipAddress?: string;
|
|
}
|
|
|
|
export class AuditService {
|
|
constructor(private audit: AuditRepository) {}
|
|
|
|
async log(input: AuditLogInput): Promise<void> {
|
|
await this.audit.create({
|
|
id: crypto.randomUUID(),
|
|
user_sub: input.userSub,
|
|
user_email: input.userEmail,
|
|
action: input.action,
|
|
resource_type: input.resourceType,
|
|
resource_id: input.resourceId ?? null,
|
|
details: input.details ?? null,
|
|
ip_address: input.ipAddress ?? null,
|
|
created_at: new Date().toISOString(),
|
|
});
|
|
}
|
|
|
|
async list(offset: number, limit: number): Promise<{ entries: AuditLogRow[]; total: number }> {
|
|
return this.audit.list(offset, limit);
|
|
}
|
|
|
|
async listBySurvey(
|
|
surveyId: string,
|
|
offset: number,
|
|
limit: number,
|
|
): Promise<{ entries: AuditLogRow[]; total: number }> {
|
|
return this.audit.listBySurvey(surveyId, offset, limit);
|
|
}
|
|
}
|