Files
stack/apps/api/src/tasks/dto/update-task.dto.ts
Jason Woltje 132fe6ba98 feat(#5): Implement CRUD APIs for tasks, events, and projects
Implements comprehensive CRUD APIs following TDD principles with 92.44%
test coverage (exceeds 85% requirement).

Features:
- Tasks API: Full CRUD with filtering, pagination, and subtask support
- Events API: Full CRUD with recurrence support and date filtering
- Projects API: Full CRUD with task/event association
- Authentication guards on all endpoints
- Workspace-scoped queries for multi-tenant isolation
- Activity logging for all operations (CREATED, UPDATED, DELETED, etc.)
- DTOs with class-validator validation
- Comprehensive test suite (221 tests, 44 for new APIs)

Implementation:
- Services: Business logic with Prisma ORM integration
- Controllers: RESTful endpoints with AuthGuard
- Modules: Properly registered in AppModule
- Documentation: Complete API reference in docs/4-api/4-crud-endpoints/

Test Coverage:
- Tasks: 96.1%
- Events: 89.83%
- Projects: 84.21%
- Overall: 92.44%

TDD Workflow:
1. RED: Wrote failing tests first
2. GREEN: Implemented minimal code to pass tests
3. REFACTOR: Improved code quality while maintaining coverage

Refs #5

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-28 18:43:12 -06:00

64 lines
1.6 KiB
TypeScript

import { TaskStatus, TaskPriority } from "@prisma/client";
import {
IsString,
IsOptional,
IsUUID,
IsEnum,
IsDateString,
IsInt,
IsObject,
MinLength,
MaxLength,
Min,
} from "class-validator";
/**
* DTO for updating an existing task
* All fields are optional to support partial updates
*/
export class UpdateTaskDto {
@IsOptional()
@IsString({ message: "title must be a string" })
@MinLength(1, { message: "title must not be empty" })
@MaxLength(255, { message: "title must not exceed 255 characters" })
title?: string;
@IsOptional()
@IsString({ message: "description must be a string" })
@MaxLength(10000, { message: "description must not exceed 10000 characters" })
description?: string | null;
@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()
@IsDateString({}, { message: "dueDate must be a valid ISO 8601 date string" })
dueDate?: Date | null;
@IsOptional()
@IsUUID("4", { message: "assigneeId must be a valid UUID" })
assigneeId?: string | null;
@IsOptional()
@IsUUID("4", { message: "projectId must be a valid UUID" })
projectId?: string | null;
@IsOptional()
@IsUUID("4", { message: "parentId must be a valid UUID" })
parentId?: string | null;
@IsOptional()
@IsInt({ message: "sortOrder must be an integer" })
@Min(0, { message: "sortOrder must be at least 0" })
sortOrder?: number;
@IsOptional()
@IsObject({ message: "metadata must be an object" })
metadata?: Record<string, unknown>;
}