Closed
Description
Summary:
I have an issue when serializing the rule result, namely the conditions inside this result.
Version
2.0.0
Example code
let engine = new Engine();
engine.addRule({
"priority": 4,
"event": {
"type": "something"
},
"conditions": {
"any": [{
"fact": "data",
"path": ".age",
"operator": "lessThan",
"value": 18
}]
}
});
engine.on("success", (event: any, almanac: any, result: any) => {
console.log(JSON.stringify(result))
})
engine.run({
data: {
age: 16
}
});
The console will show:
{
"conditions": "{\"priority\":1,\"any\":[\"{\\\"operator\\\":\\\"lessThan\\\",\\\"value\\\":18,\\\"fact\\\":\\\"data\\\",\\\"path\\\":\\\".age\\\"}\"]}",
"event": {
"type": "something"
},
"priority": 4,
"result": true
}
If I look into the debugger it looks fine:
Cause
I did not really dig into this, but based solely on the debugger contents, I guess you "reused" the Condition
class for the rule results (at least of the conditions inside it). The custom serialization of this class is most likely causing the issue. IMO, you should make a different "class" for the rule results (condition) object.
Metadata
Metadata
Assignees
Labels
No labels