import type { Qs } from './utils/qs'; import type { GetPathValue, GetPath } from './utils/get'; import type { Options as PrettierOptions } from 'prettier'; export { PrettierOptions }; export type OpenApiComponentSchemas = Record; type BasicType = 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'enums' | 'null' | 'any'; export type OpenApiSchema = { type: 'ref'; ref: string; } | { type: BasicType | BasicType[]; description: string; required?: string[]; enum?: any[]; properties?: Record; additionalProperties?: boolean | OpenApiSchema; items?: OpenApiSchema; default?: any; nullable?: boolean; }; export type RefType = { type: 'ref'; ref: string; }; export type BaseContentType = { type: 'object'; contentType: string; description: string; schema: OpenApiSchema; }; export type OpenApiResponse = RefType | (BaseContentType & {}); export type OpenApiRequestBody = RefType | (BaseContentType & { required: boolean; }); export type OpenApiComponentResponses = Record; export type OpenApiComponentRequestBodies = Record; export type OpenApiComponentParameters = Record; export type OpenApiParameter = OpenApiParameterObject | OpenApiParameterRef; export type OpenApiParameterObject = { type: 'object'; in: 'query' | 'header' | 'path' | 'cookie'; name: string; description: string; required: boolean; schema: OpenApiSchema; }; export type OpenApiParameterRef = { type: 'ref'; ref: string; }; export type OpenApiComponents = { schemas: OpenApiComponentSchemas; parameters: OpenApiComponentParameters; requestBodies: OpenApiComponentRequestBodies; responses: OpenApiComponentResponses; }; export type OpenApiPaths = Record; export type OpenApiPath = { path: string; description: string; methods: Record; }; export type OpenApiDefine = { components: OpenApiComponents; paths: OpenApiPaths; }; export type ApiCommandArgsType = Command extends ApiCommand ? Args : never; export type ApiCommandResType = Command extends ApiCommand ? Res : never; export type ApiCommandSelectedResType = Command extends ApiCommand ? Selector extends string ? Selector extends GetPath> ? GetPathValue, Selector> : unknown : ApiCommandResType : never; export interface ApiClient { send>(command: Command): Promise>; sendAll, Commands extends [Command, ...Command[]] | { [key: string]: Command; }>(commands: Commands): Promise<{ [P in keyof Commands]: ApiCommandSelectedResType; }>; } export type Get = K extends keyof T ? T[K] : any; export type ApiCommand = { readonly method: `${Group}::${Path}::${Method}`; readonly args: Args; readonly mock?: Res; readonly selector: Selector; }; export type ApiConfig = { schemas: { [key in K]: string | { input: string; selector?: (o: any) => any; }; }; outDir: string; prettierConfig?: string | PrettierOptions; }; export type ApiConfigFn = () => ApiConfig | Promise>; export type ApiClientOptions = { remote: { [group in K]: ApiClientRemoteOptions; }; }; export type ApiClientRemoteOptions = { endpoint: string; override?: { qs?: Qs; fetch?: typeof fetch; Request?: typeof Request; }; handleRequest?: (request: Request) => Request | Promise; handleResponse?: (response: Response) => Response | Promise; validateData?: (url: string, data: any) => void; }; export interface OpenApiRequestBodyObject { contentType: string; } export interface OpenApiResponseObject { contentType: string; }