Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions apps/api/src/attachments/attachments.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@ export class AttachmentsController {
@ApiResponse({
status: 200,
description: 'Download URL generated successfully',
schema: {
type: 'object',
properties: {
downloadUrl: {
type: 'string',
description: 'Signed URL for downloading the file',
example:
'https://bucket.s3.amazonaws.com/path/to/file.pdf?signature=...',
},
expiresIn: {
type: 'number',
description: 'URL expiration time in seconds',
example: 900,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
downloadUrl: {
type: 'string',
description: 'Signed URL for downloading the file',
example:
'https://bucket.s3.amazonaws.com/path/to/file.pdf?signature=...',
},
expiresIn: {
type: 'number',
description: 'URL expiration time in seconds',
example: 900,
},
},
},
},
},
Expand Down
57 changes: 53 additions & 4 deletions apps/api/src/comments/comments.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export class CommentsController {
}

@Delete(':commentId')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({
summary: 'Delete a comment',
description: 'Delete a comment and all its attachments (author only)',
Expand All @@ -148,22 +147,72 @@ export class CommentsController {
example: 'cmt_abc123def456',
})
@ApiResponse({
status: 204,
status: 200,
description: 'Comment deleted successfully',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
success: { type: 'boolean', example: true },
deletedCommentId: { type: 'string', example: 'cmt_abc123def456' },
message: {
type: 'string',
example: 'Comment deleted successfully',
},
},
},
},
},
})
@ApiResponse({
status: 401,
description: 'Unauthorized - Invalid authentication',
content: {
'application/json': {
schema: {
type: 'object',
properties: { message: { type: 'string', example: 'Unauthorized' } },
},
},
},
})
@ApiResponse({
status: 404,
description: 'Comment not found',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: {
type: 'string',
example: 'Comment with ID cmt_abc123def456 not found',
},
},
},
},
},
})
async deleteComment(
@OrganizationId() organizationId: string,
@AuthContext() authContext: AuthContextType,
@Param('commentId') commentId: string,
): Promise<void> {
): Promise<{ success: boolean; deletedCommentId: string; message: string }> {
if (!authContext.userId) {
throw new BadRequestException('User ID is required');
}

return await this.commentsService.deleteComment(
await this.commentsService.deleteComment(
organizationId,
commentId,
authContext.userId,
);

return {
success: true,
deletedCommentId: commentId,
message: 'Comment deleted successfully',
};
}
}
55 changes: 53 additions & 2 deletions apps/api/src/context/schemas/create-context.responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@ import type { ApiResponseOptions } from '@nestjs/swagger';

export const CREATE_CONTEXT_RESPONSES: Record<number, ApiResponseOptions> = {
201: {
status: 201,
description: 'Context entry created successfully',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
id: { type: 'string' },
organizationId: { type: 'string' },
question: { type: 'string' },
answer: { type: 'string' },
tags: { type: 'array', items: { type: 'string' } },
createdAt: { type: 'string', format: 'date-time' },
updatedAt: { type: 'string', format: 'date-time' },
authType: { type: 'string', enum: ['api-key', 'session'] },
},
},
example: {
id: 'ctx_abc123def456',
organizationId: 'org_xyz789uvw012',
question: 'How do we handle user authentication in our application?',
answer: 'We use a hybrid authentication system supporting both API keys and session-based authentication.',
answer:
'We use a hybrid authentication system supporting both API keys and session-based authentication.',
tags: ['authentication', 'security', 'api', 'sessions'],
createdAt: '2024-01-15T10:30:00.000Z',
updatedAt: '2024-01-15T10:30:00.000Z',
Expand All @@ -19,21 +34,41 @@ export const CREATE_CONTEXT_RESPONSES: Record<number, ApiResponseOptions> = {
},
},
400: {
status: 400,
description: 'Bad request - Invalid input data',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'array', items: { type: 'string' } },
error: { type: 'string' },
statusCode: { type: 'number' },
},
},
example: {
message: ['question should not be empty', 'answer should not be empty'],
message: [
'question should not be empty',
'answer should not be empty',
],
error: 'Bad Request',
statusCode: 400,
},
},
},
},
401: {
status: 401,
description: 'Unauthorized - Invalid or missing authentication',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string' },
statusCode: { type: 'number', example: 401 },
},
},
example: {
message: 'Unauthorized',
statusCode: 401,
Expand All @@ -42,9 +77,17 @@ export const CREATE_CONTEXT_RESPONSES: Record<number, ApiResponseOptions> = {
},
},
404: {
status: 404,
description: 'Organization not found',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string' },
statusCode: { type: 'number', example: 404 },
},
},
example: {
message: 'Organization not found',
statusCode: 404,
Expand All @@ -53,9 +96,17 @@ export const CREATE_CONTEXT_RESPONSES: Record<number, ApiResponseOptions> = {
},
},
500: {
status: 500,
description: 'Internal server error',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string' },
statusCode: { type: 'number', example: 500 },
},
},
example: {
message: 'Internal server error',
statusCode: 500,
Expand Down
45 changes: 43 additions & 2 deletions apps/api/src/context/schemas/delete-context.responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,48 @@ import type { ApiResponseOptions } from '@nestjs/swagger';

export const DELETE_CONTEXT_RESPONSES: Record<number, ApiResponseOptions> = {
200: {
status: 200,
description: 'Context entry deleted successfully',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string' },
deletedContext: {
type: 'object',
properties: {
id: { type: 'string' },
question: { type: 'string' },
},
},
authType: { type: 'string', enum: ['api-key', 'session'] },
},
},
example: {
message: 'Context entry deleted successfully',
deletedContext: {
id: 'ctx_abc123def456',
question: 'How do we handle user authentication in our application?',
question:
'How do we handle user authentication in our application?',
},
authType: 'apikey',
},
},
},
},
401: {
status: 401,
description: 'Unauthorized - Invalid or missing authentication',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string' },
statusCode: { type: 'number', example: 401 },
},
},
example: {
message: 'Unauthorized',
statusCode: 401,
Expand All @@ -28,20 +52,37 @@ export const DELETE_CONTEXT_RESPONSES: Record<number, ApiResponseOptions> = {
},
},
404: {
status: 404,
description: 'Context entry not found',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string' },
statusCode: { type: 'number', example: 404 },
},
},
example: {
message: 'Context entry with ID ctx_abc123def456 not found in organization org_xyz789uvw012',
message:
'Context entry with ID ctx_abc123def456 not found in organization org_xyz789uvw012',
statusCode: 404,
},
},
},
},
500: {
status: 500,
description: 'Internal server error',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string' },
statusCode: { type: 'number', example: 500 },
},
},
example: {
message: 'Internal server error',
statusCode: 500,
Expand Down
Loading
Loading