import { ApiPropertyOptional } from "@nestjs/swagger"; import { Type } from "class-transformer"; import { IsArray, IsBoolean, IsEnum, IsInt, IsOptional, IsString, Min, } from "class-validator"; import { PartyRole } from "../entities/schema/partyRole.enum"; export class ReinquiryInquiriesDto { @ApiPropertyOptional({ description: "Blame public id (e.g. A00041). Use for single-case refresh.", example: "A00041", }) @IsOptional() @IsString() publicId?: string; @ApiPropertyOptional({ description: "Blame case Mongo id. Alternative to publicId.", }) @IsOptional() @IsString() blameRequestId?: string; @ApiPropertyOptional({ description: "Bulk mode: max number of blame cases to process (0 = no limit).", default: 0, }) @IsOptional() @Type(() => Number) @IsInt() @Min(0) limit?: number; @ApiPropertyOptional({ description: "Party roles to refresh. Defaults to FIRST and SECOND.", enum: PartyRole, isArray: true, }) @IsOptional() @IsArray() @IsEnum(PartyRole, { each: true }) roles?: PartyRole[]; @ApiPropertyOptional({ description: "When true, runs inquiries but does not persist updates.", default: false, }) @IsOptional() @IsBoolean() dryRun?: boolean; } export class ReinquiryPartyInputDto { plateId?: string; plate?: { ir: number; leftDigits: number; centerAlphabet: string; centerDigits: number; }; nationalCode?: string; birthDate?: number | string; } export class ReinquiryPartyPreviewDto { /** What would be written to inquiries.thirdParty.data[role] */ thirdParty?: Record; /** What would be written to inquiries.person.data[role] */ person?: Record; /** Summary of parties[].vehicle / parties[].insurance updates */ party?: { vehicle?: { name?: string; type?: string; plateId?: string }; insurance?: { policyNumber?: string; company?: string; financialCeiling?: string; startDate?: string; endDate?: string; }; }; } export class ReinquiryPartyResultDto { role: PartyRole; /** Values read from blameCase.parties[role] before calling external APIs */ input?: ReinquiryPartyInputDto; /** Present when dryRun=true — shows what would be saved (not written to DB) */ preview?: ReinquiryPartyPreviewDto; thirdParty?: { ok: boolean; message?: string }; person?: { ok: boolean; message?: string }; } export class ReinquiryCaseResultDto { blameRequestId: string; publicId?: string; blameUpdated: boolean; claimsUpdated: number; /** Full inquiries object that would be saved (dryRun only) */ inquiriesPreview?: { thirdParty?: Record; person?: Record; }; parties: ReinquiryPartyResultDto[]; } export class ReinquiryInquiriesResponseDto { dryRun: boolean; docsSeen: number; blameDocsUpdated: number; claimDocsUpdated: number; results: ReinquiryCaseResultDto[]; }