
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
durable-rule-converter
Advanced tools
Convert jQuery QueryBuilder rules to Durables Rules Engine rule
This is a simple library to convert rules created from jQuery Query Builder to Durables Rules Engine
Dependencies
npm install durable-rule-converter
Navigate to https://querybuilder.js.org/demo.html for a demo or implement a rule builder using query builder. A sample of query builder is given below.
After creating your rule, click the 'Get Rules' button and you will get below JSON as the output. You can use your own custom implementation to get the output from query builder.
The output form Query Builder will be like below,
{
"condition": "AND",
"rules": [{
"id": "price",
"field": "price",
"type": "double",
"input": "number",
"operator": "less",
"value": 10.25
},
{
"condition": "OR",
"rules": [{
"id": "category",
"field": "category",
"type": "integer",
"input": "select",
"operator": "equal",
"value": 2
},
{
"id": "category",
"field": "category",
"type": "integer",
"input": "select",
"operator": "equal",
"value": 1
},
{
"condition": "AND",
"rules": [{
"id": "in_stock",
"field": "in_stock",
"type": "integer",
"input": "radio",
"operator": "equal",
"value": 1
}]
}
]
}
],
"valid": true
};
So, we have the query builder input and now we are going to convert it to a rule defenition which is the input for durable rules engine.
const RuleConverter = require('durable-rule-converter');
// output from jQuery Query Builder
var ruleInput = {
"condition": "AND",
"rules": [{
"id": "price",
"field": "price",
"type": "double",
"input": "number",
"operator": "less",
"value": 10.25
},
{
"condition": "OR",
"rules": [{
"id": "category",
"field": "category",
"type": "integer",
"input": "select",
"operator": "equal",
"value": 2
},
{
"id": "category",
"field": "category",
"type": "integer",
"input": "select",
"operator": "equal",
"value": 1
},
{
"condition": "AND",
"rules": [{
"id": "in_stock",
"field": "in_stock",
"type": "integer",
"input": "radio",
"operator": "equal",
"value": 1
}]
}
]
}
],
"valid": true
};
var output = RuleConverter(ruleInput);
And the output will be,
{
"m": {
"$and": [{
"$lt": {
"price": 10.25
}
}, {
"$or": [{
"$eq": {
"category": 2
}
}, {
"$eq": {
"category": 1
}
}, {
"$and": [{
"$eq": {
"in_stock": 1
}
}]
}]
}]
}
}
You can use the above definition in durable rules engine like below JSON format,
{
"myRule$state": {
"input": {
"t_0": {
"all": [<PUT-THE-ABOVE-OUTPUT-HERE>],
"to": "done",
"run": "done"
},
},
"done": {},
}
}
Reference for JSON rules for Durable Rules Engine,
Currently the library support below operations only,
This is the draft version of the library, which you can use for your basic needs if you are using Durable Rules Engine.
FAQs
Convert jQuery QueryBuilder rules to Durables Rules Engine rule
The npm package durable-rule-converter receives a total of 16 weekly downloads. As such, durable-rule-converter popularity was classified as not popular.
We found that durable-rule-converter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.