Skip to content

Commit 2947748

Browse files
committed
chore: merge main into release for new releases
2 parents 51a0fb4 + dbb149e commit 2947748

21 files changed

+1159
-6
lines changed

apps/api/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { TasksModule } from './tasks/tasks.module';
1717
import { VendorsModule } from './vendors/vendors.module';
1818
import { ContextModule } from './context/context.module';
1919
import { TrustPortalModule } from './trust-portal/trust-portal.module';
20+
import { TaskTemplateModule } from './framework-editor/task-template/task-template.module';
2021

2122
@Module({
2223
imports: [
@@ -43,6 +44,7 @@ import { TrustPortalModule } from './trust-portal/trust-portal.module';
4344
CommentsModule,
4445
HealthModule,
4546
TrustPortalModule,
47+
TaskTemplateModule,
4648
],
4749
controllers: [AppController],
4850
providers: [AppService],
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { IsString, IsNotEmpty, IsEnum } from 'class-validator';
3+
import { Frequency, Departments } from '@trycompai/db';
4+
5+
export class CreateTaskTemplateDto {
6+
@ApiProperty({
7+
description: 'Task template name',
8+
example: 'Monthly Security Review',
9+
})
10+
@IsString()
11+
@IsNotEmpty()
12+
name: string;
13+
14+
@ApiProperty({
15+
description: 'Detailed description of the task template',
16+
example: 'Review and update security policies on a monthly basis',
17+
})
18+
@IsString()
19+
@IsNotEmpty()
20+
description: string;
21+
22+
@ApiProperty({
23+
description: 'Frequency of the task',
24+
enum: Frequency,
25+
example: Frequency.monthly,
26+
})
27+
@IsEnum(Frequency)
28+
frequency: Frequency;
29+
30+
@ApiProperty({
31+
description: 'Department responsible for the task',
32+
enum: Departments,
33+
example: Departments.it,
34+
})
35+
@IsEnum(Departments)
36+
department: Departments;
37+
}
38+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { Frequency, Departments } from '@trycompai/db';
3+
4+
export class TaskTemplateResponseDto {
5+
@ApiProperty({
6+
description: 'Task template ID',
7+
example: 'frk_tt_abc123def456',
8+
})
9+
id: string;
10+
11+
@ApiProperty({
12+
description: 'Task template name',
13+
example: 'Monthly Security Review',
14+
})
15+
name: string;
16+
17+
@ApiProperty({
18+
description: 'Detailed description of the task template',
19+
example: 'Review and update security policies on a monthly basis',
20+
})
21+
description: string;
22+
23+
@ApiProperty({
24+
description: 'Frequency of the task',
25+
enum: Frequency,
26+
example: Frequency.monthly,
27+
})
28+
frequency: Frequency;
29+
30+
@ApiProperty({
31+
description: 'Department responsible for the task',
32+
enum: Departments,
33+
example: Departments.it,
34+
})
35+
department: Departments;
36+
37+
@ApiProperty({
38+
description: 'Creation timestamp',
39+
example: '2025-01-01T00:00:00.000Z',
40+
})
41+
createdAt: Date;
42+
43+
@ApiProperty({
44+
description: 'Last update timestamp',
45+
example: '2025-01-01T00:00:00.000Z',
46+
})
47+
updatedAt: Date;
48+
}
49+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { PartialType } from '@nestjs/swagger';
2+
import { CreateTaskTemplateDto } from './create-task-template.dto';
3+
4+
export class UpdateTaskTemplateDto extends PartialType(CreateTaskTemplateDto) {}
5+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {
2+
PipeTransform,
3+
Injectable,
4+
BadRequestException,
5+
} from '@nestjs/common';
6+
7+
@Injectable()
8+
export class ValidateIdPipe implements PipeTransform<string, string> {
9+
transform(value: string): string {
10+
// Validate that the ID is not empty
11+
if (!value || typeof value !== 'string' || value.trim() === '') {
12+
throw new BadRequestException('ID must be a non-empty string');
13+
}
14+
15+
// Validate CUID format with prefix 'frk_tt_'
16+
const cuidRegex = /^frk_tt_[a-z0-9]+$/i;
17+
if (!cuidRegex.test(value)) {
18+
throw new BadRequestException(
19+
'Invalid ID format. Expected format: frk_tt_[alphanumeric]',
20+
);
21+
}
22+
23+
return value;
24+
}
25+
}
26+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
export const DELETE_TASK_TEMPLATE_RESPONSES = {
2+
200: {
3+
status: 200,
4+
description: 'Successfully deleted framework editor task template',
5+
schema: {
6+
example: {
7+
message: 'Framework editor task template deleted successfully',
8+
deletedTaskTemplate: {
9+
id: 'frk_tt_abc123def456',
10+
name: 'Monthly Security Review',
11+
},
12+
authType: 'session',
13+
authenticatedUser: {
14+
id: 'user_123',
15+
16+
},
17+
},
18+
},
19+
},
20+
401: {
21+
status: 401,
22+
description: 'Unauthorized - Invalid or missing authentication',
23+
schema: {
24+
example: {
25+
statusCode: 401,
26+
message: 'Unauthorized',
27+
},
28+
},
29+
},
30+
404: {
31+
status: 404,
32+
description: 'Framework editor task template not found',
33+
schema: {
34+
example: {
35+
statusCode: 404,
36+
message: 'Framework editor task template with ID frk_tt_abc123def456 not found',
37+
},
38+
},
39+
},
40+
500: {
41+
status: 500,
42+
description: 'Internal server error',
43+
schema: {
44+
example: {
45+
statusCode: 500,
46+
message: 'Internal server error',
47+
},
48+
},
49+
},
50+
};
51+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
export const GET_ALL_TASK_TEMPLATES_RESPONSES = {
2+
200: {
3+
status: 200,
4+
description: 'Successfully retrieved all framework editor task templates',
5+
schema: {
6+
example: {
7+
data: [
8+
{
9+
id: 'frk_tt_abc123def456',
10+
name: 'Monthly Security Review',
11+
description: 'Review and update security policies on a monthly basis',
12+
frequency: 'monthly',
13+
department: 'it',
14+
createdAt: '2025-01-01T00:00:00.000Z',
15+
updatedAt: '2025-01-01T00:00:00.000Z',
16+
},
17+
],
18+
count: 1,
19+
authType: 'session',
20+
authenticatedUser: {
21+
id: 'user_123',
22+
23+
},
24+
},
25+
},
26+
},
27+
401: {
28+
status: 401,
29+
description: 'Unauthorized - Invalid or missing authentication',
30+
schema: {
31+
example: {
32+
statusCode: 401,
33+
message: 'Unauthorized',
34+
},
35+
},
36+
},
37+
500: {
38+
status: 500,
39+
description: 'Internal server error',
40+
schema: {
41+
example: {
42+
statusCode: 500,
43+
message: 'Internal server error',
44+
},
45+
},
46+
},
47+
};
48+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
export const GET_TASK_TEMPLATE_BY_ID_RESPONSES = {
2+
200: {
3+
status: 200,
4+
description: 'Successfully retrieved framework editor task template',
5+
schema: {
6+
example: {
7+
id: 'frk_tt_abc123def456',
8+
name: 'Monthly Security Review',
9+
description: 'Review and update security policies on a monthly basis',
10+
frequency: 'monthly',
11+
department: 'it',
12+
createdAt: '2025-01-01T00:00:00.000Z',
13+
updatedAt: '2025-01-01T00:00:00.000Z',
14+
authType: 'session',
15+
authenticatedUser: {
16+
id: 'user_123',
17+
18+
},
19+
},
20+
},
21+
},
22+
401: {
23+
status: 401,
24+
description: 'Unauthorized - Invalid or missing authentication',
25+
schema: {
26+
example: {
27+
statusCode: 401,
28+
message: 'Unauthorized',
29+
},
30+
},
31+
},
32+
404: {
33+
status: 404,
34+
description: 'Framework editor task template not found',
35+
schema: {
36+
example: {
37+
statusCode: 404,
38+
message: 'Framework editor task template with ID frk_tt_abc123def456 not found',
39+
},
40+
},
41+
},
42+
500: {
43+
status: 500,
44+
description: 'Internal server error',
45+
schema: {
46+
example: {
47+
statusCode: 500,
48+
message: 'Internal server error',
49+
},
50+
},
51+
},
52+
};
53+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { UpdateTaskTemplateDto } from '../dto/update-task-template.dto';
2+
3+
export const TASK_TEMPLATE_BODIES = {
4+
updateTaskTemplate: {
5+
type: UpdateTaskTemplateDto,
6+
description: 'Update framework editor task template data',
7+
},
8+
};
9+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export const TASK_TEMPLATE_OPERATIONS = {
2+
getAllTaskTemplates: {
3+
summary: 'Get all framework editor task templates',
4+
description: 'Retrieve all framework editor task templates',
5+
},
6+
getTaskTemplateById: {
7+
summary: 'Get framework editor task template by ID',
8+
description: 'Retrieve a specific framework editor task template by its ID',
9+
},
10+
updateTaskTemplate: {
11+
summary: 'Update framework editor task template',
12+
description: 'Update a framework editor task template by ID',
13+
},
14+
deleteTaskTemplate: {
15+
summary: 'Delete framework editor task template',
16+
description: 'Delete a framework editor task template by ID',
17+
},
18+
};
19+

0 commit comments

Comments
 (0)