Comparing version 0.0.9 to 0.1.0
{ | ||
"name": "aa-hooks", | ||
"version": "0.0.9", | ||
"version": "0.1.0", | ||
"description": "Library for working with autonomous agent events", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -10,6 +10,7 @@ | ||
- baseAaIs | ||
- responseKeyContains | ||
- responseContainsKey | ||
- responseKeyIs | ||
- responseKeyLessThan | ||
- responseKeyMoreThan | ||
- triggerDataExists | ||
- triggerDataContainsKey | ||
@@ -53,2 +54,3 @@ - triggerDataKeyIs | ||
.triggerDataContainsKey("drawer") | ||
.not.triggerDataContainsKey("decimals") | ||
... | ||
@@ -55,0 +57,0 @@ |
@@ -9,10 +9,20 @@ const dag = require('aabot/dag.js'); | ||
this.id = id; | ||
/** @private */ | ||
this.opposite = false; | ||
} | ||
get not() { | ||
this.opposite = true; | ||
return this; | ||
} | ||
#addFilter(id, func) { | ||
if (this.net.filters[id]) { | ||
this.net.filters[id].push(func); | ||
this.net.filters[id].push({ filter: func, opposite: this.opposite }); | ||
} else { | ||
this.net.filters[id] = [func]; | ||
this.net.filters[id] = [{ filter: func, opposite: this.opposite }]; | ||
} | ||
this.opposite = false; | ||
} | ||
@@ -137,3 +147,3 @@ | ||
*/ | ||
responseKeyContains(key) { | ||
responseContainsKey(key) { | ||
this.#addFilter(this.id, (res) => { | ||
@@ -189,2 +199,12 @@ const resVars = res?.response?.responseVars; | ||
triggerDataExists() { | ||
this.#addFilter(this.id, async (res) => { | ||
const payload = await this.#getPayloadByResponse(res); | ||
return !!Object.values(payload).length; | ||
}); | ||
return this; | ||
} | ||
/** | ||
@@ -191,0 +211,0 @@ * @param {string} key |
@@ -62,5 +62,6 @@ const { v4: uuidv4 } = require('uuid'); | ||
for (let filterIndex = 0; filterIndex < filters.length; filterIndex++) { | ||
const result = await filters[filterIndex](res); | ||
const { filter, opposite } = filters[filterIndex]; | ||
const result = await filter(res); | ||
if (!result) { | ||
if (opposite ? result : !result) { | ||
break; | ||
@@ -67,0 +68,0 @@ } else { |
@@ -7,2 +7,5 @@ export = HookController; | ||
id: any; | ||
/** @private */ | ||
private opposite; | ||
get not(): import("./hookController"); | ||
getTriggerUnit(trigger_unit: any): Promise<any>; | ||
@@ -28,3 +31,3 @@ /** | ||
*/ | ||
responseKeyContains(key: string): import("./hookController"); | ||
responseContainsKey(key: string): import("./hookController"); | ||
/** | ||
@@ -45,2 +48,3 @@ * @param {string} key | ||
responseKeyMoreThan(key: string, value: string | number): import("./hookController"); | ||
triggerDataExists(): import("./hookController"); | ||
/** | ||
@@ -47,0 +51,0 @@ * @param {string} key |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118416
583
228