json-rules-engine
Advanced tools
Comparing version
{ | ||
"name": "json-rules-engine", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"description": "Rules Engine expressed in simple json", | ||
@@ -62,3 +62,3 @@ "main": "dist/index.js", | ||
"contributors": [ | ||
"Chris Pardy <chris.pardy@ownup.com>" | ||
"Chris Pardy <chris.pardy@gmail.com>" | ||
], | ||
@@ -96,4 +96,4 @@ "license": "ISC", | ||
"hash-it": "^6.0.0", | ||
"jsonpath-plus": "^10.0.0" | ||
"jsonpath-plus": "^10.1.0" | ||
} | ||
} |
@@ -156,8 +156,18 @@ export interface AlmanacOptions { | ||
export type RuleResultSerializable = Pick< | ||
Required<RuleResult>, | ||
"name" | "event" | "priority" | "result"> & { | ||
conditions: TopLevelConditionResultSerializable | ||
} | ||
export interface RuleResult { | ||
name: string; | ||
conditions: TopLevelCondition; | ||
conditions: TopLevelConditionResult; | ||
event?: Event; | ||
priority?: number; | ||
result: any; | ||
toJSON(): string; | ||
toJSON<T extends boolean>( | ||
stringify: T | ||
): T extends true ? string : RuleResultSerializable; | ||
} | ||
@@ -180,2 +190,10 @@ | ||
interface BooleanConditionResultProperties { | ||
result?: boolean | ||
} | ||
interface ConditionResultProperties extends BooleanConditionResultProperties { | ||
factResult?: unknown | ||
} | ||
interface ConditionProperties { | ||
@@ -191,3 +209,6 @@ fact: string; | ||
type ConditionPropertiesResult = ConditionProperties & ConditionResultProperties | ||
type NestedCondition = ConditionProperties | TopLevelCondition; | ||
type NestedConditionResult = ConditionPropertiesResult | TopLevelConditionResult; | ||
type AllConditions = { | ||
@@ -198,2 +219,5 @@ all: NestedCondition[]; | ||
}; | ||
type AllConditionsResult = AllConditions & { | ||
all: NestedConditionResult[] | ||
} & BooleanConditionResultProperties | ||
type AnyConditions = { | ||
@@ -204,3 +228,7 @@ any: NestedCondition[]; | ||
}; | ||
type AnyConditionsResult = AnyConditions & { | ||
any: NestedConditionResult[] | ||
} & BooleanConditionResultProperties | ||
type NotConditions = { not: NestedCondition; name?: string; priority?: number }; | ||
type NotConditionsResult = NotConditions & {not: NestedConditionResult} & BooleanConditionResultProperties; | ||
type ConditionReference = { | ||
@@ -211,2 +239,3 @@ condition: string; | ||
}; | ||
type ConditionReferenceResult = ConditionReference & BooleanConditionResultProperties | ||
export type TopLevelCondition = | ||
@@ -217,1 +246,11 @@ | AllConditions | ||
| ConditionReference; | ||
export type TopLevelConditionResult = | ||
| AllConditionsResult | ||
| AnyConditionsResult | ||
| NotConditionsResult | ||
| ConditionReferenceResult | ||
export type TopLevelConditionResultSerializable = | ||
| AllConditionsResult | ||
| AnyConditionsResult | ||
| NotConditionsResult | ||
| ConditionReference |
100585
1.35%1924
1.85%Updated