Skip to content
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] Resource Link Entity #8397

Merged
merged 2 commits into from
Oct 13, 2024
Merged

[Feat] Resource Link Entity #8397

merged 2 commits into from
Oct 13, 2024

Conversation

GloireMutaliko21
Copy link
Contributor

@GloireMutaliko21 GloireMutaliko21 commented Oct 13, 2024

PR

Please note: we will close your PR without comment if you do not check the boxes above and provide ALL requested information.


Description

This pull request introduces a new resource_links table to centralize the management of links associated with various project resources. The goal is to allow users to easily attach relevant links to different entities, such as tasks, modules, or sprints.

For example, when a task requires additional resources for its completion (links to documentation, technical specifications, related support tickets, or associated modules), these references can now be stored and tracked in a single table. This enhances the management of external references, improves visibility of resources needed for each task, and ensures greater consistency in project tracking. The flexible and scalable structure of this table also allows for adding links to new entities without major structural changes.

Note: This PR is base of #8399

@GloireMutaliko21 GloireMutaliko21 self-assigned this Oct 13, 2024
Copy link
Contributor

coderabbitai bot commented Oct 13, 2024

Walkthrough

The pull request introduces significant changes to several files, primarily focusing on the renaming of the ActivityLogEntityEnum to EntityEnum across multiple components. This includes updates to interfaces, classes, and methods that interact with activity logs, ensuring they now reference the new enum. Additionally, a new EntityEnum is defined in base-entity.model.ts, and a new ResourceLink entity is introduced, along with its associated repository files and a migration for creating the resource_link database table.

Changes

File Path Change Summary
packages/contracts/src/activity-log.model.ts Updated IActivityLog to use EntityEnum, removed ActivityLogEntityEnum.
packages/contracts/src/base-entity.model.ts Added new enum EntityEnum with various entity types.
packages/contracts/src/index.ts Added export for EntityEnum and resource-link.model.
packages/contracts/src/resource-link.model.ts Introduced new interfaces: IResourceLink, IResourceLinkCreateInput, IResourceLinkUpdateInput, IResourceLinkFindInput.
packages/core/src/activity-log/activity-log.entity.ts Renamed ActivityLogEntityEnum to EntityEnum in the ActivityLog class.
packages/core/src/activity-log/activity-log.helper.ts Updated function signature to use EntityEnum instead of ActivityLogEntityEnum.
packages/core/src/activity-log/dto/get-activity-logs.dto.ts Replaced ActivityLogEntityEnum with EntityEnum in GetActivityLogsDTO.
packages/core/src/core/entities/index.ts Added new export for ResourceLink.
packages/core/src/core/entities/internal.ts Added export for resource-link.entity.
packages/core/src/database/migrations/1728798743598-CreateResourceLinkTable.ts Introduced migration class for creating resource_link table.
packages/core/src/organization-project-module/organization-project-module.service.ts Renamed ActivityLogEntityEnum to EntityEnum in methods related to activity logging.
packages/core/src/organization-project/organization-project.service.ts Updated create method to use EntityEnum for logging activities.
packages/core/src/organization-sprint/organization-sprint.service.ts Updated methods to replace ActivityLogEntityEnum with EntityEnum.
packages/core/src/resource-link/repository/index.ts Added exports for mikro-orm-resource-link.repository and type-orm-resource-link.repository.
packages/core/src/resource-link/repository/mikro-orm-resource-link.repository.ts Added MikroOrmResourceLinkRepository class.
packages/core/src/resource-link/repository/type-orm-resource-link.repository.ts Added TypeOrmResourceLinkRepository class.
packages/core/src/resource-link/resource-link.entity.ts Introduced ResourceLink class with properties and relationships defined.
packages/core/src/tasks/commands/handlers/task-create.handler.ts Updated TaskCreateHandler to use EntityEnum instead of ActivityLogEntityEnum.
packages/core/src/tasks/task.service.ts Updated TaskService methods to replace ActivityLogEntityEnum with EntityEnum and enhanced task update logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Service
    participant ActivityLog
    participant EntityEnum

    User->>Service: Create/Update Task
    Service->>ActivityLog: Generate Activity Log Description(EntityEnum.Task)
    ActivityLog->>EntityEnum: Use EntityEnum for logging
    ActivityLog-->>Service: Log Activity
    Service-->>User: Return Response
Loading

Possibly related PRs

Suggested reviewers

  • Rahul Rocket

Poem

🐰 In the meadow where code does play,
A new enum hops in, brightening the day.
With links to resources, oh what a sight,
Activity logs now shine so bright!
EntityEnum leads the way,
In our code, it’s here to stay! 🌼


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@GloireMutaliko21 GloireMutaliko21 changed the title Feat/resource links entity [Feat] Resource Link Entity Oct 13, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (11)
packages/core/src/resource-link/repository/mikro-orm-resource-link.repository.ts (1)

4-4: Class definition is correct and follows best practices.

The MikroOrmResourceLinkRepository class is well-defined, extending the appropriate base class with the correct generic type parameter. This approach promotes code reuse and follows the principle of composition over inheritance.

Consider adding a brief class-level JSDoc comment to describe the purpose of this repository class. For example:

/**
 * Repository for managing ResourceLink entities using MikroORM.
 */
export class MikroOrmResourceLinkRepository extends MikroOrmBaseEntityRepository<ResourceLink> {}
packages/contracts/src/resource-link.model.ts (2)

5-13: LGTM: IResourceLink interface is well-defined.

The interface is comprehensive and includes all necessary properties for a resource link. The use of EntityEnum for the entity property ensures type safety, and the optional properties provide flexibility.

Consider adding JSDoc comments to describe the purpose of each property, especially for metaData which can be of two different types.


1-19: Overall, excellent implementation of resource link interfaces.

This file demonstrates a strong understanding of TypeScript and interface design. The use of utility types (Omit, Partial, Pick) is particularly noteworthy, ensuring type safety and flexibility in various operations (create, update, find) on resource links.

To further enhance the code:

  1. Consider adding JSDoc comments for each interface to describe their purpose and usage.
  2. If EntityEnum is extensive, consider adding a type guard or validation function to ensure only valid entities are used.
  3. For metaData in IResourceLink, consider using a union type with a custom interface instead of string | IURLMetaData for more precise typing.

These suggestions are minor and the current implementation is already of high quality.

packages/contracts/src/activity-log.model.ts (1)

Line range hint 1-42: Summary of changes and their impact

The changes in this file are part of a larger refactoring effort to consolidate entity enums. The main modifications include:

  1. Updating the import statement to include EntityEnum.
  2. Changing the entity property in IActivityLog to use EntityEnum.
  3. Removing the ActivityLogEntityEnum.

These changes should improve code organization and reduce duplication. However, it's crucial to ensure that these modifications are consistently applied across the entire codebase to prevent any potential issues.

Consider documenting this architectural change in the project's documentation or changelog to inform other developers about the consolidation of entity enums and its implications for future development.

packages/core/src/activity-log/activity-log.entity.ts (1)

17-20: LGTM. Consider minor formatting improvement.

The @IsEnum decorator and the entity property type have been correctly updated to use EntityEnum. These changes maintain type safety and validation consistency.

Consider adding a blank line before the entity property declaration to improve readability:

 @IsEnum(EntityEnum)
 @ColumnIndex()
 @MultiORMColumn()
+
 entity: EntityEnum;
packages/core/src/tasks/commands/handlers/task-create.handler.ts (2)

78-85: LGTM! Consider enhancing error logging.

The changes correctly implement the use of EntityEnum.Task in place of ActivityLogEntityEnum.Task. The logic for generating and publishing the activity log remains intact.

Consider enhancing the error logging in the catch block to include the task details:

 } catch (error) {
   // Handle errors during task creation
-  this.logger.error(`Error while creating task: ${error.message}`, error.message);
+  this.logger.error(`Error while creating task: ${error.message}`, error.stack, { input });
   throw new HttpException({ message: error?.message, error }, HttpStatus.BAD_REQUEST);
 }

This change would provide more context when debugging task creation errors.


Line range hint 98-107: LGTM! Consider security implications of logging.

The changes correctly implement the use of EntityEnum.Task in the console.log statement. The logged information provides a comprehensive view of the created task and its activity log.

However, logging detailed task information, including potentially sensitive data, may pose a security risk in production environments. Consider the following improvements:

  1. Use a logging level (e.g., debug) that can be easily disabled in production.
  2. Redact or omit sensitive information from the logged data.

Here's a suggested implementation:

if (process.env.NODE_ENV !== 'production') {
  const logData = {
    taskId: task.id,
    entity: EntityEnum.Task,
    action: ActionTypeEnum.Created,
    organizationId,
    tenantId
  };
  this.logger.debug(`Task created: ${JSON.stringify(logData)}`);
}

This approach ensures that detailed logging only occurs in non-production environments and limits the exposed information.

packages/core/src/core/entities/index.ts (1)

Line range hint 1-300: Overall assessment: Changes are correct and consistent.

The addition of the ResourceLink entity to this file is minimal and follows the existing patterns for importing and exporting core entities. The changes maintain the alphabetical order and structure of both the import list and the coreEntities array. These modifications should integrate smoothly with the rest of the codebase.

As the codebase grows, consider implementing a more automated approach for managing entity imports and exports, such as using barrel files or code generation tools. This could help reduce the likelihood of manual errors and make it easier to maintain consistency across the project.

packages/core/src/organization-sprint/organization-sprint.service.ts (2)

123-123: LGTM: EntityEnum usage updated correctly.

The changes from ActivityLogEntityEnum to EntityEnum are correctly implemented in both the generateActivityLogDescription function call and the ActivityLogEvent constructor. These updates are consistent with the enum renaming.

As a minor suggestion, consider updating the comment above the generateActivityLogDescription call to reflect the new enum name for improved code documentation.

Also applies to: 130-130


199-199: LGTM: EntityEnum usage updated correctly in update method.

The changes from ActivityLogEntityEnum to EntityEnum are correctly implemented in both the generateActivityLogDescription function call and the ActivityLogEvent constructor within the update method. These updates are consistent with the enum renaming and match the changes made in the create method.

For consistency with the suggestion made for the create method, consider updating the comment above the generateActivityLogDescription call in this method as well to reflect the new enum name.

Also applies to: 222-222

packages/core/src/resource-link/resource-link.entity.ts (1)

58-59: Update the comment to accurately describe the creator property

The comment currently states User comment author, which may not accurately reflect the purpose of the creator property in the ResourceLink entity. Consider updating the comment to something like User who created the resource link for clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1ce997e and fea108a.

📒 Files selected for processing (19)
  • packages/contracts/src/activity-log.model.ts (1 hunks)
  • packages/contracts/src/base-entity.model.ts (1 hunks)
  • packages/contracts/src/index.ts (2 hunks)
  • packages/contracts/src/resource-link.model.ts (1 hunks)
  • packages/core/src/activity-log/activity-log.entity.ts (2 hunks)
  • packages/core/src/activity-log/activity-log.helper.ts (2 hunks)
  • packages/core/src/activity-log/dto/get-activity-logs.dto.ts (3 hunks)
  • packages/core/src/core/entities/index.ts (2 hunks)
  • packages/core/src/core/entities/internal.ts (1 hunks)
  • packages/core/src/database/migrations/1728798743598-CreateResourceLinkTable.ts (1 hunks)
  • packages/core/src/organization-project-module/organization-project-module.service.ts (4 hunks)
  • packages/core/src/organization-project/organization-project.service.ts (2 hunks)
  • packages/core/src/organization-sprint/organization-sprint.service.ts (4 hunks)
  • packages/core/src/resource-link/repository/index.ts (1 hunks)
  • packages/core/src/resource-link/repository/mikro-orm-resource-link.repository.ts (1 hunks)
  • packages/core/src/resource-link/repository/type-orm-resource-link.repository.ts (1 hunks)
  • packages/core/src/resource-link/resource-link.entity.ts (1 hunks)
  • packages/core/src/tasks/commands/handlers/task-create.handler.ts (3 hunks)
  • packages/core/src/tasks/task.service.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/core/src/resource-link/repository/index.ts
🧰 Additional context used
🔇 Additional comments (44)
packages/core/src/resource-link/repository/mikro-orm-resource-link.repository.ts (2)

1-2: Imports look good!

The imports are appropriate and necessary for the implementation of the MikroOrmResourceLinkRepository class. They follow a clear and organized project structure.


1-4: Overall, this is a well-implemented repository class.

The MikroOrmResourceLinkRepository is correctly set up to handle ResourceLink entities using MikroORM. It follows best practices by extending the base repository class and leveraging inheritance for code reuse. The file structure and naming conventions are consistent with the project's organization.

Great job on keeping the implementation concise and focused!

packages/core/src/resource-link/repository/type-orm-resource-link.repository.ts (4)

1-4: Imports look good!

The necessary dependencies are correctly imported, and the import order follows a common convention. There are no unused imports.


6-7: Class declaration and decorator are well-implemented!

The @Injectable() decorator is correctly used, allowing for dependency injection. The class properly extends Repository<ResourceLink>, following TypeORM's custom repository pattern. The class name adheres to the naming convention for TypeORM repositories.


8-10: Constructor implementation is correct and follows best practices!

The constructor correctly uses @InjectRepository(ResourceLink) for dependency injection. The call to the super constructor with repository.target, repository.manager, and repository.queryRunner is the proper way to extend the Repository class in TypeORM. This implementation ensures that the custom repository has access to all the necessary TypeORM functionality.


1-11: Overall, excellent implementation of the TypeOrmResourceLinkRepository!

The file introduces a well-structured and correctly implemented custom repository for the ResourceLink entity. It follows TypeORM and NestJS best practices, including proper use of decorators, dependency injection, and extension of the base Repository class. The code is concise and clear, making it easy to understand and maintain.

packages/contracts/src/resource-link.model.ts (4)

1-3: LGTM: Import statements are well-organized and relevant.

The import statements are concise and import only the necessary types and interfaces. This approach helps maintain a clean and modular codebase.


15-15: LGTM: IResourceLinkCreateInput is well-defined.

The use of the Omit utility type to create a new interface based on IResourceLink without the creator and creatorId properties is a good TypeScript practice. This approach ensures type safety when creating new resource links.


17-17: LGTM: IResourceLinkUpdateInput is well-crafted.

The interface definition demonstrates advanced use of TypeScript utility types. By using Partial and Omit together, it allows for flexible updates of resource links while preventing changes to core identifiers (entity and entityId). This approach ensures type safety and maintains data integrity during updates.


19-19: LGTM: IResourceLinkFindInput is concise and purposeful.

The use of the Pick utility type to create a minimal interface for finding resource links is excellent. By selecting only the entity and entityId properties, it provides a clear and type-safe way to query resource links based on their core identifiers.

packages/core/src/activity-log/activity-log.helper.ts (2)

16-16: Approve the function signature update and verify its usage.

The function signature has been correctly updated to use EntityEnum instead of ActivityLogEntityEnum, which is consistent with the import statement change.

To ensure that all callers of this function have been updated accordingly, please run the following script:

#!/bin/bash
# Description: Verify the usage of generateActivityLogDescription function

# Test 1: Check for any remaining usage of generateActivityLogDescription with ActivityLogEntityEnum
echo "Checking for any remaining usage of generateActivityLogDescription with ActivityLogEntityEnum:"
rg --type typescript "generateActivityLogDescription\s*\([^)]*ActivityLogEntityEnum"

# Test 2: Verify the correct usage of generateActivityLogDescription with EntityEnum
echo "Verifying the correct usage of generateActivityLogDescription with EntityEnum:"
rg --type typescript "generateActivityLogDescription\s*\([^)]*EntityEnum"

# Test 3: List all files using generateActivityLogDescription for manual review
echo "Listing all files using generateActivityLogDescription for manual review:"
rg --type typescript -l "generateActivityLogDescription"

This script will help identify any inconsistencies in the usage of the generateActivityLogDescription function across the codebase.


1-1: Verify the consistency of enum renaming across the codebase.

The import statement has been updated to use EntityEnum instead of ActivityLogEntityEnum. This change suggests a broader refactoring of enum types in the project.

To ensure consistency and identify any potential issues, please run the following script:

This script will help identify any inconsistencies or files that might need further updates.

✅ Verification successful

Enum renaming is consistent across the codebase.

All instances of ActivityLogEntityEnum have been successfully replaced with EntityEnum, and the new enum is consistently used throughout the repository.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of ActivityLogEntityEnum and verify EntityEnum usage

# Test 1: Check for any remaining usage of ActivityLogEntityEnum
echo "Checking for any remaining usage of ActivityLogEntityEnum:"
rg --type typescript "ActivityLogEntityEnum"

# Test 2: Verify the correct usage of EntityEnum
echo "Verifying the correct usage of EntityEnum:"
rg --type typescript "EntityEnum"

# Test 3: Check for any files that might need updating
echo "Checking for files that might need updating:"
rg --type typescript -l "ActivityLogEntityEnum|EntityEnum"

Length of output: 847


Script:

#!/bin/bash
# Description: Re-check for any remaining usage of ActivityLogEntityEnum and verify EntityEnum usage with corrected file type.

# Test 1: Check for any remaining usage of ActivityLogEntityEnum
echo "Checking for any remaining usage of ActivityLogEntityEnum:"
rg --type ts "ActivityLogEntityEnum"

# Test 2: Verify the correct usage of EntityEnum
echo "Verifying the correct usage of EntityEnum:"
rg --type ts "EntityEnum"

# Test 3: Check for any files that might need updating
echo "Checking for files that might need updating:"
rg --type ts -l "ActivityLogEntityEnum|EntityEnum"

Length of output: 9661

packages/contracts/src/activity-log.model.ts (3)

1-1: LGTM: Import statement updated correctly

The import statement has been appropriately updated to include EntityEnum from the base-entity.model file. This change aligns with the usage of EntityEnum in the IActivityLog interface.


Line range hint 1-42: Verify completeness of EntityEnum and update usages

The removal of ActivityLogEntityEnum is noted. This change simplifies the entity representation by relying on EntityEnum. However, it's crucial to ensure that this change doesn't introduce any regressions.

Please verify the following:

  1. Ensure that EntityEnum in base-entity.model covers all the cases that were previously in ActivityLogEntityEnum.
  2. Update all previous usages of ActivityLogEntityEnum throughout the codebase.

Run the following script to assist with this verification:

#!/bin/bash
# Description: Check for any remaining usage of ActivityLogEntityEnum and compare with EntityEnum

# Search for any remaining usage of ActivityLogEntityEnum
echo "Searching for any remaining usage of ActivityLogEntityEnum:"
rg --type typescript "ActivityLogEntityEnum"

# Display the contents of EntityEnum for manual verification
echo "Contents of EntityEnum (for manual verification):"
rg --type typescript -A 20 "export enum EntityEnum"

Please review the output to ensure all necessary entities are included in EntityEnum and update any remaining usages of ActivityLogEntityEnum.


8-8: Verify usage of updated IActivityLog interface

The change from ActivityLogEntityEnum to EntityEnum for the entity property is correct and aligns with the removal of ActivityLogEntityEnum. However, this change might affect other parts of the codebase that use the IActivityLog interface.

Please run the following script to verify the usage of IActivityLog and ensure that all occurrences are updated accordingly:

✅ Verification successful

Verification Successful: No Remaining Usage of ActivityLogEntityEnum

The ActivityLogEntityEnum is no longer used in the codebase, and the IActivityLog interface is correctly utilized across various modules. The interface change aligns with the overall codebase updates and poses no issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of ActivityLogEntityEnum and verify IActivityLog usage

# Search for any remaining usage of ActivityLogEntityEnum
echo "Searching for any remaining usage of ActivityLogEntityEnum:"
rg --type typescript "ActivityLogEntityEnum"

# Search for usage of IActivityLog
echo "Verifying usage of IActivityLog:"
rg --type typescript "IActivityLog"

Length of output: 406


Script:

#!/bin/bash
# Description: Check for any remaining usage of ActivityLogEntityEnum and verify IActivityLog usage

# Search for any remaining usage of ActivityLogEntityEnum in TypeScript files
echo "Searching for any remaining usage of ActivityLogEntityEnum in TypeScript files:"
rg --glob "*.ts" --glob "*.tsx" "ActivityLogEntityEnum"

# Search for usage of IActivityLog in TypeScript files
echo "Verifying usage of IActivityLog in TypeScript files:"
rg --glob "*.ts" --glob "*.tsx" "IActivityLog"

Length of output: 3656

packages/core/src/activity-log/dto/get-activity-logs.dto.ts (4)

3-3: LGTM: Import statement updated correctly

The import statement has been updated to use EntityEnum instead of ActivityLogEntityEnum. This change is consistent with the refactoring mentioned in the summary and appears to be correct.


21-21: LGTM: Swagger decorator simplified

The @ApiPropertyOptional decorator for the entity property has been simplified to directly use EntityEnum. This change improves readability and is consistent with best practices for using enums with Swagger decorators.


Line range hint 1-58: Overall assessment: Changes look good

The changes in this file are consistent with the described refactoring effort to replace ActivityLogEntityEnum with a more generic EntityEnum. The modifications improve code consistency and simplify Swagger decorators. No issues were found in the changes.

However, it's important to ensure that this refactoring has been applied consistently across the entire codebase. Please review the results of the verification script to confirm that all necessary updates have been made.


23-24: LGTM: Entity property type updated correctly

The entity property has been correctly updated to use EntityEnum for both the @IsEnum decorator and the property type. This change ensures type safety and proper validation.

To ensure consistency across the codebase, please run the following script to verify the usage of EntityEnum:

✅ Verification successful

Let's correct the shell script to use file extensions instead of the unrecognized typescript type.


LGTM: Entity property type updated correctly

The entity property has been correctly updated to use EntityEnum for both the @IsEnum decorator and the property type. This change ensures type safety and proper validation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of EntityEnum across the codebase

# Test: Search for EntityEnum usage
echo "Searching for EntityEnum usage:"
rg --type typescript "EntityEnum" -g "!*.spec.ts"

# Test: Check for any remaining references to ActivityLogEntityEnum
echo "Checking for any remaining references to ActivityLogEntityEnum:"
rg --type typescript "ActivityLogEntityEnum" -g "!*.spec.ts"

Length of output: 390


Script:

#!/bin/bash
# Description: Verify the usage of EntityEnum across the codebase

# Test: Search for EntityEnum usage
echo "Searching for EntityEnum usage:"
rg "EntityEnum" -g "*.ts" -g "*.tsx"

# Test: Check for any remaining references to ActivityLogEntityEnum
echo "Checking for any remaining references to ActivityLogEntityEnum:"
rg "ActivityLogEntityEnum" -g "*.ts" -g "*.tsx"

Length of output: 8268

packages/core/src/activity-log/activity-log.entity.ts (3)

15-15: LGTM. API property updated correctly.

The @ApiProperty decorator has been properly updated to reference EntityEnum. This change ensures that the API documentation remains consistent with the code changes.


Line range hint 1-114: Summary: Enum renaming implemented correctly.

The renaming of ActivityLogEntityEnum to EntityEnum has been consistently applied throughout the ActivityLog entity. The changes maintain the functionality and structure of the class while updating the necessary references. The modifications to imports, decorators, and property types are all in line with the intended change.


6-6: LGTM. Verify enum usage across the codebase.

The import statement has been correctly updated to use EntityEnum instead of ActivityLogEntityEnum. This change is consistent with the renaming of the enum.

To ensure that this change doesn't introduce any issues, please verify the usage of EntityEnum across the codebase:

✅ Verification successful

Verification Successful: ActivityLogEntityEnum Renamed to EntityEnum

All references to ActivityLogEntityEnum have been successfully removed. The EntityEnum is correctly utilized across the codebase without introducing any inconsistencies.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of EntityEnum across the codebase

# Test 1: Check for any remaining references to ActivityLogEntityEnum
echo "Checking for any remaining references to ActivityLogEntityEnum:"
rg --type typescript "ActivityLogEntityEnum"

# Test 2: Verify the correct usage of EntityEnum
echo "Verifying the correct usage of EntityEnum:"
rg --type typescript "EntityEnum"

Length of output: 380


Script:

#!/bin/bash
# Description: Verify the usage of EntityEnum across the codebase

# Test 1: Check for any remaining references to ActivityLogEntityEnum
echo "Checking for any remaining references to ActivityLogEntityEnum:"
rg --type ts "ActivityLogEntityEnum"

# Test 2: Verify the correct usage of EntityEnum
echo "Verifying the correct usage of EntityEnum:"
rg --type ts "EntityEnum"

Length of output: 8268

packages/core/src/tasks/commands/handlers/task-create.handler.ts (1)

3-3: LGTM! Verify enum usage across the codebase.

The import statement has been correctly updated to use EntityEnum instead of ActivityLogEntityEnum. This change is consistent with the refactoring mentioned in the summary.

To ensure consistency across the codebase, run the following script to check for any remaining usage of ActivityLogEntityEnum:

packages/core/src/core/entities/index.ts (2)

120-120: LGTM: Import statement addition is correct.

The ResourceLink entity has been properly added to the import list, maintaining the alphabetical order and consistent with the existing structure.


270-270: LGTM: CoreEntities array updated correctly.

The ResourceLink entity has been properly added to the coreEntities array, maintaining the alphabetical order and consistent with the existing structure. This change ensures that the new entity is exported and available for use in other parts of the application.

To ensure the ResourceLink entity is properly defined and imported, please run the following verification script:

This script will help verify that the ResourceLink entity is properly defined and imported, reducing the likelihood of any integration issues.

packages/contracts/src/index.ts (3)

108-108: LGTM: New model export added correctly

The export statement for 'resource-link.model' has been added correctly, maintaining the alphabetical order and following the existing pattern of export statements in this file.


Line range hint 108-149: Summary: New model added and EntityEnum exported

The changes in this file are consistent and well-structured. They include:

  1. Adding an export for a new 'resource-link.model'.
  2. Including 'EntityEnum' in the named exports from 'base-entity.model'.

These changes suggest modifications to the underlying models, which may have implications for other parts of the codebase.

To ensure these changes are properly integrated, please run the following verification:

#!/bin/bash
# Description: Verify the usage of ResourceLink and EntityEnum in the codebase

# Test 1: Check for imports of ResourceLink
echo "Checking ResourceLink imports:"
rg --type typescript 'import.*ResourceLink' packages

# Test 2: Check for usage of EntityEnum
echo "Checking EntityEnum usage:"
rg --type typescript 'EntityEnum\.' packages

# Test 3: Check for any TODOs related to these changes
echo "Checking for related TODOs:"
rg --type typescript 'TODO.*(?:ResourceLink|EntityEnum)' packages

This will help ensure that the new model and enum are being used correctly throughout the project.


148-149: LGTM: EntityEnum added to named exports

The 'EntityEnum' has been correctly added to the named exports from 'base-entity.model'. The necessary syntactical change (adding a comma after 'JsonData') has been made correctly.

To ensure consistency, please verify the 'EntityEnum' in 'base-entity.model':

✅ Verification successful

Verified: EntityEnum correctly added to named exports

The presence of EntityEnum in base-entity.model.ts has been confirmed. The named export in index.ts has been updated appropriately.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence and structure of EntityEnum in base-entity.model.ts

# Test: Search for EntityEnum in base-entity.model.ts
rg --type typescript -A 10 'export enum EntityEnum' packages/contracts/src/base-entity.model.ts

Length of output: 473


Script:

#!/bin/bash
# Description: Verify the presence and structure of EntityEnum in base-entity.model.ts

# Test: Search for 'export enum EntityEnum' directly in the specified file
rg 'export enum EntityEnum' packages/contracts/src/base-entity.model.ts

Length of output: 98

packages/core/src/organization-sprint/organization-sprint.service.ts (2)

5-5: LGTM: Import statement updated correctly.

The import of EntityEnum from @gauzy/contracts is consistent with the renaming mentioned in the summary. This change is correctly implemented and maintains the existing import structure.


Line range hint 1-368: Summary: EntityEnum renaming successfully implemented.

The changes in this file consistently and correctly implement the renaming of ActivityLogEntityEnum to EntityEnum. This update affects the import statement and usage within the create and update methods of the OrganizationSprintService class. The changes are minimal and do not alter the overall logic or functionality of the service.

Key points:

  1. Import statement updated correctly.
  2. EntityEnum used consistently in activity log generation and event publishing.
  3. No other significant changes or issues introduced.

These changes improve consistency with the rest of the codebase and should not introduce any new bugs or issues. The refactoring appears to be successful and well-executed.

packages/core/src/core/entities/internal.ts (1)

124-124: LGTM: New entity export added correctly.

The new export for resource-link.entity has been added correctly:

  1. It's placed in the appropriate alphabetical order among other entity exports.
  2. The import path follows the consistent pattern used for other entity imports.
  3. Adding this entity to the public API of the core module seems intentional, likely to support the new ResourceLink functionality mentioned in the PR summary.

To ensure the ResourceLink entity is properly implemented, let's verify its existence and basic structure:

✅ Verification successful

: The ResourceLink entity has been successfully added and correctly exported in packages/core/src/core/entities/internal.ts. The entity file exists and is properly structured, ensuring seamless integration into the core module's public API.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the ResourceLink entity file exists and check its basic structure
if [ -f "packages/core/src/resource-link/resource-link.entity.ts" ]; then
    echo "ResourceLink entity file exists."
    echo "File contents:"
    cat "packages/core/src/resource-link/resource-link.entity.ts"
else
    echo "Error: ResourceLink entity file not found."
fi

Length of output: 2619

packages/core/src/organization-project-module/organization-project-module.service.ts (3)

6-6: LGTM: Import statement updated correctly

The import statement has been updated to use EntityEnum instead of ActivityLogEntityEnum, which is consistent with the reported changes. This modification ensures that the correct enum is imported and used throughout the file.


Line range hint 1-486: Overall assessment: Changes are consistent and well-implemented

The renaming of ActivityLogEntityEnum to EntityEnum has been carried out consistently throughout this file. The changes are limited to the import statement and usage within the create and update methods, which is in line with the expected scope of the modification. The rest of the file remains unchanged, indicating that existing functionality has been preserved.

To ensure the completeness of this change across the entire codebase, it's recommended to run the verification script provided in the previous comment. This will help identify any instances of ActivityLogEntityEnum that might have been overlooked in other files.


57-57: LGTM: Enum usage updated correctly

The ActivityLogEntityEnum has been consistently replaced with EntityEnum in both the create and update methods. This change aligns with the reported enum renaming and maintains the existing functionality.

To ensure all instances of ActivityLogEntityEnum have been updated throughout the codebase, please run the following verification script:

This will help identify any places where the old enum name might still be in use.

Also applies to: 64-64, 116-116, 128-128

✅ Verification successful

Verification Successful: No remaining instances of ActivityLogEntityEnum found

All instances of ActivityLogEntityEnum have been successfully replaced with EntityEnum in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of ActivityLogEntityEnum
rg --type typescript "ActivityLogEntityEnum"

Length of output: 79


Script:

#!/bin/bash
# Search for any remaining instances of ActivityLogEntityEnum in TypeScript files
rg "ActivityLogEntityEnum" --glob "*.ts" --glob "*.tsx"

Length of output: 55

packages/core/src/organization-project/organization-project.service.ts (4)

6-6: Import statement updated correctly

The import statement has been properly updated to use the new EntityEnum instead of ActivityLogEntityEnum. This change is consistent with the reported enum renaming.


131-131: Enum usage updated correctly in create method

The create method has been updated to use EntityEnum.OrganizationProject instead of ActivityLogEntityEnum.OrganizationProject. This change is consistent and correct in both instances (lines 131 and 138).

Also applies to: 138-138


Line range hint 1-624: Summary of changes: Enum renaming implemented correctly

The changes in this file are minimal and focused on renaming ActivityLogEntityEnum to EntityEnum. The implementation is correct and consistent throughout the file. The main impacts are:

  1. Updated import statement to use EntityEnum.
  2. Updated usage in the create method to use EntityEnum.OrganizationProject.

These changes should not affect the functionality of the OrganizationProjectService class. However, it's important to ensure that this renaming has been applied consistently across the entire codebase to prevent any potential issues.


Line range hint 1-624: Enum renaming applied consistently

After reviewing the entire file, it appears that the renaming of ActivityLogEntityEnum to EntityEnum has been applied consistently. No instances of the old enum name were found, and all relevant usages have been updated correctly.

However, to ensure complete consistency across the codebase, it would be beneficial to verify that this renaming has been applied in all other files where ActivityLogEntityEnum might have been used.

To verify the consistent application of this change across the codebase, you can run the following script:

✅ Verification successful

Enum renaming applied consistently

After executing the verification scripts, no instances of ActivityLogEntityEnum were found in organization-project.service.ts. The use of EntityEnum has been updated correctly throughout the file. The renaming appears to be consistently applied in this context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of ActivityLogEntityEnum in the codebase

# Search for any remaining instances of ActivityLogEntityEnum
echo "Searching for remaining instances of ActivityLogEntityEnum:"
rg --type typescript "ActivityLogEntityEnum"

# Search for usage of EntityEnum to confirm correct usage
echo "Confirming usage of EntityEnum:"
rg --type typescript "EntityEnum"

Length of output: 350


Script:

#!/bin/bash
# Description: Check for any remaining instances of ActivityLogEntityEnum in the codebase

# Search for any remaining instances of ActivityLogEntityEnum in .ts and .tsx files
echo "Searching for remaining instances of ActivityLogEntityEnum:"
rg "ActivityLogEntityEnum" --glob "*.ts" --glob "*.tsx"

# Search for usage of EntityEnum in .ts and .tsx files to confirm correct usage
echo "Confirming usage of EntityEnum:"
rg "EntityEnum" --glob "*.ts" --glob "*.tsx"

Length of output: 8276

packages/core/src/resource-link/resource-link.entity.ts (1)

66-67: Re-evaluate the onDelete: 'CASCADE' behavior for the creator relationship

Setting onDelete: 'CASCADE' on the creator relationship means that when a user is deleted, all associated resource links they created will also be deleted. This could lead to unintended data loss. Verify if this is the desired behavior. If you want to preserve resource links even after the creator is deleted, consider changing the onDelete option to SET NULL and updating nullable to true to allow for orphaned resource links.

packages/core/src/database/migrations/1728798743598-CreateResourceLinkTable.ts (2)

178-215: Check Data Type Compatibility for Boolean Fields in MySQL

In the MySQL migration (lines 184-185), the isActive and isArchived fields are defined as tinyint. While MySQL does not have a native boolean type, using tinyint(1) is common practice. Ensure that the application handles these fields correctly as booleans.

Confirm that the ORM and application logic correctly interpret these tinyint fields as booleans in MySQL.


61-61: Verify Availability of gen_random_uuid() Function in Postgres

The function gen_random_uuid() used for default UUID generation may require the pgcrypto extension, which is not enabled by default in all PostgreSQL installations.

Ensure that the pgcrypto extension is enabled in your PostgreSQL database. If not, you can enable it by running:

Alternatively, consider using uuid_generate_v4() from the uuid-ossp extension if it's preferred in your environment.

packages/core/src/tasks/task.service.ts (3)

119-119: Check compatibility of EntityEnum.Task in ActivityLogEvent.

When publishing the ActivityLogEvent, the entity field is now set to EntityEnum.Task. Ensure that ActivityLogEvent and all consumers of this event are compatible with EntityEnum values to maintain consistent activity logging.

To verify, examine the definition of ActivityLogEvent and its usage:

#!/bin/bash
# Description: Check the definition of ActivityLogEvent and instances where 'entity' is assigned.

# Check the ActivityLogEvent class definition
rg --type ts 'class ActivityLogEvent' -A 10

# Find all usages of ActivityLogEvent where 'entity' is set
rg --type ts 'new ActivityLogEvent' -A 10

17-17: Verify the replacement of ActivityLogEntityEnum with EntityEnum.

The import statement replaces ActivityLogEntityEnum with EntityEnum. Ensure that EntityEnum includes all the necessary values previously provided by ActivityLogEntityEnum to prevent any unexpected issues in activity logging.

To verify that EntityEnum contains the required values, run the following script:


107-107: Ensure generateActivityLogDescription handles EntityEnum.Task correctly.

The call to generateActivityLogDescription now uses EntityEnum.Task instead of ActivityLogEntityEnum.Task. Confirm that this function accepts EntityEnum values and generates the correct descriptions for task-related activity logs.

To verify, search for the usage of generateActivityLogDescription and check its handling of EntityEnum:

✅ Verification successful

generateActivityLogDescription correctly handles EntityEnum.Task.

All usages of generateActivityLogDescription with EntityEnum.Task are properly managed, ensuring accurate activity log descriptions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usages of generateActivityLogDescription and inspect parameter types.

rg --type ts 'generateActivityLogDescription' -A 3

Length of output: 9152


Script:

#!/bin/bash
# Description: Locate the definition of generateActivityLogDescription and inspect its parameters.

fd generateActivityLogDescription --type ts | xargs -I {} ast-grep --lang typescript --pattern $'function generateActivityLogDescription($_)' {}

Length of output: 319


Script:

#!/bin/bash
# Description: Find all calls to generateActivityLogDescription and inspect the arguments passed.

rg --type ts 'generateActivityLogDescription' -A 5

Length of output: 8982


Script:

#!/bin/bash
# Description: Locate the definition of ActivityTemplates and inspect its contents.

rg 'const ActivityTemplates' -A 20

Length of output: 2169


Script:

#!/bin/bash
# Description: Find all templates related to EntityEnum.Task within ActivityTemplates.

rg 'ActivityTemplates.*EntityEnum.Task' -A 10

Length of output: 47

Copy link

nx-cloud bot commented Oct 13, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit fea108a. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
nx build desktop-ui --prod --base-href ./
nx build gauzy -c=production --prod --verbose
✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

@evereq evereq merged commit 7c19f6a into develop Oct 13, 2024
17 of 20 checks passed
@evereq evereq deleted the feat/resource-links-entity branch October 13, 2024 15:05
evereq added a commit that referenced this pull request Oct 13, 2024
* fix: #8339 employee & organization parameters to URLs

* fix: #8339 project parameters to URLs

* fix: #8339 date range picker parameters to URLs

* fix: #8339 project parameters to URLs

* fix: don't merge new config with old default config

* fix: don't merge new config with old default config

* fix: organization controller and module improvement

* feat: add standardWorkHoursPerDay column to organization entity

* feat: #8341 add standardWorkHoursPerDay column migration to organization entity

* feat: #8341 add standardWorkHoursPerDay column migration to organization table

* feat: #8341 add standardWorkHoursPerDay column migration to tenant table

* fix: create/update standard work hours per day

* feat: get task by view query model

* feat: get task by view query DTO

* feat: get tasks by view filter API

* fix: save standard work hours per day for organization

* fix: get tasks by view filters

* fix: remove unused DTO

* chore(deps): add chartjs-plugin-annotation

chore: add chartjs-plugin-annotation package for annotation support in charts

* fix: organization ID filter in query

* feat: add translations for Standard Work Hours

* feat: #8341 added horizontal dotted line

* fix(deepscan): removed unused import

* fix(coderrabitai): improve types and finders

* fix: sprint DELETE role permission

* fix: improve sprints role permissions

* fix: #8340 clear data before loading on report pages

* fix: issue type value using enum

* fix(deepscan): removed unused import

* feat: #8339 bookmark query params builder resolver

* [Feat] Add new workspace's methods to desktop authentication service (#8375)

* feat: add new methods to service

* feat: remove unecessary try-catch blocks and type annotations for return values in AuthService methods.

* [Feat] Create Reusable Component and Add Workspace Links (#8383)

* feat: export social links

* feat: create a shared logo component

* feat: create a shared social links component

* feat: add reusable patterns to constants

* feat: add link to magic workspace signin and use reusable logo, links and switch

* feat: SwitchThemeModule, LogoComponent, and SocialLinksComponent to NgxLoginModule

* fix(cspell): typo spelling :-)

* fix: improvement suggested by CodeRabbit

* fix: improvement suggested by CodeRabbit

* fix: improvement suggested by CodeRabbit

* fix: task type enum swagger

* fix: issue type enum

* feat: #8386 add module and entity for global logging of API

* feat: #8386 add repository and subscriber for global logging of API

* feat: #8386 table migration for "api_call_log" table

* fix: #8386 circular dependency injection in repository

* [Fix] Edit team functionality not working

* feat: #8386 retrieves call logs API

* fix(deepscan): property is accessed without null check

* fix: missing role-permission module

* fix: better encapsulation and reducing coupling between modules

* fix: task view not found update command handler

* [Fix] Filters not working

* fix: #8386 added origin into `api_call_log`  table

* [Feat] Implement magic login (#8387)

* feat: create reusable workspace selection component

* feat: create debounce click directive

* feat: create reusable avatar component

* feat: implement login magic component

* feat: implement login magic workspace component

* feat: implement login workspace component

* feat: reuse shared core styles

* feat: add new component to login

* feat: create authentication routes

* feat: use lazy loading for authentications routes

* fix: add code rabbit suggestions

* fix: apply code rabbit suggestions

* fix: apply code rabbit suggestions

* [Fix] Task deselect on refresh (#8392)

* fix: task deselect on refresh

* fix: add `organizationTeamId` missing property to time tracker API request and spread `arg.timer` into the request object.

* fix: apply code rabbit suggestion

* [Fix] Edit contact for (client,customers,leads) functionality not working  (#8393)

* [Fix] Edit contact for (client,customers,leads) functionality not working

* Remove member deletion

* [Fix] Remote timer logic stop calls (#8394)

* fix: remote timer logic and stopTimer calls

* refactor: remote timer logic

* [Feat] Resource Link Entity (#8397)

* feat: add resource link model and entity

* feat: resource link migration

* [Feat] Resource Link API (#8399)

* feat: add resource link model and entity

* feat: resource link migration

* feat: add resource link service

* feat: resource link commands

* feat: add resource link handlers

* feat: add resource link subscriber

* feat: add resource link controller and DTO

* chore: desktop builds on Windows

---------

Co-authored-by: Rahul R. <rahulrathore576@gmail.com>
Co-authored-by: GloireMutaliko21 <mufunyig@gmail.com>
Co-authored-by: Kifungo A <45813955+adkif@users.noreply.github.com>
Co-authored-by: samuelmbabhazi <samuelmbabhazi@gmail.com>
Co-authored-by: samuel mbabhazi <111171386+samuelmbabhazi@users.noreply.github.com>
Co-authored-by: Gloire Mutaliko (Salva) <86450367+GloireMutaliko21@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants