@hey-api/client-axios
Advanced tools
Comparing version 0.2.10 to 0.2.11
@@ -59,6 +59,6 @@ import { CreateAxiosDefaults, AxiosStatic, AxiosResponse, AxiosError, AxiosInstance } from 'axios'; | ||
} | ||
interface RequestOptionsBase<ThrowOnError extends boolean> extends Config<ThrowOnError> { | ||
interface RequestOptionsBase<ThrowOnError extends boolean, Url extends string = string> extends Config<ThrowOnError> { | ||
path?: Record<string, unknown>; | ||
query?: Record<string, unknown>; | ||
url: string; | ||
url: Url; | ||
} | ||
@@ -94,6 +94,17 @@ type RequestResult<Data = unknown, TError = unknown, ThrowOnError extends boolean = boolean> = ThrowOnError extends true ? Promise<AxiosResponse<Data>> : Promise<(AxiosResponse<Data> & { | ||
}; | ||
type Options<T = unknown, ThrowOnError extends boolean = boolean> = T extends { | ||
type Options<T extends { | ||
url: string; | ||
} = { | ||
url: string; | ||
}, ThrowOnError extends boolean = boolean> = T extends { | ||
body?: any; | ||
} ? T extends { | ||
headers?: any; | ||
} ? OmitKeys<OptionsBase<ThrowOnError>, 'body' | 'headers'> & Omit<T, 'url'> : OmitKeys<OptionsBase<ThrowOnError>, 'body'> & Omit<T, 'url'> & Pick<OptionsBase<ThrowOnError>, 'headers'> : T extends { | ||
headers?: any; | ||
} ? OmitKeys<OptionsBase<ThrowOnError>, 'headers'> & Omit<T, 'url'> & Pick<OptionsBase<ThrowOnError>, 'body'> : OptionsBase<ThrowOnError> & Omit<T, 'url'>; | ||
type OptionsLegacyParser<T = unknown, ThrowOnError extends boolean = boolean> = T extends { | ||
body?: any; | ||
} ? T extends { | ||
headers?: any; | ||
} ? OmitKeys<OptionsBase<ThrowOnError>, 'body' | 'headers'> & T : OmitKeys<OptionsBase<ThrowOnError>, 'body'> & T & Pick<OptionsBase<ThrowOnError>, 'headers'> : T extends { | ||
@@ -105,2 +116,2 @@ headers?: any; | ||
export { type Client, type Config, type Options, type RequestOptionsBase, type RequestResult, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer }; | ||
export { type Client, type Config, type Options, type OptionsLegacyParser, type RequestOptionsBase, type RequestResult, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer }; |
{ | ||
"name": "@hey-api/client-axios", | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"description": "🚀 Axios client for `@hey-api/openapi-ts` codegen.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://heyapi.dev/", |
@@ -7,3 +7,3 @@ <div align="center"> | ||
[Live demo](https://stackblitz.com/edit/hey-api-client-axios-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fservices.gen.ts,src%2Fclient%2Ftypes.gen.ts,src%2FApp.tsx) | ||
[Live demo](https://stackblitz.com/edit/hey-api-client-axios-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts,src%2FApp.tsx) | ||
@@ -10,0 +10,0 @@ ## Features |
@@ -92,2 +92,3 @@ import type { AxiosError } from 'axios'; | ||
Options, | ||
OptionsLegacyParser, | ||
RequestOptionsBase, | ||
@@ -94,0 +95,0 @@ RequestResult, |
@@ -79,7 +79,9 @@ import type { | ||
export interface RequestOptionsBase<ThrowOnError extends boolean> | ||
extends Config<ThrowOnError> { | ||
export interface RequestOptionsBase< | ||
ThrowOnError extends boolean, | ||
Url extends string = string, | ||
> extends Config<ThrowOnError> { | ||
path?: Record<string, unknown>; | ||
query?: Record<string, unknown>; | ||
url: string; | ||
url: Url; | ||
} | ||
@@ -147,2 +149,17 @@ | ||
export type Options< | ||
T extends { url: string } = { url: string }, | ||
ThrowOnError extends boolean = boolean, | ||
> = T extends { body?: any } | ||
? T extends { headers?: any } | ||
? OmitKeys<OptionsBase<ThrowOnError>, 'body' | 'headers'> & Omit<T, 'url'> | ||
: OmitKeys<OptionsBase<ThrowOnError>, 'body'> & | ||
Omit<T, 'url'> & | ||
Pick<OptionsBase<ThrowOnError>, 'headers'> | ||
: T extends { headers?: any } | ||
? OmitKeys<OptionsBase<ThrowOnError>, 'headers'> & | ||
Omit<T, 'url'> & | ||
Pick<OptionsBase<ThrowOnError>, 'body'> | ||
: OptionsBase<ThrowOnError> & Omit<T, 'url'>; | ||
export type OptionsLegacyParser< | ||
T = unknown, | ||
@@ -149,0 +166,0 @@ ThrowOnError extends boolean = boolean, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
83446
734