48
apps/api/src/agent-tasks/dto/create-agent-task.dto.ts
Normal file
48
apps/api/src/agent-tasks/dto/create-agent-task.dto.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { AgentTaskStatus, AgentTaskPriority } from "@prisma/client";
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
IsEnum,
|
||||
IsObject,
|
||||
MinLength,
|
||||
MaxLength,
|
||||
} from "class-validator";
|
||||
|
||||
/**
|
||||
* DTO for creating a new agent task
|
||||
*/
|
||||
export class CreateAgentTaskDto {
|
||||
@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;
|
||||
|
||||
@IsOptional()
|
||||
@IsEnum(AgentTaskStatus, { message: "status must be a valid AgentTaskStatus" })
|
||||
status?: AgentTaskStatus;
|
||||
|
||||
@IsOptional()
|
||||
@IsEnum(AgentTaskPriority, { message: "priority must be a valid AgentTaskPriority" })
|
||||
priority?: AgentTaskPriority;
|
||||
|
||||
@IsString({ message: "agentType must be a string" })
|
||||
@MinLength(1, { message: "agentType must not be empty" })
|
||||
agentType!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject({ message: "agentConfig must be an object" })
|
||||
agentConfig?: Record<string, unknown>;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject({ message: "result must be an object" })
|
||||
result?: Record<string, unknown>;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "error must be a string" })
|
||||
error?: string;
|
||||
}
|
||||
3
apps/api/src/agent-tasks/dto/index.ts
Normal file
3
apps/api/src/agent-tasks/dto/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from "./create-agent-task.dto";
|
||||
export * from "./update-agent-task.dto";
|
||||
export * from "./query-agent-tasks.dto";
|
||||
48
apps/api/src/agent-tasks/dto/query-agent-tasks.dto.ts
Normal file
48
apps/api/src/agent-tasks/dto/query-agent-tasks.dto.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { AgentTaskStatus, AgentTaskPriority } from "@prisma/client";
|
||||
import {
|
||||
IsOptional,
|
||||
IsEnum,
|
||||
IsInt,
|
||||
Min,
|
||||
Max,
|
||||
IsString,
|
||||
IsUUID,
|
||||
} from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
|
||||
/**
|
||||
* DTO for querying agent tasks with pagination and filters
|
||||
*/
|
||||
export class QueryAgentTasksDto {
|
||||
@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;
|
||||
|
||||
@IsOptional()
|
||||
@IsEnum(AgentTaskStatus, { message: "status must be a valid AgentTaskStatus" })
|
||||
status?: AgentTaskStatus;
|
||||
|
||||
@IsOptional()
|
||||
@IsEnum(AgentTaskPriority, { message: "priority must be a valid AgentTaskPriority" })
|
||||
priority?: AgentTaskPriority;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "agentType must be a string" })
|
||||
agentType?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsUUID("4", { message: "createdById must be a valid UUID" })
|
||||
createdById?: string;
|
||||
|
||||
// Internal field set by controller/guard
|
||||
workspaceId?: string;
|
||||
}
|
||||
51
apps/api/src/agent-tasks/dto/update-agent-task.dto.ts
Normal file
51
apps/api/src/agent-tasks/dto/update-agent-task.dto.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { AgentTaskStatus, AgentTaskPriority } from "@prisma/client";
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
IsEnum,
|
||||
IsObject,
|
||||
MinLength,
|
||||
MaxLength,
|
||||
} from "class-validator";
|
||||
|
||||
/**
|
||||
* DTO for updating an existing agent task
|
||||
* All fields are optional to support partial updates
|
||||
*/
|
||||
export class UpdateAgentTaskDto {
|
||||
@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(AgentTaskStatus, { message: "status must be a valid AgentTaskStatus" })
|
||||
status?: AgentTaskStatus;
|
||||
|
||||
@IsOptional()
|
||||
@IsEnum(AgentTaskPriority, { message: "priority must be a valid AgentTaskPriority" })
|
||||
priority?: AgentTaskPriority;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "agentType must be a string" })
|
||||
@MinLength(1, { message: "agentType must not be empty" })
|
||||
agentType?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject({ message: "agentConfig must be an object" })
|
||||
agentConfig?: Record<string, unknown>;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject({ message: "result must be an object" })
|
||||
result?: Record<string, unknown> | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: "error must be a string" })
|
||||
error?: string | null;
|
||||
}
|
||||
Reference in New Issue
Block a user