/**
 * Carrier ORM Entity (Infrastructure Layer)
 *
 * TypeORM entity for carrier persistence
 */

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

@Entity('carriers')
@Index('idx_carriers_code', ['code'])
@Index('idx_carriers_scac', ['scac'])
@Index('idx_carriers_active', ['isActive'])
@Index('idx_carriers_supports_api', ['supportsApi'])
export class CarrierOrmEntity {
  @PrimaryColumn('uuid')
  id: string;

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

  @Column({ type: 'varchar', length: 50, unique: true })
  code: string;

  @Column({ type: 'char', length: 4, unique: true })
  scac: string;

  @Column({ name: 'logo_url', type: 'text', nullable: true })
  logoUrl: string | null;

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

  @Column({ name: 'api_config', type: 'jsonb', nullable: true })
  apiConfig: any | null;

  @Column({ name: 'is_active', type: 'boolean', default: true })
  isActive: boolean;

  @Column({ name: 'supports_api', type: 'boolean', default: false })
  supportsApi: boolean;

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

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