/// import events = require("events"); import { Core } from "../index"; /** * Use this object for representing a service in the application * A Service is a singleton in the application, that is init after all others services are created * * You can use a Service to create Listeners or implement shared behavior between others services * * @exports * @abstract * @class Service */ declare class Service extends events.EventEmitter { _webda: Core; _name: string; _params: any; _createException: string; _initTime: number; /** * * * @class Service * @param {Webda} webda - The main instance of Webda * @param {String} name - The name of the service * @param {Object} params - The parameters block define in the configuration file */ constructor(webda: Core, name: string, params: any); resolve(): void; /** * Convert an object to JSON using the Webda json filter * * @class Service * @param {Object} object - The object to export * @return {String} The export of the strip object ( removed all attribute with _ ) */ toPublicJSON(object: any): string; /** * Will be called after all the Services are created * * @param config for the host so you can add your own route here * @abstract */ init(): Promise; /** * Handle cleaning of params */ normalizeParams(): void; reinit(config: any): Promise; /** * For future use, while deploying this should be call so the service can create what it needs if necessary * * @abstract */ install(params: any): Promise; /** * For future use, while undeploying this should be call so the service can create what it needs if necessary * * @abstract */ uninstall(params: any): Promise; /** * Emit the event with data and wait for Promise to finish if listener returned a Promise */ emitSync(event: any, data: any): Promise; /** * Listen to an event as on(...) would do except that it will be asynchronous * @param event * @param callback * @param queue Name of queue to use, can be undefined, queue name are used to define differents priorities */ onAsync(event: any, callback: any, queue: any): void; /** * Return a webda service * @param service name to retrieve */ getService(service: string): Service; getTypedService(service: string): T; /** * Return the Modda definition if any * */ static getModda(): void; getName(): string; /** * Clean the service data, can only be used in test mode * * @abstract */ __clean(): Promise; /** * @private */ ___cleanData(): Promise; log(level: any, ...args: any[]): void; } export { Service };