Open jeshuamaxey opened 10 months ago
Additionally, result
and factResult
are missing from RuleResult
's conditions
property.
I believe the ConditionProperties
interface is the right place to add them, i.e.
interface ConditionProperties {
fact: string;
operator: string;
value: { fact: string } | any;
path?: string;
priority?: number;
params?: Record<string, any>;
name?: string;
// the following properties are missing
result: boolean;
factResult?: any
}
In this example, the failures are filtered by the result
property and this causes compilation errors in TypeScript
https://github.com/CacheControl/json-rules-engine/blob/0de797ccddbe52d2d50e1a4f90db6f830b0ac92a/examples/09-rule-results.js#L48
RuleResult
has atoJSON()
method (source)The
RuleResult
interface declaration does not include this (source). Also, there is no class declaration for RuleResult.The impact of this issue is felt when handling rule results, in my case decomposing them from an EngineResult. I ran into the same problem outlined in https://github.com/CacheControl/json-rules-engine/issues/172 which was "resolved" with the introduction of the
toJSON
method toRuleResult
s. This resolution doesn't help if you're using typescript, as the compiler has no knowledge of this method.To make my code work around this, I've had to create a new
RuleResult
type in my code and extend it to include thetoJSON
method, which is a bit yuck.A good solution would include:
RuleResult
class declaration which includes thetoJSON()
methodRuleResultSerializable
type declaration (taking inspiration from the type declaration forRule
class declaration)Thanks