index.d.ts 988 B

123456789101112131415161718192021222324
  1. import '../lib/polyfills/objectKeys';
  2. interface IMockData {
  3. payload: object;
  4. isSuccess: boolean;
  5. }
  6. declare type IMockFunction = (params: any) => Promise<any>;
  7. /**
  8. * 一旦调用 init,当前环境下的接口调用将会走 mock 的数据(可选择部分或者全部)
  9. * @memberof MockApi
  10. */
  11. export declare const init: (config?: {
  12. /** 初始化时配置的api,等同于 batchAppendMockApiResult */
  13. mockApiMap?: {
  14. [method: string]: IMockData | IMockFunction;
  15. } | undefined;
  16. /** 只有当配置了api才会走 mock */
  17. isOnlyMockWhenConfig?: boolean | undefined;
  18. } | undefined) => void;
  19. export declare const emitEvent: (eventName: string) => void;
  20. export declare const appendMockApiResult: (method: string, result: IMockFunction | IMockData, disableMockFilter?: ((params: any) => boolean) | undefined) => void;
  21. export declare const batchAppendMockApiResult: (mockApiMap: {
  22. [method: string]: IMockData | IMockFunction;
  23. }) => void;
  24. export {};