-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ✨ add tasks resolver: getTasks / getUserTasks / createUserTasks/updateUserTasks #101
Conversation
Caution Review failedThe pull request is closed. WalkthroughThis pull request includes significant modifications across multiple files in the Changes
Possibly related issues
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (21)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 23
🧹 Outside diff range and nitpick comments (9)
libs/tasks/domain/src/index.ts (1)
1-4
: Well-structured domain layer exports!The exports are properly organized following clean architecture principles, with clear separation between entities and repository interfaces. This structure will help maintain clear boundaries between different layers of the application.
Consider adding a
README.md
in the domain layer to document:
- The purpose and responsibility of each exported component
- The relationship between entities
- Any invariants or business rules that must be maintained
libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts (2)
8-9
: Add validation and default value for createdAtConsider adding validation and a default value for better usability:
@Field(() => Date) + @IsNotEmpty() + @IsDate() - createdAt: Date; + createdAt: Date = new Date();
3-4
: Add GraphQL documentationConsider adding description to the InputType for better API documentation:
- @InputType() + @InputType({ description: 'Input type for creating a new user task' })libs/tasks/interface-adapters/src/lib/dto/update-user-task.dto.spec.ts (1)
3-14
: Enhance test coverage with additional test casesWhile the basic test is good, consider adding these test cases for better coverage:
- Validation of property types (string for id, Date for updatedAt)
- Edge cases with null/undefined values
- Invalid date formats
Example additional test cases:
it('should throw error for invalid id type', () => { expect(() => new UpdateUserTaskDto(123 as any, new Date())).toThrow(); }); it('should handle null updatedAt', () => { const dto = new UpdateUserTaskDto('123', null); expect(dto.updatedAt).toBeNull(); });libs/tasks/domain/src/lib/entities/user-task.entity.ts (1)
5-15
: Add JSDoc documentation and constructor validationThe class implementation is clean, but would benefit from:
- JSDoc documentation explaining the purpose and usage
- Validation in the constructor for required fields
Example enhancement:
/** * Represents a task assigned to a user * @property {string} id - Unique identifier for the user task * @property {Date} createdAt - Creation timestamp * @property {Date | null} updatedAt - Last update timestamp * ... */ export class UserTask { constructor( public readonly id: string, public readonly createdAt: Date, public readonly updatedAt: Date | null, public readonly taskId: string, public readonly task: Task | null, public readonly userId: string, public readonly user: User | null, ) { if (!id || !taskId || !userId) { throw new Error('Required fields cannot be empty'); } } }libs/tasks/domain/src/lib/task.repository.ts (1)
4-9
: Consider adding pagination support for findAllTasks and findUserTasksFor scalability, these methods should support pagination to handle large datasets efficiently.
Example enhancement:
export interface TaskRepository { findAllTasks(pagination?: { skip: number; take: number }): Promise<{ tasks: Task[]; total: number; }>; findUserTasks( userId: string, range?: { from: Date; to: Date }, pagination?: { skip: number; take: number } ): Promise<{ tasks: Task[]; total: number; }>; // ... }libs/tasks/interface-adapters/src/lib/dto/task.dto.spec.ts (1)
3-29
: Add test cases for edge cases and validation.Current test coverage is basic. Consider adding tests for:
- Empty/invalid categories array
- Empty title validation
- Validation decorator behavior
Example additional test cases:
it('should throw error for empty title', () => { expect(() => new TaskDto('123', '', null, ['category1'])) .toThrow(); }); it('should throw error for empty categories array', () => { expect(() => new TaskDto('123', 'title', null, [])) .toThrow(); }); it('should validate string categories', () => { expect(() => new TaskDto('123', 'title', null, [123] as any)) .toThrow(); });libs/tasks/domain/src/lib/entities/user-task.entity.spec.ts (1)
5-29
: Test implementation looks good, but coverage could be improved.While the basic test case effectively validates the UserTask creation and properties, consider adding the following test cases for better coverage:
- Validation of required vs optional fields
- Error cases with invalid inputs
- Functionality of updatedAt field updates
// Add these test cases it('should throw error when required fields are missing', () => { expect(() => new UserTask(null, new Date(), null, null, null, null, null)) .toThrow(); }); it('should allow updating the updatedAt field', () => { const userTask = new UserTask('id', new Date(), null, 'taskId', task, 'userId', user); const updateDate = new Date(); userTask.updatedAt = updateDate; expect(userTask.updatedAt).toBe(updateDate); });libs/tasks/domain/src/lib/entities/task.entity.spec.ts (1)
3-39
: Tests are well-structured but could use additional edge cases.The current test suite covers the basic scenarios well. Consider adding these test cases for more robust coverage:
- Validation of required fields (id, title)
- Handling of invalid category formats
- Edge cases for title (empty, whitespace-only)
// Add these test cases it('should throw error when required fields are missing', () => { expect(() => new Task(null, null, 'description', [])).toThrow(); expect(() => new Task('id', '', 'description', [])).toThrow(); }); it('should handle whitespace-only title', () => { expect(() => new Task('id', ' ', 'description', [])).toThrow(); }); it('should validate category format', () => { expect(() => new Task('id', 'title', 'description', [123])).toThrow(); expect(() => new Task('id', 'title', 'description', [''])).toThrow(); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (27)
README.md
(0 hunks)libs/tasks/application/src/index.ts
(1 hunks)libs/tasks/application/src/lib/tasks-application.spec.ts
(0 hunks)libs/tasks/application/src/lib/tasks-application.ts
(0 hunks)libs/tasks/application/src/lib/tasks.service.spec.ts
(1 hunks)libs/tasks/application/src/lib/tasks.service.ts
(1 hunks)libs/tasks/domain/src/index.ts
(1 hunks)libs/tasks/domain/src/lib/entities/task.entity.spec.ts
(1 hunks)libs/tasks/domain/src/lib/entities/task.entity.ts
(1 hunks)libs/tasks/domain/src/lib/entities/user-task.entity.spec.ts
(1 hunks)libs/tasks/domain/src/lib/entities/user-task.entity.ts
(1 hunks)libs/tasks/domain/src/lib/task.repository.spec.ts
(1 hunks)libs/tasks/domain/src/lib/task.repository.ts
(1 hunks)libs/tasks/domain/src/lib/tasks-domain.spec.ts
(0 hunks)libs/tasks/domain/src/lib/tasks-domain.ts
(0 hunks)libs/tasks/interface-adapters/src/index.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.spec.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/task.dto.spec.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/task.dto.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/update-user-task.dto.spec.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/update-user-task.dto.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/resolver/tasks.resolver.spec.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/resolver/tasks.resolver.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.spec.ts
(0 hunks)libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.ts
(0 hunks)libs/tasks/interface-adapters/src/lib/tasks.module.ts
(1 hunks)
💤 Files with no reviewable changes (7)
- libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.ts
- libs/tasks/application/src/lib/tasks-application.ts
- libs/tasks/domain/src/lib/tasks-domain.ts
- libs/tasks/application/src/lib/tasks-application.spec.ts
- libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.spec.ts
- libs/tasks/domain/src/lib/tasks-domain.spec.ts
- README.md
✅ Files skipped from review due to trivial changes (2)
- libs/tasks/application/src/index.ts
- libs/tasks/interface-adapters/src/index.ts
🧰 Additional context used
🪛 Biome (1.9.4)
libs/tasks/application/src/lib/tasks.service.ts
[error] 6-6: This constructor is unnecessary.
Unsafe fix: Remove the unnecessary constructor.
(lint/complexity/noUselessConstructor)
🪛 eslint
libs/tasks/application/src/lib/tasks.service.ts
[error] 6-6: Unexpected empty constructor.
(@typescript-eslint/no-empty-function)
libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts
Outdated
Show resolved
Hide resolved
libs/tasks/interface-adapters/src/lib/dto/update-user-task.dto.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 16
🧹 Outside diff range and nitpick comments (6)
libs/tasks/application/src/lib/tasks.service.ts (1)
4-5
: Add service interface documentation.Consider adding JSDoc documentation to describe the service's responsibility and its public API.
/** * Service responsible for managing tasks. * Provides methods for task retrieval and manipulation. */ @Injectable() export class TasksService {libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.ts (2)
22-28
: Improve mutation response type and add validationThe mutation returns a simple string which is not very informative.
// Create a proper response type @ObjectType() class TaskMutationResponse { @Field() success: boolean; @Field({ nullable: true }) message?: string; @Field(() => [String], { nullable: true }) taskIds?: string[]; } @Mutation(() => TaskMutationResponse) async createUserTasks( @Args('userId', { validate: true }) userId: string, @Args('tasks', { validate: true }) tasks: CreateUserTaskDto[], ): Promise<TaskMutationResponse> { try { await this.userTasksService.createSome(userId, tasks); return { success: true, taskIds: tasks.map(t => t.id) }; } catch (error) { return { success: false, message: 'Failed to create tasks' }; } }
30-36
: Add documentation and improve error handlingThe mutation lacks documentation and proper error handling.
/** * Updates multiple user tasks * @param userId - The ID of the user who owns the tasks * @param userTasks - Array of tasks to update * @throws {BadRequestException} When input validation fails * @throws {NotFoundException} When any task is not found */ @Mutation(() => TaskMutationResponse) async updateUserTasks( @Args('userId') userId: string, @Args('userTasks') userTasks: UpdateUserTaskDto[], ): Promise<TaskMutationResponse> { try { await this.userTasksService.updateSome(userId, userTasks); return { success: true, taskIds: userTasks.map(t => t.id) }; } catch (error) { if (error instanceof NotFoundException) { throw error; } throw new InternalServerErrorException('Failed to update tasks'); } }libs/tasks/interface-adapters/src/lib/dto/user-task.dto.spec.ts (1)
34-60
: Add edge case testsThe null value test should be expanded to cover more edge cases.
describe('edge cases', () => { it('should handle undefined values', () => { expect(() => new UserTaskDto( '123', new Date(), undefined, '456', undefined, '789', undefined )).not.toThrow(); }); it('should validate date formats', () => { expect(() => new UserTaskDto( '123', 'invalid-date' as any, // should throw null, '456', null, '789', null )).toThrow(); }); it('should validate ID formats', () => { const dto = new UserTaskDto( 'invalid-id-format', new Date(), null, 'invalid-task-id', null, 'invalid-user-id', null ); const errors = validateSync(dto); expect(errors.length).toBeGreaterThan(0); }); });libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.spec.ts (2)
1-4
: Consider importing types for better type safety.The test file uses types like
Date
in the test cases. Consider importing interfaces for the task-related types to ensure type safety in the test data.import { Test, TestingModule } from '@nestjs/testing'; import { UserTasksService } from '@tasks/application'; +import { CreateUserTaskDto, UpdateUserTaskDto } from '../dto';
6-62
: Consider adding integration and E2E tests.While unit tests are good, consider:
- Adding integration tests with a test database
- Including E2E tests for the GraphQL resolver
- Adding performance tests for bulk operations
- Testing rate limiting and pagination scenarios
This will ensure better coverage of real-world scenarios.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (12)
libs/tasks/application/src/index.ts
(1 hunks)libs/tasks/application/src/lib/tasks.service.spec.ts
(1 hunks)libs/tasks/application/src/lib/tasks.service.ts
(1 hunks)libs/tasks/application/src/lib/user-tasks.service.spec.ts
(1 hunks)libs/tasks/application/src/lib/user-tasks.service.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/user-task.dto.spec.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/user-task.dto.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/resolver/tasks.resolver.spec.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/resolver/tasks.resolver.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.spec.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/tasks.module.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- libs/tasks/application/src/lib/tasks.service.spec.ts
- libs/tasks/interface-adapters/src/lib/resolver/tasks.resolver.ts
🧰 Additional context used
🪛 Biome (1.9.4)
libs/tasks/interface-adapters/src/lib/dto/user-task.dto.ts
[error] 18-18: Don't use 'String' as a type.
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead
(lint/complexity/noBannedTypes)
🪛 eslint
libs/tasks/interface-adapters/src/lib/dto/user-task.dto.ts
[error] 18-18: Prefer using the primitive string
as a type name, rather than the upper-cased String
.
(@typescript-eslint/no-wrapper-object-types)
🔇 Additional comments (6)
libs/tasks/application/src/index.ts (1)
1-2
: LGTM! Clean and focused exports.
The barrel file correctly exports the necessary services, maintaining a clear and organized module structure.
libs/tasks/application/src/lib/tasks.service.ts (1)
6-9
:
Implement repository pattern for task retrieval.
The current implementation is incomplete and lacks proper data access logic.
Consider implementing the repository pattern:
@Injectable()
export class TasksService {
constructor(
@Inject('TaskRepository')
private readonly taskRepository: TaskRepository,
) {}
async findAll(): Promise<Task[]> {
try {
return await this.taskRepository.findAll();
} catch (error) {
throw new InternalServerErrorException('Failed to fetch tasks');
}
}
}
libs/tasks/interface-adapters/src/lib/tasks.module.ts (2)
8-9
:
Add required module dependencies.
The module is missing critical dependencies:
- Database module for persistence
- Repository providers
- Configuration module if needed
Example implementation:
@Module({
imports: [
DatabaseModule,
MongooseModule.forFeature([
{ name: Task.name, schema: TaskSchema },
]),
ConfigModule.forFeature(tasksConfig),
],
providers: [
TasksResolver,
TasksService,
UserTasksResolver,
UserTasksService,
{
provide: 'TaskRepository',
useClass: MongooseTaskRepository,
},
],
exports: [TasksService, UserTasksService],
})
9-10
: Verify resolver and service dependencies.
Let's verify that all required dependencies are properly configured.
✅ Verification successful
Let me gather more information about the services and DTOs to complete the verification.
Let me check the application services and DTOs from the imported paths to complete the verification.
All resolver and service dependencies are properly configured
Based on the verification:
- Both resolvers (
TasksResolver
andUserTasksResolver
) are correctly injected with their respective services - All required DTOs are present and properly imported
- The module correctly imports and provides both services from
@tasks/application
- The module exports both services, allowing them to be used by other modules
- All necessary decorators and types from
@nestjs/graphql
and@nestjs/common
are properly imported
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check resolver implementations and their dependencies
echo "Checking resolver implementations..."
rg -A 5 "class.*Resolver" libs/tasks/interface-adapters/src/lib/resolver/
# Check for missing dependencies
echo "Checking for potential missing dependencies..."
fd -e ts -x grep -l "Repository|Entity|Schema|DTO" {} \;
Length of output: 1510
Script:
#!/bin/bash
# Check service implementations and their dependencies
echo "Checking service implementations..."
rg -A 5 "class.*Service" libs/tasks/interface-adapters/src/lib/service/
# Check DTOs
echo "Checking DTOs..."
fd -e ts -x grep -l "class.*Dto" {} \; libs/tasks/interface-adapters/src/
# Check imports in resolvers
echo "Checking imports in resolvers..."
rg "import.*from" libs/tasks/interface-adapters/src/lib/resolver/
Length of output: 2927
Script:
#!/bin/bash
# Check application services
echo "Checking application services..."
rg -A 5 "class.*Service" libs/tasks/application/src/
# Check DTOs in the application layer
echo "Checking DTOs..."
rg -A 3 "class.*Dto" libs/tasks/interface-adapters/src/lib/dto/
# Check module imports
echo "Checking module imports..."
rg "import.*from" libs/tasks/interface-adapters/src/lib/tasks.module.ts
Length of output: 2747
libs/tasks/application/src/lib/user-tasks.service.ts (1)
22-28
:
Enhance updateSome method with proper validation and error handling
Similar to createSome, this method needs proper implementation and validation:
- Return a more specific type
- Validate input array
- Add transaction support
- Add proper error handling
- Consider optimistic locking for concurrent updates
libs/tasks/interface-adapters/src/lib/resolver/tasks.resolver.spec.ts (1)
1-40
: Add authorization guard tests
Based on previous review comments, authorization guards should be added to the resolver. Add tests to verify the guards are properly applied.
#!/bin/bash
# Check if GqlAuthGuard is properly imported and used
rg -l "GqlAuthGuard" .
ast-grep --pattern '@UseGuards($$$)'
libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.spec.ts
Outdated
Show resolved
Hide resolved
libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.spec.ts
Show resolved
Hide resolved
libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.spec.ts
Show resolved
Hide resolved
libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.spec.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts (2)
6-9
: Add a description to the Field decorator for better documentation.Consider adding a description to improve the GraphQL schema documentation.
- @Field(() => String) + @Field(() => String, { description: 'Unique identifier for the user task' })
14-17
: Consider enhancing the constructor with validation and defaults.The constructor could be improved by adding parameter validation and a default value for createdAt.
- constructor(id: string, createdAt: Date) { + constructor(id: string, createdAt: Date = new Date()) { + if (!id) throw new Error('id is required'); this.id = id; this.createdAt = createdAt; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/user-task.dto.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- libs/tasks/interface-adapters/src/lib/dto/user-task.dto.ts
🔇 Additional comments (1)
libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts (1)
1-5
: LGTM! Proper setup of GraphQL input type.
The imports and class declaration follow NestJS best practices.
libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
libs/tasks/interface-adapters/src/lib/dto/base-task.dto.ts (3)
5-9
: Consider adding documentation and strengthening validation.While the base implementation is solid, consider these enhancements:
- Add JSDoc comments to document the purpose of this base class
- Consider adding
@Matches(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)
to enforce UUID v4 format specifically+/** + * Base DTO class for task-related operations. + * Provides common ID field with UUID validation. + */ @InputType({ isAbstract: true }) export abstract class BaseTaskDto { @Field(() => String) @IsNotEmpty() @IsUUID() + @Matches(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, { + message: 'ID must be a valid UUID v4', + }) id: string;
11-13
: Consider making the constructor protected.Since this is an abstract base class, consider making the constructor protected to enforce proper inheritance usage.
- constructor(id: string) { + protected constructor(id: string) { this.id = id; }
1-14
: Good alignment with clean architecture principles.The placement of this DTO in the
interface-adapters
layer and its role as a base class for GraphQL input types aligns well with clean architecture principles. This separation ensures:
- Clear boundary between GraphQL interface and domain logic
- Consistent validation across all task-related inputs
- Reusability across different GraphQL operations
Consider maintaining this pattern for other entities in the system.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
libs/tasks/interface-adapters/src/lib/dto/base-task.dto.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/update-user-task.dto.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- libs/tasks/interface-adapters/src/lib/dto/update-user-task.dto.ts
- libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts
🔇 Additional comments (2)
libs/tasks/interface-adapters/src/lib/dto/base-task.dto.ts (2)
1-4
: LGTM! Clean imports and proper decorator usage.
The imports are focused and the @InputType
decorator with isAbstract: true
is correctly used to prevent GraphQL from registering this as a concrete type.
1-14
: Verify the integration with derived DTOs.
The base class looks well-structured, but let's verify its usage in derived DTOs to ensure consistent implementation.
✅ Verification successful
Let me check the implementation details of these derived DTOs to ensure they are properly structured.
Integration with derived DTOs is properly implemented
Both CreateUserTaskDto
and UpdateUserTaskDto
correctly extend BaseTaskDto
, properly call the parent constructor with super(id)
, and maintain consistent validation decorators. The inheritance hierarchy and type safety are well-maintained.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check how BaseTaskDto is extended and used across the codebase
# Find all DTOs that extend BaseTaskDto
echo "Checking for classes extending BaseTaskDto:"
ast-grep --pattern 'class $_ extends BaseTaskDto'
# Check for proper constructor calls in derived classes
echo -e "\nChecking constructor implementations in derived classes:"
ast-grep --pattern 'super($_)'
Length of output: 478
Script:
#!/bin/bash
# Check the implementation of derived DTOs
echo "Content of update-user-task.dto.ts:"
cat libs/tasks/interface-adapters/src/lib/dto/update-user-task.dto.ts
echo -e "\nContent of create-user-task.dto.ts:"
cat libs/tasks/interface-adapters/src/lib/dto/create-user-task.dto.ts
Length of output: 1193
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
libs/tasks/interface-adapters/src/lib/dto/task.dto.ts (3)
12-17
: Enhance UUID validation with version and custom messageConsider specifying the UUID version and adding a custom message for better error feedback.
@Field(() => ID) @IsNotEmpty() -@IsUUID() +@IsUUID('4', { message: 'Task ID must be a valid UUID v4' }) id: string;
26-30
: Add custom validation messages for better user feedbackConsider adding descriptive messages to help users understand validation errors.
@Field(() => String, { nullable: true }) @IsOptional() -@IsString() -@MaxLength(1000) +@IsString({ message: 'Description must be a string' }) +@MaxLength(1000, { message: 'Description cannot exceed 1000 characters' }) description: string | null;
32-38
: Enhance array validation with minimum size and custom messagesConsider adding a minimum size requirement and custom messages for better validation feedback.
@Field(() => [String]) -@IsNotEmpty() +@IsNotEmpty({ message: 'Categories array cannot be empty' }) @IsArray() -@IsString({ each: true }) -@MinLength(1, { each: true }) -@MaxLength(255, { each: true }) +@ArrayMinSize(1, { message: 'At least one category is required' }) +@IsString({ each: true, message: 'Each category must be a string' }) +@MinLength(1, { each: true, message: 'Category names cannot be empty' }) +@MaxLength(255, { each: true, message: 'Category names cannot exceed 255 characters' }) categories: string[];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
libs/tasks/domain/src/lib/task.repository.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/task.dto.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/dto/user-task.dto.ts
(1 hunks)libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- libs/tasks/interface-adapters/src/lib/dto/user-task.dto.ts
- libs/tasks/domain/src/lib/task.repository.ts
- libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.ts
🔇 Additional comments (3)
libs/tasks/interface-adapters/src/lib/dto/task.dto.ts (3)
1-10
: LGTM! Clean and well-organized imports
All imported decorators are properly utilized in the code.
19-24
: LGTM! Well-validated title field
The field includes appropriate length constraints and required validations.
40-50
: LGTM! Clean constructor implementation
The constructor properly initializes all fields with correct typing.
🎉 This PR is included in version 1.13.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Related #100 #99
Summary by CodeRabbit
New Features
TasksService
andUserTasksService
for managing tasks and user tasks.Bug Fixes
Tests
Documentation