Fix searching on GET APIs

This commit is contained in:
SepehrYahyaee
2026-06-23 10:22:46 +03:30
parent 16d3c54613
commit c6b417ced7
9 changed files with 223 additions and 45 deletions

View File

@@ -9,9 +9,10 @@ import {
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). */
/** Allowed sort keys for V2 list endpoints (claims / blame / insurer files). */
export const LIST_SORT_BY_V2 = [
"publicId",
"createdAt",
@@ -21,9 +22,16 @@ export const LIST_SORT_BY_V2 = [
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 lists. If neither `page` nor `limit` is sent,
* the full filtered+sorted list is returned (backward compatible).
* 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({
@@ -68,7 +76,7 @@ export class ListQueryV2Dto {
@ApiPropertyOptional({
description:
"Case-insensitive substring match on `publicId` and `requestNo` (and other endpoint-specific fields).",
"Case-insensitive substring match on `publicId`, `requestNo`, status, and other endpoint-specific fields.",
example: "A142",
maxLength: 64,
})
@@ -85,4 +93,13 @@ export class ListQueryV2Dto {
@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;
}