import create, { ExecObject, ExecHandle, Router, ExecFunc } from './router.create'; import { ExtendedObject } from './info'; import Response from "./response"; export { create, ExecObject, ExecHandle, Router, ExecFunc }; declare type RouterList = { [key: string]: Router; }; /** 获取剥离 Promise 后的值 */ declare type PromiseValue = T extends Promise ? P : S extends true ? never : T; /** 获取剥离 Response 后的值 */ declare type ResponseValue = T extends Response ? P : S extends true ? never : T; declare type MergeObjectParam = A extends { [k in K]?: infer TA; } ? (B extends { [k in K]?: infer TB; } ? TA | TB : TA) : B extends { [k in K]?: infer TB; } ? TB : never; declare type MergeObject = A extends object ? (B extends object ? { [k in keyof A | keyof B]?: MergeObjectParam; } : A | B) : A | B; export declare type ExecValue> = E extends ExecFunc ? ResponseValue> : never; export declare type ExecQuery> = E extends ExecFunc ? Q : never; export declare type ExecBody> = E extends ExecFunc ? B : never; export declare type ExecData> = E extends ExecFunc ? D : never; export declare type ExecQueryData> = MergeObject, ExecData>; export declare type ExecBodyData> = MergeObject, ExecData>; export interface set { /** * 设置路由 * @param path 路径 * @param f 函数集合 * @param r 自定义处理器 */ (path: string, f: ExecObject, r?: ExecHandle): void; /** * 设置路由 * @param path 路径 * @param appId 应用Id * @param f 函数集合 * @param r 自定义处理器 */ (path: string, appId: string, f: ExecObject, r?: ExecHandle): void; } export interface remove { /** * 移除路由 * @param path 路径 * @param appId 应用Id */ (path: string, appId?: string): void; } export interface get { /** * 获取路由 * @param path 路径 * @param appId 应用Id */ (path: string, appId?: string): Router; } /** * 设置路由 * @param path 路径 * @param appId 应用Id * @param f 函数集合 * @param r 自定义处理器 */ export declare function set(this: RouterList | void, path: string, appId: string, f: ExecObject, r?: ExecHandle): void; /** * 设置路由 * @param path 路径 * @param f 函数集合 * @param r 自定义处理器 */ export declare function set(this: RouterList | void, path: string, f: ExecObject, r?: ExecHandle): void; /** * 移除路由 * @param path 路径 * @param appId 应用Id */ export declare function remove(this: RouterList | void, path: string, appId?: string): void; /** * 获取路由 * @param path 路径 * @param appId 应用Id */ export declare function get(this: RouterList | void, path: string, appId?: string): Router; interface RouterApi { /** 创建路由 */ create: create; /** 设置路由 */ set: set; /** 移除路由 */ remove: remove; /** 获取路由 */ get: get; } /** * 创建路由API * @param routers 默认的路由列表 */ declare function RouterApi(routers?: RouterList): RouterApi; export declare type api = RouterApi; export default RouterApi;