131 lines
4.4 KiB
TypeScript
131 lines
4.4 KiB
TypeScript
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { TimestampedEntity } from './timestamped.entity';
|
|
|
|
export enum InspectionReportStatus {
|
|
WORKING = 'WORKING',
|
|
OFFICIALIZED = 'OFFICIALIZED',
|
|
FROZEN = 'FROZEN',
|
|
CANCELLED = 'CANCELLED',
|
|
}
|
|
|
|
export enum InspectionReportPdfStatus {
|
|
PENDING = 'PENDING',
|
|
READY = 'READY',
|
|
FAILED = 'FAILED',
|
|
}
|
|
|
|
export enum InspectionReportWordStatus {
|
|
PENDING = 'PENDING',
|
|
READY = 'READY',
|
|
FAILED = 'FAILED',
|
|
}
|
|
|
|
@Entity({ name: 'inspection_reports' })
|
|
@Index('idx_inspection_reports_visit_id', ['visitId'])
|
|
@Index('uq_inspection_reports_act', ['actId'], { unique: true })
|
|
@Index('uq_inspection_reports_year_number', ['reportYear', 'reportNumber'], { unique: true })
|
|
@Index('uq_inspection_reports_code', ['code'], { unique: true })
|
|
@Index('idx_inspection_reports_generated_at', ['generatedAt'])
|
|
@Index('idx_inspection_reports_status', ['status', 'pdfStatus'])
|
|
@Index('idx_inspection_reports_gedo_officialized_at', ['gedoOfficializedAt'])
|
|
export class InspectionReport extends TimestampedEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ name: 'visit_id', type: 'uuid' })
|
|
visitId!: string;
|
|
|
|
@Column({ name: 'act_id', type: 'uuid' })
|
|
actId!: string;
|
|
|
|
@Column({ name: 'report_year', type: 'integer' })
|
|
reportYear!: number;
|
|
|
|
@Column({ name: 'report_number', type: 'integer' })
|
|
reportNumber!: number;
|
|
|
|
@Column({ type: 'varchar', length: 40 })
|
|
code!: string;
|
|
|
|
@Column({ type: 'varchar', length: 24, default: InspectionReportStatus.WORKING })
|
|
status!: InspectionReportStatus;
|
|
|
|
@Column({ name: 'executive_summary', type: 'text', nullable: true })
|
|
executiveSummary!: string | null;
|
|
|
|
@Column({ name: 'report_description', type: 'text', nullable: true })
|
|
reportDescription!: string | null;
|
|
|
|
@Column({ name: 'gedo_if_identifier', type: 'varchar', length: 255, nullable: true })
|
|
gedoIfIdentifier!: string | null;
|
|
|
|
@Column({ name: 'gedo_officialized_at', type: 'timestamptz', nullable: true })
|
|
gedoOfficializedAt!: Date | null;
|
|
|
|
@Column({ name: 'gedo_pdf_original_name', type: 'varchar', length: 255, nullable: true })
|
|
gedoPdfOriginalName!: string | null;
|
|
|
|
@Column({ name: 'gedo_pdf_stored_name', type: 'varchar', length: 255, nullable: true })
|
|
gedoPdfStoredName!: string | null;
|
|
|
|
@Column({ name: 'gedo_pdf_mime_type', type: 'varchar', length: 120, nullable: true })
|
|
gedoPdfMimeType!: string | null;
|
|
|
|
@Column({ name: 'gedo_pdf_size_bytes', type: 'integer', nullable: true })
|
|
gedoPdfSizeBytes!: number | null;
|
|
|
|
@Column({ name: 'gedo_pdf_sha256', type: 'char', length: 64, nullable: true })
|
|
gedoPdfSha256!: string | null;
|
|
|
|
@Column({ name: 'pdf_status', type: 'varchar', length: 24, default: InspectionReportPdfStatus.PENDING })
|
|
pdfStatus!: InspectionReportPdfStatus;
|
|
|
|
@Column({ name: 'word_status', type: 'varchar', length: 24, default: InspectionReportWordStatus.PENDING })
|
|
wordStatus!: InspectionReportWordStatus;
|
|
|
|
@Column({ name: 'word_original_name', type: 'varchar', length: 255, nullable: true })
|
|
wordOriginalName!: string | null;
|
|
|
|
@Column({ name: 'word_stored_name', type: 'varchar', length: 255, nullable: true })
|
|
wordStoredName!: string | null;
|
|
|
|
@Column({ name: 'word_mime_type', type: 'varchar', length: 120, nullable: true })
|
|
wordMimeType!: string | null;
|
|
|
|
@Column({ name: 'word_size_bytes', type: 'integer', nullable: true })
|
|
wordSizeBytes!: number | null;
|
|
|
|
@Column({ name: 'word_sha256', type: 'char', length: 64, nullable: true })
|
|
wordSha256!: string | null;
|
|
|
|
@Column({ name: 'word_generated_at', type: 'timestamptz', nullable: true })
|
|
wordGeneratedAt!: Date | null;
|
|
|
|
@Column({ name: 'word_error', type: 'varchar', length: 500, nullable: true })
|
|
wordError!: string | null;
|
|
|
|
@Column({ name: 'current_revision_number', type: 'integer', default: 0 })
|
|
currentRevisionNumber!: number;
|
|
|
|
@Column({ type: 'varchar', length: 220 })
|
|
title!: string;
|
|
|
|
@Column({ name: 'act_version', type: 'integer' })
|
|
actVersion!: number;
|
|
|
|
@Column({ name: 'act_closure_sha256', type: 'char', length: 64 })
|
|
actClosureSha256!: string;
|
|
|
|
@Column({ name: 'frozen_sha256', type: 'char', length: 64 })
|
|
frozenSha256!: string;
|
|
|
|
@Column({ name: 'frozen_snapshot', type: 'jsonb' })
|
|
frozenSnapshot!: Record<string, unknown>;
|
|
|
|
@Column({ name: 'generated_at', type: 'timestamptz' })
|
|
generatedAt!: Date;
|
|
|
|
@Column({ name: 'generated_by', type: 'uuid' })
|
|
generatedBy!: string;
|
|
}
|