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: email plugins support #2611

Merged
merged 60 commits into from
Oct 13, 2024
Merged

feat: email plugins support #2611

merged 60 commits into from
Oct 13, 2024

Conversation

liorzam
Copy link
Collaborator

@liorzam liorzam commented Aug 4, 2024

Summary by CodeRabbit

  • New Features

    • Added a new script command "run-kyb-web-apps" for improved development workflow.
    • Introduced the BallerineApiPlugin and BallerineEmailPlugin classes for better plugin management and email handling.
    • Added new constants and types for enhanced vendor and email template support.
    • Streamlined email plugin configurations to focus on template-based emails.
  • Improvements

    • Updated the WebhookPlugin, KycPlugin, and KycSessionPlugin classes to extend BallerineApiPlugin, improving their functionality.
    • Enhanced search functionality in the development environment by excluding specific directories.
    • Improved plugin configurations for better clarity and usability in the workflow examples.
    • Updated unit tests to focus on direct property validation for plugins, enhancing test clarity and specificity.

Copy link

changeset-bot bot commented Aug 4, 2024

⚠️ No Changeset found

Latest commit: 461e1bd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Aug 4, 2024

Walkthrough

The recent changes introduce a new script command in package.json for running KYB web applications, enhancing the development process. The command "run-kyb-web-apps" sets environment variables and utilizes the concurrently package to run multiple development builds simultaneously. Additionally, new constants and types have been added across various files, particularly in the plugin system, which enhances the management of email templates and vendor monitoring. The modifications streamline the email handling process by focusing on template-based configurations.

Changes

Files Change Summary
package.json Added new script command "run-kyb-web-apps" for concurrent execution of KYB web applications; added "start": "vite" command in both projects.
.vscode/settings.json Added new search settings: search.exclude, search.followSymlinks, and search.useIgnoreFiles.
apps/kyb-app/amplify.yml Updated build command syntax from double quotes to single quotes.
packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts Introduced new constants for vendors and email templates, updated types for plugin options.
packages/workflow-core/src/lib/constants.ts Introduced BALLERINE_API_PLUGINS constant and updated pluginsRegistry with new mappings.
packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts Refactored ApiPlugin class for modularity, adding methods for URL generation and payload preparation.
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts Added BallerineApiPlugin class and interface IBallerineApiPluginParams for enhanced plugin management.
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-email-plugin.ts Introduced BallerineEmailPlugin class for managing email-related API requests.
packages/workflow-core/src/lib/plugins/external-plugin/kyc-plugin.ts Updated KycPlugin to extend BallerineApiPlugin.
packages/workflow-core/src/lib/plugins/external-plugin/kyc-session-plugin.ts Updated KycSessionPlugin to extend BallerineApiPlugin.
packages/workflow-core/src/lib/plugins/external-plugin/webhook-plugin.ts Updated WebhookPlugin to extend BallerineApiPlugin, modifying constructor and URL handling methods.
packages/workflow-core/src/lib/plugins/common-plugin/iterative-plugin.test.ts Changed a test case to be skipped, indicating it will not run during tests.
packages/workflow-core/src/lib/plugins/external-plugin/webhook-plugin.test.ts Refactored the test suite for the webhook plugin, commenting out previous tests and leaving a placeholder test.
packages/workflow-core/src/lib/workflow-runner.test.unit.ts Modified unit tests to enhance clarity and introduce new properties for plugin definitions.

Possibly related PRs

  • Pdf export feature #2331: The changes in this PR involve modifications to the package.json files, which are related to script commands and project configurations, similar to the updates made in the main PR's package.json.
  • Dispatch Event Plugin #2425: The changes in the main PR regarding the addition of new script commands may connect with the dispatch event plugin, as both involve enhancements to project functionalities.
  • feature/risk_rule_logic #2472: The main PR's updates to package.json and project scripts could be relevant to the risk rule logic, as both involve project configuration and enhancements.
  • Backoffice home page #2480: The main PR's modifications to package.json and project scripts may relate to the backoffice home page updates, as both involve changes to project structure and functionality.
  • feature/webhook_plugin_signing #2703: The main PR's focus on enhancing project scripts may connect with the webhook plugin signing, as both involve improving project capabilities.
  • Merchant monitoring pages fixes #2711: The main PR's updates to project scripts could be related to the merchant monitoring pages fixes, as both involve enhancements to user-facing functionalities.
  • Workflow endpoints models  #2716: The main PR's changes to package.json may connect with the workflow endpoints models, as both involve updates to project structure and functionality.
  • fix(ci-cd): fixed the issue for multi branch submodule fetch in single image #2724: The main PR's updates to project scripts may relate to the CI/CD fixes, as both involve improving project workflows.
  • Feature/implement ocr button #2731: The main PR's enhancements to project scripts may connect with the implementation of the OCR button, as both involve improving document handling capabilities.
  • Updated swagger schema of get workflow by id endpoint #2762: The main PR's updates to the swagger schema may relate to the changes in the workflow by ID endpoint, as both involve enhancements to API documentation and functionality.

Suggested labels

enhancement, Review effort [1-5]: 4

Suggested reviewers

  • Omri-Levy

🐰 In the code, we hop and play,
With plugins brightening the way!
Emails now dance on templates’ grace,
Bringing joy to every space.
Let's celebrate with a cheer,
For changes that bring us near! 🎉


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.

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: 4

Outside diff range, codebase verification and nitpick comments (2)
services/workflows-service/scripts/workflows/dynamic-ui-workflow.ts (2)

152-152: No handling logic found for INVITATION_FAILURE error action.

The INVITATION_FAILURE error action is defined and used in the workflow, but there are no conditional statements or functions handling this specific error action. Ensure that the INVITATION_FAILURE error action is correctly handled in the workflow to avoid potential issues.

  • services/workflows-service/scripts/workflows/dynamic-ui-workflow.ts
Analysis chain

Verify handling of the updated error action.

Ensure that the INVITATION_FAILURE error action is correctly handled in the workflow.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of the `INVITATION_FAILURE` error action.

# Test: Search for the action handling. Expect: Correct handling of the action.
rg --type ts 'INVITATION_FAILURE'

Length of output: 252


Script:

#!/bin/bash
# Description: Verify the handling of the `INVITATION_FAILURE` error action.

# Test: Search for conditional checks or handling logic for `INVITATION_FAILURE`.
rg --type ts 'INVITATION_FAILURE' -A 10

Length of output: 2229


Script:

#!/bin/bash
# Description: Verify the handling of the `INVITATION_FAILURE` error action.

# Test: Search for conditional statements or functions handling `INVITATION_FAILURE`.
rg --type ts 'INVITATION_FAILURE' -A 20 | rg -i 'if|switch|case|function'

Length of output: 788


247-249: Update references to the old plugin kind resubmission to template-email.

Ensure that all references to the old plugin kind resubmission are updated to template-email to maintain consistency and avoid potential issues.

  • packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts: Update the plugin kind from resubmission to template-email.
Analysis chain

Verify consistency and implementation of the new plugin name and kind.

Ensure that all references to the resubmission-email plugin are updated and the template-email plugin kind is correctly implemented.


Verify consistency and implementation of the new plugin name and kind.

Ensure that all references to the resubmission-email plugin are updated and the template-email plugin kind is correctly implemented. Additionally, verify that there are no old references to previous plugin names or kinds that might cause issues.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency and implementation of the new plugin name and kind.

# Test: Search for the plugin name and kind. Expect: Only occurrences of the new name and kind.
rg --type ts 'resubmission-email'
rg --type ts 'template-email'

Length of output: 2254


Script:

#!/bin/bash
# Description: Verify the consistency and implementation of the new plugin name and kind, and check for old references.

# Test: Search for potential old references to previous plugin names and kinds.
rg --type ts 'resubmission'
rg --type ts 'pluginKind'

# Test: Confirm the correct usage of the new plugin name and kind.
rg --type ts 'resubmission-email'
rg --type ts 'template-email'

Length of output: 21411

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d4cfa3b and 47b0bf5.

Files selected for processing (11)
  • packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (6 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-email-plugin.ts (1 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/email-plugin.ts (2 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/types.ts (2 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (9 hunks)
  • packages/workflow-core/src/lib/workflow-runner.ts (4 hunks)
  • services/workflows-service/scripts/workflows/dynamic-ui-workflow.ts (3 hunks)
  • services/workflows-service/scripts/workflows/kyb-kyc-workflow-definition.ts (1 hunks)
  • services/workflows-service/scripts/workflows/parent-kyb-kyc-session-workflow.ts (1 hunks)
  • services/workflows-service/src/workflow/workflow-controller-examples.ts (2 hunks)
Additional context used
Biome
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-email-plugin.ts

[error] 18-20: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts

[error] 7-7: Shouldn't redeclare 'IBallerineApiPluginParams'. Consider to delete it or rename it.

'IBallerineApiPluginParams' is defined here:

(lint/suspicious/noRedeclare)

Additional comments not posted (29)
services/workflows-service/src/workflow/workflow-controller-examples.ts (2)

40-41: LGTM! Verify the correctness of the new properties.

The changes for 'resubmission-email' look good and align with the new template-driven approach.

However, ensure that the template property and the updated pluginKind are correctly defined and used in the codebase.

Verification successful

The new properties for 'resubmission-email' are correctly defined and used in the codebase.

The changes to pluginKind and the addition of the template property are consistently applied across multiple files:

  • services/workflows-service/src/workflow/workflow-controller-examples.ts
  • services/workflows-service/scripts/workflows/kyb-kyc-workflow-definition.ts
  • services/workflows-service/scripts/workflows/dynamic-ui-workflow.ts
  • services/workflows-service/scripts/workflows/parent-kyb-kyc-session-workflow.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the new properties in the 'resubmission-email' plugin configuration.

# Test: Search for the usage of 'resubmission-email' and its properties. Expect: Correct usage and definitions.
rg --type python -A 5 $'resubmission-email'

Length of output: 73


Script:

#!/bin/bash
# Description: Verify the correctness of the new properties in the 'resubmission-email' plugin configuration.

# Test: Search for the usage of 'resubmission-email' and its properties. Expect: Correct usage and definitions.
rg --type typescript -A 5 'resubmission-email'

Length of output: 81


Script:

#!/bin/bash
# Description: Verify the correctness of the new properties in the 'resubmission-email' plugin configuration.

# Test: Search for the usage of 'resubmission-email' and its properties. Expect: Correct usage and definitions.
rg -A 5 'resubmission-email'

Length of output: 2717


4-9: LGTM! Verify the correctness of the new properties.

The new configuration for 'invitation-email' looks good and aligns with the new template-driven approach.

However, ensure that the template, successAction, errorAction, and stateNames properties are correctly defined and used in the codebase.

Verification successful

The properties template, successAction, errorAction, and stateNames are correctly defined and used in the codebase.

The new configuration for 'invitation-email' aligns with the new template-driven approach and is correctly implemented across the codebase.

  • template: Defined and used appropriately.
  • successAction: Defined and used appropriately.
  • errorAction: Defined and used appropriately.
  • stateNames: Defined and used appropriately.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the new properties in the 'invitation-email' plugin configuration.

# Test: Search for the usage of 'invitation-email' and its properties. Expect: Correct usage and definitions.
rg --type python -A 5 $'invitation-email'

Length of output: 71


Script:

#!/bin/bash
# Description: Verify the correctness of the new properties in the 'invitation-email' plugin configuration.

# Test: Search for the usage of 'invitation-email' and its properties. Expect: Correct usage and definitions.
rg --type ts -A 5 'invitation-email'
rg --type ts -A 5 'template'
rg --type ts -A 5 'successAction'
rg --type ts -A 5 'errorAction'
rg --type ts -A 5 'stateNames'

Length of output: 223238

packages/workflow-core/src/lib/plugins/external-plugin/email-plugin.ts (3)

24-24: LGTM! Verify the correctness of the new method.

The change to use replaceAllVariables for the preheader property looks good.

However, ensure that the replaceAllVariables method is correctly defined and used in the codebase.

Verification successful

The replaceAllVariables method is correctly defined and used in the codebase.

The change to use replaceAllVariables for the preheader property in email-plugin.ts is verified and looks good.

  • Definition: packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts
  • Usage: email-plugin.ts, api-plugin.ts, ballerine-plugin.ts, ballerine-email-plugin.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the `replaceAllVariables` method.

# Test: Search for the definition and usage of `replaceAllVariables`. Expect: Correct definition and usage.
rg --type python -A 5 $'replaceAllVariables'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify the correctness of the `replaceAllVariables` method.

# Test: Search for the definition and usage of `replaceAllVariables`. Expect: Correct definition and usage.
rg --type typescript -A 5 'replaceAllVariables'

Length of output: 82


Script:

#!/bin/bash
# Description: Verify the correctness of the `replaceAllVariables` method.

# Test: Search for the definition and usage of `replaceAllVariables`. Expect: Correct definition and usage.
rg --type ts -A 5 'replaceAllVariables'

Length of output: 6003


21-21: LGTM! Verify the correctness of the new method.

The change to use replaceAllVariables for the subject property looks good.

However, ensure that the replaceAllVariables method is correctly defined and used in the codebase.

Verification successful

Let's re-run the script with the correct file type to verify the definition and usage of the replaceAllVariables method.


Let's re-run the script without specifying the file type to verify the definition and usage of the replaceAllVariables method.


Verified!

The replaceAllVariables method is correctly defined and used in the codebase. The implementation and usage align with the expected functionality for replacing variables in the subject property.

  • Definition found in packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts
  • Usage confirmed in email-plugin.ts and ballerine-email-plugin.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the `replaceAllVariables` method.

# Test: Search for the definition and usage of `replaceAllVariables`. Expect: Correct definition and usage.
rg --type python -A 5 $'replaceAllVariables'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify the correctness of the `replaceAllVariables` method.

# Test: Search for the definition and usage of `replaceAllVariables`. Expect: Correct definition and usage.
rg --type typescript -A 5 'replaceAllVariables'

Length of output: 82


Script:

#!/bin/bash
# Description: Verify the correctness of the `replaceAllVariables` method.

# Test: Search for the definition and usage of `replaceAllVariables`. Expect: Correct definition and usage.
rg -A 5 'replaceAllVariables'

Length of output: 5993


34-34: LGTM! Verify the correctness of the new method.

The change to use replaceAllVariables for other string properties in the payload looks good.

However, ensure that the replaceAllVariables method is correctly defined and used in the codebase.

packages/workflow-core/src/lib/plugins/external-plugin/types.ts (1)

7-7: LGTM! Verify the correctness of the new property.

The addition of the template property to the IApiPluginParams interface looks good.

However, ensure that the ApiEmailTemplates type is correctly defined and used in the codebase.

Verification successful

The ApiEmailTemplates type is correctly defined and used.

  • The type is defined in packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts.
  • It is used in several files, ensuring consistent and type-safe usage.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the `ApiEmailTemplates` type.

# Test: Search for the definition and usage of `ApiEmailTemplates`. Expect: Correct definition and usage.
rg --type python -A 5 $'ApiEmailTemplates'

Length of output: 72


Script:

#!/bin/bash
# Description: Verify the correctness of the `ApiEmailTemplates` type.

# Test: Search for the definition and usage of `ApiEmailTemplates`. Expect: Correct definition and usage.
rg --type typescript -A 5 'ApiEmailTemplates'

Length of output: 80


Script:

#!/bin/bash
# Description: Verify the correctness of the `ApiEmailTemplates` type.

# Test: Search for the definition and usage of `ApiEmailTemplates`. Expect: Correct definition and usage.
rg --type ts -A 5 'ApiEmailTemplates'

Length of output: 4291

packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1)

14-20: LGTM!

The _validatePlugin function correctly validates the plugin parameters and throws an error for unknown plugin kinds.

services/workflows-service/scripts/workflows/kyb-kyc-workflow-definition.ts (5)

179-179: Verify implementation of the new plugin kind.

Ensure that the template-email plugin kind is supported and correctly implemented in the codebase.

Verification successful

Verify implementation of the new plugin kind.

The template-email plugin kind is found in multiple files, indicating it is recognized and used within the codebase. Ensure that the following files correctly implement and support the template-email plugin kind:

  • packages/workflow-core/src/lib/workflow-runner.ts
  • packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-email-plugin.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `template-email` plugin kind.

# Test: Search for the plugin kind. Expect: Correct implementation of the new kind.
rg --type ts 'template-email'

Length of output: 1782


181-181: Verify handling of the EMAIL_SENT action.

Ensure that the EMAIL_SENT action is correctly handled in the workflow.


180-180: Verify the existence and reference of the email template.

Ensure that the resubmission template exists and is correctly referenced in the codebase.

Verification successful

The resubmission template exists and is correctly referenced.

The search results show multiple references to the resubmission template across different files, indicating its presence and correct usage in the codebase.

  • services/workflows-service/src/workflow/workflow-controller-examples.ts
  • packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts
  • services/workflows-service/scripts/workflows/dynamic-ui-workflow.ts
  • services/workflows-service/scripts/workflows/kyb-kyc-workflow-definition.ts
  • services/workflows-service/scripts/workflows/parent-kyb-kyc-session-workflow.ts
  • sdks/web-ui-sdk/src/lib/contexts/configuration/types.ts
  • sdks/web-ui-sdk/src/lib/contexts/app-state/types.ts
  • apps/backoffice-v2/src/domains/workflows/fetchers.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and reference of the `resubmission` template.

# Test: Search for the template reference. Expect: Correct reference of the template.
rg --type ts 'resubmission'

Length of output: 3346


178-178: Verify consistency of the plugin name.

Ensure that all references to the resubmission-email plugin are updated throughout the codebase to maintain consistency.

Verification successful

The plugin name has been consistently updated.

All references to the resubmission-email plugin have been updated throughout the codebase, and no instances of the old name resubmission_email were found.

  • services/workflows-service/src/workflow/workflow-controller-examples.ts
  • services/workflows-service/scripts/workflows/parent-kyb-kyc-session-workflow.ts
  • services/workflows-service/scripts/workflows/dynamic-ui-workflow.ts
  • services/workflows-service/scripts/workflows/kyb-kyc-workflow-definition.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the `resubmission-email` plugin are updated.

# Test: Search for the plugin name. Expect: Only occurrences of the new name.
rg --type ts 'resubmission-email'

Length of output: 471


Script:

#!/bin/bash
# Description: Verify that the old plugin name `resubmission_email` has been completely replaced.

# Test: Search for the old plugin name. Expect: No occurrences of the old name.
rg --type ts 'resubmission_email'

Length of output: 33


182-182: Verify handling of the EMAIL_FAILURE action.

Ensure that the EMAIL_FAILURE action is correctly handled in the workflow.

Verification successful

The EMAIL_FAILURE action is correctly handled in the workflow.

The EMAIL_FAILURE action transitions the workflow to a 'failed' state, ensuring proper error handling.

  • services/workflows-service/scripts/workflows/dynamic-ui-workflow.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of the `EMAIL_FAILURE` action.

# Test: Search for the action handling. Expect: Correct handling of the action.
rg --type ts 'EMAIL_FAILURE'

Length of output: 685


Script:

#!/bin/bash
# Extract context around the `EMAIL_FAILURE` occurrences to verify handling.
rg --type ts 'EMAIL_FAILURE' -A 10 -B 10

Length of output: 12567

packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (5)

240-249: Verify usage and integration of the new _onReplaceVariable method.

Ensure that the _onReplaceVariable method is correctly used and integrated within the ApiPlugin class.

Verification successful

The _onReplaceVariable method is correctly used and integrated.

  • Defined and used within ApiPlugin class.
  • Extended and utilized in BallerinePlugin class.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and integration of the `_onReplaceVariable` method.

# Test: Search for the method usage. Expect: Correct usage and integration.
rg --type ts '_onReplaceVariable'

Length of output: 691


Line range hint 251-273:
Verify usage and integration of the new replaceAllVariables method.

Ensure that the replaceAllVariables method is correctly used and integrated within the ApiPlugin class.


118-120: Verify usage and integration of the new _getPluginUrl method.

Ensure that the _getPluginUrl method is correctly used and integrated within the ApiPlugin class.

Verification successful

The _getPluginUrl method is correctly used and integrated within the ApiPlugin class.

The method is defined and utilized appropriately within the class, ensuring a centralized way to retrieve the plugin URL.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and integration of the `_getPluginUrl` method.

# Test: Search for the method usage. Expect: Correct usage and integration.
rg --type ts '_getPluginUrl'

Length of output: 397


Script:

#!/bin/bash
# Description: Gather more context around the usage of `_getPluginUrl` in `api-plugin.ts`.

# Get the class definition and methods in `api-plugin.ts` to understand the integration of `_getPluginUrl`.
rg --type ts -A 10 'class ' packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts
rg --type ts -A 10 'protected async _getPluginUrl' packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts

Length of output: 892


175-185: Verify usage and integration of the new _onPreparePayload method.

Ensure that the _onPreparePayload method is correctly used and integrated within the ApiPlugin class.

Verification successful

Let's gather more context around the line where _onPreparePayload is called to verify its integration within the class.


The _onPreparePayload method is correctly used and integrated within the ApiPlugin class.

  • The method is called to prepare the payload before making an HTTP request, ensuring variables within the payload are appropriately replaced.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and integration of the `_onPreparePayload` method.

# Test: Search for the method usage. Expect: Correct usage and integration.
rg --type ts '_onPreparePayload'

Length of output: 282


Script:

#!/bin/bash
# Extract 10 lines before and after the line where `_onPreparePayload` is called to understand its context.
rg '_onPreparePayload' -A 10 -B 10 packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts

Length of output: 1295


274-291: Verify usage and integration of the new replaceSecrets method.

Ensure that the replaceSecrets method is correctly used and integrated within the ApiPlugin class.

Verification successful

The replaceSecrets method is correctly used and integrated within the ApiPlugin and BallerinePlugin classes.

  • The method is used within the _onReplaceVariable method in both api-plugin.ts and ballerine-plugin.ts, ensuring modular and clear handling of secret replacements.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and integration of the `replaceSecrets` method.

# Test: Search for the method usage. Expect: Correct usage and integration.
rg --type ts 'replaceSecrets'

Length of output: 364


Script:

#!/bin/bash
# Description: Verify the context of `replaceSecrets` usage in `api-plugin.ts` and `ballerine-plugin.ts`.

# Search for the usage of `replaceSecrets` in `api-plugin.ts` with context lines.
rg --type ts 'replaceSecrets' -A 5 -B 5 packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts

# Search for the usage of `replaceSecrets` in `ballerine-plugin.ts` with context lines.
rg --type ts 'replaceSecrets' -A 5 -B 5 packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts

Length of output: 1060

services/workflows-service/scripts/workflows/dynamic-ui-workflow.ts (4)

45-45: Verify consistency of the corrected event name.

Ensure that the corrected event name INVITATION_FAILURE is consistently used throughout the codebase.


148-148: Verify consistency of the plugin name.

Ensure that all references to the invitation-email plugin are updated throughout the codebase to maintain consistency.

Verification successful

The plugin name update is consistent.

All references to the invitation-email plugin have been updated correctly, and there are no remaining instances of the old plugin name collection_invite_email.

  • services/workflows-service/src/workflow/workflow-controller-examples.ts
  • services/workflows-service/scripts/workflows/dynamic-ui-workflow.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the `invitation-email` plugin are updated.

# Test: Search for the plugin name. Expect: Only occurrences of the new name.
rg --type ts 'invitation-email'

Length of output: 237


Script:

#!/bin/bash
# Description: Verify that the old plugin name `collection_invite_email` is no longer present in the codebase.

# Test: Search for the old plugin name. Expect: No occurrences of the old name.
rg --type ts 'collection_invite_email'

Length of output: 38


149-149: Verify implementation of the new plugin kind.

Ensure that the template-email plugin kind is supported and correctly implemented in the codebase.

Verification successful

The template-email plugin kind is correctly implemented.

The template-email plugin kind is well-integrated into the system, with appropriate references and implementations in the following files:

  • packages/workflow-core/src/lib/workflow-runner.ts
  • packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-email-plugin.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `template-email` plugin kind.

# Test: Search for the plugin kind. Expect: Correct implementation of the new kind.
rg --type ts 'template-email'

Length of output: 1782


Script:

#!/bin/bash
# Description: Gather details about the implementation of `template-email` in the identified files.

# Search for the implementation details in workflow-runner.ts
rg -A 10 'template-email' packages/workflow-core/src/lib/workflow-runner.ts

# Search for the implementation details in vendor-consts.ts
rg -A 10 'template-email' packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts

# Search for the implementation details in ballerine-plugin.ts
rg -A 10 'template-email' packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts

# Search for the implementation details in ballerine-email-plugin.ts
rg -A 10 'template-email' packages/workflow-core/src/lib/plugins/external-plugin/ballerine-email-plugin.ts

Length of output: 3302


153-153: Verify handling of the expanded state names.

Ensure that the state transition for the invitation email plugin is correctly handled.

packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (3)

16-20: LGTM!

The addition of EMAIL_TEMPLATES enhances the structure for email handling.


30-30: LGTM!

The ApiEmailTemplates type derivation from EMAIL_TEMPLATES ensures type safety and clarity.


37-37: LGTM!

The BALLERINE_API_PLUGINS now includes functions for each email template type, consolidating email handling into a unified structure.

packages/workflow-core/src/lib/workflow-runner.ts (5)

67-67: LGTM!

The import path change for BallerineApiPlugin reflects the new organization of the plugin directory.


68-68: LGTM!

The addition of the BallerineEmailPlugin import is necessary for the new email functionality.


69-73: LGTM!

The import path change for ApiBallerinePlugins and related constants reflects the new organization of the plugin directory.


207-207: LGTM!

The pluginKind property update to use the ApiBallerinePlugins type enhances type safety and flexibility.


819-819: LGTM!

The error logging mechanism now includes the stack trace of errors, providing better debugging information.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 47b0bf5 and 99d478f.

Files selected for processing (2)
  • packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (6 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1 hunks)
Additional context used
Biome
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts

[error] 7-7: Shouldn't redeclare 'IBallerineApiPluginParams'. Consider to delete it or rename it.

'IBallerineApiPluginParams' is defined here:

(lint/suspicious/noRedeclare)

Additional comments not posted (12)
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (6)

14-20: LGTM!

The _validatePlugin function correctly validates the plugin kind and throws an error if the kind is unknown.


22-51: Optimize _getPluginOptions function.

Reduce redundant checks for plugin kinds to improve readability.

const _getPluginOptions = (params: IBallerineApiPluginParams & IApiPluginParams) => {
  _validatePlugin(params);
  let optionsFactoryFn;

  const pluginOptionFactoryFn = BALLERINE_API_PLUGIN_FACTORY[params.pluginKind] as any;

  if (['individual-sanctions', 'company-sanctions', 'ubo'].includes(params.pluginKind)) {
    if (!params.vendor) {
      throw new Error(`Missed vendor for: ${params.pluginKind}`);
    }
    optionsFactoryFn = pluginOptionFactoryFn[params.vendor];
  } else if (params.pluginKind === 'template-email') {
    if (!params.template) {
      throw new Error(`Missed templateName for: ${params.pluginKind}`);
    }
    optionsFactoryFn = pluginOptionFactoryFn[params.template];
  }

  if (!optionsFactoryFn) {
    throw new Error(`Unknown plugin kind: ${params.pluginKind}, params: ${JSON.stringify(params)}`);
  }

  return optionsFactoryFn(params as any);
};

53-72: LGTM!

The BallerineApiPlugin constructor correctly initializes the plugin with parameters and options, and sets up request and response transformers and validators.


74-76: LGTM!

The _getPluginUrl function correctly replaces variables in the URL using the context.


78-95: LGTM!

The _onReplaceVariable function correctly handles secret replacement by provider and falls back to the parent class method if no secrets are replaced.


Line range hint 274-295:
LGTM!

The replaceSecretsByProvider function correctly handles secret replacement based on the provider and variable key.

Tools
Biome

[error] 7-7: Shouldn't redeclare 'IBallerineApiPluginParams'. Consider to delete it or rename it.

'IBallerineApiPluginParams' is defined here:

(lint/suspicious/noRedeclare)

packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (6)

118-120: LGTM!

The _getPluginUrl function correctly retrieves the plugin URL.


175-185: LGTM!

The _onPreparePayload function correctly replaces variables in the payload using the context.


240-249: LGTM!

The _onReplaceVariable function correctly handles secret replacement by provider.


Line range hint 251-272:
LGTM!

The replaceAllVariables function correctly handles variable replacement in the content using the context.


274-298: LGTM!

The replaceSecretsByProvider function correctly handles secret replacement based on the provider and variable key.


62-70: LGTM!

The invoke function correctly uses _getPluginUrl and _onPreparePayload for URL handling and payload preparation.

Also applies to: 118-120, 149-185

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: 4

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 99d478f and d002693.

Files selected for processing (2)
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-email-plugin.ts (1 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1 hunks)
Additional context used
Biome
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-email-plugin.ts

[error] 18-20: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts

[error] 7-7: Shouldn't redeclare 'IBallerineApiPluginParams'. Consider to delete it or rename it.

'IBallerineApiPluginParams' is defined here:

(lint/suspicious/noRedeclare)

Additional comments not posted (5)
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-email-plugin.ts (2)

81-90: LGTM!

The method is well-structured and performs its task correctly.


92-94: LGTM!

The method is well-structured and performs its task correctly.

packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (3)

14-20: LGTM!

The function is well-structured and performs its task correctly.


70-71: LGTM!

The method is well-structured and performs its task correctly.


74-91: LGTM!

The method is well-structured and performs its task correctly.

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: 1

Outside diff range, codebase verification and nitpick comments (1)
packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (1)

Line range hint 251-272:
LGTM! Consider optimizing the implementation.

The implementation is correct, but the function can be optimized by using a more functional approach.

-    for (const placeholder of placeholders) {
-      const variableKey = placeholder.replace(/{|}/g, '');
-      const replacedVariable = this._onReplaceVariable(variableKey, replacedContent, placeholder);
-      if (replacedVariable) {
-        return replacedVariable;
-      }
-      const placeholderValue = `${this.fetchObjectPlaceholderValue(context, variableKey)}`;
-      replacedContent = replacedContent.replace(placeholder, placeholderValue);
-    }
+    await Promise.all(placeholders.map(async placeholder => {
+      const variableKey = placeholder.replace(/{|}/g, '');
+      const replacedVariable = this._onReplaceVariable(variableKey, replacedContent, placeholder);
+      if (replacedVariable) {
+        return replacedVariable;
+      }
+      const placeholderValue = `${this.fetchObjectPlaceholderValue(context, variableKey)}`;
+      replacedContent = replacedContent.replace(placeholder, placeholderValue);
+    }));
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d002693 and af7e237.

Files selected for processing (2)
  • packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (6 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
Files skipped from review due to trivial changes (1)
  • services/workflows-service/prisma/data-migrations
Additional comments not posted (3)
packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (3)

118-120: LGTM!

The implementation is straightforward and correct.


240-249: LGTM!

The implementation is correct and improves modularity.


62-62: LGTM! But verify the _getPluginUrl implementation.

The refactoring improves readability and maintainability.

However, ensure that _getPluginUrl is correctly implemented and used.

Verification successful

Verification successful.

The _getPluginUrl method in api-plugin.ts is correctly implemented, returning the URL stored in the instance.

  • Location: packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts, line 62
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `_getPluginUrl`.

# Test: Search for the function definition. Expect: Correct implementation.
rg --type ts '_getPluginUrl'

Length of output: 397


Script:

#!/bin/bash
# Extract the implementation of `_getPluginUrl` from `api-plugin.ts` for review.
rg --type ts --context 10 '_getPluginUrl' packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts

Length of output: 1201

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between af7e237 and 3cc3767.

Files selected for processing (1)
  • packages/workflow-core/src/lib/workflow-runner.ts (3 hunks)
Additional comments not posted (3)
packages/workflow-core/src/lib/workflow-runner.ts (3)

67-73: LGTM! Imports updated correctly.

The import paths for BallerineApiPlugin and BALLERINE_API_PLUGINS_KINDS have been updated to reflect the new organization of plugins. The new import for BallerineEmailPlugin is correctly added.


204-207: LGTM! Enhanced type safety for pluginKind.

The pluginKind property in the apiPluginSchema has been updated to use ApiBallerinePlugins, enhancing type safety and flexibility.


401-403: LGTM! New condition for template-email kind added.

The new condition for the template-email kind correctly routes to the newly added BallerineEmailPlugin, enhancing the runner's capability to manage different types of email plugins.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3cc3767 and d71cdfd.

Files selected for processing (1)
  • services/workflows-service/src/workflow/workflow-controller-examples.ts (2 hunks)
Additional comments not posted (2)
services/workflows-service/src/workflow/workflow-controller-examples.ts (2)

4-9: Verify the new plugin configuration for 'invitation-email'.

The new configuration introduces properties like template, successAction, errorAction, and stateNames. Ensure that these properties align with the intended functionality and that the template value 'invitation' is correctly handled in the codebase.

Verification successful

The 'invitation' template is properly handled in the codebase.

The search results confirm that the 'invitation' template and its related properties are consistently used across multiple files, ensuring proper handling and integration.

  • workflow-controller-examples.ts
  • kyb-kyc-workflow-definition.ts
  • dynamic-ui-workflow.ts
  • vendor-consts.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of the 'invitation' template in the codebase.

# Test: Search for the usage of 'invitation' template. Expect: Proper handling of the 'invitation' template.
rg --type python -A 5 $'invitation'

Length of output: 65


Script:

#!/bin/bash
# Description: Verify the handling of the 'invitation' template in the codebase.

# Test: Search for the usage of 'invitation' template. Expect: Proper handling of the 'invitation' template.
rg 'invitation' -A 5

Length of output: 5420


40-41: Verify the new template property and pluginKind change for 'resubmission-email'.

The pluginKind has been changed to 'template-email' and a new template property has been added. Ensure that these changes align with the intended functionality and that the template value 'resubmission' is correctly handled in the codebase.

Verification successful

Verify the new template property and pluginKind change for 'resubmission-email'.

The pluginKind has been changed to 'template-email' and a new template property has been added. Ensure that these changes align with the intended functionality and that the template value 'resubmission' is correctly handled in the codebase.


Verified the new template property and pluginKind change for 'resubmission-email'.

The changes to the pluginKind and the addition of the template property for 'resubmission-email' are consistent with the existing codebase and align with the intended functionality.

  • The 'resubmission' template is properly handled across various files and contexts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of the 'resubmission' template in the codebase.

# Test: Search for the usage of 'resubmission' template. Expect: Proper handling of the 'resubmission' template.
rg --type python -A 5 $'resubmission'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify the handling of the 'resubmission' template in the codebase.

# Test: Search for the usage of 'resubmission' template. Expect: Proper handling of the 'resubmission' template.
rg -A 5 'resubmission'

Length of output: 16584

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: 2

Outside diff range, codebase verification and nitpick comments (1)
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1)

Line range hint 240-249:
Remove redundant method definition.

The _onReplaceVariable method is defined twice, which is redundant. Consider removing one of the definitions.

-  async _onReplaceVariable(variableKey: string, replacedContent: string, placeholder: string) {
-    const replacedCustomerSecrets = await this.replaceSecretsByProvider(
-      'customer',
-      variableKey,
-      replacedContent,
-      placeholder,
-    );
-
-    return replacedCustomerSecrets;
-  }
Tools
Biome

[error] 7-7: Shouldn't redeclare 'IBallerineApiPluginParams'. Consider to delete it or rename it.

'IBallerineApiPluginParams' is defined here:

(lint/suspicious/noRedeclare)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d71cdfd and 752607c.

Files selected for processing (2)
  • packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (6 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1 hunks)
Additional context used
Biome
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts

[error] 7-7: Shouldn't redeclare 'IBallerineApiPluginParams'. Consider to delete it or rename it.

'IBallerineApiPluginParams' is defined here:

(lint/suspicious/noRedeclare)

Additional comments not posted (11)
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (4)

14-20: LGTM!

The _validatePlugin function is straightforward and performs necessary validation.


49-68: LGTM!

The constructor of BallerineApiPlugin initializes the plugin with necessary parameters and options.


70-72: LGTM!

The _getPluginUrl method is straightforward and performs necessary URL replacements.


74-85: LGTM!

The _onReplaceVariable method performs necessary secret replacements.

packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (7)

118-120: LGTM!

The _getPluginUrl function is straightforward and performs necessary URL retrieval.


240-249: LGTM!

The _onReplaceVariable method performs necessary secret replacements.


Line range hint 251-272:
LGTM!

The replaceAllVariables function performs necessary variable replacements.


274-293: LGTM!

The replaceSecretsByProvider function performs necessary secret replacements based on the provider.


Line range hint 295-297:
LGTM!

The getSystemSecret function performs necessary retrieval of system secrets.


Line range hint 299-307:
LGTM!

The fetchSecret function performs necessary retrieval of secrets from the secrets manager.


Line range hint 309-316:
LGTM!

The fetchObjectPlaceholderValue function performs necessary retrieval of placeholder values from an object.

Comment on lines 22 to 47
const _getPluginOptions = (params: IBallerineApiPluginParams & IApiPluginParams) => {
_validatePlugin(params);
let optionsFactoryFn;

const pluginOptionFactoryFn = BALLERINE_API_PLUGIN_FACTORY[params.pluginKind] as any;

if (['individual-sanctions', 'company-sanctions', 'ubo'].includes(params.pluginKind)) {
if (!params.vendor) {
throw new Error(`Missed vendor for: ${params.pluginKind}`);
}
optionsFactoryFn = pluginOptionFactoryFn[params.vendor];
}

if (params.pluginKind === 'template-email') {
if (!params.template) {
throw new Error(`Missed templateName for: ${params.pluginKind}`);
}
optionsFactoryFn = pluginOptionFactoryFn[params.template];
}

if (!optionsFactoryFn) {
throw new Error(`Unknown plugin kind: ${params.pluginKind}, params: ${JSON.stringify(params)}`);
}

return optionsFactoryFn(params as any);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize _getPluginOptions function.

Reduce redundant checks for plugin kinds to improve readability.

const _getPluginOptions = (params: IBallerineApiPluginParams & IApiPluginParams) => {
  _validatePlugin(params);
  let optionsFactoryFn;

  const pluginOptionFactoryFn = BALLERINE_API_PLUGIN_FACTORY[params.pluginKind] as any;

  if (['individual-sanctions', 'company-sanctions', 'ubo'].includes(params.pluginKind)) {
    if (!params.vendor) {
      throw new Error(`Missed vendor for: ${params.pluginKind}`);
    }
    optionsFactoryFn = pluginOptionFactoryFn[params.vendor];
  } else if (params.pluginKind === 'template-email') {
    if (!params.template) {
      throw new Error(`Missed templateName for: ${params.pluginKind}`);
    }
    optionsFactoryFn = pluginOptionFactoryFn[params.template];
  }

  if (!optionsFactoryFn) {
    throw new Error(`Unknown plugin kind: ${params.pluginKind}, params: ${JSON.stringify(params)}`);
  }

  return optionsFactoryFn(params as any);
};

Committable suggestion was skipped due to low confidence.

Comment on lines 175 to 185
private async _onPreparePayload(_payload: AnyRecord) {
const returnObj = JSON.parse(JSON.stringify(_payload));

for (const key of Object.keys(returnObj)) {
if (typeof returnObj[key] === 'string') {
returnObj[key] = await this.replaceAllVariables(returnObj[key] as string, returnObj);
}
}

return returnObj;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize _onPreparePayload function.

The implementation is correct, but the function can be optimized by using a more functional approach.

-    for (const key of Object.keys(returnObj)) {
-      if (typeof returnObj[key] === 'string') {
-        returnObj[key] = await this.replaceAllVariables(returnObj[key] as string, returnObj);
-      }
-    }
+    await Promise.all(Object.keys(returnObj).map(async key => {
+      if (typeof returnObj[key] === 'string') {
+        returnObj[key] = await this.replaceAllVariables(returnObj[key] as string, returnObj);
+      }
+    }));
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private async _onPreparePayload(_payload: AnyRecord) {
const returnObj = JSON.parse(JSON.stringify(_payload));
for (const key of Object.keys(returnObj)) {
if (typeof returnObj[key] === 'string') {
returnObj[key] = await this.replaceAllVariables(returnObj[key] as string, returnObj);
}
}
return returnObj;
}
private async _onPreparePayload(_payload: AnyRecord) {
const returnObj = JSON.parse(JSON.stringify(_payload));
await Promise.all(Object.keys(returnObj).map(async key => {
if (typeof returnObj[key] === 'string') {
returnObj[key] = await this.replaceAllVariables(returnObj[key] as string, returnObj);
}
}));
return returnObj;
}

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: 1

Outside diff range, codebase verification and nitpick comments (1)
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1)

75-77: Simplify _getPluginUrl method.

The _getPluginUrl method could be simplified if this.url is already a fully resolved URL. Ensure that variable replacement is necessary.

- async _getPluginUrl(context: AnyRecord) {
-   return await this.replaceAllVariables(this.url, context);
+ async _getPluginUrl(_: AnyRecord) {
+   return this.url;
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 752607c and 1e1355e.

Files selected for processing (3)
  • packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (6 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1 hunks)
  • packages/workflow-core/src/lib/workflow-runner.ts (4 hunks)
Additional context used
Biome
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts

[error] 7-7: Shouldn't redeclare 'IBallerineApiPluginParams'. Consider to delete it or rename it.

'IBallerineApiPluginParams' is defined here:

(lint/suspicious/noRedeclare)

Additional comments not posted (13)
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (3)

22-51: Optimize _getPluginOptions function.

Reduce redundant checks for plugin kinds to improve readability and maintainability.


79-90: Review _onReplaceVariable method for consistency.

Ensure that the method correctly handles variable replacement and integrates well with the superclass method.


54-73: Ensure proper handling of plugin options in the constructor.

The constructor correctly initializes the plugin with options, but verify that all necessary parameters are passed and handled.

packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (7)

118-120: Simplify _getPluginUrl method.

The method directly returns this.url, which is straightforward. Ensure that this approach aligns with the intended design.


149-149: Optimize payload preparation in _onPreparePayload.

Consider using a more functional approach to iterate over keys and replace variables.


175-185: Optimize _onPreparePayload function.

The function can be optimized by using a more functional approach, such as Promise.all with map.


240-249: Review _onReplaceVariable method for consistency.

Ensure that the method correctly handles variable replacement and integrates well with the superclass method.


271-290: Review replaceSecretsByProvider method for security.

Ensure that secret replacement logic is secure and correctly handles different providers.


62-78: Ensure URL consistency in _getPluginUrl.

The _getPluginUrl method simplifies URL retrieval. Verify that this.url is correctly set across all instances.

Verification successful

URL Consistency in _getPluginUrl Method Verified

The ApiPlugin class constructor initializes the url property using the pluginParams.url parameter. The _getPluginUrl method simply returns this url property, ensuring consistency in URL retrieval. The instantiation of ApiPlugin is primarily handled through the initiateApiPlugins method in the workflow-runner.ts file, which maps apiPluginSchemas to ApiPlugin instances, ensuring that the url is set correctly from the schema.

  • Constructor Initialization: The url is initialized in the constructor from pluginParams.url.
  • Method Consistency: _getPluginUrl returns this.url, maintaining consistency.
  • Instantiation: Managed through initiateApiPlugins, ensuring url is set from schemas.

No inconsistencies were found regarding the URL setting in ApiPlugin instances.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Ensure that `this.url` is correctly set across all instances of ApiPlugin.

# Test: Search for ApiPlugin instantiation. Expect: `url` parameter is correctly set.
rg --type javascript 'new ApiPlugin'

Length of output: 73


Script:

#!/bin/bash
# Description: Ensure that `this.url` is correctly set across all instances of ApiPlugin.

# Test: Search for ApiPlugin instantiation. Expect: `url` parameter is correctly set.
rg --type js 'new ApiPlugin'

Length of output: 30


Script:

#!/bin/bash
# Search for the definition of the ApiPlugin class to understand its constructor and usage.
ast-grep --lang typescript --pattern 'class ApiPlugin { $$$ }'

# Search for any methods or functions that might instantiate ApiPlugin.
rg 'ApiPlugin' -A 5

Length of output: 78649


Line range hint 251-269:
Ensure comprehensive variable replacement in replaceAllVariables.

The method iterates through placeholders and applies replacements. Verify that all placeholders are correctly identified and replaced.

packages/workflow-core/src/lib/workflow-runner.ts (3)

204-207: Ensure correct usage of ApiBallerinePlugins type.

The change to use ApiBallerinePlugins enhances type safety. Verify that all plugin kinds are correctly defined and used.


67-73: Verify imports for new plugins.

Ensure that the imports for BallerineApiPlugin and BallerineEmailPlugin are correctly integrated and used.

Verification successful

Imports for Ballerine Plugins are Correctly Integrated

The BallerineApiPlugin and BallerineEmailPlugin are correctly imported and used within the codebase. The workflow-runner.ts file includes these imports and utilizes them appropriately in the logic, indicating proper integration.

  • Files and Usage:
    • workflow-runner.ts: Both plugins are imported and used within the logic.
    • ballerine-plugin.ts: Defines BallerineApiPlugin.
    • ballerine-email-plugin.ts: Extends BallerineApiPlugin with BallerineEmailPlugin.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that BallerineApiPlugin and BallerineEmailPlugin are correctly integrated and used.

# Test: Search for BallerineApiPlugin and BallerineEmailPlugin usage. Expect: Correct integration.
rg --type javascript 'Ballerine(Api|Email)Plugin'

Length of output: 86


Script:

#!/bin/bash
# Description: Verify that BallerineApiPlugin and BallerineEmailPlugin are correctly integrated and used.

# Test: Search for BallerineApiPlugin and BallerineEmailPlugin usage in TypeScript files. Expect: Correct integration.
rg --type ts 'Ballerine(Api|Email)Plugin'

Length of output: 2018


402-403: Check routing to BallerineEmailPlugin.

Ensure that the condition for routing to BallerineEmailPlugin is correctly implemented and tested.

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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1e1355e and c57c8b9.

Files selected for processing (5)
  • packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (6 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (9 hunks)
  • packages/workflow-core/src/lib/workflow-runner.ts (4 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • services/workflows-service/prisma/data-migrations
Additional context used
Biome
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts

[error] 7-7: Shouldn't redeclare 'IBallerineApiPluginParams'. Consider to delete it or rename it.

'IBallerineApiPluginParams' is defined here:

(lint/suspicious/noRedeclare)

packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts

[error] 393-393: Unexpected constant condition.

(lint/correctness/noConstantCondition)

Additional comments not posted (16)
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (2)

14-51: Optimize _getPluginOptions function.

Reduce redundant checks for plugin kinds to improve readability.


56-72: Fix redeclaration issue.

The IBallerineApiPluginParams interface is redeclared in this file. Consider deleting or renaming it.

packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (6)

62-78: Refactor URL handling for consistency.

The _getPluginUrl method ensures consistent URL handling by using this.url. This change improves maintainability and readability.


118-120: Ensure URL consistency in _getPluginUrl.

The _getPluginUrl method directly returns this.url, which aligns with the refactoring goals for URL handling.


149-149: Optimize _onPreparePayload function.

The implementation is correct, but the function can be optimized by using a more functional approach.


233-233: Ensure header variable replacement.

The composeRequestHeaders method correctly replaces variables in headers, enhancing flexibility and security.


240-256: Refactor _onReplaceVariable for clarity.

The _onReplaceVariable method centralizes variable replacement logic, improving code clarity and maintainability.


282-301: Refactor replaceSecretsByProvider for modularity.

The replaceSecretsByProvider method modularizes secret replacement, enhancing clarity and reducing redundancy.

packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (4)

31-36: Add EMAIL_TEMPLATES for structured email handling.

The EMAIL_TEMPLATES constant improves email handling capabilities by defining structured email types.


49-49: Ensure type safety with ApiEmailTemplates.

The ApiEmailTemplates type ensures type safety and clarity when referencing email templates.


95-99: Define EmailOptions for email operations.

The EmailOptions type provides a clear structure for options used in email template operations, enhancing readability.


451-593: Streamline email plugin structure.

The consolidation of email-related plugins into template-email streamlines email handling into a unified structure, improving maintainability.

packages/workflow-core/src/lib/workflow-runner.ts (4)

67-73: Imports updated correctly for new plugin architecture.

The import paths for BallerineApiPlugin and BallerineEmailPlugin have been updated to reflect the new plugin organization. This change aligns with the modular structure and enhances maintainability.


208-208: Improved type safety with ApiBallerinePlugins.

The use of ApiBallerinePlugins for pluginKind enhances type safety and flexibility, allowing for easier extension of plugin kinds.


403-405: Support for template-email kind added.

The addition of the template-email condition to route to BallerineEmailPlugin expands the workflow runner's capabilities to manage email-specific operations.


822-822: Enhanced error logging with additional context.

The inclusion of additional context information in error logs improves the ability to debug and monitor issues effectively.

Comment on lines +7 to +12
export interface IBallerineApiPluginParams {
pluginKind: ApiBallerinePlugins;
vendor?: string;
displayName: string | undefined;
stateNames: string[];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix redeclaration issue for IBallerineApiPluginParams.

The IBallerineApiPluginParams interface is redeclared in this file. Consider deleting or renaming it to avoid conflicts.

- export interface IBallerineApiPluginParams {
-   pluginKind: ApiBallerinePlugins;
-   vendor?: string;
-   displayName: string | undefined;
-   stateNames: string[];
- }
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export interface IBallerineApiPluginParams {
pluginKind: ApiBallerinePlugins;
vendor?: string;
displayName: string | undefined;
stateNames: string[];
}
Tools
Biome

[error] 7-7: Shouldn't redeclare 'IBallerineApiPluginParams'. Consider to delete it or rename it.

'IBallerineApiPluginParams' is defined here:

(lint/suspicious/noRedeclare)

vendor: 'legitscript',
callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.merchantMonitoring&processName=website-monitoring'])
withQualityControl: ${
options.merchantMonitoringQualityControl || true ? 'true' : 'false'
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix constant condition in merchant monitoring.

The condition options.merchantMonitoringQualityControl || true always evaluates to true. Consider revising the logic.

- withQualityControl: ${options.merchantMonitoringQualityControl || true ? 'true' : 'false'}
+ withQualityControl: ${options.merchantMonitoringQualityControl ? 'true' : 'false'}
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
options.merchantMonitoringQualityControl || true ? 'true' : 'false'
withQualityControl: ${options.merchantMonitoringQualityControl ? 'true' : 'false'}
Tools
Biome

[error] 393-393: Unexpected constant condition.

(lint/correctness/noConstantCondition)

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

Outside diff range and nitpick comments (3)
packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (3)

14-20: Avoid using any to enhance type safety.

The variables optionsFactoryFn and pluginOptionFactoryFn are currently typed as any. Using any undermines TypeScript's type safety features. Consider defining specific types or interfaces for these variables to improve code reliability and maintainability.


79-84: Extract hardcoded 'ballerine' string to a constant or configuration.

The string 'ballerine' is hardcoded in the replaceSecretsByProvider method. To enhance flexibility and maintainability, consider extracting it into a constant or making it configurable.


77-77: Address the TODO comment regarding plugin refactoring.

There's a TODO comment indicating that the # should be removed after refactoring plugins. Please ensure this is addressed to maintain code cleanliness.

Would you like me to assist with this task or open a new GitHub issue to track it?

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c57c8b9 and 1cf619b.

Files selected for processing (5)
  • package.json (1 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (12 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
  • services/workflows-service/src/workflow/workflow-controller-examples.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • services/workflows-service/prisma/data-migrations
Additional context used
Biome
packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts

[error] 396-396: Unexpected constant condition.

(lint/correctness/noConstantCondition)

Additional comments not posted (9)
services/workflows-service/src/workflow/workflow-controller-examples.ts (6)

4-9: LGTM!

The new plugin configuration for 'invitation-email' looks good. It uses a 'template-email' plugin kind, specifies an invitation template, and has appropriate success and error actions. The 'collection_invite' state name also indicates its usage within the invitation process.


33-33: Verify the impact of the state name change.

The state name for the 'ubo' plugin has been changed from 'get_vendor_data' to 'run_vendor_data'. Please ensure that this change is reflected consistently in all the relevant workflows and that there are no unintended consequences.

The same verification script from the previous comment can be used to check the usage of the old and new state names.


40-41: Verify the 'resubmission' template.

The 'resubmission-email' plugin now uses the 'template-email' plugin kind and specifies a 'resubmission' template. Please ensure that this template exists and is properly configured to handle resubmission emails.

Run the following script to verify the existence of the 'resubmission' template:

#!/bin/bash
# Description: Verify the existence of the 'resubmission' template.

# Test: Search for the 'resubmission' template file. Expect: Exactly one occurrence.
fd --type file --glob '*resubmission*' --hidden --no-ignore templates/

46-59: Verify the merchant monitoring setup and configuration.

The new 'merchant_monitoring' plugin introduces a merchant monitoring capability using the Ballerine system. Please ensure that the necessary infrastructure and configurations are in place to support this feature.

Additionally, review the provided data mapping:

countryCode: entity.data.country,
websiteUrl: entity.data.additionalInfo.store.website.mainWebsite,

Verify that the correct data is being mapped and passed to the monitoring process.

Run the following script to verify the usage of the mapped data fields:

#!/bin/bash
# Description: Verify the usage of the mapped data fields for the 'merchant_monitoring' plugin.

# Test 1: Search for the usage of 'entity.data.country'. Expect: Occurrences only in relevant data mappings.
rg --type typescript $'entity\.data\.country'

# Test 2: Search for the usage of 'entity.data.additionalInfo.store.website.mainWebsite'. Expect: Occurrences only in relevant data mappings.
rg --type typescript $'entity\.data\.additionalInfo\.store\.website\.mainWebsite'

21-24: Verify the impact of the plugin renaming and state name change.

The 'company-sanctions' plugin has been renamed to 'companySanctions', and its state name has been updated to 'run_vendor_data'. Please ensure that these changes are propagated consistently throughout the codebase and that there are no unintended side effects.

Run the following script to verify the usage of the old and new plugin names and state names:

#!/bin/bash
# Description: Verify the usage of the old and new plugin names and state names for the 'company-sanctions' plugin.

# Test 1: Search for the old plugin name. Expect: No occurrences.
rg --type typescript $'company-sanctions'

# Test 2: Search for the new plugin name. Expect: Occurrences only in relevant configurations.
rg --type typescript -A 5 $'companySanctions'

# Test 3: Search for the old state name. Expect: No occurrences.
rg --type typescript $'get_vendor_data'

# Test 4: Search for the new state name. Expect: Occurrences only in relevant workflows.
rg --type typescript -A 5 $'run_vendor_data'

15-15: Verify the impact of the state name change.

The state name for the 'kyb' plugin has been changed from 'get_vendor_data' to 'run_vendor_data'. Please ensure that this change is reflected consistently in all the relevant workflows and that there are no unintended consequences.

Run the following script to verify the usage of the old and new state names:

package.json (1)

33-33: LGTM!

The new script command run-kyb-web-apps is well-structured and follows the established pattern. It sets the necessary environment variables and uses concurrently to run the KYB web application commands simultaneously. This addition enhances the development process without introducing any breaking changes.

packages/workflow-core/src/lib/plugins/external-plugin/ballerine-plugin.ts (1)

6-11: Fix redeclaration issue for IBallerineApiPluginParams.

The IBallerineApiPluginParams interface is redeclared in this file. Consider deleting or renaming it to avoid conflicts.

packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (1)

396-396: Fix constant condition in merchant monitoring

The condition options.merchantMonitoringQualityControl || true always evaluates to true, making the ternary operator redundant. Consider revising the logic.

Apply this diff to fix the condition:

-withQualityControl: ${
-  options.merchantMonitoringQualityControl || true ? 'true' : 'false'
-}
+withQualityControl: ${
+  options.merchantMonitoringQualityControl ? 'true' : 'false'
+}
Tools
Biome

[error] 396-396: Unexpected constant condition.

(lint/correctness/noConstantCondition)

},
}),
supportEmail: join('',['support@',entity.data.additionalInfo.customerCompany,'.com']),
adapter: '{secrets.MAIL_ADAPTER}'
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct template variable {secrets.MAIL_ADAPTER}

There's a typo in the template variable. It should be {secret.MAIL_ADAPTER} to match the usage elsewhere in the code.

Apply this diff to fix the typo:

-  adapter: '{secrets.MAIL_ADAPTER}'
+  adapter: '{secret.MAIL_ADAPTER}'
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
adapter: '{secrets.MAIL_ADAPTER}'
adapter: '{secret.MAIL_ADAPTER}'

[BALLERINE_API_PLUGINS['merchant-monitoring']]: {
[MERCHANT_MONITORING_VENDORS['ballerine']]: (options: MerchantMonirotingOptions) => ({
name: 'merchantMonitoring',
pluginKind: 'api',
Copy link
Contributor

Choose a reason for hiding this comment

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

Set correct pluginKind for Merchant Monitoring Plugin

The pluginKind is currently set to 'api', but it should be 'merchant-monitoring' to match the defined pluginKind in MerchantMonitoringOptions.

Apply this diff to correct the pluginKind:

-pluginKind: 'api',
+pluginKind: 'merchant-monitoring',
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pluginKind: 'api',
pluginKind: 'merchant-monitoring',

Comment on lines +103 to +113
pluginKind: 'merchant-monitoring';
vendor: MerchantMonitoringVendors;
dataMapping?: string;
merchantMonitoringQualityControl: boolean;
reportType?:
| 'MERCHANT_REPORT_T1'
| 'MERCHANT_REPORT_T2'
| 'ONGOING_MERCHANT_REPORT_T1'
| 'ONGOING_MERCHANT_REPORT_T2';
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Fix typo in type name: MerchantMonirotingOptions

The type name MerchantMonirotingOptions appears to have a typo. It should be MerchantMonitoringOptions.

Apply this diff to correct the typo:

-type MerchantMonirotingOptions = {
+type MerchantMonitoringOptions = {
  pluginKind: 'merchant-monitoring';
  vendor: MerchantMonitoringVendors;
  dataMapping?: string;
  merchantMonitoringQualityControl: boolean;
  reportType?:
    | 'MERCHANT_REPORT_T1'
    | 'MERCHANT_REPORT_T2'
    | 'ONGOING_MERCHANT_REPORT_T1'
    | 'ONGOING_MERCHANT_REPORT_T2';
};

Also, update all references to this type:

// In line 157
-| MerchantMonirotingOptions
+| MerchantMonitoringOptions

// In line 379
[MERCHANT_MONITORING_VENDORS['ballerine']]: (options: MerchantMonitoringOptions) => ({

Committable suggestion was skipped due to low confidence.

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

🧹 Outside diff range and nitpick comments (2)
packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (2)

570-570: Address TODO comment regarding token creation

There's a TODO comment about creating a new token. This should be addressed to ensure proper functionality.

Please implement the new token creation logic or provide more context on why this TODO exists and when it will be addressed.


589-590: Resolve TODO comment about mail adapter configuration

There's a TODO comment about figuring out the mail adapter from env or secrets. This should be resolved to ensure proper configuration.

Please determine and implement the correct way to configure the mail adapter, either from environment variables or secrets.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between baad4cf and b9eac99.

📒 Files selected for processing (2)
  • packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts (7 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeQL
packages/workflow-core/src/lib/plugins/external-plugin/api-plugin.ts

[failure] 311-311: Polynomial regular expression used on uncontrolled data
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.

🔇 Additional comments (9)
packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (9)

1-80: LGTM: Well-structured constant and type definitions

The constant and type definitions in this section are well-structured and follow a consistent pattern. They provide a clear organization for different vendor types and plugin configurations.


81-175: LGTM: Well-designed plugin types and options

The plugin factory helper types, ApiBallerinePlugin type, and various vendor-specific option types are well-structured and provide good type safety. They cover the necessary configurations for different plugins and vendors.


176-223: LGTM: Robust TPluginFactory type definition

The TPluginFactory type is well-designed and provides a flexible yet type-safe structure for different plugin kinds and their respective vendors. It effectively uses advanced TypeScript features like conditional types and mapped types to ensure type correctness across various plugin configurations.


231-238: LGTM: Well-implemented getKycEntityMapping function

The getKycEntityMapping function is correctly implemented and provides appropriate mappings based on the takeEntityDetailFromKyc parameter.


239-712: LGTM: Well-structured BALLERINE_API_PLUGIN_FACTORY

The overall structure and organization of the BALLERINE_API_PLUGIN_FACTORY object is consistent and well-designed. It provides comprehensive configurations for various plugins and vendors.


224-229: ⚠️ Potential issue

Fix typo in constant name: BASE_SANCSIONS_SCREENING_OPTIONS

There's a typo in the constant name BASE_SANCSIONS_SCREENING_OPTIONS. It should be BASE_SANCTIONS_SCREENING_OPTIONS.

Apply this diff to correct the typo:

-const BASE_SANCSIONS_SCREENING_OPTIONS = {
+const BASE_SANCTIONS_SCREENING_OPTIONS = {
  url: '{secret.UNIFIED_API_URL}/aml-sessions',
  headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' },
  method: 'POST' as const,
  displayName: 'Sanctions Screening',
};

Also, update all references to this constant throughout the file.

Likely invalid or redundant comment.


436-438: ⚠️ Potential issue

Fix constant condition in merchant monitoring plugin

The condition options.merchantMonitoringQualityControl ?? true ? 'true' : 'false' will always evaluate to 'true' due to the ?? true part.

Apply this diff to correct the condition:

-withQualityControl: ${options.merchantMonitoringQualityControl ?? true ? 'true' : 'false'}
+withQualityControl: ${options.merchantMonitoringQualityControl ? 'true' : 'false'}

Likely invalid or redundant comment.


420-424: ⚠️ Potential issue

Fix incorrect pluginKind in merchant monitoring plugin

The pluginKind for the merchant monitoring plugin is incorrectly set to 'api'. It should be 'merchant-monitoring' to match the plugin's actual kind.

Apply this diff to correct the pluginKind:

-pluginKind: 'api',
+pluginKind: 'merchant-monitoring',

Likely invalid or redundant comment.


98-108: ⚠️ Potential issue

Fix typo in type name: MerchantMonirotingOptions

There's a typo in the type name MerchantMonirotingOptions. It should be MerchantMonitoringOptions.

Apply this diff to correct the typo:

-type MerchantMonirotingOptions = {
+type MerchantMonitoringOptions = {
  pluginKind: 'merchant-monitoring';
  vendor: MerchantMonitoringVendors;
  dataMapping?: string;
  merchantMonitoringQualityControl: boolean;
  reportType?:
    | 'MERCHANT_REPORT_T1'
    | 'MERCHANT_REPORT_T2'
    | 'ONGOING_MERCHANT_REPORT_T1'
    | 'ONGOING_MERCHANT_REPORT_T2';
};

Also, update all references to this type throughout the file.

Likely invalid or redundant comment.

Comment on lines 1 to 712
kybCompanyName: entity.data.additionalInfo.companyName,
customerCompanyName: entity.data.additionalInfo.customerCompany,
firstName: entity.data.firstName,
kycLink: pluginsOutput.kyc_session.kyc_session_1.result.metadata.url,
from: '[email protected]',
name: join(' ',[entity.data.additionalInfo.customerCompany,'Team']),
receivers: [entity.data.email],
subject: '{customerCompanyName} activation, Action needed.',
templateId: ${
options.templateId
? `'${options.templateId}'`
: `(documents[].decision[].revisionReason | [0] != null) && 'd-2c6ae291d9df4f4a8770d6a4e272d803' || 'd-61c568cfa5b145b5916ff89790fe2065'`
},
revisionReason: documents[].decision[].revisionReason | [0],
language: workflowRuntimeConfig.language,
supportEmail: join('',['support@',entity.data.additionalInfo.customerCompany,'.com']),
adapter: '{secret.MAIL_ADAPTER}'
}`, // jmespath
},
],
},
response: {
transform: [],
},
}),
[EMAIL_TEMPLATES['invitation']]: (options: EmailOptions) => ({
name: 'invitation',
template: EMAIL_TEMPLATES['invitation'],
pluginKind: 'invitation',
url: `{secret.EMAIL_API_URL}`,
method: 'POST',
headers: {
Authorization: 'Bearer {secret.EMAIL_API_TOKEN}',
'Content-Type': 'application/json',
},
request: {
transform: [
{
transformer: 'jmespath',
mapping: `{
${options.dataMapping || ''}
customerName: metadata.customerName,
collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]),
from: '[email protected]',
receivers: [entity.data.additionalInfo.mainRepresentative.email],
language: workflowRuntimeConfig.language,
templateId: ${
options.templateId
? `'${options.templateId}'`
: `'d-8949519316074e03909042cfc5eb4f02'`
},
adapter: '{secret.MAIL_ADAPTER}'
}`, // jmespath
},
],
},
response: {
transform: [],
},
}),
},
[BALLERINE_API_PLUGINS['kyc-session']]: {
[KYC_VENDORS['veriff']]: (options: KycSessionOptions) => ({
...(options ?? {}),
name: 'kyc_session',
pluginKind: 'kyc-session',
vendor: 'veriff',
url: `{secret.UNIFIED_API_URL}/individual-verification-sessions`,
method: 'POST',
headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' },
request: {
transform: [
{
transformer: 'jmespath',
mapping: `{
${options.dataMapping || ''}
endUserId: join('__',[entity.ballerineEntityId || entity.data.id || entity.data.identityNumber, pluginsOutput.kyc_session.kyc_session_1.result.metadata.id || '']),
firstName: entity.data.firstName,
lastName: entity.data.lastName,
callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/KYC_RESPONSE_RECEIVED','?resultDestination=pluginsOutput.kyc_session.kyc_session_1.result']),
vendor: 'veriff',
withAml: ${options.withAml ?? false ? 'true' : 'false'}
}`, // jmespath
},
],
},
response: {
transform: [
{
transformer: 'jmespath',
mapping: "{kyc_session_1: {vendor: 'veriff', type: 'kyc', result: {metadata: @}}}", // jmespath
},
],
},
}),
},
} satisfies TPluginFactory;
// Record<ApiBallerinePlugins, PluginFactoryFn> |
// Record<'individual-sanctions', Record<ApiIndividualScreeningVendors, PluginFactoryFn>> |
// Record<'company-sanctions', Record<ApiCompanyScreeningVendors, PluginFactoryFn>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Confirmed Issues in vendor-consts.ts

The shell script execution has confirmed the presence of the previously identified issues in packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts. Please address the following:

  1. Typographical Errors

    • MerchantMonirotingOptions should be corrected to MerchantMonitoringOptions.
    • BASE_SANCSIONS_SCREENING_OPTIONS should be corrected to BASE_SANCTIONS_SCREENING_OPTIONS.
  2. Incorrect pluginKind

    • The pluginKind for the merchant monitoring plugin is incorrectly set to 'api'. It should be updated to the appropriate value, such as 'merchant-monitoring'.
  3. Faulty Condition Logic

    • The condition merchantMonitoringQualityControl ?? true ? 'true' : 'false' should be revised to ensure it correctly reflects the intended logic.
  4. Consistent Use of Template Variables

    • Ensure that all template variables, such as {secret.MAIL_ADAPTER}, are consistently and correctly used throughout the codebase.

Addressing these issues will improve the code's reliability and maintainability.

🔗 Analysis chain

Overall assessment: Well-structured with some areas for improvement

The file provides a comprehensive set of constants, types, and plugin configurations for the workflow core. The structure is generally good, but there are several areas that need attention:

  1. Fix typos in type and constant names (e.g., MerchantMonirotingOptions, BASE_SANCSIONS_SCREENING_OPTIONS).
  2. Correct the pluginKind for the merchant monitoring plugin.
  3. Fix the constant condition in the merchant monitoring plugin's withQualityControl option.
  4. Ensure consistent use of template variables (e.g., {secret.MAIL_ADAPTER}).
  5. Implement proper token creation and mail adapter configuration as mentioned in the TODO comments.

Addressing these issues will significantly improve the code quality and maintainability of this file.

To ensure all instances of the identified issues are addressed, run the following script:

This will help ensure all instances of the identified issues are located and addressed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find occurrences of identified issues

echo "Occurrences of 'MerchantMonirotingOptions':"
rg 'MerchantMonirotingOptions' --type typescript

echo "\nOccurrences of 'BASE_SANCSIONS_SCREENING_OPTIONS':"
rg 'BASE_SANCSIONS_SCREENING_OPTIONS' --type typescript

echo "\nOccurrences of 'pluginKind: 'api'' in merchant monitoring:"
rg "pluginKind:\s*'api'" --type typescript -C 5 | rg -C 5 'merchant.*monitoring'

echo "\nOccurrences of 'merchantMonitoringQualityControl ?? true':"
rg 'merchantMonitoringQualityControl\s*\?\?\s*true' --type typescript

echo "\nOccurrences of '{secrets.MAIL_ADAPTER}':"
rg '{secrets\.MAIL_ADAPTER}' --type typescript

echo "\nOccurrences of TODO comments:"
rg 'TODO:' --type typescript

Length of output: 1295


Script:

#!/bin/bash
# Description: Find occurrences of identified issues by targeting .ts and .tsx files

echo "Occurrences of 'MerchantMonirotingOptions':"
rg 'MerchantMonirotingOptions' -g "*.ts" -g "*.tsx"

echo "\nOccurrences of 'BASE_SANCSIONS_SCREENING_OPTIONS':"
rg 'BASE_SANCSIONS_SCREENING_OPTIONS' -g "*.ts" -g "*.tsx"

echo "\nOccurrences of 'pluginKind: 'api'' in merchant monitoring:"
rg "pluginKind:\s*'api'" -g "*.ts" -g "*.tsx" -C 5 | rg -C 5 'merchant.*monitoring'

echo "\nOccurrences of 'merchantMonitoringQualityControl ?? true':"
rg 'merchantMonitoringQualityControl\s*\?\?\s*true' -g "*.ts" -g "*.tsx"

echo "\nOccurrences of '{secret.MAIL_ADAPTER}':"
rg '{secret\.MAIL_ADAPTER}' -g "*.ts" -g "*.tsx"

echo "\nOccurrences of TODO comments:"
rg 'TODO:' -g "*.ts" -g "*.tsx"

Length of output: 14530

const secretKey = variableKey.replace('secrets.', '');
const secretValue = `${await this.fetchSecret(secretKey)}`;
async replaceVariablesFromContext(content: string, context: TContext) {
const placeholders = content.match(/{(.*?)}/g);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the regular expression to prevent ReDoS vulnerability

The regular expression on line 311 can be exploited for Regular Expression Denial of Service (ReDoS) attacks due to catastrophic backtracking when processing malicious input. To mitigate this risk, consider using a safer regular expression that avoids this vulnerability.

Apply this diff to fix the vulnerability:

-        const placeholders = content.match(/{(.*?)}/g);
+        const placeholders = content.match(/{[^{}]*}/g);

This change ensures that the regular expression only matches placeholders without nested braces, preventing potential performance issues from malicious input.

📝 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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const placeholders = content.match(/{(.*?)}/g);
const placeholders = content.match(/{[^{}]*}/g);
🧰 Tools
🪛 GitHub Check: CodeQL

[failure] 311-311: Polynomial regular expression used on uncontrolled data
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.
This regular expression that depends on library input may run slow on strings starting with '{{' and with many repetitions of '{{a'.

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: 2

🧹 Outside diff range and nitpick comments (3)
packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (3)

570-570: Implement token creation as per TODO comment

There's a TODO comment about creating a new token. This functionality needs to be implemented.

Would you like assistance in implementing the token creation logic?


589-589: Resolve adapter configuration as per TODO comment

There's a TODO comment about figuring out the adapter from env or secrets. This needs to be addressed to ensure proper configuration.

Would you like assistance in determining the best approach for configuring the adapter?


1-712: Summary of review findings and recommendations

Overall, the file is well-structured and provides a comprehensive set of constants, types, and plugin configurations for the workflow core. However, there are several areas that need attention:

  1. Fix typos in type and constant names (e.g., MerchantMonirotingOptions, BASE_SANCSIONS_SCREENING_OPTIONS).
  2. Address the TODO comments, particularly regarding the deprecation of country in favor of address.country.
  3. Correct the pluginKind for the merchant monitoring plugin.
  4. Fix the constant condition in the merchant monitoring plugin's withQualityControl option.
  5. Ensure consistent use of template variables (e.g., {secret.MAIL_ADAPTER}).
  6. Implement proper token creation and mail adapter configuration as mentioned in the TODO comments.

Addressing these issues will significantly improve the code quality and maintainability of this file.

Consider breaking down this large file into smaller, more focused modules to improve maintainability. For example, you could separate the constants, type definitions, and plugin configurations into different files.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f7f61d7 and 035fd7b.

📒 Files selected for processing (2)
  • apps/kyb-app/amplify.yml (1 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/kyb-app/amplify.yml
🧰 Additional context used
🔇 Additional comments (5)
packages/workflow-core/src/lib/plugins/external-plugin/vendor-consts.ts (5)

239-709: LGTM: Well-structured plugin factory

The BALLERINE_API_PLUGIN_FACTORY is well-organized and provides a flexible, type-safe way to create different types of plugins. The use of helper types like PluginFactoryFnHelper, PluginVendorFnHelper, and PluginEmailFnHelper ensures type consistency across different plugin configurations.


98-108: ⚠️ Potential issue

Fix typo in type name: MerchantMonirotingOptions

There's a typo in the type name MerchantMonirotingOptions. It should be MerchantMonitoringOptions.

Apply this diff to correct the typo:

-type MerchantMonirotingOptions = {
+type MerchantMonitoringOptions = {
  pluginKind: 'merchant-monitoring';
  vendor: MerchantMonitoringVendors;
  dataMapping?: string;
  merchantMonitoringQualityControl: boolean;
  reportType?:
    | 'MERCHANT_REPORT_T1'
    | 'MERCHANT_REPORT_T2'
    | 'ONGOING_MERCHANT_REPORT_T1'
    | 'ONGOING_MERCHANT_REPORT_T2';
};

Also, update all references to this type throughout the file.

Likely invalid or redundant comment.


423-423: ⚠️ Potential issue

Set correct pluginKind for Merchant Monitoring Plugin

The pluginKind is currently set to 'api', but it should be 'merchant-monitoring' to match the defined pluginKind in MerchantMonitoringOptions.

Apply this diff to correct the pluginKind:

-pluginKind: 'api',
+pluginKind: 'merchant-monitoring',

Likely invalid or redundant comment.


436-438: ⚠️ Potential issue

Fix constant condition in merchant monitoring plugin

The condition options.merchantMonitoringQualityControl ?? true ? 'true' : 'false' will always evaluate to 'true' due to the ?? true part.

Apply this diff to correct the condition:

-withQualityControl: ${options.merchantMonitoringQualityControl ?? true ? 'true' : 'false'}
+withQualityControl: ${options.merchantMonitoringQualityControl ? 'true' : 'false'}

Likely invalid or redundant comment.


224-229: ⚠️ Potential issue

Fix typo in constant name: BASE_SANCSIONS_SCREENING_OPTIONS

There's a typo in the constant name BASE_SANCSIONS_SCREENING_OPTIONS. It should be BASE_SANCTIONS_SCREENING_OPTIONS.

Apply this diff to correct the typo:

-const BASE_SANCSIONS_SCREENING_OPTIONS = {
+const BASE_SANCTIONS_SCREENING_OPTIONS = {
  url: '{secret.UNIFIED_API_URL}/aml-sessions',
  headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' },
  method: 'POST' as const,
  displayName: 'Sanctions Screening',
};

Also, update all references to this constant throughout the file.

Likely invalid or redundant comment.

? `'${options.templateId}'`
: `'d-706793b7bef041ee86bf12cf0359e76d'`
},
adapter: '{secret.MAIL_ADAPTER}'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure consistent use of {secret.MAIL_ADAPTER}

There are inconsistent uses of {secret.MAIL_ADAPTER} and {secrets.MAIL_ADAPTER} in the email template configurations. Ensure that the correct version is used consistently.

Review and update all occurrences to use the correct secret reference:

-adapter: '{secrets.MAIL_ADAPTER}'
+adapter: '{secret.MAIL_ADAPTER}'

Also applies to: 577-577, 618-618, 653-653

pluginKind: 'company-sanctions',
vendor: 'asia-verify',
url: {
url: `{secret.UNIFIED_API_URL}/companies/{country}/{entity.data.companyName}/sanctions`,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Extensive usage of 'country' found

The analysis shows that the term 'country' is used extensively across numerous files in the codebase, while 'address.country' is referenced significantly fewer times. Deprecating 'country' in favor of 'address.country' would require comprehensive refactoring to ensure consistency and prevent potential issues.

🔗 Analysis chain

Address TODO regarding 'country' usage

There's a TODO comment suggesting to deprecate the use of 'country' in favor of 'address.country'. This change should be implemented to improve consistency across the codebase.

Would you like assistance in creating a plan to replace 'country' with 'address.country' throughout the codebase?

Run the following script to verify the current usage of 'country' and 'address.country':

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find occurrences of 'country' and 'address.country' in TypeScript files

echo "Occurrences of 'country':"
rg '\bcountry\b' -g '*.ts' -g '*.tsx'

echo "\nOccurrences of 'address.country':"
rg 'address\.country' -g '*.ts' -g '*.tsx'

Length of output: 78442

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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 035fd7b and 93ad5df.

📒 Files selected for processing (2)
  • apps/kyb-app/package.json (1 hunks)
  • apps/workflows-dashboard/package.json (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
apps/workflows-dashboard/package.json (1)

9-9: Approve the addition of the "start" script, but clarification needed.

The addition of the "start" script with the command "vite" is a good practice and aligns with common conventions in React projects. However, there are a couple of points to consider:

  1. The existing "dev" script already uses Vite with the "--host" flag. Could you clarify the intended difference between the "start" and "dev" scripts?

  2. If the intention is to have a script without network access, the current implementation achieves that. However, for consistency, you might consider:

    a) Renaming "start" to "dev" and "dev" to "dev:network" for clarity.
    b) Using "vite --host" for "start" to match "dev", ensuring consistent behavior.

To ensure there are no unintended side effects, please run the following command:

This will help verify the consistency of script naming across the project.

✅ Verification successful

The addition of the "start" script is consistent and appropriate.

The new "start": "vite" script aligns with the existing conventions across the codebase. It provides a standard way to initiate the Vite development server without the --host flag, differentiating it from the "dev": "vite --host" script, which allows network access.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any other occurrences of 'start' or 'dev' scripts in other package.json files
fd package.json | xargs grep -n '"start"\|"dev"'

Length of output: 1754

@@ -5,6 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"start": "vite",
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider differentiating between start and dev scripts

The addition of the "start": "vite" script creates redundancy with the existing "dev": "vite" script. This might lead to confusion among developers about which command to use.

Typically, in Node.js projects:

  • The start script is used to run the application in a production environment.
  • The dev script is used for development purposes.

Consider the following suggestions:

  1. If the intention is to have a production start command, modify the start script to run a production build:
    "start": "vite build && vite preview"
  2. If both commands are intended for development, consider removing one to avoid confusion:
    "dev": "vite"
  3. If there's a specific reason for having both, add comments in the package.json to explain the difference between start and dev.

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: 1

🧹 Outside diff range and nitpick comments (2)
packages/workflow-core/src/lib/workflow-runner.test.unit.ts (2)

Line range hint 273-308: LGTM with suggestion: Consider balancing specific and structural assertions.

The changes to the API plugin initialization test, including the addition of pluginKind: 'api' and the shift to specific property assertions, improve the test's focus and resilience. However, consider maintaining some structural assertions to catch unexpected changes in the plugin structure.

For example, you could add an assertion to check if the plugin has any unexpected properties:

const expectedKeys = ['name', 'stateNames', 'url', 'method', /* other expected keys */];
expect(Object.keys(result[0])).toEqual(expect.arrayContaining(expectedKeys));
expect(Object.keys(result[0])).toHaveLength(expectedKeys.length);

This balances specific property checks with overall structure validation.


Line range hint 350-384: LGTM: Consistent changes to common plugin initialization test with new iterateOn property.

The changes to the common plugin initialization test, including the addition of pluginKind: 'iterative' and the shift to specific property assertions, are consistent with the changes made to other plugin tests. These improvements enhance the test's focus and resilience.

The addition of the iterateOn property with a JMESPath transformer is a valuable inclusion specific to iterative plugins. This ensures that the iterateOn functionality is properly tested.

As suggested in previous comments, consider balancing these specific property checks with some structural assertions to catch unexpected changes in the plugin structure.

Additionally, you might want to add a more detailed test for the iterateOn property to ensure it behaves correctly:

expect(result[0]?.iterateOn[0].transform({ users: ['user1', 'user2'] })).toEqual(['user1', 'user2']);

This would verify that the JMESPath transformer is correctly extracting the 'users' array.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 93ad5df and 461e1bd.

📒 Files selected for processing (3)
  • packages/workflow-core/src/lib/plugins/common-plugin/iterative-plugin.test.ts (1 hunks)
  • packages/workflow-core/src/lib/plugins/external-plugin/webhook-plugin.test.ts (1 hunks)
  • packages/workflow-core/src/lib/workflow-runner.test.unit.ts (8 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/workflow-core/src/lib/plugins/common-plugin/iterative-plugin.test.ts
  • packages/workflow-core/src/lib/plugins/external-plugin/webhook-plugin.test.ts
🧰 Additional context used
🔇 Additional comments (4)
packages/workflow-core/src/lib/workflow-runner.test.unit.ts (4)

101-101: LGTM: Addition of pluginKind property enhances clarity.

The addition of pluginKind: 'api' to the API plugin definition improves type safety and makes the code more self-documenting. This change is consistent with the enhancements mentioned in the summary and clarifies the plugin's role within the workflow.


152-152: LGTM: Consistent addition of pluginKind property.

The addition of pluginKind: 'api' to this API plugin definition is consistent with the previous change and maintains consistency across the codebase. This improves the overall clarity and type safety of the plugin definitions.


176-176: LGTM: Addition of pluginKind property to common plugin.

The addition of pluginKind: 'iterative' to the common plugin definition is consistent with the changes made to other plugin types. This clarifies that it's an iterative plugin, improving type safety and making the code more self-documenting.


Line range hint 314-343: LGTM: Consistent changes to child plugin initialization test.

The changes to the child plugin initialization test, including the addition of pluginKind: 'child' and the shift to specific property assertions, are consistent with the changes made to the API plugin test. These improvements enhance the test's focus and resilience.

As suggested in the previous comment, consider balancing these specific property checks with some structural assertions to catch unexpected changes in the plugin structure.

@@ -134,7 +135,7 @@ describe('sendEvent #unit', () => {
// expect(res.isDone()).toBe(true);
});

it('should execute common plugins', async () => {
it.skip('should execute common plugins', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Clarify reason for skipping 'execute common plugins' test.

Skipping tests can lead to reduced test coverage. If there's a valid reason for skipping this test (e.g., ongoing refactoring or known issues), please add a TODO comment explaining why it's skipped and when it will be re-enabled. If it's no longer relevant, consider removing the test entirely.

@alonp99 alonp99 merged commit d8b55d3 into dev Oct 13, 2024
3 checks passed
@alonp99 alonp99 deleted the bal-2513-email-plugin-fixes branch October 13, 2024 08:49
tomer-shvadron added a commit that referenced this pull request Oct 13, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 13, 2024
@Omri-Levy Omri-Levy mentioned this pull request Nov 4, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 12, 2024
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.

4 participants