formatRulesEngine()
Call Signature
formatRulesEngine(
rulesEngine:RulesEngineAny):string
Defined in: rules-engine/src/utils/formatRulesEngine/formatRulesEngine.ts:16
Parameters
| Parameter | Type |
|---|---|
rulesEngine | RulesEngineAny |
Returns
string
Call Signature
formatRulesEngine<
TResult>(rulesEngine:RulesEngineAny,options:FormatRulesEngineOptions& {rulesEngineProcessor:RulesEngineProcessor<TResult>; }):TResult
Defined in: rules-engine/src/utils/formatRulesEngine/formatRulesEngine.ts:17
Type Parameters
| Type Parameter | Default type |
|---|---|
TResult | unknown |
Parameters
| Parameter | Type |
|---|---|
rulesEngine | RulesEngineAny |
options | FormatRulesEngineOptions & { rulesEngineProcessor: RulesEngineProcessor<TResult>; } |
Returns
TResult
Call Signature
formatRulesEngine(
rulesEngine:RulesEngineAny,options:"json-rules-engine"|FormatRulesEngineOptions& {format:"json-rules-engine"; }):RuleProperties[]
Defined in: rules-engine/src/utils/formatRulesEngine/formatRulesEngine.ts:31
Generates an array of 'json-rules-engine' rules from a rules engine object. The array can be
the first argument to new Engine or looped to add the rules one at a time.
Parameters
| Parameter | Type |
|---|---|
rulesEngine | RulesEngineAny |
options | "json-rules-engine" | FormatRulesEngineOptions & { format: "json-rules-engine"; } |
Returns
RuleProperties[]
Examples
const engine = new Engine(formatRulesEngine(re, 'json-rules-engine'))
formatRulesEngine(re, 'json-rules-engine').forEach(rule => engine.addRule(rule))
Call Signature
formatRulesEngine(
rulesEngine:RulesEngineAny,options:"native"|FormatRulesEngineOptions& {format:"native"; }):RulesEngineEvaluator
Defined in: rules-engine/src/utils/formatRulesEngine/formatRulesEngine.ts:46
Compiles a rules engine object into an in-process evaluator: a function that, given a facts
object, returns the consequents of every condition that fires—in order, honoring the
evaluationMode. The evaluator has no runtime dependencies.
Parameters
| Parameter | Type |
|---|---|
rulesEngine | RulesEngineAny |
options | "native" | FormatRulesEngineOptions & { format: "native"; } |
Returns
Example
const evaluate = formatRulesEngine(re, 'native');
const firedConsequents = evaluate({ experience: 12 });
Call Signature
formatRulesEngine(
rulesEngine:RulesEngineAny,options:"rulepilot"|FormatRulesEngineOptions& {format:"rulepilot"; }):Rule
Defined in: rules-engine/src/utils/formatRulesEngine/formatRulesEngine.ts:62
Compiles a rules engine object into a single rulepilot
Rule whose ordered conditions reproduce the cascade, each paired with result: consequent.
RulePilot.evaluate returns the first matching condition's result, so this target models
single-outcome decisioning; cumulative evaluation mode throws.
Parameters
| Parameter | Type |
|---|---|
rulesEngine | RulesEngineAny |
options | "rulepilot" | FormatRulesEngineOptions & { format: "rulepilot"; } |
Returns
Rule
Example
const rule = formatRulesEngine(re, 'rulepilot');
const result = await RulePilot.evaluate(rule, { experience: 12 }, true);
Call Signature
formatRulesEngine(
rulesEngine:RulesEngineAny,options:"node-rules"|FormatRulesEngineOptions& {format:"node-rules"; }):Rule[]
Defined in: rules-engine/src/utils/formatRulesEngine/formatRulesEngine.ts:77
Compiles a rules engine object into an array of live
node-rules Rule objects, ready to register on a
RuleEngine. Each fired condition's consequent is collected onto fact.events.
Parameters
| Parameter | Type |
|---|---|
rulesEngine | RulesEngineAny |
options | "node-rules" | FormatRulesEngineOptions & { format: "node-rules"; } |
Returns
Rule[]
Example
const R = new RuleEngine(formatRulesEngine(re, 'node-rules'));
R.execute({ experience: 12 }, ({ events }) => console.log(events));
API documentation is generated from the latest commit on the main branch. It may be somewhat inconsistent with official releases of React Query Builder.