All files / apps/work-orders-service/src/work-orders work-order.entity.ts

100% Statements 18/18
100% Branches 16/16
100% Functions 0/0
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 698x                 8x     8x   8x     8x     8x           8x     8x       8x     8x                   8x               8x     8x     8x     8x     8x    
import {
  Column,
  CreateDateColumn,
  Entity,
  Index,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
import { TriageCategory, TriageUrgency } from '@app/contracts';
import { WorkOrderPriority, WorkOrderStatus } from './work-order.enums';
 
@Entity('work_orders')
export class WorkOrder {
  @PrimaryGeneratedColumn('uuid')
  id!: string;
 
  @Column({ length: 200 })
  title!: string;
 
  @Column({ type: 'text' })
  description!: string;
 
  // Reference to the Properties service's aggregate — an ID only, never a DB-level
  // foreign key: the properties table lives in another service's database.
  @Index()
  @Column({ name: 'property_id', type: 'uuid' })
  propertyId!: string;
 
  @Column({ type: 'varchar', length: 10, default: WorkOrderPriority.MEDIUM })
  priority!: WorkOrderPriority;
 
  @Index()
  @Column({ type: 'varchar', length: 20, default: WorkOrderStatus.OPEN })
  status!: WorkOrderStatus;
 
  @Column({ name: 'assignee_id', type: 'uuid', nullable: true })
  assigneeId!: string | null;
 
  // AI triage is advisory and asynchronous: all columns are nullable because
  // an order exists before (and possibly without) a classification.
  @Column({
    name: 'triage_category',
    type: 'varchar',
    length: 30,
    nullable: true,
  })
  triageCategory!: TriageCategory | null;
 
  @Column({
    name: 'triage_urgency',
    type: 'varchar',
    length: 10,
    nullable: true,
  })
  triageUrgency!: TriageUrgency | null;
 
  @Column({ name: 'triage_reasoning', type: 'text', nullable: true })
  triageReasoning!: string | null;
 
  @Column({ name: 'triaged_at', type: 'timestamptz', nullable: true })
  triagedAt!: Date | null;
 
  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
  createdAt!: Date;
 
  @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
  updatedAt!: Date;
}