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: move create workflow to app gen package #5396

Conversation

djabarovgeorge
Copy link
Contributor

@djabarovgeorge djabarovgeorge commented Apr 10, 2024

What change does this PR introduce?

Refactor the code so we would reuse the same logic and not maintain duplicated code.

Why was this change needed?

Other information (Screenshots)

EE REF

Summary by CodeRabbit

  • New Features

    • Enhanced message template capabilities with new properties and stricter type checks.
    • Introduced new workflow steps and types for more flexible notification templates.
    • Updated application dependencies to improve functionality and security.
  • Refactor

    • Simplified module loading in the application setup.
    • Streamlined use cases for creating and updating message templates and workflows.
    • Improved service methods in content management for better performance and error handling.
  • Bug Fixes

    • Removed duplicate imports and outdated functions to ensure smoother operations.
  • Style

    • Reorganized imports and code structure across various modules for better readability and maintenance.

Copy link

linear bot commented Apr 10, 2024

Copy link

netlify bot commented Apr 10, 2024

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit f07d9b5
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/661d65d544afd7000888916a
😎 Deploy Preview https://deploy-preview-5396--dev-web-novu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Apr 10, 2024

Deploy Preview for novu-design ready!

Name Link
🔨 Latest commit f07d9b5
🔍 Latest deploy log https://app.netlify.com/sites/novu-design/deploys/661d65d5aa0d78000810b9e7
😎 Deploy Preview https://deploy-preview-5396--novu-design.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@djabarovgeorge djabarovgeorge marked this pull request as ready for review April 15, 2024 09:36
@djabarovgeorge
Copy link
Contributor Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Apr 15, 2024

Walkthrough

The recent updates focus on refining the codebase across various modules, enhancing readability, and improving error handling. Key changes include the restructuring of imports and exports, updating dependencies, and introducing new utility functions and enums. The modifications also extend to entity and schema updates, particularly with the addition of new properties and types. Overall, these changes aim to streamline processes and enforce stricter type checks, thereby increasing the robustness of the application.

Changes

File Path Change Summary
.../app.module.ts Simplified conditional loading of enterprise modules based on environment variables.
.../app/change/usecases/index.ts
.../app/message-template/usecases/index.ts
.../app/workflows/usecases/index.ts
.../application-generic/src/usecases/index.ts
Streamlined imports and exports for various use cases.
.../create-layout/create-layout.use-case.ts
.../update-notification-template/update-notification-template.usecase.ts
Reordered imports; removed and replaced some functions and decorators.
.../update-message-template/update-message-template.command.ts
.../update-message-template/update-message-template.usecase.ts
Updated property types and handling logic; added IsString decorator.
.../shared/dtos/message-template.ts
.../dal/src/repositories/message-template/message-template.entity.ts
.../dal/src/repositories/message-template/message-template.schema.ts
Updated actor property type and added output property with schema definitions.
.../pages/templates/constants.tsx
.../types/channel/index.ts
.../types/notification-templates/index.ts
Updated constants and enums to include new types and steps.
.../application-generic/package.json Updated various dependencies.
.../application-generic/src/services/index.ts
.../application-generic/src/services/content.service.ts
.../application-generic/src/services/sanitize/sanitizer.service.spec.ts
Updated service exports and imports; enhanced error handling and readability in service methods.
.../application-generic/src/usecases/create-message-template/...
.../application-generic/src/usecases/create-workflow/...
.../application-generic/src/usecases/update-change/...
Added and refactored use cases for message templates and workflows; updated import paths and adjusted variable handling.
.../application-generic/src/utils/variants/... Introduced utility functions isVariantEmpty and normalizeVariantDefault.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@djabarovgeorge djabarovgeorge added the coderabbit-review Ask Code Rabbit to review the PR label Apr 15, 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: 3

@@ -220,7 +217,7 @@ export class UpdateNotificationTemplate {
const variants = command.steps ? command.steps?.flatMap((step) => step.variants || []) : [];

for (const variant of variants) {
if (checkIsVariantEmpty(variant)) {
if (isVariantEmpty(variant)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The replacement of checkIsVariantEmpty with isVariantEmpty in the main application code has been successfully verified. However, the function checkIsVariantEmpty is still referenced in a test file (packages/application-generic/src/utils/variants/isVariantEmpty.spec.ts). It is recommended to update this test file to use isVariantEmpty to maintain consistency and ensure all tests are aligned with the current implementation.

Analysis chain

Ensure the replacement of checkIsVariantEmpty with isVariantEmpty maintains the intended functionality.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usages of the old function `checkIsVariantEmpty` to ensure it's fully replaced.
rg --type ts "checkIsVariantEmpty"

Length of output: 145

Comment on lines +3 to +11
export const normalizeVariantDefault = (items: ITemplateVariable[]) => {
return items.map((item) => {
if (item.defaultValue === '') {
item.defaultValue = undefined;
}

return item;
});
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper handling of null values for defaultValue.

-    if (item.defaultValue === '') {
+    if (item.defaultValue === '' || item.defaultValue === null) {
      item.defaultValue = undefined;

This change ensures that both empty strings and null values are normalized to undefined, enhancing the robustness of the function.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
export const normalizeVariantDefault = (items: ITemplateVariable[]) => {
return items.map((item) => {
if (item.defaultValue === '') {
item.defaultValue = undefined;
}
return item;
});
};
export const normalizeVariantDefault = (items: ITemplateVariable[]) => {
return items.map((item) => {
if (item.defaultValue === '' || item.defaultValue === null) {
item.defaultValue = undefined;
}
return item;
});
};

@djabarovgeorge djabarovgeorge changed the base branch from next to refactor-echo-use-cases April 16, 2024 18:57
@djabarovgeorge djabarovgeorge deleted the branch refactor-echo-use-cases April 16, 2024 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants