forked from Yara724/api
Fix registrar signing, reviewer re-entry, replacement evidence freshness, owner decision and rating races, multipart objections, vehicle serialization and product reporting. Validate uploaded media with FFmpeg, serve evidence through expiring signed links, and add targeted regressions plus a dry-run repair for prematurely completed visit cases.
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import { ApiPropertyOptional } from "@nestjs/swagger";
|
|
import { Type, Transform, plainToInstance } from "class-transformer";
|
|
import { IsArray, IsOptional, Validate, ValidateNested } from "class-validator";
|
|
import { HasObjectionEntriesConstraint } from "src/common/validators/has-objection-entries.validator";
|
|
import { NewPartDto, UserObjectionPartDto } from "./user-objection.dto";
|
|
|
|
/**
|
|
* V2 user objection body — submitted as multipart/form-data.
|
|
* `objectionParts` and `newParts` are JSON-encoded strings in the form fields.
|
|
* Optional `invoices` files are uploaded as a `invoices` file array.
|
|
*/
|
|
export class UserObjectionV2Dto {
|
|
@ApiPropertyOptional({
|
|
type: [UserObjectionPartDto],
|
|
description:
|
|
"JSON-encoded array of disputed priced parts. Pass as a JSON string in the multipart field.",
|
|
})
|
|
@Validate(HasObjectionEntriesConstraint)
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => UserObjectionPartDto)
|
|
@Transform(({ value }) => {
|
|
if (typeof value === "string") {
|
|
try {
|
|
const parsed = JSON.parse(value);
|
|
return Array.isArray(parsed)
|
|
? plainToInstance(UserObjectionPartDto, parsed)
|
|
: parsed;
|
|
} catch {
|
|
return value;
|
|
}
|
|
}
|
|
return value;
|
|
})
|
|
objectionParts?: UserObjectionPartDto[];
|
|
|
|
@ApiPropertyOptional({
|
|
type: [NewPartDto],
|
|
description:
|
|
"JSON-encoded array of new parts to add. Pass as a JSON string in the multipart field.",
|
|
})
|
|
@Validate(HasObjectionEntriesConstraint)
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => NewPartDto)
|
|
@Transform(({ value }) => {
|
|
if (typeof value === "string") {
|
|
try {
|
|
const parsed = JSON.parse(value);
|
|
return Array.isArray(parsed)
|
|
? plainToInstance(NewPartDto, parsed)
|
|
: parsed;
|
|
} catch {
|
|
return value;
|
|
}
|
|
}
|
|
return value;
|
|
})
|
|
newParts?: NewPartDto[];
|
|
}
|