All checks were successful
ci/woodpecker/push/api Pipeline was successful
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { IsOptional, IsEnum, IsString, IsInt, IsIn, Min, Max } from "class-validator";
|
|
import { Type } from "class-transformer";
|
|
import { EntryStatus, Visibility } from "@prisma/client";
|
|
|
|
/**
|
|
* DTO for querying knowledge entries (list endpoint)
|
|
*/
|
|
export class EntryQueryDto {
|
|
@IsOptional()
|
|
@IsEnum(EntryStatus, { message: "status must be a valid EntryStatus" })
|
|
status?: EntryStatus;
|
|
|
|
@IsOptional()
|
|
@IsEnum(Visibility, { message: "visibility must be a valid Visibility" })
|
|
visibility?: Visibility;
|
|
|
|
@IsOptional()
|
|
@IsString({ message: "tag must be a string" })
|
|
tag?: string;
|
|
|
|
@IsOptional()
|
|
@IsString({ message: "search must be a string" })
|
|
search?: string;
|
|
|
|
@IsOptional()
|
|
@IsIn(["updatedAt", "createdAt", "title"], {
|
|
message: "sortBy must be updatedAt, createdAt, or title",
|
|
})
|
|
sortBy?: "updatedAt" | "createdAt" | "title";
|
|
|
|
@IsOptional()
|
|
@IsIn(["asc", "desc"], { message: "sortOrder must be asc or desc" })
|
|
sortOrder?: "asc" | "desc";
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt({ message: "page must be an integer" })
|
|
@Min(1, { message: "page must be at least 1" })
|
|
page?: number;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt({ message: "limit must be an integer" })
|
|
@Min(1, { message: "limit must be at least 1" })
|
|
@Max(100, { message: "limit must not exceed 100" })
|
|
limit?: number;
|
|
}
|