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

@Entity('task_activity_audit')
@Index('idx_task_activity_audit_user_created', ['user_id', 'created_at'])
@Index('idx_task_activity_audit_nonce', ['user_id', 'nonce'])
export class TaskActivityAudit {
  @PrimaryGeneratedColumn({ type: 'bigint' })
  id: bigint;

  @Column({ type: 'bigint', nullable: false })
  user_id: bigint;

  @Column({ type: 'varchar', length: 64, nullable: false })
  nonce: string;

  @Column({ type: 'varchar', length: 40, nullable: false })
  activity: string;

  @Column({ type: 'varchar', length: 80, nullable: true })
  requested_target_id: string | null;

  @Column({ type: 'varchar', length: 80, nullable: true })
  resolved_target_id: string | null;

  @Column({ type: 'boolean', nullable: false, default: false })
  accepted: boolean;

  @Column({ type: 'varchar', length: 120, nullable: false })
  reason: string;

  @Column({ type: 'varchar', length: 80, nullable: true })
  session_id: string | null;

  @Column({ type: 'varchar', length: 40, nullable: true })
  map_id: string | null;

  @Column({ type: 'float', nullable: true })
  position_x: number | null;

  @Column({ type: 'float', nullable: true })
  position_y: number | null;

  @Column({ type: 'varchar', length: 64, nullable: true })
  client_ip: string | null;

  @Column({ type: 'varchar', length: 255, nullable: true })
  user_agent: string | null;

  @Column({ type: 'timestamp', nullable: true })
  client_occurred_at: Date | null;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  created_at: Date;
}
