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

@Entity('runbooks')
export class Runbook {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

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

  @Column({ type: 'varchar', length: 200 })
  name!: string;

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

  @Column({ type: 'varchar', length: 30, nullable: true })
  triggerType!: 'manual' | 'alert' | 'schedule' | 'scheduled';

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

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

  @Column({ type: 'smallint', default: 1 })
  maxRiskLevel!: number;

  @Column({ type: 'boolean', default: false })
  autoApprove!: boolean;

  @Column({ type: 'boolean', default: true })
  isActive!: boolean;

  @CreateDateColumn({ type: 'timestamptz' })
  createdAt!: Date;

  @UpdateDateColumn({ type: 'timestamptz' })
  updatedAt!: Date;
}
