import { IncomingMessage, ServerResponse } from 'node:http'; export declare function cacheBody(req: RequestFormData & { _bodyCached?: boolean; _dataChunks?: Uint8Array[]; }): void; // 更新请求类型定义 export interface RequestFormData extends IncomingMessage { files?: { fieldname: string; originalname: string; encoding: string; mimetype: string; buffer: Buffer; size: number; }[]; params?: Record; query?: Record; body?: Promise; } export interface MockServerResponse extends ServerResponse { req: IncomingMessage; send(chunk: T): ReturnType['end']>; } // 更新处理函数类型 export type ProxyFuncType = (req: RequestFormData, res: MockServerResponse) => void | Promise; // eslint-disable-next-line @typescript-eslint/no-explicit-any export type MockConfiguration = Record | null>; export type YApiOptionBySchema = { /** YApi host */ host: string; /** 接口id */ id: string; /** YApi开放接口token */ token: string; }; // eslint-disable-next-line @typescript-eslint/no-explicit-any type Any = any; /** * 通过 YApi 接口对应的响应JSON Schema生成默认的数据 * @param {YApiOptionBySchema} option Schema * @param {T} data data * @returns {Promise} mockData */ export declare const yApiSchemaMock: (option: YApiOptionBySchema, data?: T) => Promise; export type YApiOption = { /** YApi host */ host: string; /** YApi 项目ID */ projectId: number; /** 重写请求路径, 例如:'^/api/' */ pathRewrite: string; }; /** * 请求YApi高级mock接口数据 * @param {RequestFormData} req req * @param {YApiOption} yapi YApiOption * @returns {Promise} data */ export declare const yApiMock: (req: RequestFormData, yapi: YApiOption) => Promise; export declare function containMockUrl(url: string): string | undefined; type MockResponse = ServerResponse & { req: IncomingMessage; }; declare function mockPlugin(req: RequestFormData, res: MockResponse): boolean | MockResponse; declare const setupMock: () => typeof mockPlugin | void; export default setupMock;