Files
stack/apps/api/src/tasks/dto/query-tasks.dto.ts
T
Jason Woltje 26a0df835f fix(api): fix RLS context, DTO validation, and error handling
- Wrap SET LOCAL in transactions for proper connection pooling
- Make workspaceId optional in query DTOs (derived from guards)
- Replace Error throws with UnauthorizedException in activity controller
- Update workspace guard to remove RLS context setting
- Document that services should use withUserContext/withUserTransaction
2026-01-29 20:14:27 -06:00

62 lines
1.5 KiB
TypeScript

import { TaskStatus, TaskPriority } from "@prisma/client";
import {
IsUUID,
IsEnum,
IsOptional,
IsInt,
Min,
Max,
IsDateString,
} from "class-validator";
import { Type } from "class-transformer";
/**
* DTO for querying tasks with filters and pagination
*/
export class QueryTasksDto {
@IsOptional()
@IsUUID("4", { message: "workspaceId must be a valid UUID" })
workspaceId?: string;
@IsOptional()
@IsEnum(TaskStatus, { message: "status must be a valid TaskStatus" })
status?: TaskStatus;
@IsOptional()
@IsEnum(TaskPriority, { message: "priority must be a valid TaskPriority" })
priority?: TaskPriority;
@IsOptional()
@IsUUID("4", { message: "assigneeId must be a valid UUID" })
assigneeId?: string;
@IsOptional()
@IsUUID("4", { message: "projectId must be a valid UUID" })
projectId?: string;
@IsOptional()
@IsUUID("4", { message: "parentId must be a valid UUID" })
parentId?: string;
@IsOptional()
@IsDateString({}, { message: "dueDateFrom must be a valid ISO 8601 date string" })
dueDateFrom?: Date;
@IsOptional()
@IsDateString({}, { message: "dueDateTo must be a valid ISO 8601 date string" })
dueDateTo?: Date;
@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;
}