/// import * as winston from "winston"; import { XApi, Hook, ServiceResult } from "./types"; /** * @class XController */ export declare class XController implements XApi { [index: string]: any; XService: XService; XDb: any; constructor(props: { XService: XService; XDb: any; }); add(): Promise; find(): Promise; findAll(): Promise; update(): Promise; remove(): Promise; } /** * @class XService * @param {string} serviceDir The service directory path * @param {object} hooks Hook of serivces */ export default class XService { private _serviceDir; private _hooks; private _debug; private _tracer; private _bool; private _db; constructor(opts: { serviceDir: string; hooks?: Hook; debug?: boolean; logger?: winston.Winston; db?: any; }); /** * Execute a service with hooks * @param {string} sid Service ID. Ex: XUser.User.SignUp * @param {object} params Params of service function * * @see https://nodejs.org/api/process.html#process_process_hrtime_time */ run(sid: string, ...params: any[]): Promise; /** * Execute a service without hooks * @param {string} sid Service ID. Ex: XUser.User.SignUp * @param {array} params array of params. The ordering is IMPORTANT * @param {object} sResult */ exec(sid: string, params?: Array, sResult?: ServiceResult): Promise; /** * * @param {object} type Service type hook ("before", "after") or main ("handler") * @param sid Service Id, with hook is "*" * @param params Params of running service, will be passed to service hook * @param sResult Result of previous service * @param tracer Tracer information, contain traceId */ private _execHooks(type, sid, params?, sResult?, tracer?); /** * Retrieve controller and action from cache bool or from file * @param {string} sService The name of module * @param {string} sController The name of controller * @param {string} sAction The name of action * @returns {object} return instance of XController and the name of action should be run */ private _resolve(sService, sController, sAction, sid); /** * Parse SID string and return objec contain sService, SController and sAction * @param {object} sid Raw name of service, controller and action */ private _normalizeService(sid); /** * Ensure the hook always have global hook (before and after) * @param hooks The given hook */ private _normalizeHooks(hooks?); }