/**
 * Audit logging types — ported from Python + TS implementations.
 */

import { z } from 'zod';

export interface AuditDoc {
  id: string;
  productId: string;
  userId: string;
  action: string;
  category: string;
  details: Record<string, unknown>;
  timestamp?: string;
  ipAddress?: string;
  userAgent?: string;
  createdAt: string;
  ttl?: number;
}

export const CreateAuditSchema = z.object({
  userId: z.string().min(1),
  action: z.string().min(1),
  category: z.string().default('general'),
  details: z.record(z.unknown()).default({}),
  timestamp: z.string().datetime().optional(),
  ipAddress: z.string().optional(),
  userAgent: z.string().optional(),
});

export const QueryAuditSchema = z.object({
  userId: z.string().optional(),
  action: z.string().optional(),
  category: z.string().optional(),
  days: z.number().int().min(1).max(365).default(30),
  limit: z.number().int().min(1).max(1000).default(100),
  offset: z.number().int().min(0).default(0),
});

export type CreateAuditInput = z.infer<typeof CreateAuditSchema>;
export type QueryAuditInput = z.infer<typeof QueryAuditSchema>;
