/**
 * Per-tenant hook script entity.
 *
 * Hook scripts run at specific lifecycle points during agent tool execution:
 * - PreToolUse: runs before a tool is invoked (can block execution)
 * - PostToolUse: runs after a tool completes (for auditing/logging)
 * - PreNotification: runs before sending a notification
 * - PostNotification: runs after sending a notification
 */
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';

@Entity('hook_scripts')
export class HookScript {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

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

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

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

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

  @Column({ type: 'text', default: '' })
  script!: string;

  @Column({ type: 'int', default: 30 })
  timeout!: number;

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

  @Column({ type: 'text', default: '' })
  description!: string;

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

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