UNPKG

@ebonydevcopy/framework

Version:

A module-based NodeJS chatbot framework.

37 lines 1.25 kB
/** * ebony-framework * * @module utilities/actions * @author Christos Panagiotakopoulos <chrispanag@gmail.com> * @copyright Copyright(c) 2020 Christos Panagiotakopoulos * @license MIT * */ import User from '../models/User'; declare type Action<U extends User<any>> = (user: U, ...params: any) => Promise<any>; interface ActionsStore<U extends User<any>> { [key: string]: Action<U>; } export declare type ActionMiddleware<U extends User<any>> = (actionName: string, user: U, params: any[], next: () => any) => any; /** * The Actions Class */ export default class Actions<U extends User<any>> { private actions; private preMiddlewares; private postMiddlewares; constructor(preMiddlewares?: Array<ActionMiddleware<U>>, postMiddlewares?: Array<ActionMiddleware<U>>); addMiddleware(type: 'pre' | 'post', middleware: ActionMiddleware<U>): void; addMiddlewares(type: 'pre' | 'post', middlewares: Array<ActionMiddleware<U>>): void; /** * Adds actions to the bot */ importActions(actions?: ActionsStore<U>): void; private nextFactory; /** * Executes an action */ exec(actionName: string, user: U, ...params: any[]): Promise<void>; } export {}; //# sourceMappingURL=actions.d.ts.map