import {
  Column,
  CreateDateColumn,
  Entity,
  PrimaryColumn,
  UpdateDateColumn,
} from 'typeorm';
import { randomUUID } from 'crypto';

@Entity({ name: 'monitor_log_event' })
export class MonitorLogEventEntity {
  @PrimaryColumn({ type: 'varchar', length: 64 })
  id: string = randomUUID();

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

  @Column({ name: 'node_key', type: 'varchar', length: 255, nullable: true })
  nodeKey!: string | null;

  @Column({ type: 'varchar', length: 255, nullable: true })
  host!: string | null;

  @Column({ name: 'source_type', type: 'varchar', length: 32, default: 'vector' })
  sourceType!: 'vector' | 'fluent-bit' | 'manual';

  @Column({ name: 'source_name', type: 'varchar', length: 255, nullable: true })
  sourceName!: string | null;

  @Column({ type: 'varchar', length: 32, nullable: true })
  level!: string | null;

  @Column({ name: 'message_text', type: 'text' })
  messageText!: string;

  @Column({ name: 'event_at', type: 'timestamp' })
  eventAt!: Date;

  @Column({ name: 'meta_json', type: 'text', nullable: true })
  metaJson!: string | null;

  @CreateDateColumn({ name: 'created_at' })
  createdAt!: Date;

  @UpdateDateColumn({ name: 'updated_at' })
  updatedAt!: Date;
}
