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

@Entity('approval_requests')
export class ApprovalRequest {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

  @Column({ type: 'varchar', length: 20 })
  tenantId!: string;

  @Column({ type: 'uuid' })
  taskId!: string;

  @Column({ type: 'text' })
  command!: string;

  @Column({ type: 'smallint' })
  riskLevel!: number;

  @Column({ type: 'varchar', length: 20, default: 'pending' })
  status!: 'pending' | 'approved' | 'rejected' | 'expired';

  @Column({ type: 'uuid', nullable: true })
  decidedBy?: string;

  @Column({ type: 'timestamptz', nullable: true })
  decidedAt?: Date;

  @Column({ type: 'text', nullable: true })
  reason?: string;

  @Column({ type: 'timestamptz' })
  expiresAt!: Date;

  @Column({ type: 'varchar', array: true, nullable: true })
  notificationChannels!: string[];
}
