import type { paths } from './types.ts';
export type ParamDefs = Partial<Record<'query' | 'header' | 'path', string[]>>;
export type EndpointRequest<TResponse> = {
    ver: 'beta';
    method: 'get' | 'post' | 'patch' | 'delete' | 'put';
    path: string;
    paramDefs?: ParamDefs;
    params?: Record<string, any>;
    body?: any;
    responseType?: TResponse;
};
/**
 * @license (MIT OR CC0-1.0)
 * @source https://github.com/sindresorhus/type-fest/blob/570e27f8fdaee37ef5d5e0fbf241e0212ff8fc1a/source/simplify.d.ts
 */
export type Simplify<T> = {
    [KeyType in keyof T]: T[KeyType];
} & {};
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
export type ExtractParameters<T> = 'parameters' extends keyof T ? UnionToIntersection<{
    [K in keyof T['parameters']]-?: T['parameters'][K];
}[keyof T['parameters']]> : {};
export type ExtractRequestBody<T> = 'requestBody' extends keyof T ? 'content' extends keyof T['requestBody'] ? 'application/json' extends keyof T['requestBody']['content'] ? T['requestBody']['content']['application/json'] : {
    data: {
        [K in keyof T['requestBody']['content']]: T['requestBody']['content'][K];
    }[keyof T['requestBody']['content']];
} : 'application/json' extends keyof T['requestBody'] ? T['requestBody']['application/json'] : {
    data: {
        [K in keyof T['requestBody']]: T['requestBody'][K];
    }[keyof T['requestBody']];
} : {};
export type Operation<Url extends keyof paths, Method extends keyof paths[Url]> = {
    url: Url;
    method: Method;
    parameters: Simplify<ExtractParameters<paths[Url][Method]>>;
    body: ExtractRequestBody<Required<paths[Url][Method]>>;
    response: ExtractResponse<paths[Url][Method]>;
};
export type ReadOnlyMethods = 'get' | 'head';
export type SuccessStatuses = '2XX' | '200' | '201' | '202' | '204' | '205';
export type RedirectStatuses = '3XX' | '301' | '302';
export type EmptyResponseStatuses = '201' | '204' | '205';
export type KnownJsonResponseTypes = 'application/json' | 'application/octocat-stream' | 'application/scim+json' | 'text/html' | 'text/plain';
export type SuccessResponseDataType<Responses> = {
    [K in SuccessStatuses & keyof Responses]: GetContentKeyIfPresent<Responses[K]> extends never ? never : GetContentKeyIfPresent<Responses[K]>;
}[SuccessStatuses & keyof Responses];
export type RedirectResponseDataType<Responses> = {
    [K in RedirectStatuses & keyof Responses]: unknown;
}[RedirectStatuses & keyof Responses];
export type EmptyResponseDataType<Responses> = {
    [K in EmptyResponseStatuses & keyof Responses]: never;
}[EmptyResponseStatuses & keyof Responses];
export type GetContentKeyIfPresent<T> = 'content' extends keyof T ? DataType<T['content']> : DataType<T>;
export type DataType<T> = {
    [K in KnownJsonResponseTypes & keyof T]: T[K];
}[KnownJsonResponseTypes & keyof T];
export type ExtractResponse<R> = 'responses' extends keyof R ? SuccessResponseDataType<R['responses']> extends never ? RedirectResponseDataType<R['responses']> extends never ? EmptyResponseDataType<R['responses']> : RedirectResponseDataType<R['responses']> : SuccessResponseDataType<R['responses']> : unknown;
