/** * @desc * * @使用场景 * * @coder.yang2010@gmail.com * @Date 2019/12/26 **/ import { AsyncSeriesHook, AsyncSeriesWaterfallHook, SyncHook } from "tapable"; import { IWebApiDefinded } from "moon-core/declarations/typings/api"; import { IFileSaveOptions } from "moon-core/declarations/typings/page"; import { IGenApiConfig } from "./index"; import ApiGroup from "moon-core/declarations/web-api/client/domain/api-group"; export interface IContext { moonConfig: IGenApiConfig; apiGroups?: ApiGroup[]; } export interface GenContext { config: IGenApiConfig; workDir: string; } export declare type ErrorMsg = { level: "warn" | "error"; message: string; }; /** * api可编译hook */ export default class ApiCompileHooks { init: AsyncSeriesHook; onError: AsyncSeriesHook; /** 编辑转换之前 */ loadApiGroup: AsyncSeriesWaterfallHook; /** 加载swagger JSON之后 */ loadSwagger: SyncHook<{ moonConfig: IGenApiConfig; swaggerJson?: any; }, any, any>; swagger2ApiGroup: AsyncSeriesWaterfallHook; /** 编辑转换之前 */ beforeCompile: SyncHook; /** 一组Api编辑转换之前 */ beforeGroupCompile: SyncHook; /** 单个api编译时 */ beforeApiCompile: SyncHook; /** 单个api request修改时 */ onRequestParam: SyncHook; /** 单个api response修改时 */ onResponseSchema: SyncHook; /** controller文件存储前 */ beforeApiSave: SyncHook; /** controller文件存储后 */ afterApiSave: SyncHook; afterGroupCompile: SyncHook; /** 编辑转换之后 */ afterCompile: SyncHook; beforeIndex: SyncHook; afterIndex: SyncHook; /** 结束后;*/ finish: SyncHook; }