- Create workspace listing page at /settings/workspaces - List all user workspaces with role badges - Create new workspace functionality - Display member count per workspace - Create workspace detail page at /settings/workspaces/[id] - Workspace settings (name, ID, created date) - Member management with role editing - Invite member functionality - Delete workspace (owner only) - Add workspace components: - WorkspaceCard: Display workspace info with role badge - WorkspaceSettings: Edit workspace settings and delete - MemberList: Display and manage workspace members - InviteMember: Send invitations with role selection - Add WorkspaceMemberWithUser type to shared package - Follow existing app patterns for styling and structure - Use mock data (ready for API integration)
5.8 KiB
5.8 KiB
KNOW-003: Tag Management API - Completion Summary
Status: ✅ Complete
Implemented Files
DTOs (Data Transfer Objects)
-
apps/api/src/knowledge/dto/create-tag.dto.ts- Validates tag creation input
- Required:
name - Optional:
slug,color(hex format),description - Slug validation: lowercase alphanumeric with hyphens
-
apps/api/src/knowledge/dto/update-tag.dto.ts- Validates tag update input
- All fields optional for partial updates
- Same validation rules as create DTO
Service Layer
apps/api/src/knowledge/tags.service.tscreate()- Creates tag with auto-generated slug if not providedfindAll()- Lists all workspace tags with entry countsfindOne()- Gets single tag by slugupdate()- Updates tag, regenerates slug if name changesremove()- Deletes tag (cascade removes entry associations)getEntriesWithTag()- Lists all entries tagged with specific tagfindOrCreateTags()- Helper for entry creation/update with auto-create option
Controller Layer
apps/api/src/knowledge/tags.controller.ts- All endpoints authenticated via
AuthGuard - Workspace isolation enforced on all operations
- Endpoints:
POST /api/knowledge/tags- Create tagGET /api/knowledge/tags- List tagsGET /api/knowledge/tags/:slug- Get tagPUT /api/knowledge/tags/:slug- Update tagDELETE /api/knowledge/tags/:slug- Delete tag (204 No Content)GET /api/knowledge/tags/:slug/entries- Get entries with tag
- All endpoints authenticated via
Module Configuration
-
apps/api/src/knowledge/knowledge.module.ts- Imports: PrismaModule, AuthModule
- Exports: TagsService (for use by entry service)
-
Updated
apps/api/src/app.module.ts- Added KnowledgeModule to main app imports
Tests
-
apps/api/src/knowledge/tags.service.spec.ts(17 tests, all passing)- Tests for all CRUD operations
- Slug generation and validation
- Conflict detection
- Entry associations
- Auto-create functionality
-
apps/api/src/knowledge/tags.controller.spec.ts(12 tests, all passing)- Tests for all endpoints
- Authentication validation
- Request/response handling
Key Features
-
Automatic Slug Generation
- Converts tag names to URL-friendly slugs
- Example: "My Tag Name!" → "my-tag-name"
- Can be overridden with custom slug
-
Workspace Isolation
- All operations scoped to user's workspace
- Tags are unique per workspace (slug-based)
-
Color Validation
- Hex color format required (#RRGGBB)
- Optional field for UI customization
-
Entry Count
- Tag list includes count of associated entries
- Useful for UI display and tag management
-
Auto-Create Support
findOrCreateTags()method for entry service- Enables creating tags on-the-fly during entry creation
- Generates friendly names from slugs
-
Conflict Handling
- Detects duplicate slugs within workspace
- Returns 409 Conflict with descriptive message
- Handles race conditions during auto-create
Test Coverage
- Total Tests: 29 passing
- Service Tests: 17
- Controller Tests: 12
- Coverage Areas:
- CRUD operations
- Validation (slug format, color format)
- Error handling (not found, conflicts, bad requests)
- Workspace isolation
- Auto-create functionality
- Authentication checks
TypeScript Compliance
- ✅ No
anytypes used - ✅ Explicit return types on all public methods
- ✅ Explicit parameter types throughout
- ✅ Interfaces used for DTOs
- ✅ Proper error handling with typed exceptions
- ✅ Follows
~/.claude/agent-guides/typescript.md - ✅ Follows
~/.claude/agent-guides/backend.md
Database Schema
Uses existing Prisma schema:
model KnowledgeTag {
id String @id @default(uuid()) @db.Uuid
workspaceId String @map("workspace_id") @db.Uuid
workspace Workspace @relation(...)
name String
slug String
color String?
description String?
entries KnowledgeEntryTag[]
@@unique([workspaceId, slug])
@@index([workspaceId])
}
Integration Points
-
Entry Service (parallel implementation)
- Will use
TagsService.findOrCreateTags()for tag associations - Entry create/update accepts tag slugs array
- Auto-create option available
- Will use
-
Authentication
- Uses existing
AuthGuardfromapps/api/src/auth/guards/auth.guard.ts - Workspace ID extracted from request user context
- Uses existing
-
Prisma
- Uses existing
PrismaServicefor database operations - Leverages Prisma's type-safe query builder
- Uses existing
Next Steps (for Entry Service Integration)
- Update entry service to accept
tags: string[]in DTOs - Call
TagsService.findOrCreateTags()during entry creation/update - Associate tags via
KnowledgeEntryTagjunction table - Consider adding
autoCreateTags: booleanoption to entry DTOs
Git Commit
feat(knowledge): add tag management API (KNOW-003)
- 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
Commit hash: f07f044
Task Status: COMPLETE ✅ Coding Standards: Compliant ✅ Tests: Passing (29/29) ✅ Documentation: Updated ✅