json-rules-engine
Advanced tools
Comparing version 6.0.0-alpha-2 to 6.0.0-alpha-3
@@ -96,4 +96,2 @@ 'use strict'; | ||
if (!properties) throw new Error('Engine: addRule() requires options'); | ||
if (!Object.prototype.hasOwnProperty.call(properties, 'conditions')) throw new Error('Engine: addRule() argument requires "conditions" property'); | ||
if (!Object.prototype.hasOwnProperty.call(properties, 'event')) throw new Error('Engine: addRule() argument requires "event" property'); | ||
@@ -104,2 +102,5 @@ var rule = void 0; | ||
} else { | ||
if (!Object.prototype.hasOwnProperty.call(properties, 'event')) throw new Error('Engine: addRule() argument requires "event" property'); | ||
if (!Object.prototype.hasOwnProperty.call(properties, 'conditions')) throw new Error('Engine: addRule() argument requires "conditions" property'); | ||
rule = new _rule2.default(properties); | ||
@@ -280,6 +281,6 @@ } | ||
if (ruleResult.result) { | ||
almanac.factValue('success-events', { event: rule.event }); | ||
return Promise.all([_this2.emitAsync('success', rule.event, almanac, ruleResult), _this2.emitAsync(rule.event.type, rule.event.params, almanac, ruleResult)]); | ||
almanac.factValue('success-events', { event: ruleResult.event }); | ||
return Promise.all([_this2.emitAsync('success', ruleResult.event, almanac, ruleResult), _this2.emitAsync(ruleResult.event.type, ruleResult.event.params, almanac, ruleResult)]); | ||
} else { | ||
return _this2.emitAsync('failure', rule.event, almanac, ruleResult); | ||
return _this2.emitAsync('failure', ruleResult.event, almanac, ruleResult); | ||
} | ||
@@ -286,0 +287,0 @@ }); |
@@ -133,6 +133,6 @@ 'use strict'; | ||
if (!Object.prototype.hasOwnProperty.call(event, 'type')) throw new Error('Rule: setEvent() requires event object with "type" property'); | ||
this.event = { | ||
this.ruleEvent = { | ||
type: event.type | ||
}; | ||
if (event.params) this.event.params = event.params; | ||
if (event.params) this.ruleEvent.params = event.params; | ||
return this; | ||
@@ -161,3 +161,3 @@ } | ||
priority: this.priority, | ||
event: this.event, | ||
event: this.ruleEvent, | ||
name: this.name | ||
@@ -215,3 +215,3 @@ }; | ||
var ruleResult = new _ruleResult2.default(this.conditions, this.event, this.priority, this.name); | ||
var ruleResult = new _ruleResult2.default(this.conditions, this.ruleEvent, this.priority, this.name); | ||
@@ -218,0 +218,0 @@ /** |
{ | ||
"name": "json-rules-engine", | ||
"version": "6.0.0-alpha-2", | ||
"version": "6.0.0-alpha-3", | ||
"description": "Rules Engine expressed in simple json", | ||
@@ -83,3 +83,3 @@ "main": "dist/index.js", | ||
"clone": "^2.1.2", | ||
"eventemitter2": "6.4.3", | ||
"eventemitter2": "^6.4.3", | ||
"hash-it": "^4.0.5", | ||
@@ -86,0 +86,0 @@ "jsonpath-plus": "^4.0.0", |
74528
+ Addedeventemitter2@6.4.9(transitive)
- Removedeventemitter2@6.4.3(transitive)
Updatedeventemitter2@^6.4.3