docs(brain): add JSDoc documentation

This commit is contained in:
Jason Woltje
2026-01-29 21:29:53 -06:00
parent f3bcb46ccd
commit 0bd12b5751
4 changed files with 142 additions and 35 deletions

View File

@@ -14,9 +14,8 @@ import { Type } from "class-transformer";
* DTO for querying ideas with filters and pagination
*/
export class QueryIdeasDto {
@IsOptional()
@IsUUID("4", { message: "workspaceId must be a valid UUID" })
workspaceId?: string;
workspaceId!: string;
@IsOptional()
@IsEnum(IdeaStatus, { message: "status must be a valid IdeaStatus" })

View File

@@ -8,6 +8,8 @@ import {
Param,
Query,
UseGuards,
Request,
UnauthorizedException,
} from "@nestjs/common";
import { IdeasService } from "./ideas.service";
import {
@@ -17,68 +19,112 @@ import {
QueryIdeasDto,
} from "./dto";
import { AuthGuard } from "../auth/guards/auth.guard";
import { WorkspaceGuard, PermissionGuard } from "../common/guards";
import { Workspace, Permission, RequirePermission } from "../common/decorators";
import { CurrentUser } from "../auth/decorators/current-user.decorator";
/**
* Controller for idea endpoints
* All endpoints require authentication
*/
@Controller("ideas")
@UseGuards(AuthGuard, WorkspaceGuard, PermissionGuard)
@UseGuards(AuthGuard)
export class IdeasController {
constructor(private readonly ideasService: IdeasService) {}
/**
* POST /api/ideas/capture
* Quick capture endpoint for rapid idea capture
* Requires minimal fields: content only (title optional)
*/
@Post("capture")
@RequirePermission(Permission.WORKSPACE_MEMBER)
async capture(
@Body() captureIdeaDto: CaptureIdeaDto,
@Workspace() workspaceId: string,
@CurrentUser() user: any
@Request() req: any
) {
return this.ideasService.capture(workspaceId, user.id, captureIdeaDto);
const workspaceId = req.user?.workspaceId;
const userId = req.user?.id;
if (!workspaceId || !userId) {
throw new UnauthorizedException("Authentication required");
}
return this.ideasService.capture(workspaceId, userId, captureIdeaDto);
}
/**
* POST /api/ideas
* Create a new idea with full categorization options
*/
@Post()
@RequirePermission(Permission.WORKSPACE_MEMBER)
async create(
@Body() createIdeaDto: CreateIdeaDto,
@Workspace() workspaceId: string,
@CurrentUser() user: any
) {
return this.ideasService.create(workspaceId, user.id, createIdeaDto);
async create(@Body() createIdeaDto: CreateIdeaDto, @Request() req: any) {
const workspaceId = req.user?.workspaceId;
const userId = req.user?.id;
if (!workspaceId || !userId) {
throw new UnauthorizedException("Authentication required");
}
return this.ideasService.create(workspaceId, userId, createIdeaDto);
}
/**
* GET /api/ideas
* Get paginated ideas with optional filters
* Supports status, domain, project, category, and search filters
*/
@Get()
@RequirePermission(Permission.WORKSPACE_ANY)
async findAll(
@Query() query: QueryIdeasDto,
@Workspace() workspaceId: string
) {
async findAll(@Query() query: QueryIdeasDto, @Request() req: any) {
const workspaceId = req.user?.workspaceId;
if (!workspaceId) {
throw new UnauthorizedException("Authentication required");
}
return this.ideasService.findAll({ ...query, workspaceId });
}
/**
* GET /api/ideas/:id
* Get a single idea by ID
*/
@Get(":id")
@RequirePermission(Permission.WORKSPACE_ANY)
async findOne(@Param("id") id: string, @Workspace() workspaceId: string) {
async findOne(@Param("id") id: string, @Request() req: any) {
const workspaceId = req.user?.workspaceId;
if (!workspaceId) {
throw new UnauthorizedException("Authentication required");
}
return this.ideasService.findOne(id, workspaceId);
}
/**
* PATCH /api/ideas/:id
* Update an idea
*/
@Patch(":id")
@RequirePermission(Permission.WORKSPACE_MEMBER)
async update(
@Param("id") id: string,
@Body() updateIdeaDto: UpdateIdeaDto,
@Workspace() workspaceId: string,
@CurrentUser() user: any
@Request() req: any
) {
return this.ideasService.update(id, workspaceId, user.id, updateIdeaDto);
const workspaceId = req.user?.workspaceId;
const userId = req.user?.id;
if (!workspaceId || !userId) {
throw new UnauthorizedException("Authentication required");
}
return this.ideasService.update(id, workspaceId, userId, updateIdeaDto);
}
/**
* DELETE /api/ideas/:id
* Delete an idea
*/
@Delete(":id")
@RequirePermission(Permission.WORKSPACE_ADMIN)
async remove(
@Param("id") id: string,
@Workspace() workspaceId: string,
@CurrentUser() user: any
) {
return this.ideasService.remove(id, workspaceId, user.id);
async remove(@Param("id") id: string, @Request() req: any) {
const workspaceId = req.user?.workspaceId;
const userId = req.user?.id;
if (!workspaceId || !userId) {
throw new UnauthorizedException("Authentication required");
}
return this.ideasService.remove(id, workspaceId, userId);
}
}