fix(knowledge): resolve TypeScript errors in tags service

- Fix updateData typing for partial updates
- Add slug field to CreateTagDto
- Build now passes

Note: tasks.controller.spec.ts needs test config update for WorkspaceGuard
This commit is contained in:
Jason Woltje
2026-01-29 17:09:27 -06:00
parent 25947cee52
commit a5b984c7fd
10 changed files with 998 additions and 14 deletions

View File

@@ -15,6 +15,13 @@ export class CreateTagDto {
@MaxLength(100, { message: "name must not exceed 100 characters" })
name!: string;
@IsOptional()
@IsString({ message: "slug must be a string" })
@Matches(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, {
message: "slug must be lowercase alphanumeric with hyphens",
})
slug?: string;
@IsOptional()
@IsString({ message: "color must be a string" })
@Matches(/^#[0-9A-Fa-f]{6}$/, {

View File

@@ -209,7 +209,19 @@ export class TagsService {
}
}
// Update tag
// Update tag - only include defined fields
const updateData: {
name?: string;
slug?: string;
color?: string | null;
description?: string | null;
} = {};
if (updateTagDto.name !== undefined) updateData.name = updateTagDto.name;
if (newSlug !== undefined) updateData.slug = newSlug;
if (updateTagDto.color !== undefined) updateData.color = updateTagDto.color;
if (updateTagDto.description !== undefined) updateData.description = updateTagDto.description;
const tag = await this.prisma.knowledgeTag.update({
where: {
workspaceId_slug: {
@@ -217,12 +229,7 @@ export class TagsService {
slug,
},
},
data: {
name: updateTagDto.name,
slug: newSlug,
color: updateTagDto.color,
description: updateTagDto.description,
},
data: updateData,
select: {
id: true,
workspaceId: true,