import { Body, Controller, Get, Inject, Param, Patch, Post, Query, UseGuards } from '@nestjs/common'; import { CurrentUser } from '../auth/current-user.decorator'; import type { AuthRequestUser } from '../auth/auth.types'; import { JwtAuthGuard } from '../auth/jwt-auth.guard'; import { ContinuityCheckDto, CreatePlotMemoryDto, CreatePlotThreadDto, GeneratePlotMemoriesDto, UpdatePlotMemoryDto, UpdatePlotThreadDto } from './memory.dto'; import { MemoriesService } from './memories.service'; @Controller() @UseGuards(JwtAuthGuard) export class MemoriesController { constructor(@Inject(MemoriesService) private readonly memoriesService: MemoriesService) {} @Get('projects/:projectId/plot-memories') listPlotMemories( @CurrentUser() user: AuthRequestUser, @Param('projectId') projectId: string, @Query('memory_type') memoryType?: string, @Query('status') status?: string, @Query('episode_id') episodeId?: string ) { return this.memoriesService.listPlotMemories(user, projectId, { memory_type: memoryType, status, episode_id: episodeId }); } @Post('projects/:projectId/plot-memories/generate') generatePlotMemories( @CurrentUser() user: AuthRequestUser, @Param('projectId') projectId: string, @Body() dto: GeneratePlotMemoriesDto ) { return this.memoriesService.submitPlotMemoryGeneration(user, projectId, dto); } @Post('projects/:projectId/plot-memories') createPlotMemory( @CurrentUser() user: AuthRequestUser, @Param('projectId') projectId: string, @Body() dto: CreatePlotMemoryDto ) { return this.memoriesService.createPlotMemory(user, projectId, dto); } @Patch('plot-memories/:memoryId') updatePlotMemory( @CurrentUser() user: AuthRequestUser, @Param('memoryId') memoryId: string, @Body() dto: UpdatePlotMemoryDto ) { return this.memoriesService.updatePlotMemory(user, memoryId, dto); } @Get('projects/:projectId/memory-context') getMemoryContext( @CurrentUser() user: AuthRequestUser, @Param('projectId') projectId: string, @Query('episode_no') episodeNo?: string ) { return this.memoriesService.getMemoryContext(user, projectId, episodeNo); } @Get('characters/:characterId/memories') listCharacterMemories( @CurrentUser() user: AuthRequestUser, @Param('characterId') characterId: string ) { return this.memoriesService.listCharacterMemories(user, characterId); } @Get('projects/:projectId/character-memories') listProjectCharacterMemories( @CurrentUser() user: AuthRequestUser, @Param('projectId') projectId: string ) { return this.memoriesService.listProjectCharacterMemories(user, projectId); } @Get('projects/:projectId/plot-threads') listPlotThreads( @CurrentUser() user: AuthRequestUser, @Param('projectId') projectId: string, @Query('status') status?: string ) { return this.memoriesService.listPlotThreads(user, projectId, status); } @Post('projects/:projectId/plot-threads') createPlotThread( @CurrentUser() user: AuthRequestUser, @Param('projectId') projectId: string, @Body() dto: CreatePlotThreadDto ) { return this.memoriesService.createPlotThread(user, projectId, dto); } @Patch('plot-threads/:threadId') updatePlotThread( @CurrentUser() user: AuthRequestUser, @Param('threadId') threadId: string, @Body() dto: UpdatePlotThreadDto ) { return this.memoriesService.updatePlotThread(user, threadId, dto); } @Post('episodes/:episodeId/continuity-check') runContinuityCheck( @CurrentUser() user: AuthRequestUser, @Param('episodeId') episodeId: string, @Body() dto: ContinuityCheckDto ) { return this.memoriesService.runContinuityCheck(user, episodeId, dto); } }