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

In case insensitive risk rule engine operator #2790

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open

Conversation

tomer-shvadron
Copy link
Collaborator

@tomer-shvadron tomer-shvadron commented Oct 20, 2024

  • feat: in case insensitive risk rule engine operator
  • feat: migration commit push

Summary by CodeRabbit

  • New Features
    • Introduced a case insensitive risk rule engine operator in the workflows service.
  • Dependency Updates
    • Updated @ballerine/common to version 0.9.44 across multiple projects.
    • Updated @ballerine/workflow-core to version 0.6.56 across multiple projects.
    • Updated @ballerine/workflow-node-sdk to version 0.6.56 in the workflows service.
    • Updated @ballerine/workflow-browser-sdk to version 0.6.56.
    • Updated @ballerine/web-ui-sdk to version 1.5.45.
  • Bug Fixes
    • Enhanced functionality for handling a new field type, unique_id, in the Notion service.
  • Tests
    • Added integration tests for the RuleEngineService, including validation for the new IN_CASE_INSENSITIVE operator.
    • Expanded unit tests for various operators in the rule engine, improving error handling and nested property validation.

Copy link

changeset-bot bot commented Oct 20, 2024

⚠️ No Changeset found

Latest commit: 39b6d1d

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 Oct 20, 2024

Walkthrough

This pull request introduces version updates across multiple packages in the @ballerine ecosystem, primarily focusing on updating the @ballerine/common, @ballerine/workflow-browser-sdk, and @ballerine/workflow-node-sdk dependencies. The changelogs for each package have been updated to reflect these changes, including a new feature for a case insensitive risk rule engine operator in the @ballerine/workflows-service. Additionally, integration and unit tests have been added or enhanced to ensure proper functionality of the new and existing features.

Changes

File Path Change Summary
apps/backoffice-v2/CHANGELOG.md Updated to version 0.7.59, detailing dependency updates.
apps/backoffice-v2/package.json Version updated to 0.7.59; dependencies updated: @ballerine/common, @ballerine/workflow-browser-sdk, @ballerine/workflow-node-sdk.
apps/kyb-app/CHANGELOG.md Updated to version 0.3.70, detailing dependency updates.
apps/kyb-app/package.json Version updated to 0.3.70; dependencies updated: @ballerine/common, @ballerine/workflow-browser-sdk.
examples/headless-example/CHANGELOG.md Updated to version 0.3.55, detailing dependency updates.
examples/headless-example/package.json Version updated to 0.3.55; dependencies updated: @ballerine/common, @ballerine/workflow-browser-sdk.
packages/common/CHANGELOG.md Updated to version 0.9.44, indicating a patch change for the risk rule engine operator.
packages/common/package.json Version updated to 0.9.44.
packages/common/src/rule-engine/operators/constants.ts Added constant IN_CASE_INSENSITIVE.
packages/common/src/rule-engine/operators/helpers.ts Updated BaseOperator class with new generic types; added InCaseInsensitive class.
packages/common/src/rule-engine/operators/types.ts Updated ConditionFn type; removed OperationHelper type.
packages/workflow-core/CHANGELOG.md Updated to version 0.6.56, detailing dependency updates.
packages/workflow-core/package.json Version updated to 0.6.56; dependency updated: @ballerine/common.
sdks/web-ui-sdk/CHANGELOG.md Updated to version 1.5.45, detailing dependency updates.
sdks/web-ui-sdk/package.json Version updated to 1.5.45; dependency updated: @ballerine/common.
sdks/workflow-browser-sdk/CHANGELOG.md Updated to version 0.6.56, detailing dependency updates.
sdks/workflow-browser-sdk/package.json Version updated to 0.6.56; dependencies updated: @ballerine/common, @ballerine/workflow-core.
sdks/workflow-node-sdk/CHANGELOG.md Updated to version 0.6.56, detailing dependency updates.
sdks/workflow-node-sdk/package.json Version updated to 0.6.56; dependency updated: @ballerine/workflow-core.
services/workflows-service/CHANGELOG.md Updated to version 0.7.59, introducing a new case insensitive risk rule engine operator.
services/workflows-service/package.json Version updated to 0.7.59; dependencies updated: @ballerine/common, @ballerine/workflow-core, @ballerine/workflow-node-sdk.
services/workflows-service/src/notion/notion.service.ts Updated to handle new unique_id field type in transformNotionFieldToValue.
services/workflows-service/src/rule-engine/rule-engine.service.intg.test.ts New integration tests for RuleEngineService, validating IN_CASE_INSENSITIVE functionality.
services/workflows-service/src/rule-engine/core/test/rule-engine.unit.test.ts Enhanced unit tests for rule engine operators and error handling.
websites/docs/package.json Dependency updated: @ballerine/common from ^0.9.43 to ^0.9.44.

Possibly related PRs

Suggested reviewers

  • alonp99: Suggested reviewer for the changes made in this PR.

Poem

🐰 In the patch of code, we hop and play,
Updating dependencies, come what may.
With case insensitivity, our rules now shine,
A rabbit's joy in every line!
So let’s celebrate, with carrots and cheer,
For a smoother workflow, year after year! 🥕


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 and nitpick comments (12)
packages/common/src/rule-engine/operators/constants.ts (1)

30-30: LGTM: Addition of IN_CASE_INSENSITIVE to OperationHelpers

The new entry for IN_CASE_INSENSITIVE is correctly added to the OperationHelpers object, following the existing pattern and maintaining type safety with the as const assertion. This addition completes the implementation of the new case-insensitive operator in the constants file.

Consider grouping related operations together for better code organization. For example, you could move this new entry next to the IN operation:

export const OperationHelpers = {
  // ... other operations
  [OPERATION.IN]: IN,
  [OPERATION.IN_CASE_INSENSITIVE]: IN_CASE_INSENSITIVE,
  [OPERATION.NOT_IN]: NOT_IN,
  // ... remaining operations
} as const;

This grouping would make it easier to locate and maintain related operations in the future.

packages/common/src/rule-engine/operators/enums.ts (1)

12-12: LGTM! Consider adding a brief comment for clarity.

The addition of IN_CASE_INSENSITIVE to the OPERATION object is consistent with the PR objective and follows the existing naming conventions. Well done!

To improve maintainability, consider adding a brief comment explaining the purpose of this new operation. For example:

// Performs a case-insensitive 'IN' operation
IN_CASE_INSENSITIVE: 'IN_CASE_INSENSITIVE',
packages/common/src/rule-engine/operators/types.ts (1)

9-9: LGTM! Consider grouping related imports.

The addition of OPERATION and OPERATOR imports aligns with the PR objective. To improve code organization, consider grouping related imports together.

You could group the imports like this:

import { z, ZodSchema } from 'zod';
import {
  AmlCheckSchema,
  BetweenSchema,
  LastYearsSchema,
  PrimitiveSchema,
} from '@/rule-engine/operators/schemas';
import { OPERATION, OPERATOR } from './enums';
websites/docs/package.json (1)

20-20: LGTM: Dependency version update looks good.

The update of @ballerine/common from ^0.9.43 to ^0.9.44 is consistent with the broader changes across the project. This minor version bump likely includes backward-compatible new features or bug fixes.

Don't forget to update the changelog if there are any notable changes or features introduced in this new version of @ballerine/common.

services/workflows-service/src/rule-engine/rule-engine.service.intg.test.ts (3)

16-31: LGTM: Well-structured test case for IN_CASE_INSENSITIVE rule.

The test case setup correctly defines rules to test the new IN_CASE_INSENSITIVE operator. The structure and combination of rules are appropriate.

Consider adding a descriptive comment above the rules constant to explain the purpose of these specific rules, enhancing the test's readability.


38-43: LGTM with suggestions: Test execution is correct, but assertions could be more robust.

The test correctly executes the rule engine and checks for 'PASSED' status. However, consider enhancing the assertions for more comprehensive testing:

  1. Verify the number of rules in the result:
expect(result.length).toBe(2);
  1. Check individual rule results:
expect(result[0].status).toBe('PASSED');
expect(result[0].key).toBe('single');
expect(result[1].status).toBe('PASSED');
expect(result[1].key).toBe('array');

These additions will make the test more robust and informative.


1-44: Overall: Good test implementation with room for expansion.

This integration test effectively covers the new IN_CASE_INSENSITIVE rule, aligning well with the PR objectives. The test structure is sound and follows good practices.

To further improve the test suite:

  1. Consider adding more test cases to cover edge cases, such as:
    • Empty strings or arrays
    • Mixed case input
    • Special characters or numbers in the input
  2. Add a negative test case where the rule should fail.
  3. Test the behavior when combining IN_CASE_INSENSITIVE with other operators.

These additions would provide more comprehensive coverage of the new feature and ensure its robustness across various scenarios.

packages/common/src/rule-engine/rules/schemas.ts (1)

87-91: LGTM! New case-insensitive operator added.

The addition of the IN_CASE_INSENSITIVE operator aligns with the PR objective and expands the rule engine's functionality. This allows for more flexible rule definitions, which is a valuable improvement.

Consider updating the documentation to include information about this new operator and its usage. This will help developers understand and utilize this new feature effectively.

services/workflows-service/src/notion/notion.service.ts (1)

95-97: LGTM! Consider adding a comment for consistency.

The addition of handling for the 'unique_id' field type is correct and consistent with the existing pattern in the method. It successfully extends the functionality to support this new Notion field type.

For consistency with other conditions, consider adding a brief comment explaining the 'unique_id' field type, similar to how other conditions are documented. This would improve code readability and maintainability. For example:

+    // Handle Notion's unique identifier field
     if (notionField.type === 'unique_id') {
       return notionField.unique_id.number;
     }
packages/common/CHANGELOG.md (1)

3-7: Improve the change description and fix grammatical issue.

The changelog entry is mostly correct, but there are a couple of minor improvements we can make:

  1. The description "In case insensitive risk rule engine operator" could be more informative. Consider expanding it to clarify what exactly changed.
  2. There's a minor grammatical issue: "case insensitive" should be hyphenated as "case-insensitive".

Consider updating the changelog entry as follows:

 ## 0.9.44

 ### Patch Changes

-- In case insensitive risk rule engine operator
++ Added case-insensitive operator to the risk rule engine

This change provides more context about what was added and fixes the hyphenation issue.

🧰 Tools
🪛 LanguageTool

[misspelling] ~7-~7: This word is normally spelled with a hyphen.
Context: ...mon ## 0.9.44 ### Patch Changes - In case insensitive risk rule engine operator ## 0.9.43 #...

(EN_COMPOUNDS_CASE_INSENSITIVE)

examples/headless-example/CHANGELOG.md (1)

3-10: LGTM! Consider adding a brief description of changes.

The changelog entry for version 0.3.55 correctly documents the updated dependencies. This is consistent with the overall changes in the pull request.

Consider adding a brief description of any notable changes or improvements introduced by these dependency updates. This can help users understand the impact of the new versions.

services/workflows-service/CHANGELOG.md (1)

7-7: Consider hyphenating "case-insensitive" for better readability.

The new feature description currently reads "In case insensitive risk rule engine operator". For improved clarity and adherence to common English conventions, consider hyphenating "case-insensitive":

- In case insensitive risk rule engine operator
+ In case-insensitive risk rule engine operator

This minor change enhances readability and follows standard spelling conventions for compound adjectives.

🧰 Tools
🪛 LanguageTool

[misspelling] ~7-~7: This word is normally spelled with a hyphen.
Context: ...ice ## 0.7.59 ### Patch Changes - In case insensitive risk rule engine operator - Updated dep...

(EN_COMPOUNDS_CASE_INSENSITIVE)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5448ecd and 5e26f8b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (27)
  • apps/backoffice-v2/CHANGELOG.md (1 hunks)
  • apps/backoffice-v2/package.json (2 hunks)
  • apps/kyb-app/CHANGELOG.md (1 hunks)
  • apps/kyb-app/package.json (2 hunks)
  • examples/headless-example/CHANGELOG.md (1 hunks)
  • examples/headless-example/package.json (2 hunks)
  • packages/common/CHANGELOG.md (1 hunks)
  • packages/common/package.json (1 hunks)
  • packages/common/src/rule-engine/operators/constants.ts (2 hunks)
  • packages/common/src/rule-engine/operators/enums.ts (2 hunks)
  • packages/common/src/rule-engine/operators/helpers.ts (18 hunks)
  • packages/common/src/rule-engine/operators/types.ts (2 hunks)
  • packages/common/src/rule-engine/rules/schemas.ts (2 hunks)
  • packages/workflow-core/CHANGELOG.md (1 hunks)
  • packages/workflow-core/package.json (2 hunks)
  • sdks/web-ui-sdk/CHANGELOG.md (1 hunks)
  • sdks/web-ui-sdk/package.json (2 hunks)
  • sdks/workflow-browser-sdk/CHANGELOG.md (1 hunks)
  • sdks/workflow-browser-sdk/package.json (2 hunks)
  • sdks/workflow-node-sdk/CHANGELOG.md (1 hunks)
  • sdks/workflow-node-sdk/package.json (2 hunks)
  • services/workflows-service/CHANGELOG.md (1 hunks)
  • services/workflows-service/package.json (2 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
  • services/workflows-service/src/notion/notion.service.ts (1 hunks)
  • services/workflows-service/src/rule-engine/rule-engine.service.intg.test.ts (1 hunks)
  • websites/docs/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (9)
  • apps/backoffice-v2/CHANGELOG.md
  • apps/kyb-app/CHANGELOG.md
  • packages/common/package.json
  • packages/workflow-core/CHANGELOG.md
  • sdks/web-ui-sdk/CHANGELOG.md
  • sdks/workflow-browser-sdk/CHANGELOG.md
  • sdks/workflow-node-sdk/CHANGELOG.md
  • sdks/workflow-node-sdk/package.json
  • services/workflows-service/prisma/data-migrations
🧰 Additional context used
🪛 LanguageTool
packages/common/CHANGELOG.md

[misspelling] ~7-~7: This word is normally spelled with a hyphen.
Context: ...mon ## 0.9.44 ### Patch Changes - In case insensitive risk rule engine operator ## 0.9.43 #...

(EN_COMPOUNDS_CASE_INSENSITIVE)

services/workflows-service/CHANGELOG.md

[misspelling] ~7-~7: This word is normally spelled with a hyphen.
Context: ...ice ## 0.7.59 ### Patch Changes - In case insensitive risk rule engine operator - Updated dep...

(EN_COMPOUNDS_CASE_INSENSITIVE)

🔇 Additional comments (29)
packages/common/src/rule-engine/operators/constants.ts (2)

14-14: LGTM: New import for IN_CASE_INSENSITIVE constant

The import of the IN_CASE_INSENSITIVE constant is consistent with the existing import style and naming conventions. This addition aligns with the PR objective of introducing a case-insensitive risk rule engine operator.


14-14: Summary: Successful implementation of IN_CASE_INSENSITIVE operator

The changes in this file successfully implement the new case-insensitive risk rule engine operator as described in the PR objectives. The additions are minimal, focused, and consistent with the existing code structure and conventions. These changes lay the groundwork for using the new operator in the rule engine, enhancing its flexibility as intended.

Also applies to: 30-30

packages/common/src/rule-engine/operators/enums.ts (1)

28-28: LGTM! Verify usage across the codebase.

The addition of OPERATION.IN_CASE_INSENSITIVE to the OPERATIONS array is correct and maintains consistency with the OPERATION object.

To ensure this change is properly integrated, let's verify its usage across the codebase:

✅ Verification successful

Verified: OPERATION.IN_CASE_INSENSITIVE is correctly integrated and used across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of the new IN_CASE_INSENSITIVE operation

# Test 1: Search for direct usage of IN_CASE_INSENSITIVE
echo "Searching for direct usage of IN_CASE_INSENSITIVE:"
rg "IN_CASE_INSENSITIVE" --type ts

# Test 2: Search for any switch statements or if-else chains that might need updating
echo "Searching for switch statements or if-else chains involving OPERATION:"
rg "switch.*OPERATION|if.*OPERATION" --type ts

# Test 3: Check for any documentation or comments that might need updating
echo "Checking for documentation or comments mentioning operations:"
rg "Available operations|Supported operations" --type ts

Length of output: 1600

packages/common/src/rule-engine/operators/types.ts (4)

11-13: LGTM! Good addition of type definitions.

The new TOperation and TOperator types provide improved type safety for the rule engine, aligning with the PR's objectives. This change enhances the overall type checking in the codebase.


Line range hint 1-31: Overall, the changes enhance the rule engine's flexibility.

The modifications to this file, including the new imports, type definitions, and the update to ConditionFn, align well with the PR's objective of introducing a new case-insensitive risk rule engine operator. These changes should improve the type safety and flexibility of the rule engine.

However, it's crucial to verify the impact of these changes, particularly the removal of OperationHelper and the update to ConditionFn, across the entire codebase to ensure no unintended side effects.


Line range hint 1-31: Verify impact of OperationHelper type removal.

The removal of the OperationHelper type and its related import suggests a change in how operations are handled. This might be related to the introduction of the new case-insensitive operator.

Please run the following script to check for any remaining usage of OperationHelper or OperationHelpers across the codebase:

#!/bin/bash
# Description: Check for usage of OperationHelper or OperationHelpers

echo "Searching for OperationHelper usage:"
rg "OperationHelper" --type ts

echo "\nSearching for OperationHelpers usage:"
rg "OperationHelpers" --type ts

If any usages are found, they may need to be updated or removed to align with this change.


28-31: LGTM! Verify usage across the codebase.

The update to ConditionFn type enhances its flexibility by allowing more specific type definitions. This aligns well with the PR's objective of improving the risk rule engine.

To ensure this change doesn't break existing code, please verify its usage across the codebase. Run the following script to check for potential issues:

services/workflows-service/src/rule-engine/rule-engine.service.intg.test.ts (2)

1-14: LGTM: Proper test setup and imports.

The test setup follows NestJS testing best practices. The import of RuleSet from @ballerine/common aligns with the PR objectives mentioning updates to this package.


33-36: LGTM: Appropriate test data for case insensitivity.

The formData object is well-structured to test the IN_CASE_INSENSITIVE operator. It correctly includes both single string and array scenarios with intentional case differences.

packages/common/src/rule-engine/rules/schemas.ts (2)

15-16: LGTM! Stylistic improvement in function definition.

The change from a traditional function declaration to an arrow function is a good stylistic choice that aligns with modern JavaScript practices. The functionality remains unchanged, maintaining the code's behavior while improving readability.


5-6: LGTM! Verify consistency of import changes across the project.

The consolidation of imports from @/rule-engine improves maintainability. However, ensure this change is consistent across the entire project to maintain architectural integrity.

Run the following script to verify the import changes:

Also applies to: 13-13

✅ Verification successful

Imports Consolidated Successfully

All old import patterns from '../operators/enums' and '../operators/schemas' have been removed. The new import pattern from '@/rule-engine' is consistently applied across the project.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of import changes for OPERATION and OPERATOR

# Test 1: Check for any remaining imports from '../operators/enums' or '../operators/schemas'
echo "Checking for old import patterns:"
rg -g '*.ts' -e "from '../operators/enums'" -e "from '../operators/schemas'"

# Test 2: Check for new import pattern
echo "Checking for new import pattern:"
rg -g '*.ts' -e "from '@/rule-engine'"

Length of output: 453

sdks/workflow-browser-sdk/package.json (1)

4-4: LGTM! Version and dependency updates are consistent.

The changes in this file are part of a coordinated update across the @ballerine ecosystem:

  1. Package version bumped from 0.6.55 to 0.6.56
  2. @ballerine/common dependency updated from 0.9.43 to 0.9.44
  3. @ballerine/workflow-core dependency updated from 0.6.55 to 0.6.56

These updates align with the overall changes mentioned in the pull request summary.

Let's verify if these version updates are consistent across the entire pull request:

Also applies to: 36-37

✅ Verification successful

Consistency Verified! All version and dependency updates are uniformly applied across the repository.

  • Verified "@ballerine/workflow-browser-sdk": "0.6.56" in multiple package.json files.
  • Verified "@ballerine/common": "0.9.44" in multiple package.json files.
  • Verified "@ballerine/workflow-core": "0.6.56" in multiple package.json files.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of version updates across the repository

# Test 1: Check for @ballerine/workflow-browser-sdk version
echo "Checking @ballerine/workflow-browser-sdk version:"
rg '"@ballerine/workflow-browser-sdk": "0\.6\.56"' -g '*.json'

# Test 2: Check for @ballerine/common version
echo "Checking @ballerine/common version:"
rg '"@ballerine/common": "0\.9\.44"' -g '*.json'

# Test 3: Check for @ballerine/workflow-core version
echo "Checking @ballerine/workflow-core version:"
rg '"@ballerine/workflow-core": "0\.6\.56"' -g '*.json'

# Note: If any of these searches return no results, it might indicate inconsistent updates

Length of output: 1368

sdks/web-ui-sdk/package.json (2)

24-24: LGTM: Version update is appropriate.

The package version has been incremented from 1.5.44 to 1.5.45, which is a patch version update. This aligns with semantic versioning principles and is consistent with the PR objectives mentioning updates across multiple packages.


99-99: LGTM: Dependency update looks good. Verify compatibility.

The @ballerine/common dependency has been updated from 0.9.43 to 0.9.44, which is consistent with the updates mentioned in the PR summary. This change aligns with the PR objectives of updating dependencies across multiple packages.

To ensure this update doesn't introduce any breaking changes, please run the following verification script:

apps/backoffice-v2/package.json (5)

3-3: LGTM: Version update is appropriate.

The minor version bump from 0.7.58 to 0.7.59 is consistent with the changes made in this update and follows semantic versioning principles.


54-54: LGTM: @ballerine/common dependency update is appropriate.

The patch version update of @ballerine/common from 0.9.43 to 0.9.44 is consistent with the other dependency updates in this PR and likely includes bug fixes or minor improvements.


57-57: LGTM: @ballerine/workflow-browser-sdk dependency update is appropriate.

The patch version update of @ballerine/workflow-browser-sdk from 0.6.55 to 0.6.56 is consistent with the other dependency updates in this PR and likely includes bug fixes or minor improvements.


58-58: LGTM: @ballerine/workflow-node-sdk dependency update is appropriate.

The patch version update of @ballerine/workflow-node-sdk from 0.6.55 to 0.6.56 is consistent with the other dependency updates in this PR and likely includes bug fixes or minor improvements.


3-3: Summary: All dependency updates and version bump are appropriate.

The changes in this file include:

  1. A minor version bump of the package itself (0.7.58 to 0.7.59)
  2. Patch updates to three @ballerine dependencies:
    • @ballerine/common (0.9.43 to 0.9.44)
    • @ballerine/workflow-browser-sdk (0.6.55 to 0.6.56)
    • @ballerine/workflow-node-sdk (0.6.55 to 0.6.56)

These updates are consistent with the PR objectives and the AI-generated summary. They reflect proper version management and are likely to include bug fixes or minor improvements across the @ballerine ecosystem.

Also applies to: 54-54, 57-58

services/workflows-service/package.json (5)

4-4: Version bump looks good.

The package version has been incremented from 0.7.58 to 0.7.59, which aligns with the addition of the new case-insensitive risk rule engine operator mentioned in the PR objectives.


52-52: Dependency update looks good. Verify consistency across the monorepo.

The @ballerine/workflow-node-sdk dependency has been updated from 0.6.55 to 0.6.56. This patch update is likely to contain bug fixes or minor improvements.

Please run the following script to ensure this update is consistent across the monorepo:

#!/bin/bash
# Description: Check for consistency of @ballerine/workflow-node-sdk version across the monorepo

echo "Checking @ballerine/workflow-node-sdk version consistency:"
grep -R '"@ballerine/workflow-node-sdk": "' . --include=package.json | grep -v node_modules

4-4: Summary of changes and final verification step.

All changes in this file look good:

  1. The package version has been bumped to 0.7.59.
  2. The following dependencies have been updated to their latest patch versions:
    • @ballerine/common
    • @ballerine/workflow-core
    • @ballerine/workflow-node-sdk

These updates are consistent with the PR objectives and the AI-generated summary.

As a final step, please run the following script to ensure all dependency versions are consistent and to verify that the package-lock.json file has been updated:

#!/bin/bash
# Description: Final verification of dependency versions and package-lock.json

echo "Checking all updated dependency versions:"
grep -R '"@ballerine/common": "' . --include=package.json | grep -v node_modules
grep -R '"@ballerine/workflow-core": "' . --include=package.json | grep -v node_modules
grep -R '"@ballerine/workflow-node-sdk": "' . --include=package.json | grep -v node_modules

echo "Verifying package-lock.json:"
grep -A 3 '"@ballerine/workflows-service":' package-lock.json

If all versions are consistent and the package-lock.json has been updated correctly, the changes are ready to be merged.

Also applies to: 50-52


51-51: Dependency update looks good. Verify consistency across the monorepo.

The @ballerine/workflow-core dependency has been updated from 0.6.55 to 0.6.56. This patch update is likely to contain bug fixes or minor improvements.

Please run the following script to ensure this update is consistent across the monorepo:


50-50: Dependency update looks good. Verify consistency across the monorepo.

The @ballerine/common dependency has been updated from 0.9.43 to 0.9.44. This patch update is likely to contain bug fixes or minor improvements.

Please run the following script to ensure this update is consistent across the monorepo:

services/workflows-service/CHANGELOG.md (1)

3-11: LGTM! New feature and dependency updates look good.

The changelog entry for version 0.7.59 includes a new feature and dependency updates:

  1. New feature: "In case insensitive risk rule engine operator"
    This feature enhances the risk rule engine by adding case-insensitive operations, which should improve flexibility in rule matching.

  2. Dependency updates:

    • @ballerine/common updated to 0.9.44
    • @ballerine/workflow-core updated to 0.6.56
    • @ballerine/workflow-node-sdk updated to 0.6.56

These changes are well-documented and follow the expected format for a changelog entry.

🧰 Tools
🪛 LanguageTool

[misspelling] ~7-~7: This word is normally spelled with a hyphen.
Context: ...ice ## 0.7.59 ### Patch Changes - In case insensitive risk rule engine operator - Updated dep...

(EN_COMPOUNDS_CASE_INSENSITIVE)

packages/common/src/rule-engine/operators/helpers.ts (4)

Line range hint 21-38: Update to BaseOperator Generics Enhances Type Safety

The change to BaseOperator now accepting separate TDataValue and TConditionValue generic parameters improves type specificity and flexibility across operator implementations. This enhances the clarity of data and condition value types in derived classes.


121-157: InCaseInsensitive Operator Implementation Looks Good

The new InCaseInsensitive operator correctly implements case-insensitive comparison for both single values and arrays. The approach of normalizing strings to lowercase ensures accurate comparisons regardless of case.


391-391: Export of IN_CASE_INSENSITIVE Operator Added

The export statement export const IN_CASE_INSENSITIVE = new InCaseInsensitive(); correctly exposes the new operator for use throughout the project.


Line range hint 107-118: Ensure Consistent Generic Parameters in Derived Classes

The In operator has been updated to extend BaseOperator<Primitive, Primitive[]>. Please verify that all instances where operators extend BaseOperator have been updated to reflect the new generic parameter structure to prevent potential type mismatches.

You can run the following script to identify any derived classes that may need updating:

examples/headless-example/package.json Show resolved Hide resolved
packages/workflow-core/package.json Show resolved Hide resolved
apps/kyb-app/package.json Show resolved Hide resolved
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 5e26f8b and 334cfbc.

📒 Files selected for processing (1)
  • services/workflows-service/src/rule-engine/core/test/rule-engine.unit.test.ts (1 hunks)
🧰 Additional context used

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

🧹 Outside diff range and nitpick comments (1)
services/workflows-service/src/rule-engine/core/test/rule-engine.unit.test.ts (1)

585-637: LGTM: Comprehensive tests added for IN_CASE_INSENSITIVE operator

The new test suite for the IN_CASE_INSENSITIVE operator is well-structured and covers both string and array properties, including positive and negative cases. This ensures the operator functions correctly for different data types and scenarios.

However, there's a minor issue in the test description:

On line 612, the test description "should correctly evaluate when using a string property" should be changed to "should correctly evaluate when using an array property" to accurately reflect the test case.

Consider applying this change:

-    it('should correctly evaluate when using a string property', () => {
+    it('should correctly evaluate when using an array property', () => {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 334cfbc and bd4e6da.

📒 Files selected for processing (2)
  • packages/common/src/rule-engine/operators/constants.ts (2 hunks)
  • services/workflows-service/src/rule-engine/core/test/rule-engine.unit.test.ts (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/common/src/rule-engine/operators/constants.ts
🧰 Additional context used
🔇 Additional comments (1)
services/workflows-service/src/rule-engine/core/test/rule-engine.unit.test.ts (1)

122-123: LGTM: Error message updated to include new operator

The error message has been correctly updated to include the new IN_CASE_INSENSITIVE operator in the list of expected operators. This change is consistent with the addition of the new operator to the system.

Also applies to: 128-128

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 (1)
services/workflows-service/src/rule-engine/core/test/rule-engine.unit.test.ts (1)

369-369: Clarify the purpose of "not in use" in the describe block title.

The describe block title includes "- not in use" which is confusing. If the operator is not in use, why are we testing it? Consider either removing the "not in use" suffix or adding a comment explaining why these tests exist for an unused operator.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bd4e6da and 39b6d1d.

📒 Files selected for processing (1)
  • services/workflows-service/src/rule-engine/core/test/rule-engine.unit.test.ts (4 hunks)
🧰 Additional context used
🔇 Additional comments (2)
services/workflows-service/src/rule-engine/core/test/rule-engine.unit.test.ts (2)

Line range hint 471-522: LGTM!

The NOT_EQUALS operator tests are well-structured and cover both positive and negative cases effectively.


Line range hint 523-584: LGTM!

The IN operator tests are comprehensive and cover both positive and negative cases effectively.

Comment on lines +585 to +637
describe('IN_CASE_INSENSITIVE operator', () => {
it('should correctly evaluate when using a string property', () => {
const ruleSetExample: RuleSet = {
operator: OPERATOR.AND,
rules: [
{
key: 'country',
operator: OPERATION.IN_CASE_INSENSITIVE,
value: ['us', 'ca'],
},
],
};

const data = { country: 'US' };

let validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');

data.country = 'Ca';
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');

data.country = 'GB';
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('FAILED');
});

it('should correctly evaluate when using a string property', () => {
const ruleSetExample: RuleSet = {
operator: OPERATOR.AND,
rules: [
{
key: 'countries',
operator: OPERATION.IN_CASE_INSENSITIVE,
value: ['us', 'ca'],
},
],
};

const data = { countries: ['US'] };

let validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');

data.countries = ['Ca'];
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');

data.countries = ['GB'];
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('FAILED');
});
});
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 duplicate and incorrect test descriptions.

The test implementation is thorough and covers both single string and array values effectively. However, there are issues with the test descriptions:

  1. Both tests have the same description: "should correctly evaluate when using a string property"
  2. The second test's description is incorrect as it tests array values, not string properties

Update the test descriptions to clearly differentiate their purposes:

-    it('should correctly evaluate when using a string property', () => {
+    it('should correctly evaluate case-insensitive matching for string values', () => {
       // ... first test implementation ...
     });

-    it('should correctly evaluate when using a string property', () => {
+    it('should correctly evaluate case-insensitive matching for array values', () => {
       // ... second test implementation ...
     });
📝 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
describe('IN_CASE_INSENSITIVE operator', () => {
it('should correctly evaluate when using a string property', () => {
const ruleSetExample: RuleSet = {
operator: OPERATOR.AND,
rules: [
{
key: 'country',
operator: OPERATION.IN_CASE_INSENSITIVE,
value: ['us', 'ca'],
},
],
};
const data = { country: 'US' };
let validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');
data.country = 'Ca';
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');
data.country = 'GB';
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('FAILED');
});
it('should correctly evaluate when using a string property', () => {
const ruleSetExample: RuleSet = {
operator: OPERATOR.AND,
rules: [
{
key: 'countries',
operator: OPERATION.IN_CASE_INSENSITIVE,
value: ['us', 'ca'],
},
],
};
const data = { countries: ['US'] };
let validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');
data.countries = ['Ca'];
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');
data.countries = ['GB'];
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('FAILED');
});
});
describe('IN_CASE_INSENSITIVE operator', () => {
it('should correctly evaluate case-insensitive matching for string values', () => {
const ruleSetExample: RuleSet = {
operator: OPERATOR.AND,
rules: [
{
key: 'country',
operator: OPERATION.IN_CASE_INSENSITIVE,
value: ['us', 'ca'],
},
],
};
const data = { country: 'US' };
let validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');
data.country = 'Ca';
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');
data.country = 'GB';
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('FAILED');
});
it('should correctly evaluate case-insensitive matching for array values', () => {
const ruleSetExample: RuleSet = {
operator: OPERATOR.AND,
rules: [
{
key: 'countries',
operator: OPERATION.IN_CASE_INSENSITIVE,
value: ['us', 'ca'],
},
],
};
const data = { countries: ['US'] };
let validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');
data.countries = ['Ca'];
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('PASSED');
data.countries = ['GB'];
validationResults = runRuleSet(ruleSetExample, data);
expect(validationResults[0]!.status).toBe('FAILED');
});
});

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.

1 participant