import { type Polka } from 'polka'; import type { PolkaRes, ProviderHttpServer } from './server'; import { EventEmitterClass } from '../../core/eventEmitterClass'; import type { GlobalVendorArgs, BotCtxMiddlewareOptions, BotCtxMiddleware, ProviderEventTypes } from '../../types'; export type Vendor = {} & T; /** * Abstract class representing a ProviderClass. * @abstract * @extends EventEmitterClass * @implements ProviderHttpServer * @typeparam V - Type parameter for vendor. */ declare abstract class ProviderClass extends EventEmitterClass implements ProviderHttpServer { /** * Global arguments for vendor. * @abstract * @type {GlobalVendorArgs} */ abstract globalVendorArgs: GlobalVendorArgs; /** * Vendor instance. * @type {Vendor} */ vendor: Vendor; /** * HTTP server instance. * @type {Polka} */ server: Polka; /** * Bot name identifier. * @type {string} */ idBotName: string; /** * Context bot identifier. * @type {string} */ idCtxBot: string; /** * Constructs a ProviderClass instance. */ constructor(); /** * Abstract method to be executed before http initialization. * @protected * @abstract */ protected abstract beforeHttpServerInit(): void; /** * Abstract method to be executed after http initialization. * @protected * @abstract */ protected abstract afterHttpServerInit(): void; /** * Abstract method to define bus events. * @protected * @abstract * @returns {Array<{ event: string | number | symbol; func: Function }>} Array of event definitions. */ protected abstract busEvents(): Array<{ event: string | number | symbol; func: Function; }>; /** * Abstract method to initialize vendor. * @protected * @abstract * @returns {Promise} A promise indicating the completion of vendor initialization. */ protected abstract initVendor(): Promise; /** * Abstract method to send a message. * @public * @abstract * @template K * @param {string} userId - User identifier. * @param {*} message - Message to be sent. * @param {*} [args] - Additional arguments. * @returns {Promise} A promise resolving to the sent message. */ abstract sendMessage(userId: string, message: any, args?: any): Promise; /** * Abstract method to save a file. * @public * @abstract * @param {*} ctx - Context information. * @param {{ path: string }} [options] - File save options. * @returns {Promise} A promise resolving to the path of the saved file. */ abstract saveFile(ctx: any, options?: { path: string; }): Promise; /** * Listen on vendor events. * @protected * @param {{ on: any, [key: string]: any }} vendor - Vendor instance. * @returns {void} */ protected listenOnEvents(vendor: Vendor): void; /** * Start the HTTP server. * @public * @param {BotCtxMiddleware} vendor - Bot context middleware. * @param {(arg?: any) => void} [cb=() => null] - Callback function. * @returns {void} */ start(vendor: BotCtxMiddleware, cb?: (arg?: any) => void): void; /** * Stop the HTTP server. * @public * @returns {Promise} A promise indicating the completion of server shutdown. */ stop(): Promise; /** * Handle context middleware. * @public * @param {Function} ctxPolka - Context polka function. * @returns {Function} Request handler function. */ inHandleCtx, 'sendMessage'> & { provider: V; }>(ctxPolka: (bot: T, req: Request, res: PolkaRes) => Promise): (...args: any[]) => any; /** * Trigger send inside event * @param payload */ dispatchInside(payload: { body: string; name: string; from: string; }): void; /** * Get list of routes registered on the server. * @public * @param {Polka} app - Polka application instance. * @returns {string[]} Array of route definitions. */ getListRoutes(app: Polka): string[]; /** * Build the HTTP server. * @public * @returns {Polka} Polka instance. */ buildHTTPServer(): Polka; /** * Get instance of the vendor. * @public * @returns {Vendor} Vendor instance. */ getInstance(): Vendor; /** * Initialize HTTP server and vendor. * @public * @param {number} port - Port number. * @param {Pick} opts - Middleware options. * @returns {void} */ initAll: (port: number, opts: Pick) => void; } export { ProviderClass }; //# sourceMappingURL=provider.d.ts.map