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

@Entity('conversation_messages')
export class ConversationMessage {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

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

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

  @Column({ type: 'varchar', length: 20 })
  role!: 'user' | 'assistant' | 'system';

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

  @Column({ type: 'jsonb', nullable: true })
  toolCalls?: any[];

  @Column({ type: 'jsonb', nullable: true })
  toolResults?: any[];

  @Column({ type: 'jsonb', nullable: true })
  attachments?: Array<{
    mediaType: string;
    base64Data: string;
    fileName?: string;
  }>;

  @Column({ type: 'int', nullable: true })
  tokenCount?: number;

  @Column({ type: 'int' })
  sequenceNumber!: number;

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