Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "aa-hooks", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Library for working with autonomous agent events", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -26,3 +26,3 @@ | ||
- isBounced | ||
- customHook | ||
- customFilter | ||
@@ -43,2 +43,4 @@ ## Examples | ||
console.error("Response unit: ", responseObj.response_unit); | ||
await hooks.addWatchedAddress("..."); // watch new agent | ||
} | ||
@@ -45,0 +47,0 @@ |
@@ -386,3 +386,3 @@ const dag = require('aabot/dag.js'); | ||
customHook(filter, metaKeys = []) { | ||
customFilter(filter, metaKeys = []) { | ||
@@ -389,0 +389,0 @@ this.#addFilter(this.type, async (res) => { |
@@ -57,3 +57,3 @@ const { v4: uuidv4 } = require('uuid'); | ||
async #findType(res) { | ||
async #findId(res) { | ||
let type; | ||
@@ -108,2 +108,10 @@ const entries = Object.entries(this.filters); | ||
/** | ||
* @param {string} address | ||
*/ | ||
async addWatchedAddress(address) { | ||
await dag.loadAA(address); | ||
await this.#watch(address); | ||
} | ||
async #responseHandler(res) { | ||
@@ -113,3 +121,3 @@ const unlock = await mutex.lock('responseHandler'); | ||
if (res.timestamp >= this.startTs) { | ||
const eventType = await this.#findType(res); | ||
const eventType = await this.#findId(res); | ||
@@ -116,0 +124,0 @@ if (eventType) { |
@@ -111,4 +111,4 @@ export = HookController; | ||
*/ | ||
customHook(filter: (response: response, meta: meta) => boolean, metaKeys?: Array<string>): import("./hookController"); | ||
customFilter(filter: (response: response, meta: meta) => boolean, metaKeys?: Array<string>): import("./hookController"); | ||
#private; | ||
} |
@@ -16,4 +16,4 @@ export class Hooks { | ||
* @callback eventCallback | ||
* @param {object} response | ||
* @param {object} trigger | ||
* @param {object} triggerUnit | ||
* @param {object} responseObj | ||
*/ | ||
@@ -24,5 +24,9 @@ /** | ||
*/ | ||
register(callback: (response: object, trigger: object) => any): HookController; | ||
register(callback: (triggerUnit: object, responseObj: object) => any): HookController; | ||
/** | ||
* @param {string} address | ||
*/ | ||
addWatchedAddress(address: string): Promise<void>; | ||
#private; | ||
} | ||
import HookController = require("./hookController"); |
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
117718
558
223