@run-iq/dsl-jsonlogic
v0.1.3
Published
JSONLogic DSL evaluator for PPE
Readme
@run-iq/dsl-jsonlogic
JSONLogic DSL evaluator for the PPE engine.
Install
npm install @run-iq/dsl-jsonlogicPeer dependency: @run-iq/core >= 0.1.0
Usage
import { PPEEngine } from '@run-iq/core';
import { JsonLogicEvaluator } from '@run-iq/dsl-jsonlogic';
const engine = new PPEEngine({
plugins: [myPlugin],
dsls: [new JsonLogicEvaluator()],
strict: true,
});Rules can then use jsonlogic conditions:
const rule = {
id: 'tax-high-income',
model: 'PROGRESSIVE_BRACKET',
condition: {
dsl: 'jsonlogic',
value: { '>': [{ var: 'grossSalary' }, 5_000_000] },
},
// ...
};API
JsonLogicEvaluator
Implements DSLEvaluator from @run-iq/core.
| Property | Value |
|---|---|
| dsl | "jsonlogic" |
| version | "1.0.0" |
evaluate(expression, context) — evaluates a JSONLogic expression against a data context and returns a boolean.
Timeout and sandboxing are handled by the core engine's PluginSandbox — this evaluator stays pure.
Requirements
- Node.js >= 20
@run-iq/core>= 0.1.0
License
MIT
