forked from Yara724/api
123 lines
3.1 KiB
TypeScript
123 lines
3.1 KiB
TypeScript
import { ApiPropertyOptional } from "@nestjs/swagger";
|
|
import { Type } from "class-transformer";
|
|
import {
|
|
IsIn,
|
|
IsInt,
|
|
IsISO8601,
|
|
IsOptional,
|
|
IsString,
|
|
Max,
|
|
MaxLength,
|
|
Min,
|
|
} from "class-validator";
|
|
import { BlameRequestType } from "src/Types&Enums/blame-request-management/blameRequestType.enum";
|
|
import { UNIFIED_FILE_STATUS_KEYS } from "src/helpers/unified-file-status";
|
|
|
|
/** Allowed sort keys for V2 list endpoints (claims / blame / insurer files). */
|
|
export const LIST_SORT_BY_V2 = [
|
|
"publicId",
|
|
"createdAt",
|
|
"requestNo",
|
|
"status",
|
|
] as const;
|
|
|
|
export type ListSortByV2 = (typeof LIST_SORT_BY_V2)[number];
|
|
|
|
export const LIST_FILE_TYPE_V2 = [
|
|
BlameRequestType.THIRD_PARTY,
|
|
BlameRequestType.CAR_BODY,
|
|
] as const;
|
|
|
|
export type ListFileTypeV2 = (typeof LIST_FILE_TYPE_V2)[number];
|
|
|
|
/**
|
|
* Optional query params for V2 expert/insurer file lists.
|
|
* If neither `page` nor `limit` is sent, the full filtered+sorted list is returned.
|
|
*/
|
|
export class ListQueryV2Dto {
|
|
@ApiPropertyOptional({
|
|
description: "1-based page index (use together with `limit` for pagination).",
|
|
example: 1,
|
|
minimum: 1,
|
|
})
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
page?: number;
|
|
|
|
@ApiPropertyOptional({
|
|
description: "Page size (max 100). If only `page` is set, defaults to 20.",
|
|
example: 20,
|
|
minimum: 1,
|
|
maximum: 100,
|
|
})
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(100)
|
|
limit?: number;
|
|
|
|
@ApiPropertyOptional({
|
|
enum: LIST_SORT_BY_V2,
|
|
description: "Sort field. Default: `createdAt`.",
|
|
})
|
|
@IsOptional()
|
|
@IsIn([...LIST_SORT_BY_V2])
|
|
sortBy?: ListSortByV2;
|
|
|
|
@ApiPropertyOptional({
|
|
enum: ["asc", "desc"],
|
|
description: "Sort direction. Default: `desc` for dates, `asc` for publicId/requestNo.",
|
|
})
|
|
@IsOptional()
|
|
@IsIn(["asc", "desc"])
|
|
sortOrder?: "asc" | "desc";
|
|
|
|
@ApiPropertyOptional({
|
|
description:
|
|
"Case-insensitive substring match on `publicId`, `requestNo`, status, and other endpoint-specific fields.",
|
|
example: "A142",
|
|
maxLength: 64,
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(64)
|
|
search?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
enum: UNIFIED_FILE_STATUS_KEYS,
|
|
description:
|
|
"Filter by calculated unified file status (blame + claim combined).",
|
|
})
|
|
@IsOptional()
|
|
@IsIn([...UNIFIED_FILE_STATUS_KEYS])
|
|
unifiedStatus?: (typeof UNIFIED_FILE_STATUS_KEYS)[number];
|
|
|
|
@ApiPropertyOptional({
|
|
enum: LIST_FILE_TYPE_V2,
|
|
description:
|
|
"Filter by blame file type: third-party liability (`THIRD_PARTY`) or car body (`CAR_BODY`).",
|
|
})
|
|
@IsOptional()
|
|
@IsIn([...LIST_FILE_TYPE_V2])
|
|
fileType?: ListFileTypeV2;
|
|
|
|
@ApiPropertyOptional({
|
|
description: "Filter start date (ISO 8601). Only files created on or after this date are returned.",
|
|
example: "2025-01-01T00:00:00.000Z",
|
|
})
|
|
@IsOptional()
|
|
@IsISO8601({ strict: false })
|
|
startDate?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: "Filter end date (ISO 8601). Only files created on or before this date are returned.",
|
|
example: "2025-12-31T23:59:59.999Z",
|
|
})
|
|
@IsOptional()
|
|
@IsISO8601({ strict: false })
|
|
endDate?: string;
|
|
}
|