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

@Entity('messages')
export class Message {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

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

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

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

  @Column({ type: 'varchar', length: 10 })
  direction!: 'outbound' | 'inbound';

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

  @Column({ type: 'varchar', length: 10, default: 'normal' })
  priority!: 'low' | 'normal' | 'high' | 'urgent';

  @Column({ type: 'varchar', length: 20, default: 'pending' })
  deliveryStatus!: 'pending' | 'sent' | 'delivered' | 'failed';

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

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

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

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