Skip to content
Merged
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
2 changes: 2 additions & 0 deletions apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { TasksModule } from './tasks/tasks.module';
import { VendorsModule } from './vendors/vendors.module';
import { ContextModule } from './context/context.module';
import { TrustPortalModule } from './trust-portal/trust-portal.module';
import { TaskTemplateModule } from './framework-editor/task-template/task-template.module';

@Module({
imports: [
Expand All @@ -43,6 +44,7 @@ import { TrustPortalModule } from './trust-portal/trust-portal.module';
CommentsModule,
HealthModule,
TrustPortalModule,
TaskTemplateModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsNotEmpty, IsEnum } from 'class-validator';
import { Frequency, Departments } from '@trycompai/db';

export class CreateTaskTemplateDto {
@ApiProperty({
description: 'Task template name',
example: 'Monthly Security Review',
})
@IsString()
@IsNotEmpty()
name: string;

@ApiProperty({
description: 'Detailed description of the task template',
example: 'Review and update security policies on a monthly basis',
})
@IsString()
@IsNotEmpty()
description: string;

@ApiProperty({
description: 'Frequency of the task',
enum: Frequency,
example: Frequency.monthly,
})
@IsEnum(Frequency)
frequency: Frequency;

@ApiProperty({
description: 'Department responsible for the task',
enum: Departments,
example: Departments.it,
})
@IsEnum(Departments)
department: Departments;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { ApiProperty } from '@nestjs/swagger';
import { Frequency, Departments } from '@trycompai/db';

export class TaskTemplateResponseDto {
@ApiProperty({
description: 'Task template ID',
example: 'frk_tt_abc123def456',
})
id: string;

@ApiProperty({
description: 'Task template name',
example: 'Monthly Security Review',
})
name: string;

@ApiProperty({
description: 'Detailed description of the task template',
example: 'Review and update security policies on a monthly basis',
})
description: string;

@ApiProperty({
description: 'Frequency of the task',
enum: Frequency,
example: Frequency.monthly,
})
frequency: Frequency;

@ApiProperty({
description: 'Department responsible for the task',
enum: Departments,
example: Departments.it,
})
department: Departments;

@ApiProperty({
description: 'Creation timestamp',
example: '2025-01-01T00:00:00.000Z',
})
createdAt: Date;

@ApiProperty({
description: 'Last update timestamp',
example: '2025-01-01T00:00:00.000Z',
})
updatedAt: Date;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { PartialType } from '@nestjs/swagger';
import { CreateTaskTemplateDto } from './create-task-template.dto';

export class UpdateTaskTemplateDto extends PartialType(CreateTaskTemplateDto) {}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
PipeTransform,
Injectable,
BadRequestException,
} from '@nestjs/common';

@Injectable()
export class ValidateIdPipe implements PipeTransform<string, string> {
transform(value: string): string {
// Validate that the ID is not empty
if (!value || typeof value !== 'string' || value.trim() === '') {
throw new BadRequestException('ID must be a non-empty string');
}

// Validate CUID format with prefix 'frk_tt_'
const cuidRegex = /^frk_tt_[a-z0-9]+$/i;
if (!cuidRegex.test(value)) {
throw new BadRequestException(
'Invalid ID format. Expected format: frk_tt_[alphanumeric]',
);
}

return value;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
export const DELETE_TASK_TEMPLATE_RESPONSES = {
200: {
status: 200,
description: 'Successfully deleted framework editor task template',
schema: {
example: {
message: 'Framework editor task template deleted successfully',
deletedTaskTemplate: {
id: 'frk_tt_abc123def456',
name: 'Monthly Security Review',
},
authType: 'session',
authenticatedUser: {
id: 'user_123',
email: 'user@example.com',
},
},
},
},
401: {
status: 401,
description: 'Unauthorized - Invalid or missing authentication',
schema: {
example: {
statusCode: 401,
message: 'Unauthorized',
},
},
},
404: {
status: 404,
description: 'Framework editor task template not found',
schema: {
example: {
statusCode: 404,
message: 'Framework editor task template with ID frk_tt_abc123def456 not found',
},
},
},
500: {
status: 500,
description: 'Internal server error',
schema: {
example: {
statusCode: 500,
message: 'Internal server error',
},
},
},
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export const GET_ALL_TASK_TEMPLATES_RESPONSES = {
200: {
status: 200,
description: 'Successfully retrieved all framework editor task templates',
schema: {
example: {
data: [
{
id: 'frk_tt_abc123def456',
name: 'Monthly Security Review',
description: 'Review and update security policies on a monthly basis',
frequency: 'monthly',
department: 'it',
createdAt: '2025-01-01T00:00:00.000Z',
updatedAt: '2025-01-01T00:00:00.000Z',
},
],
count: 1,
authType: 'session',
authenticatedUser: {
id: 'user_123',
email: 'user@example.com',
},
},
},
},
401: {
status: 401,
description: 'Unauthorized - Invalid or missing authentication',
schema: {
example: {
statusCode: 401,
message: 'Unauthorized',
},
},
},
500: {
status: 500,
description: 'Internal server error',
schema: {
example: {
statusCode: 500,
message: 'Internal server error',
},
},
},
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export const GET_TASK_TEMPLATE_BY_ID_RESPONSES = {
200: {
status: 200,
description: 'Successfully retrieved framework editor task template',
schema: {
example: {
id: 'frk_tt_abc123def456',
name: 'Monthly Security Review',
description: 'Review and update security policies on a monthly basis',
frequency: 'monthly',
department: 'it',
createdAt: '2025-01-01T00:00:00.000Z',
updatedAt: '2025-01-01T00:00:00.000Z',
authType: 'session',
authenticatedUser: {
id: 'user_123',
email: 'user@example.com',
},
},
},
},
401: {
status: 401,
description: 'Unauthorized - Invalid or missing authentication',
schema: {
example: {
statusCode: 401,
message: 'Unauthorized',
},
},
},
404: {
status: 404,
description: 'Framework editor task template not found',
schema: {
example: {
statusCode: 404,
message: 'Framework editor task template with ID frk_tt_abc123def456 not found',
},
},
},
500: {
status: 500,
description: 'Internal server error',
schema: {
example: {
statusCode: 500,
message: 'Internal server error',
},
},
},
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { UpdateTaskTemplateDto } from '../dto/update-task-template.dto';

export const TASK_TEMPLATE_BODIES = {
updateTaskTemplate: {
type: UpdateTaskTemplateDto,
description: 'Update framework editor task template data',
},
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const TASK_TEMPLATE_OPERATIONS = {
getAllTaskTemplates: {
summary: 'Get all framework editor task templates',
description: 'Retrieve all framework editor task templates',
},
getTaskTemplateById: {
summary: 'Get framework editor task template by ID',
description: 'Retrieve a specific framework editor task template by its ID',
},
updateTaskTemplate: {
summary: 'Update framework editor task template',
description: 'Update a framework editor task template by ID',
},
deleteTaskTemplate: {
summary: 'Delete framework editor task template',
description: 'Delete a framework editor task template by ID',
},
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const TASK_TEMPLATE_PARAMS = {
taskTemplateId: {
name: 'id',
description: 'Framework editor task template ID',
example: 'frk_tt_abc123def456',
},
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
export const UPDATE_TASK_TEMPLATE_RESPONSES = {
200: {
status: 200,
description: 'Successfully updated framework editor task template',
schema: {
example: {
id: 'frk_tt_abc123def456',
name: 'Monthly Security Review (Updated)',
description: 'Review and update security policies on a monthly basis',
frequency: 'monthly',
department: 'it',
createdAt: '2025-01-01T00:00:00.000Z',
updatedAt: '2025-01-02T00:00:00.000Z',
authType: 'session',
authenticatedUser: {
id: 'user_123',
email: 'user@example.com',
},
},
},
},
400: {
status: 400,
description: 'Bad request - Invalid data provided',
schema: {
example: {
statusCode: 400,
message: 'Validation failed',
},
},
},
401: {
status: 401,
description: 'Unauthorized - Invalid or missing authentication',
schema: {
example: {
statusCode: 401,
message: 'Unauthorized',
},
},
},
404: {
status: 404,
description: 'Framework editor task template not found',
schema: {
example: {
statusCode: 404,
message: 'Framework editor task template with ID frk_tt_abc123def456 not found',
},
},
},
500: {
status: 500,
description: 'Internal server error',
schema: {
example: {
statusCode: 500,
message: 'Internal server error',
},
},
},
};

Loading
Loading