/// import { EventEmitter } from 'events'; declare type TCRUDOperations = 'create' | 'read' | 'update' | 'delete'; declare type TActionMessage = 'init' | 'execute' | TCRUDOperations; interface IPromiseResponse { response: any; result: any; } interface IActionMessage { id: string; action: TActionMessage; functionsList?: Array; functionsName?: Array; name?: string; valueParams?: Array; timeout?: number; minWorkers?: number; } interface IFunction { code: string; params: Array<{ name: string; }>; name: string; returns: { name: string; }; } declare class ParserRunner extends EventEmitter { PATH_MASTER_WORKER: string; timeout: number; minWorkers: number; mainWorker: Worker; constructor(timeout: number, minWorkers: number); /** * OnError handler * * @param event */ onError: (event: ErrorEvent) => void; /** * OnMessage handler * * @param event */ onMessage: (event: MessageEvent) => void; /** * postMessage handler to the master worker. * * @param action - action message * @param resolve - cb to call to resolve the promise * @param reject - cb to call to reject the promise */ postMessage: (action: IActionMessage, resolve: Function, reject: Function) => void; /** * Parse a list of functions. * * @param functionsList */ parse: (functionsList: Array) => Promise; /** * execute a function base on the parameters * * @param name - function name * @param valueParams - function params value * @returns - result */ run: (name: string, valueParams: any) => Promise; /** * To perfome CRUD operations: CREATE ,READ ,UPDATE, DELETE * * @param functionsList - Array of functions to perform the CRUD ops on. * @param type - name of CRUD operation. * @returns */ crud: (functionsList: Array, type: TCRUDOperations) => Promise; /** * Create New Functions * * @param functionsList - list of functions to create * @returns */ create: (functionsList: Array) => Promise; /** * Update functions * * @param functionsList - list of functions to update * @returns */ update: (functionsList: Array) => Promise; /** * Delete functions * * @param functionsList - list of functions to delete * @returns */ delete: (functionsList: Array) => Promise; /** * Read Functions * * @param functionsList - list of functions to read * @returns */ read: (functionsList: Array) => Promise; } export default ParserRunner;