import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';
import { DeviceLocation } from '../../../domain/value-objects/device-location';
import { DeviceStatus } from '../../../domain/value-objects/device-status';

@Entity('devices')
export class DeviceEntity {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

  @Column('json')
  location!: DeviceLocation;

  @Column()
  type!: string;

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

  @Column({ name: 'ip_address' })
  ipAddress!: string;

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

  @Column()
  fingerprint!: string;

  @Column({ type: 'enum', enum: ['active', 'background', 'closed'], default: 'closed' })
  status!: DeviceStatus;

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

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

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