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: Add JP version and regex operations in jsonlogic #73

Merged
merged 1 commit into from
May 29, 2024

Conversation

ayushjain17
Copy link
Collaborator

Problem

Semantic versioning and regex related operations not present in jsonlogic

Solution

Add semver and regex operations in jsonlogic

@ayushjain17 ayushjain17 requested a review from a team as a code owner May 23, 2024 11:27
Copy link
Collaborator

@Datron Datron left a comment

Choose a reason for hiding this comment

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

Lack of support for android webviews means this won't work with SDK. Is that fine?

Cargo.toml Outdated
@@ -41,7 +41,7 @@ chrono = { version = "0.4.26", features = ["serde"] }
uuid = {version = "1.3.4", features = ["v4", "serde"]}
reqwest = { version = "0.11.18", features = ["json"]}
jsonschema = "~0.17"
jsonlogic = "0.5.1"
jsonlogic = { git = "https://github.com/juspay/jsonlogic_rs.git", rev = "4f1a8bcbb423c599eacf6c95ae17f5c0974bc071" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did we make this change? All other changes are in JS

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to add the same operators in the rust client

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are those added in this PR? If not, can we make this change when we add the operations

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

jsonLogic.add_operation("match", matchRegex);
jsonLogic.add_operation("semver_eq", compareSemanticIsEqual);
jsonLogic.add_operation("semver_gt", compareSemanticIsGreater);
jsonLogic.add_operation("semver_gteq", compareSemanticIsGreaterEqual);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
jsonLogic.add_operation("semver_gteq", compareSemanticIsGreaterEqual);
jsonLogic.add_operation("semver_ge", compareSemanticIsGreaterEqual);

jsonLogic.add_operation("semver_gt", compareSemanticIsGreater);
jsonLogic.add_operation("semver_gteq", compareSemanticIsGreaterEqual);
jsonLogic.add_operation("semver_lt", compareSemanticIsLesser);
jsonLogic.add_operation("semver_lteq", compareSemanticIsLesserEqual);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
jsonLogic.add_operation("semver_lteq", compareSemanticIsLesserEqual);
jsonLogic.add_operation("semver_le", compareSemanticIsLesserEqual);

const compareSemanticIsGreaterImp = function (version_a: string, version_b: string) {
return version_a.localeCompare(version_b, undefined, {numeric:true, sensitivity:'base'}) > 0;
const compareSemantic = function (version_a: string, version_b: string): number {
return version_a.localeCompare(version_b, undefined, { numeric: true, sensitivity: 'base' });
Copy link
Collaborator

Choose a reason for hiding this comment

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

the locales parameter and options parameter are not supported on android webview
Screenshot 2024-05-24 at 12 21 32 PM

jsonLogic.add_operation("match", matchRegex);
jsonLogic.add_operation("semver_eq", compareSemanticIsEqual);
jsonLogic.add_operation("semver_gt", compareSemanticIsGreater);
jsonLogic.add_operation("semver_gteq", compareSemanticIsGreaterEqual);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@ayushjain17 should we add one for between also ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@pratikmishra356 less than supports between operation as well, the behaviour of these version comparison operators are same as that of the normal comparison operators - wrt the number of operators

@ayushjain17 ayushjain17 force-pushed the jsExpClient branch 4 times, most recently from 627c264 to 83d34bf Compare May 24, 2024 10:31
@ayushjain17 ayushjain17 changed the title feat: Add semver and regex operations in jsonlogic feat: Add custom version and regex operations in jsonlogic May 24, 2024
@ayushjain17 ayushjain17 force-pushed the jsExpClient branch 3 times, most recently from 416da02 to 9bca3e5 Compare May 28, 2024 08:16
@Datron Datron self-requested a review May 28, 2024 08:25
@ayushjain17 ayushjain17 changed the title feat: Add custom version and regex operations in jsonlogic feat: Add JP version and regex operations in jsonlogic May 28, 2024
@ShubhranshuSanjeev ShubhranshuSanjeev added the priority Things that need immediate attention label May 28, 2024
@ayushjain17 ayushjain17 force-pushed the jsExpClient branch 5 times, most recently from a390d37 to f9f0e5a Compare May 28, 2024 12:52
@@ -41,7 +41,7 @@ chrono = { version = "0.4.26", features = ["serde"] }
uuid = {version = "1.3.4", features = ["v4", "serde"]}
reqwest = { version = "0.11.18", features = ["json"]}
jsonschema = "~0.17"
jsonlogic = "0.5.1"
jsonlogic = { git = "https://github.com/juspay/jsonlogic_rs.git", version = "0.5.2" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why add this without rust changes?

@ayushjain17 ayushjain17 merged commit eb14280 into main May 29, 2024
4 checks passed
@ayushjain17 ayushjain17 deleted the jsExpClient branch May 29, 2024 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority Things that need immediate attention
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants