import { BaseEntity } from '@edr/api-common';
import { Column, Entity, Index, Unique } from 'typeorm';

@Entity({ schema: 'freight', name: 'approval_rules' })
@Unique(['requiresDirectorApproval', 'stepOrder'])
@Index(['requiresDirectorApproval'])
@Index(['stepOrder'])
export class ApprovalRule extends BaseEntity {
  @Column({ name: 'requires_director_approval', type: 'boolean' })
  requiresDirectorApproval!: boolean;

  @Column({ name: 'step_order', type: 'smallint' })
  stepOrder!: number;

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

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

  @Column({ name: 'blocks_role', type: 'varchar', length: 30, nullable: true })
  blocksRole?: string | null;
}
