import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn } from 'typeorm';

export enum AmlPattern {
  BUY_TRANSFER_WITHDRAW = 'buy_transfer_withdraw',
  FAN_OUT = 'fan_out',
  SELF_DEALING = 'self_dealing',
  CROSS_BORDER = 'cross_border',
  STRUCTURING = 'structuring',
}

export enum AlertStatus {
  OPEN = 'open',
  INVESTIGATING = 'investigating',
  ESCALATED = 'escalated',
  RESOLVED = 'resolved',
  DISMISSED = 'dismissed',
}

@Entity('aml_alerts')
export class AmlAlert {
  @PrimaryGeneratedColumn('uuid') id: string;
  @Column({ name: 'user_id', type: 'uuid' }) userId: string;
  @Column({ type: 'varchar', length: 50 }) pattern: AmlPattern;
  @Column({ name: 'risk_score', type: 'numeric', precision: 5, scale: 2 }) riskScore: string;
  @Column({ type: 'text' }) description: string;
  @Column({ type: 'jsonb', nullable: true }) evidence: Record<string, any> | null;
  @Column({ type: 'varchar', length: 20, default: 'open' }) status: AlertStatus;
  @Column({ name: 'assigned_to', type: 'uuid', nullable: true }) assignedTo: string | null;
  @Column({ type: 'text', nullable: true }) resolution: string | null;
  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt: Date;
}
