- Add Tag DTOs (CreateTagDto, UpdateTagDto) with validation - Implement TagsService with CRUD operations - Add TagsController with authenticated endpoints - Support automatic slug generation from tag names - Add workspace isolation for tags - Include entry count in tag responses - Add findOrCreateTags method for entry creation/update - Implement comprehensive test coverage (29 tests passing) Endpoints: - GET /api/knowledge/tags - List workspace tags - POST /api/knowledge/tags - Create tag - GET /api/knowledge/tags/:slug - Get tag by slug - PUT /api/knowledge/tags/:slug - Update tag - DELETE /api/knowledge/tags/:slug - Delete tag - GET /api/knowledge/tags/:slug/entries - List entries with tag Related: KNOW-003
30 lines
826 B
TypeScript
30 lines
826 B
TypeScript
import { IsOptional, IsEnum, IsString, IsInt, Min, Max } from "class-validator";
|
|
import { Type } from "class-transformer";
|
|
import { EntryStatus } 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()
|
|
@IsString({ message: "tag must be a string" })
|
|
tag?: string;
|
|
|
|
@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;
|
|
}
|