1- import { UseInterceptors , Controller , Injectable , Inject , UseGuards , Post , Body , Res , Get } from '@nestjs/common' ;
1+ import {
2+ UseInterceptors ,
3+ Controller ,
4+ Injectable ,
5+ Inject ,
6+ UseGuards ,
7+ Post ,
8+ Body ,
9+ Res ,
10+ Get ,
11+ Delete ,
12+ } from '@nestjs/common' ;
213import { ApiBearerAuth , ApiBody , ApiOperation , ApiQuery , ApiResponse , ApiTags } from '@nestjs/swagger' ;
314import { SentryInterceptor } from '../../interceptors/sentry.interceptor.js' ;
415import { UseCaseType } from '../../common/data-injection.tokens.js' ;
516import {
617 IAddMessageToThreadWithAIAssistant ,
718 ICreateThreadWithAIAssistant ,
19+ IDeleteThreadWithAIAssistant ,
820 IGetAllThreadMessages ,
921 IGetAllUserThreadsWithAIAssistant ,
1022} from './ai-use-cases.interface.js' ;
@@ -21,6 +33,7 @@ import { AddMessageToThreadWithAssistantDS } from './application/data-structures
2133import { FoundUserThreadsWithAiRO } from './application/dto/found-user-threads-with-ai.ro.js' ;
2234import { FoundUserThreadMessagesRO } from './application/dto/found-user-thread-messages.ro.js' ;
2335import { FindAllThreadMessagesDS } from './application/data-structures/find-all-thread-messages.ds.js' ;
36+ import { SuccessResponse } from '../../microservices/saas-microservice/data-structures/common-responce.ds.js' ;
2437
2538@UseInterceptors ( SentryInterceptor )
2639@Controller ( )
@@ -37,6 +50,8 @@ export class UserAIThreadsController {
3750 private readonly getAllUserThreadsWithAIAssistantUseCase : IGetAllUserThreadsWithAIAssistant ,
3851 @Inject ( UseCaseType . GET_ALL_THREAD_MESSAGES )
3952 private readonly getAllThreadMessagesUseCase : IGetAllThreadMessages ,
53+ @Inject ( UseCaseType . DELETE_THREAD_WITH_AI_ASSISTANT )
54+ private readonly deleteThreadWithAIAssistantUseCase : IDeleteThreadWithAIAssistant ,
4055 ) { }
4156
4257 @ApiOperation ( { summary : 'Create new thread with ai assistant' } )
@@ -127,4 +142,23 @@ export class UserAIThreadsController {
127142 } ;
128143 return await this . getAllThreadMessagesUseCase . execute ( inputData , InTransactionEnum . OFF ) ;
129144 }
145+
146+ @ApiOperation ( { summary : 'Delete users thread with ai assistant' } )
147+ @ApiResponse ( {
148+ status : 201 ,
149+ description : 'Delete users thread.' ,
150+ type : SuccessResponse ,
151+ isArray : true ,
152+ } )
153+ @Delete ( '/ai/thread/:threadId' )
154+ public async deleteThreadWithAssistant (
155+ @UserId ( ) userId : string ,
156+ @SlugUuid ( 'threadId' ) threadId : string ,
157+ ) : Promise < SuccessResponse > {
158+ const inputData : FindAllThreadMessagesDS = {
159+ threadId,
160+ userId,
161+ } ;
162+ return await this . deleteThreadWithAIAssistantUseCase . execute ( inputData , InTransactionEnum . ON ) ;
163+ }
130164}
0 commit comments