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

Jsonlogic import export improvement #1202

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Tupsu-jy
Copy link
Contributor

@Tupsu-jy Tupsu-jy commented Feb 5, 2025

Hello

I have previously mentioned my intention to refactor how JSONLogic import/export works. The main idea is to make everything work dynamically based on JSONLogic definitions found in the config, leveraging an expanded templateMatcher. My motivation was that the current implementation of JSONLogic import involves a lot of special-case logic (ie. arity etc) to recognize operators, that I found difficult to understand. I believe this new approach would make the import/export code more clear, maintainable, and less fragile while also making custom operators easier to implement. Also my previous contributions did not fully utilize the potential of the templateMatcher, and expanding its use felt relatively straightforward.

This branch is that idea mostly done. Both import and export just use the config jsonlogic definitions to figure out how to handle various operators.

You might notice from commits that I actually wrote this in December. Unfortunately I did not have time after that to really focus on this after that. As I see there are two main issues with this branch at the moment.

  1. A test (loads tree with func SUM_OF_MULTISELECT in LHS) is failing because, in this case, the expected field object (e.g., { "var": "fieldName" }) is replaced by the custom function SUM_OF_MULTISELECT within the "between" operator. The templateMatcher relies on finding a field object in a specific location, and I'm uncertain how to handle this discrepancy. Question: Is the test incorrect, or should the code be extended to handle operators like this?

  2. There is some issue with decompressing config. A test is failing and I have not really had time look into it.

Anyways, I have not really done anything with this since December, but if this approach seems useful I could probably finish it. Provided I get some pointers on how things are supposed to work regarding the whole sum_of_multiselect issue I mentioned. Mostly I just wanted to inform you that I made this in case you find it useful.

Copy link

codesandbox bot commented Feb 5, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

vercel bot commented Feb 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-awesome-query-builder-examples ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2025 2:02pm
react-awesome-query-builder-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2025 2:02pm
react-awesome-query-builder-sandbox-next ✅ Ready (Inspect) Visit Preview Feb 5, 2025 2:02pm

Copy link

codesandbox-ci bot commented Feb 5, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ce42cdb:

Sandbox Source
@react-awesome-query-builder/examples Configuration
@react-awesome-query-builder/sandbox Configuration
@react-awesome-query-builder/sandbox-simple Configuration
@react-awesome-query-builder/sandbox-next Configuration

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