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

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

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

  @Column({ name: 'agent_key', type: 'varchar', length: 255, unique: true })
  agentKey!: string;

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

  @Column({ type: 'varchar', length: 64, default: 'linux' })
  platform!: string;

  @Column({ type: 'varchar', length: 16, default: 'disabled' })
  status!: 'enabled' | 'disabled';

  @Column({ name: 'monitoring_enabled', type: 'boolean', default: false })
  monitoringEnabled!: boolean;

  @Column({ name: 'log_ingest_enabled', type: 'boolean', default: false })
  logIngestEnabled!: boolean;

  @Column({ name: 'proactive_push_enabled', type: 'boolean', default: false })
  proactivePushEnabled!: boolean;

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

  @Column({ name: 'last_heartbeat_at', type: 'timestamp', nullable: true })
  lastHeartbeatAt!: Date | null;

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

  @Column({ name: 'last_verify_at', type: 'timestamp', nullable: true })
  lastVerifyAt!: Date | null;

  @Column({ name: 'last_verify_status', type: 'varchar', length: 16, nullable: true })
  lastVerifyStatus!: 'online' | 'offline' | null;

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

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

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