export type Data = Record type DefaultFactory = (protocols: Data) => T | null | undefined type ProtocolConstructor = | { new (...args: any[]): T & object } | { (): T } | ProtocolMethod type ProtocolMethod = T extends (...args: any) => any ? { new (): TConstructor; (): T; readonly prototype: TConstructor } : never type ProtocolType = ProtocolConstructor | ProtocolConstructor[] type Validator = (value: any, params: Record) => void export interface ApiProtocol { [name: string]: ProtocolOptions } export interface ApiOptions { beforeAll?: () => void beforeSuccess?: () => void formatArgs?: { [name: string]: Validator } } export interface ProtocolOptions { name?: string type?: ProtocolType | true | null required?: boolean default?: D | DefaultFactory | null | undefined | object validator?(value: any): boolean | undefined | string }