import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm'; import { InspectionResponsibleDocumentType } from './inspection-act-responsible.entity'; export enum InspectionActSignerType { INSPECTOR = 'INSPECTOR', COMPANY_RESPONSIBLE = 'COMPANY_RESPONSIBLE', } export enum InspectionActSignatureStatus { SIGNED = 'SIGNED', REFUSED = 'REFUSED', ABSENT = 'ABSENT', } export enum InspectionActSignatureSource { WEB = 'WEB', ANDROID = 'ANDROID', } export enum InspectionCompanySignatureManifestation { CONFORMITY = 'CONFORMITY', DISSENT = 'DISSENT', } @Entity({ name: 'inspection_act_signatures' }) @Index('idx_inspection_act_signatures_act_created', ['actId', 'createdAt']) @Index('idx_inspection_act_signatures_sha256', ['signaturePayloadSha256']) export class InspectionActSignature { @PrimaryGeneratedColumn('uuid') id!: string; @Column({ name: 'act_id', type: 'uuid' }) actId!: string; @Column({ name: 'signer_type', type: 'varchar', length: 32 }) signerType!: InspectionActSignerType; @Column({ name: 'signer_user_id', type: 'uuid', nullable: true }) signerUserId!: string | null; @Column({ name: 'signer_name', type: 'varchar', length: 200 }) signerName!: string; @Column({ name: 'document_type', type: 'varchar', length: 20, nullable: true }) documentType!: InspectionResponsibleDocumentType | null; @Column({ name: 'document_number', type: 'varchar', length: 40, nullable: true }) documentNumber!: string | null; @Column({ type: 'varchar', length: 200, nullable: true }) position!: string | null; @Column({ type: 'varchar', length: 20 }) status!: InspectionActSignatureStatus; @Column({ type: 'text', nullable: true }) reason!: string | null; @Column({ name: 'company_manifestation', type: 'varchar', length: 20, nullable: true }) companyManifestation!: InspectionCompanySignatureManifestation | null; @Column({ name: 'company_statement', type: 'text', nullable: true }) companyStatement!: string | null; @Column({ name: 'original_name', type: 'varchar', length: 255, nullable: true }) originalName!: string | null; @Column({ name: 'stored_name', type: 'varchar', length: 80, nullable: true }) storedName!: string | null; @Column({ name: 'mime_type', type: 'varchar', length: 100, nullable: true }) mimeType!: string | null; @Column({ name: 'size_bytes', type: 'bigint', nullable: true }) sizeBytes!: number | null; @Column({ name: 'image_sha256', type: 'char', length: 64, nullable: true }) imageSha256!: string | null; @Column({ name: 'consent_text', type: 'text', nullable: true }) consentText!: string | null; @Column({ name: 'consent_version', type: 'varchar', length: 20, nullable: true }) consentVersion!: string | null; @Column({ name: 'consent_accepted_at', type: 'timestamptz', nullable: true }) consentAcceptedAt!: Date | null; @Column({ name: 'client_signed_at', type: 'timestamptz', nullable: true }) clientSignedAt!: Date | null; @Column({ name: 'signed_at', type: 'timestamptz', nullable: true }) signedAt!: Date | null; @Column({ type: 'numeric', precision: 9, scale: 6, nullable: true }) latitude!: number | null; @Column({ type: 'numeric', precision: 9, scale: 6, nullable: true }) longitude!: number | null; @Column({ name: 'accuracy_m', type: 'numeric', precision: 12, scale: 3, nullable: true }) accuracyM!: number | null; @Column({ name: 'device_label', type: 'varchar', length: 200, nullable: true }) deviceLabel!: string | null; @Column({ type: 'varchar', length: 20 }) source!: InspectionActSignatureSource; @Column({ name: 'prepared_sha256', type: 'char', length: 64 }) preparedSha256!: string; @Column({ name: 'signature_payload_sha256', type: 'char', length: 64 }) signaturePayloadSha256!: string; @Column({ name: 'uploaded_by', type: 'uuid' }) uploadedBy!: string; @Column({ name: 'created_at', type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' }) createdAt!: Date; }